[
  {
    "path": ".github/FUNDING.yml",
    "content": "github: cincuranet\ncustom: https://firebirdsql.org/en/donate/\n"
  },
  {
    "path": ".github/workflows/ci.yml",
    "content": "name: CI\n\non: [push, pull_request]\n\nenv:\n  CONFIGURATION: Release\n  DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1\n\njobs:\n  ci:\n    runs-on: windows-2025\n    strategy:\n      fail-fast: false\n      matrix:\n        FIREBIRD_SELECTION: [FB30, FB40, FB50]\n        TEST_SUITE: [Tests-FirebirdClient-Default-Compression-CryptRequired, Tests-FirebirdClient-Default-NoCompression-CryptRequired, Tests-FirebirdClient-Default-Compression-CryptDisabled, Tests-FirebirdClient-Default-NoCompression-CryptDisabled, Tests-FirebirdClient-Embedded, Tests-EFCore, Tests-EFCore-Functional, Tests-EF6]\n    timeout-minutes: 120\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v5\n        \n      - name: .NET 10.0\n        uses: actions/setup-dotnet@v5\n        with:\n          dotnet-version: 10.0.x\n\n      - name: Build\n        run: |\n          try {\n            .\\build.ps1 -Configuration ${{ env.CONFIGURATION }}\n            exit $LASTEXITCODE\n          }\n          catch {\n            echo $_\n            exit 1\n          }\n        shell: powershell\n\n      - name: Tests\n        run: |\n          try {\n            $env:tests_firebird_dir = 'C:\\firebird'\n\n            .\\tests.ps1 -Configuration ${{ env.CONFIGURATION }} -FirebirdSelection ${{ matrix.FIREBIRD_SELECTION }} -TestSuite ${{ matrix.TEST_SUITE }}\n            exit $LASTEXITCODE\n          }\n          catch {\n            echo $_\n            exit 1\n          }\n        shell: powershell\n\n      - name: Publish Artifacts\n        uses: actions/upload-artifact@v4\n        with:\n          name: 'ci_${{ matrix.TEST_SUITE }}_${{ matrix.FIREBIRD_SELECTION }}_${{ env.CONFIGURATION }}'\n          path: '.\\\\out\\\\'\n"
  },
  {
    "path": ".gitignore",
    "content": "*.suo\n*.user\n*.lock.json\n.vs\nbin\nobj\nout/\n.idea\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing\n\nThanks for considering contributing. Here are some items to consider before starting (in no particular order).\n\n* Check [issues](https://github.com/FirebirdSQL/NETProvider/issues) if you want to start on something.\n* Before you start working on something announce your intention on the mailing list (or comment on the issue).\n* Issue only complete PRs (no WIPs).\n* Make sure your PR doesn't contain unneccessary changes (whitespaces, new lines, ...).\n* Follow existing code formatting/styling (even for new files).\n* Disclose AI usage.\n* Make sure you swept all corners (i.e. all build configurations are fine, works with all Firebird version, etc.).\n* Make sure your changes merge without conflicts.\n* Consider backward compatibility.\n* Don't be afraid to ask (i.e. backward compatibility).\n* Be prepared to do some changes after your PR is reviewed.\n* Consider whether your change is benefit for majority of users (opposite to only a small group).\n* All contributions are licensed under [_Initial Developer's Public License_](license.txt).\n"
  },
  {
    "path": "README.md",
    "content": "# Firebird .NET Data Provider\n\n## Documentation\n\n* [ADO.NET provider](docs/ado-net.md)\n* [Entity Framework 6 provider](docs/entity-framework-6.md)\n* [Entity Framework Core provider](docs/entity-framework-core.md)\n* [Services - Backup](docs/services-backup.md)\n* [Events](docs/events.md)\n* [ADO.NET - Schema](docs/ado-net-schema.md)\n* [Time zones](docs/time-zones.md)\n* [DECFLOAT datatype](docs/decfloat.md)\n* [INT128 datatype](docs/int128.md)\n* [Batching](docs/batching.md)\n\n## Packages\n\n| NuGet | Version | Downloads |\n|-------|---------|-----------|\n| [FirebirdSql.Data.FirebirdClient](https://www.nuget.org/packages/FirebirdSql.Data.FirebirdClient) | ![FirebirdSql.Data.FirebirdClient](https://img.shields.io/nuget/v/FirebirdSql.Data.FirebirdClient.svg) | ![FirebirdSql.Data.FirebirdClient](https://img.shields.io/nuget/dt/FirebirdSql.Data.FirebirdClient.svg) |\n| [EntityFramework.Firebird](https://www.nuget.org/packages/EntityFramework.Firebird) | ![EntityFramework.Firebird](https://img.shields.io/nuget/v/EntityFramework.Firebird.svg) | ![EntityFramework.Firebird](https://img.shields.io/nuget/dt/EntityFramework.Firebird.svg) |\n| [FirebirdSql.EntityFrameworkCore.Firebird](https://www.nuget.org/packages/FirebirdSql.EntityFrameworkCore.Firebird) | ![FirebirdSql.EntityFrameworkCore.Firebird](https://img.shields.io/nuget/v/FirebirdSql.EntityFrameworkCore.Firebird.svg) | ![FirebirdSql.EntityFrameworkCore.Firebird](https://img.shields.io/nuget/dt/FirebirdSql.EntityFrameworkCore.Firebird.svg) |\n\n## Resources\n\n* [Downloads](https://github.com/FirebirdSQL/NETProvider/releases)\n* [Issue tracker](https://github.com/FirebirdSQL/NETProvider/issues)\n* [Development mailing list](https://groups.google.com/forum/#!forum/firebird-net-provider)\n* [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/FirebirdSQL/NETProvider)\n\n## Builds\n\n[![GitHub Actions](https://github.com/FirebirdSQL/NETProvider/workflows/CI/badge.svg)](https://github.com/FirebirdSQL/NETProvider/actions)\n\n## Misc\n\n### Notable supporters\n\n* Sean Leyne (Broadview Software)\n* SMS-Timing\n\n### 3rd party code\n\n* For zlib compression the provider uses pieces from [DotNetZip](http://dotnetzip.codeplex.com/) library.\n* For RC4 encryption the provider uses pieces from [Bouncy Castle](https://www.bouncycastle.org/csharp/index.html) library.\n"
  },
  {
    "path": "build.ps1",
    "content": "param(\n\t[Parameter(Mandatory=$True)]$Configuration)\n\n$ErrorActionPreference = 'Stop'\n\n$baseDir = Split-Path -Parent $PSCommandPath\n\n. \"$baseDir\\include.ps1\"\n\n$outDir = \"$baseDir\\out\"\n$versionProvider = ''\n$versionEFCore = ''\n$versionEF6 = ''\n\nfunction Clean() {\n\tif (Test-Path $outDir) {\n\t\trm -Force -Recurse $outDir\n\t}\n\tmkdir $outDir | Out-Null\n}\n\nfunction Build() {\n\tdotnet clean \"$baseDir\\src\\NETProvider.slnx\" -c $Configuration -v m\n\tdotnet build \"$baseDir\\src\\NETProvider.slnx\" -c $Configuration -p:ContinuousIntegrationBuild=true -v m\n}\n\nfunction Versions() {\n\tfunction v($file) {\n\t\treturn (Get-Item $file).VersionInfo.ProductVersion -replace '(\\d+)\\.(\\d+)\\.(\\d+)(-[a-z0-9]+)?.*','$1.$2.$3$4'\n\t}\n\t$script:versionProvider = v $baseDir\\src\\FirebirdSql.Data.FirebirdClient\\bin\\$Configuration\\net10.0\\FirebirdSql.Data.FirebirdClient.dll\n\t$script:versionEFCore = v $baseDir\\src\\FirebirdSql.EntityFrameworkCore.Firebird\\bin\\$Configuration\\net10.0\\FirebirdSql.EntityFrameworkCore.Firebird.dll\n\t$script:versionEF6 = v $baseDir\\src\\EntityFramework.Firebird\\bin\\$Configuration\\net48\\EntityFramework.Firebird.dll\n}\n\nfunction NuGets() {\n\tcp $baseDir\\src\\FirebirdSql.Data.FirebirdClient\\bin\\$Configuration\\FirebirdSql.Data.FirebirdClient.$versionProvider.nupkg $outDir\n\tcp $baseDir\\src\\FirebirdSql.EntityFrameworkCore.Firebird\\bin\\$Configuration\\FirebirdSql.EntityFrameworkCore.Firebird.$versionEFCore.nupkg $outDir\n\tcp $baseDir\\src\\EntityFramework.Firebird\\bin\\$Configuration\\EntityFramework.Firebird.$versionEF6.nupkg $outDir\n\n\tcp $baseDir\\src\\FirebirdSql.Data.FirebirdClient\\bin\\$Configuration\\FirebirdSql.Data.FirebirdClient.$versionProvider.snupkg $outDir\n\tcp $baseDir\\src\\FirebirdSql.EntityFrameworkCore.Firebird\\bin\\$Configuration\\FirebirdSql.EntityFrameworkCore.Firebird.$versionEFCore.snupkg $outDir\n\tcp $baseDir\\src\\EntityFramework.Firebird\\bin\\$Configuration\\EntityFramework.Firebird.$versionEF6.snupkg $outDir\n}\n\nClean\nBuild\nVersions\nNuGets\n"
  },
  {
    "path": "docs/ado-net-schema.md",
    "content": "# ADO.NET - Schema\n\n### Steps\n\n* Install `FirebirdSql.Data.FirebirdClient` from NuGet.\n* Add `using FirebirdSql.Data.FirebirdClient;`.\n\n### Code\n\n```csharp\nusing (var connection = new FbConnection(\"database=localhost:demo.fdb;user=sysdba;password=masterkey\"))\n{\n\tconnection.Open();\n\n\tvar metadataCollections = connection.GetSchema();\n\tvar dataTypes = connection.GetSchema(DbMetaDataCollectionNames.DataTypes);\n\tvar dataSourceInformation = connection.GetSchema(DbMetaDataCollectionNames.DataSourceInformation);\n\tvar reservedWords = connection.GetSchema(DbMetaDataCollectionNames.ReservedWords);\n\tvar userTables = connection.GetSchema(\"Tables\", new string[] { null, null, null, \"TABLE\" });\n\tvar systemTables = connection.GetSchema(\"Tables\", new string[] { null, null, null, \"SYSTEM TABLE\" });\n\tvar tableColumns = connection.GetSchema(\"Columns\", new string[] { null, null, \"TableName\" });\n}\n```\n"
  },
  {
    "path": "docs/ado-net.md",
    "content": "# ADO.NET\n\n### Steps\n\n* Install `FirebirdSql.Data.FirebirdClient` from NuGet.\n* Add `using FirebirdSql.Data.FirebirdClient;`.\n* Basic classes are `FbConnection`, `FbTransaction`, `FbCommand` and `FbDataReader`.\n* Connection string can be built using `FbConnectionStringBuilder`.\n\n### Code\n\n```csharp\nusing (var connection = new FbConnection(\"database=localhost:demo.fdb;user=sysdba;password=masterkey\"))\n{\n\tconnection.Open();\n\tusing (var transaction = connection.BeginTransaction())\n\t{\n\t\tusing (var command = new FbCommand(\"select * from demo\", connection, transaction))\n\t\t{\n\t\t\tusing (var reader = command.ExecuteReader())\n\t\t\t{\n\t\t\t\twhile (reader.Read())\n\t\t\t\t{\n\t\t\t\t\tvar values = new object[reader.FieldCount];\n\t\t\t\t\treader.GetValues(values);\n\t\t\t\t\tConsole.WriteLine(string.Join(\"|\", values));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n```\n\n### Scripts\n\n```sql\ncreate table demo (id int primary key, foobar varchar(20) character set utf8);\n```\n\n```sql\ninsert into demo values (6, 'FooBar');\n```\n"
  },
  {
    "path": "docs/batching.md",
    "content": "# Batching\n\nBatching is supported for Firebird 4 (and above). The work is handled by `FbBatchCommand` class. It has similar API surface as `FbCommand`. The usage should feel familiar.\n\n### Specifics\n\nCalling the `ExecuteNonQuery`/`ExecuteNonQueryAsync` does not throw an exception, should the exception happen on server while processing the data. Instead the returned `FbBatchNonQueryResult` object should be used to check the status. The `EnsureSuccess` method or `AllSuccess` property can be used for global check. Further enumeration gives detailed information.\n\nProperties `MultiError`, `ReturnRecordsAffected` and `BatchBufferSize` allow for behavior fine-tuning (these represent `TAG_MULTIERROR`, `TAG_RECORD_COUNTS` and `TAG_BUFFER_BYTES_SIZE` in BPB).\n\nWhen dealing with huge batches of possible unlimited size, it's good to use `ComputeCurrentBatchSize`/`ComputeCurrentBatchSizeAsync` to make sure the batch is not over `BatchBufferSize`. However calling `ComputeCurrentBatchSize`/`ComputeCurrentBatchSizeAsync` is not cheap and should be handled accordingly.    \n\n### Limitations\n\nAt the moment batching is not supported for Firebird Embedded. The progress is tracked [here](https://github.com/FirebirdSQL/NETProvider/issues/1022).\n\nUsing (real) blobs as values is not supported. Regular `byte[]`, `string`, etc. values and the implicit conversions work just fine. The progress is tracked [here](https://github.com/FirebirdSQL/NETProvider/issues/1038). \n\n### Examples\n\nExamples can be found in [`FbBatchCommandTests`](../src/FirebirdSql.Data.FirebirdClient.Tests/FbBatchCommandTests.cs).\n"
  },
  {
    "path": "docs/decfloat.md",
    "content": "# DECFLOAT datatype\n\n`DECFLOAT(16)` and `DECFLOAT(34)` from Firebird 4 is handled by `FbDecFloat` type. `FbDecFloat` can be used as parameter value for `FbParameter`.\n\n### Examples\n\nExamples can be found in [`FbDecFloat16SupportTests`](../src/FirebirdSql.Data.FirebirdClient.Tests/FbDecFloat16SupportTests.cs) and [`FbDecFloat34SupportTests`](../src/FirebirdSql.Data.FirebirdClient.Tests/FbDecFloat34SupportTests.cs).\n"
  },
  {
    "path": "docs/entity-framework-6.md",
    "content": "# Entity Framework 6\n\n### Steps\n\n* Install `EntityFramework.Firebird` from NuGet.\n* Create `DbProviderFactories` record (see below).\n* Create configuration (see below).\n* Create your `DbContext`.\n* Firebird 2.5 and up is supported.\n\n### Code\n\n```csharp\nclass Program\n{\n\tstatic void Main(string[] args)\n\t{\n\t\tusing (var db = new MyContext(\"database=localhost:demo.fdb;user=sysdba;password=masterkey\"))\n\t\t{\n\t\t\tdb.Database.Log = Console.WriteLine;\n\n\t\t\tdb.Demos.ToList();\n\t\t}\n\t}\n}\n\nclass MyContext : DbContext\n{\n\tpublic MyContext(string connectionString)\n\t\t: base(new FbConnection(connectionString), true)\n\t{ }\n\n\tpublic DbSet<Demo> Demos { get; set; }\n\n\tprotected override void OnModelCreating(DbModelBuilder modelBuilder)\n\t{\n\t\tbase.OnModelCreating(modelBuilder);\n\n\t\tmodelBuilder.Properties()\n\t\t\t.Configure(x => x.HasColumnName(x.ClrPropertyInfo.Name.ToUpper()));\n\n\t\tvar demoConf = modelBuilder.Entity<Demo>();\n\t\tdemoConf.ToTable(\"DEMO\");\n\t}\n}\n\nclass Demo\n{\n\tpublic int Id { get; set; }\n\tpublic string FooBar { get; set; }\n}\n```\n\n### DbProviderFactories\n\n.NET Framework:\n```xml\n<system.data>\n\t<DbProviderFactories>\n\t\t<remove invariant=\"FirebirdSql.Data.FirebirdClient\" />\n\t\t<add name=\"FirebirdClient\" description=\"FirebirdClient\" invariant=\"FirebirdSql.Data.FirebirdClient\" type=\"FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient\" />\n\t</DbProviderFactories>\n</system.data>\n```\n\n.NET Core/.NET 5+:\n```csharp\nSystem.Data.Common.DbProviderFactories.RegisterFactory(FbProviderServices.ProviderInvariantName, FirebirdClientFactory.Instance);\n```\n\n### Configuration\n\n.NET Framework:\n```xml\n<configSections>\n\t<section name=\"entityFramework\" type=\"System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" requirePermission=\"false\" />\n</configSections>\n<entityFramework>\n\t<defaultConnectionFactory type=\"EntityFramework.Firebird.FbConnectionFactory, EntityFramework.Firebird\" />\n\t<providers>\n\t\t<provider invariantName=\"FirebirdSql.Data.FirebirdClient\" type=\"EntityFramework.Firebird.FbProviderServices, EntityFramework.Firebird\" />\n\t</providers>\n</entityFramework>\n```\n\n.NET Core/.NET 5+:\n```csharp\npublic class Conf : DbConfiguration\n{\n\tpublic Conf()\n\t{\n\t\tSetProviderServices(FbProviderServices.ProviderInvariantName, FbProviderServices.Instance);\n\t}\n}\n```\n\n### Scripts\n\n```sql\ncreate table demo (id int primary key, foobar varchar(20) character set utf8);\n```\n\n```sql\ninsert into demo values (6, 'FooBar');\n```\n"
  },
  {
    "path": "docs/entity-framework-core.md",
    "content": "# Entity Framework Core 8.x\n\n* Install `FirebirdSql.EntityFrameworkCore.Firebird` from NuGet.\n* Create your `DbContext`.\n* Call `UseFirebird` in `OnConfiguring`.\n* Firebird 3 and up is supported.\n\n### Code\n\n```csharp\nclass Program\n{\n\tstatic void Main(string[] args)\n\t{\n\t\tusing (var db = new MyContext(\"database=localhost:demo.fdb;user=sysdba;password=masterkey\"))\n\t\t{\n\t\t\tdb.Demos.ToList();\n\t\t}\n\t}\n}\n\nclass MyContext : DbContext\n{\n\tstatic readonly ILoggerFactory MyLoggerFactory = LoggerFactory.Create(builder => { builder.AddConsole(); });\n\n\treadonly string _connectionString;\n\n\tpublic MyContext(string connectionString)\n\t{\n\t\t_connectionString = connectionString;\n\t}\n\n\tpublic DbSet<Demo> Demos { get; set; }\n\n\tprotected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)\n\t{\n\t\tbase.OnConfiguring(optionsBuilder);\n\n\t\toptionsBuilder\n\t\t\t.UseLoggerFactory(MyLoggerFactory)\n\t\t\t.UseFirebird(_connectionString);\n\t}\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder)\n\t{\n\t\tbase.OnModelCreating(modelBuilder);\n\n\t\tvar demoConf = modelBuilder.Entity<Demo>();\n\t\tdemoConf.Property(x => x.Id).HasColumnName(\"ID\");\n\t\tdemoConf.Property(x => x.FooBar).HasColumnName(\"FOOBAR\");\n\t\tdemoConf.ToTable(\"DEMO\");\n\t}\n}\n\nclass Demo\n{\n\tpublic int Id { get; set; }\n\tpublic string FooBar { get; set; }\n}\n```\n\n### Scripts\n\n```sql\ncreate table demo (id int primary key, foobar varchar(20) character set utf8);\n```\n\n```sql\ninsert into demo values (6, 'FooBar');\n```\n"
  },
  {
    "path": "docs/events.md",
    "content": "# Events\n\n### Steps\n\n* Install `FirebirdSql.Data.FirebirdClient` from NuGet.\n* Add `using FirebirdSql.Data.FirebirdClient;`.\n\n### Code\n\n```csharp\nusing (var events = new FbRemoteEvent(\"database=localhost:demo.fdb;user=sysdba;password=masterkey\"))\n{\n\tevents.RemoteEventCounts += (sender, e) => Console.WriteLine($\"Event: {e.Name} | Counts: {e.Counts}\");\n\tevents.RemoteEventError += (sender, e) => Console.WriteLine($\"ERROR: {e.Error}\");\n\tevents.QueueEvents(\"EVENT1\", \"EVENT2\", \"EVENT3\", \"EVENT4\");\n\tConsole.WriteLine(\"Listening...\");\n\tConsole.ReadLine();\n}\n```\n"
  },
  {
    "path": "docs/int128.md",
    "content": "# INT128 datatype\n\n`INT128` from Firebird 4 is handled by regular .NET `BigInteger` type. `BigInteger` can be used as parameter value for `FbParameter`.\n\n### Examples\n\nExamples can be found in [`FbInt128SupportTests`](../src/FirebirdSql.Data.FirebirdClient.Tests/FbInt128SupportTests.cs).\n"
  },
  {
    "path": "docs/services-backup.md",
    "content": "# Services - Backup\n\n### Steps\n\n* Install `FirebirdSql.Data.FirebirdClient` from NuGet.\n* Add `using FirebirdSql.Data.Services;`.\n\n### Code\n\n```csharp\nvar backup = new FbBackup(\"database=localhost:demo.fdb;user=sysdba;password=masterkey\");\nbackup.BackupFiles.Add(new FbBackupFile(@\"C:\\backup.fbk\"));\n//backup.Options = ...\nbackup.Verbose = true;\nbackup.ServiceOutput += (sender, e) => Console.WriteLine(e.Message);\nbackup.Execute();\n```\n\n### More\n* `FbRestore`\n* `FbStreamingBackup`\n* `FbStreamingRestore`"
  },
  {
    "path": "docs/time-zones.md",
    "content": "# Time zones\n\nTime zones from Firebird 4 are handled by `FbZonedDateTime` and `FbZonedTime` types respectively. Given the lack of proper support for time zones in .NET (especially cross platform), these types provide the building blocks for developer to work with time zones using some library (i.e. _NodaTime_). Both `FbZonedDateTime` and `FbZonedTime` can be used as parameter value for `FbParameter`.\n\n### Examples\n\nExamples can be found in [`FbTimeZonesSupportTests`](../src/FirebirdSql.Data.FirebirdClient.Tests/FbTimeZonesSupportTests.cs).\n"
  },
  {
    "path": "header.ps1",
    "content": "$LicenseHeader = @\"\n/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\"@\n\n$baseDir = Split-Path -Parent $PSCommandPath\n\ngci $baseDir -Recurse -Filter *.cs | %{\n\t$content = gc $_.FullName -Encoding UTF8\n\t$newContent = @()\n\t\n\t$started = $false\n\tforeach ($line in $content) {\n\t\tif ($line.StartsWith('//$Authors')) {\n\t\t\t$started = $true\n\t\t\t$line = $LicenseHeader + \"`r`n`r`n\" + $line\n\t\t}\n\t\tif ($started) {\n\t\t\t$newContent += $line\n\t\t}\t\t\n\t}\n\tif (!$started) {\n\t\t#echo $_.FullName\n\t\treturn\n\t}\n\n\tsc $_.FullName $newContent -Encoding UTF8\n}"
  },
  {
    "path": "include.ps1",
    "content": "function Check-ExitCode() {\n\t$exitCode = $LASTEXITCODE\n\tif ($exitCode -ne 0) {\n\t\techo \"Non-zero ($exitCode) exit code. Exiting...\"\n\t\texit $exitCode\n\t}\n}"
  },
  {
    "path": "license.txt",
    "content": "Initial Developer's Public License Version 1.0\r\n\r\n1. Definitions\r\n\r\n1.0 \"Commercial Use\" means distribution or otherwise making the Covered Code available to a third party.\r\n\r\n1.1 \"Contributor\" means each entity that creates or contributes to the creation of Modifications.\r\n\r\n1.2 \"Contributor Version\" means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor.\r\n\r\n1.3. \"Covered Code\" means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof.\r\n\r\n1.4. \"Electronic Distribution Mechanism\" means a mechanism generally accepted in the software development community for the electronic transfer of data.\r\n\r\n1.5. \"Executable\" means Covered Code in any form other than Source Code.\r\n\r\n1.6. \"Initial Developer\" means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A.\r\n\r\n1.7. \"Larger Work\" means a work which combines Covered Code or portions thereof with code not governed by the terms of this License.\r\n\r\n1.8. \"License\" means this document.\r\n\r\n1.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.\r\n\r\n1.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:\r\n\r\nAny addition to or deletion from the contents of a file containing Original Code or previous Modifications.\r\n\r\nAny new file that contains any part of the Original Code or previous Modifications.\r\n\r\n1.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.\r\n\r\n1.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.\r\n\r\n1.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.\r\n\r\n1.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.\r\n\r\n2. Source Code License.\r\n\r\n2.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:\r\n\r\n(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\r\n\r\n(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).\r\n\r\n(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.\r\n\r\nd) Notwithstanding Section 2.1(b) above, no patent license is granted:\r\n\r\n1) for code that You delete from the Original Code;\r\n\r\n2) separate from the Original Code; or\r\n\r\n3) for infringements caused by:\r\n\r\ni) the modification of the Original Code or\r\n\r\nii) the combination of the Original Code with other software or devices.\r\n\r\n2.2. Contributor Grant. Subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license\r\n\r\n(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\r\n\r\n(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).\r\n\r\n(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.\r\n\r\n(d) Notwithstanding Section 2.2(b) above, no patent license is granted:\r\n\r\n1) for any code that Contributor has deleted from the Contributor Version;\r\n\r\n2) separate from the Contributor Version;\r\n\r\n3) for infringements caused by: i) third party modifications of Contributor Version or\r\n\r\nii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or\r\n\r\n4) under Patent Claims infringed by Covered Code in the absence of Modifications made by that Contributor.\r\n\r\n3. Distribution Obligations.\r\n\r\n3.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.\r\n\r\n3.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.\r\n\r\n3.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\r\n\r\n(a) the Source Code, and\r\n\r\n(b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code.\r\n\r\n3.4. Intellectual Property Matters\r\n\r\na) 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.\r\n\r\n(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.\r\n\r\n(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.\r\n\r\n3.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.\r\n\r\n3.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.\r\n\r\n3.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.\r\n\r\n4. Inability to Comply Due to Statute or Regulation.\r\n\r\nIf 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:\r\n\r\n(a) comply with the terms of this License to the maximum extent possible; and\r\n\r\n(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.\r\n\r\n5. Application of this License.\r\n\r\nThis License applies to code to which the Initial Developer has attached the notice in Exhibit A and to related Covered Code.\r\n\r\n6. Versions of the License.\r\n\r\n6.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.\r\n\r\n6.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.\r\n\r\n6.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\r\n\r\n(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\r\n\r\n(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.)\r\n\r\n6.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:\r\n\r\n1) The license is published by the Initial Developer of this code. Only the Initial Developer can modify the terms applicable to Covered Code.\r\n\r\n2) 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 the Initial Developer's Public License and must include a description of changes from the Initial Developer's Public License.\r\n\r\n3) The name of the license in Exhibit A is the \"Initial Developer's Public License\".\r\n\r\n4) The reference to an alternative license in Exhibit A has been removed .\r\n\r\n5) Amendments I, II, III, V, and VI have been deleted.\r\n\r\n6) Exhibit A, Netscape Public License has been deleted\r\n\r\n7. DISCLAIMER OF WARRANTY.\r\n\r\nCOVERED 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.\r\n\r\n8. TERMINATION.\r\n\r\n8.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.\r\n\r\n8.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:\r\n\r\n(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:\r\n\r\n(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\r\n\r\n(ii) withdraw Your litigation claim with respect to the Contributor Version against such Participant.\r\n\r\nIf 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.\r\n\r\n(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.\r\n\r\n8.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.\r\n\r\n8.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.\r\n\r\n9. LIMITATION OF LIABILITY.\r\n\r\nUNDER 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.\r\n\r\n10. U.S. GOVERNMENT END USERS.\r\n\r\nThe 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.\r\n\r\n11. MISCELLANEOUS.\r\n\r\nThis 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.\r\n\r\n12. RESPONSIBILITY FOR CLAIMS.\r\n\r\nAs 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.\r\n\r\n13. MULTIPLE-LICENSED CODE.\r\n\r\nInitial 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.\r\n\r\nEXHIBIT A -Initial Developer's Public License.\r\n\r\nThe 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 from the Firebird Project website, at http://www.firebirdsql.org/en/initial-developer-s-public-license-version-1-0/\r\n\r\nSoftware 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.\r\n\r\nThe Original Code is ______________________________________.\r\n\r\nThe Initial Developer of the Original Code is ________________________.\r\n\r\nPortions created by ______________________\r\nare Copyright (C) ______ _______________________.\r\n\r\nAll Rights Reserved.\r\n\r\nContributor(s): ______________________________________. \r\n"
  },
  {
    "path": "src/.editorconfig",
    "content": "root = true\n\n[*]\nindent_style = tab\nindent_size = 4\ntrim_trailing_whitespace = true\n\n[*.cs]\ndotnet_sort_system_directives_first = true\ndotnet_separate_import_directive_groups = false\ncsharp_style_implicit_object_creation_when_type_is_apparent = false\ncsharp_prefer_simple_using_statement = false"
  },
  {
    "path": "src/Directory.Build.props",
    "content": "<Project>\n\t<Import Project=\"Versions.props\" />\n\t<PropertyGroup>\n\t\t<LangVersion>latest</LangVersion>\n\t\t<DebugType>portable</DebugType>\n\t</PropertyGroup>\n\t<PropertyGroup>\n\t\t<Company>FirebirdSQL</Company>\n\t\t<Product>NETProvider</Product>\n\t\t<Authors>FirebirdSQL</Authors>\n\t\t<PackageProjectUrl>http://www.firebirdsql.org/en/net-provider/</PackageProjectUrl>\n\t\t<PackageIconUrl>https://raw.githubusercontent.com/FirebirdSQL/NETProvider/master/firebird-logo.png</PackageIconUrl>\n\t\t<PackageIcon>firebird-logo.png</PackageIcon>\n\t\t<RepositoryUrl>https://github.com/FirebirdSQL/NETProvider</RepositoryUrl>\n\t\t<RepositoryType>git</RepositoryType>\n\t\t<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>\n\t\t<MinClientVersion>3.6</MinClientVersion>\n\t\t<IncludeSymbols>true</IncludeSymbols>\n\t\t<SymbolPackageFormat>snupkg</SymbolPackageFormat>\n\t\t<PackageLicenseFile>license.txt</PackageLicenseFile>\n\t</PropertyGroup>\n\t<PropertyGroup>\n\t\t<CopyrightEndYear>2026</CopyrightEndYear>\n\t</PropertyGroup>\n\n\t<!-- SourceLink -->\n\t<PropertyGroup Condition=\"'$(SkipSourceLink)'!='true'\">\n\t\t<PublishRepositoryUrl>true</PublishRepositoryUrl>\n\t\t<EmbedUntrackedSources>true</EmbedUntrackedSources>\n\t</PropertyGroup>\n\t<ItemGroup Condition=\"'$(SkipSourceLink)'!='true'\">\n\t\t<PackageReference Include=\"Microsoft.SourceLink.GitHub\" Version=\"8.0.0\">\n\t\t\t<PrivateAssets>all</PrivateAssets>\n\t\t\t<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>\n\t\t</PackageReference>\n\t</ItemGroup>\n</Project>\n"
  },
  {
    "path": "src/EntityFramework.Firebird/App.config.install.xdt",
    "content": "﻿<configuration xmlns:xdt=\"http://schemas.microsoft.com/XML-Document-Transform\">\n\t<entityFramework>\n\t\t<defaultConnectionFactory xdt:Transform=\"Remove\" />\n\t\t<defaultConnectionFactory type=\"EntityFramework.Firebird.FbConnectionFactory, EntityFramework.Firebird\" xdt:Transform=\"Insert\" />\n\t\t<providers>\n\t\t\t<provider invariantName=\"FirebirdSql.Data.FirebirdClient\" type=\"EntityFramework.Firebird.FbProviderServices, EntityFramework.Firebird\" xdt:Transform=\"InsertIfMissing\" xdt:Locator=\"Match(invariantName)\" />\n\t\t</providers>\n\t</entityFramework>\n</configuration>\n"
  },
  {
    "path": "src/EntityFramework.Firebird/DefaultFbMigrationSqlGeneratorBehavior.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\n\nnamespace EntityFramework.Firebird;\n\npublic class DefaultFbMigrationSqlGeneratorBehavior : IFbMigrationSqlGeneratorBehavior\n{\n\tpublic virtual IEnumerable<string> CreateIdentityForColumn(string columnName, string tableName)\n\t{\n\t\tvar identitySequenceName = CreateIdentitySequenceName(columnName, tableName);\n\t\tusing (var writer = FbMigrationSqlGenerator.SqlWriter())\n\t\t{\n\t\t\twriter.WriteLine(\"EXECUTE BLOCK\");\n\t\t\twriter.WriteLine(\"AS\");\n\t\t\twriter.WriteLine(\"BEGIN\");\n\t\t\twriter.Indent++;\n\t\t\twriter.Write(\"if (not exists(select 1 from rdb$generators where rdb$generator_name = '\");\n\t\t\twriter.Write(identitySequenceName);\n\t\t\twriter.Write(\"')) then\");\n\t\t\twriter.WriteLine();\n\t\t\twriter.WriteLine(\"begin\");\n\t\t\twriter.Indent++;\n\t\t\twriter.Write(\"execute statement 'create sequence \");\n\t\t\twriter.Write(identitySequenceName);\n\t\t\twriter.Write(\"';\");\n\t\t\twriter.WriteLine();\n\t\t\twriter.Indent--;\n\t\t\twriter.WriteLine(\"end\");\n\t\t\twriter.Indent--;\n\t\t\twriter.Write(\"END\");\n\t\t\tyield return writer.ToString();\n\t\t}\n\n\t\tusing (var writer = FbMigrationSqlGenerator.SqlWriter())\n\t\t{\n\t\t\twriter.Write(\"CREATE OR ALTER TRIGGER \");\n\t\t\twriter.Write(FbMigrationSqlGenerator.Quote(CreateTriggerName(columnName, tableName)));\n\t\t\twriter.Write(\" ACTIVE BEFORE INSERT ON \");\n\t\t\twriter.Write(FbMigrationSqlGenerator.Quote(tableName));\n\t\t\twriter.WriteLine();\n\t\t\twriter.WriteLine(\"AS\");\n\t\t\twriter.WriteLine(\"BEGIN\");\n\t\t\twriter.Indent++;\n\t\t\twriter.Write(\"if (new.\");\n\t\t\twriter.Write(FbMigrationSqlGenerator.Quote(columnName));\n\t\t\twriter.Write(\" is null) then\");\n\t\t\twriter.WriteLine();\n\t\t\twriter.WriteLine(\"begin\");\n\t\t\twriter.Indent++;\n\t\t\twriter.Write(\"new.\");\n\t\t\twriter.Write(FbMigrationSqlGenerator.Quote(columnName));\n\t\t\twriter.Write(\" = next value for \");\n\t\t\twriter.Write(identitySequenceName);\n\t\t\twriter.Write(\";\");\n\t\t\twriter.WriteLine();\n\t\t\twriter.Indent--;\n\t\t\twriter.WriteLine(\"end\");\n\t\t\twriter.Indent--;\n\t\t\twriter.Write(\"END\");\n\t\t\tyield return writer.ToString();\n\t\t}\n\t}\n\n\tpublic virtual IEnumerable<string> DropIdentityForColumn(string columnName, string tableName)\n\t{\n\t\tvar triggerName = CreateTriggerName(columnName, tableName);\n\t\tusing (var writer = FbMigrationSqlGenerator.SqlWriter())\n\t\t{\n\t\t\twriter.WriteLine(\"EXECUTE BLOCK\");\n\t\t\twriter.WriteLine(\"AS\");\n\t\t\twriter.WriteLine(\"BEGIN\");\n\t\t\twriter.Indent++;\n\t\t\twriter.Write(\"if (exists(select 1 from rdb$triggers where rdb$trigger_name = '\");\n\t\t\twriter.Write(triggerName);\n\t\t\twriter.Write(\"')) then\");\n\t\t\twriter.WriteLine();\n\t\t\twriter.WriteLine(\"begin\");\n\t\t\twriter.Indent++;\n\t\t\twriter.Write(\"execute statement 'drop trigger \");\n\t\t\twriter.Write(FbMigrationSqlGenerator.Quote(triggerName));\n\t\t\twriter.Write(\"';\");\n\t\t\twriter.WriteLine();\n\t\t\twriter.Indent--;\n\t\t\twriter.WriteLine(\"end\");\n\t\t\twriter.Indent--;\n\t\t\twriter.Write(\"END\");\n\t\t\tyield return writer.ToString();\n\t\t}\n\t}\n\n\tprotected virtual string CreateTriggerName(string columnName, string tableName)\n\t{\n\t\treturn string.Format(\"ID_{0}_{1}\", tableName, columnName);\n\t}\n\n\tprotected virtual string CreateIdentitySequenceName(string columnName, string tableName)\n\t{\n\t\treturn \"GEN_IDENTITY\";\n\t}\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/EntityFramework.Firebird.csproj",
    "content": "﻿<Project Sdk=\"Microsoft.NET.Sdk\">\n\t<PropertyGroup>\n\t\t<TargetFrameworks>net48;netstandard2.1</TargetFrameworks>\n\t\t<AssemblyName>EntityFramework.Firebird</AssemblyName>\n\t\t<RootNamespace>EntityFramework.Firebird</RootNamespace>\n\t\t<SignAssembly>true</SignAssembly>\n\t\t<AssemblyOriginatorKeyFile>Properties\\EntityFramework.Firebird.snk</AssemblyOriginatorKeyFile>\n\t\t<GenerateAssemblyInfo>true</GenerateAssemblyInfo>\n\t\t<GeneratePackageOnBuild>true</GeneratePackageOnBuild>\n\t</PropertyGroup>\n\t<PropertyGroup>\n\t\t<Version>$(EF6ProviderVersion)</Version>\n\t\t<AssemblyTitle>NETProvider - Entity Framework Provider</AssemblyTitle>\n\t\t<Copyright>(c) 2014-$(CopyrightEndYear)</Copyright>\n\t</PropertyGroup>\n\t<PropertyGroup>\n\t\t<PackageId>EntityFramework.Firebird</PackageId>\n\t\t<Title>Firebird Entity Framework Provider</Title>\n\t\t<PackageDescription>The Entity Framework provider for Firebird enables you to develop .NET applications that connect to the Firebird database using Entity Framework.</PackageDescription>\n\t\t<PackageTags>firebird firebirsql firebirdclient entityframewor adonet database</PackageTags>\n\t</PropertyGroup>\n\t<PropertyGroup Condition=\"'$(Configuration)'=='Release'\">\n\t\t<DefineConstants>EF6;TRACE</DefineConstants>\n\t</PropertyGroup>\n\t<PropertyGroup Condition=\"'$(Configuration)'=='Debug'\">\n\t\t<DefineConstants>EF6;DEBUG;TRACE</DefineConstants>\n\t</PropertyGroup>\n\t<ItemGroup>\n\t\t<None Remove=\"Resources\\ProviderManifest.xml\" />\n\t\t<None Remove=\"Resources\\StoreSchemaDefinition.ssdl\" />\n\t\t<None Remove=\"Resources\\StoreSchemaDefinitionVersion3.ssdl\" />\n\t\t<None Remove=\"Resources\\StoreSchemaMapping.msl\" />\n\t\t<None Remove=\"Resources\\StoreSchemaMappingVersion3.msl\" />\n\t</ItemGroup>\n\t<ItemGroup>\n\t\t<EmbeddedResource Include=\"Resources\\ProviderManifest.xml\" />\n\t\t<EmbeddedResource Include=\"Resources\\StoreSchemaDefinition.ssdl\" />\n\t\t<EmbeddedResource Include=\"Resources\\StoreSchemaDefinitionVersion3.ssdl\" />\n\t\t<EmbeddedResource Include=\"Resources\\StoreSchemaMapping.msl\" />\n\t\t<EmbeddedResource Include=\"Resources\\StoreSchemaMappingVersion3.msl\" />\n\t</ItemGroup>\n\t<ItemGroup>\n\t\t<None Update=\"App.config.install.xdt\" Pack=\"true\" PackagePath=\"content\" />\n\t\t<None Update=\"Web.config.install.xdt\" Pack=\"true\" PackagePath=\"content\" />\n\t\t<None Include=\"..\\..\\license.txt\" Pack=\"true\" PackagePath=\"\" />\n\t\t<None Include=\"..\\..\\firebird-logo.png\" Pack=\"true\" PackagePath=\"\" />\n\t</ItemGroup>\n\t<ItemGroup>\n\t\t<PackageReference Include=\"EntityFramework\" Version=\"$(EF6ReferencePackageVersion)\" />\n\t\t<PackageReference Include=\"FirebirdSql.Data.FirebirdClient\" Version=\"$(EF6ReferenceProviderVersion)\" />\n\t</ItemGroup>\n\t<ItemGroup Condition=\"'$(TargetFramework)'=='net48'\">\n\t\t<Reference Include=\"System.Configuration\" />\n\t\t<Reference Include=\"Microsoft.CSharp\" />\n\t</ItemGroup>\n\t<ItemGroup Condition=\"'$(TargetFramework)'=='netstandard2.1'\">\n\t</ItemGroup>\n</Project>\n"
  },
  {
    "path": "src/EntityFramework.Firebird/FbConnectionFactory.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Configuration;\nusing System.Data.Common;\nusing System.Data.Entity.Infrastructure;\nusing System.Linq;\n\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace EntityFramework.Firebird;\n\npublic class FbConnectionFactory : IDbConnectionFactory\n{\n\tpublic DbConnection CreateConnection(string nameOrConnectionString)\n\t{\n\t\tif (nameOrConnectionString == null)\n\t\t\tthrow new ArgumentNullException(nameof(nameOrConnectionString));\n\n\t\tif (nameOrConnectionString.Contains('='))\n\t\t{\n\t\t\treturn new FbConnection(nameOrConnectionString);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tvar configuration = ConfigurationManager.ConnectionStrings[nameOrConnectionString];\n\t\t\tif (configuration == null)\n\t\t\t\tthrow new ArgumentException(\"Specified connection string name cannot be found.\");\n\t\t\treturn new FbConnection(configuration.ConnectionString);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/FbMigrationSqlGenerator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Collections.ObjectModel;\nusing System.Data.Common;\nusing System.Data.Entity;\nusing System.Data.Entity.Core.Common;\nusing System.Data.Entity.Core.Common.CommandTrees;\nusing System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;\nusing System.Data.Entity.Core.Metadata.Edm;\nusing System.Data.Entity.Infrastructure.DependencyResolution;\nusing System.Data.Entity.Migrations.Model;\nusing System.Data.Entity.Migrations.Sql;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing EntityFramework.Firebird.SqlGen;\nusing FirebirdSql.Data.Common;\n\nnamespace EntityFramework.Firebird;\n\npublic class FbMigrationSqlGenerator : MigrationSqlGenerator\n{\n\treadonly IFbMigrationSqlGeneratorBehavior _behavior;\n\n\tstring _migrationsHistoryTableName;\n\n\tpublic FbMigrationSqlGenerator(IFbMigrationSqlGeneratorBehavior behavior = null)\n\t{\n\t\t_behavior = behavior ?? new DefaultFbMigrationSqlGeneratorBehavior();\n\t}\n\n\tpublic override IEnumerable<MigrationStatement> Generate(IEnumerable<MigrationOperation> migrationOperations, string providerManifestToken)\n\t{\n\t\tInitializeProviderServices(providerManifestToken);\n\n\t\tvar lastOperation = migrationOperations.Last();\n\t\tvar historyOperation = lastOperation is UpdateDatabaseOperation updateDatabaseOperation\n\t\t\t? updateDatabaseOperation.Migrations.First().Operations.OfType<HistoryOperation>().First()\n\t\t\t: lastOperation as HistoryOperation;\n\n\t\tif (historyOperation != null)\n\t\t{\n\t\t\tvar modify = historyOperation.CommandTrees.First();\n\t\t\t_migrationsHistoryTableName = ((DbScanExpression)modify.Target.Expression).Target.Table;\n\t\t}\n\t\t//This happens only and only if downgrading database to initial point (ie. reverting also Initial migration)\n\t\telse\n\t\t{\n\t\t\tvar dropTableOperation = (DropTableOperation)lastOperation; //DropTableOperation for MigrationHistory-table\n\t\t\t_migrationsHistoryTableName = Regex.Replace(dropTableOperation.Name, @\".+\\.(.+)\", \"$1\");\n\t\t}\n\n\t\treturn GenerateStatements(migrationOperations).ToArray();\n\t}\n\n\tvoid InitializeProviderServices(string providerManifestToken)\n\t{\n\t\tusing (var connection = CreateConnection())\n\t\t{\n\t\t\tProviderManifest = DbProviderServices.GetProviderServices(connection).GetProviderManifest(providerManifestToken);\n\t\t}\n\t}\n\n\t#region Operations\n\n\tprotected IEnumerable<MigrationStatement> Generate(MigrationOperation operation)\n\t{\n\t\tthrow new NotSupportedException(string.Format(\"Unknown operation '{0}'.\", operation.GetType().FullName));\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(UpdateDatabaseOperation operation)\n\t{\n\t\treturn GenerateStatements(operation.Migrations.SelectMany(x => x.Operations));\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(SqlOperation operation)\n\t{\n\t\tyield return Statement(operation.Sql, operation.SuppressTransaction);\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(AddColumnOperation operation)\n\t{\n\t\tvar tableName = CheckName(ExtractName(operation.Table));\n\t\tvar column = operation.Column;\n\t\tif (column.IsNullable != null\n\t\t\t\t&& !column.IsNullable.Value\n\t\t\t\t&& column.DefaultValue == null\n\t\t\t\t&& string.IsNullOrWhiteSpace(column.DefaultValueSql)\n\t\t\t\t&& !column.IsIdentity\n\t\t\t\t&& !column.IsTimestamp)\n\t\t{\n\t\t\tcolumn.DefaultValue = column.ClrDefaultValue;\n\t\t}\n\t\tvar columnData = Generate(column, tableName);\n\t\tusing (var writer = SqlWriter())\n\t\t{\n\t\t\twriter.Write(\"ALTER TABLE \");\n\t\t\twriter.Write(Quote(tableName));\n\t\t\twriter.Write(\" ADD \");\n\t\t\twriter.Write(columnData.Item1);\n\t\t\tyield return Statement(writer);\n\t\t}\n\t\tforeach (var item in columnData.Item2.Select(x => Statement(x)))\n\t\t\tyield return item;\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(AddForeignKeyOperation operation)\n\t{\n\t\tusing (var writer = SqlWriter())\n\t\t{\n\t\t\twriter.Write(\"ALTER TABLE \");\n\t\t\twriter.Write(Quote(CheckName(ExtractName(operation.DependentTable))));\n\t\t\twriter.Write(\" ADD CONSTRAINT \");\n\t\t\twriter.Write(Quote(CheckName(CreateItemName(operation.Name))));\n\t\t\twriter.Write(\" FOREIGN KEY (\");\n\t\t\tWriteColumns(writer, operation.DependentColumns.Select(Quote));\n\t\t\twriter.Write(\") REFERENCES \");\n\t\t\twriter.Write(Quote(CheckName(ExtractName(operation.PrincipalTable))));\n\t\t\twriter.Write(\" (\");\n\t\t\tWriteColumns(writer, operation.PrincipalColumns.Select(Quote));\n\t\t\twriter.Write(\")\");\n\t\t\tif (operation.CascadeDelete)\n\t\t\t{\n\t\t\t\twriter.Write(\" ON DELETE CASCADE\");\n\t\t\t}\n\t\t\tyield return Statement(writer);\n\t\t}\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(AddPrimaryKeyOperation operation)\n\t{\n\t\tusing (var writer = SqlWriter())\n\t\t{\n\t\t\twriter.Write(\"ALTER TABLE \");\n\t\t\twriter.Write(Quote(CheckName(ExtractName(operation.Table))));\n\t\t\twriter.Write(\" ADD CONSTRAINT \");\n\t\t\twriter.Write(Quote(CheckName(CreateItemName(operation.Name))));\n\t\t\twriter.Write(\" PRIMARY KEY (\");\n\t\t\tWriteColumns(writer, operation.Columns.Select(Quote));\n\t\t\twriter.Write(\")\");\n\t\t\tyield return Statement(writer);\n\t\t}\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(AlterColumnOperation operation)\n\t{\n\t\tvar column = operation.Column;\n\t\tvar tableName = CheckName(ExtractName(operation.Table));\n\t\tvar columnName = CheckName(column.Name);\n\t\t// drop NOT NULL first, either it will be recreated or it was to drop\n\t\tusing (var writer = SqlWriter())\n\t\t{\n\t\t\twriter.WriteLine(\"EXECUTE BLOCK\");\n\t\t\twriter.WriteLine(\"AS\");\n\t\t\twriter.WriteLine(\"declare constraint_name type of column rdb$relation_constraints.rdb$constraint_name;\");\n\t\t\twriter.WriteLine(\"BEGIN\");\n\t\t\twriter.Indent++;\n\t\t\twriter.WriteLine(\"select rc.rdb$constraint_name\");\n\t\t\twriter.WriteLine(\"from rdb$relation_constraints rc\");\n\t\t\twriter.WriteLine(\"join rdb$check_constraints cc on rc.rdb$constraint_name = cc.rdb$constraint_name\");\n\t\t\twriter.Write(\"where rc.rdb$constraint_type = 'NOT NULL' and rc.rdb$relation_name = '\");\n\t\t\twriter.Write(tableName);\n\t\t\twriter.Write(\"' and cc.rdb$trigger_name  = '\");\n\t\t\twriter.Write(columnName);\n\t\t\twriter.Write(\"'\");\n\t\t\twriter.WriteLine();\n\t\t\twriter.WriteLine(\"into :constraint_name;\");\n\t\t\twriter.WriteLine(\"if (constraint_name is not null) then\");\n\t\t\twriter.WriteLine(\"begin\");\n\t\t\twriter.Indent++;\n\t\t\twriter.Write(\"execute statement 'alter table \");\n\t\t\twriter.Write(Quote(tableName));\n\t\t\twriter.Write(\" drop constraint ' || :constraint_name;\");\n\t\t\twriter.WriteLine();\n\t\t\twriter.Indent--;\n\t\t\twriter.WriteLine(\"end\");\n\t\t\twriter.Indent--;\n\t\t\twriter.Write(\"END\");\n\t\t\tyield return Statement(writer);\n\t\t}\n\t\t// drop identity trigger first, either it will be recreated or it was to drop\n\t\tforeach (var item in _behavior.DropIdentityForColumn(columnName, tableName))\n\t\t\tyield return Statement(item);\n\n\t\tusing (var writer = SqlWriter())\n\t\t{\n\t\t\twriter.Write(\"ALTER TABLE \");\n\t\t\twriter.Write(Quote(tableName));\n\t\t\twriter.Write(\" ALTER COLUMN \");\n\t\t\twriter.Write(Quote(columnName));\n\t\t\twriter.Write(\" TYPE \");\n\t\t\twriter.Write(BuildPropertyType(column));\n\t\t\t// possible NOT NULL drop was dropped with statement above\n\t\t\tif (column.IsNullable != null && !column.IsNullable.Value)\n\t\t\t{\n\t\t\t\twriter.Write(\" NOT NULL\");\n\t\t\t}\n\t\t\tif (column.Type == PrimitiveTypeKind.Boolean)\n\t\t\t{\n\t\t\t\twriter.Write(\" CHECK(\");\n\t\t\t\twriter.Write(Quote(columnName));\n\t\t\t\twriter.Write(\" IN (0,1))\");\n\t\t\t}\n\t\t\tyield return Statement(writer);\n\t\t}\n\n\t\tif (column.DefaultValue != null || !string.IsNullOrWhiteSpace(column.DefaultValueSql))\n\t\t{\n\t\t\tusing (var writer = SqlWriter())\n\t\t\t{\n\t\t\t\twriter.Write(\"ALTER TABLE \");\n\t\t\t\twriter.Write(Quote(tableName));\n\t\t\t\twriter.Write(\" ALTER COLUMN \");\n\t\t\t\twriter.Write(Quote(columnName));\n\t\t\t\twriter.Write(\" DROP DEFAULT\");\n\t\t\t\tyield return Statement(writer);\n\t\t\t}\n\n\t\t\tusing (var writer = SqlWriter())\n\t\t\t{\n\t\t\t\twriter.Write(\"ALTER TABLE \");\n\t\t\t\twriter.Write(Quote(tableName));\n\t\t\t\twriter.Write(\" ALTER COLUMN \");\n\t\t\t\twriter.Write(Quote(columnName));\n\t\t\t\twriter.Write(\" SET DEFAULT \");\n\t\t\t\twriter.Write(column.DefaultValue != null ? WriteValue((dynamic)column.DefaultValue) : column.DefaultValueSql);\n\t\t\t\tyield return Statement(writer);\n\t\t\t}\n\t\t}\n\n\t\tif (column.IsIdentity)\n\t\t{\n\t\t\t// possible identity drop was dropped with statement above\n\t\t\tforeach (var item in _behavior.CreateIdentityForColumn(columnName, tableName))\n\t\t\t\tyield return Statement(item);\n\t\t}\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(AlterProcedureOperation operation)\n\t{\n\t\treturn Generate(operation, \"ALTER\");\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(AlterTableOperation operation)\n\t{\n\t\t// Nothing to do since there is no inherent semantics associated with annotations\n\t\tyield break;\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(CreateIndexOperation operation)\n\t{\n\t\tusing (var writer = SqlWriter())\n\t\t{\n\t\t\twriter.Write(\"CREATE \");\n\t\t\tif (operation.IsUnique)\n\t\t\t{\n\t\t\t\twriter.Write(\"UNIQUE \");\n\t\t\t}\n\t\t\twriter.Write(\"INDEX \");\n\t\t\twriter.Write(Quote(CheckName(CreateItemName(BuildIndexName(operation)))));\n\t\t\twriter.Write(\" ON \");\n\t\t\twriter.Write(Quote(CheckName(ExtractName(operation.Table))));\n\t\t\twriter.Write(\"(\");\n\t\t\tWriteColumns(writer, operation.Columns.Select(Quote));\n\t\t\twriter.Write(\")\");\n\t\t\tyield return Statement(writer);\n\t\t}\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(CreateProcedureOperation operation)\n\t{\n\t\treturn Generate(operation, \"CREATE\");\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(CreateTableOperation operation)\n\t{\n\t\tvar tableName = CheckName(ExtractName(operation.Name));\n\t\tvar isMigrationsHistoryTable = tableName.Equals(_migrationsHistoryTableName, StringComparison.InvariantCulture);\n\t\tvar columnsData = operation.Columns.Select(x => Generate(x, tableName)).ToArray();\n\t\tusing (var writer = SqlWriter())\n\t\t{\n\t\t\tif (isMigrationsHistoryTable)\n\t\t\t{\n\t\t\t\twriter.WriteLine(\"EXECUTE BLOCK\");\n\t\t\t\twriter.WriteLine(\"AS\");\n\t\t\t\twriter.WriteLine(\"BEGIN\");\n\t\t\t\twriter.Indent++;\n\t\t\t\twriter.WriteLine(\"EXECUTE STATEMENT\");\n\t\t\t\twriter.Indent++;\n\t\t\t\twriter.Write(\"'\");\n\t\t\t}\n\t\t\twriter.Write(\"CREATE TABLE \");\n\t\t\twriter.Write(Quote(tableName));\n\t\t\twriter.Write(\" (\");\n\t\t\twriter.WriteLine();\n\t\t\twriter.Indent++;\n\t\t\tWriteColumns(writer, columnsData.Select(x => x.Item1), true);\n\t\t\twriter.Indent--;\n\t\t\twriter.WriteLine();\n\t\t\twriter.Write(\")\");\n\t\t\tif (isMigrationsHistoryTable)\n\t\t\t{\n\t\t\t\twriter.WriteLine(\"'\");\n\t\t\t\twriter.Indent--;\n\t\t\t\twriter.WriteLine(\"WITH AUTONOMOUS TRANSACTION;\");\n\t\t\t\twriter.Indent--;\n\t\t\t\twriter.Write(\"END\");\n\t\t\t}\n\t\t\tyield return Statement(writer);\n\t\t}\n\t\tif (operation.PrimaryKey != null)\n\t\t{\n\t\t\tforeach (var item in Generate(operation.PrimaryKey))\n\t\t\t\tyield return item;\n\t\t}\n\t\tforeach (var item in columnsData.SelectMany(x => x.Item2).Select(x => Statement(x)))\n\t\t\tyield return item;\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(DropColumnOperation operation)\n\t{\n\t\tusing (var writer = SqlWriter())\n\t\t{\n\t\t\twriter.Write(\"ALTER TABLE \");\n\t\t\twriter.Write(Quote(CheckName(ExtractName(operation.Table))));\n\t\t\twriter.Write(\" DROP \");\n\t\t\twriter.Write(Quote(CheckName(operation.Name)));\n\t\t\tyield return Statement(writer);\n\t\t}\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(DropForeignKeyOperation operation)\n\t{\n\t\tusing (var writer = SqlWriter())\n\t\t{\n\t\t\twriter.Write(\"ALTER TABLE \");\n\t\t\twriter.Write(Quote(CheckName(ExtractName(operation.DependentTable))));\n\t\t\twriter.Write(\" DROP CONSTRAINT \");\n\t\t\twriter.Write(Quote(CheckName(CreateItemName(operation.Name))));\n\t\t\tyield return Statement(writer);\n\t\t}\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(DropIndexOperation operation)\n\t{\n\t\tusing (var writer = SqlWriter())\n\t\t{\n\t\t\twriter.Write(\"DROP INDEX \");\n\t\t\twriter.Write(Quote(CheckName(CreateItemName(BuildIndexName(operation)))));\n\t\t\tyield return Statement(writer);\n\t\t}\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(DropPrimaryKeyOperation operation)\n\t{\n\t\tusing (var writer = SqlWriter())\n\t\t{\n\t\t\twriter.Write(\"ALTER TABLE \");\n\t\t\twriter.Write(Quote(CheckName(ExtractName(operation.Table))));\n\t\t\twriter.Write(\" DROP CONSTRAINT \");\n\t\t\twriter.Write(Quote(CheckName(CreateItemName(operation.Name))));\n\t\t\tyield return Statement(writer);\n\t\t}\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(DropProcedureOperation operation)\n\t{\n\t\tusing (var writer = SqlWriter())\n\t\t{\n\t\t\twriter.Write(\"DROP PROCEDURE \");\n\t\t\twriter.Write(Quote(CheckName(ExtractName(operation.Name))));\n\t\t\tyield return Statement(writer);\n\t\t}\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(DropTableOperation operation)\n\t{\n\t\tusing (var writer = SqlWriter())\n\t\t{\n\t\t\twriter.Write(\"DROP TABLE \");\n\t\t\twriter.Write(Quote(CheckName(ExtractName(operation.Name))));\n\t\t\tyield return Statement(writer);\n\t\t}\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(MoveProcedureOperation operation)\n\t{\n\t\tthrow new NotSupportedException(\"Moving procedure is not supported by Firebird.\");\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(MoveTableOperation operation)\n\t{\n\t\tthrow new NotSupportedException(\"Moving table is not supported by Firebird.\");\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(RenameColumnOperation operation)\n\t{\n\t\tusing (var writer = SqlWriter())\n\t\t{\n\t\t\twriter.Write(\"ALTER TABLE \");\n\t\t\twriter.Write(Quote(CheckName(ExtractName(operation.Table))));\n\t\t\twriter.Write(\" ALTER COLUMN \");\n\t\t\twriter.Write(Quote(CheckName(operation.Name)));\n\t\t\twriter.Write(\" TO \");\n\t\t\twriter.Write(Quote(CheckName(operation.NewName)));\n\t\t\tyield return Statement(writer);\n\t\t}\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(RenameIndexOperation operation)\n\t{\n\t\tthrow new NotSupportedException(\"Renaming index is not supported by Firebird.\");\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(RenameProcedureOperation operation)\n\t{\n\t\tthrow new NotSupportedException(\"Renaming procedure is not supported by Firebird.\");\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(RenameTableOperation operation)\n\t{\n\t\tthrow new NotSupportedException(\"Renaming table is not supported by Firebird.\");\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(HistoryOperation operation)\n\t{\n\t\tforeach (var commandTree in operation.CommandTrees)\n\t\t{\n\t\t\tList<DbParameter> _;\n\n\t\t\tswitch (commandTree.CommandTreeKind)\n\t\t\t{\n\t\t\t\tcase DbCommandTreeKind.Insert:\n\t\t\t\t\tconst int MigrationIdColumn = 0;\n\t\t\t\t\tconst int ContextKeyColumn = 1;\n\t\t\t\t\tconst int ModelColumn = 2;\n\t\t\t\t\tconst int VersionColumn = 3;\n\t\t\t\t\tconst int MaxChunkLength = 32000;\n\n\t\t\t\t\tvar dbInsert = (DbInsertCommandTree)commandTree;\n\t\t\t\t\tvar modelData = ((dbInsert.SetClauses[ModelColumn] as DbSetClause).Value as DbConstantExpression).Value as byte[];\n\n\t\t\t\t\t// If model length is less than max value, stick to original version\n\t\t\t\t\tif (modelData.Length < MaxChunkLength)\n\t\t\t\t\t{\n\t\t\t\t\t\tusing (var writer = SqlWriter())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\twriter.Write(DmlSqlGenerator.GenerateInsertSql(dbInsert, out _, generateParameters: false));\n\t\t\t\t\t\t\tyield return Statement(writer);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t// If it's bigger - we split it into chunks, as big as possible\n\t\t\t\t\t\tvar dataChunks = modelData.Split(MaxChunkLength);\n\n\t\t\t\t\t\t// We can't change CommandTree, but we can create new one, only difference being data length\n\t\t\t\t\t\tusing (var writer = SqlWriter())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvar setClauses = new ReadOnlyCollection<DbModificationClause>(\n\t\t\t\t\t\t\t\t\tnew List<DbModificationClause>\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tdbInsert.SetClauses[MigrationIdColumn],\n\t\t\t\t\t\t\t\t\t\t\tdbInsert.SetClauses[ContextKeyColumn],\n\t\t\t\t\t\t\t\t\t\t\tDbExpressionBuilder.SetClause(\n\t\t\t\t\t\t\t\t\t\t\t\t((DbSetClause)dbInsert.SetClauses[ModelColumn]).Property,\n\t\t\t\t\t\t\t\t\t\t\t\tdataChunks.ElementAt(0).ToArray()\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tdbInsert.SetClauses[VersionColumn],\n\t\t\t\t\t\t\t\t\t});\n\n\n\t\t\t\t\t\t\tvar newCommandTree = new DbInsertCommandTree(dbInsert.MetadataWorkspace, commandTree.DataSpace, dbInsert.Target, setClauses, dbInsert.Returning);\n\n\t\t\t\t\t\t\twriter.Write(DmlSqlGenerator.GenerateInsertSql(newCommandTree, out _, generateParameters: false));\n\t\t\t\t\t\t\tyield return Statement(writer);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Now we have first Insert, let's update it with chunks of remaing data\n\t\t\t\t\t\tforeach (var dataChunk in dataChunks.Skip(1))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tusing (var writer = SqlWriter())\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvar modelProperty = (dbInsert.SetClauses[ModelColumn] as DbSetClause).Property as DbPropertyExpression;\n\n\t\t\t\t\t\t\t\tvar modificationClauses = new List<DbModificationClause>\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t// Updating existing chunk of data with subsequent part\n\t\t\t\t\t\t\t\t\t\tDbExpressionBuilder.SetClause(\n\t\t\t\t\t\t\t\t\t\t\tmodelProperty,\n\t\t\t\t\t\t\t\t\t\t\t// TODO: Better solution required\n\t\t\t\t\t\t\t\t\t\t\t// Best if we could use DbExpression.Concat, but it returns DbFunctionExpression, which is not supported\n\t\t\t\t\t\t\t\t\t\t\t// Here we'll get SET Model = 'data', which we can update as text later\n\t\t\t\t\t\t\t\t\t\t\tdataChunk.ToArray()\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t}.AsReadOnly();\n\n\t\t\t\t\t\t\t\tvar updateCommandTree = new DbUpdateCommandTree(dbInsert.MetadataWorkspace,\n\t\t\t\t\t\t\t\t\tdbInsert.DataSpace,\n\t\t\t\t\t\t\t\t\tdbInsert.Target,\n\t\t\t\t\t\t\t\t\t// Predicate is MigrationId value\n\t\t\t\t\t\t\t\t\tDbExpressionBuilder.Equal(\n\t\t\t\t\t\t\t\t\t\t((DbSetClause)dbInsert.SetClauses[MigrationIdColumn]).Property,\n\t\t\t\t\t\t\t\t\t\t((DbSetClause)dbInsert.SetClauses[MigrationIdColumn]).Value),\n\t\t\t\t\t\t\t\t\tmodificationClauses,\n\t\t\t\t\t\t\t\t\tdbInsert.Returning);\n\n\t\t\t\t\t\t\t\twriter.Write(DmlSqlGenerator.GenerateUpdateSql(updateCommandTree, out _, generateParameters: false));\n\n\t\t\t\t\t\t\t\t// Since we couldn't concat before, replacing query as string\n\t\t\t\t\t\t\t\t// Replacing SET Model = 'data'\n\t\t\t\t\t\t\t\t//\t\twith SET Model = Model || 'data'\n\t\t\t\t\t\t\t\t// Model being first is important, since these are parts of single value\n\t\t\t\t\t\t\t\tvar statement = writer.ToString();\n\t\t\t\t\t\t\t\tvar newStatement = statement.Replace($\"SET \\\"{modelProperty.Property.Name}\\\" = \", $\"SET \\\"{modelProperty.Property.Name}\\\" = \\\"{modelProperty.Property.Name}\\\" || \");\n\n\t\t\t\t\t\t\t\tyield return Statement(newStatement);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase DbCommandTreeKind.Delete:\n\t\t\t\t\tusing (var writer = SqlWriter())\n\t\t\t\t\t{\n\t\t\t\t\t\twriter.Write(DmlSqlGenerator.GenerateDeleteSql((DbDeleteCommandTree)commandTree, out _, generateParameters: false));\n\t\t\t\t\t\tyield return Statement(writer);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected virtual IEnumerable<MigrationStatement> Generate(ProcedureOperation operation, string action)\n\t{\n\t\tusing (var writer = SqlWriter())\n\t\t{\n\t\t\tvar inputParameters = operation.Parameters.Where(x => !x.IsOutParameter).ToArray();\n\t\t\tvar outputParameters = operation.Parameters.Where(x => x.IsOutParameter).ToArray();\n\n\t\t\twriter.Write(action);\n\t\t\twriter.Write(\" PROCEDURE \");\n\t\t\twriter.Write(Quote(CheckName(ExtractName(operation.Name))));\n\t\t\tif (inputParameters.Any())\n\t\t\t{\n\t\t\t\twriter.Write(\" (\");\n\t\t\t\twriter.WriteLine();\n\t\t\t\twriter.Indent++;\n\t\t\t\tWriteColumns(writer, inputParameters.Select(Generate), true);\n\t\t\t\twriter.Indent--;\n\t\t\t\twriter.WriteLine();\n\t\t\t\twriter.Write(\")\");\n\t\t\t}\n\t\t\tif (outputParameters.Any())\n\t\t\t{\n\t\t\t\twriter.WriteLine();\n\t\t\t\twriter.Write(\"RETURNS (\");\n\t\t\t\twriter.WriteLine();\n\t\t\t\twriter.Indent++;\n\t\t\t\tWriteColumns(writer, outputParameters.Select(Generate), true);\n\t\t\t\twriter.Indent--;\n\t\t\t\twriter.WriteLine();\n\t\t\t\twriter.Write(\")\");\n\t\t\t}\n\t\t\twriter.WriteLine();\n\t\t\twriter.WriteLine(\"AS\");\n\t\t\twriter.WriteLine(\"BEGIN\");\n\t\t\twriter.Write(operation.BodySql);\n\t\t\twriter.WriteLine();\n\t\t\twriter.Write(\"END\");\n\t\t\tyield return Statement(writer);\n\t\t}\n\t}\n\n\tprotected (string, IEnumerable<string>) Generate(ColumnModel column, string tableName)\n\t{\n\t\tvar builder = new StringBuilder();\n\t\tvar additionalCommands = new List<string>();\n\n\t\tvar columnName = CheckName(column.Name);\n\n\t\tvar columnType = BuildPropertyType(column);\n\t\tbuilder.Append(Quote(columnName));\n\t\tbuilder.Append(\" \");\n\t\tbuilder.Append(columnType);\n\n\t\tif (column.DefaultValue != null)\n\t\t{\n\t\t\tbuilder.Append(\" DEFAULT \");\n\t\t\tbuilder.Append(WriteValue((dynamic)column.DefaultValue));\n\t\t}\n\t\telse if (!string.IsNullOrWhiteSpace(column.DefaultValueSql))\n\t\t{\n\t\t\tbuilder.Append(\" DEFAULT \");\n\t\t\tbuilder.Append(column.DefaultValueSql);\n\t\t}\n\n\t\tif ((column.IsNullable != null)\n\t\t\t&& !column.IsNullable.Value)\n\t\t{\n\t\t\tbuilder.Append(\" NOT NULL\");\n\t\t}\n\n\t\tif (column.Type == PrimitiveTypeKind.Boolean)\n\t\t{\n\t\t\tbuilder.Append(\" CHECK(\");\n\t\t\tbuilder.Append(Quote(columnName));\n\t\t\tbuilder.Append(\" IN (0,1))\");\n\t\t}\n\n\t\tif (column.IsIdentity)\n\t\t{\n\t\t\tvar identity = _behavior.CreateIdentityForColumn(columnName, tableName);\n\t\t\tadditionalCommands.AddRange(identity.Where(x => !string.IsNullOrWhiteSpace(x)));\n\t\t}\n\n\t\treturn (builder.ToString(), additionalCommands);\n\t}\n\n\tprotected string Generate(ParameterModel parameter)\n\t{\n\t\tvar builder = new StringBuilder();\n\t\tbuilder.Append(Quote(CheckName(parameter.Name)));\n\t\tbuilder.Append(\" \");\n\t\tbuilder.Append(BuildPropertyType(parameter));\n\t\treturn builder.ToString();\n\t}\n\n\t#endregion\n\n\t#region Helpers\n\n\tstatic MigrationStatement Statement(SqlWriter sqlWriter, bool suppressTransaction = false)\n\t{\n\t\treturn Statement(sqlWriter.ToString(), suppressTransaction);\n\t}\n\tprotected static MigrationStatement Statement(string sql, bool suppressTransaction = false)\n\t{\n\t\treturn new MigrationStatement\n\t\t{\n\t\t\tSql = sql,\n\t\t\tSuppressTransaction = suppressTransaction,\n\t\t\tBatchTerminator = \";\",\n\t\t};\n\t}\n\n\tprotected static string WriteValue(object value)\n\t{\n\t\treturn string.Format(CultureInfo.InvariantCulture, \"{0}\", value);\n\t}\n\n\tprotected static string WriteValue(DateTime value)\n\t{\n\t\treturn SqlGenerator.FormatDateTime(value);\n\t}\n\n\tprotected static string WriteValue(byte[] value)\n\t{\n\t\treturn SqlGenerator.FormatBinary(value);\n\t}\n\n\tprotected static string WriteValue(bool value)\n\t{\n\t\treturn SqlGenerator.FormatBoolean(value);\n\t}\n\n\tprotected static string WriteValue(Guid value)\n\t{\n\t\treturn SqlGenerator.FormatGuid(value);\n\t}\n\n\tprotected static string WriteValue(string value)\n\t{\n\t\treturn SqlGenerator.FormatString(value, true);\n\t}\n\n\tprotected static string WriteValue(TimeSpan value)\n\t{\n\t\treturn SqlGenerator.FormatTime(value);\n\t}\n\n\tprotected internal static string Quote(string name)\n\t{\n\t\treturn SqlGenerator.QuoteIdentifier(name);\n\t}\n\n\tinternal static SqlWriter SqlWriter()\n\t{\n\t\tvar result = new SqlWriter(new StringBuilder());\n\t\tresult.Indent++;\n\t\treturn result;\n\t}\n\n\tstring BuildPropertyType(PropertyModel propertyModel)\n\t{\n\t\tvar storeTypeName = propertyModel.StoreType;\n\t\tvar typeUsage = ProviderManifest.GetStoreType(propertyModel.TypeUsage);\n\t\tif (!string.IsNullOrWhiteSpace(storeTypeName))\n\t\t{\n\t\t\ttypeUsage = BuildStoreTypeUsage(storeTypeName, propertyModel) ?? typeUsage;\n\t\t}\n\t\treturn SqlGenerator.GetSqlPrimitiveType(typeUsage);\n\t}\n\n\tstatic string BuildIndexName(IndexOperation indexOperation)\n\t{\n\t\treturn !indexOperation.HasDefaultName\n\t\t\t? indexOperation.Name\n\t\t\t: IndexOperation.BuildDefaultName(new[] { ExtractName(indexOperation.Table) }.Concat(indexOperation.Columns));\n\t}\n\n\tstatic string ExtractName(string name)\n\t{\n\t\treturn name.Substring(name.LastIndexOf('.') + 1);\n\t}\n\n\tstatic string CreateItemName(string name)\n\t{\n\t\twhile (true)\n\t\t{\n\t\t\tvar match = Regex.Match(name, @\"^(?<prefix>.+_)[^.]+\\.(?<suffix>.+)$\");\n\t\t\tif (!match.Success)\n\t\t\t\tbreak;\n\t\t\tname = match.Result(\"${prefix}${suffix}\");\n\t\t}\n\t\treturn name;\n\t}\n\n\tstatic string CheckName(string name)\n\t{\n\t\tconst int LengthLimit = 31;\n\t\tif (name.Length > LengthLimit)\n\t\t\tthrow new ArgumentOutOfRangeException($\"The name '{name}' is longer than Firebird's {LengthLimit} characters limit for object names.\");\n\t\treturn name;\n\t}\n\n\tstatic void WriteColumns(SqlWriter writer, IEnumerable<string> columns, bool separateLines = false)\n\t{\n\t\tvar separator = (string)null;\n\t\tforeach (var column in columns)\n\t\t{\n\t\t\tif (separator != null)\n\t\t\t{\n\t\t\t\twriter.Write(separator);\n\t\t\t\tif (separateLines)\n\t\t\t\t\twriter.WriteLine();\n\t\t\t}\n\t\t\twriter.Write(column);\n\t\t\tseparator = \", \";\n\t\t}\n\t}\n\n\tstatic DbConnection CreateConnection()\n\t{\n\t\treturn DbConfiguration.DependencyResolver.GetService<DbProviderFactory>(FbProviderServices.ProviderInvariantName).CreateConnection();\n\t}\n\n\tIEnumerable<MigrationStatement> GenerateStatements(IEnumerable<MigrationOperation> operations)\n\t{\n\t\treturn operations.Select<dynamic, IEnumerable<MigrationStatement>>(x => Generate(x)).SelectMany(x => x);\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/FbMigrationsTransactionsInterceptor.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Data.Common;\nusing System.Data.Entity.Infrastructure.Interception;\nusing System.Diagnostics;\nusing System.Linq;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace EntityFramework.Firebird;\n\n// Migrations are executed in Serializable transaction. Because of my \"AUTONOMOUS TRANSACTION\" usage\n// I better use ReadCommitted. Here I plug in, in case of Migrations.\nclass FbMigrationsTransactionsInterceptor : IDbConnectionInterceptor\n{\n\tpublic void BeginningTransaction(DbConnection connection, BeginTransactionInterceptionContext interceptionContext)\n\t{\n\t\tif (connection is FbConnection\n\t\t\t&& interceptionContext.IsolationLevel == IsolationLevel.Serializable\n\t\t\t&& IsInMigrations())\n\t\t{\n\t\t\tinterceptionContext.Result = connection.BeginTransaction(IsolationLevel.ReadCommitted);\n\t\t}\n\t}\n\n\tpublic static bool IsInMigrations()\n\t{\n\t\tvar stackTrace = new StackTrace(false);\n\t\treturn stackTrace.GetFrames().Any(f => f.GetMethod().ReflectedType?.Namespace.Equals(\"System.Data.Entity.Migrations\", StringComparison.Ordinal) ?? false);\n\t}\n\n\tpublic void BeganTransaction(DbConnection connection, BeginTransactionInterceptionContext interceptionContext)\n\t{ }\n\n\tpublic void Closed(DbConnection connection, DbConnectionInterceptionContext interceptionContext)\n\t{ }\n\n\tpublic void Closing(DbConnection connection, DbConnectionInterceptionContext interceptionContext)\n\t{ }\n\n\tpublic void ConnectionStringGetting(DbConnection connection, DbConnectionInterceptionContext<string> interceptionContext)\n\t{ }\n\n\tpublic void ConnectionStringGot(DbConnection connection, DbConnectionInterceptionContext<string> interceptionContext)\n\t{ }\n\n\tpublic void ConnectionStringSet(DbConnection connection, DbConnectionPropertyInterceptionContext<string> interceptionContext)\n\t{ }\n\n\tpublic void ConnectionStringSetting(DbConnection connection, DbConnectionPropertyInterceptionContext<string> interceptionContext)\n\t{ }\n\n\tpublic void ConnectionTimeoutGetting(DbConnection connection, DbConnectionInterceptionContext<int> interceptionContext)\n\t{ }\n\n\tpublic void ConnectionTimeoutGot(DbConnection connection, DbConnectionInterceptionContext<int> interceptionContext)\n\t{ }\n\n\tpublic void DataSourceGetting(DbConnection connection, DbConnectionInterceptionContext<string> interceptionContext)\n\t{ }\n\n\tpublic void DataSourceGot(DbConnection connection, DbConnectionInterceptionContext<string> interceptionContext)\n\t{ }\n\n\tpublic void DatabaseGetting(DbConnection connection, DbConnectionInterceptionContext<string> interceptionContext)\n\t{ }\n\n\tpublic void DatabaseGot(DbConnection connection, DbConnectionInterceptionContext<string> interceptionContext)\n\t{ }\n\n\tpublic void Disposed(DbConnection connection, DbConnectionInterceptionContext interceptionContext)\n\t{ }\n\n\tpublic void Disposing(DbConnection connection, DbConnectionInterceptionContext interceptionContext)\n\t{ }\n\n\tpublic void EnlistedTransaction(DbConnection connection, EnlistTransactionInterceptionContext interceptionContext)\n\t{ }\n\n\tpublic void EnlistingTransaction(DbConnection connection, EnlistTransactionInterceptionContext interceptionContext)\n\t{ }\n\n\tpublic void Opened(DbConnection connection, DbConnectionInterceptionContext interceptionContext)\n\t{ }\n\n\tpublic void Opening(DbConnection connection, DbConnectionInterceptionContext interceptionContext)\n\t{ }\n\n\tpublic void ServerVersionGetting(DbConnection connection, DbConnectionInterceptionContext<string> interceptionContext)\n\t{ }\n\n\tpublic void ServerVersionGot(DbConnection connection, DbConnectionInterceptionContext<string> interceptionContext)\n\t{ }\n\n\tpublic void StateGetting(DbConnection connection, DbConnectionInterceptionContext<ConnectionState> interceptionContext)\n\t{ }\n\n\tpublic void StateGot(DbConnection connection, DbConnectionInterceptionContext<ConnectionState> interceptionContext)\n\t{ }\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/FbProviderManifest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data.Entity.Core;\nusing System.Data.Entity.Core.Common;\nusing System.Data.Entity.Core.Metadata.Edm;\nusing System.Diagnostics;\nusing System.Reflection;\nusing System.Text;\nusing System.Xml;\n\nnamespace EntityFramework.Firebird;\n\npublic class FbProviderManifest : DbXmlEnabledProviderManifest\n{\n\t#region Private Fields\n\n\tinternal const int BinaryMaxSize = Int32.MaxValue;\n\tinternal const int AsciiVarcharMaxSize = 32765;\n\tinternal const int UnicodeVarcharMaxSize = AsciiVarcharMaxSize / 4;\n\tinternal const char LikeEscapeCharacter = '\\\\';\n\n\tprivate System.Collections.ObjectModel.ReadOnlyCollection<PrimitiveType> _primitiveTypes = null;\n\tprivate System.Collections.ObjectModel.ReadOnlyCollection<EdmFunction> _functions = null;\n\n\t#endregion\n\n\t#region Constructors\n\n\t/// <summary>\n\t/// Constructor\n\t/// </summary>\n\t/// <param name=\"manifestToken\">A token used to infer the capabilities of the store</param>\n\tpublic FbProviderManifest(string manifestToken)\n\t\t: base(FbProviderManifest.GetProviderManifest())\n\t{ }\n\n\t#endregion\n\n\t#region Properties\n\t#endregion\n\n\tinternal static XmlReader GetProviderManifest()\n\t{\n\t\treturn GetXmlResource(GetManifestResourceName());\n\t}\n\n\t/// <summary>\n\t/// Providers should override this to return information specific to their provider.\n\t///\n\t/// This method should never return null.\n\t/// </summary>\n\t/// <param name=\"informationType\">The name of the information to be retrieved.</param>\n\t/// <returns>An XmlReader at the begining of the information requested.</returns>\n\tprotected override XmlReader GetDbInformation(string informationType)\n\t{\n\t\tif (informationType == StoreSchemaDefinition || informationType == StoreSchemaDefinitionVersion3)\n\t\t{\n\t\t\treturn GetStoreSchemaDescription(informationType);\n\t\t}\n\t\tif (informationType == StoreSchemaMapping || informationType == StoreSchemaMappingVersion3)\n\t\t{\n\t\t\treturn GetStoreSchemaMapping(informationType);\n\t\t}\n\t\tif (informationType == ConceptualSchemaDefinition || informationType == ConceptualSchemaDefinitionVersion3)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\n\t\tthrow new ProviderIncompatibleException(string.Format(\"The provider returned null for the informationType '{0}'.\", informationType));\n\t}\n\n\tpublic override System.Collections.ObjectModel.ReadOnlyCollection<PrimitiveType> GetStoreTypes()\n\t{\n\t\tif (_primitiveTypes == null)\n\t\t{\n\t\t\t_primitiveTypes = base.GetStoreTypes();\n\t\t}\n\n\t\treturn _primitiveTypes;\n\t}\n\n\tpublic override System.Collections.ObjectModel.ReadOnlyCollection<EdmFunction> GetStoreFunctions()\n\t{\n\t\tif (_functions == null)\n\t\t{\n\t\t\t_functions = base.GetStoreFunctions();\n\t\t}\n\n\t\treturn _functions;\n\t}\n\n\t/// <summary>\n\t/// This method takes a type and a set of facets and returns the best mapped equivalent type\n\t/// in EDM.\n\t/// </summary>\n\t/// <param name=\"storeType\">A TypeUsage encapsulating a store type and a set of facets</param>\n\t/// <returns>A TypeUsage encapsulating an EDM type and a set of facets</returns>\n\tpublic override TypeUsage GetEdmType(TypeUsage storeType)\n\t{\n\t\tif (storeType == null)\n\t\t{\n\t\t\tthrow new ArgumentNullException(\"storeType\");\n\t\t}\n\n\t\tvar storeTypeName = storeType.EdmType.Name.ToLowerInvariant();\n\t\tif (!StoreTypeNameToEdmPrimitiveType.ContainsKey(storeTypeName))\n\t\t{\n\t\t\tthrow new ArgumentException(string.Format(\"The underlying provider does not support the type '{0}'.\", storeTypeName));\n\t\t}\n\n\t\tvar edmPrimitiveType = base.StoreTypeNameToEdmPrimitiveType[storeTypeName];\n\n\t\tvar maxLength = 0;\n\t\tvar isUnicode = true;\n\t\tvar isFixedLen = false;\n\t\tvar isUnbounded = true;\n\n\t\tPrimitiveTypeKind newPrimitiveTypeKind;\n\n\t\tswitch (storeTypeName)\n\t\t{\n\t\t\t// for some types we just go with simple type usage with no facets\n\t\t\tcase \"smallint\":\n\t\t\tcase \"int\":\n\t\t\tcase \"bigint\":\n\t\t\tcase \"smallint_bool\":\n\t\t\tcase \"float\":\n\t\t\tcase \"double\":\n\t\t\tcase \"guid\":\n\t\t\t\treturn TypeUsage.CreateDefaultTypeUsage(edmPrimitiveType);\n\n\t\t\tcase \"decimal\":\n\t\t\tcase \"numeric\":\n\t\t\t\tif (TypeHelpers.TryGetPrecision(storeType, out var precision) && TypeHelpers.TryGetScale(storeType, out var scale))\n\t\t\t\t{\n\t\t\t\t\treturn TypeUsage.CreateDecimalTypeUsage(edmPrimitiveType, precision, scale);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn TypeUsage.CreateDecimalTypeUsage(edmPrimitiveType);\n\t\t\t\t}\n\n\t\t\tcase \"varchar\":\n\t\t\t\tnewPrimitiveTypeKind = PrimitiveTypeKind.String;\n\t\t\t\tisUnbounded = !TypeHelpers.TryGetMaxLength(storeType, out maxLength);\n\t\t\t\tisUnicode = true; //hardcoded\n\t\t\t\tisFixedLen = false;\n\t\t\t\tbreak;\n\n\t\t\tcase \"char\":\n\t\t\t\tnewPrimitiveTypeKind = PrimitiveTypeKind.String;\n\t\t\t\tisUnbounded = !TypeHelpers.TryGetMaxLength(storeType, out maxLength);\n\t\t\t\tisUnicode = true; //hardcoded\n\t\t\t\tisFixedLen = true;\n\t\t\t\tbreak;\n\n\t\t\tcase \"timestamp\":\n\t\t\t\treturn TypeUsage.CreateDateTimeTypeUsage(edmPrimitiveType, null);\n\t\t\tcase \"date\":\n\t\t\t\treturn TypeUsage.CreateDateTimeTypeUsage(edmPrimitiveType, null);\n\t\t\tcase \"time\":\n\t\t\t\treturn TypeUsage.CreateTimeTypeUsage(edmPrimitiveType, null);\n\n\t\t\tcase \"blob\":\n\t\t\t\tnewPrimitiveTypeKind = PrimitiveTypeKind.Binary;\n\t\t\t\tisUnbounded = true;\n\t\t\t\tisFixedLen = false;\n\t\t\t\tbreak;\n\n\t\t\tcase \"clob\":\n\t\t\t\tnewPrimitiveTypeKind = PrimitiveTypeKind.String;\n\t\t\t\tisUnbounded = true;\n\t\t\t\tisUnicode = true; //hardcoded\n\t\t\t\tisFixedLen = false;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tthrow new NotSupportedException(string.Format(\"The underlying provider does not support the type '{0}'.\", storeTypeName));\n\t\t}\n\n\t\tDebug.Assert(newPrimitiveTypeKind == PrimitiveTypeKind.String || newPrimitiveTypeKind == PrimitiveTypeKind.Binary, \"at this point only string and binary types should be present\");\n\n\t\tswitch (newPrimitiveTypeKind)\n\t\t{\n\t\t\tcase PrimitiveTypeKind.String:\n\t\t\t\tif (!isUnbounded)\n\t\t\t\t{\n\t\t\t\t\treturn TypeUsage.CreateStringTypeUsage(edmPrimitiveType, isUnicode, isFixedLen, maxLength);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn TypeUsage.CreateStringTypeUsage(edmPrimitiveType, isUnicode, isFixedLen);\n\t\t\t\t}\n\t\t\tcase PrimitiveTypeKind.Binary:\n\t\t\t\tif (!isUnbounded)\n\t\t\t\t{\n\t\t\t\t\treturn TypeUsage.CreateBinaryTypeUsage(edmPrimitiveType, isFixedLen, maxLength);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn TypeUsage.CreateBinaryTypeUsage(edmPrimitiveType, isFixedLen);\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new NotSupportedException(string.Format(\"The underlying provider does not support the type '{0}'.\", storeTypeName));\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// This method takes a type and a set of facets and returns the best mapped equivalent type\n\t/// in SQL Server, taking the store version into consideration.\n\t/// </summary>\n\t/// <param name=\"storeType\">A TypeUsage encapsulating an EDM type and a set of facets</param>\n\t/// <returns>A TypeUsage encapsulating a store type and a set of facets</returns>\n\tpublic override TypeUsage GetStoreType(TypeUsage edmType)\n\t{\n\t\tif (edmType == null)\n\t\t{\n\t\t\tthrow new ArgumentNullException(\"edmType\");\n\t\t}\n\t\tDebug.Assert(edmType.EdmType.BuiltInTypeKind == BuiltInTypeKind.PrimitiveType);\n\n\t\tif (!(edmType.EdmType is PrimitiveType primitiveType))\n\t\t{\n\t\t\tthrow new ArgumentException(string.Format(\"The underlying provider does not support the type '{0}'.\", edmType));\n\t\t}\n\n\t\tvar facets = edmType.Facets;\n\n\t\tswitch (primitiveType.PrimitiveTypeKind)\n\t\t{\n\t\t\tcase PrimitiveTypeKind.Boolean:\n\t\t\t\treturn TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType[\"smallint_bool\"]);\n\n\t\t\tcase PrimitiveTypeKind.Int16:\n\t\t\t\treturn TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType[\"smallint\"]);\n\n\t\t\tcase PrimitiveTypeKind.Int32:\n\t\t\t\treturn TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType[\"int\"]);\n\n\t\t\tcase PrimitiveTypeKind.Int64:\n\t\t\t\treturn TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType[\"bigint\"]);\n\n\t\t\tcase PrimitiveTypeKind.Double:\n\t\t\t\treturn TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType[\"double\"]);\n\n\t\t\tcase PrimitiveTypeKind.Single:\n\t\t\t\treturn TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType[\"float\"]);\n\n\t\t\tcase PrimitiveTypeKind.Decimal: // decimal, numeric\n\t\t\t\t{\n\t\t\t\t\tif (!TypeHelpers.TryGetPrecision(edmType, out var precision))\n\t\t\t\t\t{\n\t\t\t\t\t\tprecision = 9;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!TypeHelpers.TryGetScale(edmType, out var scale))\n\t\t\t\t\t{\n\t\t\t\t\t\tscale = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn TypeUsage.CreateDecimalTypeUsage(StoreTypeNameToStorePrimitiveType[\"decimal\"], precision, scale);\n\t\t\t\t}\n\n\t\t\tcase PrimitiveTypeKind.Binary: // blob\n\t\t\t\t{\n\t\t\t\t\tvar isFixedLength = null != facets[MetadataHelpers.FixedLengthFacetName].Value && (bool)facets[MetadataHelpers.FixedLengthFacetName].Value;\n\t\t\t\t\tvar f = facets[MetadataHelpers.MaxLengthFacetName];\n\n\t\t\t\t\tvar isMaxLength = f.IsUnbounded || null == f.Value || (int)f.Value > BinaryMaxSize;\n\t\t\t\t\tvar maxLength = !isMaxLength ? (int)f.Value : Int32.MinValue;\n\n\t\t\t\t\tTypeUsage tu;\n\t\t\t\t\tif (isFixedLength)\n\t\t\t\t\t{\n\t\t\t\t\t\ttu = TypeUsage.CreateBinaryTypeUsage(StoreTypeNameToStorePrimitiveType[\"blob\"], true, maxLength);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif (isMaxLength)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttu = TypeUsage.CreateBinaryTypeUsage(StoreTypeNameToStorePrimitiveType[\"blob\"], false);\n\t\t\t\t\t\t\tDebug.Assert(tu.Facets[\"MaxLength\"].Description.IsConstant, \"blob is not constant!\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttu = TypeUsage.CreateBinaryTypeUsage(StoreTypeNameToStorePrimitiveType[\"blob\"], false, maxLength);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn tu;\n\t\t\t\t}\n\n\t\t\tcase PrimitiveTypeKind.String: // char, varchar, text blob\n\t\t\t\t{\n\t\t\t\t\tvar isUnicode = null == facets[MetadataHelpers.UnicodeFacetName].Value || (bool)facets[MetadataHelpers.UnicodeFacetName].Value;\n\t\t\t\t\tvar isFixedLength = null != facets[MetadataHelpers.FixedLengthFacetName].Value && (bool)facets[MetadataHelpers.FixedLengthFacetName].Value;\n\t\t\t\t\tvar f = facets[MetadataHelpers.MaxLengthFacetName];\n\t\t\t\t\t// maxlen is true if facet value is unbounded, the value is bigger than the limited string sizes *or* the facet\n\t\t\t\t\t// value is null. this is needed since functions still have maxlength facet value as null\n\t\t\t\t\tvar isMaxLength = f.IsUnbounded || null == f.Value || (int)f.Value > (isUnicode ? UnicodeVarcharMaxSize : AsciiVarcharMaxSize);\n\t\t\t\t\tvar maxLength = !isMaxLength ? (int)f.Value : Int32.MinValue;\n\n\t\t\t\t\tTypeUsage tu;\n\n\t\t\t\t\tif (isUnicode)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (isFixedLength)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttu = TypeUsage.CreateStringTypeUsage(StoreTypeNameToStorePrimitiveType[\"char\"], true, true, maxLength);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (isMaxLength)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttu = TypeUsage.CreateStringTypeUsage(StoreTypeNameToStorePrimitiveType[\"clob\"], true, false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttu = TypeUsage.CreateStringTypeUsage(StoreTypeNameToStorePrimitiveType[\"varchar\"], true, false, maxLength);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif (isFixedLength)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttu = TypeUsage.CreateStringTypeUsage(StoreTypeNameToStorePrimitiveType[\"char\"], false, true, maxLength);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (isMaxLength)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttu = TypeUsage.CreateStringTypeUsage(StoreTypeNameToStorePrimitiveType[\"clob\"], false, false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttu = TypeUsage.CreateStringTypeUsage(StoreTypeNameToStorePrimitiveType[\"varchar\"], false, false, maxLength);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn tu;\n\t\t\t\t}\n\n\t\t\tcase PrimitiveTypeKind.DateTime: // datetime, date\n\t\t\t\t{\n\t\t\t\t\tbool useTimestamp;\n\t\t\t\t\tif (TypeHelpers.TryGetPrecision(edmType, out var precision))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (precision == 0)\n\t\t\t\t\t\t\tuseTimestamp = false;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tuseTimestamp = true;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tuseTimestamp = true;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn TypeUsage.CreateDefaultTypeUsage(useTimestamp ? StoreTypeNameToStorePrimitiveType[\"timestamp\"] : StoreTypeNameToStorePrimitiveType[\"date\"]);\n\t\t\t\t}\n\n\t\t\tcase PrimitiveTypeKind.Time:\n\t\t\t\treturn TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType[\"time\"]);\n\n\t\t\tcase PrimitiveTypeKind.Guid:\n\t\t\t\treturn TypeUsage.CreateDefaultTypeUsage(StoreTypeNameToStorePrimitiveType[\"guid\"]);\n\n\t\t\tdefault:\n\t\t\t\tthrow new NotSupportedException(string.Format(\"There is no store type corresponding to the EDM type '{0}' of primitive type '{1}'.\", edmType, primitiveType.PrimitiveTypeKind));\n\t\t}\n\t}\n\n\tprivate XmlReader GetStoreSchemaMapping(string mslName)\n\t{\n\t\treturn GetXmlResource(GetStoreSchemaResourceName(mslName, \"msl\"));\n\t}\n\n\tprivate XmlReader GetStoreSchemaDescription(string ssdlName)\n\t{\n\t\treturn GetXmlResource(GetStoreSchemaResourceName(ssdlName, \"ssdl\"));\n\t}\n\n\tprivate static XmlReader GetXmlResource(string resourceName)\n\t{\n\t\tvar executingAssembly = Assembly.GetExecutingAssembly();\n\t\tvar stream = executingAssembly.GetManifestResourceStream(resourceName);\n\t\treturn XmlReader.Create(stream);\n\t}\n\n\tprivate static string GetManifestResourceName()\n\t{\n\t\treturn \"EntityFramework.Firebird.Resources.ProviderManifest.xml\";\n\t}\n\n\tprivate static string GetStoreSchemaResourceName(string name, string type)\n\t{\n\t\treturn string.Format(\"EntityFramework.Firebird.Resources.{0}.{1}\", name, type);\n\t}\n\n\tpublic override bool SupportsEscapingLikeArgument(out char escapeCharacter)\n\t{\n\t\tescapeCharacter = LikeEscapeCharacter;\n\t\treturn true;\n\t}\n\n\tpublic override string EscapeLikeArgument(string argument)\n\t{\n\t\tvar sb = new StringBuilder(argument);\n\t\tsb.Replace(LikeEscapeCharacter.ToString(), LikeEscapeCharacter.ToString() + LikeEscapeCharacter.ToString());\n\t\tsb.Replace(\"%\", LikeEscapeCharacter + \"%\");\n\t\tsb.Replace(\"_\", LikeEscapeCharacter + \"_\");\n\t\treturn sb.ToString();\n\t}\n\n\tpublic override bool SupportsInExpression()\n\t{\n\t\treturn true;\n\t}\n\n\tpublic override bool SupportsParameterOptimizationInSchemaQueries()\n\t{\n\t\treturn true;\n\t}\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/FbProviderServices.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Data.Common;\nusing System.Data.Entity.Core.Common;\nusing System.Data.Entity.Core.Common.CommandTrees;\nusing System.Data.Entity.Core.Metadata.Edm;\nusing System.Data.Entity.Infrastructure;\nusing System.Data.Entity.Infrastructure.DependencyResolution;\nusing System.Data.Entity.Infrastructure.Interception;\nusing System.Data.Entity.Migrations.Sql;\nusing System.Diagnostics;\nusing System.Linq;\nusing EntityFramework.Firebird.SqlGen;\nusing FirebirdSql.Data.FirebirdClient;\nusing FirebirdSql.Data.Isql;\nusing FirebirdSql.Data.Services;\n\nnamespace EntityFramework.Firebird;\n\npublic class FbProviderServices : DbProviderServices\n{\n\tpublic const string ProviderInvariantName = \"FirebirdSql.Data.FirebirdClient\";\n\tpublic static readonly FbProviderServices Instance = new FbProviderServices();\n\n\tpublic FbProviderServices()\n\t{\n\t\tAddDependencyResolver(new SingletonDependencyResolver<IDbConnectionFactory>(new FbConnectionFactory()));\n\t\tAddDependencyResolver(new SingletonDependencyResolver<Func<MigrationSqlGenerator>>(() => new FbMigrationSqlGenerator(), ProviderInvariantName));\n\t\tDbInterception.Add(new FbMigrationsTransactionsInterceptor());\n\t}\n\n\tprotected override DbCommandDefinition CreateDbCommandDefinition(DbProviderManifest manifest, DbCommandTree commandTree)\n\t{\n\t\tvar prototype = CreateCommand(manifest, commandTree);\n\t\tvar result = CreateCommandDefinition(prototype);\n\t\treturn result;\n\t}\n\n\tprivate DbCommand CreateCommand(DbProviderManifest manifest, DbCommandTree commandTree)\n\t{\n\t\tif (manifest == null)\n\t\t\tthrow new ArgumentNullException(\"manifest\");\n\n\t\tif (commandTree == null)\n\t\t\tthrow new ArgumentNullException(\"commandTree\");\n\n\t\tvar expectedTypes = PrepareTypeCoercions(commandTree);\n\n\t\tvar command = FbCommand.CreateWithTypeCoercions(expectedTypes);\n\n\t\tcommand.CommandText = SqlGenerator.GenerateSql(commandTree, out var parameters, out var commandType);\n\t\tcommand.CommandType = commandType;\n\n\t\t// Get the function (if any) implemented by the command tree since this influences our interpretation of parameters\n\t\tEdmFunction function = null;\n\t\tif (commandTree is DbFunctionCommandTree)\n\t\t{\n\t\t\tfunction = ((DbFunctionCommandTree)commandTree).EdmFunction;\n\t\t}\n\n\t\t// Now make sure we populate the command's parameters from the CQT's parameters:\n\t\tforeach (var queryParameter in commandTree.Parameters)\n\t\t{\n\t\t\tFbParameter parameter;\n\n\t\t\t// Use the corresponding function parameter TypeUsage where available (currently, the SSDL facets and\n\t\t\t// type trump user-defined facets and type in the EntityCommand).\n\t\t\tif (null != function && function.Parameters.TryGetValue(queryParameter.Key, false, out var functionParameter))\n\t\t\t{\n\t\t\t\tparameter = CreateSqlParameter(functionParameter.Name, functionParameter.TypeUsage, functionParameter.Mode, DBNull.Value);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tparameter = CreateSqlParameter(queryParameter.Key, queryParameter.Value, ParameterMode.In, DBNull.Value);\n\t\t\t}\n\n\t\t\tcommand.Parameters.Add(parameter);\n\t\t}\n\n\t\t// Now add parameters added as part of SQL gen (note: this feature is only safe for DML SQL gen which\n\t\t// does not support user parameters, where there is no risk of name collision)\n\t\tif (null != parameters && 0 < parameters.Count)\n\t\t{\n\t\t\tif (!(commandTree is DbInsertCommandTree) &&\n\t\t\t\t!(commandTree is DbUpdateCommandTree) &&\n\t\t\t\t!(commandTree is DbDeleteCommandTree))\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException(\"SqlGenParametersNotPermitted\");\n\t\t\t}\n\n\t\t\tforeach (var parameter in parameters)\n\t\t\t{\n\t\t\t\tcommand.Parameters.Add(parameter);\n\t\t\t}\n\t\t}\n\n\t\treturn command;\n\t}\n\n\tprotected override string GetDbProviderManifestToken(DbConnection connection)\n\t{\n\t\ttry\n\t\t{\n\t\t\tvar serverVersion = default(Version);\n\t\t\tif (connection.State == ConnectionState.Open)\n\t\t\t{\n\t\t\t\tserverVersion = FbServerProperties.ParseServerVersion(connection.ServerVersion);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tvar serverProperties = new FbServerProperties() { ConnectionString = connection.ConnectionString };\n\t\t\t\tserverVersion = FbServerProperties.ParseServerVersion(serverProperties.GetServerVersion());\n\t\t\t}\n\t\t\treturn serverVersion.ToString(2);\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Could not retrieve storage version.\", ex);\n\t\t}\n\t}\n\n\tprotected override DbProviderManifest GetDbProviderManifest(string versionHint)\n\t{\n\t\tif (string.IsNullOrEmpty(versionHint))\n\t\t{\n\t\t\tthrow new ArgumentException(\"Could not determine store version; a valid store connection or a version hint is required.\");\n\t\t}\n\t\treturn new FbProviderManifest(versionHint);\n\t}\n\n\tinternal static FbParameter CreateSqlParameter(string name, TypeUsage type, ParameterMode mode, object value)\n\t{\n\t\tvar result = new FbParameter(name, value);\n\n\t\tvar direction = MetadataHelpers.ParameterModeToParameterDirection(mode);\n\t\tif (result.Direction != direction)\n\t\t{\n\t\t\tresult.Direction = direction;\n\t\t}\n\n\t\t// output parameters are handled differently (we need to ensure there is space for return\n\t\t// values where the user has not given a specific Size/MaxLength)\n\t\tvar isOutParam = mode != ParameterMode.In;\n\t\tvar sqlDbType = GetSqlDbType(type, isOutParam, out var size);\n\n\t\tif (result.FbDbType != sqlDbType)\n\t\t{\n\t\t\tresult.FbDbType = sqlDbType;\n\t\t}\n\n\t\t// Note that we overwrite 'facet' parameters where either the value is different or\n\t\t// there is an output parameter.\n\t\tif (size.HasValue && (isOutParam || result.Size != size.Value))\n\t\t{\n\t\t\tresult.Size = size.Value;\n\t\t}\n\n\t\tvar isNullable = MetadataHelpers.IsNullable(type);\n\t\tif (isOutParam || isNullable != result.IsNullable)\n\t\t{\n\t\t\tresult.IsNullable = isNullable;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprivate static FbDbType GetSqlDbType(TypeUsage type, bool isOutParam, out int? size)\n\t{\n\t\t// only supported for primitive type\n\t\tvar primitiveTypeKind = MetadataHelpers.GetPrimitiveTypeKind(type);\n\n\t\tsize = default;\n\n\t\tswitch (primitiveTypeKind)\n\t\t{\n\t\t\tcase PrimitiveTypeKind.Boolean:\n\t\t\t\treturn FbDbType.SmallInt;\n\n\t\t\tcase PrimitiveTypeKind.Int16:\n\t\t\t\treturn FbDbType.SmallInt;\n\n\t\t\tcase PrimitiveTypeKind.Int32:\n\t\t\t\treturn FbDbType.Integer;\n\n\t\t\tcase PrimitiveTypeKind.Int64:\n\t\t\t\treturn FbDbType.BigInt;\n\n\t\t\tcase PrimitiveTypeKind.Double:\n\t\t\t\treturn FbDbType.Double;\n\n\t\t\tcase PrimitiveTypeKind.Single:\n\t\t\t\treturn FbDbType.Float;\n\n\t\t\tcase PrimitiveTypeKind.Decimal:\n\t\t\t\treturn FbDbType.Decimal;\n\n\t\t\tcase PrimitiveTypeKind.Binary:\n\t\t\t\t// for output parameters, ensure there is space...\n\t\t\t\tsize = GetParameterSize(type, isOutParam);\n\t\t\t\treturn GetBinaryDbType(type);\n\n\t\t\tcase PrimitiveTypeKind.String:\n\t\t\t\tsize = GetParameterSize(type, isOutParam);\n\t\t\t\treturn GetStringDbType(type);\n\n\t\t\tcase PrimitiveTypeKind.DateTime:\n\t\t\t\treturn FbDbType.TimeStamp;\n\n\t\t\tcase PrimitiveTypeKind.Time:\n\t\t\t\treturn FbDbType.Time;\n\n\t\t\tcase PrimitiveTypeKind.Guid:\n\t\t\t\treturn FbDbType.Guid;\n\n\t\t\tdefault:\n\t\t\t\tDebug.Fail(\"unknown PrimitiveTypeKind \" + primitiveTypeKind);\n\t\t\t\tthrow new InvalidOperationException(\"unknown PrimitiveTypeKind \" + primitiveTypeKind);\n\t\t}\n\t}\n\n\tprivate static int? GetParameterSize(TypeUsage type, bool isOutParam)\n\t{\n\t\tif (MetadataHelpers.TryGetMaxLength(type, out var maxLength))\n\t\t{\n\t\t\t// if the MaxLength facet has a specific value use it\n\t\t\treturn maxLength;\n\t\t}\n\t\telse if (isOutParam)\n\t\t{\n\t\t\t// if the parameter is a return/out/inout parameter, ensure there\n\t\t\t// is space for any value\n\t\t\treturn int.MaxValue;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// no value\n\t\t\treturn default;\n\t\t}\n\t}\n\n\tprivate static FbDbType GetStringDbType(TypeUsage type)\n\t{\n\t\tDebug.Assert(type.EdmType.BuiltInTypeKind == BuiltInTypeKind.PrimitiveType && PrimitiveTypeKind.String == ((PrimitiveType)type.EdmType).PrimitiveTypeKind, \"only valid for string type\");\n\n\t\tFbDbType dbType;\n\t\t// Specific type depends on whether the string is a unicode string and whether it is a fixed length string.\n\t\t// By default, assume widest type (unicode) and most common type (variable length)\n\t\tif (!MetadataHelpers.TryGetIsFixedLength(type, out var fixedLength))\n\t\t{\n\t\t\tfixedLength = false;\n\t\t}\n\n\t\tif (!MetadataHelpers.TryGetIsUnicode(type, out var unicode))\n\t\t{\n\t\t\tunicode = true;\n\t\t}\n\n\t\tif (fixedLength)\n\t\t{\n\t\t\tdbType = (unicode ? FbDbType.Char : FbDbType.Char);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (!MetadataHelpers.TryGetMaxLength(type, out var maxLength))\n\t\t\t{\n\t\t\t\tmaxLength = (unicode ? FbProviderManifest.UnicodeVarcharMaxSize : FbProviderManifest.AsciiVarcharMaxSize);\n\t\t\t}\n\t\t\tif (maxLength == default || maxLength > (unicode ? FbProviderManifest.UnicodeVarcharMaxSize : FbProviderManifest.AsciiVarcharMaxSize))\n\t\t\t{\n\t\t\t\tdbType = FbDbType.Text;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tdbType = (unicode ? FbDbType.VarChar : FbDbType.VarChar);\n\t\t\t}\n\t\t}\n\n\t\treturn dbType;\n\t}\n\n\tprivate static FbDbType GetBinaryDbType(TypeUsage type)\n\t{\n\t\tDebug.Assert(type.EdmType.BuiltInTypeKind == BuiltInTypeKind.PrimitiveType &&\n\t\t\tPrimitiveTypeKind.Binary == ((PrimitiveType)type.EdmType).PrimitiveTypeKind, \"only valid for binary type\");\n\n\t\t// Specific type depends on whether the binary value is fixed length. By default, assume variable length.\n\t\t//bool fixedLength;\n\t\t//if (!MetadataHelpers.TryGetIsFixedLength(type, out fixedLength))\n\t\t//{\n\t\t//    fixedLength = false;\n\t\t//}\n\n\t\treturn FbDbType.Binary;\n\t}\n\n\tprivate static Type[] PrepareTypeCoercions(DbCommandTree commandTree)\n\t{\n\t\tif (commandTree is DbQueryCommandTree queryTree)\n\t\t{\n\t\t\tif (queryTree.Query is DbProjectExpression projectExpression)\n\t\t\t{\n\t\t\t\tvar resultsType = projectExpression.Projection.ResultType.EdmType;\n\t\t\t\tif (resultsType is StructuralType resultsAsStructuralType)\n\t\t\t\t{\n\t\t\t\t\tvar members = resultsAsStructuralType.Members;\n\t\t\t\t\treturn members.Select(ExtractExpectedTypeForCoercion).ToArray();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (commandTree is DbFunctionCommandTree functionTree)\n\t\t{\n\t\t\tif (functionTree.ResultType != null)\n\t\t\t{\n\t\t\t\tDebug.Assert(MetadataHelpers.IsCollectionType(functionTree.ResultType.EdmType), \"Result type of a function is expected to be a collection of RowType or PrimitiveType\");\n\n\t\t\t\tvar typeUsage = MetadataHelpers.GetElementTypeUsage(functionTree.ResultType);\n\t\t\t\tvar elementType = typeUsage.EdmType;\n\t\t\t\tif (MetadataHelpers.IsRowType(elementType))\n\t\t\t\t{\n\t\t\t\t\tvar members = ((RowType)elementType).Members;\n\t\t\t\t\treturn members.Select(ExtractExpectedTypeForCoercion).ToArray();\n\t\t\t\t}\n\t\t\t\telse if (MetadataHelpers.IsPrimitiveType(elementType))\n\t\t\t\t{\n\t\t\t\t\treturn new[] { MakeTypeCoercion(((PrimitiveType)elementType).ClrEquivalentType, typeUsage) };\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tDebug.Fail(\"Result type of a function is expected to be a collection of RowType or PrimitiveType\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tprivate static Type ExtractExpectedTypeForCoercion(EdmMember member)\n\t{\n\t\tvar type = ((PrimitiveType)member.TypeUsage.EdmType).ClrEquivalentType;\n\t\treturn MakeTypeCoercion(type, member.TypeUsage);\n\t}\n\n\tprivate static Type MakeTypeCoercion(Type type, TypeUsage typeUsage)\n\t{\n\t\tif (type.IsValueType && MetadataHelpers.IsNullable(typeUsage))\n\t\t\treturn typeof(Nullable<>).MakeGenericType(type);\n\t\treturn type;\n\t}\n\n\tprotected override void DbCreateDatabase(DbConnection connection, int? commandTimeout,\n#pragma warning disable 3001\n\t\t\tStoreItemCollection storeItemCollection)\n#pragma warning restore 3001\n\t{\n\t\tFbConnection.CreateDatabase(connection.ConnectionString, pageSize: 16384);\n\t\tvar script = DbCreateDatabaseScript(GetDbProviderManifestToken(connection), storeItemCollection);\n\t\tvar fbScript = new FbScript(script);\n\t\tfbScript.Parse();\n\t\tif (fbScript.Results.Any())\n\t\t{\n\t\t\tusing (var fbConnection = new FbConnection(connection.ConnectionString))\n\t\t\t{\n\t\t\t\tvar execution = new FbBatchExecution(fbConnection);\n\t\t\t\texecution.AppendSqlStatements(fbScript);\n\t\t\t\texecution.Execute();\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected override string DbCreateDatabaseScript(string providerManifestToken,\n#pragma warning disable 3001\n\t\t\tStoreItemCollection storeItemCollection)\n#pragma warning restore 3001\n\t{\n\t\treturn SsdlToFb.Transform(storeItemCollection, providerManifestToken);\n\t}\n\n\tprotected override bool DbDatabaseExists(DbConnection connection, int? commandTimeout,\n#pragma warning disable 3001\n\t\t\tStoreItemCollection storeItemCollection)\n#pragma warning restore 3001\n\t{\n\t\tif (connection.State == ConnectionState.Open\n\t\t\t   || connection.State == ConnectionState.Executing\n\t\t\t   || connection.State == ConnectionState.Fetching)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tconnection.Open();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tconnection.Close();\n\t\t\t\t}\n\t\t\t\tcatch { }\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected override void DbDeleteDatabase(DbConnection connection, int? commandTimeout,\n#pragma warning disable 3001\n\t\t\tStoreItemCollection storeItemCollection)\n#pragma warning restore 3001\n\t{\n\t\tFbConnection.DropDatabase(connection.ConnectionString);\n\t}\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/IFbMigrationSqlGeneratorBehavior.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\n\nnamespace EntityFramework.Firebird;\n\npublic interface IFbMigrationSqlGeneratorBehavior\n{\n\tIEnumerable<string> CreateIdentityForColumn(string columnName, string tableName);\n\tIEnumerable<string> DropIdentityForColumn(string columnName, string tableName);\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/MetadataHelpers.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Data;\nusing System.Data.Entity.Core.Metadata.Edm;\nusing System.Diagnostics;\n\nnamespace EntityFramework.Firebird;\n\ninternal static class MetadataHelpers\n{\n\t#region Type Helpers\n\n\t/// <summary>\n\t/// Cast the EdmType of the given type usage to the given TEdmType\n\t/// </summary>\n\t/// <typeparam name=\"TEdmType\"></typeparam>\n\t/// <param name=\"typeUsage\"></param>\n\t/// <returns></returns>\n\tinternal static TEdmType GetEdmType<TEdmType>(TypeUsage typeUsage)\n\t\twhere TEdmType : EdmType\n\t{\n\t\treturn (TEdmType)typeUsage.EdmType;\n\t}\n\n\t/// <summary>\n\t/// Gets the TypeUsage of the elment if the given type is a collection type\n\t/// </summary>\n\t/// <param name=\"type\"></param>\n\t/// <returns></returns>\n\tinternal static TypeUsage GetElementTypeUsage(TypeUsage type)\n\t{\n\t\tif (MetadataHelpers.IsCollectionType(type))\n\t\t{\n\t\t\treturn ((CollectionType)type.EdmType).TypeUsage;\n\t\t}\n\t\treturn null;\n\t}\n\n\t/// <summary>\n\t/// Retrieves the properties of in the EdmType underlying the input type usage,\n\t///  if that EdmType is a structured type (EntityType, RowType).\n\t/// </summary>\n\t/// <param name=\"typeUsage\"></param>\n\t/// <returns></returns>\n\tinternal static IList<EdmProperty> GetProperties(TypeUsage typeUsage)\n\t{\n\t\treturn MetadataHelpers.GetProperties(typeUsage.EdmType);\n\t}\n\n\t/// <summary>\n\t/// Retrieves the properties of the given EdmType, if it is\n\t///  a structured type (EntityType, RowType).\n\t/// </summary>\n\t/// <param name=\"edmType\"></param>\n\t/// <returns></returns>\n\tinternal static IList<EdmProperty> GetProperties(EdmType edmType)\n\t{\n\t\tswitch (edmType.BuiltInTypeKind)\n\t\t{\n\t\t\tcase BuiltInTypeKind.ComplexType:\n\t\t\t\treturn ((ComplexType)edmType).Properties;\n\t\t\tcase BuiltInTypeKind.EntityType:\n\t\t\t\treturn ((EntityType)edmType).Properties;\n\t\t\tcase BuiltInTypeKind.RowType:\n\t\t\t\treturn ((RowType)edmType).Properties;\n\t\t\tdefault:\n\t\t\t\treturn new List<EdmProperty>();\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Is the given type usage over a collection type\n\t/// </summary>\n\t/// <param name=\"typeUsage\"></param>\n\t/// <returns></returns>\n\tinternal static bool IsCollectionType(TypeUsage typeUsage)\n\t{\n\t\treturn MetadataHelpers.IsCollectionType(typeUsage.EdmType);\n\t}\n\n\t/// <summary>\n\t/// Is the given type a collection type\n\t/// </summary>\n\t/// <param name=\"type\"></param>\n\t/// <returns></returns>\n\tinternal static bool IsCollectionType(EdmType type)\n\t{\n\t\treturn (BuiltInTypeKind.CollectionType == type.BuiltInTypeKind);\n\t}\n\n\t/// <summary>\n\t/// Is the given type usage over a primitive type\n\t/// </summary>\n\t/// <param name=\"type\"></param>\n\t/// <returns></returns>\n\tinternal static bool IsPrimitiveType(TypeUsage type)\n\t{\n\t\treturn MetadataHelpers.IsPrimitiveType(type.EdmType);\n\t}\n\n\t/// <summary>\n\t/// Is the given type a primitive type\n\t/// </summary>\n\t/// <param name=\"type\"></param>\n\t/// <returns></returns>\n\tinternal static bool IsPrimitiveType(EdmType type)\n\t{\n\t\treturn (BuiltInTypeKind.PrimitiveType == type.BuiltInTypeKind);\n\t}\n\n\t/// <summary>\n\t/// Is the given type usage over a row type\n\t/// </summary>\n\t/// <param name=\"type\"></param>\n\t/// <returns></returns>\n\tinternal static bool IsRowType(TypeUsage type)\n\t{\n\t\treturn MetadataHelpers.IsRowType(type.EdmType);\n\t}\n\n\t/// <summary>\n\t/// Is the given type a row type\n\t/// </summary>\n\t/// <param name=\"type\"></param>\n\t/// <returns></returns>\n\tinternal static bool IsRowType(EdmType type)\n\t{\n\t\treturn (BuiltInTypeKind.RowType == type.BuiltInTypeKind);\n\t}\n\n\t/// <summary>\n\t/// Gets the type of the given type usage if it is a primitive type\n\t/// </summary>\n\t/// <param name=\"type\"></param>\n\t/// <param name=\"typeKind\"></param>\n\t/// <returns></returns>\n\tinternal static bool TryGetPrimitiveTypeKind(TypeUsage type, out PrimitiveTypeKind typeKind)\n\t{\n\t\tif (type != null && type.EdmType != null && type.EdmType.BuiltInTypeKind == BuiltInTypeKind.PrimitiveType)\n\t\t{\n\t\t\ttypeKind = ((PrimitiveType)type.EdmType).PrimitiveTypeKind;\n\t\t\treturn true;\n\t\t}\n\n\t\ttypeKind = default;\n\t\treturn false;\n\t}\n\n\tinternal static PrimitiveTypeKind GetPrimitiveTypeKind(TypeUsage type)\n\t{\n\t\tif (!MetadataHelpers.TryGetPrimitiveTypeKind(type, out var returnValue))\n\t\t{\n\t\t\tDebug.Assert(false, \"Cannot create parameter of non-primitive type\");\n\t\t\tthrow new NotSupportedException(\"Cannot create parameter of non-primitive type\");\n\t\t}\n\t\treturn returnValue;\n\t}\n\n\t/// <summary>\n\t/// Gets the value for the metadata property with the given name\n\t/// </summary>\n\t/// <typeparam name=\"T\"></typeparam>\n\t/// <param name=\"item\"></param>\n\t/// <param name=\"propertyName\"></param>\n\t/// <returns></returns>\n\tinternal static T TryGetValueForMetadataProperty<T>(MetadataItem item, string propertyName)\n\t{\n\t\tif (!item.MetadataProperties.TryGetValue(propertyName, true, out var property))\n\t\t{\n\t\t\treturn default;\n\t\t}\n\n\t\treturn (T)property.Value;\n\t}\n\n\tinternal static bool IsPrimitiveType(TypeUsage type, PrimitiveTypeKind primitiveType)\n\t{\n\t\tif (TryGetPrimitiveTypeKind(type, out var typeKind))\n\t\t{\n\t\t\treturn (typeKind == primitiveType);\n\t\t}\n\t\treturn false;\n\t}\n\n\t#endregion\n\n\t#region Facet Support\n\n\t#region Facet Names\n\t/// <summary>\n\t/// Name of the MaxLength Facet\n\t/// </summary>\n\tinternal const string MaxLengthFacetName = \"MaxLength\";\n\n\t/// <summary>\n\t/// Name of the Unicode Facet\n\t/// </summary>\n\tinternal const string UnicodeFacetName = \"Unicode\";\n\n\t/// <summary>\n\t/// Name of the FixedLength Facet\n\t/// </summary>\n\tinternal const string FixedLengthFacetName = \"FixedLength\";\n\n\t/// <summary>\n\t/// Name of the Precision Facet\n\t/// </summary>\n\tinternal const string PrecisionFacetName = \"Precision\";\n\n\t/// <summary>\n\t/// Name of the Scale Facet\n\t/// </summary>\n\tinternal const string ScaleFacetName = \"Scale\";\n\n\t/// <summary>\n\t/// Name of the DefaultValue Facet\n\t/// </summary>\n\tinternal const string DefaultValueFacetName = \"DefaultValue\";\n\n\t/// <summary>\n\t/// Name of the Nullable Facet\n\t/// </summary>\n\tinternal const string NullableFacetName = \"Nullable\";\n\n\t/// <summary>\n\t/// Name of StoreGeneratedPattern Facet\n\t/// </summary>\n\tinternal const string StoreGeneratedPatternFacetName = \"StoreGeneratedPattern\";\n\t#endregion\n\n\t#region Facet Retreival Helpers\n\n\t/// <summary>\n\t/// Get the value specified on the given type usage for the given facet name.\n\t/// If the faces does not have a value specifid or that value is null returns\n\t/// the default value for that facet.\n\t/// </summary>\n\t/// <typeparam name=\"T\"></typeparam>\n\t/// <param name=\"type\"></param>\n\t/// <param name=\"facetName\"></param>\n\t/// <returns></returns>\n\t/// <summary>\n\t/// Get the value specified on the given type usage for the given facet name.\n\t/// If the faces does not have a value specifid or that value is null returns\n\t/// the default value for that facet.\n\t/// </summary>\n\t/// <typeparam name=\"T\"></typeparam>\n\t/// <param name=\"type\"></param>\n\t/// <param name=\"facetName\"></param>\n\t/// <returns></returns>\n\tinternal static T GetFacetValueOrDefault<T>(TypeUsage type, string facetName, T defaultValue)\n\t{\n\t\t//Get the value for the facet, if any\n\t\tif (type.Facets.TryGetValue(facetName, false, out var facet) && facet.Value != null && !facet.IsUnbounded)\n\t\t{\n\t\t\treturn (T)facet.Value;\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn defaultValue;\n\t\t}\n\t}\n\n\tinternal static bool IsFacetValueConstant(TypeUsage type, string facetName)\n\t{\n\t\treturn MetadataHelpers.GetFacet(((PrimitiveType)type.EdmType).FacetDescriptions, facetName).IsConstant;\n\t}\n\n\tprivate static FacetDescription GetFacet(IEnumerable<FacetDescription> facetCollection, string facetName)\n\t{\n\t\tforeach (var facetDescription in facetCollection)\n\t\t{\n\t\t\tif (facetDescription.FacetName == facetName)\n\t\t\t{\n\t\t\t\treturn facetDescription;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/// <summary>\n\t/// Given a facet name and an EdmType, tries to get that facet's description.\n\t/// </summary>\n\t/// <param name=\"edmType\"></param>\n\t/// <param name=\"facetName\"></param>\n\t/// <param name=\"facetDescription\"></param>\n\t/// <returns></returns>\n\tinternal static bool TryGetTypeFacetDescriptionByName(EdmType edmType, string facetName, out FacetDescription facetDescription)\n\t{\n\t\tfacetDescription = null;\n\t\tif (MetadataHelpers.IsPrimitiveType(edmType))\n\t\t{\n\t\t\tvar primitiveType = (PrimitiveType)edmType;\n\t\t\tforeach (var fd in primitiveType.FacetDescriptions)\n\t\t\t{\n\t\t\t\tif (facetName.Equals(fd.FacetName, StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\tfacetDescription = fd;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tinternal static bool IsNullable(TypeUsage type)\n\t{\n\t\tif (type.Facets.TryGetValue(NullableFacetName, false, out var nullableFacet))\n\t\t{\n\t\t\treturn (bool)nullableFacet.Value;\n\t\t}\n\t\treturn false;\n\t}\n\n\tinternal static bool TryGetMaxLength(TypeUsage type, out int? maxLength)\n\t{\n\t\tif (!IsPrimitiveType(type, PrimitiveTypeKind.String) &&\n\t\t\t!IsPrimitiveType(type, PrimitiveTypeKind.Binary))\n\t\t{\n\t\t\tmaxLength = 0;\n\t\t\treturn false;\n\t\t}\n\n\t\t// Binary and String FixedLength facets share the same name\n\t\treturn TryGetIntFacetValue(type, MaxLengthFacetName, out maxLength);\n\t}\n\n\tinternal static bool TryGetIntFacetValue(TypeUsage type, string facetName, out int? intValue)\n\t{\n\t\tintValue = 0;\n\n\t\tif (type.Facets.TryGetValue(facetName, false, out var intFacet) && intFacet.Value != null)\n\t\t{\n\t\t\tif (!intFacet.IsUnbounded)\n\t\t\t\tintValue = (int)intFacet.Value;\n\t\t\telse\n\t\t\t\tintValue = default;\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tinternal static bool TryGetIsFixedLength(TypeUsage type, out bool isFixedLength)\n\t{\n\t\tif (!IsPrimitiveType(type, PrimitiveTypeKind.String) &&\n\t\t\t!IsPrimitiveType(type, PrimitiveTypeKind.Binary))\n\t\t{\n\t\t\tisFixedLength = false;\n\t\t\treturn false;\n\t\t}\n\n\t\t// Binary and String MaxLength facets share the same name\n\t\treturn TryGetBooleanFacetValue(type, FixedLengthFacetName, out isFixedLength);\n\t}\n\n\tinternal static bool TryGetBooleanFacetValue(TypeUsage type, string facetName, out bool boolValue)\n\t{\n\t\tboolValue = false;\n\t\tif (type.Facets.TryGetValue(facetName, false, out var boolFacet) && boolFacet.Value != null)\n\t\t{\n\t\t\tboolValue = (bool)boolFacet.Value;\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tinternal static bool TryGetIsUnicode(TypeUsage type, out bool isUnicode)\n\t{\n\t\tif (!IsPrimitiveType(type, PrimitiveTypeKind.String))\n\t\t{\n\t\t\tisUnicode = false;\n\t\t\treturn false;\n\t\t}\n\n\t\treturn TryGetBooleanFacetValue(type, UnicodeFacetName, out isUnicode);\n\t}\n\n\t#endregion\n\n\t#endregion\n\n\tinternal static bool IsCanonicalFunction(EdmFunction function)\n\t{\n\t\treturn (function.NamespaceName == \"Edm\");\n\t}\n\n\tinternal static bool IsStoreFunction(EdmFunction function)\n\t{\n\t\treturn !IsCanonicalFunction(function);\n\t}\n\n\t// Returns ParameterDirection corresponding to given ParameterMode\n\tinternal static ParameterDirection ParameterModeToParameterDirection(ParameterMode mode)\n\t{\n\t\tswitch (mode)\n\t\t{\n\t\t\tcase ParameterMode.In:\n\t\t\t\treturn ParameterDirection.Input;\n\n\t\t\tcase ParameterMode.InOut:\n\t\t\t\treturn ParameterDirection.InputOutput;\n\n\t\t\tcase ParameterMode.Out:\n\t\t\t\treturn ParameterDirection.Output;\n\n\t\t\tcase ParameterMode.ReturnValue:\n\t\t\t\treturn ParameterDirection.ReturnValue;\n\n\t\t\tdefault:\n\t\t\t\tDebug.Fail(\"unrecognized mode \" + mode.ToString());\n\t\t\t\treturn default;\n\t\t}\n\t}\n\n\tinternal static string GetTableName(EntitySetBase entitySetBase)\n\t{\n\t\tvar tableName = MetadataHelpers.TryGetValueForMetadataProperty<string>(entitySetBase, \"Table\");\n\t\treturn !string.IsNullOrEmpty(tableName)\n\t\t\t? tableName\n\t\t\t: entitySetBase.Name;\n\t}\n\n\tprivate static bool IsStoreGeneratedPattern(EdmMember member, StoreGeneratedPattern pattern)\n\t{\n\t\treturn (member.TypeUsage.Facets.TryGetValue(StoreGeneratedPatternFacetName, false, out var item) && ((StoreGeneratedPattern)item.Value) == pattern);\n\t}\n\tinternal static bool IsStoreGeneratedComputed(EdmMember member)\n\t{\n\t\treturn IsStoreGeneratedPattern(member, StoreGeneratedPattern.Computed);\n\t}\n\tinternal static bool IsStoreGeneratedIdentity(EdmMember member)\n\t{\n\t\treturn IsStoreGeneratedPattern(member, StoreGeneratedPattern.Identity);\n\t}\n\tinternal static bool IsStoreGenerated(EdmMember member)\n\t{\n\t\treturn IsStoreGeneratedComputed(member) || IsStoreGeneratedIdentity(member);\n\t}\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/Resources/ProviderManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<ProviderManifest Namespace=\"FirebirdClient\" xmlns=\"http://schemas.microsoft.com/ado/2006/04/edm/providermanifest\">\n  <Types>\n    <Type Name=\"smallint\" PrimitiveTypeKind=\"Int16\">\n    </Type>\n    <Type Name=\"int\" PrimitiveTypeKind=\"Int32\">\n    </Type>\n    <Type Name=\"bigint\" PrimitiveTypeKind=\"Int64\">\n    </Type>\n    <Type Name=\"float\" PrimitiveTypeKind=\"Single\">\n    </Type>\n    <Type Name=\"double\" PrimitiveTypeKind=\"Double\">\n    </Type>\n    <Type Name=\"decimal\" PrimitiveTypeKind=\"Decimal\">\n      <FacetDescriptions>\n        <Precision Minimum=\"1\" Maximum=\"18\" DefaultValue=\"9\" Constant=\"false\" />\n        <Scale Minimum=\"0\" Maximum=\"18\" DefaultValue=\"0\" Constant=\"false\" />\n      </FacetDescriptions>\n    </Type>\n    <Type Name=\"numeric\" PrimitiveTypeKind=\"Decimal\">\n      <FacetDescriptions>\n        <Precision Minimum=\"1\" Maximum=\"18\" DefaultValue=\"9\" Constant=\"false\" />\n        <Scale Minimum=\"0\" Maximum=\"18\" DefaultValue=\"0\" Constant=\"false\" />\n      </FacetDescriptions>\n    </Type>\n    <Type Name=\"timestamp\" PrimitiveTypeKind=\"DateTime\">\n      <FacetDescriptions>\n        <Precision DefaultValue=\"4\" Constant=\"true\" />\n      </FacetDescriptions>\n    </Type>\n    <Type Name=\"date\" PrimitiveTypeKind=\"DateTime\">\n      <FacetDescriptions>\n        <Precision DefaultValue=\"0\" Constant=\"true\" />\n      </FacetDescriptions>\n    </Type>\n    <Type Name=\"time\" PrimitiveTypeKind=\"Time\">\n      <FacetDescriptions>\n        <Precision DefaultValue=\"4\" Constant=\"true\" />\n      </FacetDescriptions>\n    </Type>\n    <Type Name=\"smallint_bool\" PrimitiveTypeKind=\"Boolean\">\n    </Type>\n    <Type Name=\"char\" PrimitiveTypeKind=\"String\">\n      <FacetDescriptions>\n        <MaxLength Minimum=\"1\" Maximum=\"32765\" DefaultValue=\"32765\" Constant=\"false\" />\n        <Unicode DefaultValue=\"false\" Constant=\"false\" />\n        <FixedLength DefaultValue=\"true\" Constant=\"true\" />\n      </FacetDescriptions>\n    </Type>\n    <Type Name=\"varchar\" PrimitiveTypeKind=\"String\">\n      <FacetDescriptions>\n        <MaxLength Minimum=\"1\" Maximum=\"32765\" DefaultValue=\"32765\" Constant=\"false\" />\n        <Unicode DefaultValue=\"true\" Constant=\"false\" />\n        <FixedLength DefaultValue=\"false\" Constant=\"true\" />\n      </FacetDescriptions>\n    </Type>\n    <Type Name=\"blob\" PrimitiveTypeKind=\"Binary\">\n      <FacetDescriptions>\n        <MaxLength DefaultValue=\"2147483647\" Constant=\"true\" />\n        <FixedLength DefaultValue=\"false\" Constant=\"true\" />\n      </FacetDescriptions>\n    </Type>\n    <Type Name=\"clob\" PrimitiveTypeKind=\"String\">\n      <FacetDescriptions>\n        <MaxLength DefaultValue=\"2147483647\" Constant=\"true\" />\n        <Unicode DefaultValue=\"true\" Constant=\"false\" />\n        <FixedLength DefaultValue=\"false\" Constant=\"true\" />\n      </FacetDescriptions>\n    </Type>\n\t\t<Type Name=\"guid\" PrimitiveTypeKind=\"Guid\">\n\t\t</Type>\n  </Types>\n  <Functions>\n    <!-- BEGIN SYSTEM FUNCTIONS ##################################### -->\n    <!-- CURRENT_TIMESTAMP -->\n    <Function Name=\"CURRENT_TIMESTAMP\" BuiltIn=\"true\" NiladicFunction=\"true\">\n      <ReturnType Type=\"DateTime\" />\n    </Function>\n    \n    <!-- CURRENT_DATE -->\n    <Function Name=\"CURRENT_DATE\" BuiltIn=\"true\" NiladicFunction=\"true\">\n      <ReturnType Type=\"DateTime\" />\n    </Function>\n\n    <!-- CURRENT_USER -->\n    <Function Name=\"CURRENT_USER\" BuiltIn=\"true\" NiladicFunction=\"true\">\n      <ReturnType Type=\"String\" Unicode=\"false\" />\n    </Function>\n    <!-- END SYSTEM FUNCTIONS ####################################### -->\n  </Functions>\n</ProviderManifest>\n"
  },
  {
    "path": "src/EntityFramework.Firebird/Resources/StoreSchemaDefinition.ssdl",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Schema Namespace=\"FirebirdClient_EF\" Provider=\"FirebirdSql.Data.FirebirdClient\" ProviderManifestToken=\"Firebird\" Alias=\"Self\" xmlns=\"http://schemas.microsoft.com/ado/2006/04/edm/ssdl\">\n  <EntityContainer Name=\"Schema\">\n    <EntitySet Name=\"STables\" EntityType=\"Self.Table\">\n      <DefiningQuery>\n        -- STables\n        SELECT\n        TRIM(rdb$relation_name) as \"Id\"\n        , 'Firebird' as \"CatalogName\"\n        , 'Firebird' as \"SchemaName\" \n        , TRIM(rdb$relation_name) as \"Name\"\n        FROM\n        rdb$relations\n        WHERE\n        rdb$view_source IS NULL AND rdb$system_flag = 0\n      </DefiningQuery>\n    </EntitySet>    \n    <EntitySet Name=\"STableColumns\" EntityType=\"Self.TableColumn\">\n      <DefiningQuery>\n        -- STableColumns\n        SELECT TRIM(rf.rdb$relation_name) || 'x' || TRIM(rf.rdb$field_name) as \"Id\"\n        , TRIM(rf.rdb$relation_name) as \"ParentId\"\n        , TRIM(rf.rdb$field_name) as \"Name\"\n        , rf.rdb$field_position+1 as \"Ordinal\"\n        , IIF(COALESCE(rf.rdb$null_flag, f.rdb$null_flag) IS NULL, 1, 0) as \"IsNullable\"\n        , TRIM(CASE\n        WHEN POSITION('#BOOL#', UPPER(rf.rdb$description)) &gt; 0 THEN 'smallint_bool'\n        WHEN POSITION('#GUID#', UPPER(rf.rdb$description)) &gt; 0 THEN 'guid'\n        ELSE CASE f.rdb$field_type\n          WHEN 7 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'smallint'\n            END\n          WHEN 8 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'int'\n            END\n          WHEN 16 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'bigint'\n            END\n          WHEN 10 THEN 'float'\n          WHEN 27 THEN 'double'\n          WHEN 12 THEN 'date'\n          WHEN 13 THEN 'time'\n          WHEN 35 THEN 'timestamp'\n          WHEN 261 THEN CASE f.rdb$field_sub_type\n            WHEN 1 THEN 'clob'\n            ELSE 'blob'\n            END\n          WHEN 37 THEN 'varchar'\n          WHEN 14 THEN 'char'\n          WHEN 40 THEN 'cstring'\n          END\n        END) as \"TypeName\"\n        , IIF(f.rdb$character_length = 0, 32765, f.rdb$character_length) as \"MaxLength\" --hot fix for CORE-2228\n        , IIF(f.rdb$field_precision = 0 AND f.rdb$field_scale &lt; 0, 18, f.rdb$field_precision) as \"Precision\"\n\t\t\t\t, 4 as \"DateTimePrecision\"\n\t\t\t\t, f.rdb$field_scale * (-1) as \"Scale\"\n\t\t\t\t, NULL as \"CollationCatalog\"\n\t\t\t\t, NULL as \"CollationSchema\"\n\t\t\t\t, NULL as \"CollationName\"\n\t\t\t\t, NULL as \"CharacterSetCatalog\"\n\t\t\t\t, NULL as \"CharacterSetSchema\"\n\t\t\t\t, NULL as \"CharacterSetName\"\n\t\t\t\t, 0 as \"IsMultiSet\"\n\t\t\t\t, IIF(POSITION('#PK_GEN#', UPPER(rf.rdb$description)) &gt; 0, 1, 0) as \"IsIdentity\"\n        , IIF(f.rdb$computed_blr IS NULL, 0, 1) as \"IsStoreGenerated\"\n        , COALESCE(rf.rdb$default_source, f.rdb$default_source) as \"Default\"\n        FROM\n        rdb$relation_fields rf\n        INNER JOIN rdb$fields f ON (rf.rdb$field_source = f.rdb$field_name)\n        INNER JOIN rdb$relations r ON (rf.rdb$relation_name = r.rdb$relation_name)\n        WHERE\n        rf.rdb$system_flag = 0 AND r.rdb$view_blr IS NULL\n      </DefiningQuery>\n    </EntitySet>\n\n    <EntitySet Name=\"SViews\" EntityType=\"Self.View\">\n      <DefiningQuery>\n        -- SViews\n        SELECT\n        TRIM(rdb$relation_name) as \"Id\"\n        , 'Firebird' as \"CatalogName\"\n        , 'Firebird' as \"SchemaName\"\n        , TRIM(rdb$relation_name) as \"Name\"\n        , rdb$view_source as \"ViewDefinition\"\n        , 1 as \"IsUpdatable\"\n        FROM\n        rdb$relations\n        WHERE\n        rdb$view_blr IS NOT NULL AND rdb$system_flag = 0\n      </DefiningQuery>\n    </EntitySet>   \n    <EntitySet Name=\"SViewColumns\" EntityType=\"Self.ViewColumn\">\n      <DefiningQuery>\n        -- SViewColumns\n        SELECT TRIM(rf.rdb$relation_name) || 'x' || TRIM(rf.rdb$field_name) as \"Id\"\n        , TRIM(rf.rdb$relation_name) as \"ParentId\"\n        , TRIM(rf.rdb$field_name) as \"Name\"\n        , rf.rdb$field_position+1 as \"Ordinal\"\n        , IIF(COALESCE(rf.rdb$null_flag, f.rdb$null_flag) IS NULL, 1, 0) as \"IsNullable\"\n        , TRIM(CASE\n        WHEN POSITION('#BOOL#', UPPER(rf.rdb$description)) &gt; 0 THEN 'smallint_bool'\n        WHEN POSITION('#GUID#', UPPER(rf.rdb$description)) &gt; 0 THEN 'guid'\n        ELSE CASE f.rdb$field_type\n          WHEN 7 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'smallint'\n            END\n          WHEN 8 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'int'\n            END\n          WHEN 16 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'bigint'\n            END\n          WHEN 10 THEN 'float'\n          WHEN 27 THEN 'double'\n          WHEN 12 THEN 'date'\n          WHEN 13 THEN 'time'\n          WHEN 35 THEN 'timestamp'\n          WHEN 261 THEN CASE f.rdb$field_sub_type\n            WHEN 1 THEN 'clob'\n            ELSE 'blob'\n            END\n          WHEN 37 THEN 'varchar'\n          WHEN 14 THEN 'char'\n          WHEN 40 THEN 'cstring'\n          END\n        END) as \"TypeName\"\n        , IIF(f.rdb$character_length = 0, 32765, f.rdb$character_length) as \"MaxLength\" --hot fix for CORE-2228\n        , IIF(f.rdb$field_precision = 0 AND f.rdb$field_scale &lt; 0, 18, f.rdb$field_precision) as \"Precision\"\n        , 4 as \"DateTimePrecision\"\n        , f.rdb$field_scale * (-1) as \"Scale\"\n        , NULL as \"CollationCatalog\"\n        , NULL as \"CollationSchema\"\n        , NULL as \"CollationName\"\n        , NULL as \"CharacterSetCatalog\"\n        , NULL as \"CharacterSetSchema\"\n        , NULL as \"CharacterSetName\"\n        , 0 as \"IsMultiSet\"\n        , IIF(POSITION('#PK_GEN#', UPPER(rf.rdb$description)) &gt; 0, 1, 0) as \"IsIdentity\"\n        , IIF(f.rdb$computed_blr IS NULL, 0, 1) as \"IsStoreGenerated\"\n        , COALESCE(rf.rdb$default_source, f.rdb$default_source) as \"Default\"\n        FROM\n        rdb$relation_fields rf\n        INNER JOIN rdb$fields f ON (rf.rdb$field_source = f.rdb$field_name)\n        INNER JOIN rdb$relations r ON (rf.rdb$relation_name = r.rdb$relation_name)\n        WHERE\n        rf.rdb$system_flag = 0 AND r.rdb$view_blr IS NOT NULL\n      </DefiningQuery>\n    </EntitySet>\n\n    <EntitySet Name=\"SFunctions\" EntityType=\"Self.Function\">\n      <DefiningQuery>\n        -- SFunctions\n        SELECT\n        TRIM(f.rdb$function_name) as \"Id\"\n        , 'Firebird' as \"CatalogName\"\n        , 'Firebird' as \"SchemaName\"\n        , TRIM(f.rdb$function_name) as \"Name\"\n        , TRIM(/*CASE \n        WHEN POSITION('#BOOL#', UPPER(fa.rdb$description)) &gt; 0 THEN 'smallint_bool'\n        WHEN POSITION('#GUID#', UPPER(fa.rdb$description)) &gt; 0 THEN 'guid'\n        ELSE*/ CASE fa.rdb$field_type\n          WHEN 7 THEN CASE\n            WHEN ((fa.rdb$field_sub_type = 2) OR (fa.rdb$field_sub_type = 0 AND fa.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN fa.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'smallint'\n            END\n          WHEN 8 THEN CASE\n            WHEN ((fa.rdb$field_sub_type = 2) OR (fa.rdb$field_sub_type = 0 AND fa.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN fa.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'int'\n            END\n          WHEN 16 THEN CASE\n            WHEN ((fa.rdb$field_sub_type = 2) OR (fa.rdb$field_sub_type = 0 AND fa.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN fa.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'bigint'\n            END\n          WHEN 10 THEN 'float'\n          WHEN 27 THEN 'double'\n          WHEN 12 THEN 'date'\n          WHEN 13 THEN 'time'\n          WHEN 35 THEN 'timestamp'\n          WHEN 261 THEN CASE fa.rdb$field_sub_type\n            WHEN 1 THEN 'clob'\n            ELSE 'blob'\n            END\n          WHEN 37 THEN 'varchar'\n          WHEN 14 THEN 'char'\n          WHEN 40 THEN 'cstring'\n          /*END*/\n        END) as \"ReturnTypeName\"\n        , fa.rdb$character_length as \"ReturnMaxLength\"\n\t\t\t\t, IIF(fa.rdb$field_precision = 0 AND fa.rdb$field_scale &lt; 0, 18, fa.rdb$field_precision) as \"ReturnPrecision\"\n\t\t\t\t, 4 as \"ReturnDateTimePrecision\"\n\t\t\t\t, fa.rdb$field_scale * (-1) as \"ReturnScale\"\n\t\t\t\t, NULL as \"ReturnCollationCatalog\"\n\t\t\t\t, NULL as \"ReturnCollationSchema\"\n\t\t\t\t, NULL as \"ReturnCollationName\"\n\t\t\t\t, NULL as \"ReturnCharacterSetCatalog\"\n\t\t\t\t, NULL as \"ReturnCharacterSetSchema\"\n\t\t\t\t, NULL as \"ReturnCharacterSetName\"\n\t\t\t\t, 0 as \"ReturnIsMultiSet\"\n\t\t\t\t, 0 as \"IsAggregate\"\n\t\t\t\t, 0 as \"IsBuiltIn\"\n\t\t\t\t, 0 as \"IsNiladic\" --CAST((select CASE COUNT(*) WHEN 1 THEN 1 ELSE 0 END FROM rdb$function_arguments fa WHERE fa.rdb$function_name = f.rdb$function_name) as smallint) as \"IsNiladic\"\n\t\t\t\tFROM\n\t\t\t\trdb$functions f INNER JOIN rdb$function_arguments fa ON (f.rdb$function_name = fa.rdb$function_name AND f.rdb$return_argument = fa.rdb$argument_position)\n\t\t\t\tWHERE f.rdb$system_flag = 0\n\t\t\t</DefiningQuery>\n    </EntitySet>\n    <EntitySet Name=\"SFunctionParameters\" EntityType=\"Self.Parameter\">\n      <DefiningQuery>\n        -- SFunctionParameters\n        SELECT\n        TRIM(fa.rdb$function_name) || 'x' || TRIM(fa.rdb$argument_position) as \"Id\"\n        , TRIM(fa.rdb$function_name) as \"ParentId\"\n        , 'param' || TRIM(fa.rdb$argument_position) as \"Name\"\n        , fa.rdb$argument_position as \"Ordinal\"\n        , TRIM(/*CASE \n        WHEN POSITION('#BOOL#', UPPER(fa.rdb$description)) &gt; 0 THEN 'smallint_bool'\n        WHEN POSITION('#GUID#', UPPER(fa.rdb$description)) &gt; 0 THEN 'guid'\n        ELSE*/ CASE fa.rdb$field_type\n          WHEN 7 THEN CASE\n            WHEN ((fa.rdb$field_sub_type = 2) OR (fa.rdb$field_sub_type = 0 AND fa.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN fa.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'smallint'\n            END\n          WHEN 8 THEN CASE\n            WHEN ((fa.rdb$field_sub_type = 2) OR (fa.rdb$field_sub_type = 0 AND fa.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN fa.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'int'\n            END\n          WHEN 16 THEN CASE\n            WHEN ((fa.rdb$field_sub_type = 2) OR (fa.rdb$field_sub_type = 0 AND fa.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN fa.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'bigint'\n            END\n          WHEN 10 THEN 'float'\n          WHEN 27 THEN 'double'\n          WHEN 12 THEN 'date'\n          WHEN 13 THEN 'time'\n          WHEN 35 THEN 'timestamp'\n          WHEN 261 THEN CASE fa.rdb$field_sub_type\n            WHEN 1 THEN 'clob'\n            ELSE 'blob'\n            END\n          WHEN 37 THEN 'varchar'\n          WHEN 14 THEN 'char'\n          WHEN 40 THEN 'cstring'\n          /*END*/\n        END) as \"TypeName\"\n        , fa.rdb$character_length as \"MaxLength\"\n        , IIF(fa.rdb$field_precision = 0 AND fa.rdb$field_scale &lt; 0, 18, fa.rdb$field_precision) as \"Precision\"\n        , 4 as \"DateTimePrecision\"\n        , fa.rdb$field_scale * (-1) as \"Scale\"\n        , NULL as \"CollationCatalog\"\n        , NULL as \"CollationSchema\"\n        , NULL as \"CollationName\"\n        , NULL as \"CharacterSetCatalog\"\n        , NULL as \"CharacterSetSchema\"\n        , NULL as \"CharacterSetName\"\n        , 0 as \"IsMultiSet\"\n        , 'IN' as \"Mode\"\n        , NULL as \"Default\"\n        FROM\n        rdb$functions f INNER JOIN rdb$function_arguments fa ON (f.rdb$function_name = fa.rdb$function_name AND f.rdb$return_argument &lt;&gt; fa.rdb$argument_position)\n        WHERE f.rdb$system_flag = 0\n      </DefiningQuery>\n    </EntitySet>\n\n    <EntitySet Name=\"SProcedures\" EntityType=\"Self.Procedure\">\n      <DefiningQuery>\n        -- SProcedures\n        SELECT\n        TRIM(rdb$procedure_name) as \"Id\"\n        , 'Firebird' as \"CatalogName\"\n        , 'Firebird' as \"SchemaName\"\n        , TRIM(rdb$procedure_name) as \"Name\"\n        FROM\n        rdb$procedures\n      </DefiningQuery>\n    </EntitySet>\n    <EntitySet Name=\"SProcedureParameters\" EntityType=\"Self.Parameter\">\n      <DefiningQuery>\n        -- SProcedureParameters\n        SELECT\n        TRIM(pp.rdb$procedure_name) || 'x' || TRIM(pp.rdb$parameter_name) as \"Id\"\n        , TRIM(pp.rdb$procedure_name) as \"ParentId\"\n        , TRIM(pp.rdb$parameter_name) as \"Name\"\n        , pp.rdb$parameter_number+1 as \"Ordinal\"\n        , TRIM(CASE\n        WHEN POSITION('#BOOL#', UPPER(pp.rdb$description)) &gt; 0 THEN 'smallint_bool'\n        WHEN POSITION('#GUID#', UPPER(pp.rdb$description)) &gt; 0 THEN 'guid'\n        ELSE CASE f.rdb$field_type\n          WHEN 7 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'smallint'\n            END\n          WHEN 8 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'int'\n            END\n          WHEN 16 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'bigint'\n            END\n          WHEN 10 THEN 'float'\n          WHEN 27 THEN 'double'\n          WHEN 12 THEN 'date'\n          WHEN 13 THEN 'time'\n          WHEN 35 THEN 'timestamp'\n          WHEN 261 THEN CASE f.rdb$field_sub_type\n            WHEN 1 THEN 'clob'\n            ELSE 'blob'\n            END\n          WHEN 37 THEN 'varchar'\n          WHEN 14 THEN 'char'\n          WHEN 40 THEN 'cstring'\n          END\n        END) as \"TypeName\"\n        , IIF(f.rdb$character_length = 0, 32765, f.rdb$character_length) as \"MaxLength\" --hot fix for CORE-2228\n        , IIF(f.rdb$field_precision = 0 AND f.rdb$field_scale &lt; 0, 18, f.rdb$field_precision) as \"Precision\"\n        , 4 as \"DateTimePrecision\"\n        , f.rdb$field_scale * (-1) as \"Scale\"\n        , NULL as \"CollationCatalog\"\n        , NULL as \"CollationSchema\"\n        , NULL \"CollationName\"\n        , NULL as \"CharacterSetCatalog\"\n        , NULL as \"CharacterSetSchema\"\n        , NULL as \"CharacterSetName\"\n        , 0 as \"IsMultiSet\"\n        , TRIM(IIF(pp.rdb$parameter_type = 1, 'OUT', 'IN')) as \"Mode\"\n        , NULL as \"Default\"\n        FROM\n        rdb$procedure_parameters pp INNER JOIN rdb$fields f ON (pp.rdb$field_source = f.rdb$field_name)\n        WHERE pp.rdb$parameter_type = 0 --Out params in EF are not results\n      </DefiningQuery>\n    </EntitySet>\n\n    <EntitySet Name=\"SConstraints\" EntityType=\"Self.Constraint\">\n      <DefiningQuery>\n        -- SConstraints\n        SELECT\n        TRIM(rc.rdb$constraint_name) as \"Id\"\n        , TRIM(rc.rdb$relation_name) as \"ParentId\"\n        , TRIM(rc.rdb$constraint_name) as \"Name\"\n        , TRIM(rc.rdb$constraint_type) as \"ConstraintType\"\n        , 0 as \"IsDeferrable\"\n        , 0 \"IsInitiallyDeferred\"\n        FROM\n        rdb$relation_constraints rc\n        WHERE\n        rc.rdb$constraint_type IN ('PRIMARY KEY', 'FOREIGN KEY', 'UNIQUE')\n      </DefiningQuery>\n    </EntitySet>\n    <EntitySet Name=\"SCheckConstraints\" EntityType=\"Self.CheckConstraint\">\n      <DefiningQuery>\n        -- SCheckConstraints\n        SELECT\n        TRIM(rc.rdb$constraint_name) as \"Id\"\n        , TRIM(SUBSTRING(trg.rdb$trigger_source from 6)) as \"Expression\"\n        FROM\n        rdb$relation_constraints rc\n        INNER JOIN rdb$check_constraints cc on (rc.rdb$constraint_name = cc.rdb$constraint_name)\n        LEFT JOIN rdb$triggers trg on (cc.rdb$trigger_name = trg.rdb$trigger_name)\n        WHERE\n        rc.rdb$constraint_type IN ('CHECK')\n      </DefiningQuery>\n    </EntitySet>\n    <EntitySet Name=\"SConstraintColumns\" EntityType=\"Self.ConstraintColumn\">\n      <DefiningQuery>\n        -- SConstraintColumns\n        SELECT\n        TRIM(rc.rdb$constraint_name) as \"ConstraintId\"\n        , TRIM(rc.rdb$relation_name) || 'x' || TRIM(ise.rdb$field_name) as \"ColumnId\"\n        FROM\n        rdb$relation_constraints rc INNER JOIN rdb$index_segments ise ON (rc.rdb$index_name = ise.rdb$index_name)\n        WHERE\n        rc.rdb$constraint_type IN ('PRIMARY KEY', 'FOREIGN KEY', 'UNIQUE')\n      </DefiningQuery>\n    </EntitySet>\n    \n    <EntitySet Name=\"SForeignKeyConstraints\" EntityType=\"Self.ForeignKeyConstraint\">\n      <DefiningQuery>\n        -- SForeignKeyConstraints\n        SELECT\n        TRIM(rc.rdb$constraint_name) as \"Id\"\n        , rc.rdb$update_rule \"UpdateRule\"\n        , rc.rdb$delete_rule \"DeleteRule\"\n        FROM\n        rdb$ref_constraints rc\n      </DefiningQuery>\n    </EntitySet>\n    <EntitySet Name=\"SForeignKeys\" EntityType=\"Self.ForeignKey\">\n      <DefiningQuery>\n        -- SForeignKeys\n        SELECT\n        TRIM(refc.rdb$constraint_name) || 'x' || TRIM(is2.rdb$field_position+1) as \"Id\"\n        , TRIM(relc1.rdb$relation_name) || 'x' || TRIM(is1.rdb$field_name) as \"FromColumnId\"\n        , TRIM(relc2.rdb$relation_name) || 'x' || TRIM(is2.rdb$field_name) as \"ToColumnId\"\n        , TRIM(refc.rdb$constraint_name) as \"ConstraintId\"\n        , is2.rdb$field_position+1 as \"Ordinal\"\n        FROM rdb$ref_constraints refc\n        LEFT JOIN rdb$relation_constraints relc1 ON (refc.rdb$constraint_name = relc1.rdb$constraint_name)\n        INNER JOIN rdb$index_segments is1 ON (relc1.rdb$index_name = is1.rdb$index_name)\n        LEFT JOIN rdb$relation_constraints relc2 ON (refc.rdb$const_name_uq = relc2.rdb$constraint_name)\n        INNER JOIN rdb$index_segments is2 ON (relc2.rdb$index_name = is2.rdb$index_name)\n        WHERE is1.rdb$field_position = is2.rdb$field_position\n      </DefiningQuery>\n    </EntitySet>\n\n    <EntitySet Name=\"SViewConstraints\" EntityType=\"Self.ViewConstraint\">\n      <DefiningQuery>\n        -- SViewConstraints\n        SELECT\n        CAST(NULL as varchar(1)) as \"Id\"\n        , CAST(NULL as varchar(1)) as \"ParentId\"\n        , CAST(NULL as varchar(1)) as \"Name\"\n        , CAST(NULL as varchar(1)) as \"ConstraintType\"\n        , CAST(0 as smallint) as \"IsDeferrable\"\n        , CAST(0 as smallint) as \"IsInitiallyDeferred\"\n        , CAST(NULL as varchar(1)) as \"Expression\"\n        , CAST(NULL as varchar(1)) as \"UpdateRule\"\n        , CAST(NULL as varchar(1)) as \"DeleteRule\"\n        FROM rdb$database\n        WHERE 0=1\n      </DefiningQuery>\n    </EntitySet>\n    <EntitySet Name=\"SViewConstraintColumns\" EntityType=\"Self.ConstraintColumn\">\n      <DefiningQuery>\n        -- SViewConstraintColumns\n        SELECT\n        CAST(NULL as varchar(1)) as \"ConstraintId\"\n        , CAST(NULL as varchar(1)) as \"ColumnId\"\n        FROM rdb$database\n        WHERE 0=1\n      </DefiningQuery>\n    </EntitySet>\n    <EntitySet Name=\"SViewForeignKeys\" EntityType=\"Self.ForeignKey\">\n      <DefiningQuery>\n        -- SViewForeignKeys\n        SELECT\n        CAST(NULL as varchar(1)) as \"Id\"\n        , CAST(NULL as varchar(1)) as \"ToColumnId\"\n        , CAST(NULL as varchar(1)) as \"FromColumnId\"\n        , CAST(NULL as varchar(1)) as \"ConstraintId\"\n        , 0 as \"Ordinal\"\n        FROM rdb$database\n        WHERE 0=1\n      </DefiningQuery>\n    </EntitySet>\n\n    <AssociationSet Name=\"STableTableColumns\" Association=\"Self.TableTableColumn\">\n      <End Role=\"Parent\" EntitySet=\"STables\" />\n      <End Role=\"Column\" EntitySet=\"STableColumns\" />\n    </AssociationSet>\n    <AssociationSet Name=\"STableConstraints\" Association=\"Self.TableTableConstraint\">\n      <End Role=\"Parent\" EntitySet=\"STables\" />\n      <End Role=\"Constraint\" EntitySet=\"SConstraints\" />\n    </AssociationSet>\n    <AssociationSet Name=\"SConstraintConstraintColumns\" Association=\"Self.ConstraintConstraintColumn\">\n      <End Role=\"ConstraintColumn\" EntitySet=\"SConstraintColumns\" />\n      <End Role=\"Constraint\" EntitySet=\"SConstraints\" />\n    </AssociationSet>\n    <AssociationSet Name=\"SConstraintForeignKeys\" Association=\"Self.ConstraintForeignKey\">\n      <End Role=\"ForeignKey\" EntitySet=\"SForeignKeys\" />\n      <End Role=\"Constraint\" EntitySet=\"SForeignKeyConstraints\" />\n    </AssociationSet>\n    <AssociationSet Name=\"SFromForeignKeyColumns\" Association=\"Self.FromForeignKeyColumn\">\n      <End Role=\"ForeignKey\" EntitySet=\"SForeignKeys\" />\n      <End Role=\"Column\" EntitySet=\"STableColumns\" />\n    </AssociationSet>\n    <AssociationSet Name=\"SToForeignKeyColumns\" Association=\"Self.ToForeignKeyColumn\">\n      <End Role=\"ForeignKey\" EntitySet=\"SForeignKeys\" />\n      <End Role=\"Column\" EntitySet=\"STableColumns\" />\n    </AssociationSet>\n\n    <AssociationSet Name=\"SViewViewColumns\" Association=\"Self.ViewViewColumn\">\n      <End Role=\"Parent\" EntitySet=\"SViews\" />\n      <End Role=\"Column\" EntitySet=\"SViewColumns\" />\n    </AssociationSet>\n    <AssociationSet Name=\"SViewViewConstraints\" Association=\"Self.ViewViewConstraint\">\n      <End Role=\"Parent\" EntitySet=\"SViews\" />\n      <End Role=\"Constraint\" EntitySet=\"SViewConstraints\" />\n    </AssociationSet>\n    <AssociationSet Name=\"SViewConstraintConstraintColumns\" Association=\"Self.ViewConstraintConstraintColumn\">\n      <End Role=\"ConstraintColumn\" EntitySet=\"SViewConstraintColumns\" />\n      <End Role=\"Constraint\" EntitySet=\"SViewConstraints\" />\n    </AssociationSet>\n    <AssociationSet Name=\"SViewConstraintForeignKeys\" Association=\"Self.ViewConstraintForeignKey\">\n      <End Role=\"ForeignKey\" EntitySet=\"SViewForeignKeys\" />\n      <End Role=\"Constraint\" EntitySet=\"SViewConstraints\" />\n    </AssociationSet>\n    <AssociationSet Name=\"SFromForeignKeyViewColumns\" Association=\"Self.FromForeignKeyViewColumn\">\n      <End Role=\"ForeignKey\" EntitySet=\"SViewForeignKeys\" />\n      <End Role=\"Column\" EntitySet=\"SViewColumns\" />\n    </AssociationSet>\n    <AssociationSet Name=\"SToForeignKeyViewColumns\" Association=\"Self.ToForeignKeyViewColumn\">\n      <End Role=\"ForeignKey\" EntitySet=\"SViewForeignKeys\" />\n      <End Role=\"Column\" EntitySet=\"SViewColumns\" />\n    </AssociationSet>\n\n    <AssociationSet Name=\"FunctionFunctionParameters\" Association=\"Self.FunctionFunctionParameter\">\n      <End Role=\"Function\" EntitySet=\"SFunctions\" />\n      <End Role=\"Parameter\" EntitySet=\"SFunctionParameters\" />\n    </AssociationSet>\n    <AssociationSet Name=\"ProcedureProcedureParameters\" Association=\"Self.ProcedureProcedureParameter\">\n      <End Role=\"Procedure\" EntitySet=\"SProcedures\" />\n      <End Role=\"Parameter\" EntitySet=\"SProcedureParameters\" />\n    </AssociationSet>\n    \n  </EntityContainer>\n\n  <EntityType Name=\"Table\">\n    <Key>\n      <PropertyRef Name=\"Id\" />\n    </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"CatalogName\" Type=\"varchar\" MaxLength=\"8\" />\n    <Property Name=\"SchemaName\" Type=\"varchar\" MaxLength=\"8\" />\n    <Property Name=\"Name\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n  </EntityType>\n\n  <EntityType Name=\"TableColumn\">\n    <Key>\n      <PropertyRef Name=\"Id\" />\n    </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"63\" />\n    <Property Name=\"ParentId\" Nullable=\"false\" MaxLength=\"31\" Type=\"varchar\" />\n    <Property Name=\"Name\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"Ordinal\" Nullable=\"false\" Type=\"int\" />\n    <Property Name=\"IsNullable\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"TypeName\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"256\" />\n    <Property Name=\"MaxLength\" Type=\"int\" />\n    <Property Name=\"Precision\" Type=\"int\" />\n    <Property Name=\"DateTimePrecision\" Type=\"int\" />\n    <Property Name=\"Scale\" Type=\"int\" />\n    <Property Name=\"CollationCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CollationSchema\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CollationName\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetSchema\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetName\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"IsMultiSet\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"IsIdentity\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"IsStoreGenerated\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"Default\" Nullable=\"true\" Type=\"varchar\" />\n  </EntityType>\n\n  <EntityType Name=\"View\">\n    <Key>\n      <PropertyRef Name=\"Id\" />\n    </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"CatalogName\" Type=\"varchar\" MaxLength=\"8\" />\n    <Property Name=\"SchemaName\" Type=\"varchar\" MaxLength=\"8\" />\n    <Property Name=\"Name\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"ViewDefinition\" Nullable=\"true\" Type=\"varchar\" />\n    <Property Name=\"IsUpdatable\" Nullable=\"false\" Type=\"smallint_bool\" />\n  </EntityType>\n\n  <EntityType Name=\"ViewColumn\">\n    <Key>\n      <PropertyRef Name=\"Id\" />\n    </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"63\" />\n    <Property Name=\"ParentId\" Nullable=\"false\" MaxLength=\"31\" Type=\"varchar\" />\n    <Property Name=\"Name\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"Ordinal\" Nullable=\"false\" Type=\"int\" />\n    <Property Name=\"IsNullable\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"TypeName\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"256\" />\n    <Property Name=\"MaxLength\" Type=\"int\" />\n    <Property Name=\"Precision\" Type=\"int\" />\n    <Property Name=\"DateTimePrecision\" Type=\"int\" />\n    <Property Name=\"Scale\" Type=\"int\" />\n    <Property Name=\"CollationCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CollationSchema\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CollationName\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetSchema\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetName\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"IsMultiSet\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"IsIdentity\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"IsStoreGenerated\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"Default\" Nullable=\"true\" Type=\"varchar\" />\n  </EntityType>\n\n  <EntityType Name=\"Function\">\n    <Key>\n      <PropertyRef Name=\"Id\" />\n    </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"CatalogName\" Type=\"varchar\" MaxLength=\"8\" />\n    <Property Name=\"SchemaName\" Type=\"varchar\" MaxLength=\"8\" />\n    <Property Name=\"Name\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"ReturnTypeName\" Type=\"varchar\" MaxLength=\"256\" />\n    <Property Name=\"ReturnMaxLength\" Type=\"int\" />\n    <Property Name=\"ReturnPrecision\" Type=\"int\" />\n    <Property Name=\"ReturnDateTimePrecision\" Type=\"int\" />\n    <Property Name=\"ReturnScale\" Type=\"int\" />\n    <Property Name=\"ReturnCollationCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"ReturnCollationSchema\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"ReturnCollationName\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"ReturnCharacterSetCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"ReturnCharacterSetSchema\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"ReturnCharacterSetName\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"ReturnIsMultiSet\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"IsAggregate\" Type=\"smallint_bool\" />\n    <Property Name=\"IsBuiltIn\" Type=\"smallint_bool\" />\n    <Property Name=\"IsNiladic\" Type=\"smallint_bool\" />\n  </EntityType>\n\n  <EntityType Name=\"Procedure\">\n    <Key>\n      <PropertyRef Name=\"Id\" />\n    </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"CatalogName\" Type=\"varchar\" MaxLength=\"8\" />\n    <Property Name=\"SchemaName\" Type=\"varchar\" MaxLength=\"8\" />\n    <Property Name=\"Name\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n  </EntityType>\n\n  <EntityType Name=\"Parameter\">\n    <Key>\n      <PropertyRef Name=\"Id\" />\n    </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"63\" />\n    <Property Name=\"ParentId\" Nullable=\"false\" MaxLength=\"31\" Type=\"varchar\" />\n    <Property Name=\"Name\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"Ordinal\" Nullable=\"false\" Type=\"int\" />\n    <Property Name=\"TypeName\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"256\" />\n    <Property Name=\"MaxLength\" Nullable=\"true\" Type=\"int\" />\n    <Property Name=\"Precision\" Nullable=\"true\" Type=\"int\" />\n    <Property Name=\"DateTimePrecision\" Type=\"int\" />\n    <Property Name=\"Scale\" Nullable=\"true\" Type=\"int\" />\n    <Property Name=\"CollationCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CollationSchema\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CollationName\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetSchema\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetName\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"IsMultiSet\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"Mode\" Type=\"varchar\" MaxLength=\"16\" />\n    <Property Name=\"Default\" Type=\"varchar\" />\n  </EntityType>\n\n  <EntityType Name=\"Constraint\">\n    <Key>\n      <PropertyRef Name=\"Id\" />\n    </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"ParentId\" Nullable=\"false\" MaxLength=\"31\" Type=\"varchar\" />\n    <Property Name=\"Name\" Nullable=\"false\" MaxLength=\"31\" Type=\"varchar\" />\n    <Property Name=\"IsDeferrable\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"IsInitiallyDeferred\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"ConstraintType\" Nullable=\"false\" MaxLength=\"11\" Type=\"varchar\" />\n  </EntityType>\n\n  <EntityType Name=\"CheckConstraint\">\n    <Key>\n      <PropertyRef Name=\"Id\" />\n    </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"Expression\" Nullable=\"true\" MaxLength=\"1000\" Type=\"varchar\" />\n  </EntityType>\n\n  <EntityType Name=\"ConstraintColumn\">\n    <Key>\n      <PropertyRef Name=\"ConstraintId\" />\n      <PropertyRef Name=\"ColumnId\" />\n    </Key>\n    <Property Name=\"ConstraintId\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"ColumnId\" Nullable=\"false\" MaxLength=\"63\" Type=\"varchar\" />\n  </EntityType>\n\n  <EntityType Name=\"ForeignKeyConstraint\">\n    <Key>\n      <PropertyRef Name=\"Id\" />\n    </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"UpdateRule\" Nullable=\"false\" MaxLength=\"11\" Type=\"varchar\" />\n    <Property Name=\"DeleteRule\" Nullable=\"false\" MaxLength=\"11\" Type=\"varchar\" />\n  </EntityType>\n\n  <EntityType Name=\"ForeignKey\">\n    <Key>\n      <PropertyRef Name=\"Id\" />\n    </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"Ordinal\" Nullable=\"false\" Type=\"int\" />\n    <Property Name=\"ConstraintId\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"FromColumnId\" Nullable=\"false\" MaxLength=\"63\" Type=\"varchar\" />\n    <Property Name=\"ToColumnId\" Nullable=\"false\" MaxLength=\"63\" Type=\"varchar\" />\n  </EntityType>\n\n  <EntityType Name=\"ViewConstraint\">\n    <Key>\n      <PropertyRef Name=\"Id\" />\n    </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"ParentId\" Nullable=\"false\" MaxLength=\"31\" Type=\"varchar\" />\n    <Property Name=\"Name\" Nullable=\"false\" MaxLength=\"31\" Type=\"varchar\" />\n    <Property Name=\"IsDeferrable\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"IsInitiallyDeferred\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"ConstraintType\" Nullable=\"false\" MaxLength=\"11\" Type=\"varchar\" />\n    <Property Name=\"Expression\" Nullable=\"true\" MaxLength=\"1000\" Type=\"varchar\" />\n    <Property Name=\"UpdateRule\" Nullable=\"true\" MaxLength=\"11\" Type=\"varchar\" />\n    <Property Name=\"DeleteRule\" Nullable=\"true\" MaxLength=\"11\" Type=\"varchar\" />\n  </EntityType>\n\n  <Association Name=\"TableTableConstraint\">\n    <End Type=\"Self.Table\" Role=\"Parent\" Multiplicity=\"1\" />\n    <End Type=\"Self.Constraint\" Role=\"Constraint\" Multiplicity=\"*\" />\n    <ReferentialConstraint>\n      <Principal Role=\"Parent\">\n        <PropertyRef Name=\"Id\" />\n      </Principal>\n      <Dependent Role=\"Constraint\">\n        <PropertyRef Name=\"ParentId\" />\n      </Dependent>\n    </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ConstraintConstraintColumn\">\n    <End Type=\"Self.Constraint\" Role=\"Constraint\" Multiplicity=\"1\" />\n    <End Type=\"Self.ConstraintColumn\" Role=\"ConstraintColumn\" Multiplicity=\"*\" />\n    <ReferentialConstraint>\n      <Principal Role=\"Constraint\">\n        <PropertyRef Name=\"Id\" />\n      </Principal>\n      <Dependent Role=\"ConstraintColumn\">\n        <PropertyRef Name=\"ConstraintId\" />\n      </Dependent>\n    </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ConstraintForeignKey\">\n    <End Type=\"Self.ForeignKeyConstraint\" Role=\"Constraint\" Multiplicity=\"1\" />\n    <End Type=\"Self.ForeignKey\" Role=\"ForeignKey\" Multiplicity=\"*\" />\n    <ReferentialConstraint>\n      <Principal Role=\"Constraint\">\n        <PropertyRef Name=\"Id\" />\n      </Principal>\n      <Dependent Role=\"ForeignKey\">\n        <PropertyRef Name=\"ConstraintId\" />\n      </Dependent>\n    </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"FromForeignKeyColumn\">\n    <End Type=\"Self.TableColumn\" Role=\"Column\" Multiplicity=\"1\" />\n    <End Type=\"Self.ForeignKey\" Role=\"ForeignKey\" Multiplicity=\"*\" />\n    <ReferentialConstraint>\n      <Principal Role=\"Column\">\n        <PropertyRef Name=\"Id\" />\n      </Principal>\n      <Dependent Role=\"ForeignKey\">\n        <PropertyRef Name=\"FromColumnId\" />\n      </Dependent>\n    </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ToForeignKeyColumn\">\n    <End Type=\"Self.TableColumn\" Role=\"Column\" Multiplicity=\"1\" />\n    <End Type=\"Self.ForeignKey\" Role=\"ForeignKey\" Multiplicity=\"*\" />\n    <ReferentialConstraint>\n      <Principal Role=\"Column\">\n        <PropertyRef Name=\"Id\" />\n      </Principal>\n      <Dependent Role=\"ForeignKey\">\n        <PropertyRef Name=\"ToColumnId\" />\n      </Dependent>\n    </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"TableTableColumn\">\n    <End Type=\"Self.Table\" Role=\"Parent\" Multiplicity=\"1\" />\n    <End Type=\"Self.TableColumn\" Role=\"Column\" Multiplicity=\"*\" />\n    <ReferentialConstraint>\n      <Principal Role=\"Parent\">\n        <PropertyRef Name=\"Id\" />\n      </Principal>\n      <Dependent Role=\"Column\">\n        <PropertyRef Name=\"ParentId\" />\n      </Dependent>\n    </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ViewViewColumn\">\n    <End Type=\"Self.View\" Role=\"Parent\" Multiplicity=\"1\" />\n    <End Type=\"Self.ViewColumn\" Role=\"Column\" Multiplicity=\"*\" />\n    <ReferentialConstraint>\n      <Principal Role=\"Parent\">\n        <PropertyRef Name=\"Id\" />\n      </Principal>\n      <Dependent Role=\"Column\">\n        <PropertyRef Name=\"ParentId\" />\n      </Dependent>\n    </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"FunctionFunctionParameter\">\n    <End Type=\"Self.Function\" Role=\"Function\" Multiplicity=\"1\" />\n    <End Type=\"Self.Parameter\" Role=\"Parameter\" Multiplicity=\"*\" />\n    <ReferentialConstraint>\n      <Principal Role=\"Function\">\n        <PropertyRef Name=\"Id\" />\n      </Principal>\n      <Dependent Role=\"Parameter\">\n        <PropertyRef Name=\"ParentId\" />\n      </Dependent>\n    </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ProcedureProcedureParameter\">\n    <End Type=\"Self.Procedure\" Role=\"Procedure\" Multiplicity=\"1\" />\n    <End Type=\"Self.Parameter\" Role=\"Parameter\" Multiplicity=\"*\" />\n    <ReferentialConstraint>\n      <Principal Role=\"Procedure\">\n        <PropertyRef Name=\"Id\" />\n      </Principal>\n      <Dependent Role=\"Parameter\">\n        <PropertyRef Name=\"ParentId\" />\n      </Dependent>\n    </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ViewViewConstraint\">\n    <End Type=\"Self.View\" Role=\"Parent\" Multiplicity=\"1\" />\n    <End Type=\"Self.ViewConstraint\" Role=\"Constraint\" Multiplicity=\"*\" />\n    <ReferentialConstraint>\n      <Principal Role=\"Parent\">\n        <PropertyRef Name=\"Id\" />\n      </Principal>\n      <Dependent Role=\"Constraint\">\n        <PropertyRef Name=\"ParentId\" />\n      </Dependent>\n    </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ViewConstraintConstraintColumn\">\n    <End Type=\"Self.ViewConstraint\" Role=\"Constraint\" Multiplicity=\"1\" />\n    <End Type=\"Self.ConstraintColumn\" Role=\"ConstraintColumn\" Multiplicity=\"*\" />\n    <ReferentialConstraint>\n      <Principal Role=\"Constraint\">\n        <PropertyRef Name=\"Id\" />\n      </Principal>\n      <Dependent Role=\"ConstraintColumn\">\n        <PropertyRef Name=\"ConstraintId\" />\n      </Dependent>\n    </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ViewConstraintForeignKey\">\n    <End Type=\"Self.ViewConstraint\" Role=\"Constraint\" Multiplicity=\"1\" />\n    <End Type=\"Self.ForeignKey\" Role=\"ForeignKey\" Multiplicity=\"*\" />\n    <ReferentialConstraint>\n      <Principal Role=\"Constraint\">\n        <PropertyRef Name=\"Id\" />\n      </Principal>\n      <Dependent Role=\"ForeignKey\">\n        <PropertyRef Name=\"ConstraintId\" />\n      </Dependent>\n    </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"FromForeignKeyViewColumn\">\n    <End Type=\"Self.ViewColumn\" Role=\"Column\" Multiplicity=\"1\" />\n    <End Type=\"Self.ForeignKey\" Role=\"ForeignKey\" Multiplicity=\"*\" />\n    <ReferentialConstraint>\n      <Principal Role=\"Column\">\n        <PropertyRef Name=\"Id\" />\n      </Principal>\n      <Dependent Role=\"ForeignKey\">\n        <PropertyRef Name=\"FromColumnId\" />\n      </Dependent>\n    </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ToForeignKeyViewColumn\">\n    <End Type=\"Self.ViewColumn\" Role=\"Column\" Multiplicity=\"1\" />\n    <End Type=\"Self.ForeignKey\" Role=\"ForeignKey\" Multiplicity=\"*\" />\n    <ReferentialConstraint>\n      <Principal Role=\"Column\">\n        <PropertyRef Name=\"Id\" />\n      </Principal>\n      <Dependent Role=\"ForeignKey\">\n        <PropertyRef Name=\"ToColumnId\" />\n      </Dependent>\n    </ReferentialConstraint>\n  </Association>\n\n</Schema>"
  },
  {
    "path": "src/EntityFramework.Firebird/Resources/StoreSchemaDefinitionVersion3.ssdl",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Schema Namespace=\"FirebirdClient_EF\" Provider=\"FirebirdSql.Data.FirebirdClient\" ProviderManifestToken=\"Firebird\" Alias=\"Self\" xmlns=\"http://schemas.microsoft.com/ado/2006/04/edm/ssdl\">\n  <EntityContainer Name=\"Schema\">\n    <EntitySet Name=\"STables\" EntityType=\"Self.Table\">\n      <DefiningQuery>\n        -- STables3\n        SELECT\n        TRIM(rdb$relation_name) as \"Id\"\n        , 'Firebird' as \"CatalogName\"\n        , 'Firebird' as \"SchemaName\" \n        , TRIM(rdb$relation_name) as \"Name\"\n        FROM\n        rdb$relations\n        WHERE\n        rdb$view_source IS NULL AND rdb$system_flag = 0\n      </DefiningQuery>\n    </EntitySet>    \n    <EntitySet Name=\"STableColumns\" EntityType=\"Self.TableColumn\">\n      <DefiningQuery>\n        -- STableColumns3\n        SELECT TRIM(rf.rdb$relation_name) || 'x' || TRIM(rf.rdb$field_name) as \"Id\"\n        , TRIM(rf.rdb$relation_name) as \"ParentId\"\n        , TRIM(rf.rdb$field_name) as \"Name\"\n        , rf.rdb$field_position+1 as \"Ordinal\"\n        , IIF(COALESCE(rf.rdb$null_flag, f.rdb$null_flag) IS NULL, 1, 0) as \"IsNullable\"\n        , TRIM(CASE\n        WHEN POSITION('#BOOL#', UPPER(rf.rdb$description)) &gt; 0 THEN 'smallint_bool'\n        WHEN POSITION('#GUID#', UPPER(rf.rdb$description)) &gt; 0 THEN 'guid'\n        ELSE CASE f.rdb$field_type\n          WHEN 7 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'smallint'\n            END\n          WHEN 8 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'int'\n            END\n          WHEN 16 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'bigint'\n            END\n          WHEN 10 THEN 'float'\n          WHEN 27 THEN 'double'\n          WHEN 12 THEN 'date'\n          WHEN 13 THEN 'time'\n          WHEN 35 THEN 'timestamp'\n          WHEN 261 THEN CASE f.rdb$field_sub_type\n            WHEN 1 THEN 'clob'\n            ELSE 'blob'\n            END\n          WHEN 37 THEN 'varchar'\n          WHEN 14 THEN 'char'\n          WHEN 40 THEN 'cstring'\n          END\n        END) as \"TypeName\"\n        , IIF(f.rdb$character_length = 0, 32765, f.rdb$character_length) as \"MaxLength\" --hot fix for CORE-2228\n        , IIF(f.rdb$field_precision = 0 AND f.rdb$field_scale &lt; 0, 18, f.rdb$field_precision) as \"Precision\"\n\t\t\t\t, 4 as \"DateTimePrecision\"\n\t\t\t\t, f.rdb$field_scale * (-1) as \"Scale\"\n\t\t\t\t, NULL as \"CollationCatalog\"\n\t\t\t\t, NULL as \"CollationSchema\"\n\t\t\t\t, NULL as \"CollationName\"\n\t\t\t\t, NULL as \"CharacterSetCatalog\"\n\t\t\t\t, NULL as \"CharacterSetSchema\"\n\t\t\t\t, NULL as \"CharacterSetName\"\n\t\t\t\t, 0 as \"IsMultiSet\"\n\t\t\t\t, IIF(POSITION('#PK_GEN#', UPPER(rf.rdb$description)) &gt; 0, 1, 0) as \"IsIdentity\"\n        , IIF(f.rdb$computed_blr IS NULL, 0, 1) as \"IsStoreGenerated\"\n        , COALESCE(rf.rdb$default_source, f.rdb$default_source) as \"Default\"\n        FROM\n        rdb$relation_fields rf\n        INNER JOIN rdb$fields f ON (rf.rdb$field_source = f.rdb$field_name)\n        INNER JOIN rdb$relations r ON (rf.rdb$relation_name = r.rdb$relation_name)\n        WHERE\n        rf.rdb$system_flag = 0 AND r.rdb$view_blr IS NULL\n      </DefiningQuery>\n    </EntitySet>\n\n    <EntitySet Name=\"SViews\" EntityType=\"Self.View\">\n      <DefiningQuery>\n        -- SViews3\n        SELECT\n        TRIM(rdb$relation_name) as \"Id\"\n        , 'Firebird' as \"CatalogName\"\n        , 'Firebird' as \"SchemaName\"\n        , TRIM(rdb$relation_name) as \"Name\"\n        , rdb$view_source as \"ViewDefinition\"\n        , 1 as \"IsUpdatable\"\n        FROM\n        rdb$relations\n        WHERE\n        rdb$view_blr IS NOT NULL AND rdb$system_flag = 0\n      </DefiningQuery>\n    </EntitySet>   \n    <EntitySet Name=\"SViewColumns\" EntityType=\"Self.ViewColumn\">\n      <DefiningQuery>\n        -- SViewColumns3\n        SELECT TRIM(rf.rdb$relation_name) || 'x' || TRIM(rf.rdb$field_name) as \"Id\"\n        , TRIM(rf.rdb$relation_name) as \"ParentId\"\n        , TRIM(rf.rdb$field_name) as \"Name\"\n        , rf.rdb$field_position+1 as \"Ordinal\"\n        , IIF(COALESCE(rf.rdb$null_flag, f.rdb$null_flag) IS NULL, 1, 0) as \"IsNullable\"\n        , TRIM(CASE\n        WHEN POSITION('#BOOL#', UPPER(rf.rdb$description)) &gt; 0 THEN 'smallint_bool'\n        WHEN POSITION('#GUID#', UPPER(rf.rdb$description)) &gt; 0 THEN 'guid'\n        ELSE CASE f.rdb$field_type\n          WHEN 7 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'smallint'\n            END\n          WHEN 8 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'int'\n            END\n          WHEN 16 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'bigint'\n            END\n          WHEN 10 THEN 'float'\n          WHEN 27 THEN 'double'\n          WHEN 12 THEN 'date'\n          WHEN 13 THEN 'time'\n          WHEN 35 THEN 'timestamp'\n          WHEN 261 THEN CASE f.rdb$field_sub_type\n            WHEN 1 THEN 'clob'\n            ELSE 'blob'\n            END\n          WHEN 37 THEN 'varchar'\n          WHEN 14 THEN 'char'\n          WHEN 40 THEN 'cstring'\n          END\n        END) as \"TypeName\"\n        , IIF(f.rdb$character_length = 0, 32765, f.rdb$character_length) as \"MaxLength\" --hot fix for CORE-2228\n        , IIF(f.rdb$field_precision = 0 AND f.rdb$field_scale &lt; 0, 18, f.rdb$field_precision) as \"Precision\"\n        , 4 as \"DateTimePrecision\"\n        , f.rdb$field_scale * (-1) as \"Scale\"\n        , NULL as \"CollationCatalog\"\n        , NULL as \"CollationSchema\"\n        , NULL as \"CollationName\"\n        , NULL as \"CharacterSetCatalog\"\n        , NULL as \"CharacterSetSchema\"\n        , NULL as \"CharacterSetName\"\n        , 0 as \"IsMultiSet\"\n        , IIF(POSITION('#PK_GEN#', UPPER(rf.rdb$description)) &gt; 0, 1, 0) as \"IsIdentity\"\n        , IIF(f.rdb$computed_blr IS NULL, 0, 1) as \"IsStoreGenerated\"\n        , COALESCE(rf.rdb$default_source, f.rdb$default_source) as \"Default\"\n        FROM\n        rdb$relation_fields rf\n        INNER JOIN rdb$fields f ON (rf.rdb$field_source = f.rdb$field_name)\n        INNER JOIN rdb$relations r ON (rf.rdb$relation_name = r.rdb$relation_name)\n        WHERE\n        rf.rdb$system_flag = 0 AND r.rdb$view_blr IS NOT NULL\n      </DefiningQuery>\n    </EntitySet>\n\n    <EntitySet Name=\"SFunctions\" EntityType=\"Self.Function\">\n      <DefiningQuery>\n\t\t  -- SFunctions3\n\t\t  SELECT\n\t\t  TRIM(rdb$procedure_name) as \"Id\"\n\t\t  , 'Firebird' as \"CatalogName\"\n\t\t  , 'Firebird' as \"SchemaName\"\n\t\t  , TRIM(rdb$procedure_name) as \"Name\"\n\t\t  , NULL as \"ReturnTypeName\"\n\t\t  , NULL as \"ReturnMaxLength\"\n\t\t  , NULL as \"ReturnPrecision\"\n\t\t  , NULL as \"ReturnDateTimePrecision\"\n\t\t  , NULL as \"ReturnScale\"\n\t\t  , NULL as \"ReturnCollationCatalog\"\n\t\t  , NULL as \"ReturnCollationSchema\"\n\t\t  , NULL as \"ReturnCollationName\"\n\t\t  , NULL as \"ReturnCharacterSetCatalog\"\n\t\t  , NULL as \"ReturnCharacterSetSchema\"\n\t\t  , NULL as \"ReturnCharacterSetName\"\n\t\t  , 0 as \"ReturnIsMultiSet\"\n\t\t  , 0 as \"IsAggregate\"\n\t\t  , 0 as \"IsBuiltIn\"\n\t\t  , IIF(COALESCE(rdb$procedure_inputs, 0) = 0, 1, 0) as \"IsNiladic\"\n\t\t  , 1 as \"IsTvf\"\n\t\t  FROM\n\t\t  rdb$procedures\n\t\t  WHERE\n\t\t  rdb$procedure_type = 1\n\t  </DefiningQuery>\n    </EntitySet>\n    <EntitySet Name=\"SFunctionParameters\" EntityType=\"Self.Parameter\">\n      <DefiningQuery>\n        -- SFunctionParameters3\n        SELECT\n        TRIM(pp.rdb$procedure_name) || 'x' || TRIM(pp.rdb$parameter_name) as \"Id\"\n        , TRIM(pp.rdb$procedure_name) as \"ParentId\"\n        , TRIM(pp.rdb$parameter_name) as \"Name\"\n        , pp.rdb$parameter_number+1 as \"Ordinal\"\n        , TRIM(CASE\n        WHEN POSITION('#BOOL#', UPPER(pp.rdb$description)) &gt; 0 THEN 'smallint_bool'\n        WHEN POSITION('#GUID#', UPPER(pp.rdb$description)) &gt; 0 THEN 'guid'\n        ELSE CASE f.rdb$field_type\n          WHEN 7 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'smallint'\n            END\n          WHEN 8 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'int'\n            END\n          WHEN 16 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'bigint'\n            END\n          WHEN 10 THEN 'float'\n          WHEN 27 THEN 'double'\n          WHEN 12 THEN 'date'\n          WHEN 13 THEN 'time'\n          WHEN 35 THEN 'timestamp'\n          WHEN 261 THEN CASE f.rdb$field_sub_type\n            WHEN 1 THEN 'clob'\n            ELSE 'blob'\n            END\n          WHEN 37 THEN 'varchar'\n          WHEN 14 THEN 'char'\n          WHEN 40 THEN 'cstring'\n          END\n        END) as \"TypeName\"\n        , IIF(f.rdb$character_length = 0, 32765, f.rdb$character_length) as \"MaxLength\" --hot fix for CORE-2228\n        , IIF(f.rdb$field_precision = 0 AND f.rdb$field_scale &lt; 0, 18, f.rdb$field_precision) as \"Precision\"\n        , 4 as \"DateTimePrecision\"\n        , f.rdb$field_scale * (-1) as \"Scale\"\n        , NULL as \"CollationCatalog\"\n        , NULL as \"CollationSchema\"\n        , NULL \"CollationName\"\n        , NULL as \"CharacterSetCatalog\"\n        , NULL as \"CharacterSetSchema\"\n        , NULL as \"CharacterSetName\"\n        , 0 as \"IsMultiSet\"\n        , TRIM(IIF(pp.rdb$parameter_type = 1, 'OUT', 'IN')) as \"Mode\"\n        , NULL as \"Default\"\n        FROM\n        rdb$procedure_parameters pp INNER JOIN rdb$fields f ON (pp.rdb$field_source = f.rdb$field_name)\n        WHERE pp.rdb$parameter_type = 0\n      </DefiningQuery>\n    </EntitySet>\n\t<EntitySet Name=\"SFunctionReturnTableColumns\" EntityType=\"Self.FunctionReturnTableColumn\">\n\t\t<DefiningQuery>\n\t\t\t-- SFunctionReturnTableColumns3\n\t\t\tSELECT\n\t\t\tTRIM(pp.rdb$procedure_name) || 'x' || TRIM(pp.rdb$parameter_name) as \"Id\"\n\t\t\t, TRIM(pp.rdb$procedure_name) as \"ParentId\"\n\t\t\t, TRIM(pp.rdb$parameter_name) as \"Name\"\n\t\t\t, pp.rdb$parameter_number+1 as \"Ordinal\"\n\t\t\t, IIF(f.rdb$null_flag IS NULL, 1, 0) as \"IsNullable\"\n\t\t\t, TRIM(CASE\n\t\t\tWHEN POSITION('#BOOL#', UPPER(pp.rdb$description)) &gt; 0 THEN 'smallint_bool'\n\t\t\tWHEN POSITION('#GUID#', UPPER(pp.rdb$description)) &gt; 0 THEN 'guid'\n\t\t\tELSE CASE f.rdb$field_type\n\t\t\t  WHEN 7 THEN CASE\n\t\t\t\tWHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n\t\t\t\tWHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n\t\t\t\tELSE 'smallint'\n\t\t\t\tEND\n\t\t\t  WHEN 8 THEN CASE\n\t\t\t\tWHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n\t\t\t\tWHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n\t\t\t\tELSE 'int'\n\t\t\t\tEND\n\t\t\t  WHEN 16 THEN CASE\n\t\t\t\tWHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n\t\t\t\tWHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n\t\t\t\tELSE 'bigint'\n\t\t\t\tEND\n\t\t\t  WHEN 10 THEN 'float'\n\t\t\t  WHEN 27 THEN 'double'\n\t\t\t  WHEN 12 THEN 'date'\n\t\t\t  WHEN 13 THEN 'time'\n\t\t\t  WHEN 35 THEN 'timestamp'\n\t\t\t  WHEN 261 THEN CASE f.rdb$field_sub_type\n\t\t\t\tWHEN 1 THEN 'clob'\n\t\t\t\tELSE 'blob'\n\t\t\t\tEND\n\t\t\t  WHEN 37 THEN 'varchar'\n\t\t\t  WHEN 14 THEN 'char'\n\t\t\t  WHEN 40 THEN 'cstring'\n\t\t\t  END\n\t\t\tEND) as \"TypeName\"\n\t\t\t, IIF(f.rdb$character_length = 0, 32765, f.rdb$character_length) as \"MaxLength\" --hot fix for CORE-2228\n\t\t\t, IIF(f.rdb$field_precision = 0 AND f.rdb$field_scale &lt; 0, 18, f.rdb$field_precision) as \"Precision\"\n\t\t\t, 4 as \"DateTimePrecision\"\n\t\t\t, f.rdb$field_scale * (-1) as \"Scale\"\n\t\t\t, NULL as \"CollationCatalog\"\n\t\t\t, NULL as \"CollationSchema\"\n\t\t\t, NULL \"CollationName\"\n\t\t\t, NULL as \"CharacterSetCatalog\"\n\t\t\t, NULL as \"CharacterSetSchema\"\n\t\t\t, NULL as \"CharacterSetName\"\n\t\t\t, 0 as \"IsMultiSet\"\n\t\t\t, 0 as \"IsIdentity\"\n\t\t\t, 0 as \"IsStoreGenerated\"\n\t\t\t, NULL as \"Default\"\n\t\t\tFROM\n\t\t\trdb$procedure_parameters pp INNER JOIN rdb$fields f ON (pp.rdb$field_source = f.rdb$field_name)\n\t\t\tWHERE pp.rdb$parameter_type = 1\n\t\t</DefiningQuery>\n\t</EntitySet>\n\n    <EntitySet Name=\"SProcedures\" EntityType=\"Self.Procedure\">\n      <DefiningQuery>\n        -- SProcedures3\n        SELECT\n        TRIM(rdb$procedure_name) as \"Id\"\n        , 'Firebird' as \"CatalogName\"\n        , 'Firebird' as \"SchemaName\"\n        , TRIM(rdb$procedure_name) as \"Name\"\n        FROM\n        rdb$procedures\n\t\tWHERE\n\t\trdb$procedure_type = 2\n      </DefiningQuery>\n    </EntitySet>\n    <EntitySet Name=\"SProcedureParameters\" EntityType=\"Self.Parameter\">\n      <DefiningQuery>\n        -- SProcedureParameters3\n        SELECT\n        TRIM(pp.rdb$procedure_name) || 'x' || TRIM(pp.rdb$parameter_name) as \"Id\"\n        , TRIM(pp.rdb$procedure_name) as \"ParentId\"\n        , TRIM(pp.rdb$parameter_name) as \"Name\"\n        , pp.rdb$parameter_number+1 as \"Ordinal\"\n        , TRIM(CASE\n        WHEN POSITION('#BOOL#', UPPER(pp.rdb$description)) &gt; 0 THEN 'smallint_bool'\n        WHEN POSITION('#GUID#', UPPER(pp.rdb$description)) &gt; 0 THEN 'guid'\n        ELSE CASE f.rdb$field_type\n          WHEN 7 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'smallint'\n            END\n          WHEN 8 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'int'\n            END\n          WHEN 16 THEN CASE\n            WHEN ((f.rdb$field_sub_type = 2) OR (f.rdb$field_sub_type = 0 AND f.rdb$field_scale &lt; 0)) THEN 'decimal'\n            WHEN f.rdb$field_sub_type = 1 THEN 'numeric'\n            ELSE 'bigint'\n            END\n          WHEN 10 THEN 'float'\n          WHEN 27 THEN 'double'\n          WHEN 12 THEN 'date'\n          WHEN 13 THEN 'time'\n          WHEN 35 THEN 'timestamp'\n          WHEN 261 THEN CASE f.rdb$field_sub_type\n            WHEN 1 THEN 'clob'\n            ELSE 'blob'\n            END\n          WHEN 37 THEN 'varchar'\n          WHEN 14 THEN 'char'\n          WHEN 40 THEN 'cstring'\n          END\n        END) as \"TypeName\"\n        , IIF(f.rdb$character_length = 0, 32765, f.rdb$character_length) as \"MaxLength\" --hot fix for CORE-2228\n        , IIF(f.rdb$field_precision = 0 AND f.rdb$field_scale &lt; 0, 18, f.rdb$field_precision) as \"Precision\"\n        , 4 as \"DateTimePrecision\"\n        , f.rdb$field_scale * (-1) as \"Scale\"\n        , NULL as \"CollationCatalog\"\n        , NULL as \"CollationSchema\"\n        , NULL \"CollationName\"\n        , NULL as \"CharacterSetCatalog\"\n        , NULL as \"CharacterSetSchema\"\n        , NULL as \"CharacterSetName\"\n        , 0 as \"IsMultiSet\"\n        , TRIM(IIF(pp.rdb$parameter_type = 1, 'OUT', 'IN')) as \"Mode\"\n        , NULL as \"Default\"\n        FROM\n        rdb$procedure_parameters pp INNER JOIN rdb$fields f ON (pp.rdb$field_source = f.rdb$field_name)\n        WHERE pp.rdb$parameter_type = 0\n      </DefiningQuery>\n    </EntitySet>\n\n    <EntitySet Name=\"SConstraints\" EntityType=\"Self.Constraint\">\n      <DefiningQuery>\n        -- SConstraints3\n        SELECT\n        TRIM(rc.rdb$constraint_name) as \"Id\"\n        , TRIM(rc.rdb$relation_name) as \"ParentId\"\n        , TRIM(rc.rdb$constraint_name) as \"Name\"\n        , TRIM(rc.rdb$constraint_type) as \"ConstraintType\"\n        , 0 as \"IsDeferrable\"\n        , 0 \"IsInitiallyDeferred\"\n        FROM\n        rdb$relation_constraints rc\n        WHERE\n        rc.rdb$constraint_type IN ('PRIMARY KEY', 'FOREIGN KEY', 'UNIQUE')\n      </DefiningQuery>\n    </EntitySet>\n    <EntitySet Name=\"SCheckConstraints\" EntityType=\"Self.CheckConstraint\">\n      <DefiningQuery>\n        -- SCheckConstraints3\n        SELECT\n        TRIM(rc.rdb$constraint_name) as \"Id\"\n        , TRIM(SUBSTRING(trg.rdb$trigger_source from 6)) as \"Expression\"\n        FROM\n        rdb$relation_constraints rc\n        INNER JOIN rdb$check_constraints cc on (rc.rdb$constraint_name = cc.rdb$constraint_name)\n        LEFT JOIN rdb$triggers trg on (cc.rdb$trigger_name = trg.rdb$trigger_name)\n        WHERE\n        rc.rdb$constraint_type IN ('CHECK')\n      </DefiningQuery>\n    </EntitySet>\n    <EntitySet Name=\"SConstraintColumns\" EntityType=\"Self.ConstraintColumn\">\n      <DefiningQuery>\n        -- SConstraintColumns3\n        SELECT\n        TRIM(rc.rdb$constraint_name) as \"ConstraintId\"\n        , TRIM(rc.rdb$relation_name) || 'x' || TRIM(ise.rdb$field_name) as \"ColumnId\"\n        FROM\n        rdb$relation_constraints rc INNER JOIN rdb$index_segments ise ON (rc.rdb$index_name = ise.rdb$index_name)\n        WHERE\n        rc.rdb$constraint_type IN ('PRIMARY KEY', 'FOREIGN KEY', 'UNIQUE')\n      </DefiningQuery>\n    </EntitySet>\n    \n    <EntitySet Name=\"SForeignKeyConstraints\" EntityType=\"Self.ForeignKeyConstraint\">\n      <DefiningQuery>\n        -- SForeignKeyConstraints3\n        SELECT\n        TRIM(rc.rdb$constraint_name) as \"Id\"\n        , rc.rdb$update_rule \"UpdateRule\"\n        , rc.rdb$delete_rule \"DeleteRule\"\n        FROM\n        rdb$ref_constraints rc\n      </DefiningQuery>\n    </EntitySet>\n    <EntitySet Name=\"SForeignKeys\" EntityType=\"Self.ForeignKey\">\n      <DefiningQuery>\n        -- SForeignKeys3\n        SELECT\n        TRIM(refc.rdb$constraint_name) || 'x' || TRIM(is2.rdb$field_position+1) as \"Id\"\n        , TRIM(relc1.rdb$relation_name) || 'x' || TRIM(is1.rdb$field_name) as \"FromColumnId\"\n        , TRIM(relc2.rdb$relation_name) || 'x' || TRIM(is2.rdb$field_name) as \"ToColumnId\"\n        , TRIM(refc.rdb$constraint_name) as \"ConstraintId\"\n        , is2.rdb$field_position+1 as \"Ordinal\"\n        FROM rdb$ref_constraints refc\n        LEFT JOIN rdb$relation_constraints relc1 ON (refc.rdb$constraint_name = relc1.rdb$constraint_name)\n        INNER JOIN rdb$index_segments is1 ON (relc1.rdb$index_name = is1.rdb$index_name)\n        LEFT JOIN rdb$relation_constraints relc2 ON (refc.rdb$const_name_uq = relc2.rdb$constraint_name)\n        INNER JOIN rdb$index_segments is2 ON (relc2.rdb$index_name = is2.rdb$index_name)\n        WHERE is1.rdb$field_position = is2.rdb$field_position\n      </DefiningQuery>\n    </EntitySet>\n\n    <EntitySet Name=\"SViewConstraints\" EntityType=\"Self.ViewConstraint\">\n      <DefiningQuery>\n        -- SViewConstraints3\n        SELECT\n        CAST(NULL as varchar(1)) as \"Id\"\n        , CAST(NULL as varchar(1)) as \"ParentId\"\n        , CAST(NULL as varchar(1)) as \"Name\"\n        , CAST(NULL as varchar(1)) as \"ConstraintType\"\n        , CAST(0 as smallint) as \"IsDeferrable\"\n        , CAST(0 as smallint) as \"IsInitiallyDeferred\"\n        , CAST(NULL as varchar(1)) as \"Expression\"\n        , CAST(NULL as varchar(1)) as \"UpdateRule\"\n        , CAST(NULL as varchar(1)) as \"DeleteRule\"\n        FROM rdb$database\n        WHERE 0=1\n      </DefiningQuery>\n    </EntitySet>\n    <EntitySet Name=\"SViewConstraintColumns\" EntityType=\"Self.ConstraintColumn\">\n      <DefiningQuery>\n        -- SViewConstraintColumns3\n        SELECT\n        CAST(NULL as varchar(1)) as \"ConstraintId\"\n        , CAST(NULL as varchar(1)) as \"ColumnId\"\n        FROM rdb$database\n        WHERE 0=1\n      </DefiningQuery>\n    </EntitySet>\n    <EntitySet Name=\"SViewForeignKeys\" EntityType=\"Self.ForeignKey\">\n      <DefiningQuery>\n        -- SViewForeignKeys3\n        SELECT\n        CAST(NULL as varchar(1)) as \"Id\"\n        , CAST(NULL as varchar(1)) as \"ToColumnId\"\n        , CAST(NULL as varchar(1)) as \"FromColumnId\"\n        , CAST(NULL as varchar(1)) as \"ConstraintId\"\n        , 0 as \"Ordinal\"\n        FROM rdb$database\n        WHERE 0=1\n      </DefiningQuery>\n    </EntitySet>\n\n\t  <AssociationSet Name=\"STableTableColumns\" Association=\"Self.TableTableColumn\" >\n\t\t  <End Role=\"Parent\" EntitySet=\"STables\"/>\n\t\t  <End Role=\"Column\" EntitySet=\"STableColumns\"/>\n\t  </AssociationSet>\n\t  <AssociationSet Name=\"STableConstraints\" Association=\"Self.TableTableConstraint\" >\n\t\t  <End Role=\"Parent\" EntitySet=\"STables\"/>\n\t\t  <End Role=\"Constraint\" EntitySet=\"SConstraints\"/>\n\t  </AssociationSet>\n\t  <AssociationSet Name=\"SConstraintConstraintColumns\" Association=\"Self.ConstraintConstraintColumn\" >\n\t\t  <End Role=\"ConstraintColumn\" EntitySet=\"SConstraintColumns\"/>\n\t\t  <End Role=\"Constraint\" EntitySet=\"SConstraints\"/>\n\t  </AssociationSet>\n\t  <AssociationSet Name=\"SConstraintForeignKeys\" Association=\"Self.ConstraintForeignKey\" >\n\t\t  <End Role=\"ForeignKey\" EntitySet=\"SForeignKeys\"/>\n\t\t  <End Role=\"Constraint\" EntitySet=\"SForeignKeyConstraints\"/>\n\t  </AssociationSet>\n\t  <AssociationSet Name=\"SFromForeignKeyColumns\" Association=\"Self.FromForeignKeyColumn\" >\n\t\t  <End Role=\"ForeignKey\" EntitySet=\"SForeignKeys\"/>\n\t\t  <End Role=\"Column\" EntitySet=\"STableColumns\"/>\n\t  </AssociationSet>\n\t  <AssociationSet Name=\"SToForeignKeyColumns\" Association=\"Self.ToForeignKeyColumn\" >\n\t\t  <End Role=\"ForeignKey\" EntitySet=\"SForeignKeys\"/>\n\t\t  <End Role=\"Column\" EntitySet=\"STableColumns\"/>\n\t  </AssociationSet>\n\n\t  <AssociationSet Name=\"SViewViewColumns\" Association=\"Self.ViewViewColumn\" >\n\t\t  <End Role=\"Parent\" EntitySet=\"SViews\"/>\n\t\t  <End Role=\"Column\" EntitySet=\"SViewColumns\"/>\n\t  </AssociationSet>\n\t  <AssociationSet Name=\"SViewViewConstraints\" Association=\"Self.ViewViewConstraint\" >\n\t\t  <End Role=\"Parent\" EntitySet=\"SViews\"/>\n\t\t  <End Role=\"Constraint\" EntitySet=\"SViewConstraints\"/>\n\t  </AssociationSet>\n\t  <AssociationSet Name=\"SViewConstraintConstraintColumns\" Association=\"Self.ViewConstraintConstraintColumn\" >\n\t\t  <End Role=\"ConstraintColumn\" EntitySet=\"SViewConstraintColumns\"/>\n\t\t  <End Role=\"Constraint\" EntitySet=\"SViewConstraints\"/>\n\t  </AssociationSet>\n\t  <AssociationSet Name=\"SViewConstraintForeignKeys\" Association=\"Self.ViewConstraintForeignKey\" >\n\t\t  <End Role=\"ForeignKey\" EntitySet=\"SViewForeignKeys\"/>\n\t\t  <End Role=\"Constraint\" EntitySet=\"SViewConstraints\"/>\n\t  </AssociationSet>\n\t  <AssociationSet Name=\"SFromForeignKeyViewColumns\" Association=\"Self.FromForeignKeyViewColumn\" >\n\t\t  <End Role=\"ForeignKey\" EntitySet=\"SViewForeignKeys\"/>\n\t\t  <End Role=\"Column\" EntitySet=\"SViewColumns\"/>\n\t  </AssociationSet>\n\t  <AssociationSet Name=\"SToForeignKeyViewColumns\" Association=\"Self.ToForeignKeyViewColumn\" >\n\t\t  <End Role=\"ForeignKey\" EntitySet=\"SViewForeignKeys\"/>\n\t\t  <End Role=\"Column\" EntitySet=\"SViewColumns\"/>\n\t  </AssociationSet>\n\n\t  <AssociationSet Name=\"FunctionFunctionParameters\" Association=\"Self.FunctionFunctionParameter\">\n\t\t  <End Role=\"Function\" EntitySet=\"SFunctions\"/>\n\t\t  <End Role=\"Parameter\" EntitySet=\"SFunctionParameters\"/>\n\t  </AssociationSet>\n\t  <AssociationSet Name=\"FunctionFunctionReturnTableColumns\" Association=\"Self.FunctionFunctionReturnTableColumn\" >\n\t\t  <End Role=\"Function\" EntitySet=\"SFunctions\"/>\n\t\t  <End Role=\"Column\" EntitySet=\"SFunctionReturnTableColumns\"/>\n\t  </AssociationSet>\n\t  <AssociationSet Name=\"ProcedureProcedureParameters\" Association=\"Self.ProcedureProcedureParameter\" >\n\t\t  <End Role=\"Procedure\" EntitySet=\"SProcedures\"/>\n\t\t  <End Role=\"Parameter\" EntitySet=\"SProcedureParameters\"/>\n\t  </AssociationSet>\n\n  </EntityContainer>\n\n  <EntityType Name=\"Table\">\n    <Key>\n      <PropertyRef Name=\"Id\" />\n    </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"CatalogName\" Type=\"varchar\" MaxLength=\"8\" />\n    <Property Name=\"SchemaName\" Type=\"varchar\" MaxLength=\"8\" />\n    <Property Name=\"Name\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n  </EntityType>\n\n  <EntityType Name=\"TableColumn\">\n\t  <Key>\n\t\t  <PropertyRef Name=\"Id\" />\n\t  </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"63\" />\n    <Property Name=\"ParentId\" Nullable=\"false\" MaxLength=\"31\" Type=\"varchar\" />\n    <Property Name=\"Name\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"Ordinal\" Nullable=\"false\" Type=\"int\" />\n    <Property Name=\"IsNullable\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"TypeName\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"256\" />\n    <Property Name=\"MaxLength\" Type=\"int\" />\n    <Property Name=\"Precision\" Type=\"int\" />\n    <Property Name=\"DateTimePrecision\" Type=\"int\" />\n    <Property Name=\"Scale\" Type=\"int\" />\n    <Property Name=\"CollationCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CollationSchema\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CollationName\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetSchema\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetName\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"IsMultiSet\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"IsIdentity\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"IsStoreGenerated\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"Default\" Nullable=\"true\" Type=\"varchar\" />\n  </EntityType>\n\n  <EntityType Name=\"View\">\n\t  <Key>\n\t\t  <PropertyRef Name=\"Id\" />\n\t  </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"CatalogName\" Type=\"varchar\" MaxLength=\"8\" />\n    <Property Name=\"SchemaName\" Type=\"varchar\" MaxLength=\"8\" />\n    <Property Name=\"Name\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"ViewDefinition\" Nullable=\"true\" Type=\"varchar\" />\n    <Property Name=\"IsUpdatable\" Nullable=\"false\" Type=\"smallint_bool\" />\n  </EntityType>\n\n  <EntityType Name=\"ViewColumn\">\n\t  <Key>\n\t\t  <PropertyRef Name=\"Id\" />\n\t  </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"63\" />\n    <Property Name=\"ParentId\" Nullable=\"false\" MaxLength=\"31\" Type=\"varchar\" />\n    <Property Name=\"Name\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"Ordinal\" Nullable=\"false\" Type=\"int\" />\n    <Property Name=\"IsNullable\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"TypeName\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"256\" />\n    <Property Name=\"MaxLength\" Type=\"int\" />\n    <Property Name=\"Precision\" Type=\"int\" />\n    <Property Name=\"DateTimePrecision\" Type=\"int\" />\n    <Property Name=\"Scale\" Type=\"int\" />\n    <Property Name=\"CollationCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CollationSchema\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CollationName\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetSchema\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetName\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"IsMultiSet\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"IsIdentity\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"IsStoreGenerated\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"Default\" Nullable=\"true\" Type=\"varchar\" />\n  </EntityType>\n\n  <EntityType Name=\"Function\">\n\t  <Key>\n\t\t  <PropertyRef Name=\"Id\" />\n\t  </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"CatalogName\" Type=\"varchar\" MaxLength=\"8\" />\n    <Property Name=\"SchemaName\" Type=\"varchar\" MaxLength=\"8\" />\n    <Property Name=\"Name\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"ReturnTypeName\" Type=\"varchar\" MaxLength=\"256\" />\n    <Property Name=\"ReturnMaxLength\" Type=\"int\" />\n    <Property Name=\"ReturnPrecision\" Type=\"int\" />\n    <Property Name=\"ReturnDateTimePrecision\" Type=\"int\" />\n    <Property Name=\"ReturnScale\" Type=\"int\" />\n    <Property Name=\"ReturnCollationCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"ReturnCollationSchema\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"ReturnCollationName\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"ReturnCharacterSetCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"ReturnCharacterSetSchema\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"ReturnCharacterSetName\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"ReturnIsMultiSet\" Type=\"smallint_bool\" />\n    <Property Name=\"IsAggregate\" Type=\"smallint_bool\" />\n    <Property Name=\"IsBuiltIn\" Type=\"smallint_bool\" />\n    <Property Name=\"IsNiladic\" Type=\"smallint_bool\" />\n    <Property Name=\"IsTvf\" Nullable=\"false\" Type=\"smallint_bool\" />\n  </EntityType>\n\n  <EntityType Name=\"Procedure\">\n\t  <Key>\n\t\t  <PropertyRef Name=\"Id\" />\n\t  </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"CatalogName\" Type=\"varchar\" MaxLength=\"8\" />\n    <Property Name=\"SchemaName\" Type=\"varchar\" MaxLength=\"8\" />\n    <Property Name=\"Name\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n  </EntityType>\n\n  <EntityType Name=\"Parameter\">\n\t  <Key>\n\t\t  <PropertyRef Name=\"Id\" />\n\t  </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"63\" />\n    <Property Name=\"ParentId\" Nullable=\"false\" MaxLength=\"31\" Type=\"varchar\" />\n    <Property Name=\"Name\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"Ordinal\" Nullable=\"false\" Type=\"int\" />\n    <Property Name=\"TypeName\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"256\" />\n\t  <Property Name=\"MaxLength\" Nullable=\"true\" Type=\"int\" />\n\t  <Property Name=\"Precision\" Nullable=\"true\" Type=\"int\" />\n\t  <Property Name=\"DateTimePrecision\" Type=\"int\" />\n\t  <Property Name=\"Scale\" Nullable=\"true\" Type=\"int\" />\n    <Property Name=\"CollationCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CollationSchema\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CollationName\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetSchema\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"CharacterSetName\" Type=\"varchar\" MaxLength=\"128\" />\n    <Property Name=\"IsMultiSet\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"Mode\" Type=\"varchar\" MaxLength=\"16\" />\n    <Property Name=\"Default\" Type=\"varchar\" />\n  </EntityType>\n\n  <EntityType Name=\"FunctionReturnTableColumn\" >\n\t  <Key>\n\t\t  <PropertyRef Name=\"Id\" />\n\t  </Key>\n\t  <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"63\" />\n\t  <Property Name=\"ParentId\" Nullable=\"false\" MaxLength=\"31\" Type=\"varchar\" />\n\t  <Property Name=\"Name\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n\t  <Property Name=\"Ordinal\" Nullable=\"false\" Type=\"int\" />\n\t  <Property Name=\"IsNullable\" Nullable=\"false\" Type=\"smallint_bool\" />\n\t  <Property Name=\"TypeName\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"256\" />\n\t  <Property Name=\"MaxLength\" Type=\"int\" />\n\t  <Property Name=\"Precision\" Type=\"int\" />\n\t  <Property Name=\"DateTimePrecision\" Type=\"int\" />\n\t  <Property Name=\"Scale\" Type=\"int\" />\n\t  <Property Name=\"CollationCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n\t  <Property Name=\"CollationSchema\" Type=\"varchar\" MaxLength=\"128\" />\n\t  <Property Name=\"CollationName\" Type=\"varchar\" MaxLength=\"128\" />\n\t  <Property Name=\"CharacterSetCatalog\" Type=\"varchar\" MaxLength=\"128\" />\n\t  <Property Name=\"CharacterSetSchema\" Type=\"varchar\" MaxLength=\"128\" />\n\t  <Property Name=\"CharacterSetName\" Type=\"varchar\" MaxLength=\"128\" />\n\t  <Property Name=\"IsMultiSet\" Nullable=\"false\" Type=\"smallint_bool\" />\n\t  <Property Name=\"IsIdentity\" Nullable=\"false\" Type=\"smallint_bool\" />\n\t  <Property Name=\"IsStoreGenerated\" Nullable=\"false\" Type=\"smallint_bool\" />\n\t  <Property Name=\"Default\" Nullable=\"true\" Type=\"varchar\"/>\n  </EntityType>\n\n  <EntityType Name=\"Constraint\">\n\t  <Key>\n\t\t  <PropertyRef Name=\"Id\" />\n\t  </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"ParentId\" Nullable=\"false\" MaxLength=\"31\" Type=\"varchar\" />\n    <Property Name=\"Name\" Nullable=\"false\" MaxLength=\"31\" Type=\"varchar\" />\n    <Property Name=\"IsDeferrable\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"IsInitiallyDeferred\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"ConstraintType\" Nullable=\"false\" MaxLength=\"11\" Type=\"varchar\" />\n  </EntityType>\n\n  <EntityType Name=\"CheckConstraint\">\n\t  <Key>\n\t\t  <PropertyRef Name=\"Id\" />\n\t  </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"Expression\" Nullable=\"true\" MaxLength=\"1000\" Type=\"varchar\" />\n  </EntityType>\n\n  <EntityType Name=\"ConstraintColumn\">\n\t  <Key>\n\t\t  <PropertyRef Name=\"ConstraintId\" />\n\t\t  <PropertyRef Name=\"ColumnId\" />\n\t  </Key>\n    <Property Name=\"ConstraintId\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"ColumnId\" Nullable=\"false\" MaxLength=\"63\" Type=\"varchar\" />\n  </EntityType>\n\n  <EntityType Name=\"ForeignKeyConstraint\">\n\t  <Key>\n\t\t  <PropertyRef Name=\"Id\" />\n\t  </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"UpdateRule\" Nullable=\"false\" MaxLength=\"11\" Type=\"varchar\" />\n    <Property Name=\"DeleteRule\" Nullable=\"false\" MaxLength=\"11\" Type=\"varchar\" />\n  </EntityType>\n\n  <EntityType Name=\"ForeignKey\">\n\t  <Key>\n\t\t  <PropertyRef Name=\"Id\" />\n\t  </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n\t  <Property Name=\"Ordinal\" Nullable=\"false\" Type=\"int\" />\n    <Property Name=\"ConstraintId\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"FromColumnId\" Nullable=\"false\" MaxLength=\"63\" Type=\"varchar\" />\n    <Property Name=\"ToColumnId\" Nullable=\"false\" MaxLength=\"63\" Type=\"varchar\" />\n  </EntityType>\n\n  <EntityType Name=\"ViewConstraint\">\n\t  <Key>\n\t\t  <PropertyRef Name=\"Id\" />\n\t  </Key>\n    <Property Name=\"Id\" Nullable=\"false\" Type=\"varchar\" MaxLength=\"31\" />\n    <Property Name=\"ParentId\" Nullable=\"false\" MaxLength=\"31\" Type=\"varchar\" />\n    <Property Name=\"Name\" Nullable=\"false\" MaxLength=\"31\" Type=\"varchar\" />\n    <Property Name=\"IsDeferrable\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"IsInitiallyDeferred\" Nullable=\"false\" Type=\"smallint_bool\" />\n    <Property Name=\"ConstraintType\" Nullable=\"false\" MaxLength=\"11\" Type=\"varchar\" />\n    <Property Name=\"Expression\" Nullable=\"true\" MaxLength=\"1000\" Type=\"varchar\" />\n    <Property Name=\"UpdateRule\" Nullable=\"true\" MaxLength=\"11\" Type=\"varchar\" />\n    <Property Name=\"DeleteRule\" Nullable=\"true\" MaxLength=\"11\" Type=\"varchar\" />\n  </EntityType>\n\n  <Association Name=\"TableTableConstraint\">\n\t  <End Type=\"Self.Table\" Role=\"Parent\" Multiplicity=\"1\" />\n\t  <End Type=\"Self.Constraint\" Role=\"Constraint\" Multiplicity=\"*\" />\n\t  <ReferentialConstraint>\n\t\t  <Principal Role=\"Parent\">\n\t\t\t  <PropertyRef Name=\"Id\" />\n\t\t  </Principal>\n\t\t  <Dependent Role=\"Constraint\">\n\t\t\t  <PropertyRef Name=\"ParentId\" />\n\t\t  </Dependent>\n\t  </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ConstraintConstraintColumn\">\n\t  <End Type=\"Self.Constraint\" Role=\"Constraint\" Multiplicity=\"1\" />\n\t  <End Type=\"Self.ConstraintColumn\" Role=\"ConstraintColumn\" Multiplicity=\"*\" />\n\t  <ReferentialConstraint>\n\t\t  <Principal Role=\"Constraint\">\n\t\t\t  <PropertyRef Name=\"Id\" />\n\t\t  </Principal>\n\t\t  <Dependent Role=\"ConstraintColumn\">\n\t\t\t  <PropertyRef Name=\"ConstraintId\" />\n\t\t  </Dependent>\n\t  </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ConstraintForeignKey\">\n\t  <End Type=\"Self.ForeignKeyConstraint\" Role=\"Constraint\" Multiplicity=\"1\" />\n\t  <End Type=\"Self.ForeignKey\" Role=\"ForeignKey\" Multiplicity=\"*\" />\n\t  <ReferentialConstraint>\n\t\t  <Principal Role=\"Constraint\">\n\t\t\t  <PropertyRef Name=\"Id\" />\n\t\t  </Principal>\n\t\t  <Dependent Role=\"ForeignKey\">\n\t\t\t  <PropertyRef Name=\"ConstraintId\" />\n\t\t  </Dependent>\n\t  </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"FromForeignKeyColumn\">\n\t  <End Type=\"Self.TableColumn\" Role=\"Column\" Multiplicity=\"1\" />\n\t  <End Type=\"Self.ForeignKey\" Role=\"ForeignKey\" Multiplicity=\"*\" />\n\t  <ReferentialConstraint>\n\t\t  <Principal Role=\"Column\">\n\t\t\t  <PropertyRef Name=\"Id\" />\n\t\t  </Principal>\n\t\t  <Dependent Role=\"ForeignKey\">\n\t\t\t  <PropertyRef Name=\"FromColumnId\" />\n\t\t  </Dependent>\n\t  </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ToForeignKeyColumn\">\n\t  <End Type=\"Self.TableColumn\" Role=\"Column\" Multiplicity=\"1\" />\n\t  <End Type=\"Self.ForeignKey\" Role=\"ForeignKey\" Multiplicity=\"*\" />\n\t  <ReferentialConstraint>\n\t\t  <Principal Role=\"Column\">\n\t\t\t  <PropertyRef Name=\"Id\" />\n\t\t  </Principal>\n\t\t  <Dependent Role=\"ForeignKey\">\n\t\t\t  <PropertyRef Name=\"ToColumnId\" />\n\t\t  </Dependent>\n\t  </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"TableTableColumn\">\n\t  <End Type=\"Self.Table\" Role=\"Parent\" Multiplicity=\"1\" />\n\t  <End Type=\"Self.TableColumn\" Role=\"Column\" Multiplicity=\"*\" />\n\t  <ReferentialConstraint>\n\t\t  <Principal Role=\"Parent\">\n\t\t\t  <PropertyRef Name=\"Id\" />\n\t\t  </Principal>\n\t\t  <Dependent Role=\"Column\">\n\t\t\t  <PropertyRef Name=\"ParentId\" />\n\t\t  </Dependent>\n\t  </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ViewViewColumn\">\n\t  <End Type=\"Self.View\" Role=\"Parent\" Multiplicity=\"1\" />\n\t  <End Type=\"Self.ViewColumn\" Role=\"Column\" Multiplicity=\"*\" />\n\t  <ReferentialConstraint>\n\t\t  <Principal Role=\"Parent\">\n\t\t\t  <PropertyRef Name=\"Id\" />\n\t\t  </Principal>\n\t\t  <Dependent Role=\"Column\">\n\t\t\t  <PropertyRef Name=\"ParentId\" />\n\t\t  </Dependent>\n\t  </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"FunctionFunctionParameter\">\n\t  <End Type=\"Self.Function\" Role=\"Function\" Multiplicity=\"1\" />\n\t  <End Type=\"Self.Parameter\" Role=\"Parameter\" Multiplicity=\"*\" />\n\t  <ReferentialConstraint>\n\t\t  <Principal Role=\"Function\">\n\t\t\t  <PropertyRef Name=\"Id\" />\n\t\t  </Principal>\n\t\t  <Dependent Role=\"Parameter\">\n\t\t\t  <PropertyRef Name=\"ParentId\" />\n\t\t  </Dependent>\n\t  </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"FunctionFunctionReturnTableColumn\">\n\t  <End Type=\"Self.Function\" Role=\"Function\" Multiplicity=\"1\" />\n\t  <End Type=\"Self.FunctionReturnTableColumn\" Role=\"Column\" Multiplicity=\"*\" />\n\t  <ReferentialConstraint>\n\t\t  <Principal Role=\"Function\">\n\t\t\t  <PropertyRef Name=\"Id\" />\n\t\t  </Principal>\n\t\t  <Dependent Role=\"Column\">\n\t\t\t  <PropertyRef Name=\"ParentId\" />\n\t\t  </Dependent>\n\t  </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ProcedureProcedureParameter\">\n\t  <End Type=\"Self.Procedure\" Role=\"Procedure\" Multiplicity=\"1\" />\n\t  <End Type=\"Self.Parameter\" Role=\"Parameter\" Multiplicity=\"*\" />\n\t  <ReferentialConstraint>\n\t\t  <Principal Role=\"Procedure\">\n\t\t\t  <PropertyRef Name=\"Id\" />\n\t\t  </Principal>\n\t\t  <Dependent Role=\"Parameter\">\n\t\t\t  <PropertyRef Name=\"ParentId\" />\n\t\t  </Dependent>\n\t  </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ViewViewConstraint\">\n\t  <End Type=\"Self.View\" Role=\"Parent\" Multiplicity=\"1\" />\n\t  <End Type=\"Self.ViewConstraint\" Role=\"Constraint\" Multiplicity=\"*\" />\n\t  <ReferentialConstraint>\n\t\t  <Principal Role=\"Parent\">\n\t\t\t  <PropertyRef Name=\"Id\" />\n\t\t  </Principal>\n\t\t  <Dependent Role=\"Constraint\">\n\t\t\t  <PropertyRef Name=\"ParentId\" />\n\t\t  </Dependent>\n\t  </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ViewConstraintConstraintColumn\">\n\t  <End Type=\"Self.ViewConstraint\" Role=\"Constraint\" Multiplicity=\"1\" />\n\t  <End Type=\"Self.ConstraintColumn\" Role=\"ConstraintColumn\" Multiplicity=\"*\" />\n\t  <ReferentialConstraint>\n\t\t  <Principal Role=\"Constraint\">\n\t\t\t  <PropertyRef Name=\"Id\" />\n\t\t  </Principal>\n\t\t  <Dependent Role=\"ConstraintColumn\">\n\t\t\t  <PropertyRef Name=\"ConstraintId\" />\n\t\t  </Dependent>\n\t  </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ViewConstraintForeignKey\">\n\t  <End Type=\"Self.ViewConstraint\" Role=\"Constraint\" Multiplicity=\"1\" />\n\t  <End Type=\"Self.ForeignKey\" Role=\"ForeignKey\" Multiplicity=\"*\" />\n\t  <ReferentialConstraint>\n\t\t  <Principal Role=\"Constraint\">\n\t\t\t  <PropertyRef Name=\"Id\" />\n\t\t  </Principal>\n\t\t  <Dependent Role=\"ForeignKey\">\n\t\t\t  <PropertyRef Name=\"ConstraintId\" />\n\t\t  </Dependent>\n\t  </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"FromForeignKeyViewColumn\">\n\t  <End Type=\"Self.ViewColumn\" Role=\"Column\" Multiplicity=\"1\" />\n\t  <End Type=\"Self.ForeignKey\" Role=\"ForeignKey\" Multiplicity=\"*\" />\n\t  <ReferentialConstraint>\n\t\t  <Principal Role=\"Column\">\n\t\t\t  <PropertyRef Name=\"Id\" />\n\t\t  </Principal>\n\t\t  <Dependent Role=\"ForeignKey\">\n\t\t\t  <PropertyRef Name=\"FromColumnId\" />\n\t\t  </Dependent>\n\t  </ReferentialConstraint>\n  </Association>\n\n  <Association Name=\"ToForeignKeyViewColumn\">\n\t  <End Type=\"Self.ViewColumn\" Role=\"Column\" Multiplicity=\"1\" />\n\t  <End Type=\"Self.ForeignKey\" Role=\"ForeignKey\" Multiplicity=\"*\" />\n\t  <ReferentialConstraint>\n\t\t  <Principal Role=\"Column\">\n\t\t\t  <PropertyRef Name=\"Id\" />\n\t\t  </Principal>\n\t\t  <Dependent Role=\"ForeignKey\">\n\t\t\t  <PropertyRef Name=\"ToColumnId\" />\n\t\t  </Dependent>\n\t  </ReferentialConstraint>\n  </Association>\n\n</Schema>"
  },
  {
    "path": "src/EntityFramework.Firebird/Resources/StoreSchemaMapping.msl",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Mapping xmlns:cs=\"urn:schemas-microsoft-com:windows:storage:mapping:CS\" Space=\"C-S\" xmlns=\"urn:schemas-microsoft-com:windows:storage:mapping:CS\">\n  <cs:EntityContainerMapping StorageEntityContainer=\"Schema\" CdmEntityContainer=\"SchemaInformation\">\n\n    <cs:EntitySetMapping Name=\"Tables\" StoreEntitySet=\"STables\" TypeName=\"Store.Table\">\n      <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <cs:ScalarProperty Name=\"CatalogName\" ColumnName=\"CatalogName\" />\n      <cs:ScalarProperty Name=\"SchemaName\" ColumnName=\"SchemaName\" />\n      <cs:ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n    </cs:EntitySetMapping>\n\n    <cs:EntitySetMapping Name=\"TableColumns\" StoreEntitySet=\"STableColumns\" TypeName=\"Store.Column\">\n      <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <cs:ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n      <cs:ScalarProperty Name=\"Ordinal\" ColumnName=\"Ordinal\" />\n      <cs:ScalarProperty Name=\"IsNullable\" ColumnName=\"IsNullable\" />\n      <cs:ComplexProperty Name=\"ColumnType\">\n        <cs:ScalarProperty Name=\"TypeName\" ColumnName=\"TypeName\" />\n        <cs:ScalarProperty Name=\"MaxLength\" ColumnName=\"MaxLength\" />\n        <cs:ScalarProperty Name=\"DateTimePrecision\" ColumnName=\"DateTimePrecision\" />\n        <cs:ScalarProperty Name=\"Precision\" ColumnName=\"Precision\" />\n        <cs:ScalarProperty Name=\"Scale\" ColumnName=\"Scale\" />\n        <cs:ComplexProperty Name=\"Collation\">\n          <cs:ScalarProperty Name=\"CatalogName\" ColumnName=\"CollationCatalog\" />\n          <cs:ScalarProperty Name=\"SchemaName\" ColumnName=\"CollationSchema\" />\n          <cs:ScalarProperty Name=\"Name\" ColumnName=\"CollationName\" />\n        </cs:ComplexProperty>\n        <cs:ComplexProperty Name=\"CharacterSet\">\n          <cs:ScalarProperty Name=\"CatalogName\" ColumnName=\"CharacterSetCatalog\" />\n          <cs:ScalarProperty Name=\"SchemaName\" ColumnName=\"CharacterSetSchema\" />\n          <cs:ScalarProperty Name=\"Name\" ColumnName=\"CharacterSetName\" />\n        </cs:ComplexProperty>\n        <cs:ScalarProperty Name=\"IsMultiSet\" ColumnName=\"IsMultiSet\" />\n      </cs:ComplexProperty>\n      <cs:ScalarProperty Name=\"IsIdentity\" ColumnName=\"IsIdentity\" />\n      <cs:ScalarProperty Name=\"IsStoreGenerated\" ColumnName=\"IsStoreGenerated\" />\n      <cs:ScalarProperty Name=\"Default\" ColumnName=\"Default\" />\n    </cs:EntitySetMapping>\n\n    <cs:EntitySetMapping Name=\"Views\" StoreEntitySet=\"SViews\" TypeName=\"Store.View\">\n      <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <cs:ScalarProperty Name=\"CatalogName\" ColumnName=\"CatalogName\" />\n      <cs:ScalarProperty Name=\"SchemaName\" ColumnName=\"SchemaName\" />\n      <cs:ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n      <cs:ScalarProperty Name=\"ViewDefinition\" ColumnName=\"ViewDefinition\" />\n      <cs:ScalarProperty Name=\"IsUpdatable\" ColumnName=\"IsUpdatable\" />\n    </cs:EntitySetMapping>\n\n    <cs:EntitySetMapping Name=\"ViewColumns\" StoreEntitySet=\"SViewColumns\" TypeName=\"Store.Column\">\n      <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <cs:ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n      <cs:ScalarProperty Name=\"Ordinal\" ColumnName=\"Ordinal\" />\n      <cs:ScalarProperty Name=\"IsNullable\" ColumnName=\"IsNullable\" />\n      <cs:ComplexProperty Name=\"ColumnType\">\n        <cs:ScalarProperty Name=\"TypeName\" ColumnName=\"TypeName\" />\n        <cs:ScalarProperty Name=\"MaxLength\" ColumnName=\"MaxLength\" />\n        <cs:ScalarProperty Name=\"Precision\" ColumnName=\"Precision\" />\n        <cs:ScalarProperty Name=\"DateTimePrecision\" ColumnName=\"DateTimePrecision\" />\n        <cs:ScalarProperty Name=\"Scale\" ColumnName=\"Scale\" />\n        <cs:ComplexProperty Name=\"Collation\">\n          <cs:ScalarProperty Name=\"CatalogName\" ColumnName=\"CollationCatalog\" />\n          <cs:ScalarProperty Name=\"SchemaName\" ColumnName=\"CollationSchema\" />\n          <cs:ScalarProperty Name=\"Name\" ColumnName=\"CollationName\" />\n        </cs:ComplexProperty>\n        <cs:ComplexProperty Name=\"CharacterSet\">\n          <cs:ScalarProperty Name=\"CatalogName\" ColumnName=\"CharacterSetCatalog\" />\n          <cs:ScalarProperty Name=\"SchemaName\" ColumnName=\"CharacterSetSchema\" />\n          <cs:ScalarProperty Name=\"Name\" ColumnName=\"CharacterSetName\" />\n        </cs:ComplexProperty>\n        <cs:ScalarProperty Name=\"IsMultiSet\" ColumnName=\"IsMultiSet\" />\n      </cs:ComplexProperty>\n      <cs:ScalarProperty Name=\"IsIdentity\" ColumnName=\"IsIdentity\" />\n      <cs:ScalarProperty Name=\"IsStoreGenerated\" ColumnName=\"IsStoreGenerated\" />\n      <cs:ScalarProperty Name=\"Default\" ColumnName=\"Default\" />\n    </cs:EntitySetMapping>\n\n    <cs:EntitySetMapping Name=\"Functions\" TypeName=\"Store.ScalarFunction\" StoreEntitySet=\"SFunctions\">\n      <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <cs:ScalarProperty Name=\"CatalogName\" ColumnName=\"CatalogName\" />\n      <cs:ScalarProperty Name=\"SchemaName\" ColumnName=\"SchemaName\" />\n      <cs:ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n      <cs:ComplexProperty Name=\"ReturnType\">\n        <cs:ScalarProperty Name=\"TypeName\" ColumnName=\"ReturnTypeName\" />\n        <cs:ScalarProperty Name=\"MaxLength\" ColumnName=\"ReturnMaxLength\" />\n        <cs:ScalarProperty Name=\"Precision\" ColumnName=\"ReturnPrecision\" />\n        <cs:ScalarProperty Name=\"DateTimePrecision\" ColumnName=\"ReturnDateTimePrecision\" />\n        <cs:ScalarProperty Name=\"Scale\" ColumnName=\"ReturnScale\" />\n        <cs:ComplexProperty Name=\"Collation\">\n          <cs:ScalarProperty Name=\"CatalogName\" ColumnName=\"ReturnCollationCatalog\" />\n          <cs:ScalarProperty Name=\"SchemaName\" ColumnName=\"ReturnCollationSchema\" />\n          <cs:ScalarProperty Name=\"Name\" ColumnName=\"ReturnCollationName\" />\n        </cs:ComplexProperty>\n        <cs:ComplexProperty Name=\"CharacterSet\">\n          <cs:ScalarProperty Name=\"CatalogName\" ColumnName=\"ReturnCharacterSetCatalog\" />\n          <cs:ScalarProperty Name=\"SchemaName\" ColumnName=\"ReturnCharacterSetSchema\" />\n          <cs:ScalarProperty Name=\"Name\" ColumnName=\"ReturnCharacterSetName\" />\n        </cs:ComplexProperty>\n        <cs:ScalarProperty Name=\"IsMultiSet\" ColumnName=\"ReturnIsMultiSet\" />\n      </cs:ComplexProperty>\n      <cs:ScalarProperty Name=\"IsAggregate\" ColumnName=\"IsAggregate\" />\n      <cs:ScalarProperty Name=\"IsBuiltIn\" ColumnName=\"IsBuiltIn\" />\n      <cs:ScalarProperty Name=\"IsNiladic\" ColumnName=\"IsNiladic\" />\n    </cs:EntitySetMapping>\n\n    <cs:EntitySetMapping Name=\"FunctionParameters\" TypeName=\"Store.Parameter\" StoreEntitySet=\"SFunctionParameters\">\n      <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <cs:ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n      <cs:ScalarProperty Name=\"Ordinal\" ColumnName=\"Ordinal\" />\n      <cs:ComplexProperty Name=\"ParameterType\">\n        <cs:ScalarProperty Name=\"TypeName\" ColumnName=\"TypeName\" />\n        <cs:ScalarProperty Name=\"MaxLength\" ColumnName=\"MaxLength\" />\n        <cs:ScalarProperty Name=\"DateTimePrecision\" ColumnName=\"DateTimePrecision\" />\n        <cs:ScalarProperty Name=\"Precision\" ColumnName=\"Precision\" />\n        <cs:ScalarProperty Name=\"Scale\" ColumnName=\"Scale\" />\n        <cs:ComplexProperty Name=\"Collation\">\n          <cs:ScalarProperty Name=\"CatalogName\" ColumnName=\"CollationCatalog\" />\n          <cs:ScalarProperty Name=\"SchemaName\" ColumnName=\"CollationSchema\" />\n          <cs:ScalarProperty Name=\"Name\" ColumnName=\"CollationName\" />\n        </cs:ComplexProperty>\n        <cs:ComplexProperty Name=\"CharacterSet\">\n          <cs:ScalarProperty Name=\"CatalogName\" ColumnName=\"CharacterSetCatalog\" />\n          <cs:ScalarProperty Name=\"SchemaName\" ColumnName=\"CharacterSetSchema\" />\n          <cs:ScalarProperty Name=\"Name\" ColumnName=\"CharacterSetName\" />\n        </cs:ComplexProperty>\n        <cs:ScalarProperty Name=\"IsMultiSet\" ColumnName=\"IsMultiSet\" />\n      </cs:ComplexProperty>\n      <cs:ScalarProperty Name=\"Mode\" ColumnName=\"Mode\" />\n      <cs:ScalarProperty Name=\"Default\" ColumnName=\"Default\" />\n    </cs:EntitySetMapping>\n\n    <cs:EntitySetMapping Name=\"Procedures\" TypeName=\"Store.Procedure\" StoreEntitySet=\"SProcedures\">\n      <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <cs:ScalarProperty Name=\"CatalogName\" ColumnName=\"CatalogName\" />\n      <cs:ScalarProperty Name=\"SchemaName\" ColumnName=\"SchemaName\" />\n      <cs:ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n    </cs:EntitySetMapping>\n\n    <cs:EntitySetMapping Name=\"ProcedureParameters\" TypeName=\"Store.Parameter\" StoreEntitySet=\"SProcedureParameters\">\n      <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <cs:ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n      <cs:ScalarProperty Name=\"Ordinal\" ColumnName=\"Ordinal\" />\n      <cs:ComplexProperty Name=\"ParameterType\">\n        <cs:ScalarProperty Name=\"TypeName\" ColumnName=\"TypeName\" />\n        <cs:ScalarProperty Name=\"MaxLength\" ColumnName=\"MaxLength\" />\n        <cs:ScalarProperty Name=\"DateTimePrecision\" ColumnName=\"DateTimePrecision\" />\n        <cs:ScalarProperty Name=\"Precision\" ColumnName=\"Precision\" />\n        <cs:ScalarProperty Name=\"Scale\" ColumnName=\"Scale\" />\n        <cs:ComplexProperty Name=\"Collation\">\n          <cs:ScalarProperty Name=\"CatalogName\" ColumnName=\"CollationCatalog\" />\n          <cs:ScalarProperty Name=\"SchemaName\" ColumnName=\"CollationSchema\" />\n          <cs:ScalarProperty Name=\"Name\" ColumnName=\"CollationName\" />\n        </cs:ComplexProperty>\n        <cs:ComplexProperty Name=\"CharacterSet\">\n          <cs:ScalarProperty Name=\"CatalogName\" ColumnName=\"CharacterSetCatalog\" />\n          <cs:ScalarProperty Name=\"SchemaName\" ColumnName=\"CharacterSetSchema\" />\n          <cs:ScalarProperty Name=\"Name\" ColumnName=\"CharacterSetName\" />\n        </cs:ComplexProperty>\n        <cs:ScalarProperty Name=\"IsMultiSet\" ColumnName=\"IsMultiSet\" />\n      </cs:ComplexProperty>\n      <cs:ScalarProperty Name=\"Mode\" ColumnName=\"Mode\" />\n      <cs:ScalarProperty Name=\"Default\" ColumnName=\"Default\" />\n    </cs:EntitySetMapping>\n\n    <cs:EntitySetMapping Name=\"TableConstraints\" >\n      <cs:EntityTypeMapping TypeName=\"IsTypeOf(Store.Constraint)\">\n        <cs:MappingFragment StoreEntitySet=\"SConstraints\">\n          <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <cs:ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n          <cs:ScalarProperty Name=\"IsDeferrable\" ColumnName=\"IsDeferrable\" />\n          <cs:ScalarProperty Name=\"IsInitiallyDeferred\" ColumnName=\"IsInitiallyDeferred\" />\n        </cs:MappingFragment>\n      </cs:EntityTypeMapping>\n      <cs:EntityTypeMapping TypeName=\"Store.UniqueConstraint\">\n        <cs:MappingFragment StoreEntitySet=\"SConstraints\">\n          <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <cs:Condition ColumnName=\"ConstraintType\" Value=\"UNIQUE\"/>\n        </cs:MappingFragment>\n      </cs:EntityTypeMapping>\n      <cs:EntityTypeMapping TypeName=\"Store.CheckConstraint\">\n        <cs:MappingFragment StoreEntitySet=\"SConstraints\">\n          <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <cs:Condition ColumnName=\"ConstraintType\" Value=\"CHECK\"/>\n        </cs:MappingFragment>\n        <cs:MappingFragment StoreEntitySet=\"SCheckConstraints\">\n          <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <cs:ScalarProperty Name=\"Expression\" ColumnName=\"Expression\" />\n        </cs:MappingFragment>\n      </cs:EntityTypeMapping>\n      <cs:EntityTypeMapping TypeName=\"Store.PrimaryKeyConstraint\">\n        <cs:MappingFragment StoreEntitySet=\"SConstraints\">\n          <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <cs:Condition ColumnName=\"ConstraintType\" Value=\"PRIMARY KEY\"/>\n        </cs:MappingFragment>\n      </cs:EntityTypeMapping>\n      <cs:EntityTypeMapping TypeName=\"Store.ForeignKeyConstraint\">\n        <cs:MappingFragment StoreEntitySet=\"SConstraints\">\n          <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <cs:Condition ColumnName=\"ConstraintType\" Value=\"FOREIGN KEY\"/>\n        </cs:MappingFragment>\n        <cs:MappingFragment StoreEntitySet=\"SForeignKeyConstraints\">\n          <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <cs:ScalarProperty Name=\"UpdateRule\" ColumnName=\"UpdateRule\" />\n          <cs:ScalarProperty Name=\"DeleteRule\" ColumnName=\"DeleteRule\" />\n        </cs:MappingFragment>\n      </cs:EntityTypeMapping>\n    </cs:EntitySetMapping>\n\n    <cs:EntitySetMapping Name=\"ViewConstraints\" >\n      <cs:EntityTypeMapping TypeName=\"Store.UniqueConstraint\" >\n        <cs:MappingFragment StoreEntitySet=\"SViewConstraints\">\n          <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <cs:ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n          <cs:ScalarProperty Name=\"IsDeferrable\" ColumnName=\"IsDeferrable\" />\n          <cs:ScalarProperty Name=\"IsInitiallyDeferred\" ColumnName=\"IsInitiallyDeferred\" />\n          <cs:Condition ColumnName=\"ConstraintType\" Value=\"UNIQUE\"/>\n        </cs:MappingFragment>\n      </cs:EntityTypeMapping>\n      <cs:EntityTypeMapping TypeName=\"Store.CheckConstraint\" >\n        <cs:MappingFragment StoreEntitySet=\"SViewConstraints\">\n          <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <cs:ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n          <cs:ScalarProperty Name=\"IsDeferrable\" ColumnName=\"IsDeferrable\" />\n          <cs:ScalarProperty Name=\"IsInitiallyDeferred\" ColumnName=\"IsInitiallyDeferred\" />\n          <cs:ScalarProperty Name=\"Expression\" ColumnName=\"Expression\" />\n          <cs:Condition ColumnName=\"ConstraintType\" Value=\"CHECK\"/>\n        </cs:MappingFragment>\n      </cs:EntityTypeMapping>\n      <cs:EntityTypeMapping TypeName=\"Store.PrimaryKeyConstraint\" >\n        <cs:MappingFragment StoreEntitySet=\"SViewConstraints\">\n          <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <cs:ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n          <cs:ScalarProperty Name=\"IsDeferrable\" ColumnName=\"IsDeferrable\" />\n          <cs:ScalarProperty Name=\"IsInitiallyDeferred\" ColumnName=\"IsInitiallyDeferred\" />\n          <cs:Condition ColumnName=\"ConstraintType\" Value=\"PRIMARY KEY\"/>\n        </cs:MappingFragment>\n      </cs:EntityTypeMapping>\n      <cs:EntityTypeMapping TypeName=\"Store.ForeignKeyConstraint\" >\n        <cs:MappingFragment StoreEntitySet=\"SViewConstraints\">\n          <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <cs:ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n          <cs:ScalarProperty Name=\"IsDeferrable\" ColumnName=\"IsDeferrable\" />\n          <cs:ScalarProperty Name=\"IsInitiallyDeferred\" ColumnName=\"IsInitiallyDeferred\" />\n          <cs:ScalarProperty Name=\"UpdateRule\" ColumnName=\"UpdateRule\" />\n          <cs:ScalarProperty Name=\"DeleteRule\" ColumnName=\"DeleteRule\" />\n          <cs:Condition ColumnName=\"ConstraintType\" Value=\"FOREIGN KEY\"/>\n        </cs:MappingFragment>\n      </cs:EntityTypeMapping>\n    </cs:EntitySetMapping>\n\n    <cs:EntitySetMapping Name=\"TableForeignKeys\" StoreEntitySet=\"SForeignKeys\" TypeName=\"Store.ForeignKey\">\n      <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <cs:ScalarProperty Name=\"Ordinal\" ColumnName=\"Ordinal\" />\n    </cs:EntitySetMapping>\n\n    <cs:EntitySetMapping Name=\"ViewForeignKeys\" StoreEntitySet=\"SViewForeignKeys\" TypeName=\"Store.ForeignKey\">\n      <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <cs:ScalarProperty Name=\"Ordinal\" ColumnName=\"Ordinal\" />\n    </cs:EntitySetMapping>\n\n    <cs:AssociationSetMapping Name=\"TableTableColumns\" StoreEntitySet=\"STableColumns\" TypeName=\"Store.TableOrViewColumn\">\n      <cs:EndProperty Name=\"Parent\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"ParentId\" />\n      </cs:EndProperty>\n      <cs:EndProperty Name=\"Column\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </cs:EndProperty>\n    </cs:AssociationSetMapping>\n\n    <cs:AssociationSetMapping Name=\"ViewViewColumns\" StoreEntitySet=\"SViewColumns\" TypeName=\"Store.TableOrViewColumn\">\n      <cs:EndProperty Name=\"Parent\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"ParentId\" />\n      </cs:EndProperty>\n      <cs:EndProperty Name=\"Column\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </cs:EndProperty>\n    </cs:AssociationSetMapping>\n\n    <cs:AssociationSetMapping Name=\"TableTableConstraints\" StoreEntitySet=\"SConstraints\" TypeName=\"Store.TableOrViewConstraint\">\n      <cs:EndProperty Name=\"Parent\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"ParentId\" />\n      </cs:EndProperty>\n      <cs:EndProperty Name=\"Constraint\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </cs:EndProperty>\n    </cs:AssociationSetMapping>\n\n    <cs:AssociationSetMapping Name=\"TableConstraintColumns\" StoreEntitySet=\"SConstraintColumns\" TypeName=\"Store.TableOrViewConstraintColumn\">\n      <cs:EndProperty Name=\"Constraint\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"ConstraintId\" />\n      </cs:EndProperty>\n      <cs:EndProperty Name=\"Column\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"ColumnId\" />\n      </cs:EndProperty>\n    </cs:AssociationSetMapping>\n\n    <cs:AssociationSetMapping Name=\"TableConstraintForeignKeys\" StoreEntitySet=\"SForeignKeys\" TypeName=\"Store.ConstraintForeignKey\">\n      <cs:EndProperty Name=\"Constraint\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"ConstraintId\" />\n      </cs:EndProperty>\n      <cs:EndProperty Name=\"ForeignKey\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </cs:EndProperty>\n    </cs:AssociationSetMapping>\n\n    <cs:AssociationSetMapping Name=\"ToTableForeignKeyColumns\" StoreEntitySet=\"SForeignKeys\" TypeName=\"Store.ToForeignKeyColumn\">\n      <cs:EndProperty Name=\"ForeignKey\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </cs:EndProperty>\n      <cs:EndProperty Name=\"Column\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"ToColumnId\" />\n      </cs:EndProperty>\n    </cs:AssociationSetMapping>\n\n    <cs:AssociationSetMapping Name=\"FromTableForeignKeyColumns\" StoreEntitySet=\"SForeignKeys\" TypeName=\"Store.FromForeignKeyColumn\">\n      <cs:EndProperty Name=\"ForeignKey\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </cs:EndProperty>\n      <cs:EndProperty Name=\"Column\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"FromColumnId\" />\n      </cs:EndProperty>\n    </cs:AssociationSetMapping>\n\n    <cs:AssociationSetMapping Name=\"ViewViewConstraints\" StoreEntitySet=\"SViewConstraints\" TypeName=\"Store.TableOrViewConstraint\">\n      <cs:EndProperty Name=\"Parent\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"ParentId\" />\n      </cs:EndProperty>\n      <cs:EndProperty Name=\"Constraint\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </cs:EndProperty>\n    </cs:AssociationSetMapping>\n\n    <cs:AssociationSetMapping Name=\"ViewConstraintColumns\" StoreEntitySet=\"SViewConstraintColumns\" TypeName=\"Store.TableOrViewConstraintColumn\">\n      <cs:EndProperty Name=\"Constraint\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"ConstraintId\" />\n      </cs:EndProperty>\n      <cs:EndProperty Name=\"Column\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"ColumnId\" />\n      </cs:EndProperty>\n    </cs:AssociationSetMapping>\n\n    <cs:AssociationSetMapping Name=\"ViewConstraintForeignKeys\" StoreEntitySet=\"SViewForeignKeys\" TypeName=\"Store.ConstraintForeignKey\">\n      <cs:EndProperty Name=\"Constraint\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"ConstraintId\" />\n      </cs:EndProperty>\n      <cs:EndProperty Name=\"ForeignKey\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </cs:EndProperty>\n    </cs:AssociationSetMapping>\n\n    <cs:AssociationSetMapping Name=\"ToViewForeignKeyColumns\" StoreEntitySet=\"SViewForeignKeys\" TypeName=\"Store.ToForeignKeyColumn\">\n      <cs:EndProperty Name=\"ForeignKey\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </cs:EndProperty>\n      <cs:EndProperty Name=\"Column\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"ToColumnId\" />\n      </cs:EndProperty>\n    </cs:AssociationSetMapping>\n\n    <cs:AssociationSetMapping Name=\"FromViewForeignKeyColumns\" StoreEntitySet=\"SViewForeignKeys\" TypeName=\"Store.FromForeignKeyColumn\">\n      <cs:EndProperty Name=\"ForeignKey\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </cs:EndProperty>\n      <cs:EndProperty Name=\"Column\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"FromColumnId\" />\n      </cs:EndProperty>\n    </cs:AssociationSetMapping>\n\n    <cs:AssociationSetMapping Name=\"FunctionFunctionParameters\" StoreEntitySet=\"SFunctionParameters\" TypeName=\"Store.RoutineParameter\">\n      <cs:EndProperty Name=\"Routine\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"ParentId\" />\n      </cs:EndProperty>\n      <cs:EndProperty Name=\"Parameter\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </cs:EndProperty>\n    </cs:AssociationSetMapping>\n\n    <cs:AssociationSetMapping Name=\"ProcedureProcedureParameters\" StoreEntitySet=\"SProcedureParameters\" TypeName=\"Store.RoutineParameter\">\n      <cs:EndProperty Name=\"Routine\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"ParentId\" />\n      </cs:EndProperty>\n      <cs:EndProperty Name=\"Parameter\">\n        <cs:ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </cs:EndProperty>\n    </cs:AssociationSetMapping>\n\n  </cs:EntityContainerMapping>\n\n</Mapping>"
  },
  {
    "path": "src/EntityFramework.Firebird/Resources/StoreSchemaMappingVersion3.msl",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Mapping Space=\"C-S\" xmlns=\"urn:schemas-microsoft-com:windows:storage:mapping:CS\">\n  <EntityContainerMapping StorageEntityContainer=\"Schema\" CdmEntityContainer=\"SchemaInformation\">\n\n    <EntitySetMapping Name=\"Tables\" StoreEntitySet=\"STables\" TypeName=\"Store.Table\">\n      <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <ScalarProperty Name=\"CatalogName\" ColumnName=\"CatalogName\" />\n      <ScalarProperty Name=\"SchemaName\" ColumnName=\"SchemaName\" />\n      <ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n    </EntitySetMapping>\n\n    <EntitySetMapping Name=\"TableColumns\" StoreEntitySet=\"STableColumns\" TypeName=\"Store.Column\">\n      <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n      <ScalarProperty Name=\"Ordinal\" ColumnName=\"Ordinal\" />\n      <ScalarProperty Name=\"IsNullable\" ColumnName=\"IsNullable\" />\n      <ComplexProperty Name=\"ColumnType\">\n        <ScalarProperty Name=\"TypeName\" ColumnName=\"TypeName\" />\n        <ScalarProperty Name=\"MaxLength\" ColumnName=\"MaxLength\" />\n        <ScalarProperty Name=\"DateTimePrecision\" ColumnName=\"DateTimePrecision\" />\n        <ScalarProperty Name=\"Precision\" ColumnName=\"Precision\" />\n        <ScalarProperty Name=\"Scale\" ColumnName=\"Scale\" />\n        <ComplexProperty Name=\"Collation\">\n          <ScalarProperty Name=\"CatalogName\" ColumnName=\"CollationCatalog\" />\n          <ScalarProperty Name=\"SchemaName\" ColumnName=\"CollationSchema\" />\n          <ScalarProperty Name=\"Name\" ColumnName=\"CollationName\" />\n        </ComplexProperty>\n        <ComplexProperty Name=\"CharacterSet\">\n          <ScalarProperty Name=\"CatalogName\" ColumnName=\"CharacterSetCatalog\" />\n          <ScalarProperty Name=\"SchemaName\" ColumnName=\"CharacterSetSchema\" />\n          <ScalarProperty Name=\"Name\" ColumnName=\"CharacterSetName\" />\n        </ComplexProperty>\n        <ScalarProperty Name=\"IsMultiSet\" ColumnName=\"IsMultiSet\" />\n      </ComplexProperty>\n      <ScalarProperty Name=\"IsIdentity\" ColumnName=\"IsIdentity\" />\n      <ScalarProperty Name=\"IsStoreGenerated\" ColumnName=\"IsStoreGenerated\" />\n      <ScalarProperty Name=\"Default\" ColumnName=\"Default\" />\n    </EntitySetMapping>\n\n    <EntitySetMapping Name=\"Views\" StoreEntitySet=\"SViews\" TypeName=\"Store.View\">\n      <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <ScalarProperty Name=\"CatalogName\" ColumnName=\"CatalogName\" />\n      <ScalarProperty Name=\"SchemaName\" ColumnName=\"SchemaName\" />\n      <ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n      <ScalarProperty Name=\"ViewDefinition\" ColumnName=\"ViewDefinition\" />\n      <ScalarProperty Name=\"IsUpdatable\" ColumnName=\"IsUpdatable\" />\n    </EntitySetMapping>\n\n    <EntitySetMapping Name=\"ViewColumns\" StoreEntitySet=\"SViewColumns\" TypeName=\"Store.Column\">\n      <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n      <ScalarProperty Name=\"Ordinal\" ColumnName=\"Ordinal\" />\n      <ScalarProperty Name=\"IsNullable\" ColumnName=\"IsNullable\" />\n      <ComplexProperty Name=\"ColumnType\">\n        <ScalarProperty Name=\"TypeName\" ColumnName=\"TypeName\" />\n        <ScalarProperty Name=\"MaxLength\" ColumnName=\"MaxLength\" />\n        <ScalarProperty Name=\"Precision\" ColumnName=\"Precision\" />\n        <ScalarProperty Name=\"DateTimePrecision\" ColumnName=\"DateTimePrecision\" />\n        <ScalarProperty Name=\"Scale\" ColumnName=\"Scale\" />\n        <ComplexProperty Name=\"Collation\">\n          <ScalarProperty Name=\"CatalogName\" ColumnName=\"CollationCatalog\" />\n          <ScalarProperty Name=\"SchemaName\" ColumnName=\"CollationSchema\" />\n          <ScalarProperty Name=\"Name\" ColumnName=\"CollationName\" />\n        </ComplexProperty>\n        <ComplexProperty Name=\"CharacterSet\">\n          <ScalarProperty Name=\"CatalogName\" ColumnName=\"CharacterSetCatalog\" />\n          <ScalarProperty Name=\"SchemaName\" ColumnName=\"CharacterSetSchema\" />\n          <ScalarProperty Name=\"Name\" ColumnName=\"CharacterSetName\" />\n        </ComplexProperty>\n        <ScalarProperty Name=\"IsMultiSet\" ColumnName=\"IsMultiSet\" />\n      </ComplexProperty>\n      <ScalarProperty Name=\"IsIdentity\" ColumnName=\"IsIdentity\" />\n      <ScalarProperty Name=\"IsStoreGenerated\" ColumnName=\"IsStoreGenerated\" />\n      <ScalarProperty Name=\"Default\" ColumnName=\"Default\" />\n    </EntitySetMapping>\n\n    <EntitySetMapping Name=\"Functions\" >\n      <EntityTypeMapping TypeName=\"IsTypeOf(Store.Function)\">\n        <MappingFragment StoreEntitySet=\"SFunctions\">\n          <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <ScalarProperty Name=\"CatalogName\" ColumnName=\"CatalogName\" />\n          <ScalarProperty Name=\"SchemaName\" ColumnName=\"SchemaName\" />\n          <ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n          <ScalarProperty Name=\"IsBuiltIn\" ColumnName=\"IsBuiltIn\" />\n          <ScalarProperty Name=\"IsNiladic\" ColumnName=\"IsNiladic\" />\n        </MappingFragment>\n      </EntityTypeMapping>\n      <EntityTypeMapping TypeName=\"Store.ScalarFunction\">\n        <MappingFragment StoreEntitySet=\"SFunctions\">\n          <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <ScalarProperty Name=\"IsAggregate\" ColumnName=\"IsAggregate\" />\n          <ComplexProperty Name=\"ReturnType\">\n            <ScalarProperty Name=\"TypeName\" ColumnName=\"ReturnTypeName\" />\n            <ScalarProperty Name=\"MaxLength\" ColumnName=\"ReturnMaxLength\" />\n            <ScalarProperty Name=\"Precision\" ColumnName=\"ReturnPrecision\" />\n            <ScalarProperty Name=\"DateTimePrecision\" ColumnName=\"ReturnDateTimePrecision\" />\n            <ScalarProperty Name=\"Scale\" ColumnName=\"ReturnScale\" />\n            <ComplexProperty Name=\"Collation\">\n              <ScalarProperty Name=\"CatalogName\" ColumnName=\"ReturnCollationCatalog\" />\n              <ScalarProperty Name=\"SchemaName\" ColumnName=\"ReturnCollationSchema\" />\n              <ScalarProperty Name=\"Name\" ColumnName=\"ReturnCollationName\" />\n            </ComplexProperty>\n            <ComplexProperty Name=\"CharacterSet\">\n              <ScalarProperty Name=\"CatalogName\" ColumnName=\"ReturnCharacterSetCatalog\" />\n              <ScalarProperty Name=\"SchemaName\" ColumnName=\"ReturnCharacterSetSchema\" />\n              <ScalarProperty Name=\"Name\" ColumnName=\"ReturnCharacterSetName\" />\n            </ComplexProperty>\n            <ScalarProperty Name=\"IsMultiSet\" ColumnName=\"ReturnIsMultiSet\" />\n          </ComplexProperty>\n          <Condition ColumnName=\"IsTvf\" Value=\"false\"/>\n        </MappingFragment>\n      </EntityTypeMapping>\n      <EntityTypeMapping TypeName=\"Store.TableValuedFunction\">\n        <MappingFragment StoreEntitySet=\"SFunctions\">\n          <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <Condition ColumnName=\"IsTvf\" Value=\"true\"/>\n        </MappingFragment>\n      </EntityTypeMapping>\n    </EntitySetMapping>\n\n    <EntitySetMapping Name=\"FunctionParameters\" TypeName=\"Store.Parameter\" StoreEntitySet=\"SFunctionParameters\">\n      <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n      <ScalarProperty Name=\"Ordinal\" ColumnName=\"Ordinal\" />\n      <ComplexProperty Name=\"ParameterType\">\n        <ScalarProperty Name=\"TypeName\" ColumnName=\"TypeName\" />\n        <ScalarProperty Name=\"MaxLength\" ColumnName=\"MaxLength\" />\n        <ScalarProperty Name=\"DateTimePrecision\" ColumnName=\"DateTimePrecision\" />\n        <ScalarProperty Name=\"Precision\" ColumnName=\"Precision\" />\n        <ScalarProperty Name=\"Scale\" ColumnName=\"Scale\" />\n        <ComplexProperty Name=\"Collation\">\n          <ScalarProperty Name=\"CatalogName\" ColumnName=\"CollationCatalog\" />\n          <ScalarProperty Name=\"SchemaName\" ColumnName=\"CollationSchema\" />\n          <ScalarProperty Name=\"Name\" ColumnName=\"CollationName\" />\n        </ComplexProperty>\n        <ComplexProperty Name=\"CharacterSet\">\n          <ScalarProperty Name=\"CatalogName\" ColumnName=\"CharacterSetCatalog\" />\n          <ScalarProperty Name=\"SchemaName\" ColumnName=\"CharacterSetSchema\" />\n          <ScalarProperty Name=\"Name\" ColumnName=\"CharacterSetName\" />\n        </ComplexProperty>\n        <ScalarProperty Name=\"IsMultiSet\" ColumnName=\"IsMultiSet\" />\n      </ComplexProperty>\n      <ScalarProperty Name=\"Mode\" ColumnName=\"Mode\" />\n      <ScalarProperty Name=\"Default\" ColumnName=\"Default\" />\n    </EntitySetMapping>\n\n    <EntitySetMapping Name=\"FunctionReturnTableColumns\" StoreEntitySet=\"SFunctionReturnTableColumns\" TypeName=\"Store.FunctionReturnTableColumn\">\n      <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n      <ScalarProperty Name=\"Ordinal\" ColumnName=\"Ordinal\" />\n      <ScalarProperty Name=\"IsNullable\" ColumnName=\"IsNullable\" />\n      <ComplexProperty Name=\"ColumnType\">\n        <ScalarProperty Name=\"TypeName\" ColumnName=\"TypeName\" />\n        <ScalarProperty Name=\"MaxLength\" ColumnName=\"MaxLength\" />\n        <ScalarProperty Name=\"DateTimePrecision\" ColumnName=\"DateTimePrecision\" />\n        <ScalarProperty Name=\"Precision\" ColumnName=\"Precision\" />\n        <ScalarProperty Name=\"Scale\" ColumnName=\"Scale\" />\n        <ComplexProperty Name=\"Collation\">\n          <ScalarProperty Name=\"CatalogName\" ColumnName=\"CollationCatalog\" />\n          <ScalarProperty Name=\"SchemaName\" ColumnName=\"CollationSchema\" />\n          <ScalarProperty Name=\"Name\" ColumnName=\"CollationName\" />\n        </ComplexProperty>\n        <ComplexProperty Name=\"CharacterSet\">\n          <ScalarProperty Name=\"CatalogName\" ColumnName=\"CharacterSetCatalog\" />\n          <ScalarProperty Name=\"SchemaName\" ColumnName=\"CharacterSetSchema\" />\n          <ScalarProperty Name=\"Name\" ColumnName=\"CharacterSetName\" />\n        </ComplexProperty>\n        <ScalarProperty Name=\"IsMultiSet\" ColumnName=\"IsMultiSet\" />\n      </ComplexProperty>\n      <ScalarProperty Name=\"IsIdentity\" ColumnName=\"IsIdentity\" />\n      <ScalarProperty Name=\"IsStoreGenerated\" ColumnName=\"IsStoreGenerated\" />\n      <ScalarProperty Name=\"Default\" ColumnName=\"Default\" />\n    </EntitySetMapping>\n\n    <EntitySetMapping Name=\"Procedures\" TypeName=\"Store.Procedure\" StoreEntitySet=\"SProcedures\">\n      <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <ScalarProperty Name=\"CatalogName\" ColumnName=\"CatalogName\" />\n      <ScalarProperty Name=\"SchemaName\" ColumnName=\"SchemaName\" />\n      <ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n    </EntitySetMapping>\n\n    <EntitySetMapping Name=\"ProcedureParameters\" TypeName=\"Store.Parameter\" StoreEntitySet=\"SProcedureParameters\">\n      <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n      <ScalarProperty Name=\"Ordinal\" ColumnName=\"Ordinal\" />\n      <ComplexProperty Name=\"ParameterType\">\n        <ScalarProperty Name=\"TypeName\" ColumnName=\"TypeName\" />\n        <ScalarProperty Name=\"MaxLength\" ColumnName=\"MaxLength\" />\n        <ScalarProperty Name=\"DateTimePrecision\" ColumnName=\"DateTimePrecision\" />\n        <ScalarProperty Name=\"Precision\" ColumnName=\"Precision\" />\n        <ScalarProperty Name=\"Scale\" ColumnName=\"Scale\" />\n        <ComplexProperty Name=\"Collation\">\n          <ScalarProperty Name=\"CatalogName\" ColumnName=\"CollationCatalog\" />\n          <ScalarProperty Name=\"SchemaName\" ColumnName=\"CollationSchema\" />\n          <ScalarProperty Name=\"Name\" ColumnName=\"CollationName\" />\n        </ComplexProperty>\n        <ComplexProperty Name=\"CharacterSet\">\n          <ScalarProperty Name=\"CatalogName\" ColumnName=\"CharacterSetCatalog\" />\n          <ScalarProperty Name=\"SchemaName\" ColumnName=\"CharacterSetSchema\" />\n          <ScalarProperty Name=\"Name\" ColumnName=\"CharacterSetName\" />\n        </ComplexProperty>\n        <ScalarProperty Name=\"IsMultiSet\" ColumnName=\"IsMultiSet\" />\n      </ComplexProperty>\n      <ScalarProperty Name=\"Mode\" ColumnName=\"Mode\" />\n      <ScalarProperty Name=\"Default\" ColumnName=\"Default\" />\n    </EntitySetMapping>\n\n    <EntitySetMapping Name=\"TableConstraints\" >\n      <EntityTypeMapping TypeName=\"IsTypeOf(Store.Constraint)\">\n        <MappingFragment StoreEntitySet=\"SConstraints\">\n          <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n          <ScalarProperty Name=\"IsDeferrable\" ColumnName=\"IsDeferrable\" />\n          <ScalarProperty Name=\"IsInitiallyDeferred\" ColumnName=\"IsInitiallyDeferred\" />\n        </MappingFragment>\n      </EntityTypeMapping>\n      <EntityTypeMapping TypeName=\"Store.UniqueConstraint\">\n          <MappingFragment StoreEntitySet=\"SConstraints\">\n          <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <Condition ColumnName=\"ConstraintType\" Value=\"UNIQUE\"/>\n        </MappingFragment>\n      </EntityTypeMapping>\n      <EntityTypeMapping TypeName=\"Store.CheckConstraint\">\n        <MappingFragment StoreEntitySet=\"SConstraints\">\n          <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <Condition ColumnName=\"ConstraintType\" Value=\"CHECK\"/>\n        </MappingFragment>\n        <MappingFragment StoreEntitySet=\"SCheckConstraints\">\n          <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <ScalarProperty Name=\"Expression\" ColumnName=\"Expression\" />\n        </MappingFragment>\n      </EntityTypeMapping>\n      <EntityTypeMapping TypeName=\"Store.PrimaryKeyConstraint\">\n        <MappingFragment StoreEntitySet=\"SConstraints\">\n          <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <Condition ColumnName=\"ConstraintType\" Value=\"PRIMARY KEY\"/>\n        </MappingFragment>\n      </EntityTypeMapping>\n      <EntityTypeMapping TypeName=\"Store.ForeignKeyConstraint\">\n        <MappingFragment StoreEntitySet=\"SConstraints\">\n          <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <Condition ColumnName=\"ConstraintType\" Value=\"FOREIGN KEY\"/>\n        </MappingFragment>\n        <MappingFragment StoreEntitySet=\"SForeignKeyConstraints\">\n          <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <ScalarProperty Name=\"UpdateRule\" ColumnName=\"UpdateRule\" />\n          <ScalarProperty Name=\"DeleteRule\" ColumnName=\"DeleteRule\" />\n        </MappingFragment>\n      </EntityTypeMapping>\n    </EntitySetMapping>\n\n    <EntitySetMapping Name=\"ViewConstraints\" >\n      <EntityTypeMapping TypeName=\"Store.UniqueConstraint\" >\n        <MappingFragment StoreEntitySet=\"SViewConstraints\">\n          <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n          <ScalarProperty Name=\"IsDeferrable\" ColumnName=\"IsDeferrable\" />\n          <ScalarProperty Name=\"IsInitiallyDeferred\" ColumnName=\"IsInitiallyDeferred\" />\n          <Condition ColumnName=\"ConstraintType\" Value=\"UNIQUE\"/>\n        </MappingFragment>\n      </EntityTypeMapping>\n      <EntityTypeMapping TypeName=\"Store.CheckConstraint\" >\n        <MappingFragment StoreEntitySet=\"SViewConstraints\">\n          <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n          <ScalarProperty Name=\"IsDeferrable\" ColumnName=\"IsDeferrable\" />\n          <ScalarProperty Name=\"IsInitiallyDeferred\" ColumnName=\"IsInitiallyDeferred\" />\n          <ScalarProperty Name=\"Expression\" ColumnName=\"Expression\" />\n          <Condition ColumnName=\"ConstraintType\" Value=\"CHECK\"/>\n        </MappingFragment>\n      </EntityTypeMapping>\n      <EntityTypeMapping TypeName=\"Store.PrimaryKeyConstraint\" >\n        <MappingFragment StoreEntitySet=\"SViewConstraints\">\n          <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n          <ScalarProperty Name=\"IsDeferrable\" ColumnName=\"IsDeferrable\" />\n          <ScalarProperty Name=\"IsInitiallyDeferred\" ColumnName=\"IsInitiallyDeferred\" />\n          <Condition ColumnName=\"ConstraintType\" Value=\"PRIMARY KEY\"/>\n        </MappingFragment>\n      </EntityTypeMapping>\n      <EntityTypeMapping TypeName=\"Store.ForeignKeyConstraint\" >\n        <MappingFragment StoreEntitySet=\"SViewConstraints\">\n          <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n          <ScalarProperty Name=\"Name\" ColumnName=\"Name\" />\n          <ScalarProperty Name=\"IsDeferrable\" ColumnName=\"IsDeferrable\" />\n          <ScalarProperty Name=\"IsInitiallyDeferred\" ColumnName=\"IsInitiallyDeferred\" />\n          <ScalarProperty Name=\"UpdateRule\" ColumnName=\"UpdateRule\" />\n          <ScalarProperty Name=\"DeleteRule\" ColumnName=\"DeleteRule\" />\n          <Condition ColumnName=\"ConstraintType\" Value=\"FOREIGN KEY\"/>\n        </MappingFragment>\n      </EntityTypeMapping>\n    </EntitySetMapping>\n\n    <EntitySetMapping Name=\"TableForeignKeys\" StoreEntitySet=\"SForeignKeys\" TypeName=\"Store.ForeignKey\">\n      <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <ScalarProperty Name=\"Ordinal\" ColumnName=\"Ordinal\" />\n    </EntitySetMapping>\n\n    <EntitySetMapping Name=\"ViewForeignKeys\" StoreEntitySet=\"SViewForeignKeys\" TypeName=\"Store.ForeignKey\">\n      <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      <ScalarProperty Name=\"Ordinal\" ColumnName=\"Ordinal\" />\n    </EntitySetMapping>\n    \n    <AssociationSetMapping Name=\"TableTableColumns\" StoreEntitySet=\"STableColumns\" TypeName=\"Store.TableOrViewColumn\">\n      <EndProperty Name=\"Parent\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"ParentId\" />\n      </EndProperty>\n      <EndProperty Name=\"Column\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </EndProperty>\n      <!--Condition ColumnName=\"ParentId\" IsNull=\"false\"/-->\n    </AssociationSetMapping>\n\n    <AssociationSetMapping Name=\"ViewViewColumns\" StoreEntitySet=\"SViewColumns\" TypeName=\"Store.TableOrViewColumn\">\n      <EndProperty Name=\"Parent\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"ParentId\" />\n      </EndProperty>\n      <EndProperty Name=\"Column\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </EndProperty>\n    </AssociationSetMapping>\n\n    <AssociationSetMapping Name=\"TableTableConstraints\" StoreEntitySet=\"SConstraints\" TypeName=\"Store.TableOrViewConstraint\">\n      <EndProperty Name=\"Parent\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"ParentId\" />\n      </EndProperty>\n      <EndProperty Name=\"Constraint\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </EndProperty>\n    </AssociationSetMapping>\n\n    <AssociationSetMapping Name=\"TableConstraintColumns\" StoreEntitySet=\"SConstraintColumns\" TypeName=\"Store.TableOrViewConstraintColumn\">\n      <EndProperty Name=\"Constraint\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"ConstraintId\" />\n      </EndProperty>\n      <EndProperty Name=\"Column\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"ColumnId\" />\n      </EndProperty>\n    </AssociationSetMapping>\n\n    <AssociationSetMapping Name=\"TableConstraintForeignKeys\" StoreEntitySet=\"SForeignKeys\" TypeName=\"Store.ConstraintForeignKey\">\n      <EndProperty Name=\"Constraint\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"ConstraintId\" />\n      </EndProperty>\n      <EndProperty Name=\"ForeignKey\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </EndProperty>\n    </AssociationSetMapping>\n\n    <AssociationSetMapping Name=\"ToTableForeignKeyColumns\" StoreEntitySet=\"SForeignKeys\" TypeName=\"Store.ToForeignKeyColumn\">\n      <EndProperty Name=\"ForeignKey\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </EndProperty>\n      <EndProperty Name=\"Column\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"ToColumnId\" />\n      </EndProperty>\n    </AssociationSetMapping>\n\n    <AssociationSetMapping Name=\"FromTableForeignKeyColumns\" StoreEntitySet=\"SForeignKeys\" TypeName=\"Store.FromForeignKeyColumn\">\n      <EndProperty Name=\"ForeignKey\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </EndProperty>\n      <EndProperty Name=\"Column\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"FromColumnId\" />\n      </EndProperty>\n    </AssociationSetMapping>\n\n    <AssociationSetMapping Name=\"ViewViewConstraints\" StoreEntitySet=\"SViewConstraints\" TypeName=\"Store.TableOrViewConstraint\">\n      <EndProperty Name=\"Parent\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"ParentId\" />\n      </EndProperty>\n      <EndProperty Name=\"Constraint\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </EndProperty>\n    </AssociationSetMapping>\n\n    <AssociationSetMapping Name=\"ViewConstraintColumns\" StoreEntitySet=\"SViewConstraintColumns\" TypeName=\"Store.TableOrViewConstraintColumn\">\n      <EndProperty Name=\"Constraint\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"ConstraintId\" />\n      </EndProperty>\n      <EndProperty Name=\"Column\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"ColumnId\" />\n      </EndProperty>\n    </AssociationSetMapping>\n\n    <AssociationSetMapping Name=\"ViewConstraintForeignKeys\" StoreEntitySet=\"SViewForeignKeys\" TypeName=\"Store.ConstraintForeignKey\">\n      <EndProperty Name=\"Constraint\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"ConstraintId\" />\n      </EndProperty>\n      <EndProperty Name=\"ForeignKey\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </EndProperty>\n    </AssociationSetMapping>\n\n    <AssociationSetMapping Name=\"ToViewForeignKeyColumns\" StoreEntitySet=\"SViewForeignKeys\" TypeName=\"Store.ToForeignKeyColumn\">\n      <EndProperty Name=\"ForeignKey\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </EndProperty>\n      <EndProperty Name=\"Column\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"ToColumnId\" />\n      </EndProperty>\n    </AssociationSetMapping>\n\n    <AssociationSetMapping Name=\"FromViewForeignKeyColumns\" StoreEntitySet=\"SViewForeignKeys\" TypeName=\"Store.FromForeignKeyColumn\">\n      <EndProperty Name=\"ForeignKey\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </EndProperty>\n      <EndProperty Name=\"Column\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"FromColumnId\" />\n      </EndProperty>\n    </AssociationSetMapping>\n\n    <AssociationSetMapping Name=\"FunctionFunctionParameters\" StoreEntitySet=\"SFunctionParameters\" TypeName=\"Store.RoutineParameter\">\n      <EndProperty Name=\"Routine\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"ParentId\" />\n      </EndProperty>\n      <EndProperty Name=\"Parameter\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </EndProperty>\n    </AssociationSetMapping>\n\n    <AssociationSetMapping Name=\"FunctionFunctionReturnTableColumns\" StoreEntitySet=\"SFunctionReturnTableColumns\" TypeName=\"Store.FunctionFunctionReturnTableColumn\">\n      <EndProperty Name=\"Function\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"ParentId\" />\n      </EndProperty>\n      <EndProperty Name=\"Column\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </EndProperty>\n    </AssociationSetMapping>\n\n    <AssociationSetMapping Name=\"ProcedureProcedureParameters\" StoreEntitySet=\"SProcedureParameters\" TypeName=\"Store.RoutineParameter\">\n      <EndProperty Name=\"Routine\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"ParentId\" />\n      </EndProperty>\n      <EndProperty Name=\"Parameter\">\n        <ScalarProperty Name=\"Id\" ColumnName=\"Id\" />\n      </EndProperty>\n    </AssociationSetMapping>\n\n  </EntityContainerMapping>\n\n</Mapping>"
  },
  {
    "path": "src/EntityFramework.Firebird/SqlGen/DmlSqlGenerator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Data.Common;\nusing System.Data.Entity.Core.Common.CommandTrees;\nusing System.Data.Entity.Core.Metadata.Edm;\nusing System.Linq;\nusing System.Text;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace EntityFramework.Firebird.SqlGen;\n\ninternal static class DmlSqlGenerator\n{\n\t#region Static Fields\n\n\tprivate const int CommandTextBuilderInitialCapacity = 256;\n\n\t#endregion\n\n\t#region Static Methods\n\n\tinternal static string GenerateUpdateSql(DbUpdateCommandTree tree, out List<DbParameter> parameters, bool generateParameters = true)\n\t{\n\t\tvar commandText = new StringBuilder(CommandTextBuilderInitialCapacity);\n\t\tvar translator = new ExpressionTranslator(commandText, tree, null != tree.Returning, generateParameters);\n\t\tvar first = true;\n\n\t\tcommandText.Append(\"UPDATE \");\n\t\ttree.Target.Expression.Accept(translator);\n\t\tcommandText.AppendLine();\n\n\t\t// set c1 = ..., c2 = ..., ...\n\t\tcommandText.Append(\"SET \");\n\n\t\tforeach (DbSetClause setClause in tree.SetClauses)\n\t\t{\n\t\t\tif (first)\n\t\t\t{\n\t\t\t\tfirst = false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcommandText.Append(\", \");\n\t\t\t}\n\n\t\t\tsetClause.Property.Accept(translator);\n\t\t\tcommandText.Append(\" = \");\n\t\t\tsetClause.Value.Accept(translator);\n\n\t\t\ttranslator.RegisterMemberValue(setClause.Property, setClause.Value);\n\t\t}\n\n\t\tif (first)\n\t\t{\n\t\t\t// If first is still true, it indicates there were no set\n\t\t\t// clauses. Introduce a fake set clause so that:\n\t\t\t// - we acquire the appropriate locks\n\t\t\t// - server-gen columns (e.g. timestamp) get recomputed\n\n\t\t\tvar table = ((DbScanExpression)tree.Target.Expression).Target;\n\t\t\t// hope this column isn't indexed to not waste power\n\t\t\tvar someColumn = table.ElementType.Members.Last(x => !MetadataHelpers.IsStoreGenerated(x));\n\t\t\tcommandText.AppendFormat(\"{0} = {0}\", GenerateMemberSql(someColumn));\n\t\t}\n\t\tcommandText.AppendLine();\n\n\t\t// where c1 = ..., c2 = ...\n\t\tcommandText.Append(\"WHERE \");\n\t\ttree.Predicate.Accept(translator);\n\t\tcommandText.AppendLine();\n\n\t\t// generate returning sql\n\t\tGenerateReturningSql(commandText, tree, translator, tree.Returning);\n\n\t\tparameters = translator.Parameters;\n\t\treturn commandText.ToString();\n\t}\n\n\tinternal static string GenerateDeleteSql(DbDeleteCommandTree tree, out List<DbParameter> parameters, bool generateParameters = true)\n\t{\n\t\tvar commandText = new StringBuilder(CommandTextBuilderInitialCapacity);\n\t\tvar translator = new ExpressionTranslator(commandText, tree, false, generateParameters);\n\n\t\tcommandText.Append(\"DELETE FROM \");\n\t\ttree.Target.Expression.Accept(translator);\n\t\tcommandText.AppendLine();\n\n\t\t// where c1 = ... AND c2 = ...\n\t\tcommandText.Append(\"WHERE \");\n\t\ttree.Predicate.Accept(translator);\n\n\t\tparameters = translator.Parameters;\n\t\treturn commandText.ToString();\n\t}\n\n\tinternal static string GenerateInsertSql(DbInsertCommandTree tree, out List<DbParameter> parameters, bool generateParameters = true)\n\t{\n\t\tvar commandText = new StringBuilder(CommandTextBuilderInitialCapacity);\n\t\tvar translator = new ExpressionTranslator(commandText, tree, null != tree.Returning, generateParameters);\n\t\tvar first = true;\n\n\t\tcommandText.Append(\"INSERT INTO \");\n\t\ttree.Target.Expression.Accept(translator);\n\n\t\tif (tree.SetClauses.Any())\n\t\t{\n\t\t\t// (c1, c2, c3, ...)\n\t\t\tcommandText.Append(\"(\");\n\n\t\t\tforeach (DbSetClause setClause in tree.SetClauses)\n\t\t\t{\n\t\t\t\tif (first)\n\t\t\t\t{\n\t\t\t\t\tfirst = false;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcommandText.Append(\", \");\n\t\t\t\t}\n\t\t\t\tsetClause.Property.Accept(translator);\n\t\t\t}\n\t\t\tcommandText.AppendLine(\")\");\n\n\t\t\t// values c1, c2, ...\n\t\t\tfirst = true;\n\t\t\tcommandText.Append(\"VALUES (\");\n\t\t\tforeach (DbSetClause setClause in tree.SetClauses)\n\t\t\t{\n\t\t\t\tif (first)\n\t\t\t\t{\n\t\t\t\t\tfirst = false;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcommandText.Append(\", \");\n\t\t\t\t}\n\n\t\t\t\tsetClause.Value.Accept(translator);\n\n\t\t\t\ttranslator.RegisterMemberValue(setClause.Property, setClause.Value);\n\t\t\t}\n\t\t\tcommandText.AppendLine(\")\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcommandText.AppendLine(\"DEFAULT VALUES\");\n\t\t}\n\t\t// generate returning sql\n\t\tGenerateReturningSql(commandText, tree, translator, tree.Returning);\n\n\t\tparameters = translator.Parameters;\n\t\treturn commandText.ToString();\n\t}\n\n\t// Generates SQL describing a member\n\t// Requires: member must belong to an entity type (a safe requirement for DML\n\t// SQL gen, where we only access table columns)\n\tinternal static string GenerateMemberSql(EdmMember member)\n\t{\n\t\treturn SqlGenerator.QuoteIdentifier(member.Name);\n\t}\n\n\tprivate static void GenerateReturningSql(\n\t\tStringBuilder commandText,\n\t\tDbModificationCommandTree tree,\n\t\tExpressionTranslator translator,\n\t\tDbExpression returning)\n\t{\n\t\t// Nothing to do if there is no Returning expression\n\t\tif (returning == null)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tvar table = ((DbScanExpression)tree.Target.Expression).Target;\n\t\tvar columnsToFetch =\n\t\t\ttable.ElementType.Members\n\t\t\t\t.Where(m => MetadataHelpers.IsStoreGenerated(m))\n\t\t\t\t.Except((!(tree is DbInsertCommandTree) ? table.ElementType.KeyMembers : Enumerable.Empty<EdmMember>()));\n\n\t\tvar startBlock = new StringBuilder();\n\t\tvar separator = string.Empty;\n\n\t\tstartBlock.Append(\"EXECUTE BLOCK \");\n\t\tif (translator.Parameters.Any())\n\t\t{\n\t\t\tstartBlock.AppendLine(\"(\");\n\t\t\tseparator = string.Empty;\n\t\t\tforeach (FbParameter param in translator.Parameters)\n\t\t\t{\n\t\t\t\tstartBlock.Append(separator);\n\t\t\t\tstartBlock.Append(param.ParameterName.Replace(\"@\", string.Empty));\n\t\t\t\tstartBlock.Append(\" \");\n\t\t\t\tvar member = translator.MemberValues.First(m => m.Value.Contains(param)).Key;\n\t\t\t\tstartBlock.Append(SqlGenerator.GetSqlPrimitiveType(member.TypeUsage));\n\t\t\t\tif (param.FbDbType == FbDbType.VarChar || param.FbDbType == FbDbType.Char)\n\t\t\t\t\tstartBlock.Append(\" CHARACTER SET UTF8\");\n\t\t\t\tstartBlock.Append(\" = \");\n\t\t\t\tstartBlock.Append(param.ParameterName);\n\n\t\t\t\tseparator = \", \";\n\t\t\t}\n\t\t\tstartBlock.AppendLine();\n\t\t\tstartBlock.Append(\") \");\n\t\t}\n\n\t\tstartBlock.AppendLine(\"RETURNS (\");\n\t\tseparator = string.Empty;\n\t\tforeach (var m in columnsToFetch)\n\t\t{\n\t\t\tstartBlock.Append(separator);\n\t\t\tstartBlock.Append(GenerateMemberSql(m));\n\t\t\tstartBlock.Append(\" \");\n\t\t\tstartBlock.Append(SqlGenerator.GetSqlPrimitiveType(m.TypeUsage));\n\n\t\t\tseparator = \", \";\n\t\t}\n\t\tstartBlock.AppendLine(\")\");\n\t\tstartBlock.AppendLine(\"AS BEGIN\");\n\n\t\tvar newCommand = ChangeParamsToPSQLParams(commandText.ToString(), translator.Parameters.Select(p => p.ParameterName).ToArray());\n\t\tcommandText.Remove(0, commandText.Length);\n\t\tcommandText.Insert(0, newCommand);\n\t\tcommandText.Insert(0, startBlock.ToString());\n\n\t\tcommandText.Append(\"RETURNING \");\n\t\tseparator = string.Empty;\n\t\tforeach (var m in columnsToFetch)\n\t\t{\n\t\t\tcommandText.Append(separator);\n\t\t\tcommandText.Append(GenerateMemberSql(m));\n\n\t\t\tseparator = \", \";\n\t\t}\n\t\tcommandText.Append(\" INTO \");\n\t\tseparator = string.Empty;\n\t\tforeach (var m in columnsToFetch)\n\t\t{\n\t\t\tcommandText.Append(separator);\n\t\t\tcommandText.Append(\":\" + GenerateMemberSql(m));\n\n\t\t\tseparator = \", \";\n\t\t}\n\n\t\tcommandText.AppendLine(\";\");\n\t\tcommandText.AppendLine(\"IF (ROW_COUNT > 0) THEN\");\n\t\tcommandText.AppendLine(\"  SUSPEND;\");\n\t\tcommandText.AppendLine(\"END\");\n\t}\n\n\tprivate static string ChangeParamsToPSQLParams(string commandText, string[] parametersUsed)\n\t{\n\t\tvar command = new StringBuilder(commandText);\n\t\tforeach (var param in parametersUsed)\n\t\t{\n\t\t\tcommand.Replace(param, \":\" + param.Remove(0, 1));\n\t\t}\n\t\treturn command.ToString();\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/SqlGen/ExpressionTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Data.Common;\nusing System.Data.Entity.Core.Common.CommandTrees;\nusing System.Data.Entity.Core.Metadata.Edm;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.Text;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace EntityFramework.Firebird.SqlGen;\n\ninternal class ExpressionTranslator : DbExpressionVisitor\n{\n\t#region Fields\n\n\tprivate readonly StringBuilder _commandText;\n\tprivate readonly DbModificationCommandTree _commandTree;\n\tprivate readonly List<DbParameter> _parameters;\n\tprivate readonly Dictionary<EdmMember, List<DbParameter>> _memberValues;\n\tprivate readonly bool generateParameters;\n\tprivate int _parameterNameCount = 0;\n\n\t#endregion\n\n\t#region Internal Properties\n\n\tinternal List<DbParameter> Parameters\n\t{\n\t\tget { return _parameters; }\n\t}\n\n\tinternal Dictionary<EdmMember, List<DbParameter>> MemberValues\n\t{\n\t\tget { return _memberValues; }\n\t}\n\n\t#endregion\n\n\t#region Unsupported Visit Methods\n\n\tpublic override void Visit(DbApplyExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"ApplyExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbArithmeticExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"ArithmeticExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbCaseExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"CaseExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbCastExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"CastExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbCrossJoinExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"CrossJoinExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbDerefExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"DerefExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbDistinctExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"DistinctExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbElementExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"ElementExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbEntityRefExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"EntityRefExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbExceptExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"ExceptExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"Expression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbFilterExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"FilterExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbFunctionExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"FunctionExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbGroupByExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"GroupByExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbIntersectExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"IntersectExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbIsEmptyExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"IsEmptyExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbIsOfExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"IsOfExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbJoinExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"JoinExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbLikeExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"LikeExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbLimitExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"LimitExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbOfTypeExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"OfTypeExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbParameterReferenceExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"ParameterReferenceExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbProjectExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"ProjectExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbQuantifierExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"QuantifierExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbRefExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"RefExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbRefKeyExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"RefKeyExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbRelationshipNavigationExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"RelationshipNavigationExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbSkipExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"SkipExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbSortExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"SortExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbTreatExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"TreatExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbUnionAllExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"UnionAllExpression\\\") is not supported.\");\n\t}\n\n\tpublic override void Visit(DbVariableReferenceExpression expression)\n\t{\n\t\tthrow new NotSupportedException(\"Visit(\\\"VariableReferenceExpression\\\") is not supported.\");\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic override void Visit(DbAndExpression expression)\n\t{\n\t\tVisitBinary(expression, \" AND \");\n\t}\n\n\tpublic override void Visit(DbOrExpression expression)\n\t{\n\t\tVisitBinary(expression, \" OR \");\n\t}\n\n\tpublic override void Visit(DbComparisonExpression expression)\n\t{\n\t\tDebug.Assert(expression.ExpressionKind == DbExpressionKind.Equals,\n\t\t\t\"only equals comparison expressions are produced in DML command trees in V1\");\n\n\t\tVisitBinary(expression, \" = \");\n\n\t\tRegisterMemberValue(expression.Left, expression.Right);\n\t}\n\n\tpublic override void Visit(DbIsNullExpression expression)\n\t{\n\t\texpression.Argument.Accept(this);\n\t\t_commandText.Append(\" IS NULL\");\n\t}\n\n\tpublic override void Visit(DbNotExpression expression)\n\t{\n\t\t_commandText.Append(\"NOT (\");\n\t\texpression.Accept(this);\n\t\t_commandText.Append(\")\");\n\t}\n\n\tpublic override void Visit(DbConstantExpression expression)\n\t{\n\t\tif (generateParameters)\n\t\t{\n\t\t\tvar parameter = CreateParameter(expression.Value, expression.ResultType);\n\t\t\t_commandText.Append(parameter.ParameterName);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tusing (var writer = new SqlWriter(_commandText))\n\t\t\t{\n\t\t\t\tvar sqlGenerator = new SqlGenerator();\n\t\t\t\tsqlGenerator.WriteSql(writer, expression.Accept(sqlGenerator));\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override void Visit(DbScanExpression expression)\n\t{\n\t\t_commandText.Append(SqlGenerator.GetTargetSql(expression.Target));\n\t}\n\n\tpublic override void Visit(DbPropertyExpression expression)\n\t{\n\t\t_commandText.Append(DmlSqlGenerator.GenerateMemberSql(expression.Property));\n\t}\n\n\tpublic override void Visit(DbNullExpression expression)\n\t{\n\t\t_commandText.Append(\"NULL\");\n\t}\n\n\tpublic override void Visit(DbNewInstanceExpression expression)\n\t{\n\t\t// assumes all arguments are self-describing (no need to use aliases\n\t\t// because no renames are ever used in the projection)\n\t\tvar first = true;\n\n\t\tforeach (var argument in expression.Arguments)\n\t\t{\n\t\t\tif (first)\n\t\t\t{\n\t\t\t\tfirst = false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_commandText.Append(\", \");\n\t\t\t}\n\t\t\targument.Accept(this);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Internal Methods\n\n\t/// <summary>\n\t/// Initialize a new expression translator populating the given string builder\n\t/// with command text. Command text builder and command tree must not be null.\n\t/// </summary>\n\t/// <param name=\"commandText\">Command text with which to populate commands</param>\n\t/// <param name=\"commandTree\">Command tree generating SQL</param>\n\t/// <param name=\"preserveMemberValues\">Indicates whether the translator should preserve\n\t/// member values while compiling t-SQL (only needed for server generation)</param>\n\tinternal ExpressionTranslator(\n\t\tStringBuilder commandText,\n\t\tDbModificationCommandTree commandTree,\n\t\tbool preserveMemberValues,\n\t\tbool generateParameters)\n\t{\n\t\tDebug.Assert(null != commandText);\n\t\tDebug.Assert(null != commandTree);\n\n\t\t_commandText = commandText;\n\t\t_commandTree = commandTree;\n\t\t_parameters = new List<DbParameter>();\n\t\t_memberValues = preserveMemberValues ? new Dictionary<EdmMember, List<DbParameter>>() : null;\n\t\tthis.generateParameters = generateParameters;\n\t}\n\n\t// generate parameter (name based on parameter ordinal)\n\tinternal FbParameter CreateParameter(object value, TypeUsage type)\n\t{\n\t\tvar parameterName = string.Concat(\"@p\", _parameterNameCount.ToString(CultureInfo.InvariantCulture));\n\t\t_parameterNameCount++;\n\n\t\tvar parameter = FbProviderServices.CreateSqlParameter(parameterName, type, ParameterMode.In, value);\n\n\t\t_parameters.Add(parameter);\n\n\t\treturn parameter;\n\t}\n\n\t/// <summary>\n\t/// Call this method to register a property value pair so the translator \"remembers\"\n\t/// the values for members of the row being modified. These values can then be used\n\t/// to form a predicate for server-generation (based on the key of the row)\n\t/// </summary>\n\t/// <param name=\"propertyExpression\">Expression containing the column reference (property expression).</param>\n\t/// <param name=\"value\">Expression containing the value of the column.</param>\n\tinternal void RegisterMemberValue(DbExpression propertyExpression, DbExpression value)\n\t{\n\t\tif (null != _memberValues)\n\t\t{\n\t\t\t// register the value for this property\n\t\t\tDebug.Assert(propertyExpression.ExpressionKind == DbExpressionKind.Property,\n\t\t\t\t\t\t \"DML predicates and setters must be of the form property = value\");\n\n\t\t\t// get name of left property\n\t\t\tvar property = ((DbPropertyExpression)propertyExpression).Property;\n\n\t\t\t// don't track null values\n\t\t\tif (value.ExpressionKind != DbExpressionKind.Null)\n\t\t\t{\n\t\t\t\tDebug.Assert(value.ExpressionKind == DbExpressionKind.Constant, \"value must either constant or null\");\n\n\t\t\t\t// retrieve the last parameter added (which describes the parameter)\n\t\t\t\tvar p = _parameters[_parameters.Count - 1];\n\t\t\t\tif (!_memberValues.ContainsKey(property))\n\t\t\t\t\t_memberValues.Add(property, new List<DbParameter>(new[] { p }));\n\t\t\t\telse\n\t\t\t\t\t_memberValues[property].Add(p);\n\t\t\t}\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void VisitBinary(DbBinaryExpression expression, string separator)\n\t{\n\t\t_commandText.Append(\"(\");\n\t\texpression.Left.Accept(this);\n\t\t_commandText.Append(separator);\n\t\texpression.Right.Accept(this);\n\t\t_commandText.Append(\")\");\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/SqlGen/FirstClause.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Globalization;\n\nnamespace EntityFramework.Firebird.SqlGen;\n\ninternal class FirstClause : ISqlFragment\n{\n\t#region Fields\n\n\tprivate ISqlFragment _firstCount;\n\n\t#endregion\n\n\t#region Internal Properties\n\n\t/// <summary>\n\t/// How many first rows should be selected.\n\t/// </summary>\n\tinternal ISqlFragment FirstCount\n\t{\n\t\tget { return _firstCount; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\t/// <summary>\n\t/// Creates a FirstClause with the given topCount and withTies.\n\t/// </summary>\n\t/// <param name=\"topCount\"></param>\n\tinternal FirstClause(ISqlFragment firstCount)\n\t{\n\t\t_firstCount = firstCount;\n\t}\n\n\t/// <summary>\n\t/// Creates a TopClause with the given topCount and withTies.\n\t/// </summary>\n\t/// <param name=\"topCount\"></param>\n\tinternal FirstClause(int firstCount)\n\t{\n\t\tvar sqlBuilder = new SqlBuilder();\n\t\tsqlBuilder.Append(firstCount.ToString(CultureInfo.InvariantCulture));\n\t\t_firstCount = sqlBuilder;\n\t}\n\n\t#endregion\n\n\t#region ISqlFragment Members\n\n\t/// <summary>\n\t/// Write out the FIRST part of sql select statement\n\t/// It basically writes FIRST (X).\n\t/// </summary>\n\t/// <param name=\"writer\"></param>\n\t/// <param name=\"sqlGenerator\"></param>\n\tpublic void WriteSql(SqlWriter writer, SqlGenerator sqlGenerator)\n\t{\n\t\twriter.Write(\"FIRST (\");\n\t\tFirstCount.WriteSql(writer, sqlGenerator);\n\t\twriter.Write(\")\");\n\n\t\twriter.Write(\" \");\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/SqlGen/ISqlFragment.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nnamespace EntityFramework.Firebird.SqlGen;\n\ninternal interface ISqlFragment\n{\n\tvoid WriteSql(SqlWriter writer, SqlGenerator sqlGenerator);\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/SqlGen/JoinSymbol.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Data.Entity.Core.Metadata.Edm;\n\nnamespace EntityFramework.Firebird.SqlGen;\n\ninternal sealed class JoinSymbol : Symbol\n{\n\t#region Fields\n\n\tprivate List<Symbol> _columnList;\n\tprivate List<Symbol> _extentList;\n\tprivate List<Symbol> _flattenedExtentList;\n\tprivate Dictionary<string, Symbol> _nameToExtent;\n\tprivate bool _isNestedJoin;\n\n\t#endregion\n\n\t#region Properties\n\n\tinternal List<Symbol> ColumnList\n\t{\n\t\tget\n\t\t{\n\t\t\tif (null == _columnList)\n\t\t\t{\n\t\t\t\t_columnList = new List<Symbol>();\n\t\t\t}\n\t\t\treturn _columnList;\n\t\t}\n\t\tset { _columnList = value; }\n\t}\n\n\tinternal List<Symbol> ExtentList\n\t{\n\t\tget { return _extentList; }\n\t}\n\n\tinternal List<Symbol> FlattenedExtentList\n\t{\n\t\tget\n\t\t{\n\t\t\tif (null == _flattenedExtentList)\n\t\t\t{\n\t\t\t\t_flattenedExtentList = new List<Symbol>();\n\t\t\t}\n\t\t\treturn _flattenedExtentList;\n\t\t}\n\t\tset { _flattenedExtentList = value; }\n\t}\n\n\tinternal Dictionary<string, Symbol> NameToExtent\n\t{\n\t\tget { return _nameToExtent; }\n\t}\n\n\tinternal bool IsNestedJoin\n\t{\n\t\tget { return _isNestedJoin; }\n\t\tset { _isNestedJoin = value; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic JoinSymbol(string name, TypeUsage type, List<Symbol> extents)\n\t\t: base(name, type)\n\t{\n\t\t_extentList = new List<Symbol>(extents.Count);\n\t\t_nameToExtent = new Dictionary<string, Symbol>(extents.Count, StringComparer.OrdinalIgnoreCase);\n\n\t\tforeach (var symbol in extents)\n\t\t{\n\t\t\t_nameToExtent[symbol.Name] = symbol;\n\t\t\tExtentList.Add(symbol);\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/SqlGen/SkipClause.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Globalization;\n\nnamespace EntityFramework.Firebird.SqlGen;\n\ninternal class SkipClause : ISqlFragment\n{\n\t#region Fields\n\n\tprivate ISqlFragment _skipCount;\n\n\t#endregion\n\n\t#region Internal Properties\n\n\t/// <summary>\n\t/// How many rows should be skipped.\n\t/// </summary>\n\tinternal ISqlFragment SkipCount\n\t{\n\t\tget { return _skipCount; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\t/// <summary>\n\t/// Creates a SkipClause with the given skipCount.\n\t/// </summary>\n\t/// <param name=\"topCount\"></param>\n\tinternal SkipClause(ISqlFragment skipCount)\n\t{\n\t\t_skipCount = skipCount;\n\t}\n\n\t/// <summary>\n\t/// Creates a SkipClause with the given skipCount.\n\t/// </summary>\n\t/// <param name=\"topCount\"></param>\n\tinternal SkipClause(int skipCount)\n\t{\n\t\tvar sqlBuilder = new SqlBuilder();\n\t\tsqlBuilder.Append(skipCount.ToString(CultureInfo.InvariantCulture));\n\t\t_skipCount = sqlBuilder;\n\t}\n\n\t#endregion\n\n\t#region ISqlFragment Members\n\n\t/// <summary>\n\t/// Write out the SKIP part of sql select statement\n\t/// It basically writes SKIP (X).\n\t/// </summary>\n\t/// <param name=\"writer\"></param>\n\t/// <param name=\"sqlGenerator\"></param>\n\tpublic void WriteSql(SqlWriter writer, SqlGenerator sqlGenerator)\n\t{\n\t\twriter.Write(\"SKIP (\");\n\t\tSkipCount.WriteSql(writer, sqlGenerator);\n\t\twriter.Write(\")\");\n\n\t\twriter.Write(\" \");\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/SqlGen/SqlBuilder.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\n\nnamespace EntityFramework.Firebird.SqlGen;\n\ninternal sealed class SqlBuilder : ISqlFragment\n{\n\t#region Fields\n\n\tprivate List<object> _sqlFragments;\n\n\t#endregion\n\n\t#region Properties\n\n\tprivate List<object> SqlFragments\n\t{\n\t\tget\n\t\t{\n\t\t\tif (null == _sqlFragments)\n\t\t\t{\n\t\t\t\t_sqlFragments = new List<object>();\n\t\t\t}\n\t\t\treturn _sqlFragments;\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\t/// <summary>\n\t/// Add an object to the list - we do not verify that it is a proper sql fragment\n\t/// since this is an internal method.\n\t/// </summary>\n\t/// <param name=\"s\"></param>\n\tpublic void Append(object s)\n\t{\n\t\tDebug.Assert(s != null);\n\t\tSqlFragments.Add(s);\n\t}\n\n\t/// <summary>\n\t/// This is to pretty print the SQL.  The writer <see cref=\"SqlWriter.Write\"/>\n\t/// needs to know about new lines so that it can add the right amount of\n\t/// indentation at the beginning of lines.\n\t/// </summary>\n\tpublic void AppendLine()\n\t{\n\t\tSqlFragments.Add(Environment.NewLine);\n\t}\n\n\t/// <summary>\n\t/// Whether the builder is empty.  This is used by the <see cref=\"SqlGenerator.Visit(ProjectExpression)\"/>\n\t/// to determine whether a sql statement can be reused.\n\t/// </summary>\n\tpublic bool IsEmpty\n\t{\n\t\tget { return ((null == _sqlFragments) || (0 == _sqlFragments.Count)); }\n\t}\n\n\t#endregion\n\n\t#region ISqlFragment Members\n\n\t/// <summary>\n\t/// We delegate the writing of the fragment to the appropriate type.\n\t/// </summary>\n\t/// <param name=\"writer\"></param>\n\t/// <param name=\"sqlGenerator\"></param>\n\tpublic void WriteSql(SqlWriter writer, SqlGenerator sqlGenerator)\n\t{\n\t\tif (null != _sqlFragments)\n\t\t{\n\t\t\tforeach (var o in _sqlFragments)\n\t\t\t{\n\t\t\t\tvar str = (o as string);\n\t\t\t\tif (null != str)\n\t\t\t\t{\n\t\t\t\t\twriter.Write(str);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tvar sqlFragment = (o as ISqlFragment);\n\t\t\t\t\tif (null != sqlFragment)\n\t\t\t\t\t{\n\t\t\t\t\t\tsqlFragment.WriteSql(writer, sqlGenerator);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new InvalidOperationException();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/SqlGen/SqlGenerator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Data;\nusing System.Data.Common;\nusing System.Data.Entity.Core.Common.CommandTrees;\nusing System.Data.Entity.Core.Metadata.Edm;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.Text;\nusing FirebirdSql.Data.Common;\n\nnamespace EntityFramework.Firebird.SqlGen;\n\ninternal sealed class SqlGenerator : DbExpressionVisitor<ISqlFragment>\n{\n\t#region Visitor parameter stacks\n\t/// <summary>\n\t/// Every relational node has to pass its SELECT statement to its children\n\t/// This allows them (DbVariableReferenceExpression eventually) to update the list of\n\t/// outer extents (free variables) used by this select statement.\n\t/// </summary>\n\tStack<SqlSelectStatement> _selectStatementStack;\n\n\t/// <summary>\n\t/// The top of the stack\n\t/// </summary>\n\tprivate SqlSelectStatement CurrentSelectStatement\n\t{\n\t\t// There is always something on the stack, so we can always Peek.\n\t\tget { return _selectStatementStack.Peek(); }\n\t}\n\n\t/// <summary>\n\t/// Nested joins and extents need to know whether they should create\n\t/// a new Select statement, or reuse the parent's.  This flag\n\t/// indicates whether the parent is a join or not.\n\t/// </summary>\n\tStack<bool> _isParentAJoinStack;\n\n\t/// <summary>\n\t/// The top of the stack\n\t/// </summary>\n\tprivate bool IsParentAJoin\n\t{\n\t\t// There might be no entry on the stack if a Join node has never\n\t\t// been seen, so we return false in that case.\n\t\tget { return _isParentAJoinStack.Count == 0 ? false : _isParentAJoinStack.Peek(); }\n\t}\n\n\t#endregion\n\n\t#region Global lists and state\n\tDictionary<string, int> _allExtentNames;\n\tinternal Dictionary<string, int> AllExtentNames\n\t{\n\t\tget { return _allExtentNames; }\n\t}\n\n\t// For each column name, we store the last integer suffix that\n\t// was added to produce a unique column name.  This speeds up\n\t// the creation of the next unique name for this column name.\n\tDictionary<string, int> _allColumnNames;\n\tinternal Dictionary<string, int> AllColumnNames\n\t{\n\t\tget { return _allColumnNames; }\n\t}\n\n\tSymbolTable _symbolTable = new SymbolTable();\n\n\t/// <summary>\n\t/// VariableReferenceExpressions are allowed only as children of DbPropertyExpression\n\t/// or MethodExpression.  The cheapest way to ensure this is to set the following\n\t/// property in DbVariableReferenceExpression and reset it in the allowed parent expressions.\n\t/// </summary>\n\tbool _isVarRefSingle = false;\n\n\tbool _shouldHandleBoolComparison = true;\n\tbool _shouldCastParameter = true;\n\n\tDictionary<string, string> _shortenedNames = new Dictionary<string, string>();\n\n\t#endregion\n\n\t#region Statics\n\tstatic private readonly Dictionary<string, FunctionHandler> _builtInFunctionHandlers = InitializeBuiltInFunctionHandlers();\n\tstatic private readonly Dictionary<string, FunctionHandler> _canonicalFunctionHandlers = InitializeCanonicalFunctionHandlers();\n\tstatic private readonly Dictionary<string, string> _functionNameToOperatorDictionary = InitializeFunctionNameToOperatorDictionary();\n\n\tprivate delegate ISqlFragment FunctionHandler(SqlGenerator sqlgen, DbFunctionExpression functionExpr);\n\n\t/// <summary>\n\t/// All special built-in functions and their handlers\n\t/// </summary>\n\t/// <returns></returns>\n\tprivate static Dictionary<string, FunctionHandler> InitializeBuiltInFunctionHandlers()\n\t{\n\t\tvar functionHandlers = new Dictionary<string, FunctionHandler>(0, StringComparer.Ordinal);\n\t\treturn functionHandlers;\n\t}\n\n\t/// <summary>\n\t/// All special non-aggregate canonical functions and their handlers\n\t/// </summary>\n\t/// <returns></returns>\n\tprivate static Dictionary<string, FunctionHandler> InitializeCanonicalFunctionHandlers()\n\t{\n\t\tvar functionHandlers = new Dictionary<string, FunctionHandler>(StringComparer.Ordinal);\n\n\t\t#region Other Canonical Functions\n\t\tfunctionHandlers.Add(\"NewGuid\", HandleCanonicalFunctionNewGuid);\n\t\t#endregion\n\n\t\t#region Math Canonical Functions\n\t\tfunctionHandlers.Add(\"Abs\", HandleCanonicalFunctionAbs);\n\t\tfunctionHandlers.Add(\"Ceiling\", HandleCanonicalFunctionCeiling);\n\t\tfunctionHandlers.Add(\"Floor\", HandleCanonicalFunctionFloor);\n\t\tfunctionHandlers.Add(\"Power\", HandleCanonicalFunctionPower);\n\t\tfunctionHandlers.Add(\"Round\", HandleCanonicalFunctionRound);\n\t\tfunctionHandlers.Add(\"Truncate\", HandleCanonicalFunctionTruncate);\n\t\t#endregion\n\n\t\t#region String Canonical Functions\n\t\tfunctionHandlers.Add(\"Concat\", HandleCanonicalConcatFunction);\n\t\tfunctionHandlers.Add(\"Contains\", HandleCanonicalContainsFunction);\n\t\tfunctionHandlers.Add(\"EndsWith\", HandleCanonicalEndsWithFunction);\n\t\tfunctionHandlers.Add(\"IndexOf\", HandleCanonicalFunctionIndexOf);\n\t\tfunctionHandlers.Add(\"Length\", HandleCanonicalFunctionLength);\n\t\tfunctionHandlers.Add(\"ToLower\", HandleCanonicalFunctionToLower);\n\t\tfunctionHandlers.Add(\"ToUpper\", HandleCanonicalFunctionToUpper);\n\t\tfunctionHandlers.Add(\"Trim\", HandleCanonicalFunctionTrim);\n\t\tfunctionHandlers.Add(\"LTrim\", HandleCanonicalFunctionLTrim);\n\t\tfunctionHandlers.Add(\"RTrim\", HandleCanonicalFunctionRTrim);\n\t\tfunctionHandlers.Add(\"Left\", HandleCanonicalFunctionLeft);\n\t\tfunctionHandlers.Add(\"Right\", HandleCanonicalFunctionRight);\n\t\tfunctionHandlers.Add(\"Reverse\", HandleCanonicalFunctionReverse);\n\t\tfunctionHandlers.Add(\"Replace\", HandleCanonicalFunctionReplace);\n\t\tfunctionHandlers.Add(\"StartsWith\", HandleCanonicalStartsWithFunction);\n\t\tfunctionHandlers.Add(\"Substring\", HandleCanonicalFunctionSubstring);\n\t\t#endregion\n\n\t\t#region Date and Time Canonical Functions\n\t\tfunctionHandlers.Add(\"AddNanoseconds\", (sqlgen, e) => HandleCanonicalFunctionDateTimeAdd(sqlgen, e, null)); // not supported\n\t\tfunctionHandlers.Add(\"AddMicroseconds\", (sqlgen, e) => HandleCanonicalFunctionDateTimeAdd(sqlgen, e, null)); // not supported\n\t\tfunctionHandlers.Add(\"AddMilliseconds\", (sqlgen, e) => HandleCanonicalFunctionDateTimeAdd(sqlgen, e, \"MILLISECOND\"));\n\t\tfunctionHandlers.Add(\"AddSeconds\", (sqlgen, e) => HandleCanonicalFunctionDateTimeAdd(sqlgen, e, \"SECOND\"));\n\t\tfunctionHandlers.Add(\"AddMinutes\", (sqlgen, e) => HandleCanonicalFunctionDateTimeAdd(sqlgen, e, \"MINUTE\"));\n\t\tfunctionHandlers.Add(\"AddHours\", (sqlgen, e) => HandleCanonicalFunctionDateTimeAdd(sqlgen, e, \"HOUR\"));\n\t\tfunctionHandlers.Add(\"AddDays\", (sqlgen, e) => HandleCanonicalFunctionDateTimeAdd(sqlgen, e, \"DAY\"));\n\t\tfunctionHandlers.Add(\"AddMonths\", (sqlgen, e) => HandleCanonicalFunctionDateTimeAdd(sqlgen, e, \"MONTH\"));\n\t\tfunctionHandlers.Add(\"AddYears\", (sqlgen, e) => HandleCanonicalFunctionDateTimeAdd(sqlgen, e, \"YEAR\"));\n\t\tfunctionHandlers.Add(\"CreateDateTime\", HandleCanonicalFunctionCreateDateTime);\n\t\tfunctionHandlers.Add(\"CreateDateTimeOffset\", HandleCanonicalFunctionCreateDateTimeOffset); // not supported\n\t\tfunctionHandlers.Add(\"CreateTime\", HandleCanonicalFunctionCreateTime);\n\t\tfunctionHandlers.Add(\"CurrentDateTime\", HandleCanonicalFunctionCurrentDateTime);\n\t\tfunctionHandlers.Add(\"CurrentDateTimeOffset\", HandleCanonicalFunctionCurrentDateTimeOffset); // not supported\n\t\tfunctionHandlers.Add(\"CurrentUtcDateTime\", HandleCanonicalFunctionCurrentUtcDateTime); // not supported\n\t\tfunctionHandlers.Add(\"Day\", (sqlgen, e) => HandleCanonicalFunctionExtract(sqlgen, e, \"DAY\"));\n\t\tfunctionHandlers.Add(\"DayOfYear\", (sqlgen, e) => HandleCanonicalFunctionExtract(sqlgen, e, \"YEARDAY\"));\n\t\tfunctionHandlers.Add(\"DiffNanoseconds\", (sqlgen, e) => HandleCanonicalFunctionDateTimeDiff(sqlgen, e, null)); // not supported\n\t\tfunctionHandlers.Add(\"DiffMicroseconds\", (sqlgen, e) => HandleCanonicalFunctionDateTimeDiff(sqlgen, e, null)); // not supported\n\t\tfunctionHandlers.Add(\"DiffMilliseconds\", (sqlgen, e) => HandleCanonicalFunctionDateTimeDiff(sqlgen, e, \"MILLISECOND\"));\n\t\tfunctionHandlers.Add(\"DiffSeconds\", (sqlgen, e) => HandleCanonicalFunctionDateTimeDiff(sqlgen, e, \"SECOND\"));\n\t\tfunctionHandlers.Add(\"DiffMinutes\", (sqlgen, e) => HandleCanonicalFunctionDateTimeDiff(sqlgen, e, \"MINUTE\"));\n\t\tfunctionHandlers.Add(\"DiffHours\", (sqlgen, e) => HandleCanonicalFunctionDateTimeDiff(sqlgen, e, \"HOUR\"));\n\t\tfunctionHandlers.Add(\"DiffDays\", (sqlgen, e) => HandleCanonicalFunctionDateTimeDiff(sqlgen, e, \"DAY\"));\n\t\tfunctionHandlers.Add(\"DiffMonths\", (sqlgen, e) => HandleCanonicalFunctionDateTimeDiff(sqlgen, e, \"MONTH\"));\n\t\tfunctionHandlers.Add(\"DiffYears\", (sqlgen, e) => HandleCanonicalFunctionDateTimeDiff(sqlgen, e, \"YEAR\"));\n\t\tfunctionHandlers.Add(\"GetTotalOffsetMinutes\", HandleCanonicalFunctionGetTotalOffsetMinutes); // not supported\n\t\tfunctionHandlers.Add(\"Hour\", (sqlgen, e) => HandleCanonicalFunctionExtract(sqlgen, e, \"HOUR\"));\n\t\tfunctionHandlers.Add(\"Millisecond\", (sqlgen, e) => HandleCanonicalFunctionExtract(sqlgen, e, \"MILLISECOND\"));\n\t\tfunctionHandlers.Add(\"Minute\", (sqlgen, e) => HandleCanonicalFunctionExtract(sqlgen, e, \"MINUTE\"));\n\t\tfunctionHandlers.Add(\"Month\", (sqlgen, e) => HandleCanonicalFunctionExtract(sqlgen, e, \"MONTH\"));\n\t\tfunctionHandlers.Add(\"Second\", (sqlgen, e) => HandleCanonicalFunctionExtract(sqlgen, e, \"SECOND\"));\n\t\tfunctionHandlers.Add(\"TruncateTime\", HandleCanonicalFunctionTruncateTime);\n\t\tfunctionHandlers.Add(\"Year\", (sqlgen, e) => HandleCanonicalFunctionExtract(sqlgen, e, \"YEAR\"));\n\t\t#endregion\n\n\t\t#region Bitwise Canonical Functions\n\t\tfunctionHandlers.Add(\"BitwiseAnd\", HandleCanonicalFunctionBitwiseAnd);\n\t\tfunctionHandlers.Add(\"BitwiseNot\", HandleCanonicalFunctionBitwiseNot); // not supported\n\t\tfunctionHandlers.Add(\"BitwiseOr\", HandleCanonicalFunctionBitwiseOr);\n\t\tfunctionHandlers.Add(\"BitwiseXor\", HandleCanonicalFunctionBitwiseXor);\n\t\t#endregion\n\n\t\treturn functionHandlers;\n\t}\n\n\t/// <summary>\n\t/// Initializes the mapping from functions to T-SQL operators\n\t/// for all functions that translate to T-SQL operators\n\t/// </summary>\n\t/// <returns></returns>\n\tprivate static Dictionary<string, string> InitializeFunctionNameToOperatorDictionary()\n\t{\n\t\treturn new Dictionary<string, string>(StringComparer.Ordinal)\n\t\t\t{\n\t\t\t\t{ nameof(string.Concat), \"||\" },\n\t\t\t\t{ nameof(string.Contains), \"CONTAINING\" },\n\t\t\t\t{ nameof(string.StartsWith), \"STARTING WITH\" },\n\t\t\t};\n\t}\n\n\t#endregion\n\n\t#region Constructor\n\t/// <summary>\n\t/// Basic constructor.\n\t/// </summary>\n\tinternal SqlGenerator()\n\t{\n\t}\n\t#endregion\n\n\t#region Entry points\n\t/// <summary>\n\t/// General purpose static function that can be called from System.Data assembly\n\t/// </summary>\n\t/// <param name=\"sqlVersion\">Server version</param>\n\t/// <param name=\"tree\">command tree</param>\n\t/// <param name=\"parameters\">Parameters to add to the command tree corresponding\n\t/// to constants in the command tree. Used only in ModificationCommandTrees.</param>\n\t/// <returns>The string representing the SQL to be executed.</returns>\n\tinternal static string GenerateSql(DbCommandTree tree, out List<DbParameter> parameters, out CommandType commandType)\n\t{\n\t\tcommandType = CommandType.Text;\n\n\t\t//Handle Query\n\t\tif (tree is DbQueryCommandTree queryCommandTree)\n\t\t{\n\t\t\tvar sqlGen = new SqlGenerator();\n\t\t\tparameters = null;\n\t\t\treturn sqlGen.GenerateSql((DbQueryCommandTree)tree);\n\t\t}\n\n\t\t//Handle Function\n\t\tif (tree is DbFunctionCommandTree DbFunctionCommandTree)\n\t\t{\n\t\t\tvar sqlGen = new SqlGenerator();\n\t\t\tparameters = null;\n\n\t\t\tvar sql = sqlGen.GenerateFunctionSql(DbFunctionCommandTree, out commandType);\n\n\t\t\treturn sql;\n\t\t}\n\n\t\t//Handle Insert\n\t\tif (tree is DbInsertCommandTree insertCommandTree)\n\t\t{\n\t\t\treturn DmlSqlGenerator.GenerateInsertSql(insertCommandTree, out parameters);\n\t\t}\n\n\t\t//Handle Delete\n\t\tif (tree is DbDeleteCommandTree deleteCommandTree)\n\t\t{\n\t\t\treturn DmlSqlGenerator.GenerateDeleteSql(deleteCommandTree, out parameters);\n\t\t}\n\n\t\t//Handle Update\n\t\tif (tree is DbUpdateCommandTree updateCommandTree)\n\t\t{\n\t\t\treturn DmlSqlGenerator.GenerateUpdateSql(updateCommandTree, out parameters);\n\t\t}\n\n\t\tthrow new NotSupportedException(\"Unrecognized command tree type\");\n\t}\n\t#endregion\n\n\t#region Driver Methods\n\t/// <summary>\n\t/// Translate a command tree to a SQL string.\n\t///\n\t/// The input tree could be translated to either a SQL SELECT statement\n\t/// or a SELECT expression.  This choice is made based on the return type\n\t/// of the expression\n\t/// CollectionType => select statement\n\t/// non collection type => select expression\n\t/// </summary>\n\t/// <param name=\"tree\"></param>\n\t/// <returns>The string representing the SQL to be executed.</returns>\n\tprivate string GenerateSql(DbQueryCommandTree tree)\n\t{\n\t\t_selectStatementStack = new Stack<SqlSelectStatement>();\n\t\t_isParentAJoinStack = new Stack<bool>();\n\n\t\t_allExtentNames = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);\n\t\t_allColumnNames = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);\n\n\t\t// Literals will not be converted to parameters.\n\n\t\tISqlFragment result;\n\t\tif (MetadataHelpers.IsCollectionType(tree.Query.ResultType))\n\t\t{\n\t\t\tvar sqlStatement = VisitExpressionEnsureSqlStatement(tree.Query);\n\t\t\tDebug.Assert(sqlStatement != null, \"The outer most sql statment is null\");\n\t\t\tsqlStatement.IsTopMost = true;\n\t\t\tresult = sqlStatement;\n\n\t\t}\n\t\telse\n\t\t{\n\t\t\tvar sqlBuilder = new SqlBuilder();\n\t\t\tsqlBuilder.Append(\"SELECT \");\n\t\t\tsqlBuilder.Append(tree.Query.Accept(this));\n\n\t\t\tresult = sqlBuilder;\n\t\t}\n\n\t\tif (_isVarRefSingle)\n\t\t{\n\t\t\tthrow new NotSupportedException();\n\t\t\t// A DbVariableReferenceExpression has to be a child of DbPropertyExpression or MethodExpression\n\t\t}\n\n\t\t// Check that the parameter stacks are not leaking.\n\t\tDebug.Assert(_selectStatementStack.Count == 0);\n\t\tDebug.Assert(_isParentAJoinStack.Count == 0);\n\n\t\treturn WriteSql(result);\n\t}\n\n\t/// <summary>\n\t/// Translate a function command tree to a SQL string.\n\t/// </summary>\n\tprivate string GenerateFunctionSql(DbFunctionCommandTree tree, out CommandType commandType)\n\t{\n\t\tvar function = tree.EdmFunction;\n\n\t\t// We expect function to always have these properties\n\t\tvar userCommandText = (string)function.MetadataProperties[\"CommandTextAttribute\"].Value;\n\t\t/// No schema in FB\n\t\t//string userSchemaName = (string)function.MetadataProperties[\"Schema\"].Value;\n\t\tvar userFuncName = (string)function.MetadataProperties[\"StoreFunctionNameAttribute\"].Value;\n\n\t\tif (string.IsNullOrEmpty(userCommandText))\n\t\t{\n\t\t\t// build a quoted description of the function\n\t\t\tcommandType = CommandType.StoredProcedure;\n\n\t\t\t// if the schema name is not explicitly given, it is assumed to be the metadata namespace\n\t\t\t/// No schema in FB\n\t\t\t//string schemaName = string.IsNullOrEmpty(userSchemaName) ?\n\t\t\t//    function.NamespaceName : userSchemaName;\n\n\t\t\t// if the function store name is not explicitly given, it is assumed to be the metadata name\n\t\t\tvar functionName = string.IsNullOrEmpty(userFuncName) ?\n\t\t\t\tfunction.Name : userFuncName;\n\n\t\t\t// quote elements of function text\n\t\t\t/// No schema in FB\n\t\t\t//string quotedSchemaName = QuoteIdentifier(schemaName);\n\t\t\tvar quotedFunctionName = QuoteIdentifier(functionName);\n\n\t\t\t// separator\n\t\t\t/// No schema in FB\n\t\t\t//const string schemaSeparator = \".\";\n\t\t\t// concatenate elements of function text\n\n\t\t\t/// No schema in FB\n\t\t\tvar quotedFunctionText = /*quotedSchemaName + schemaSeparator + */quotedFunctionName;\n\n\t\t\treturn quotedFunctionText;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// if the user has specified the command text, pass it through verbatim and choose CommandType.Text\n\t\t\tcommandType = CommandType.Text;\n\t\t\treturn userCommandText;\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Convert the SQL fragments to a string.\n\t/// We have to setup the Stream for writing.\n\t/// </summary>\n\t/// <param name=\"sqlStatement\"></param>\n\t/// <returns>A string representing the SQL to be executed.</returns>\n\tstring WriteSql(ISqlFragment sqlStatement)\n\t{\n\t\tvar builder = new StringBuilder(1024);\n\t\tusing (var writer = new SqlWriter(builder))\n\t\t{\n\t\t\tWriteSql(writer, sqlStatement);\n\t\t}\n\n\t\treturn builder.ToString();\n\t}\n\n\tinternal SqlWriter WriteSql(SqlWriter writer, ISqlFragment sqlStatement)\n\t{\n\t\tsqlStatement.WriteSql(writer, this);\n\t\treturn writer;\n\t}\n\t#endregion\n\n\t#region DbExpressionVisitor Members\n\n\t/// <summary>\n\t/// Translate(left) AND Translate(right)\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/>.</returns>\n\tpublic override ISqlFragment Visit(DbAndExpression e)\n\t{\n\t\treturn VisitBinaryExpression(\" AND \", e.Left, e.Right);\n\t}\n\n\t/// <summary>\n\t/// An apply is just like a join, so it shares the common join processing\n\t/// in <see cref=\"VisitJoinExpression\"/>\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlSelectStatement\"/>.</returns>\n\tpublic override ISqlFragment Visit(DbApplyExpression e)\n\t{\n\t\tstring joinString;\n\t\tswitch (e.ExpressionKind)\n\t\t{\n\t\t\tcase DbExpressionKind.CrossApply:\n\t\t\t\tjoinString = \"CROSS APPLY\";\n\t\t\t\tbreak;\n\n\t\t\tcase DbExpressionKind.OuterApply:\n\t\t\t\tjoinString = \"OUTER APPLY\";\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tDebug.Assert(false);\n\t\t\t\tthrow new InvalidOperationException();\n\t\t}\n\n\t\tthrow new NotSupportedException($\"{joinString} statement is not supported in Firebird.\");\n\t\t// The join condition does not exist in this case, so we use null.\n\t\t// We do not have a on clause, so we use JoinType.CrossJoin.\n\t\t//return VisitJoinExpression(inputs, DbExpressionKind.CrossJoin, joinString, null);\n\t}\n\n\t/// <summary>\n\t/// For binary expressions, we delegate to <see cref=\"VisitBinaryExpression\"/>.\n\t/// We handle the other expressions directly.\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/></returns>\n\tpublic override ISqlFragment Visit(DbArithmeticExpression e)\n\t{\n\t\tSqlBuilder result;\n\n\t\tswitch (e.ExpressionKind)\n\t\t{\n\t\t\tcase DbExpressionKind.Divide:\n\t\t\t\tresult = VisitBinaryExpression(\" / \", e.Arguments[0], e.Arguments[1]);\n\t\t\t\tbreak;\n\t\t\tcase DbExpressionKind.Minus:\n\t\t\t\tresult = VisitBinaryExpression(\" - \", e.Arguments[0], e.Arguments[1]);\n\t\t\t\tbreak;\n\t\t\tcase DbExpressionKind.Modulo:\n\t\t\t\t//result = VisitBinaryExpression(\" % \", e.Arguments[0], e.Arguments[1]);\n\t\t\t\tresult = new SqlBuilder();\n\t\t\t\tresult.Append(\" MOD(\");\n\t\t\t\tresult.Append(e.Arguments[0].Accept(this));\n\t\t\t\tresult.Append(\", \");\n\t\t\t\tresult.Append(e.Arguments[1].Accept(this));\n\t\t\t\tresult.Append(\")\");\n\t\t\t\tbreak;\n\t\t\tcase DbExpressionKind.Multiply:\n\t\t\t\tresult = VisitBinaryExpression(\" * \", e.Arguments[0], e.Arguments[1]);\n\t\t\t\tbreak;\n\t\t\tcase DbExpressionKind.Plus:\n\t\t\t\tresult = VisitBinaryExpression(\" + \", e.Arguments[0], e.Arguments[1]);\n\t\t\t\tbreak;\n\n\t\t\tcase DbExpressionKind.UnaryMinus:\n\t\t\t\tresult = new SqlBuilder();\n\t\t\t\tresult.Append(\" -(\");\n\t\t\t\tresult.Append(e.Arguments[0].Accept(this));\n\t\t\t\tresult.Append(\")\");\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tDebug.Assert(false);\n\t\t\t\tthrow new InvalidOperationException();\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// If the ELSE clause is null, we do not write it out.\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/></returns>\n\tpublic override ISqlFragment Visit(DbCaseExpression e)\n\t{\n\t\tvar result = new SqlBuilder();\n\n\t\tDebug.Assert(e.When.Count == e.Then.Count);\n\n\t\tresult.Append(\"CASE\");\n\t\tfor (var i = 0; i < e.When.Count; ++i)\n\t\t{\n\t\t\tresult.Append(\" WHEN (\");\n\t\t\tresult.Append(e.When[i].Accept(this));\n\t\t\tresult.Append(\") THEN \");\n\t\t\tresult.Append(e.Then[i].Accept(this));\n\t\t}\n\t\tif (e.Else != null && !(e.Else is DbNullExpression))\n\t\t{\n\t\t\tresult.Append(\" ELSE \");\n\t\t\tresult.Append(e.Else.Accept(this));\n\t\t}\n\n\t\tresult.Append(\" END\");\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t///\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tpublic override ISqlFragment Visit(DbCastExpression e)\n\t{\n\t\tvar result = new SqlBuilder();\n\t\tvar sqlPrimitiveType = GetSqlPrimitiveType(e.ResultType);\n\n\t\tswitch (sqlPrimitiveType.ToUpperInvariant())\n\t\t{\n\t\t\tdefault:\n\t\t\t\tresult.Append(\"CAST(\");\n\t\t\t\tresult.Append(e.Argument.Accept(this));\n\t\t\t\tresult.Append(\" AS \");\n\t\t\t\tresult.Append(sqlPrimitiveType);\n\t\t\t\tresult.Append(\")\");\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// The parser generates Not(Equals(...)) for &lt;&gt;.\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/>.</returns>\n\tpublic override ISqlFragment Visit(DbComparisonExpression e)\n\t{\n\t\tswitch (e.ExpressionKind)\n\t\t{\n\t\t\tcase DbExpressionKind.Equals:\n\t\t\t\treturn VisitBinaryExpression(\" = \", e.Left, e.Right);\n\t\t\tcase DbExpressionKind.LessThan:\n\t\t\t\treturn VisitBinaryExpression(\" < \", e.Left, e.Right);\n\t\t\tcase DbExpressionKind.LessThanOrEquals:\n\t\t\t\treturn VisitBinaryExpression(\" <= \", e.Left, e.Right);\n\t\t\tcase DbExpressionKind.GreaterThan:\n\t\t\t\treturn VisitBinaryExpression(\" > \", e.Left, e.Right);\n\t\t\tcase DbExpressionKind.GreaterThanOrEquals:\n\t\t\t\treturn VisitBinaryExpression(\" >= \", e.Left, e.Right);\n\t\t\t// The parser does not generate the expression kind below.\n\t\t\tcase DbExpressionKind.NotEquals:\n\t\t\t\treturn VisitBinaryExpression(\" <> \", e.Left, e.Right);\n\n\t\t\tdefault:\n\t\t\t\tDebug.Assert(false);  // The constructor should have prevented this\n\t\t\t\tthrow new InvalidOperationException(string.Empty);\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Constants will be send to the store as part of the generated SQL, not as parameters.\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/>.  Strings are wrapped in single\n\t/// quotes and escaped.  Numbers are written literally.</returns>\n\tpublic override ISqlFragment Visit(DbConstantExpression e)\n\t{\n\t\tvar result = new SqlBuilder();\n\n\t\tif (MetadataHelpers.TryGetPrimitiveTypeKind(e.ResultType, out var typeKind))\n\t\t{\n\t\t\tswitch (typeKind)\n\t\t\t{\n\t\t\t\tcase PrimitiveTypeKind.Boolean:\n\t\t\t\t\tresult.Append(FormatBoolean((bool)e.Value));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase PrimitiveTypeKind.Int16:\n\t\t\t\t\tresult.Append(\"CAST(\");\n\t\t\t\t\tresult.Append(e.Value.ToString());\n\t\t\t\t\tresult.Append(\" AS \");\n\t\t\t\t\tresult.Append(GetSqlPrimitiveType(e.ResultType));\n\t\t\t\t\tresult.Append(\")\");\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase PrimitiveTypeKind.Int32:\n\t\t\t\t\t// default for integral values.\n\t\t\t\t\tresult.Append(e.Value.ToString());\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase PrimitiveTypeKind.Int64:\n\t\t\t\t\tresult.Append(\"CAST(\");\n\t\t\t\t\tresult.Append(e.Value.ToString());\n\t\t\t\t\tresult.Append(\" AS \");\n\t\t\t\t\tresult.Append(GetSqlPrimitiveType(e.ResultType));\n\t\t\t\t\tresult.Append(\")\");\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase PrimitiveTypeKind.Double:\n\t\t\t\t\tresult.Append(\"CAST(\");\n\t\t\t\t\tresult.Append(((Double)e.Value).ToString(CultureInfo.InvariantCulture));\n\t\t\t\t\tresult.Append(\" AS \");\n\t\t\t\t\tresult.Append(GetSqlPrimitiveType(e.ResultType));\n\t\t\t\t\tresult.Append(\")\");\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase PrimitiveTypeKind.Single:\n\t\t\t\t\tresult.Append(\"CAST(\");\n\t\t\t\t\tresult.Append(((Single)e.Value).ToString(CultureInfo.InvariantCulture));\n\t\t\t\t\tresult.Append(\" AS \");\n\t\t\t\t\tresult.Append(GetSqlPrimitiveType(e.ResultType));\n\t\t\t\t\tresult.Append(\")\");\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase PrimitiveTypeKind.Decimal:\n\t\t\t\t\tvar sqlPrimitiveType = GetSqlPrimitiveType(e.ResultType);\n\t\t\t\t\tvar strDecimal = ((Decimal)e.Value).ToString(CultureInfo.InvariantCulture);\n\n\t\t\t\t\tvar pointPosition = strDecimal.IndexOf('.');\n\n\t\t\t\t\tvar precision = 9;\n\t\t\t\t\t// there's always the max value in manifest\n\t\t\t\t\tif (MetadataHelpers.TryGetTypeFacetDescriptionByName(e.ResultType.EdmType, MetadataHelpers.PrecisionFacetName, out var precisionFacetDescription))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (precisionFacetDescription.DefaultValue != null)\n\t\t\t\t\t\t\tprecision = (int)precisionFacetDescription.DefaultValue;\n\t\t\t\t\t}\n\n\t\t\t\t\tvar maxScale = (pointPosition != -1 ? precision - pointPosition + 1 : 0);\n\n\t\t\t\t\tresult.Append(\"CAST(\");\n\t\t\t\t\tresult.Append(strDecimal);\n\t\t\t\t\tresult.Append(\" AS \");\n\t\t\t\t\tresult.Append(sqlPrimitiveType.Substring(0, sqlPrimitiveType.IndexOf('(')));\n\t\t\t\t\tresult.Append(\"(\");\n\t\t\t\t\tresult.Append(precision.ToString(CultureInfo.InvariantCulture));\n\t\t\t\t\tresult.Append(\",\");\n\t\t\t\t\tresult.Append(maxScale.ToString(CultureInfo.InvariantCulture));\n\t\t\t\t\tresult.Append(\"))\");\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase PrimitiveTypeKind.Binary:\n\t\t\t\t\tresult.Append(FormatBinary((byte[])e.Value));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase PrimitiveTypeKind.String:\n\t\t\t\t\tvar isUnicode = MetadataHelpers.GetFacetValueOrDefault<bool>(e.ResultType, MetadataHelpers.UnicodeFacetName, true);\n\t\t\t\t\t// constant is always considered Unicode\n\t\t\t\t\tisUnicode = true;\n\t\t\t\t\tvar length = MetadataHelpers.GetFacetValueOrDefault<int?>(e.ResultType, MetadataHelpers.MaxLengthFacetName, null)\n\t\t\t\t\t\t?? (isUnicode ? FbProviderManifest.UnicodeVarcharMaxSize : FbProviderManifest.AsciiVarcharMaxSize);\n\t\t\t\t\tresult.Append(FormatString((string)e.Value, isUnicode, length));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase PrimitiveTypeKind.DateTime:\n\t\t\t\t\tresult.Append(FormatDateTime((DateTime)e.Value));\n\t\t\t\t\tbreak;\n\t\t\t\tcase PrimitiveTypeKind.Time:\n\t\t\t\t\tresult.Append(FormatTime((DateTime)e.Value));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase PrimitiveTypeKind.Guid:\n\t\t\t\t\tresult.Append(FormatGuid((Guid)e.Value));\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\t// all known scalar types should been handled already.\n\t\t\t\t\tthrow new NotSupportedException();\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tthrow new NotSupportedException();\n\t\t}\n\n\t\treturn result;\n\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"DbDerefExpression\"/> is illegal at this stage\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tpublic override ISqlFragment Visit(DbDerefExpression e)\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\n\t/// <summary>\n\t/// The DISTINCT has to be added to the beginning of SqlSelectStatement.Select,\n\t/// but it might be too late for that.  So, we use a flag on SqlSelectStatement\n\t/// instead, and add the \"DISTINCT\" in the second phase.\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlSelectStatement\"/></returns>\n\tpublic override ISqlFragment Visit(DbDistinctExpression e)\n\t{\n\t\tvar result = VisitExpressionEnsureSqlStatement(e.Argument);\n\n\t\tif (!IsCompatible(result, e.ExpressionKind))\n\t\t{\n\t\t\tvar inputType = MetadataHelpers.GetElementTypeUsage(e.Argument.ResultType);\n\t\t\tresult = CreateNewSelectStatement(result, \"DISTINCT\", inputType, out var fromSymbol);\n\t\t\tAddFromSymbol(result, \"DISTINCT\", fromSymbol, false);\n\t\t}\n\n\t\tresult.IsDistinct = true;\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// An element expression returns a scalar - so it is translated to\n\t/// ( Select ... )\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tpublic override ISqlFragment Visit(DbElementExpression e)\n\t{\n\t\tvar result = new SqlBuilder();\n\t\tresult.Append(\"(\");\n\t\tresult.Append(VisitExpressionEnsureSqlStatement(e.Argument));\n\t\tresult.Append(\")\");\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"Visit(DbUnionAllExpression)\"/>\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tpublic override ISqlFragment Visit(DbExceptExpression e)\n\t{\n\t\tthrow new NotSupportedException(\"The EXCEPT statement is not supported in Firebird.\");\n\t\t//return VisitSetOpExpression(e.Left, e.Right, \"EXCEPT\");\n\t}\n\n\t/// <summary>\n\t/// Only concrete expression types will be visited.\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tpublic override ISqlFragment Visit(DbExpression e)\n\t{\n\t\tthrow new InvalidOperationException();\n\t}\n\n\t/// <summary>\n\t///\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>If we are in a Join context, returns a <see cref=\"SqlBuilder\"/>\n\t/// with the extent name, otherwise, a new <see cref=\"SqlSelectStatement\"/>\n\t/// with the From field set.</returns>\n\tpublic override ISqlFragment Visit(DbScanExpression e)\n\t{\n\t\tvar target = e.Target;\n\n\t\tif (IsParentAJoin)\n\t\t{\n\t\t\tvar result = new SqlBuilder();\n\t\t\tresult.Append(GetTargetSql(target));\n\n\t\t\treturn result;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tvar result = new SqlSelectStatement();\n\t\t\tresult.From.Append(GetTargetSql(target));\n\n\t\t\treturn result;\n\t\t}\n\t}\n\n\n\t/// <summary>\n\t/// Gets escaped SQL identifier describing this entity set.\n\t/// </summary>\n\t/// <returns></returns>\n\tinternal static string GetTargetSql(EntitySetBase entitySetBase)\n\t{\n\t\t// construct escaped SQL referencing entity set\n\t\tvar builder = new StringBuilder();\n\t\tvar definingQuery = MetadataHelpers.TryGetValueForMetadataProperty<string>(entitySetBase, \"DefiningQuery\");\n\t\tif (!string.IsNullOrEmpty(definingQuery))\n\t\t{\n\t\t\tbuilder.Append(\"(\");\n\t\t\tbuilder.Append(definingQuery);\n\t\t\tbuilder.Append(\")\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\t/// No schema in FB\n\t\t\t//string schemaName = MetadataHelpers.TryGetValueForMetadataProperty<string>(entitySetBase, \"Schema\");\n\t\t\t//if (!string.IsNullOrEmpty(schemaName))\n\t\t\t//{\n\t\t\t//    builder.Append(QuoteIdentifier(schemaName));\n\t\t\t//    builder.Append(\".\");\n\t\t\t//}\n\t\t\t//else\n\t\t\t//{\n\t\t\t//    builder.Append(QuoteIdentifier(entitySetBase.EntityContainer.Name));\n\t\t\t//    builder.Append(\".\");\n\t\t\t//}\n\n\t\t\tbuilder.Append(QuoteIdentifier(MetadataHelpers.GetTableName(entitySetBase)));\n\t\t}\n\t\treturn builder.ToString();\n\t}\n\n\t/// <summary>\n\t/// The bodies of <see cref=\"Visit(DbFilterExpression)\"/>, <see cref=\"Visit(DbGroupByExpression)\"/>,\n\t/// <see cref=\"Visit(DbProjectExpression)\"/>, <see cref=\"Visit(DbSortExpression)\"/> are similar.\n\t/// Each does the following.\n\t/// <list type=\"number\">\n\t/// <item> Visit the input expression</item>\n\t/// <item> Determine if the input's SQL statement can be reused, or a new\n\t/// one must be created.</item>\n\t/// <item>Create a new symbol table scope</item>\n\t/// <item>Push the Sql statement onto a stack, so that children can\n\t/// update the free variable list.</item>\n\t/// <item>Visit the non-input expression.</item>\n\t/// <item>Cleanup</item>\n\t/// </list>\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlSelectStatement\"/></returns>\n\tpublic override ISqlFragment Visit(DbFilterExpression e)\n\t{\n\t\treturn VisitFilterExpression(e.Input, e.Predicate, false);\n\t}\n\n\t/// <summary>\n\t/// Lambda functions are not supported.\n\t/// The functions supported are:\n\t/// <list type=\"number\">\n\t/// <item>Canonical Functions - We recognize these by their dataspace, it is DataSpace.CSpace</item>\n\t/// <item>Store Functions - We recognize these by the BuiltInAttribute and not being Canonical</item>\n\t/// <item>User-defined Functions - All the rest except for Lambda functions</item>\n\t/// </list>\n\t/// We handle Canonical and Store functions the same way: If they are in the list of functions\n\t/// that need special handling, we invoke the appropriate handler, otherwise we translate them to\n\t/// FunctionName(arg1, arg2, ..., argn).\n\t/// We translate user-defined functions to NamespaceName.FunctionName(arg1, arg2, ..., argn).\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/></returns>\n\tpublic override ISqlFragment Visit(DbFunctionExpression e)\n\t{\n\t\t//\n\t\t// check if function requires special case processing, if so, delegates to it\n\t\t//\n\t\tif (IsSpecialBuiltInFunction(e))\n\t\t{\n\t\t\treturn HandleSpecialBuiltInFunction(e);\n\t\t}\n\n\t\tif (IsSpecialCanonicalFunction(e))\n\t\t{\n\t\t\treturn HandleSpecialCanonicalFunction(e);\n\t\t}\n\n\t\treturn HandleFunctionDefault(e);\n\t}\n\n\n\t/// <summary>\n\t/// <see cref=\"DbEntityRefExpression\"/> is illegal at this stage\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tpublic override ISqlFragment Visit(DbEntityRefExpression e)\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"DbRefKeyExpression\"/> is illegal at this stage\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tpublic override ISqlFragment Visit(DbRefKeyExpression e)\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"Visit(DbFilterExpression)\"/> for general details.\n\t/// We modify both the GroupBy and the Select fields of the SqlSelectStatement.\n\t/// GroupBy gets just the keys without aliases,\n\t/// and Select gets the keys and the aggregates with aliases.\n\t///\n\t/// Whenever there exists at least one aggregate with an argument that is not is not a simple\n\t/// <see cref=\"DbPropertyExpression\"/>  over <see cref=\"DbVariableReferenceExpression\"/>,\n\t/// we create a nested query in which we alias the arguments to the aggregates.\n\t/// That is due to the following two limitations of Sql Server:\n\t/// <list type=\"number\">\n\t/// <item>If an expression being aggregated contains an outer reference, then that outer\n\t/// reference must be the only column referenced in the expression </item>\n\t/// <item>Sql Server cannot perform an aggregate function on an expression containing\n\t/// an aggregate or a subquery. </item>\n\t/// </list>\n\t///\n\t/// The default translation, without inner query is:\n\t///\n\t///     SELECT\n\t///         kexp1 AS key1, kexp2 AS key2,... kexpn AS keyn,\n\t///         aggf1(aexpr1) AS agg1, .. aggfn(aexprn) AS aggn\n\t///     FROM input AS a\n\t///     GROUP BY kexp1, kexp2, .. kexpn\n\t///\n\t/// When we inject an innner query, the equivalent translation is:\n\t///\n\t///     SELECT\n\t///         key1 AS key1, key2 AS key2, .. keyn AS keys,\n\t///         aggf1(agg1) AS agg1, aggfn(aggn) AS aggn\n\t///     FROM (\n\t///             SELECT\n\t///                 kexp1 AS key1, kexp2 AS key2,... kexpn AS keyn,\n\t///                 aexpr1 AS agg1, .. aexprn AS aggn\n\t///             FROM input AS a\n\t///         ) as a\n\t///     GROUP BY key1, key2, keyn\n\t///\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlSelectStatement\"/></returns>\n\tpublic override ISqlFragment Visit(DbGroupByExpression e)\n\t{\n\t\tvar varName = GetShortenedName(e.Input.VariableName);\n\t\tvar innerQuery = VisitInputExpression(e.Input.Expression,\n\t\t\tvarName, e.Input.VariableType, out var fromSymbol);\n\n\t\t// GroupBy is compatible with Filter and OrderBy\n\t\t// but not with Project, GroupBy\n\t\tif (!IsCompatible(innerQuery, e.ExpressionKind))\n\t\t{\n\t\t\tinnerQuery = CreateNewSelectStatement(innerQuery, varName, e.Input.VariableType, out fromSymbol);\n\t\t}\n\n\t\t_selectStatementStack.Push(innerQuery);\n\t\t_symbolTable.EnterScope();\n\n\t\tAddFromSymbol(innerQuery, varName, fromSymbol);\n\t\t// This line is not present for other relational nodes.\n\t\t_symbolTable.Add(GetShortenedName(e.Input.GroupVariableName), fromSymbol);\n\n\n\t\t// The enumerator is shared by both the keys and the aggregates,\n\t\t// so, we do not close it in between.\n\t\tvar groupByType = MetadataHelpers.GetEdmType<RowType>(MetadataHelpers.GetEdmType<CollectionType>(e.ResultType).TypeUsage);\n\n\t\t// Whenever there exists at least one aggregate with an argument that is not simply a PropertyExpression\n\t\t// over a VarRefExpression, we need a nested query in which we alias the arguments to the aggregates.\n\t\tvar needsInnerQuery = NeedsInnerQuery(e.Aggregates);\n\n\t\tSqlSelectStatement result;\n\t\tif (needsInnerQuery)\n\t\t{\n\t\t\t//Create the inner query\n\t\t\tresult = CreateNewSelectStatement(innerQuery, varName, e.Input.VariableType, false, out fromSymbol);\n\t\t\tAddFromSymbol(result, varName, fromSymbol, false);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tresult = innerQuery;\n\t\t}\n\n\t\tusing (IEnumerator<EdmProperty> members = groupByType.Properties.GetEnumerator())\n\t\t{\n\t\t\tmembers.MoveNext();\n\t\t\tDebug.Assert(result.Select.IsEmpty);\n\n\t\t\tvar separator = string.Empty;\n\n\t\t\tforeach (var key in e.Keys)\n\t\t\t{\n\t\t\t\tvar member = members.Current;\n\t\t\t\tvar alias = QuoteIdentifier(member.Name);\n\n\t\t\t\tresult.GroupBy.Append(separator);\n\n\t\t\t\tvar keySql = key.Accept(this);\n\n\t\t\t\tif (!needsInnerQuery)\n\t\t\t\t{\n\t\t\t\t\t//Default translation: Key AS Alias\n\t\t\t\t\tresult.Select.Append(separator);\n\t\t\t\t\tresult.Select.AppendLine();\n\t\t\t\t\tresult.Select.Append(keySql);\n\t\t\t\t\tresult.Select.Append(\" AS \");\n\t\t\t\t\tresult.Select.Append(alias);\n\n\t\t\t\t\tresult.GroupBy.Append(keySql);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t// The inner query contains the default translation Key AS Alias\n\t\t\t\t\tinnerQuery.Select.Append(separator);\n\t\t\t\t\tinnerQuery.Select.AppendLine();\n\t\t\t\t\tinnerQuery.Select.Append(keySql);\n\t\t\t\t\tinnerQuery.Select.Append(\" AS \");\n\t\t\t\t\tinnerQuery.Select.Append(alias);\n\n\t\t\t\t\t//The outer resulting query projects over the key aliased in the inner query:\n\t\t\t\t\t//  fromSymbol.Alias AS Alias\n\t\t\t\t\tresult.Select.Append(separator);\n\t\t\t\t\tresult.Select.AppendLine();\n\t\t\t\t\tresult.Select.Append(fromSymbol);\n\t\t\t\t\tresult.Select.Append(\".\");\n\t\t\t\t\tresult.Select.Append(alias);\n\t\t\t\t\tresult.Select.Append(\" AS \");\n\t\t\t\t\tresult.Select.Append(alias);\n\n\t\t\t\t\tresult.GroupBy.Append(alias);\n\t\t\t\t}\n\n\t\t\t\tseparator = \", \";\n\t\t\t\tmembers.MoveNext();\n\t\t\t}\n\n\t\t\tforeach (var aggregate in e.Aggregates)\n\t\t\t{\n\t\t\t\tvar member = members.Current;\n\t\t\t\tvar alias = QuoteIdentifier(member.Name);\n\n\t\t\t\tDebug.Assert(aggregate.Arguments.Count == 1);\n\t\t\t\tvar translatedAggregateArgument = aggregate.Arguments[0].Accept(this);\n\n\t\t\t\tobject aggregateArgument;\n\n\t\t\t\tif (needsInnerQuery)\n\t\t\t\t{\n\t\t\t\t\t//In this case the argument to the aggratete is reference to the one projected out by the\n\t\t\t\t\t// inner query\n\t\t\t\t\tvar wrappingAggregateArgument = new SqlBuilder();\n\t\t\t\t\twrappingAggregateArgument.Append(fromSymbol);\n\t\t\t\t\twrappingAggregateArgument.Append(\".\");\n\t\t\t\t\twrappingAggregateArgument.Append(alias);\n\t\t\t\t\taggregateArgument = wrappingAggregateArgument;\n\n\t\t\t\t\tinnerQuery.Select.Append(separator);\n\t\t\t\t\tinnerQuery.Select.AppendLine();\n\t\t\t\t\tinnerQuery.Select.Append(translatedAggregateArgument);\n\t\t\t\t\tinnerQuery.Select.Append(\" AS \");\n\t\t\t\t\tinnerQuery.Select.Append(alias);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\taggregateArgument = translatedAggregateArgument;\n\t\t\t\t}\n\n\t\t\t\tISqlFragment aggregateResult = VisitAggregate(aggregate, aggregateArgument);\n\n\t\t\t\tresult.Select.Append(separator);\n\t\t\t\tresult.Select.AppendLine();\n\t\t\t\tresult.Select.Append(aggregateResult);\n\t\t\t\tresult.Select.Append(\" AS \");\n\t\t\t\tresult.Select.Append(alias);\n\n\t\t\t\tseparator = \", \";\n\t\t\t\tmembers.MoveNext();\n\t\t\t}\n\t\t}\n\n\n\t\t_symbolTable.ExitScope();\n\t\t_selectStatementStack.Pop();\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"Visit(DbUnionAllExpression)\"/>\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tpublic override ISqlFragment Visit(DbIntersectExpression e)\n\t{\n\t\tthrow new NotSupportedException(\"The INTERSECT statement is not supported in Firebird.\");\n\t\t//return VisitSetOpExpression(e.Left, e.Right, \"INTERSECT\");\n\t}\n\n\t/// <summary>\n\t/// Not(IsEmpty) has to be handled specially, so we delegate to\n\t/// <see cref=\"VisitIsEmptyExpression\"/>.\n\t///\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/>.\n\t/// <code>[NOT] EXISTS( ... )</code>\n\t/// </returns>\n\tpublic override ISqlFragment Visit(DbIsEmptyExpression e)\n\t{\n\t\treturn VisitIsEmptyExpression(e, false);\n\t}\n\n\t/// <summary>\n\t/// Not(IsNull) is handled specially, so we delegate to\n\t/// <see cref=\"VisitIsNullExpression\"/>\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/>\n\t/// <code>IS [NOT] NULL</code>\n\t/// </returns>\n\tpublic override ISqlFragment Visit(DbIsNullExpression e)\n\t{\n\t\treturn VisitIsNullExpression(e, false);\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"DbIsOfExpression\"/> is illegal at this stage\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/></returns>\n\tpublic override ISqlFragment Visit(DbIsOfExpression e)\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"VisitJoinExpression\"/>\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlSelectStatement\"/>.</returns>\n\tpublic override ISqlFragment Visit(DbCrossJoinExpression e)\n\t{\n\t\treturn VisitJoinExpression(e.Inputs, e.ExpressionKind, \"CROSS JOIN\", null);\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"VisitJoinExpression\"/>\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlSelectStatement\"/>.</returns>\n\tpublic override ISqlFragment Visit(DbJoinExpression e)\n\t{\n\t\t#region Map join type to a string\n\t\tstring joinString;\n\t\tswitch (e.ExpressionKind)\n\t\t{\n\t\t\tcase DbExpressionKind.FullOuterJoin:\n\t\t\t\tjoinString = \"FULL OUTER JOIN\";\n\t\t\t\tbreak;\n\n\t\t\tcase DbExpressionKind.InnerJoin:\n\t\t\t\tjoinString = \"INNER JOIN\";\n\t\t\t\tbreak;\n\n\t\t\tcase DbExpressionKind.LeftOuterJoin:\n\t\t\t\tjoinString = \"LEFT OUTER JOIN\";\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tDebug.Assert(false);\n\t\t\t\tjoinString = null;\n\t\t\t\tbreak;\n\t\t}\n\t\t#endregion\n\n\t\tvar inputs = new List<DbExpressionBinding>(2);\n\t\tinputs.Add(e.Left);\n\t\tinputs.Add(e.Right);\n\n\t\treturn VisitJoinExpression(inputs, e.ExpressionKind, joinString, e.JoinCondition);\n\t}\n\n\t/// <summary>\n\t///\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/></returns>\n\tpublic override ISqlFragment Visit(DbLikeExpression e)\n\t{\n\t\tvar result = new SqlBuilder();\n\n\t\tif (!(e.Argument is DbParameterReferenceExpression && e.Pattern is DbParameterReferenceExpression))\n\t\t{\n\t\t\t_shouldCastParameter = false;\n\t\t}\n\n\t\tresult.Append(e.Argument.Accept(this));\n\t\tresult.Append(\" LIKE \");\n\t\tresult.Append(e.Pattern.Accept(this));\n\n\t\t// if the ESCAPE expression is a DbNullExpression, then that's tantamount to\n\t\t// not having an ESCAPE at all\n\t\tif (e.Escape.ExpressionKind != DbExpressionKind.Null)\n\t\t{\n\t\t\tresult.Append(\" ESCAPE \");\n\t\t\tresult.Append(e.Escape.Accept(this));\n\t\t}\n\n\t\t_shouldCastParameter = true;\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t///  Translates to TOP expression.\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/></returns>\n\tpublic override ISqlFragment Visit(DbLimitExpression e)\n\t{\n\t\tDebug.Assert(e.Limit is DbConstantExpression || e.Limit is DbParameterReferenceExpression, \"DbLimitExpression.Limit is of invalid expression type\");\n\n\t\tvar result = VisitExpressionEnsureSqlStatement(e.Argument, false);\n\n\t\tif (!IsCompatible(result, e.ExpressionKind))\n\t\t{\n\t\t\tvar inputType = MetadataHelpers.GetElementTypeUsage(e.Argument.ResultType);\n\n\t\t\tresult = CreateNewSelectStatement(result, \"top\", inputType, out var fromSymbol);\n\t\t\tAddFromSymbol(result, \"top\", fromSymbol, false);\n\t\t}\n\n\t\tvar topCount = HandleCountExpression(e.Limit);\n\n\t\tresult.First = new FirstClause(topCount);\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// DbNewInstanceExpression is allowed as a child of DbProjectExpression only.\n\t/// If anyone else is the parent, we throw.\n\t/// We also perform special casing for collections - where we could convert\n\t/// them into Unions\n\t///\n\t/// <see cref=\"VisitNewInstanceExpression\"/> for the actual implementation.\n\t///\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tpublic override ISqlFragment Visit(DbNewInstanceExpression e)\n\t{\n\t\tif (MetadataHelpers.IsCollectionType(e.ResultType))\n\t\t{\n\t\t\treturn VisitCollectionConstructor(e);\n\t\t}\n\t\tthrow new NotSupportedException();\n\t}\n\n\t/// <summary>\n\t/// The Not expression may cause the translation of its child to change.\n\t/// These children are\n\t/// <list type=\"bullet\">\n\t/// <item><see cref=\"DbNotExpression\"/>NOT(Not(x)) becomes x</item>\n\t/// <item><see cref=\"DbIsEmptyExpression\"/>NOT EXISTS becomes EXISTS</item>\n\t/// <item><see cref=\"DbIsNullExpression\"/>IS NULL becomes IS NOT NULL</item>\n\t/// <item><see cref=\"DbComparisonExpression\"/>= becomes&lt;&gt; </item>\n\t/// </list>\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/></returns>\n\tpublic override ISqlFragment Visit(DbNotExpression e)\n\t{\n\t\t// Flatten Not(Not(x)) to x.\n\t\tif (e.Argument is DbNotExpression notExpression)\n\t\t{\n\t\t\treturn notExpression.Argument.Accept(this);\n\t\t}\n\n\t\tif (e.Argument is DbIsEmptyExpression isEmptyExpression)\n\t\t{\n\t\t\treturn VisitIsEmptyExpression(isEmptyExpression, true);\n\t\t}\n\n\t\tif (e.Argument is DbIsNullExpression isNullExpression)\n\t\t{\n\t\t\treturn VisitIsNullExpression(isNullExpression, true);\n\t\t}\n\n\t\tif (e.Argument is DbComparisonExpression comparisonExpression)\n\t\t{\n\t\t\tif (comparisonExpression.ExpressionKind == DbExpressionKind.Equals)\n\t\t\t{\n\t\t\t\treturn VisitBinaryExpression(\" <> \", comparisonExpression.Left, comparisonExpression.Right);\n\t\t\t}\n\t\t}\n\n\t\tvar result = new SqlBuilder();\n\t\tresult.Append(\" NOT (\");\n\t\tresult.Append(e.Argument.Accept(this));\n\t\tresult.Append(\")\");\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns><see cref=\"SqlBuilder\"/></returns>\n\tpublic override ISqlFragment Visit(DbNullExpression e)\n\t{\n\t\tvar result = new SqlBuilder();\n\t\tresult.Append(\"NULL\");\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"DbOfTypeExpression\"/> is illegal at this stage\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/></returns>\n\tpublic override ISqlFragment Visit(DbOfTypeExpression e)\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\n\t/// <summary>\n\t///\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/></returns>\n\t/// <seealso cref=\"Visit(DbAndExpression)\"/>\n\tpublic override ISqlFragment Visit(DbOrExpression e)\n\t{\n\t\treturn VisitBinaryExpression(\" OR \", e.Left, e.Right);\n\t}\n\n\t/// <summary>\n\t///\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/></returns>\n\tpublic override ISqlFragment Visit(DbParameterReferenceExpression e)\n\t{\n\t\tvar result = new SqlBuilder();\n\n\t\tstring sqlPrimitiveType = null;\n\t\tif (_shouldCastParameter)\n\t\t{\n\t\t\tsqlPrimitiveType = GetSqlPrimitiveType(e.ResultType);\n\t\t\tresult.Append(\"CAST(\");\n\t\t}\n\t\t// Do not quote this name.\n\t\t// We are not checking that e.Name has no illegal characters. e.g. space\n\t\tresult.Append(\"@\" + e.ParameterName);\n\t\tif (_shouldCastParameter)\n\t\t{\n\t\t\tresult.Append(\" AS \");\n\t\t\tresult.Append(sqlPrimitiveType);\n\t\t\tresult.Append(\")\");\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"Visit(DbFilterExpression)\"/> for the general ideas.\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlSelectStatement\"/></returns>\n\t/// <seealso cref=\"Visit(DbFilterExpression)\"/>\n\tpublic override ISqlFragment Visit(DbProjectExpression e)\n\t{\n\t\tvar varName = GetShortenedName(e.Input.VariableName);\n\t\tvar result = VisitInputExpression(e.Input.Expression, varName, e.Input.VariableType, out var fromSymbol);\n\n\t\t// Project is compatible with Filter\n\t\t// but not with Project, GroupBy\n\t\tif (!IsCompatible(result, e.ExpressionKind))\n\t\t{\n\t\t\tresult = CreateNewSelectStatement(result, varName, e.Input.VariableType, out fromSymbol);\n\t\t}\n\n\t\t_selectStatementStack.Push(result);\n\t\t_symbolTable.EnterScope();\n\n\t\tAddFromSymbol(result, varName, fromSymbol);\n\n\t\t// Project is the only node that can have DbNewInstanceExpression as a child\n\t\t// so we have to check it here.\n\t\t// We call VisitNewInstanceExpression instead of Visit(DbNewInstanceExpression), since\n\t\t// the latter throws.\n\t\tif (e.Projection is DbNewInstanceExpression newInstanceExpression)\n\t\t{\n\t\t\tresult.Select.Append(VisitNewInstanceExpression(newInstanceExpression));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tresult.Select.Append(e.Projection.Accept(this));\n\t\t}\n\n\t\t_symbolTable.ExitScope();\n\t\t_selectStatementStack.Pop();\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// This method handles record flattening, which works as follows.\n\t/// consider an expression <c>Prop(y, Prop(x, Prop(d, Prop(c, Prop(b, Var(a)))))</c>\n\t/// where a,b,c are joins, d is an extent and x and y are fields.\n\t/// b has been flattened into a, and has its own SELECT statement.\n\t/// c has been flattened into b.\n\t/// d has been flattened into c.\n\t///\n\t/// We visit the instance, so we reach Var(a) first.  This gives us a (join)symbol.\n\t/// Symbol(a).b gives us a join symbol, with a SELECT statement i.e. Symbol(b).\n\t/// From this point on , we need to remember Symbol(b) as the source alias,\n\t/// and then try to find the column.  So, we use a SymbolPair.\n\t///\n\t/// We have reached the end when the symbol no longer points to a join symbol.\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"JoinSymbol\"/> if we have not reached the first\n\t/// Join node that has a SELECT statement.\n\t/// A <see cref=\"SymbolPair\"/> if we have seen the JoinNode, and it has\n\t/// a SELECT statement.\n\t/// A <see cref=\"SqlBuilder\"/> with {Input}.propertyName otherwise.\n\t/// </returns>\n\tpublic override ISqlFragment Visit(DbPropertyExpression e)\n\t{\n\t\tSqlBuilder result;\n\t\tvar varName = e.Property.Name;\n\n\t\tvar instanceSql = e.Instance.Accept(this);\n\n\t\t// Since the DbVariableReferenceExpression is a proper child of ours, we can reset\n\t\t// isVarSingle.\n\t\tif (e.Instance is DbVariableReferenceExpression DbVariableReferenceExpression)\n\t\t{\n\t\t\t_isVarRefSingle = false;\n\t\t}\n\n\t\t// We need to flatten, and have not yet seen the first nested SELECT statement.\n\t\tif (instanceSql is JoinSymbol joinSymbol)\n\t\t{\n\t\t\tvarName = GetShortenedName(varName);\n\t\t\tDebug.Assert(joinSymbol.NameToExtent.ContainsKey(varName));\n\t\t\tif (joinSymbol.IsNestedJoin)\n\t\t\t{\n\t\t\t\treturn new SymbolPair(joinSymbol, joinSymbol.NameToExtent[varName]);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn joinSymbol.NameToExtent[varName];\n\t\t\t}\n\t\t}\n\t\t// ---------------------------------------\n\t\t// We have seen the first nested SELECT statement, but not the column.\n\t\tif (instanceSql is SymbolPair symbolPair)\n\t\t{\n\t\t\tvarName = GetShortenedName(varName);\n\t\t\tif (symbolPair.Column is JoinSymbol columnJoinSymbol)\n\t\t\t{\n\t\t\t\tDebug.Assert(columnJoinSymbol.NameToExtent.ContainsKey(varName));\n\t\t\t\tsymbolPair.Column = columnJoinSymbol.NameToExtent[varName];\n\t\t\t\treturn symbolPair;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// symbolPair.Column has the base extent.\n\t\t\t\t// we need the symbol for the column, since it might have been renamed\n\t\t\t\t// when handling a JOIN.\n\t\t\t\tif (symbolPair.Column.Columns.ContainsKey(e.Property.Name))\n\t\t\t\t{\n\t\t\t\t\tresult = new SqlBuilder();\n\t\t\t\t\tresult.Append(symbolPair.Source);\n\t\t\t\t\tresult.Append(\".\");\n\t\t\t\t\tresult.Append(symbolPair.Column.Columns[e.Property.Name]);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// ---------------------------------------\n\n\t\tresult = new SqlBuilder();\n\t\tresult.Append(instanceSql);\n\t\tresult.Append(\".\");\n\n\t\t// At this point the column name cannot be renamed, so we do\n\t\t// not use a symbol.\n\t\tresult.Append(QuoteIdentifier(varName));\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// Any(input, x) => Exists(Filter(input,x))\n\t/// All(input, x) => Not Exists(Filter(input, not(x))\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tpublic override ISqlFragment Visit(DbQuantifierExpression e)\n\t{\n\t\tvar result = new SqlBuilder();\n\n\t\tvar negatePredicate = (e.ExpressionKind == DbExpressionKind.All);\n\t\tif (e.ExpressionKind == DbExpressionKind.Any)\n\t\t{\n\t\t\tresult.Append(\"EXISTS (\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tDebug.Assert(e.ExpressionKind == DbExpressionKind.All);\n\t\t\tresult.Append(\"NOT EXISTS (\");\n\t\t}\n\n\t\tvar filter = VisitFilterExpression(e.Input, e.Predicate, negatePredicate);\n\t\tif (filter.Select.IsEmpty)\n\t\t{\n\t\t\tAddDefaultColumns(filter);\n\t\t}\n\n\t\tresult.Append(filter);\n\t\tresult.Append(\")\");\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"DbRefExpression\"/> is illegal at this stage\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tpublic override ISqlFragment Visit(DbRefExpression e)\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"DbRelationshipNavigationExpression\"/> is illegal at this stage\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tpublic override ISqlFragment Visit(DbRelationshipNavigationExpression e)\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\n\t/// <summary>\n\t///  Translates to SKIP expression.\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/></returns>\n\tpublic override ISqlFragment Visit(DbSkipExpression e)\n\t{\n\t\tDebug.Assert(e.Count is DbConstantExpression || e.Count is DbParameterReferenceExpression, \"DbSkipExpression.Count is of invalid expression type\");\n\n\t\tvar varName = GetShortenedName(e.Input.VariableName);\n\t\tvar result = VisitInputExpression(e.Input.Expression, varName, e.Input.VariableType, out var fromSymbol);\n\n\t\tif (!IsCompatible(result, e.ExpressionKind))\n\t\t{\n\t\t\tvar inputType = MetadataHelpers.GetElementTypeUsage(e.ResultType);\n\n\t\t\tresult = CreateNewSelectStatement(result, varName, inputType, out fromSymbol);\n\t\t\tAddFromSymbol(result, varName, fromSymbol, false);\n\t\t}\n\n\t\tvar skipCount = HandleCountExpression(e.Count);\n\n\t\tresult.Skip = new SkipClause(skipCount);\n\n\t\t_selectStatementStack.Push(result);\n\t\t_symbolTable.EnterScope();\n\n\t\tAddFromSymbol(result, varName, fromSymbol);\n\n\t\tAddSortKeys(result.OrderBy, e.SortOrder);\n\n\t\t_symbolTable.ExitScope();\n\t\t_selectStatementStack.Pop();\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"Visit(DbFilterExpression)\"/>\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlSelectStatement\"/></returns>\n\t/// <seealso cref=\"Visit(DbFilterExpression)\"/>\n\tpublic override ISqlFragment Visit(DbSortExpression e)\n\t{\n\t\tvar varName = GetShortenedName(e.Input.VariableName);\n\t\tvar result = VisitInputExpression(e.Input.Expression, varName, e.Input.VariableType, out var fromSymbol);\n\n\t\t// OrderBy is compatible with Filter\n\t\t// and nothing else\n\t\tif (!IsCompatible(result, e.ExpressionKind))\n\t\t{\n\t\t\tresult = CreateNewSelectStatement(result, varName, e.Input.VariableType, out fromSymbol);\n\t\t}\n\n\t\t_selectStatementStack.Push(result);\n\t\t_symbolTable.EnterScope();\n\n\t\tAddFromSymbol(result, varName, fromSymbol);\n\n\t\tAddSortKeys(result.OrderBy, e.SortOrder);\n\n\t\t_symbolTable.ExitScope();\n\t\t_selectStatementStack.Pop();\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"DbTreatExpression\"/> is illegal at this stage\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"SqlBuilder\"/></returns>\n\tpublic override ISqlFragment Visit(DbTreatExpression e)\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\n\t/// <summary>\n\t/// This code is shared by <see cref=\"Visit(DbExceptExpression)\"/>\n\t/// and <see cref=\"Visit(DbIntersectExpression)\"/>\n\t///\n\t/// <see cref=\"VisitSetOpExpression\"/>\n\t/// Since the left and right expression may not be Sql select statements,\n\t/// we must wrap them up to look like SQL select statements.\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tpublic override ISqlFragment Visit(DbUnionAllExpression e)\n\t{\n\t\treturn VisitSetOpExpression(e.Left, e.Right, \"UNION ALL\");\n\t}\n\n\t/// <summary>\n\t/// This method determines whether an extent from an outer scope(free variable)\n\t/// is used in the CurrentSelectStatement.\n\t///\n\t/// An extent in an outer scope, if its symbol is not in the FromExtents\n\t/// of the CurrentSelectStatement.\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>A <see cref=\"Symbol\"/>.</returns>\n\tpublic override ISqlFragment Visit(DbVariableReferenceExpression e)\n\t{\n\t\tif (_isVarRefSingle)\n\t\t{\n\t\t\tthrow new NotSupportedException();\n\t\t\t// A DbVariableReferenceExpression has to be a child of DbPropertyExpression or MethodExpression\n\t\t\t// This is also checked in GenerateSql(...) at the end of the visiting.\n\t\t}\n\t\t_isVarRefSingle = true; // This will be reset by DbPropertyExpression or MethodExpression\n\n\t\tvar varName = GetShortenedName(e.VariableName);\n\t\tvar result = _symbolTable.Lookup(varName);\n\t\tif (!CurrentSelectStatement.FromExtents.Contains(result))\n\t\t{\n\t\t\tCurrentSelectStatement.OuterExtents[result] = true;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tpublic override ISqlFragment Visit(DbInExpression e)\n\t{\n\t\tvar result = new SqlBuilder();\n\n\t\tresult.Append(e.Item.Accept(this));\n\t\tresult.Append(\" IN (\");\n\n\t\tvar separator = string.Empty;\n\t\tforeach (var item in e.List)\n\t\t{\n\t\t\tresult.Append(separator);\n\t\t\tresult.Append(item.Accept(this));\n\n\t\t\tseparator = \",\";\n\t\t}\n\n\t\tresult.Append(\")\");\n\n\t\treturn result;\n\t}\n\n\t#region Visits shared by multiple nodes\n\t/// <summary>\n\t/// Aggregates are not visited by the normal visitor walk.\n\t/// </summary>\n\t/// <param name=\"aggregate\">The aggreate go be translated</param>\n\t/// <param name=\"aggregateArgument\">The translated aggregate argument</param>\n\t/// <returns></returns>\n\tSqlBuilder VisitAggregate(DbAggregate aggregate, object aggregateArgument)\n\t{\n\t\tvar aggregateResult = new SqlBuilder();\n\n\t\tif (!(aggregate is DbFunctionAggregate functionAggregate))\n\t\t{\n\t\t\tthrow new NotSupportedException();\n\t\t}\n\n\t\tif (MetadataHelpers.IsCanonicalFunction(functionAggregate.Function) && (\n\t\t\tstring.Equals(functionAggregate.Function.Name, \"StDev\", StringComparison.Ordinal) ||\n\t\t\tstring.Equals(functionAggregate.Function.Name, \"StDevP\", StringComparison.Ordinal) ||\n\t\t\tstring.Equals(functionAggregate.Function.Name, \"Var\", StringComparison.Ordinal) ||\n\t\t\tstring.Equals(functionAggregate.Function.Name, \"VarP\", StringComparison.Ordinal)))\n\t\t{\n\t\t\tthrow new NotSupportedException();\n\t\t}\n\n\t\tWriteFunctionName(aggregateResult, functionAggregate.Function);\n\n\t\taggregateResult.Append(\"(\");\n\n\t\tif (functionAggregate.Distinct)\n\t\t{\n\t\t\taggregateResult.Append(\"DISTINCT \");\n\t\t}\n\n\t\taggregateResult.Append(aggregateArgument);\n\n\t\taggregateResult.Append(\")\");\n\t\treturn aggregateResult;\n\t}\n\n\n\tSqlBuilder VisitBinaryExpression(string op, DbExpression left, DbExpression right)\n\t{\n\t\tvar result = new SqlBuilder();\n\n\t\tif (!(left is DbParameterReferenceExpression && right is DbParameterReferenceExpression))\n\t\t{\n\t\t\t_shouldCastParameter = false;\n\t\t}\n\n\t\tif (IsComplexExpression(left))\n\t\t{\n\t\t\tresult.Append(\"(\");\n\t\t}\n\n\t\tresult.Append(left.Accept(this));\n\n\t\tif (IsComplexExpression(left))\n\t\t{\n\t\t\tresult.Append(\")\");\n\t\t}\n\n\t\tif (_shouldHandleBoolComparison)\n\t\t{\n\t\t\tresult.Append(op);\n\n\t\t\tif (IsComplexExpression(right))\n\t\t\t{\n\t\t\t\tresult.Append(\"(\");\n\t\t\t}\n\n\t\t\tresult.Append(right.Accept(this));\n\n\t\t\tif (IsComplexExpression(right))\n\t\t\t{\n\t\t\t\tresult.Append(\")\");\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\t_shouldHandleBoolComparison = true;\n\t\t}\n\n\t\t_shouldCastParameter = true;\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// This is called by the relational nodes.  It does the following\n\t/// <list>\n\t/// <item>If the input is not a SqlSelectStatement, it assumes that the input\n\t/// is a collection expression, and creates a new SqlSelectStatement </item>\n\t/// </list>\n\t/// </summary>\n\t/// <param name=\"inputExpression\"></param>\n\t/// <param name=\"inputVarName\"></param>\n\t/// <param name=\"inputVarType\"></param>\n\t/// <param name=\"fromSymbol\"></param>\n\t/// <returns>A <see cref=\"SqlSelectStatement\"/> and the main fromSymbol\n\t/// for this select statement.</returns>\n\tSqlSelectStatement VisitInputExpression(DbExpression inputExpression,\n\t\tstring inputVarName, TypeUsage inputVarType, out Symbol fromSymbol)\n\t{\n\t\tSqlSelectStatement result;\n\t\tvar sqlFragment = inputExpression.Accept(this);\n\t\tresult = sqlFragment as SqlSelectStatement;\n\n\t\tif (result == null)\n\t\t{\n\t\t\tresult = new SqlSelectStatement();\n\t\t\tWrapNonQueryExtent(result, sqlFragment, inputExpression.ExpressionKind);\n\t\t}\n\n\t\tif (result.FromExtents.Count == 0)\n\t\t{\n\t\t\t// input was an extent\n\t\t\tfromSymbol = new Symbol(inputVarName, inputVarType);\n\t\t}\n\t\telse if (result.FromExtents.Count == 1)\n\t\t{\n\t\t\t// input was Filter/GroupBy/Project/OrderBy\n\t\t\t// we are likely to reuse this statement.\n\t\t\tfromSymbol = result.FromExtents[0];\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// input was a join.\n\t\t\t// we are reusing the select statement produced by a Join node\n\t\t\t// we need to remove the original extents, and replace them with a\n\t\t\t// new extent with just the Join symbol.\n\t\t\tvar joinSymbol = new JoinSymbol(inputVarName, inputVarType, result.FromExtents);\n\t\t\tjoinSymbol.FlattenedExtentList = result.AllJoinExtents;\n\n\t\t\tfromSymbol = joinSymbol;\n\t\t\tresult.FromExtents.Clear();\n\t\t\tresult.FromExtents.Add(fromSymbol);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"Visit(DbIsEmptyExpression)\"/>\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <param name=\"negate\">Was the parent a DbNotExpression?</param>\n\t/// <returns></returns>\n\tSqlBuilder VisitIsEmptyExpression(DbIsEmptyExpression e, bool negate)\n\t{\n\t\tvar result = new SqlBuilder();\n\t\tif (!negate)\n\t\t{\n\t\t\tresult.Append(\" NOT\");\n\t\t}\n\t\tresult.Append(\" EXISTS (\");\n\t\tresult.Append(VisitExpressionEnsureSqlStatement(e.Argument));\n\t\tresult.AppendLine();\n\t\tresult.Append(\")\");\n\n\t\treturn result;\n\t}\n\n\n\t/// <summary>\n\t/// Translate a NewInstance(Element(X)) expression into\n\t///   \"select top(1) * from X\"\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tprivate ISqlFragment VisitCollectionConstructor(DbNewInstanceExpression e)\n\t{\n\t\tDebug.Assert(e.Arguments.Count <= 1);\n\n\t\tif (e.Arguments.Count == 1 && e.Arguments[0].ExpressionKind == DbExpressionKind.Element)\n\t\t{\n\t\t\tvar elementExpr = e.Arguments[0] as DbElementExpression;\n\t\t\tvar result = VisitExpressionEnsureSqlStatement(elementExpr.Argument);\n\n\t\t\tif (!IsCompatible(result, DbExpressionKind.Element))\n\t\t\t{\n\t\t\t\tvar inputType = MetadataHelpers.GetElementTypeUsage(elementExpr.Argument.ResultType);\n\n\t\t\t\tresult = CreateNewSelectStatement(result, \"element\", inputType, out var fromSymbol);\n\t\t\t\tAddFromSymbol(result, \"element\", fromSymbol, false);\n\t\t\t}\n\n\t\t\tresult.First = new FirstClause(1);\n\t\t\treturn result;\n\t\t}\n\n\n\t\t// Otherwise simply build this out as a union-all ladder\n\t\tvar collectionType = MetadataHelpers.GetEdmType<CollectionType>(e.ResultType);\n\t\tDebug.Assert(collectionType != null);\n\t\tvar isScalarElement = MetadataHelpers.IsPrimitiveType(collectionType.TypeUsage);\n\n\t\tvar resultSql = new SqlBuilder();\n\t\tvar separator = string.Empty;\n\n\t\t// handle empty table\n\t\tif (e.Arguments.Count == 0)\n\t\t{\n\t\t\tDebug.Assert(isScalarElement);\n\t\t\tresultSql.Append(\" SELECT CAST(NULL AS \");\n\t\t\tresultSql.Append(GetSqlPrimitiveType(collectionType.TypeUsage));\n\t\t\tresultSql.Append(\") AS X FROM (SELECT 1 FROM RDB$DATABASE) WHERE 1=0\");\n\t\t}\n\n\t\tforeach (var arg in e.Arguments)\n\t\t{\n\t\t\tresultSql.Append(separator);\n\t\t\tresultSql.Append(\" SELECT \");\n\t\t\tresultSql.Append(arg.Accept(this));\n\t\t\t// For scalar elements, no alias is appended yet. Add this.\n\t\t\tif (isScalarElement)\n\t\t\t{\n\t\t\t\tresultSql.Append(\" AS X FROM RDB$DATABASE\");\n\t\t\t}\n\t\t\tseparator = \" UNION ALL \";\n\t\t}\n\n\t\treturn resultSql;\n\t}\n\n\n\t/// <summary>\n\t/// <see cref=\"Visit(DbIsNullExpression)\"/>\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <param name=\"negate\">Was the parent a DbNotExpression?</param>\n\t/// <returns></returns>\n\tSqlBuilder VisitIsNullExpression(DbIsNullExpression e, bool negate)\n\t{\n\t\tvar result = new SqlBuilder();\n\t\t_shouldCastParameter = false;\n\t\tresult.Append(e.Argument.Accept(this));\n\t\tif (!negate)\n\t\t{\n\t\t\tresult.Append(\" IS NULL\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tresult.Append(\" IS NOT NULL\");\n\t\t}\n\t\t_shouldCastParameter = true;\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// This handles the processing of join expressions.\n\t/// The extents on a left spine are flattened, while joins\n\t/// not on the left spine give rise to new nested sub queries.\n\t///\n\t/// Joins work differently from the rest of the visiting, in that\n\t/// the parent (i.e. the join node) creates the SqlSelectStatement\n\t/// for the children to use.\n\t///\n\t/// The \"parameter\" IsInJoinContext indicates whether a child extent should\n\t/// add its stuff to the existing SqlSelectStatement, or create a new SqlSelectStatement\n\t/// By passing true, we ask the children to add themselves to the parent join,\n\t/// by passing false, we ask the children to create new Select statements for\n\t/// themselves.\n\t///\n\t/// This method is called from <see cref=\"Visit(DbApplyExpression)\"/> and\n\t/// <see cref=\"Visit(DbJoinExpression)\"/>.\n\t/// </summary>\n\t/// <param name=\"inputs\"></param>\n\t/// <param name=\"joinKind\"></param>\n\t/// <param name=\"joinString\"></param>\n\t/// <param name=\"joinCondition\"></param>\n\t/// <returns> A <see cref=\"SqlSelectStatement\"/></returns>\n\tISqlFragment VisitJoinExpression(IList<DbExpressionBinding> inputs, DbExpressionKind joinKind,\n\t\tstring joinString, DbExpression joinCondition)\n\t{\n\t\tSqlSelectStatement result;\n\t\t// If the parent is not a join( or says that it is not),\n\t\t// we should create a new SqlSelectStatement.\n\t\t// otherwise, we add our child extents to the parent's FROM clause.\n\t\tif (!IsParentAJoin)\n\t\t{\n\t\t\tresult = new SqlSelectStatement();\n\t\t\tresult.AllJoinExtents = new List<Symbol>();\n\t\t\t_selectStatementStack.Push(result);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tresult = CurrentSelectStatement;\n\t\t}\n\n\t\t// Process each of the inputs, and then the joinCondition if it exists.\n\t\t// It would be nice if we could call VisitInputExpression - that would\n\t\t// avoid some code duplication\n\t\t// but the Join postprocessing is messy and prevents this reuse.\n\t\t_symbolTable.EnterScope();\n\n\t\tvar separator = string.Empty;\n\t\tvar isLeftMostInput = true;\n\t\tvar inputCount = inputs.Count;\n\t\tfor (var idx = 0; idx < inputCount; idx++)\n\t\t{\n\t\t\tvar input = inputs[idx];\n\n\t\t\tif (separator != string.Empty)\n\t\t\t{\n\t\t\t\tresult.From.AppendLine();\n\t\t\t}\n\t\t\tresult.From.Append(separator + \" \");\n\t\t\t// Change this if other conditions are required\n\t\t\t// to force the child to produce a nested SqlStatement.\n\t\t\tvar needsJoinContext = (input.Expression.ExpressionKind == DbExpressionKind.Scan)\n\t\t\t\t\t\t\t\t\t|| (isLeftMostInput &&\n\t\t\t\t\t\t\t\t\t\t(IsJoinExpression(input.Expression)\n\t\t\t\t\t\t\t\t\t\t || IsApplyExpression(input.Expression)))\n\t\t\t\t\t\t\t\t\t;\n\n\t\t\t_isParentAJoinStack.Push(needsJoinContext ? true : false);\n\t\t\t// if the child reuses our select statement, it will append the from\n\t\t\t// symbols to our FromExtents list.  So, we need to remember the\n\t\t\t// start of the child's entries.\n\t\t\tvar fromSymbolStart = result.FromExtents.Count;\n\n\t\t\tvar fromExtentFragment = input.Expression.Accept(this);\n\n\t\t\t_isParentAJoinStack.Pop();\n\n\t\t\tProcessJoinInputResult(fromExtentFragment, result, input, fromSymbolStart);\n\t\t\tseparator = joinString;\n\n\t\t\tisLeftMostInput = false;\n\t\t}\n\n\t\t// Visit the on clause/join condition.\n\t\tswitch (joinKind)\n\t\t{\n\t\t\tcase DbExpressionKind.FullOuterJoin:\n\t\t\tcase DbExpressionKind.InnerJoin:\n\t\t\tcase DbExpressionKind.LeftOuterJoin:\n\t\t\t\tresult.From.Append(\" ON \");\n\t\t\t\t_isParentAJoinStack.Push(false);\n\t\t\t\tresult.From.Append(joinCondition.Accept(this));\n\t\t\t\t_isParentAJoinStack.Pop();\n\t\t\t\tbreak;\n\t\t}\n\n\t\t_symbolTable.ExitScope();\n\n\t\tif (!IsParentAJoin)\n\t\t{\n\t\t\t_selectStatementStack.Pop();\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// This is called from <see cref=\"VisitJoinExpression\"/>.\n\t///\n\t/// This is responsible for maintaining the symbol table after visiting\n\t/// a child of a join expression.\n\t///\n\t/// The child's sql statement may need to be completed.\n\t///\n\t/// The child's result could be one of\n\t/// <list type=\"number\">\n\t/// <item>The same as the parent's - this is treated specially.</item>\n\t/// <item>A sql select statement, which may need to be completed</item>\n\t/// <item>An extent - just copy it to the from clause</item>\n\t/// <item>Anything else (from a collection-valued expression) -\n\t/// unnest and copy it.</item>\n\t/// </list>\n\t///\n\t/// If the input was a Join, we need to create a new join symbol,\n\t/// otherwise, we create a normal symbol.\n\t///\n\t/// We then call AddFromSymbol to add the AS clause, and update the symbol table.\n\t///\n\t///\n\t///\n\t/// If the child's result was the same as the parent's, we have to clean up\n\t/// the list of symbols in the FromExtents list, since this contains symbols from\n\t/// the children of both the parent and the child.\n\t/// The happens when the child visited is a Join, and is the leftmost child of\n\t/// the parent.\n\t/// </summary>\n\t/// <param name=\"fromExtentFragment\"></param>\n\t/// <param name=\"result\"></param>\n\t/// <param name=\"input\"></param>\n\t/// <param name=\"fromSymbolStart\"></param>\n\tvoid ProcessJoinInputResult(ISqlFragment fromExtentFragment, SqlSelectStatement result,\n\t\tDbExpressionBinding input, int fromSymbolStart)\n\t{\n\t\tSymbol fromSymbol = null;\n\t\tvar varName = GetShortenedName(input.VariableName);\n\n\t\tif (result != fromExtentFragment)\n\t\t{\n\t\t\t// The child has its own select statement, and is not reusing\n\t\t\t// our select statement.\n\t\t\t// This should look a lot like VisitInputExpression().\n\t\t\tif (fromExtentFragment is SqlSelectStatement sqlSelectStatement)\n\t\t\t{\n\t\t\t\tif (sqlSelectStatement.Select.IsEmpty)\n\t\t\t\t{\n\t\t\t\t\tvar columns = AddDefaultColumns(sqlSelectStatement);\n\n\t\t\t\t\tif (IsJoinExpression(input.Expression)\n\t\t\t\t\t\t|| IsApplyExpression(input.Expression))\n\t\t\t\t\t{\n\t\t\t\t\t\tvar extents = sqlSelectStatement.FromExtents;\n\t\t\t\t\t\tvar newJoinSymbol = new JoinSymbol(varName, input.VariableType, extents);\n\t\t\t\t\t\tnewJoinSymbol.IsNestedJoin = true;\n\t\t\t\t\t\tnewJoinSymbol.ColumnList = columns;\n\n\t\t\t\t\t\tfromSymbol = newJoinSymbol;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t// this is a copy of the code in CreateNewSelectStatement.\n\n\t\t\t\t\t\t// if the oldStatement has a join as its input, ...\n\t\t\t\t\t\t// clone the join symbol, so that we \"reuse\" the\n\t\t\t\t\t\t// join symbol.  Normally, we create a new symbol - see the next block\n\t\t\t\t\t\t// of code.\n\t\t\t\t\t\tif (sqlSelectStatement.FromExtents[0] is JoinSymbol oldJoinSymbol)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Note: sqlSelectStatement.FromExtents will not do, since it might\n\t\t\t\t\t\t\t// just be an alias of joinSymbol, and we want an actual JoinSymbol.\n\t\t\t\t\t\t\tvar newJoinSymbol = new JoinSymbol(varName, input.VariableType, oldJoinSymbol.ExtentList);\n\t\t\t\t\t\t\t// This indicates that the sqlSelectStatement is a blocking scope\n\t\t\t\t\t\t\t// i.e. it hides/renames extent columns\n\t\t\t\t\t\t\tnewJoinSymbol.IsNestedJoin = true;\n\t\t\t\t\t\t\tnewJoinSymbol.ColumnList = columns;\n\t\t\t\t\t\t\tnewJoinSymbol.FlattenedExtentList = oldJoinSymbol.FlattenedExtentList;\n\n\t\t\t\t\t\t\tfromSymbol = newJoinSymbol;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t\tresult.From.Append(\" (\");\n\t\t\t\tresult.From.Append(sqlSelectStatement);\n\t\t\t\tresult.From.Append(\" )\");\n\t\t\t}\n\t\t\telse if (input.Expression is DbScanExpression)\n\t\t\t{\n\t\t\t\tresult.From.Append(fromExtentFragment);\n\t\t\t}\n\t\t\telse // bracket it\n\t\t\t{\n\t\t\t\tWrapNonQueryExtent(result, fromExtentFragment, input.Expression.ExpressionKind);\n\t\t\t}\n\n\t\t\tif (fromSymbol == null) // i.e. not a join symbol\n\t\t\t{\n\t\t\t\tfromSymbol = new Symbol(varName, input.VariableType);\n\t\t\t}\n\n\n\t\t\tAddFromSymbol(result, varName, fromSymbol);\n\t\t\tresult.AllJoinExtents.Add(fromSymbol);\n\t\t}\n\t\telse // result == fromExtentFragment.  The child extents have been merged into the parent's.\n\t\t{\n\t\t\t// we are adding extents to the current sql statement via flattening.\n\t\t\t// We are replacing the child's extents with a single Join symbol.\n\t\t\t// The child's extents are all those following the index fromSymbolStart.\n\t\t\t//\n\t\t\tvar extents = new List<Symbol>();\n\n\t\t\t// We cannot call extents.AddRange, since the is no simple way to\n\t\t\t// get the range of symbols fromSymbolStart..result.FromExtents.Count\n\t\t\t// from result.FromExtents.\n\t\t\t// We copy these symbols to create the JoinSymbol later.\n\t\t\tfor (var i = fromSymbolStart; i < result.FromExtents.Count; ++i)\n\t\t\t{\n\t\t\t\textents.Add(result.FromExtents[i]);\n\t\t\t}\n\t\t\tresult.FromExtents.RemoveRange(fromSymbolStart, result.FromExtents.Count - fromSymbolStart);\n\t\t\tfromSymbol = new JoinSymbol(varName, input.VariableType, extents);\n\t\t\tresult.FromExtents.Add(fromSymbol);\n\t\t\t// this Join Symbol does not have its own select statement, so we\n\t\t\t// do not set IsNestedJoin\n\n\n\t\t\t// We do not call AddFromSymbol(), since we do not want to add\n\t\t\t// \"AS alias\" to the FROM clause- it has been done when the extent was added earlier.\n\t\t\t_symbolTable.Add(varName, fromSymbol);\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// We assume that this is only called as a child of a Project.\n\t///\n\t/// This replaces <see cref=\"Visit(DbNewInstanceExpression)\"/>, since\n\t/// we do not allow DbNewInstanceExpression as a child of any node other than\n\t/// DbProjectExpression.\n\t///\n\t/// We write out the translation of each of the columns in the record.\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\n\t/// <returns>A <see cref=\"SqlBuilder\"/></returns>\n\tISqlFragment VisitNewInstanceExpression(DbNewInstanceExpression e)\n\t{\n\t\tvar result = new SqlBuilder();\n\n\t\tif (e.ResultType.EdmType is RowType rowType)\n\t\t{\n\t\t\tvar members = rowType.Properties;\n\t\t\tvar separator = string.Empty;\n\t\t\tfor (var i = 0; i < e.Arguments.Count; ++i)\n\t\t\t{\n\t\t\t\tvar argument = e.Arguments[i];\n\t\t\t\tif (MetadataHelpers.IsRowType(argument.ResultType))\n\t\t\t\t{\n\t\t\t\t\t// We do not support nested records or other complex objects.\n\t\t\t\t\tthrow new NotSupportedException();\n\t\t\t\t}\n\n\t\t\t\tvar member = members[i];\n\t\t\t\tresult.Append(separator);\n\t\t\t\tresult.AppendLine();\n\t\t\t\tresult.Append(argument.Accept(this));\n\t\t\t\tresult.Append(\" AS \");\n\t\t\t\tresult.Append(QuoteIdentifier(member.Name));\n\t\t\t\tseparator = \", \";\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\t//\n\t\t\t// Types other then RowType (such as UDTs for instance) are not supported.\n\t\t\t//\n\t\t\tthrow new NotSupportedException();\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tISqlFragment VisitSetOpExpression(DbExpression left, DbExpression right, string separator)\n\t{\n\n\t\tvar leftSelectStatement = VisitExpressionEnsureSqlStatement(left);\n\t\tvar rightSelectStatement = VisitExpressionEnsureSqlStatement(right);\n\n\t\tvar setStatement = new SqlBuilder();\n\t\tsetStatement.Append(leftSelectStatement);\n\t\tsetStatement.AppendLine();\n\t\tsetStatement.Append(separator); // e.g. UNION ALL\n\t\tsetStatement.AppendLine();\n\t\tsetStatement.Append(rightSelectStatement);\n\n\t\treturn setStatement;\n\t}\n\n\n\t#endregion\n\n\t#region Function Handling Helpers\n\t/// <summary>\n\t/// Determines whether the given function is a built-in function that requires special handling\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tprivate bool IsSpecialBuiltInFunction(DbFunctionExpression e)\n\t{\n\t\treturn IsBuiltInFunction(e.Function) && _builtInFunctionHandlers.ContainsKey(e.Function.Name);\n\t}\n\n\t/// <summary>\n\t/// Determines whether the given function is a canonical function that requires special handling\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tprivate bool IsSpecialCanonicalFunction(DbFunctionExpression e)\n\t{\n\t\treturn MetadataHelpers.IsCanonicalFunction(e.Function) && _canonicalFunctionHandlers.ContainsKey(e.Function.Name);\n\t}\n\n\t/// <summary>\n\t/// Default handling for functions\n\t/// Translates them to FunctionName(arg1, arg2, ..., argn)\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tprivate ISqlFragment HandleFunctionDefault(DbFunctionExpression e)\n\t{\n\t\tvar result = new SqlBuilder();\n\t\tWriteFunctionName(result, e.Function);\n\t\tHandleFunctionArgumentsDefault(e, result);\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// Default handling for functions with a given name.\n\t/// Translates them to functionName(arg1, arg2, ..., argn)\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <param name=\"functionName\"></param>\n\t/// <returns></returns>\n\tprivate ISqlFragment HandleFunctionDefaultGivenName(DbFunctionExpression e, string functionName)\n\t{\n\t\tvar result = new SqlBuilder();\n\t\tresult.Append(functionName);\n\t\tHandleFunctionArgumentsDefault(e, result);\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// Default handling on function arguments\n\t/// Appends the list of arguments to the given result\n\t/// If the function is niladic it does not append anything,\n\t/// otherwise it appends (arg1, arg2, ..., argn)\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <param name=\"result\"></param>\n\tprivate void HandleFunctionArgumentsDefault(DbFunctionExpression e, SqlBuilder result)\n\t{\n\t\tvar isNiladicFunction = MetadataHelpers.TryGetValueForMetadataProperty<bool>(e.Function, \"NiladicFunctionAttribute\");\n\t\tif (isNiladicFunction && e.Arguments.Count > 0)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Niladic functions cannot have parameters\");\n\t\t}\n\n\t\tif (!isNiladicFunction)\n\t\t{\n\t\t\tresult.Append(\"(\");\n\t\t\tvar separator = string.Empty;\n\t\t\tforeach (var arg in e.Arguments)\n\t\t\t{\n\t\t\t\tresult.Append(separator);\n\t\t\t\tresult.Append(arg.Accept(this));\n\t\t\t\tseparator = \", \";\n\t\t\t}\n\t\t\tresult.Append(\")\");\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Handler for special built in functions\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tprivate ISqlFragment HandleSpecialBuiltInFunction(DbFunctionExpression e)\n\t{\n\t\treturn HandleSpecialFunction(_builtInFunctionHandlers, e);\n\t}\n\n\t/// <summary>\n\t/// Handler for special canonical functions\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tprivate ISqlFragment HandleSpecialCanonicalFunction(DbFunctionExpression e)\n\t{\n\t\treturn HandleSpecialFunction(_canonicalFunctionHandlers, e);\n\t}\n\n\t/// <summary>\n\t/// Dispatches the special function processing to the appropriate handler\n\t/// </summary>\n\t/// <param name=\"handlers\"></param>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tprivate ISqlFragment HandleSpecialFunction(Dictionary<string, FunctionHandler> handlers, DbFunctionExpression e)\n\t{\n\t\tif (!handlers.ContainsKey(e.Function.Name))\n\t\t\tthrow new InvalidOperationException(\"Special handling should be called only for functions in the list of special functions\");\n\n\t\treturn handlers[e.Function.Name](this, e);\n\t}\n\n\t/// <summary>\n\t/// Handles functions that are translated into SQL operators.\n\t/// The given function should have one or two arguments.\n\t/// Functions with one arguemnt are translated into\n\t///     op arg\n\t/// Functions with two arguments are translated into\n\t///     arg0 op arg1\n\t/// Also, the arguments can be optionaly enclosed in parethesis\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <param name=\"parenthesiseArguments\">Whether the arguments should be enclosed in parethesis</param>\n\t/// <returns></returns>\n\tprivate ISqlFragment HandleSpecialFunctionToOperator(DbFunctionExpression e, bool parenthesiseArguments)\n\t{\n\t\tvar result = new SqlBuilder();\n\t\tDebug.Assert(e.Arguments.Count > 0 && e.Arguments.Count <= 2, \"There should be 1 or 2 arguments for operator\");\n\n\t\tif (e.Arguments.Count > 1)\n\t\t{\n\t\t\tif (parenthesiseArguments)\n\t\t\t{\n\t\t\t\tresult.Append(\"(\");\n\t\t\t}\n\t\t\tresult.Append(e.Arguments[0].Accept(this));\n\t\t\tif (parenthesiseArguments)\n\t\t\t{\n\t\t\t\tresult.Append(\")\");\n\t\t\t}\n\t\t}\n\t\tresult.Append(\" \");\n\t\tDebug.Assert(_functionNameToOperatorDictionary.ContainsKey(e.Function.Name), \"The function can not be mapped to an operator\");\n\t\tresult.Append(_functionNameToOperatorDictionary[e.Function.Name]);\n\t\tresult.Append(\" \");\n\n\t\tif (parenthesiseArguments)\n\t\t{\n\t\t\tresult.Append(\"(\");\n\t\t}\n\t\tresult.Append(e.Arguments[e.Arguments.Count - 1].Accept(this));\n\t\tif (parenthesiseArguments)\n\t\t{\n\t\t\tresult.Append(\")\");\n\t\t}\n\t\treturn result;\n\t}\n\n\t#region String Canonical Functions\n\tprivate static ISqlFragment HandleCanonicalConcatFunction(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleSpecialFunctionToOperator(e, false);\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalContainsFunction(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\tsqlgen._shouldHandleBoolComparison = false;\n\t\treturn sqlgen.HandleSpecialFunctionToOperator(e, false);\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalEndsWithFunction(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\tsqlgen._shouldHandleBoolComparison = false;\n\t\tvar result = new SqlBuilder();\n\t\tresult.Append(\"REVERSE(\");\n\t\tresult.Append(e.Arguments[0].Accept(sqlgen));\n\t\tresult.Append(\") STARTING WITH REVERSE(\");\n\t\tresult.Append(e.Arguments[1].Accept(sqlgen));\n\t\tresult.Append(\")\");\n\t\treturn result;\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionIndexOf(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"POSITION\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionLength(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"CHAR_LENGTH\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionTrim(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn TrimHelper(sqlgen, e, \"BOTH\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionLTrim(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn TrimHelper(sqlgen, e, \"LEADING\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionRTrim(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn TrimHelper(sqlgen, e, \"TRAILING\");\n\t}\n\n\t/// <summary>\n\t/// TRIM ( [ [ <trim specification> ] [ <trim character> ] FROM ] <value expression> )\n\t/// <trim specification> ::=  LEADING  | TRAILING  | BOTH\n\t/// </summary>\n\tprivate static ISqlFragment TrimHelper(SqlGenerator sqlgen, DbFunctionExpression e, string what)\n\t{\n\t\tvar result = new SqlBuilder();\n\n\t\tresult.Append(\"TRIM(\");\n\t\tresult.Append(what);\n\t\tresult.Append(\" FROM \");\n\n\t\tDebug.Assert(e.Arguments.Count == 1, \"Trim should have one argument\");\n\t\tresult.Append(e.Arguments[0].Accept(sqlgen));\n\n\t\tresult.Append(\")\");\n\n\t\treturn result;\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionLeft(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"LEFT\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionRight(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"RIGHT\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionReverse(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"REVERSE\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionReplace(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"REPLACE\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalStartsWithFunction(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\tsqlgen._shouldHandleBoolComparison = false;\n\t\treturn sqlgen.HandleSpecialFunctionToOperator(e, false);\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionSubstring(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\tvar result = new SqlBuilder();\n\n\t\tresult.Append(\"SUBSTRING(\");\n\n\t\tDebug.Assert(e.Arguments.Count == 3, \"Substring should have three arguments\");\n\t\tresult.Append(e.Arguments[0].Accept(sqlgen));\n\t\tresult.Append(\" FROM \");\n\t\tresult.Append(e.Arguments[1].Accept(sqlgen));\n\t\tresult.Append(\" FOR \");\n\t\tresult.Append(e.Arguments[2].Accept(sqlgen));\n\n\t\tresult.Append(\")\");\n\n\t\treturn result;\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionToLower(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"LOWER\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionToUpper(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"UPPER\");\n\t}\n\t#endregion\n\n\t#region Bitwise Canonical Functions\n\tprivate static ISqlFragment HandleCanonicalFunctionBitwiseAnd(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"BIN_AND\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionBitwiseNot(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"BIN_NOT\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionBitwiseOr(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"BIN_OR\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionBitwiseXor(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"BIN_XOR\");\n\t}\n\t#endregion\n\n\t#region Date and Time Canonical Functions\n\tprivate static ISqlFragment HandleCanonicalFunctionCurrentUtcDateTime(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\tthrow new NotSupportedException(\"CurrentUtcDateTime is not supported by Firebird.\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionCurrentDateTimeOffset(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\tthrow new NotSupportedException(\"CurrentDateTimeOffset is not supported by Firebird.\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionGetTotalOffsetMinutes(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\tthrow new NotSupportedException(\"GetTotalOffsetMinutes is not supported by Firebird.\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionCurrentDateTime(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\tvar result = new SqlBuilder();\n\t\tresult.Append(\"CURRENT_TIMESTAMP\");\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// Handler for canonical funcitons for extracting date parts.\n\t/// For example:\n\t///     Year(date) -> EXTRACT(YEAR from date)\n\t/// </summary>\n\tprivate static ISqlFragment HandleCanonicalFunctionExtract(SqlGenerator sqlgen, DbFunctionExpression e, string extractPart)\n\t{\n\t\tif (extractPart == null)\n\t\t\tthrow new NotSupportedException();\n\n\t\tvar result = new SqlBuilder();\n\t\tresult.Append(\"EXTRACT(\");\n\t\tresult.Append(extractPart);\n\t\tresult.Append(\" FROM \");\n\t\tDebug.Assert(e.Arguments.Count == 1, \"Canonical datepart functions should have exactly one argument\");\n\t\tresult.Append(e.Arguments[0].Accept(sqlgen));\n\t\tresult.Append(\")\");\n\t\treturn result;\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionDateTimeAdd(SqlGenerator sqlgen, DbFunctionExpression e, string addPart)\n\t{\n\t\tif (addPart == null)\n\t\t\tthrow new NotSupportedException();\n\n\t\tvar result = new SqlBuilder();\n\t\tresult.Append(\"DATEADD(\");\n\t\tresult.Append(addPart);\n\t\tresult.Append(\", \");\n\t\tDebug.Assert(e.Arguments.Count == 2, \"Canonical dateadd functions should have exactly two arguments\");\n\t\tresult.Append(e.Arguments[1].Accept(sqlgen));\n\t\tresult.Append(\", \");\n\t\tresult.Append(e.Arguments[0].Accept(sqlgen));\n\t\tresult.Append(\")\");\n\t\treturn result;\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionDateTimeDiff(SqlGenerator sqlgen, DbFunctionExpression e, string diffPart)\n\t{\n\t\tif (diffPart == null)\n\t\t\tthrow new NotSupportedException();\n\n\t\tvar result = new SqlBuilder();\n\t\tresult.Append(\"DATEDIFF(\");\n\t\tresult.Append(diffPart);\n\t\tresult.Append(\", \");\n\t\tDebug.Assert(e.Arguments.Count == 2, \"Canonical datediff functions should have exactly two arguments\");\n\t\tresult.Append(e.Arguments[1].Accept(sqlgen));\n\t\tresult.Append(\", \");\n\t\tresult.Append(e.Arguments[0].Accept(sqlgen));\n\t\tresult.Append(\")\");\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// CCYY-MM-DD HH:NN:SS.nnnn\n\t/// CreateDateTime(year, month, day, hour, minute, second)\n\t/// </summary>\n\tprivate static ISqlFragment HandleCanonicalFunctionCreateDateTime(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\tvar result = new SqlBuilder();\n\n\t\tresult.Append(\"CAST('\");\n\t\tresult.Append((e.Arguments[0].ExpressionKind == DbExpressionKind.Constant) ? e.Arguments[0].Accept(sqlgen) : (object)\"0001\"); // year\n\t\tresult.Append(\"-\");\n\t\tresult.Append((e.Arguments[1].ExpressionKind == DbExpressionKind.Constant) ? e.Arguments[1].Accept(sqlgen) : (object)\"01\"); // month\n\t\tresult.Append(\"-\");\n\t\tresult.Append((e.Arguments[2].ExpressionKind == DbExpressionKind.Constant) ? e.Arguments[2].Accept(sqlgen) : (object)\"01\"); // day\n\t\tresult.Append(\" \");\n\t\tresult.Append((e.Arguments[3].ExpressionKind == DbExpressionKind.Constant) ? e.Arguments[3].Accept(sqlgen) : (object)\"00\"); // hour\n\t\tresult.Append(\":\");\n\t\tresult.Append((e.Arguments[4].ExpressionKind == DbExpressionKind.Constant) ? e.Arguments[4].Accept(sqlgen) : (object)\"00\"); // minute\n\t\tresult.Append(\":\");\n\t\tresult.Append(\"00\"); // second is typeof(double?), would result in CAST SqlFragment\n\t\tresult.Append(\"' AS TIMESTAMP)\");\n\n\t\t// in case a date part is not constant, generate additional DATEADD fragments\n\t\tif (e.Arguments[0].ExpressionKind != DbExpressionKind.Constant && e.Arguments[0].ExpressionKind != DbExpressionKind.Null)\n\t\t\tresult = HandleDateAdd(\"YEAR\", e.Arguments[0].Accept(sqlgen), result);\n\t\tif (e.Arguments[1].ExpressionKind != DbExpressionKind.Constant && e.Arguments[1].ExpressionKind != DbExpressionKind.Null)\n\t\t\tresult = HandleDateAdd(\"MONTH\", e.Arguments[1].Accept(sqlgen), result);\n\t\tif (e.Arguments[2].ExpressionKind != DbExpressionKind.Constant && e.Arguments[2].ExpressionKind != DbExpressionKind.Null)\n\t\t\tresult = HandleDateAdd(\"DAY\", e.Arguments[2].Accept(sqlgen), result);\n\t\tif (e.Arguments[3].ExpressionKind != DbExpressionKind.Constant && e.Arguments[3].ExpressionKind != DbExpressionKind.Null)\n\t\t\tresult = HandleDateAdd(\"HOUR\", e.Arguments[3].Accept(sqlgen), result);\n\t\tif (e.Arguments[4].ExpressionKind != DbExpressionKind.Constant && e.Arguments[4].ExpressionKind != DbExpressionKind.Null)\n\t\t\tresult = HandleDateAdd(\"MINUTE\", e.Arguments[4].Accept(sqlgen), result);\n\t\tif ((e.Arguments[5].ExpressionKind != DbExpressionKind.Constant || (((DbConstantExpression)e.Arguments[5]).Value as double?) != 0) && e.Arguments[5].ExpressionKind != DbExpressionKind.Null)\n\t\t\tresult = HandleDateAdd(\"SECOND\", e.Arguments[5].Accept(sqlgen), result);\n\n\t\t// in case a default value was used for the year/month/day part, remove it afterwards\n\t\tif (e.Arguments[0].ExpressionKind != DbExpressionKind.Constant)\n\t\t\tresult = HandleDateAdd(\"YEAR\", DbExpression.FromInt32(-1).Accept(sqlgen), result);\n\t\tif (e.Arguments[1].ExpressionKind != DbExpressionKind.Constant)\n\t\t\tresult = HandleDateAdd(\"MONTH\", DbExpression.FromInt32(-1).Accept(sqlgen), result);\n\t\tif (e.Arguments[2].ExpressionKind != DbExpressionKind.Constant)\n\t\t\tresult = HandleDateAdd(\"DAY\", DbExpression.FromInt32(-1).Accept(sqlgen), result);\n\n\t\treturn result;\n\t}\n\n\tprivate static SqlBuilder HandleDateAdd(string datePart, ISqlFragment value, ISqlFragment dateTime)\n\t{\n\t\tSqlBuilder result = new SqlBuilder();\n\t\tresult.Append(\"DATEADD(\");\n\t\tresult.Append(datePart);\n\t\tresult.Append(\", \");\n\t\tresult.Append(value);\n\t\tresult.Append(\", \");\n\t\tresult.Append(dateTime);\n\t\tresult.Append(\")\");\n\t\treturn result;\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionCreateDateTimeOffset(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\tthrow new NotSupportedException(\"CreateDateTimeOffset is not supported by Firebird.\");\n\t}\n\n\t/// <summary>\n\t/// HH:NN:SS.nnnn\n\t/// CreateTime(hour, minute, second)\n\t/// </summary>\n\tprivate static ISqlFragment HandleCanonicalFunctionCreateTime(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\tvar result = new SqlBuilder();\n\t\tresult.Append(\"CAST('\");\n\t\tresult.Append(e.Arguments[0].Accept(sqlgen));\n\t\tresult.Append(\":\");\n\t\tresult.Append(e.Arguments[1].Accept(sqlgen));\n\t\tresult.Append(\":\");\n\t\tresult.Append(e.Arguments[2].Accept(sqlgen));\n\t\tresult.Append(\"' AS TIME)\");\n\t\treturn result;\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionTruncateTime(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\tvar result = new SqlBuilder();\n\t\tresult.Append(\"CAST(CAST(\");\n\t\tresult.Append(e.Arguments[0].Accept(sqlgen));\n\t\tresult.Append(\" as DATE) as TIMESTAMP)\");\n\t\treturn result;\n\t}\n\t#endregion\n\n\t#region Other Canonical Functions\n\tprivate static ISqlFragment HandleCanonicalFunctionNewGuid(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"GEN_UUID\");\n\t}\n\t#endregion\n\n\t#region Math Canonical Functions\n\tprivate static ISqlFragment HandleCanonicalFunctionAbs(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"ABS\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionCeiling(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"CEILING\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionFloor(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"FLOOR\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionPower(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"POWER\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionRound(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"ROUND\");\n\t}\n\n\tprivate static ISqlFragment HandleCanonicalFunctionTruncate(SqlGenerator sqlgen, DbFunctionExpression e)\n\t{\n\t\treturn sqlgen.HandleFunctionDefaultGivenName(e, \"TRUNC\");\n\t}\n\t#endregion\n\n\t#endregion\n\n\n\t#endregion\n\n\t#region Helper methods for the DbExpressionVisitor\n\t/// <summary>\n\t/// <see cref=\"AddDefaultColumns\"/>\n\t/// Add the column names from the referenced extent/join to the\n\t/// select statement.\n\t///\n\t/// If the symbol is a JoinSymbol, we recursively visit all the extents,\n\t/// halting at real extents and JoinSymbols that have an associated SqlSelectStatement.\n\t///\n\t/// The column names for a real extent can be derived from its type.\n\t/// The column names for a Join Select statement can be got from the\n\t/// list of columns that was created when the Join's select statement\n\t/// was created.\n\t///\n\t/// We do the following for each column.\n\t/// <list type=\"number\">\n\t/// <item>Add the SQL string for each column to the SELECT clause</item>\n\t/// <item>Add the column to the list of columns - so that it can\n\t/// become part of the \"type\" of a JoinSymbol</item>\n\t/// <item>Check if the column name collides with a previous column added\n\t/// to the same select statement.  Flag both the columns for renaming if true.</item>\n\t/// <item>Add the column to a name lookup dictionary for collision detection.</item>\n\t/// </list>\n\t/// </summary>\n\t/// <param name=\"selectStatement\">The select statement that started off as SELECT *</param>\n\t/// <param name=\"symbol\">The symbol containing the type information for\n\t/// the columns to be added.</param>\n\t/// <param name=\"columnList\">Columns that have been added to the Select statement.\n\t/// This is created in <see cref=\"AddDefaultColumns\"/>.</param>\n\t/// <param name=\"columnDictionary\">A dictionary of the columns above.</param>\n\t/// <param name=\"separator\">Comma or nothing, depending on whether the SELECT\n\t/// clause is empty.</param>\n\tvoid AddColumns(SqlSelectStatement selectStatement, Symbol symbol,\n\t\tList<Symbol> columnList, Dictionary<string, Symbol> columnDictionary, ref string separator)\n\t{\n\t\tif (symbol is JoinSymbol joinSymbol)\n\t\t{\n\t\t\tif (!joinSymbol.IsNestedJoin)\n\t\t\t{\n\t\t\t\t// Recurse if the join symbol is a collection of flattened extents\n\t\t\t\tforeach (var sym in joinSymbol.ExtentList)\n\t\t\t\t{\n\t\t\t\t\t// if sym is ScalarType means we are at base case in the\n\t\t\t\t\t// recursion and there are not columns to add, just skip\n\t\t\t\t\tif (MetadataHelpers.IsPrimitiveType(sym.Type))\n\t\t\t\t\t{\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tAddColumns(selectStatement, sym, columnList, columnDictionary, ref separator);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tforeach (var joinColumn in joinSymbol.ColumnList)\n\t\t\t\t{\n\t\t\t\t\t// we write tableName.columnName\n\t\t\t\t\t// rather than tableName.columnName as alias\n\t\t\t\t\t// since the column name is unique (by the way we generate new column names)\n\t\t\t\t\t//\n\t\t\t\t\t// We use the symbols for both the table and the column,\n\t\t\t\t\t// since they are subject to renaming.\n\t\t\t\t\tselectStatement.Select.Append(separator);\n\t\t\t\t\tselectStatement.Select.Append(symbol);\n\t\t\t\t\tselectStatement.Select.Append(\".\");\n\t\t\t\t\tselectStatement.Select.Append(joinColumn);\n\n\t\t\t\t\t// check for name collisions.  If there is,\n\t\t\t\t\t// flag both the colliding symbols.\n\t\t\t\t\tif (columnDictionary.ContainsKey(joinColumn.Name))\n\t\t\t\t\t{\n\t\t\t\t\t\tcolumnDictionary[joinColumn.Name].NeedsRenaming = true; // the original symbol\n\t\t\t\t\t\tjoinColumn.NeedsRenaming = true; // the current symbol.\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tcolumnDictionary[joinColumn.Name] = joinColumn;\n\t\t\t\t\t}\n\n\t\t\t\t\tcolumnList.Add(joinColumn);\n\n\t\t\t\t\tseparator = \", \";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// This is a non-join extent/select statement, and the CQT type has\n\t\t\t// the relevant column information.\n\n\t\t\t// The type could be a record type(e.g. Project(...),\n\t\t\t// or an entity type ( e.g. EntityExpression(...)\n\t\t\t// so, we check whether it is a structuralType.\n\n\t\t\t// Consider an expression of the form J(a, b=P(E))\n\t\t\t// The inner P(E) would have been translated to a SQL statement\n\t\t\t// We should not use the raw names from the type, but the equivalent\n\t\t\t// symbols (they are present in symbol.Columns) if they exist.\n\t\t\t//\n\t\t\t// We add the new columns to the symbol's columns if they do\n\t\t\t// not already exist.\n\t\t\t//\n\n\t\t\tforeach (var property in MetadataHelpers.GetProperties(symbol.Type))\n\t\t\t{\n\t\t\t\tvar recordMemberName = property.Name;\n\t\t\t\t// Since all renaming happens in the second phase\n\t\t\t\t// we lose nothing by setting the next column name index to 0\n\t\t\t\t// many times.\n\t\t\t\t_allColumnNames[recordMemberName] = 0;\n\n\t\t\t\t// Create a new symbol/reuse existing symbol for the column\n\t\t\t\tif (!symbol.Columns.TryGetValue(recordMemberName, out var columnSymbol))\n\t\t\t\t{\n\t\t\t\t\t// we do not care about the types of columns, so we pass null\n\t\t\t\t\t// when construction the symbol.\n\t\t\t\t\tcolumnSymbol = new Symbol(recordMemberName, null);\n\t\t\t\t\tsymbol.Columns.Add(recordMemberName, columnSymbol);\n\t\t\t\t}\n\n\t\t\t\tselectStatement.Select.Append(separator);\n\t\t\t\tselectStatement.Select.Append(symbol);\n\t\t\t\tselectStatement.Select.Append(\".\");\n\n\t\t\t\t// We use the actual name before the \"AS\", the new name goes\n\t\t\t\t// after the AS.\n\t\t\t\tselectStatement.Select.Append(QuoteIdentifier(recordMemberName));\n\n\t\t\t\tselectStatement.Select.Append(\" AS \");\n\t\t\t\tselectStatement.Select.Append(columnSymbol);\n\n\t\t\t\t// Check for column name collisions.\n\t\t\t\tif (columnDictionary.ContainsKey(recordMemberName))\n\t\t\t\t{\n\t\t\t\t\tcolumnDictionary[recordMemberName].NeedsRenaming = true;\n\t\t\t\t\tcolumnSymbol.NeedsRenaming = true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcolumnDictionary[recordMemberName] = symbol.Columns[recordMemberName];\n\t\t\t\t}\n\n\t\t\t\tcolumnList.Add(columnSymbol);\n\n\t\t\t\tseparator = \", \";\n\t\t\t}\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Expands Select * to \"select the_list_of_columns\"\n\t/// If the columns are taken from an extent, they are written as\n\t/// {original_column_name AS Symbol(original_column)} to allow renaming.\n\t///\n\t/// If the columns are taken from a Join, they are written as just\n\t/// {original_column_name}, since there cannot be a name collision.\n\t///\n\t/// We concatenate the columns from each of the inputs to the select statement.\n\t/// Since the inputs may be joins that are flattened, we need to recurse.\n\t/// The inputs are inferred from the symbols in FromExtents.\n\t/// </summary>\n\t/// <param name=\"selectStatement\"></param>\n\t/// <returns></returns>\n\tList<Symbol> AddDefaultColumns(SqlSelectStatement selectStatement)\n\t{\n\t\t// This is the list of columns added in this select statement\n\t\t// This forms the \"type\" of the Select statement, if it has to\n\t\t// be expanded in another SELECT *\n\t\tvar columnList = new List<Symbol>();\n\n\t\t// A lookup for the previous set of columns to aid column name\n\t\t// collision detection.\n\t\tvar columnDictionary = new Dictionary<string, Symbol>(StringComparer.OrdinalIgnoreCase);\n\n\t\tvar separator = string.Empty;\n\t\t// The Select should usually be empty before we are called,\n\t\t// but we do not mind if it is not.\n\t\tif (!selectStatement.Select.IsEmpty)\n\t\t{\n\t\t\tseparator = \", \";\n\t\t}\n\n\t\tforeach (var symbol in selectStatement.FromExtents)\n\t\t{\n\t\t\tAddColumns(selectStatement, symbol, columnList, columnDictionary, ref separator);\n\t\t}\n\n\t\treturn columnList;\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"AddFromSymbol(SqlSelectStatement, string, Symbol, bool)\"/>\n\t/// </summary>\n\t/// <param name=\"selectStatement\"></param>\n\t/// <param name=\"inputVarName\"></param>\n\t/// <param name=\"fromSymbol\"></param>\n\tvoid AddFromSymbol(SqlSelectStatement selectStatement, string inputVarName, Symbol fromSymbol)\n\t{\n\t\tAddFromSymbol(selectStatement, inputVarName, fromSymbol, true);\n\t}\n\n\t/// <summary>\n\t/// This method is called after the input to a relational node is visited.\n\t/// <see cref=\"Visit(DbProjectExpression)\"/> and <see cref=\"ProcessJoinInputResult\"/>\n\t/// There are 2 scenarios\n\t/// <list type=\"number\">\n\t/// <item>The fromSymbol is new i.e. the select statement has just been\n\t/// created, or a join extent has been added.</item>\n\t/// <item>The fromSymbol is old i.e. we are reusing a select statement.</item>\n\t/// </list>\n\t///\n\t/// If we are not reusing the select statement, we have to complete the\n\t/// FROM clause with the alias\n\t/// <code>\n\t/// -- if the input was an extent\n\t/// FROM = [SchemaName].[TableName]\n\t/// -- if the input was a Project\n\t/// FROM = (SELECT ... FROM ... WHERE ...)\n\t/// </code>\n\t///\n\t/// These become\n\t/// <code>\n\t/// -- if the input was an extent\n\t/// FROM = [SchemaName].[TableName] AS alias\n\t/// -- if the input was a Project\n\t/// FROM = (SELECT ... FROM ... WHERE ...) AS alias\n\t/// </code>\n\t/// and look like valid FROM clauses.\n\t///\n\t/// Finally, we have to add the alias to the global list of aliases used,\n\t/// and also to the current symbol table.\n\t/// </summary>\n\t/// <param name=\"selectStatement\"></param>\n\t/// <param name=\"inputVarName\">The alias to be used.</param>\n\t/// <param name=\"fromSymbol\"></param>\n\t/// <param name=\"addToSymbolTable\"></param>\n\tvoid AddFromSymbol(SqlSelectStatement selectStatement, string inputVarName, Symbol fromSymbol, bool addToSymbolTable)\n\t{\n\t\t// the first check is true if this is a new statement\n\t\t// the second check is true if we are in a join - we do not\n\t\t// check if we are in a join context.\n\t\t// We do not want to add \"AS alias\" if it has been done already\n\t\t// e.g. when we are reusing the Sql statement.\n\t\tif (selectStatement.FromExtents.Count == 0 || fromSymbol != selectStatement.FromExtents[0])\n\t\t{\n\t\t\tselectStatement.FromExtents.Add(fromSymbol);\n\t\t\tselectStatement.From.Append(\" AS \");\n\t\t\tselectStatement.From.Append(fromSymbol);\n\n\t\t\t// We have this inside the if statement, since\n\t\t\t// we only want to add extents that are actually used.\n\t\t\t_allExtentNames[fromSymbol.Name] = 0;\n\t\t}\n\n\t\tif (addToSymbolTable)\n\t\t{\n\t\t\t_symbolTable.Add(inputVarName, fromSymbol);\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Translates a list of SortClauses.\n\t/// Used in the translation of OrderBy\n\t/// </summary>\n\t/// <param name=\"orderByClause\">The SqlBuilder to which the sort keys should be appended</param>\n\t/// <param name=\"sortKeys\"></param>\n\tvoid AddSortKeys(SqlBuilder orderByClause, IList<DbSortClause> sortKeys)\n\t{\n\t\tvar separator = string.Empty;\n\t\tforeach (var sortClause in sortKeys)\n\t\t{\n\t\t\torderByClause.Append(separator);\n\t\t\torderByClause.Append(sortClause.Expression.Accept(this));\n\t\t\tDebug.Assert(sortClause.Collation != null);\n\t\t\tif (!string.IsNullOrEmpty(sortClause.Collation))\n\t\t\t{\n\t\t\t\torderByClause.Append(\" COLLATE \");\n\t\t\t\torderByClause.Append(sortClause.Collation);\n\t\t\t}\n\n\t\t\torderByClause.Append(sortClause.Ascending ? \" ASC\" : \" DESC\");\n\n\t\t\tseparator = \", \";\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// <see cref=\"CreateNewSelectStatement(SqlSelectStatement oldStatement, string inputVarName, TypeUsage inputVarType, bool finalizeOldStatement, out Symbol fromSymbol) \"/>\n\t/// </summary>\n\t/// <param name=\"oldStatement\"></param>\n\t/// <param name=\"inputVarName\"></param>\n\t/// <param name=\"inputVarType\"></param>\n\t/// <param name=\"fromSymbol\"></param>\n\t/// <returns>A new select statement, with the old one as the from clause.</returns>\n\tSqlSelectStatement CreateNewSelectStatement(SqlSelectStatement oldStatement,\n\t\tstring inputVarName, TypeUsage inputVarType, out Symbol fromSymbol)\n\t{\n\t\treturn CreateNewSelectStatement(oldStatement, inputVarName, inputVarType, true, out fromSymbol);\n\t}\n\n\n\t/// <summary>\n\t/// This is called after a relational node's input has been visited, and the\n\t/// input's sql statement cannot be reused.  <see cref=\"Visit(DbProjectExpression)\"/>\n\t///\n\t/// When the input's sql statement cannot be reused, we create a new sql\n\t/// statement, with the old one as the from clause of the new statement.\n\t///\n\t/// The old statement must be completed i.e. if it has an empty select list,\n\t/// the list of columns must be projected out.\n\t///\n\t/// If the old statement being completed has a join symbol as its from extent,\n\t/// the new statement must have a clone of the join symbol as its extent.\n\t/// We cannot reuse the old symbol, but the new select statement must behave\n\t/// as though it is working over the \"join\" record.\n\t/// </summary>\n\t/// <param name=\"oldStatement\"></param>\n\t/// <param name=\"inputVarName\"></param>\n\t/// <param name=\"inputVarType\"></param>\n\t/// <param name=\"finalizeOldStatement\"></param>\n\t/// <param name=\"fromSymbol\"></param>\n\t/// <returns>A new select statement, with the old one as the from clause.</returns>\n\tSqlSelectStatement CreateNewSelectStatement(SqlSelectStatement oldStatement,\n\t\tstring inputVarName, TypeUsage inputVarType, bool finalizeOldStatement, out Symbol fromSymbol)\n\t{\n\t\tfromSymbol = null;\n\n\t\t// Finalize the old statement\n\t\tif (finalizeOldStatement && oldStatement.Select.IsEmpty)\n\t\t{\n\t\t\tvar columns = AddDefaultColumns(oldStatement);\n\n\t\t\t// Thid could not have been called from a join node.\n\t\t\tDebug.Assert(oldStatement.FromExtents.Count == 1);\n\n\t\t\t// if the oldStatement has a join as its input, ...\n\t\t\t// clone the join symbol, so that we \"reuse\" the\n\t\t\t// join symbol.  Normally, we create a new symbol - see the next block\n\t\t\t// of code.\n\t\t\tif (oldStatement.FromExtents[0] is JoinSymbol oldJoinSymbol)\n\t\t\t{\n\t\t\t\t// Note: oldStatement.FromExtents will not do, since it might\n\t\t\t\t// just be an alias of joinSymbol, and we want an actual JoinSymbol.\n\t\t\t\tvar newJoinSymbol = new JoinSymbol(inputVarName, inputVarType, oldJoinSymbol.ExtentList);\n\t\t\t\t// This indicates that the oldStatement is a blocking scope\n\t\t\t\t// i.e. it hides/renames extent columns\n\t\t\t\tnewJoinSymbol.IsNestedJoin = true;\n\t\t\t\tnewJoinSymbol.ColumnList = columns;\n\t\t\t\tnewJoinSymbol.FlattenedExtentList = oldJoinSymbol.FlattenedExtentList;\n\n\t\t\t\tfromSymbol = newJoinSymbol;\n\t\t\t}\n\t\t}\n\n\t\tif (fromSymbol == null)\n\t\t{\n\t\t\t// This is just a simple extent/SqlSelectStatement,\n\t\t\t// and we can get the column list from the type.\n\t\t\tfromSymbol = new Symbol(inputVarName, inputVarType);\n\t\t}\n\n\t\t// Observe that the following looks like the body of Visit(ExtentExpression).\n\t\tvar selectStatement = new SqlSelectStatement();\n\t\tselectStatement.From.Append(\"( \");\n\t\tselectStatement.From.Append(oldStatement);\n\t\tselectStatement.From.AppendLine();\n\t\tselectStatement.From.Append(\") \");\n\n\n\t\treturn selectStatement;\n\t}\n\n\tinternal static string FormatBoolean(bool value)\n\t{\n\t\treturn value ? \"CAST(1 AS SMALLINT)\" : \"CAST(0 AS SMALLINT)\";\n\t}\n\n\tinternal static string FormatBinary(byte[] value)\n\t{\n\t\treturn string.Format(\"x'{0}'\", value.ToHexString());\n\t}\n\n\tinternal static string FormatString(string value, bool isUnicode, int? explicitLength = null)\n\t{\n\t\tvar result = new StringBuilder();\n\t\tresult.Append(\"CAST(\");\n\t\tif (isUnicode)\n\t\t{\n\t\t\tresult.Append(\"_UTF8\");\n\t\t}\n\t\tresult.Append(\"'\");\n\t\tresult.Append(value.Replace(\"'\", \"''\"));\n\t\tresult.Append(\"' AS VARCHAR(\");\n\t\tresult.Append(explicitLength ?? value.Length);\n\t\tresult.Append(\"))\");\n\t\treturn result.ToString();\n\t}\n\n\tinternal static string FormatDateTime(DateTime value)\n\t{\n\t\tvar result = new StringBuilder();\n\t\tresult.Append(\"CAST('\");\n\t\tresult.Append(value.ToString(\"yyyy-MM-dd HH:mm:ss.ffff\", CultureInfo.InvariantCulture));\n\t\tresult.Append(\"' AS TIMESTAMP)\");\n\t\treturn result.ToString();\n\t}\n\n\tinternal static string FormatTime(DateTime value)\n\t{\n\t\tvar result = new StringBuilder();\n\t\tresult.Append(\"CAST('\");\n\t\tresult.Append(value.ToString(\"HH:mm:ss.ffff\", CultureInfo.InvariantCulture));\n\t\tresult.Append(\"' AS TIME)\");\n\t\treturn result.ToString();\n\t}\n\tinternal static string FormatTime(TimeSpan value)\n\t{\n\t\treturn FormatTime(DateTime.Today.Add(value));\n\t}\n\n\tinternal static string FormatGuid(Guid value)\n\t{\n\t\tvar result = new StringBuilder();\n\t\tresult.Append(\"CHAR_TO_UUID('\");\n\t\tresult.Append(value.ToString());\n\t\tresult.Append(\"')\");\n\t\treturn result.ToString();\n\t}\n\n\t/// <summary>\n\t/// Returns the sql primitive/native type name.\n\t/// It will include size, precision or scale depending on type information present in the\n\t/// type facets\n\t/// </summary>\n\t/// <param name=\"type\"></param>\n\t/// <returns></returns>\n\tinternal static string GetSqlPrimitiveType(TypeUsage type)\n\t{\n\t\tvar primitiveType = MetadataHelpers.GetEdmType<PrimitiveType>(type);\n\n\t\tvar typeName = primitiveType.Name;\n\t\tvar isUnicode = true;\n\t\tvar isFixedLength = false;\n\t\tvar length = 0;\n\t\tbyte precision = 0;\n\t\tbyte scale = 0;\n\n\t\tswitch (primitiveType.PrimitiveTypeKind)\n\t\t{\n\t\t\tcase PrimitiveTypeKind.Boolean:\n\t\t\t\ttypeName = \"SMALLINT\";\n\t\t\t\tbreak;\n\n\t\t\tcase PrimitiveTypeKind.Int16:\n\t\t\t\ttypeName = \"SMALLINT\";\n\t\t\t\tbreak;\n\n\t\t\tcase PrimitiveTypeKind.Int32:\n\t\t\t\ttypeName = \"INT\";\n\t\t\t\tbreak;\n\n\t\t\tcase PrimitiveTypeKind.Int64:\n\t\t\t\ttypeName = \"BIGINT\";\n\t\t\t\tbreak;\n\n\t\t\tcase PrimitiveTypeKind.Double:\n\t\t\t\ttypeName = \"DOUBLE PRECISION\";\n\t\t\t\tbreak;\n\n\t\t\tcase PrimitiveTypeKind.Single:\n\t\t\t\ttypeName = \"FLOAT\";\n\t\t\t\tbreak;\n\n\t\t\tcase PrimitiveTypeKind.Decimal:\n\t\t\t\tprecision = MetadataHelpers.GetFacetValueOrDefault<byte>(type, MetadataHelpers.PrecisionFacetName, 9);\n\t\t\t\tDebug.Assert(precision > 0, \"decimal precision must be greater than zero\");\n\t\t\t\tscale = MetadataHelpers.GetFacetValueOrDefault<byte>(type, MetadataHelpers.ScaleFacetName, 0);\n\t\t\t\tDebug.Assert(precision >= scale, \"decimalPrecision must be greater or equal to decimalScale\");\n\t\t\t\tDebug.Assert(precision <= 18, \"decimalPrecision must be less than or equal to 18\");\n\t\t\t\ttypeName = string.Format(\"DECIMAL({0},{1})\", precision, scale);\n\t\t\t\tbreak;\n\n\t\t\tcase PrimitiveTypeKind.Binary:\n\t\t\t\ttypeName = \"BLOB SUB_TYPE BINARY\";\n\t\t\t\tbreak;\n\n\t\t\tcase PrimitiveTypeKind.String:\n\t\t\t\tisUnicode = MetadataHelpers.GetFacetValueOrDefault<bool>(type, MetadataHelpers.UnicodeFacetName, true);\n\t\t\t\tisFixedLength = MetadataHelpers.GetFacetValueOrDefault<bool>(type, MetadataHelpers.FixedLengthFacetName, false);\n\t\t\t\tlength = MetadataHelpers.GetFacetValueOrDefault<int?>(type, MetadataHelpers.MaxLengthFacetName, null)\n\t\t\t\t\t?? (isUnicode ? FbProviderManifest.UnicodeVarcharMaxSize : FbProviderManifest.AsciiVarcharMaxSize);\n\t\t\t\tif (isFixedLength)\n\t\t\t\t{\n\t\t\t\t\ttypeName = (isUnicode ? \"CHAR(\" : \"CHAR(\") + length + \")\";\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (length > (isUnicode ? FbProviderManifest.UnicodeVarcharMaxSize : FbProviderManifest.AsciiVarcharMaxSize))\n\t\t\t\t\t{\n\t\t\t\t\t\ttypeName = \"BLOB SUB_TYPE TEXT\";\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\ttypeName = (isUnicode ? \"VARCHAR(\" : \"VARCHAR(\") + length + \")\";\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase PrimitiveTypeKind.DateTime:\n\t\t\t\tprecision = MetadataHelpers.GetFacetValueOrDefault<byte>(type, MetadataHelpers.PrecisionFacetName, 4);\n\t\t\t\ttypeName = (precision > 0 ? \"TIMESTAMP\" : \"DATE\");\n\t\t\t\tbreak;\n\n\t\t\tcase PrimitiveTypeKind.Time:\n\t\t\t\ttypeName = \"TIME\";\n\t\t\t\tbreak;\n\n\t\t\tcase PrimitiveTypeKind.Guid:\n\t\t\t\ttypeName = \"CHAR(16) CHARACTER SET OCTETS\";\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tthrow new NotSupportedException(\"Unsupported EdmType: \" + primitiveType.PrimitiveTypeKind);\n\t\t}\n\n\t\treturn typeName;\n\t}\n\n\t/// <summary>\n\t/// Handles the expression represending DbLimitExpression.Limit and DbSkipExpression.Count.\n\t/// If it is a constant expression, it simply does to string thus avoiding casting it to the specific value\n\t/// (which would be done if <see cref=\"Visit(DbConstantExpression)\"/> is called)\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tprivate ISqlFragment HandleCountExpression(DbExpression e)\n\t{\n\t\tISqlFragment result;\n\n\t\tif (e.ExpressionKind == DbExpressionKind.Constant)\n\t\t{\n\t\t\t//For constant expression we should not cast the value,\n\t\t\t// thus we don't go throught the default DbConstantExpression handling\n\t\t\tvar sqlBuilder = new SqlBuilder();\n\t\t\tsqlBuilder.Append(((DbConstantExpression)e).Value.ToString());\n\t\t\tresult = sqlBuilder;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tresult = e.Accept(this);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// This is used to determine if a particular expression is an Apply operation.\n\t/// This is only the case when the DbExpressionKind is CrossApply or OuterApply.\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tbool IsApplyExpression(DbExpression e)\n\t{\n\t\treturn (DbExpressionKind.CrossApply == e.ExpressionKind || DbExpressionKind.OuterApply == e.ExpressionKind);\n\t}\n\n\t/// <summary>\n\t/// This is used to determine if a particular expression is a Join operation.\n\t/// This is true for DbCrossJoinExpression and DbJoinExpression, the\n\t/// latter of which may have one of several different ExpressionKinds.\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tbool IsJoinExpression(DbExpression e)\n\t{\n\t\treturn (DbExpressionKind.CrossJoin == e.ExpressionKind ||\n\t\t\t\tDbExpressionKind.FullOuterJoin == e.ExpressionKind ||\n\t\t\t\tDbExpressionKind.InnerJoin == e.ExpressionKind ||\n\t\t\t\tDbExpressionKind.LeftOuterJoin == e.ExpressionKind);\n\t}\n\n\t/// <summary>\n\t/// This is used to determine if a calling expression needs to place\n\t/// round brackets around the translation of the expression e.\n\t///\n\t/// Constants, parameters, properties and internal functions as operators do not require brackets,\n\t/// everything else does.\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns>true, if the expression needs brackets </returns>\n\tbool IsComplexExpression(DbExpression e)\n\t{\n\t\tswitch (e.ExpressionKind)\n\t\t{\n\t\t\tcase DbExpressionKind.Constant:\n\t\t\tcase DbExpressionKind.ParameterReference:\n\t\t\tcase DbExpressionKind.Property:\n\t\t\t\treturn false;\n\t\t\tcase DbExpressionKind.Function:\n\t\t\t\treturn (!_functionNameToOperatorDictionary.ContainsKey((e as DbFunctionExpression).Function.Name));\n\n\t\t\tdefault:\n\t\t\t\treturn true;\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Determine if the owner expression can add its unique sql to the input's\n\t/// SqlSelectStatement\n\t/// </summary>\n\t/// <param name=\"result\">The SqlSelectStatement of the input to the relational node.</param>\n\t/// <param name=\"expressionKind\">The kind of the expression node(not the input's)</param>\n\t/// <returns></returns>\n\tbool IsCompatible(SqlSelectStatement result, DbExpressionKind expressionKind)\n\t{\n\t\tswitch (expressionKind)\n\t\t{\n\t\t\tcase DbExpressionKind.Distinct:\n\t\t\t\treturn result.First == null\n\t\t\t\t\t// The projection after distinct may not project all\n\t\t\t\t\t// columns used in the Order By\n\t\t\t\t\t&& result.OrderBy.IsEmpty;\n\n\t\t\tcase DbExpressionKind.Filter:\n\t\t\t\treturn result.Select.IsEmpty\n\t\t\t\t\t\t&& result.Where.IsEmpty\n\t\t\t\t\t\t&& result.GroupBy.IsEmpty\n\t\t\t\t\t\t&& result.First == null;\n\n\t\t\tcase DbExpressionKind.GroupBy:\n\t\t\t\treturn result.Select.IsEmpty\n\t\t\t\t\t\t&& result.GroupBy.IsEmpty\n\t\t\t\t\t\t&& result.OrderBy.IsEmpty\n\t\t\t\t\t\t&& result.First == null;\n\n\t\t\tcase DbExpressionKind.Limit:\n\t\t\tcase DbExpressionKind.Element:\n\t\t\t\treturn result.First == null;\n\n\t\t\tcase DbExpressionKind.Project:\n\t\t\t\treturn result.Select.IsEmpty\n\t\t\t\t\t\t&& result.GroupBy.IsEmpty;\n\n\t\t\tcase DbExpressionKind.Skip:\n\t\t\t\treturn result.Select.IsEmpty\n\t\t\t\t\t\t&& result.GroupBy.IsEmpty\n\t\t\t\t\t\t&& result.OrderBy.IsEmpty\n\t\t\t\t\t\t&& !result.IsDistinct;\n\n\t\t\tcase DbExpressionKind.Sort:\n\t\t\t\treturn result.Select.IsEmpty\n\t\t\t\t\t\t&& result.GroupBy.IsEmpty\n\t\t\t\t\t\t&& result.OrderBy.IsEmpty;\n\n\t\t\tdefault:\n\t\t\t\tDebug.Assert(false);\n\t\t\t\tthrow new InvalidOperationException();\n\t\t}\n\n\t}\n\n\t/// <summary>\n\t/// Decorate with double quotes and escape double quotes inside in Firebird.\n\t/// </summary>\n\t/// <param name=\"name\"></param>\n\t/// <returns></returns>\n\tinternal static string QuoteIdentifier(string name)\n\t{\n\t\tDebug.Assert(!string.IsNullOrEmpty(name));\n\t\t// We assume that the names are not quoted to begin with.\n\t\treturn \"\\\"\" + name.Replace(\"\\\"\", \"\\\"\\\"\") + \"\\\"\";\n\t}\n\n\t/// <summary>\n\t/// Simply calls <see cref=\"VisitExpressionEnsureSqlStatement(DbExpression, bool)\"/>\n\t/// with addDefaultColumns set to true\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <returns></returns>\n\tSqlSelectStatement VisitExpressionEnsureSqlStatement(DbExpression e)\n\t{\n\t\treturn VisitExpressionEnsureSqlStatement(e, true);\n\t}\n\n\t/// <summary>\n\t/// This is called from <see cref=\"GenerateSql(DbQueryCommandTree)\"/> and nodes which require a\n\t/// select statement as an argument e.g. <see cref=\"Visit(DbIsEmptyExpression)\"/>,\n\t/// <see cref=\"Visit(DbUnionAllExpression)\"/>.\n\t///\n\t/// SqlGenerator needs its child to have a proper alias if the child is\n\t/// just an extent or a join.\n\t///\n\t/// The normal relational nodes result in complete valid SQL statements.\n\t/// For the rest, we need to treat them as there was a dummy\n\t/// <code>\n\t/// -- originally {expression}\n\t/// -- change that to\n\t/// SELECT *\n\t/// FROM {expression} as c\n\t/// </code>\n\t///\n\t/// DbLimitExpression needs to start the statement but not add the default columns\n\t/// </summary>\n\t/// <param name=\"e\"></param>\n\t/// <param name=\"addDefaultColumns\"></param>\n\t/// <returns></returns>\n\tSqlSelectStatement VisitExpressionEnsureSqlStatement(DbExpression e, bool addDefaultColumns)\n\t{\n\t\tDebug.Assert(MetadataHelpers.IsCollectionType(e.ResultType));\n\n\t\tSqlSelectStatement result;\n\t\tswitch (e.ExpressionKind)\n\t\t{\n\t\t\tcase DbExpressionKind.Project:\n\t\t\tcase DbExpressionKind.Filter:\n\t\t\tcase DbExpressionKind.GroupBy:\n\t\t\tcase DbExpressionKind.Sort:\n\t\t\t\tresult = e.Accept(this) as SqlSelectStatement;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tvar inputVarName = \"c\";  // any name will do - this is my random choice.\n\t\t\t\t_symbolTable.EnterScope();\n\n\t\t\t\tTypeUsage type = null;\n\t\t\t\tswitch (e.ExpressionKind)\n\t\t\t\t{\n\t\t\t\t\tcase DbExpressionKind.Scan:\n\t\t\t\t\tcase DbExpressionKind.CrossJoin:\n\t\t\t\t\tcase DbExpressionKind.FullOuterJoin:\n\t\t\t\t\tcase DbExpressionKind.InnerJoin:\n\t\t\t\t\tcase DbExpressionKind.LeftOuterJoin:\n\t\t\t\t\tcase DbExpressionKind.CrossApply:\n\t\t\t\t\tcase DbExpressionKind.OuterApply:\n\t\t\t\t\t\ttype = MetadataHelpers.GetElementTypeUsage(e.ResultType);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tDebug.Assert(MetadataHelpers.IsCollectionType(e.ResultType));\n\t\t\t\t\t\ttype = MetadataHelpers.GetEdmType<CollectionType>(e.ResultType).TypeUsage;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tresult = VisitInputExpression(e, inputVarName, type, out var fromSymbol);\n\t\t\t\tAddFromSymbol(result, inputVarName, fromSymbol);\n\t\t\t\t_symbolTable.ExitScope();\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif (addDefaultColumns && result.Select.IsEmpty)\n\t\t{\n\t\t\tAddDefaultColumns(result);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// This method is called by <see cref=\"Visit(DbFilterExpression)\"/> and\n\t/// <see cref=\"Visit(DbQuantifierExpression)\"/>\n\t///\n\t/// </summary>\n\t/// <param name=\"input\"></param>\n\t/// <param name=\"predicate\"></param>\n\t/// <param name=\"negatePredicate\">This is passed from <see cref=\"Visit(DbQuantifierExpression)\"/>\n\t/// in the All(...) case.</param>\n\t/// <returns></returns>\n\tSqlSelectStatement VisitFilterExpression(DbExpressionBinding input, DbExpression predicate, bool negatePredicate)\n\t{\n\t\tvar varName = GetShortenedName(input.VariableName);\n\t\tvar result = VisitInputExpression(input.Expression,\n\t\t\tvarName, input.VariableType, out var fromSymbol);\n\n\t\t// Filter is compatible with OrderBy\n\t\t// but not with Project, another Filter or GroupBy\n\t\tif (!IsCompatible(result, DbExpressionKind.Filter))\n\t\t{\n\t\t\tresult = CreateNewSelectStatement(result, varName, input.VariableType, out fromSymbol);\n\t\t}\n\n\t\t_selectStatementStack.Push(result);\n\t\t_symbolTable.EnterScope();\n\n\t\tAddFromSymbol(result, varName, fromSymbol);\n\n\t\tif (negatePredicate)\n\t\t{\n\t\t\tresult.Where.Append(\"NOT (\");\n\t\t}\n\t\tresult.Where.Append(predicate.Accept(this));\n\t\tif (negatePredicate)\n\t\t{\n\t\t\tresult.Where.Append(\")\");\n\t\t}\n\n\t\t_symbolTable.ExitScope();\n\t\t_selectStatementStack.Pop();\n\n\t\treturn result;\n\t}\n\n\t/// <summary>\n\t/// If the sql fragment for an input expression is not a SqlSelect statement\n\t/// or other acceptable form (e.g. an extent as a SqlBuilder), we need\n\t/// to wrap it in a form acceptable in a FROM clause.  These are\n\t/// primarily the\n\t/// <list type=\"bullet\">\n\t/// <item>The set operation expressions - union all, intersect, except</item>\n\t/// <item>TVFs, which are conceptually similar to tables</item>\n\t/// </list>\n\t/// </summary>\n\t/// <param name=\"result\"></param>\n\t/// <param name=\"sqlFragment\"></param>\n\t/// <param name=\"expressionKind\"></param>\n\tvoid WrapNonQueryExtent(SqlSelectStatement result, ISqlFragment sqlFragment, DbExpressionKind expressionKind)\n\t{\n\t\tswitch (expressionKind)\n\t\t{\n\t\t\tcase DbExpressionKind.Function:\n\t\t\t\t// TVF\n\t\t\t\tresult.From.Append(sqlFragment);\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tresult.From.Append(\" (\");\n\t\t\t\tresult.From.Append(sqlFragment);\n\t\t\t\tresult.From.Append(\")\");\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Is this a builtin function (ie) does it have the builtinAttribute specified?\n\t/// </summary>\n\t/// <param name=\"function\"></param>\n\t/// <returns></returns>\n\tprivate static bool IsBuiltInFunction(EdmFunction function)\n\t{\n\t\treturn MetadataHelpers.TryGetValueForMetadataProperty<bool>(function, \"BuiltInAttribute\");\n\t}\n\n\t/// <summary>\n\t///\n\t/// </summary>\n\t/// <param name=\"function\"></param>\n\t/// <param name=\"result\"></param>\n\tvoid WriteFunctionName(SqlBuilder result, EdmFunction function)\n\t{\n\t\tvar storeFunctionName = MetadataHelpers.TryGetValueForMetadataProperty<string>(function, \"StoreFunctionNameAttribute\");\n\n\t\tif (string.IsNullOrEmpty(storeFunctionName))\n\t\t{\n\t\t\tstoreFunctionName = function.Name;\n\t\t}\n\t\t// If the function is a builtin (ie) the BuiltIn attribute has been\n\t\t// specified, then, the function name should not be quoted; additionally,\n\t\t// no namespace should be used.\n\t\tif (IsBuiltInFunction(function))\n\t\t{\n\t\t\tif (MetadataHelpers.IsCanonicalFunction(function))\n\t\t\t{\n\t\t\t\tswitch (storeFunctionName)\n\t\t\t\t{\n\t\t\t\t\tcase \"BigCount\":\n\t\t\t\t\t\tresult.Append(\"COUNT\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tresult.Append(storeFunctionName.ToUpperInvariant());\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tresult.Append(storeFunctionName);\n\t\t\t}\n\n\t\t}\n\t\telse\n\t\t{\n\t\t\t//result.Append(QuoteIdentifier((string)function.MetadataProperties[\"Schema\"].Value ?? \"dbo\"));\n\t\t\t//result.Append(\".\");\n\t\t\tresult.Append(QuoteIdentifier(storeFunctionName));\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Helper method for the Group By visitor\n\t/// Returns true if at least one of the aggregates in the given list\n\t/// has an argument that is not a <see cref=\"DbPropertyExpression\"/>\n\t/// over <see cref=\"DbVariableReferenceExpression\"/>\n\t/// </summary>\n\t/// <param name=\"aggregates\"></param>\n\t/// <returns></returns>\n\tstatic bool NeedsInnerQuery(IList<DbAggregate> aggregates)\n\t{\n\t\tforeach (var aggregate in aggregates)\n\t\t{\n\t\t\tDebug.Assert(aggregate.Arguments.Count == 1);\n\t\t\tif (!IsPropertyOverVarRef(aggregate.Arguments[0]))\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t/// <summary>\n\t/// Determines whether the given expression is a <see cref=\"DbPropertyExpression\"/>\n\t/// over <see cref=\"DbVariableReferenceExpression\"/>\n\t/// </summary>\n\t/// <param name=\"expression\"></param>\n\t/// <returns></returns>\n\tstatic bool IsPropertyOverVarRef(DbExpression expression)\n\t{\n\t\tif (!(expression is DbPropertyExpression propertyExpression))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tif (!(propertyExpression.Instance is DbVariableReferenceExpression varRefExpression))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/// <summary>\n\t/// Shortens the name of variable (tables, etc.).\n\t/// </summary>\n\t/// <param name=\"name\"></param>\n\t/// <returns></returns>\n\tinternal string GetShortenedName(string name)\n\t{\n\t\tif (!_shortenedNames.TryGetValue(name, out var shortened))\n\t\t{\n\t\t\tshortened = BuildName(_shortenedNames.Count);\n\t\t\t_shortenedNames[name] = shortened;\n\t\t}\n\t\treturn shortened;\n\t}\n\n\tinternal static string BuildName(int index)\n\t{\n\t\tconst int offset = 'A';\n\t\tconst int length = 'Z' - offset;\n\t\tif (index <= length)\n\t\t{\n\t\t\treturn ((char)(offset + index)).ToString();\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn BuildName(index / length) + BuildName(index % length);\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/SqlGen/SqlSelectStatement.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Diagnostics;\n\nnamespace EntityFramework.Firebird.SqlGen;\n\ninternal sealed class SqlSelectStatement : ISqlFragment\n{\n\t#region Fields\n\n\tprivate bool _isDistinct;\n\tprivate List<Symbol> _allJoinExtents;\n\tprivate List<Symbol> _fromExtents;\n\tprivate Dictionary<Symbol, bool> _outerExtents;\n\tprivate FirstClause _first;\n\tprivate SkipClause _skip;\n\tprivate SqlBuilder _select = new SqlBuilder();\n\tprivate SqlBuilder _from = new SqlBuilder();\n\tprivate SqlBuilder _where;\n\tprivate SqlBuilder _groupBy;\n\tprivate SqlBuilder _orderBy;\n\t//indicates whether it is the top most select statement,\n\t// if not Order By should be omitted unless there is a corresponding TOP\n\tprivate bool _isTopMost;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic SqlBuilder OrderBy\n\t{\n\t\tget\n\t\t{\n\t\t\tif (null == _orderBy)\n\t\t\t{\n\t\t\t\t_orderBy = new SqlBuilder();\n\t\t\t}\n\t\t\treturn _orderBy;\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Internal Properties\n\n\t/// <summary>\n\t/// Do we need to add a DISTINCT at the beginning of the SELECT\n\t/// </summary>\n\tinternal bool IsDistinct\n\t{\n\t\tget { return _isDistinct; }\n\t\tset { _isDistinct = value; }\n\t}\n\n\tinternal List<Symbol> AllJoinExtents\n\t{\n\t\tget { return _allJoinExtents; }\n\t\t// We have a setter as well, even though this is a list,\n\t\t// since we use this field only in special cases.\n\t\tset { _allJoinExtents = value; }\n\t}\n\n\tinternal List<Symbol> FromExtents\n\t{\n\t\tget\n\t\t{\n\t\t\tif (null == _fromExtents)\n\t\t\t{\n\t\t\t\t_fromExtents = new List<Symbol>();\n\t\t\t}\n\t\t\treturn _fromExtents;\n\t\t}\n\t}\n\n\tinternal Dictionary<Symbol, bool> OuterExtents\n\t{\n\t\tget\n\t\t{\n\t\t\tif (null == _outerExtents)\n\t\t\t{\n\t\t\t\t_outerExtents = new Dictionary<Symbol, bool>();\n\t\t\t}\n\t\t\treturn _outerExtents;\n\t\t}\n\t}\n\n\tinternal FirstClause First\n\t{\n\t\tget { return _first; }\n\t\tset\n\t\t{\n\t\t\tDebug.Assert(_first == null, \"SqlSelectStatement.Top has already been set\");\n\t\t\t_first = value;\n\t\t}\n\t}\n\n\tinternal SkipClause Skip\n\t{\n\t\tget { return _skip; }\n\t\tset\n\t\t{\n\t\t\tDebug.Assert(_skip == null, \"SqlSelectStatement.Skip has already been set\");\n\t\t\t_skip = value;\n\t\t}\n\t}\n\n\tinternal SqlBuilder Select\n\t{\n\t\tget { return _select; }\n\t}\n\n\tinternal SqlBuilder From\n\t{\n\t\tget { return _from; }\n\t}\n\n\tinternal SqlBuilder Where\n\t{\n\t\tget\n\t\t{\n\t\t\tif (null == _where)\n\t\t\t{\n\t\t\t\t_where = new SqlBuilder();\n\t\t\t}\n\t\t\treturn _where;\n\t\t}\n\t}\n\n\tinternal SqlBuilder GroupBy\n\t{\n\t\tget\n\t\t{\n\t\t\tif (null == _groupBy)\n\t\t\t{\n\t\t\t\t_groupBy = new SqlBuilder();\n\t\t\t}\n\t\t\treturn _groupBy;\n\t\t}\n\t}\n\n\tinternal bool IsTopMost\n\t{\n\t\tget { return _isTopMost; }\n\t\tset { _isTopMost = value; }\n\t}\n\n\t#endregion\n\n\t#region ISqlFragment Members\n\n\t/// <summary>\n\t/// Write out a SQL select statement as a string.\n\t/// We have to\n\t/// <list type=\"number\">\n\t/// <item>Check whether the aliases extents we use in this statement have\n\t/// to be renamed.\n\t/// We first create a list of all the aliases used by the outer extents.\n\t/// For each of the FromExtents( or AllJoinExtents if it is non-null),\n\t/// rename it if it collides with the previous list.\n\t/// </item>\n\t/// <item>Write each of the clauses (if it exists) as a string</item>\n\t/// </list>\n\t/// </summary>\n\t/// <param name=\"writer\"></param>\n\t/// <param name=\"sqlGenerator\"></param>\n\tpublic void WriteSql(SqlWriter writer, SqlGenerator sqlGenerator)\n\t{\n\t\t#region Check if FROM aliases need to be renamed\n\n\t\t// Create a list of the aliases used by the outer extents\n\t\t// JoinSymbols have to be treated specially.\n\t\tList<string> outerExtentAliases = null;\n\n\t\tif ((null != _outerExtents) && (0 < _outerExtents.Count))\n\t\t{\n\t\t\tforeach (var outerExtent in _outerExtents.Keys)\n\t\t\t{\n\t\t\t\tif (outerExtent is JoinSymbol joinSymbol)\n\t\t\t\t{\n\t\t\t\t\tforeach (var symbol in joinSymbol.FlattenedExtentList)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (null == outerExtentAliases)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\touterExtentAliases = new List<string>();\n\t\t\t\t\t\t}\n\t\t\t\t\t\touterExtentAliases.Add(symbol.NewName);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (null == outerExtentAliases)\n\t\t\t\t\t{\n\t\t\t\t\t\touterExtentAliases = new List<string>();\n\t\t\t\t\t}\n\t\t\t\t\touterExtentAliases.Add(outerExtent.NewName);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// An then rename each of the FromExtents we have\n\t\t// If AllJoinExtents is non-null - it has precedence.\n\t\t// The new name is derived from the old name - we append an increasing int.\n\t\tvar extentList = AllJoinExtents ?? _fromExtents;\n\t\tif (null != extentList)\n\t\t{\n\t\t\tforeach (var fromAlias in extentList)\n\t\t\t{\n\t\t\t\tif ((null != outerExtentAliases) && outerExtentAliases.Contains(fromAlias.Name))\n\t\t\t\t{\n\t\t\t\t\tvar i = sqlGenerator.AllExtentNames[fromAlias.Name];\n\t\t\t\t\tstring newName;\n\n\t\t\t\t\tdo\n\t\t\t\t\t{\n\t\t\t\t\t\t++i;\n\t\t\t\t\t\tnewName = fromAlias.Name + i.ToString(System.Globalization.CultureInfo.InvariantCulture);\n\t\t\t\t\t}\n\t\t\t\t\twhile (sqlGenerator.AllExtentNames.ContainsKey(newName));\n\n\t\t\t\t\tsqlGenerator.AllExtentNames[fromAlias.Name] = i;\n\t\t\t\t\tfromAlias.NewName = newName;\n\n\t\t\t\t\t// Add extent to list of known names (although i is always incrementing, \"prefix11\" can\n\t\t\t\t\t// eventually collide with \"prefix1\" when it is extended)\n\t\t\t\t\tsqlGenerator.AllExtentNames[newName] = 0;\n\t\t\t\t}\n\n\t\t\t\t// Add the current alias to the list, so that the extents\n\t\t\t\t// that follow do not collide with me.\n\t\t\t\tif (null == outerExtentAliases)\n\t\t\t\t{\n\t\t\t\t\touterExtentAliases = new List<string>();\n\t\t\t\t}\n\t\t\t\touterExtentAliases.Add(fromAlias.NewName);\n\t\t\t}\n\t\t}\n\n\t\t#endregion\n\n\t\t// Increase the indent, so that the Sql statement is nested by one tab.\n\t\twriter.Indent += 1; // ++ can be confusing in this context\n\n\t\twriter.Write(\"SELECT \");\n\t\tif (IsDistinct)\n\t\t{\n\t\t\twriter.Write(\"DISTINCT \");\n\t\t}\n\n\t\tif (First != null)\n\t\t{\n\t\t\tFirst.WriteSql(writer, sqlGenerator);\n\t\t}\n\n\t\tif (Skip != null)\n\t\t{\n\t\t\tSkip.WriteSql(writer, sqlGenerator);\n\t\t}\n\n\t\tif ((_select == null) || Select.IsEmpty)\n\t\t{\n\t\t\tDebug.Assert(false);  // we have removed all possibilities of SELECT *.\n\t\t\twriter.Write(\"*\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tSelect.WriteSql(writer, sqlGenerator);\n\t\t}\n\n\t\twriter.WriteLine();\n\t\twriter.Write(\"FROM \");\n\t\tFrom.WriteSql(writer, sqlGenerator);\n\n\t\tif ((_where != null) && !Where.IsEmpty)\n\t\t{\n\t\t\twriter.WriteLine();\n\t\t\twriter.Write(\"WHERE \");\n\t\t\tWhere.WriteSql(writer, sqlGenerator);\n\t\t}\n\n\t\tif ((_groupBy != null) && !GroupBy.IsEmpty)\n\t\t{\n\t\t\twriter.WriteLine();\n\t\t\twriter.Write(\"GROUP BY \");\n\t\t\tGroupBy.WriteSql(writer, sqlGenerator);\n\t\t}\n\n\t\tif ((_orderBy != null) && !OrderBy.IsEmpty && (IsTopMost || First != null || Skip != null))\n\t\t{\n\t\t\twriter.WriteLine();\n\t\t\twriter.Write(\"ORDER BY \");\n\t\t\tOrderBy.WriteSql(writer, sqlGenerator);\n\t\t}\n\n\t\t--writer.Indent;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/SqlGen/SqlWriter.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace EntityFramework.Firebird.SqlGen;\n\ninternal class SqlWriter : StringWriter\n{\n\t#region Fields\n\n\t// We start at -1, since the first select statement will increment it to 0.\n\tprivate int _indent = -1;\n\tprivate bool _atBeginningOfLine = true;\n\n\t#endregion\n\n\t#region Properties\n\n\t/// <summary>\n\t/// The number of tabs to be added at the beginning of each new line.\n\t/// </summary>\n\tinternal int Indent\n\t{\n\t\tget { return _indent; }\n\t\tset { _indent = value; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\t/// <summary>\n\t///\n\t/// </summary>\n\t/// <param name=\"b\"></param>\n\tpublic SqlWriter(StringBuilder b)\n\t\t: base(b, System.Globalization.CultureInfo.InvariantCulture)\n\t{\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\t/// <summary>\n\t/// Reset atBeginningofLine if we detect the newline string.\n\t/// <see cref=\"SqlBuilder.AppendLine\"/>\n\t/// Add as many tabs as the value of indent if we are at the\n\t/// beginning of a line.\n\t/// </summary>\n\t/// <param name=\"value\"></param>\n\tpublic override void Write(string value)\n\t{\n\t\tif (value == Environment.NewLine)\n\t\t{\n\t\t\tbase.WriteLine();\n\t\t\t_atBeginningOfLine = true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (_atBeginningOfLine)\n\t\t\t{\n\t\t\t\tif (_indent > 0)\n\t\t\t\t{\n\t\t\t\t\tbase.Write(new string('\\t', _indent));\n\t\t\t\t}\n\t\t\t\t_atBeginningOfLine = false;\n\t\t\t}\n\t\t\tbase.Write(value);\n\t\t}\n\t}\n\n\tpublic override void WriteLine()\n\t{\n\t\tbase.WriteLine();\n\t\t_atBeginningOfLine = true;\n\t}\n\n\tpublic override void WriteLine(string value)\n\t{\n\t\tWrite(value);\n\t\tWriteLine();\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/SqlGen/Symbol.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Data.Entity.Core.Metadata.Edm;\n\nnamespace EntityFramework.Firebird.SqlGen;\n\ninternal class Symbol : ISqlFragment\n{\n\t#region Fields\n\n\tprivate Dictionary<string, Symbol> _columns = new Dictionary<string, Symbol>(StringComparer.CurrentCultureIgnoreCase);\n\tprivate bool _needsRenaming = false;\n\tprivate bool _isUnnest = false;\n\tprivate string _name;\n\tprivate string _newName;\n\tprivate TypeUsage _type;\n\n\t#endregion\n\n\t#region Public Properties\n\n\tpublic string Name\n\t{\n\t\tget { return _name; }\n\t}\n\n\tpublic string NewName\n\t{\n\t\tget { return _newName; }\n\t\tset { _newName = value; }\n\t}\n\n\t#endregion\n\n\t#region Internal Properties\n\n\tinternal Dictionary<string, Symbol> Columns\n\t{\n\t\tget { return _columns; }\n\t}\n\n\tinternal bool NeedsRenaming\n\t{\n\t\tget { return _needsRenaming; }\n\t\tset { _needsRenaming = value; }\n\t}\n\n\tinternal bool IsUnnest\n\t{\n\t\tget { return _isUnnest; }\n\t\tset { _isUnnest = value; }\n\t}\n\n\tinternal TypeUsage Type\n\t{\n\t\tget { return _type; }\n\t\tset { _type = value; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic Symbol(string name, TypeUsage type)\n\t{\n\t\t_name = name;\n\t\t_newName = name;\n\t\tType = type;\n\t}\n\n\t#endregion\n\n\t#region ISqlFragment Members\n\n\t/// <summary>\n\t/// Write this symbol out as a string for sql.  This is just\n\t/// the new name of the symbol (which could be the same as the old name).\n\t///\n\t/// We rename columns here if necessary.\n\t/// </summary>\n\t/// <param name=\"writer\"></param>\n\t/// <param name=\"sqlGenerator\"></param>\n\tpublic void WriteSql(SqlWriter writer, SqlGenerator sqlGenerator)\n\t{\n\t\tif (NeedsRenaming)\n\t\t{\n\t\t\tstring newName;\n\t\t\tvar i = sqlGenerator.AllColumnNames[NewName];\n\t\t\tdo\n\t\t\t{\n\t\t\t\t++i;\n\t\t\t\tnewName = Name + i.ToString(System.Globalization.CultureInfo.InvariantCulture);\n\t\t\t} while (sqlGenerator.AllColumnNames.ContainsKey(newName));\n\t\t\tsqlGenerator.AllColumnNames[NewName] = i;\n\n\t\t\t// Prevent it from being renamed repeatedly.\n\t\t\tNeedsRenaming = false;\n\t\t\tNewName = newName;\n\n\t\t\t// Add this column name to list of known names so that there are no subsequent\n\t\t\t// collisions\n\t\t\tsqlGenerator.AllColumnNames[newName] = 0;\n\t\t}\n\n\t\twriter.Write(SqlGenerator.QuoteIdentifier(NewName));\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/SqlGen/SymbolPair.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Diagnostics;\n\nnamespace EntityFramework.Firebird.SqlGen;\n\ninternal class SymbolPair : ISqlFragment\n{\n\t#region Fields\n\n\tprivate Symbol _source;\n\tprivate Symbol _column;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic Symbol Source\n\t{\n\t\tget { return _source; }\n\t\tset { _source = value; }\n\t}\n\n\tpublic Symbol Column\n\t{\n\t\tget { return _column; }\n\t\tset { _column = value; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic SymbolPair(Symbol source, Symbol column)\n\t{\n\t\tSource = source;\n\t\tColumn = column;\n\t}\n\n\t#endregion\n\n\t#region ISqlFragment Members\n\n\tpublic void WriteSql(SqlWriter writer, SqlGenerator sqlGenerator)\n\t{\n\t\t// Symbol pair should never be part of a SqlBuilder.\n\t\tDebug.Assert(false);\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/SqlGen/SymbolTable.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\n\nnamespace EntityFramework.Firebird.SqlGen;\n\ninternal sealed class SymbolTable\n{\n\t#region Fields\n\n\tprivate List<Dictionary<string, Symbol>> _symbols = new List<Dictionary<string, Symbol>>();\n\n\t#endregion\n\n\t#region Methods\n\n\tinternal void EnterScope()\n\t{\n\t\t_symbols.Add(new Dictionary<string, Symbol>(StringComparer.OrdinalIgnoreCase));\n\t}\n\n\tinternal void ExitScope()\n\t{\n\t\t_symbols.RemoveAt(_symbols.Count - 1);\n\t}\n\n\tinternal void Add(string name, Symbol value)\n\t{\n\t\t_symbols[_symbols.Count - 1][name] = value;\n\t}\n\n\tinternal Symbol Lookup(string name)\n\t{\n\t\tfor (var i = _symbols.Count - 1; i >= 0; --i)\n\t\t{\n\t\t\tif (_symbols[i].ContainsKey(name))\n\t\t\t{\n\t\t\t\treturn _symbols[i][name];\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/SsdlToFb.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Data.Entity.Core.Metadata.Edm;\nusing System.Linq;\nusing System.Text;\nusing EntityFramework.Firebird.SqlGen;\n\nnamespace EntityFramework.Firebird;\n\ninternal static class SsdlToFb\n{\n\tpublic static string Transform(StoreItemCollection storeItems, string providerManifestToken)\n\t{\n\t\tvar result = new StringBuilder();\n\n\t\tif (storeItems != null)\n\t\t{\n\t\t\tresult.Append(string.Join(Environment.NewLine, Tables(storeItems)));\n\t\t\tresult.AppendLine();\n\t\t\tresult.Append(string.Join(Environment.NewLine, ForeignKeyConstraints(storeItems)));\n\t\t\tresult.AppendLine();\n\t\t}\n\n\t\treturn result.ToString();\n\t}\n\n\tstatic IEnumerable<string> Tables(StoreItemCollection storeItems)\n\t{\n\t\tforeach (var entitySet in storeItems.GetItems<EntityContainer>()[0].BaseEntitySets.OfType<EntitySet>())\n\t\t{\n\t\t\tvar result = new StringBuilder();\n\t\t\tvar additionalColumnComments = new Dictionary<string, string>();\n\t\t\tresult.AppendFormat(\"RECREATE TABLE {0} (\", SqlGenerator.QuoteIdentifier(MetadataHelpers.GetTableName(entitySet)));\n\t\t\tresult.AppendLine();\n\t\t\tforeach (var property in MetadataHelpers.GetProperties(entitySet.ElementType))\n\t\t\t{\n\t\t\t\tvar column = GenerateColumn(property);\n\t\t\t\tresult.Append(\"\\t\");\n\t\t\t\tresult.Append(column.ColumnName);\n\t\t\t\tresult.Append(\",\");\n\t\t\t\tresult.AppendLine();\n\t\t\t\tforeach (var item in column.ColumnComments)\n\t\t\t\t\tadditionalColumnComments.Add(item.Key, item.Value);\n\t\t\t}\n\t\t\tresult.AppendFormat(\"CONSTRAINT {0} PRIMARY KEY ({1})\",\n\t\t\t\tSqlGenerator.QuoteIdentifier(string.Format(\"PK_{0}\", MetadataHelpers.GetTableName(entitySet))),\n\t\t\t\tstring.Join(\", \", entitySet.ElementType.KeyMembers.Select(pk => SqlGenerator.QuoteIdentifier(pk.Name))));\n\t\t\tresult.AppendLine();\n\t\t\tresult.Append(\");\");\n\t\t\tresult.AppendLine();\n\t\t\tforeach (var identity in entitySet.ElementType.KeyMembers.Where(pk => MetadataHelpers.IsStoreGeneratedIdentity(pk)).Select(i => i.Name))\n\t\t\t{\n\t\t\t\tadditionalColumnComments.Add(identity, \"#PK_GEN#\");\n\t\t\t}\n\t\t\tforeach (var comment in additionalColumnComments)\n\t\t\t{\n\t\t\t\tresult.AppendFormat(\"COMMENT ON COLUMN {0}.{1} IS '{2}';\",\n\t\t\t\t\tSqlGenerator.QuoteIdentifier(MetadataHelpers.GetTableName(entitySet)),\n\t\t\t\t\tSqlGenerator.QuoteIdentifier(comment.Key),\n\t\t\t\t\tcomment.Value);\n\t\t\t\tresult.AppendLine();\n\t\t\t}\n\t\t\tyield return result.ToString();\n\t\t}\n\t}\n\n\tstatic IEnumerable<string> ForeignKeyConstraints(StoreItemCollection storeItems)\n\t{\n\t\tforeach (var associationSet in storeItems.GetItems<EntityContainer>()[0].BaseEntitySets.OfType<AssociationSet>())\n\t\t{\n\t\t\tvar result = new StringBuilder();\n\t\t\tvar constraint = associationSet.ElementType.ReferentialConstraints.Single<ReferentialConstraint>();\n\t\t\tvar end = associationSet.AssociationSetEnds[constraint.FromRole.Name];\n\t\t\tvar end2 = associationSet.AssociationSetEnds[constraint.ToRole.Name];\n\t\t\tresult.AppendFormat(\"ALTER TABLE {0} ADD CONSTRAINT {1} FOREIGN KEY ({2})\",\n\t\t\t\tSqlGenerator.QuoteIdentifier(MetadataHelpers.GetTableName(end2.EntitySet)),\n\t\t\t\tSqlGenerator.QuoteIdentifier(string.Format(\"FK_{0}\", associationSet.Name)),\n\t\t\t\tstring.Join(\", \", constraint.ToProperties.Select(fk => SqlGenerator.QuoteIdentifier(fk.Name))));\n\t\t\tresult.AppendLine();\n\t\t\tresult.AppendFormat(\"REFERENCES {0}({1})\",\n\t\t\t\tSqlGenerator.QuoteIdentifier(MetadataHelpers.GetTableName(end.EntitySet)),\n\t\t\t\tstring.Join(\", \", constraint.FromProperties.Select(pk => SqlGenerator.QuoteIdentifier(pk.Name))));\n\t\t\tresult.AppendLine();\n\t\t\tresult.AppendFormat(\"ON DELETE {0}\",\n\t\t\t\tend.CorrespondingAssociationEndMember.DeleteBehavior == OperationAction.Cascade ? \"CASCADE\" : \"NO ACTION\");\n\t\t\tresult.Append(\";\");\n\t\t\tyield return result.ToString();\n\t\t}\n\t}\n\n\tclass GenerateColumnResult\n\t{\n\t\tpublic string ColumnName { get; set; }\n\t\tpublic IDictionary<string, string> ColumnComments { get; set; }\n\t}\n\tstatic GenerateColumnResult GenerateColumn(EdmProperty property)\n\t{\n\t\tvar column = new StringBuilder();\n\t\tvar columnComments = new Dictionary<string, string>();\n\t\tcolumn.Append(SqlGenerator.QuoteIdentifier(property.Name));\n\t\tcolumn.Append(\" \");\n\t\tcolumn.Append(SqlGenerator.GetSqlPrimitiveType(property.TypeUsage));\n\t\tswitch (MetadataHelpers.GetEdmType<PrimitiveType>(property.TypeUsage).PrimitiveTypeKind)\n\t\t{\n\t\t\tcase PrimitiveTypeKind.Boolean:\n\t\t\t\tcolumn.AppendFormat(\" CHECK ({0} IN (1,0))\", SqlGenerator.QuoteIdentifier(property.Name));\n\t\t\t\tcolumnComments.Add(property.Name, \"#BOOL#\");\n\t\t\t\tbreak;\n\t\t\tcase PrimitiveTypeKind.Guid:\n\t\t\t\tcolumnComments.Add(property.Name, \"#GUID#\");\n\t\t\t\tbreak;\n\t\t}\n\t\tif (!property.Nullable)\n\t\t{\n\t\t\tcolumn.Append(\" NOT NULL\");\n\t\t}\n\t\treturn new GenerateColumnResult() { ColumnName = column.ToString(), ColumnComments = columnComments };\n\t}\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/TypeHelpers.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Data.Entity.Core.Metadata.Edm;\n\nnamespace EntityFramework.Firebird;\n\ninternal static class TypeHelpers\n{\n\tpublic static bool TryGetPrecision(TypeUsage tu, out byte precision)\n\t{\n\t\tprecision = 0;\n\t\tif (tu.Facets.TryGetValue(\"Precision\", false, out var f))\n\t\t{\n\t\t\tif (!f.IsUnbounded && f.Value != null)\n\t\t\t{\n\t\t\t\tprecision = (byte)f.Value;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic static bool TryGetMaxLength(TypeUsage tu, out int maxLength)\n\t{\n\t\tmaxLength = 0;\n\t\tif (tu.Facets.TryGetValue(\"MaxLength\", false, out var f))\n\t\t{\n\t\t\tif (!f.IsUnbounded && f.Value != null)\n\t\t\t{\n\t\t\t\tmaxLength = (int)f.Value;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic static bool TryGetScale(TypeUsage tu, out byte scale)\n\t{\n\t\tscale = 0;\n\t\tif (tu.Facets.TryGetValue(\"Scale\", false, out var f))\n\t\t{\n\t\t\tif (!f.IsUnbounded && f.Value != null)\n\t\t\t{\n\t\t\t\tscale = (byte)f.Value;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird/Web.config.install.xdt",
    "content": "﻿<configuration xmlns:xdt=\"http://schemas.microsoft.com/XML-Document-Transform\">\n\t<entityFramework>\n\t\t<defaultConnectionFactory xdt:Transform=\"Remove\" />\n\t\t<defaultConnectionFactory type=\"EntityFramework.Firebird.FbConnectionFactory, EntityFramework.Firebird\" xdt:Transform=\"Insert\" />\n\t\t<providers>\n\t\t\t<provider invariantName=\"FirebirdSql.Data.FirebirdClient\" type=\"EntityFramework.Firebird.FbProviderServices, EntityFramework.Firebird\" xdt:Transform=\"InsertIfMissing\" xdt:Locator=\"Match(invariantName)\" />\n\t\t</providers>\n\t</entityFramework>\n</configuration>\n"
  },
  {
    "path": "src/EntityFramework.Firebird.Tests/EntityFramework.Firebird.Tests.csproj",
    "content": "﻿<Project Sdk=\"Microsoft.NET.Sdk\">\n\t<PropertyGroup>\n\t\t<TargetFramework>net10.0</TargetFramework>\n\t\t<GenerateAssemblyInfo>false</GenerateAssemblyInfo>\n\t\t<GeneratePackageOnBuild>false</GeneratePackageOnBuild>\n\t\t<SkipSourceLink>true</SkipSourceLink>\n\t\t<AssemblyName>EntityFramework.Firebird.Tests</AssemblyName>\n\t\t<RootNamespace>EntityFramework.Firebird.Tests</RootNamespace>\n\t\t<SignAssembly>true</SignAssembly>\n\t\t<AssemblyOriginatorKeyFile>..\\FirebirdSql.Data.TestsBase\\FirebirdSql.Data.TestsBase.snk</AssemblyOriginatorKeyFile>\n\t\t<OutputType>Exe</OutputType>\n\t\t<StartupObject>FirebirdSql.Data.TestsBase.Program</StartupObject>\n\t</PropertyGroup>\n\t<ItemGroup>\n\t\t<Using Include=\"NUnit.Framework.Legacy.ClassicAssert\" Alias=\"Assert\" />\n\t\t<Using Include=\"NUnit.Framework.Legacy.CollectionAssert\" Alias=\"CollectionAssert\" />\n\t\t<Using Include=\"NUnit.Framework.Legacy.StringAssert\" Alias=\"StringAssert\" />\n\t</ItemGroup>\n\t<ItemGroup Condition=\"'$(TargetFramework)'=='net10.0'\">\n\t\t<!-- left in repo as an example/documentation for .NET Framework -->\n\t\t<None Remove=\"app.config\" />\n\t</ItemGroup>\n\t<ItemGroup>\n\t\t<PackageReference Include=\"Microsoft.NET.Test.Sdk\" Version=\"17.12.0\" />\n\t\t<PackageReference Include=\"NUnit\" Version=\"4.2.2\" />\n\t\t<PackageReference Include=\"NUnit3TestAdapter\" Version=\"4.6.0\" />\n\t\t<PackageReference Include=\"NUnitLite\" Version=\"4.2.2\" />\n\t</ItemGroup>\n\t<ItemGroup>\n\t\t<ProjectReference Include=\"..\\EntityFramework.Firebird\\EntityFramework.Firebird.csproj\" />\n\t</ItemGroup>\n\t<ItemGroup>\n\t\t<Service Include=\"{82a7f48d-3b50-4b1e-b82e-3ada8210c358}\" />\n\t</ItemGroup>\n\t<Import Project=\"..\\FirebirdSql.Data.TestsBase\\FirebirdSql.Data.TestsBase.projitems\" Label=\"Shared\" />\n</Project>\n"
  },
  {
    "path": "src/EntityFramework.Firebird.Tests/EntityFrameworkTestsBase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data.Entity;\nusing System.Data.Entity.Core.Common;\nusing FirebirdSql.Data.FirebirdClient;\nusing FirebirdSql.Data.TestsBase;\n\nnamespace EntityFramework.Firebird.Tests;\n\npublic abstract class EntityFrameworkTestsBase : FbTestsBase\n{\n\tstatic EntityFrameworkTestsBase()\n\t{\n#if !NETFRAMEWORK\n\t\t// example/documentation for .NET Framework\n\t\tSystem.Data.Common.DbProviderFactories.RegisterFactory(FbProviderServices.ProviderInvariantName, FirebirdClientFactory.Instance);\n#endif\n\t\tDbConfiguration.SetConfiguration(new FbTestDbContext.Conf());\n\t}\n\n\tpublic EntityFrameworkTestsBase()\n\t\t: base(FbServerType.Default, false, FbWireCrypt.Enabled, false)\n\t{ }\n\n\tpublic DbProviderServices GetProviderServices()\n\t{\n\t\treturn FbProviderServices.Instance;\n\t}\n\n\tpublic TContext GetDbContext<TContext>() where TContext : FbTestDbContext\n\t{\n\t\tDatabase.SetInitializer<TContext>(null);\n\t\tConnection.Close();\n\t\treturn (TContext)Activator.CreateInstance(typeof(TContext), Connection);\n\t}\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird.Tests/FbTestDbContext.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Data.Entity;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace EntityFramework.Firebird.Tests;\n\npublic class FbTestDbContext : DbContext\n{\n\tpublic class Conf : DbConfiguration\n\t{\n\t\tpublic Conf()\n\t\t{\n\t\t\tSetProviderServices(FbProviderServices.ProviderInvariantName, FbProviderServices.Instance);\n\t\t}\n\t}\n\n\tpublic FbTestDbContext(FbConnection conn)\n\t\t: base(conn, false)\n\t{ }\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird.Tests/InfrastructureTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing NUnit.Framework;\n\nnamespace EntityFramework.Firebird.Tests;\n\npublic class InfrastructureTests : EntityFrameworkTestsBase\n{\n\t[Test]\n\tpublic void DbProviderServicesTest()\n\t{\n\t\tobject dbproviderservices = GetProviderServices();\n\t\tAssert.IsNotNull(dbproviderservices);\n\t\tAssert.IsInstanceOf<FbProviderServices>(dbproviderservices);\n\t}\n\n\t[Test]\n\tpublic void ProviderManifestTest()\n\t{\n\t\tvar manifest = GetProviderServices().GetProviderManifest(\"foobar\");\n\t\tAssert.IsNotNull(manifest);\n\t}\n\n\t[Test]\n\tpublic void ProviderManifestTokenTest()\n\t{\n\t\tvar token = GetProviderServices().GetProviderManifestToken(Connection);\n\t\tAssert.IsNotNull(token);\n\t\tAssert.IsNotEmpty(token);\n\t\tvar v = new Version(token);\n\t\tAssert.Greater(v.Major, 0);\n\t\tAssert.GreaterOrEqual(v.Minor, 0);\n\t\tAssert.AreEqual(v.Build, -1);\n\t\tAssert.AreEqual(v.Revision, -1);\n\t}\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird.Tests/QueryTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Data.Entity;\nusing System.Linq;\nusing FirebirdSql.Data.FirebirdClient;\nusing NUnit.Framework;\n\nnamespace EntityFramework.Firebird.Tests;\n\npublic class QueryTests : EntityFrameworkTestsBase\n{\n\tclass QueryTest1Context : FbTestDbContext\n\t{\n\t\tpublic QueryTest1Context(FbConnection conn)\n\t\t\t: base(conn)\n\t\t{ }\n\n\t\tprotected override void OnModelCreating(DbModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnModelCreating(modelBuilder);\n\t\t\tvar queryTest1Entity = modelBuilder.Entity<QueryTest1Entity>();\n\t\t\tqueryTest1Entity.Property(x => x.ID).HasColumnName(\"ID\");\n\t\t\tqueryTest1Entity.ToTable(\"TEST_QUERYTEST1ENTITY\");\n\t\t}\n\n\t\tpublic IDbSet<QueryTest1Entity> QueryTest1Entity { get; set; }\n\t}\n\t[Test]\n\tpublic void QueryTest1()\n\t{\n\t\tusing (var c = GetDbContext<QueryTest1Context>())\n\t\t{\n\t\t\tc.Database.ExecuteSqlCommand(\"create table test_querytest1entity (id int primary key)\");\n\t\t\tAssert.DoesNotThrow(() => c.QueryTest1Entity.Max<QueryTest1Entity, int?>(x => x.ID));\n\t\t}\n\t}\n\n\tclass QueryTest2Context : FbTestDbContext\n\t{\n\t\tpublic QueryTest2Context(FbConnection conn)\n\t\t\t: base(conn)\n\t\t{ }\n\n\t\tprotected override void OnModelCreating(DbModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnModelCreating(modelBuilder);\n\t\t}\n\n\t\tpublic IDbSet<Foo> Foos { get; set; }\n\t}\n\t[Test]\n\tpublic void QueryTest2()\n\t{\n\t\tusing (var c = GetDbContext<QueryTest2Context>())\n\t\t{\n\t\t\tvar q = c.Foos\n\t\t\t\t.OrderBy(x => x.ID)\n\t\t\t\t.Take(45).Skip(0)\n\t\t\t\t.Select(x => new\n\t\t\t\t{\n\t\t\t\t\tx.ID,\n\t\t\t\t\tx.BazID,\n\t\t\t\t\tBazID2 = x.Baz.ID,\n\t\t\t\t\tx.Baz.BazString,\n\t\t\t\t});\n\t\t\tAssert.DoesNotThrow(() =>\n\t\t\t{\n\t\t\t\tq.ToString();\n\t\t\t});\n\t\t}\n\t}\n\n\tclass QueryTest3Context : FbTestDbContext\n\t{\n\t\tpublic QueryTest3Context(FbConnection conn)\n\t\t\t: base(conn)\n\t\t{ }\n\n\t\tprotected override void OnModelCreating(DbModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnModelCreating(modelBuilder);\n\t\t}\n\n\t\tpublic IDbSet<Foo> Foos { get; set; }\n\t}\n\t[Test]\n\tpublic void QueryTest3()\n\t{\n\t\tusing (var c = GetDbContext<QueryTest3Context>())\n\t\t{\n\t\t\tvar q = c.Foos\n\t\t\t\t .OrderByDescending(m => m.Bars.Count())\n\t\t\t\t .Skip(3)\n\t\t\t\t .SelectMany(m => m.Bars);\n\t\t\tAssert.DoesNotThrow(() =>\n\t\t\t{\n\t\t\t\tq.ToString();\n\t\t\t});\n\t\t}\n\t}\n\n\tclass ProperVarcharLengthForConstantContext : FbTestDbContext\n\t{\n\t\tpublic ProperVarcharLengthForConstantContext(FbConnection conn)\n\t\t\t: base(conn)\n\t\t{ }\n\n\t\tprotected override void OnModelCreating(DbModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnModelCreating(modelBuilder);\n\t\t}\n\n\t\tpublic IDbSet<Bar> Bars { get; set; }\n\t}\n\t[Test]\n\tpublic void ProperVarcharLengthForConstantTest()\n\t{\n\t\tusing (var c = GetDbContext<ProperVarcharLengthForConstantContext>())\n\t\t{\n\t\t\tvar q = c.Bars.Where(x => x.BarString == \"TEST\");\n\t\t\tStringAssert.Contains(\"CAST(_UTF8'TEST' AS VARCHAR(8191))\", q.ToString());\n\n\t\t}\n\t}\n\n\tclass DbFunctionsContext : FbTestDbContext\n\t{\n\t\tpublic DbFunctionsContext(FbConnection conn)\n\t\t\t: base(conn)\n\t\t{ }\n\n\t\tprotected override void OnModelCreating(DbModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnModelCreating(modelBuilder);\n\t\t}\n\n\t\tpublic IDbSet<Qux> Quxs { get; set; }\n\t}\n\t[Test]\n\tpublic void QueryTestDbFunctionsCreateDateTime1()\n\t{\n\t\tusing (var c = GetDbContext<DbFunctionsContext>())\n\t\t{\n\t\t\tvar q = c.Quxs\n\t\t\t\t.Where(x => x.QuxDateTime == DbFunctions.CreateDateTime(2020, 3, 19, 14, 12, 0))\n\t\t\t\t.ToString();\n\t\t\tStringAssert.Contains(\"CAST('2020-3-19 14:12:00' AS TIMESTAMP)\", q.ToString());\n\t\t}\n\t}\n\t[Test]\n\tpublic void QueryTestDbFunctionsCreateDateTime2()\n\t{\n\t\tusing (var c = GetDbContext<DbFunctionsContext>())\n\t\t{\n\t\t\tvar q = c.Quxs\n\t\t\t\t.Where(x => x.QuxDateTime == DbFunctions.CreateDateTime(2020, 3, 19, 14, 12, 36))\n\t\t\t\t.ToString();\n\t\t\tStringAssert.Contains(\"DATEADD(SECOND, CAST(36 AS DOUBLE PRECISION), CAST('2020-3-19 14:12:00' AS TIMESTAMP))\", q.ToString());\n\t\t}\n\t}\n\t[Test]\n\tpublic void QueryTestDbFunctionsCreateDateTime3()\n\t{\n\t\tusing (var c = GetDbContext<DbFunctionsContext>())\n\t\t{\n\t\t\tvar q = c.Quxs\n\t\t\t\t.Where(x => x.QuxDateTime == DbFunctions.CreateDateTime(null, null, null, null, null, null))\n\t\t\t\t.ToString();\n\t\t\tStringAssert.Contains(\"DATEADD(DAY, -1, DATEADD(MONTH, -1, DATEADD(YEAR, -1, CAST('0001-01-01 00:00:00' AS TIMESTAMP))))\", q.ToString());\n\t\t}\n\t}\n\t[Test]\n\tpublic void QueryTestDbFunctionsCreateDateTime4()\n\t{\n\t\tusing (var c = GetDbContext<DbFunctionsContext>())\n\t\t{\n\t\t\tvar q = c.Quxs\n\t\t\t\t.Where(x => x.QuxDateTime == DbFunctions.CreateDateTime(x.QuxYear, x.QuxMonth, x.QuxDay, null, null, null))\n\t\t\t\t.ToString();\n\t\t\tStringAssert.Contains(\"DATEADD(DAY, -1, DATEADD(MONTH, -1, DATEADD(YEAR, -1, DATEADD(DAY, \\\"B\\\".\\\"QuxDay\\\", DATEADD(MONTH, \\\"B\\\".\\\"QuxMonth\\\", DATEADD(YEAR, \\\"B\\\".\\\"QuxYear\\\", CAST('0001-01-01 00:00:00' AS TIMESTAMP)))))))\", q.ToString());\n\t\t}\n\t}\n}\n\nclass QueryTest1Entity\n{\n\tpublic int ID { get; set; }\n}\n\nclass Foo\n{\n\tpublic int ID { get; set; }\n\tpublic int BazID { get; set; }\n\tpublic ICollection<Bar> Bars { get; set; }\n\tpublic Baz Baz { get; set; }\n}\nclass Bar\n{\n\tpublic int ID { get; set; }\n\tpublic int FooID { get; set; }\n\tpublic string BarString { get; set; }\n\tpublic Foo Foo { get; set; }\n}\nclass Baz\n{\n\tpublic int ID { get; set; }\n\tpublic string BazString { get; set; }\n\tpublic ICollection<Foo> Foos { get; set; }\n}\nclass Qux\n{\n\tpublic int ID { get; set; }\n\tpublic DateTime QuxDateTime { get; set; }\n\tpublic int QuxYear { get; set; }\n\tpublic int QuxMonth { get; set; }\n\tpublic int QuxDay { get; set; }\n}\n"
  },
  {
    "path": "src/EntityFramework.Firebird.Tests/app.config",
    "content": "﻿<?xml version=\"1.0\"?>\n<configuration>\n\t<configSections>\n\t\t<section name=\"entityFramework\" type=\"System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" requirePermission=\"false\" />\n\t</configSections>\n\t<system.data>\n\t\t<DbProviderFactories>\n\t\t\t<clear />\n\t\t\t<add name=\"FirebirdClient Data Provider\" invariant=\"FirebirdSql.Data.FirebirdClient\" description=\".Net Framework Data Provider for Firebird\" type=\"FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient\" />\n\t\t</DbProviderFactories>\n\t</system.data>\n\t<entityFramework>\n\t\t<defaultConnectionFactory type=\"EntityFramework.Firebird.FbConnectionFactory, EntityFramework.Firebird\" />\n\t\t<providers>\n\t\t\t<provider invariantName=\"FirebirdSql.Data.FirebirdClient\" type=\"EntityFramework.Firebird.FbProviderServices, EntityFramework.Firebird\" />\n\t\t</providers>\n\t</entityFramework>\n</configuration>"
  },
  {
    "path": "src/FirebirdSql.Data.External/FirebirdSql.Data.External.projitems",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <PropertyGroup>\n    <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>\n    <HasSharedItems>true</HasSharedItems>\n    <SharedGUID>884ee120-b22e-4940-8c1c-626f13028376</SharedGUID>\n  </PropertyGroup>\n  <PropertyGroup Label=\"Configuration\">\n    <Import_RootNamespace>FirebirdSql.Data.External</Import_RootNamespace>\n  </PropertyGroup>\n  <ItemGroup>\n    <Compile Include=\"$(MSBuildThisFileDirectory)RC4\\ICipherParameters.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)RC4\\KeyParameter.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)RC4\\RC4Engine.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)zlib\\Deflate.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)zlib\\Inflate.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)zlib\\InfTree.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)zlib\\Tree.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)zlib\\Zlib.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)zlib\\ZlibCodec.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)zlib\\ZlibConstants.cs\" />\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "src/FirebirdSql.Data.External/FirebirdSql.Data.External.shproj",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>884ee120-b22e-4940-8c1c-626f13028376</ProjectGuid>\n    <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>\n  </PropertyGroup>\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\n  <Import Project=\"$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\CodeSharing\\Microsoft.CodeSharing.Common.Default.props\" />\n  <Import Project=\"$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\CodeSharing\\Microsoft.CodeSharing.Common.props\" />\n  <PropertyGroup />\n  <Import Project=\"FirebirdSql.Data.External.projitems\" Label=\"Shared\" />\n  <Import Project=\"$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\CodeSharing\\Microsoft.CodeSharing.CSharp.targets\" />\n</Project>\n"
  },
  {
    "path": "src/FirebirdSql.Data.External/RC4/ICipherParameters.cs",
    "content": "using System;\n\nnamespace Org.BouncyCastle.Crypto\n{\n    /**\n     * all parameter classes implement this.\n     */\n    internal interface ICipherParameters\n    {\n    }\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.External/RC4/KeyParameter.cs",
    "content": "using System;\n\nusing Org.BouncyCastle.Crypto;\n\nnamespace Org.BouncyCastle.Crypto.Parameters\n{\n    internal class KeyParameter\n\t\t: ICipherParameters\n    {\n        private readonly byte[] key;\n\n\t\tpublic KeyParameter(\n\t\t\tbyte[] key)\n\t\t{\n\t\t\tif (key == null)\n\t\t\t\tthrow new ArgumentNullException(\"key\");\n\n\t\t\tthis.key = (byte[]) key.Clone();\n\t\t}\n\n\t\tpublic KeyParameter(\n            byte[]\tkey,\n            int\t\tkeyOff,\n            int\t\tkeyLen)\n        {\n\t\t\tif (key == null)\n\t\t\t\tthrow new ArgumentNullException(\"key\");\n\t\t\tif (keyOff < 0 || keyOff > key.Length)\n\t\t\t\tthrow new ArgumentOutOfRangeException(\"keyOff\");\n            if (keyLen < 0 || keyLen > (key.Length - keyOff))\n\t\t\t\tthrow new ArgumentOutOfRangeException(\"keyLen\");\n\n\t\t\tthis.key = new byte[keyLen];\n            Array.Copy(key, keyOff, this.key, 0, keyLen);\n        }\n\n\t\tpublic byte[] GetKey()\n        {\n\t\t\treturn (byte[]) key.Clone();\n        }\n    }\n\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.External/RC4/RC4Engine.cs",
    "content": "using System;\n\nusing Org.BouncyCastle.Crypto.Parameters;\n//using Org.BouncyCastle.Utilities;\n\nnamespace Org.BouncyCastle.Crypto.Engines\n{\n    internal class RC4Engine\n\t\t//: IStreamCipher\n    {\n        private readonly static int STATE_LENGTH = 256;\n\n        /*\n        * variables to hold the state of the RC4 engine\n        * during encryption and decryption\n        */\n\n        private byte[]\tengineState;\n        private int\t\tx;\n        private int\t\ty;\n        private byte[]\tworkingKey;\n\n        /**\n        * initialise a RC4 cipher.\n        *\n        * @param forEncryption whether or not we are for encryption.\n        * @param parameters the parameters required to set up the cipher.\n        * @exception ArgumentException if the parameters argument is\n        * inappropriate.\n        */\n        public virtual void Init(\n            bool\t\t\t\tforEncryption,\n            ICipherParameters\tparameters)\n        {\n            if (parameters is KeyParameter)\n            {\n                /*\n                * RC4 encryption and decryption is completely\n                * symmetrical, so the 'forEncryption' is\n                * irrelevant.\n                */\n                workingKey = ((KeyParameter)parameters).GetKey();\n                SetKey(workingKey);\n\n                return;\n            }\n\n            //throw new ArgumentException(\"invalid parameter passed to RC4 init - \" + Platform.GetTypeName(parameters));\n            throw new ArgumentException(\"invalid parameter passed to RC4 init\");\n\t\t}\n\n        public virtual string AlgorithmName\n        {\n            get { return \"RC4\"; }\n        }\n\n        public virtual byte ReturnByte(\n\t\t\tbyte input)\n        {\n            x = (x + 1) & 0xff;\n            y = (engineState[x] + y) & 0xff;\n\n            // swap\n            byte tmp = engineState[x];\n            engineState[x] = engineState[y];\n            engineState[y] = tmp;\n\n            // xor\n            return (byte)(input ^ engineState[(engineState[x] + engineState[y]) & 0xff]);\n        }\n\n        public virtual void ProcessBytes(\n            byte[]\tinput,\n            int\t\tinOff,\n            int\t\tlength,\n            byte[]\toutput,\n            int\t\toutOff)\n        {\n            //Check.DataLength(input, inOff, length, \"input buffer too short\");\n            //Check.OutputLength(output, outOff, length, \"output buffer too short\");\n\n            for (int i = 0; i < length ; i++)\n            {\n                x = (x + 1) & 0xff;\n                y = (engineState[x] + y) & 0xff;\n\n                // swap\n                byte tmp = engineState[x];\n                engineState[x] = engineState[y];\n                engineState[y] = tmp;\n\n                // xor\n                output[i+outOff] = (byte)(input[i + inOff]\n                        ^ engineState[(engineState[x] + engineState[y]) & 0xff]);\n            }\n        }\n\n        public virtual void Reset()\n        {\n            SetKey(workingKey);\n        }\n\n        // Private implementation\n\n        private void SetKey(\n\t\t\tbyte[] keyBytes)\n        {\n            workingKey = keyBytes;\n\n            // System.out.println(\"the key length is ; \"+ workingKey.Length);\n\n            x = 0;\n            y = 0;\n\n            if (engineState == null)\n            {\n                engineState = new byte[STATE_LENGTH];\n            }\n\n            // reset the state of the engine\n            for (int i=0; i < STATE_LENGTH; i++)\n            {\n                engineState[i] = (byte)i;\n            }\n\n            int i1 = 0;\n            int i2 = 0;\n\n            for (int i=0; i < STATE_LENGTH; i++)\n            {\n                i2 = ((keyBytes[i1] & 0xff) + engineState[i] + i2) & 0xff;\n                // do the byte-swap inline\n                byte tmp = engineState[i];\n                engineState[i] = engineState[i2];\n                engineState[i2] = tmp;\n                i1 = (i1+1) % keyBytes.Length;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.External/zlib/Deflate.cs",
    "content": "// Deflate.cs\n// ------------------------------------------------------------------\n//\n// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.\n// All rights reserved.\n//\n// This code module is part of DotNetZip, a zipfile class library.\n//\n// ------------------------------------------------------------------\n//\n// This code is licensed under the Microsoft Public License.\n// See the file License.txt for the license details.\n// More info on: http://dotnetzip.codeplex.com\n//\n// ------------------------------------------------------------------\n//\n// last saved (in emacs):\n// Time-stamp: <2011-August-03 19:52:15>\n//\n// ------------------------------------------------------------------\n//\n// This module defines logic for handling the Deflate or compression.\n//\n// This code is based on multiple sources:\n// - the original zlib v1.2.3 source, which is Copyright (C) 1995-2005 Jean-loup Gailly.\n// - the original jzlib, which is Copyright (c) 2000-2003 ymnk, JCraft,Inc.\n//\n// However, this code is significantly different from both.\n// The object model is not the same, and many of the behaviors are different.\n//\n// In keeping with the license for these other works, the copyrights for\n// jzlib and zlib are here.\n//\n// -----------------------------------------------------------------------\n// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are met:\n//\n// 1. Redistributions of source code must retain the above copyright notice,\n// this list of conditions and the following disclaimer.\n//\n// 2. Redistributions in binary form must reproduce the above copyright\n// notice, this list of conditions and the following disclaimer in\n// the documentation and/or other materials provided with the distribution.\n//\n// 3. The names of the authors may not be used to endorse or promote products\n// derived from this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,\n// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\n// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,\n// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,\n// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\n// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// -----------------------------------------------------------------------\n//\n// This program is based on zlib-1.1.3; credit to authors\n// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)\n// and contributors of zlib.\n//\n// -----------------------------------------------------------------------\n\n\nusing System;\n\nnamespace Ionic.Zlib\n{\n\n    internal enum BlockState\n    {\n        NeedMore = 0,       // block not completed, need more input or more output\n        BlockDone,          // block flush performed\n        FinishStarted,              // finish started, need only more output at next deflate\n        FinishDone          // finish done, accept no more input or output\n    }\n\n    internal enum DeflateFlavor\n    {\n        Store,\n        Fast,\n        Slow\n    }\n\n    internal sealed class DeflateManager\n    {\n        private static readonly int MEM_LEVEL_MAX = 9;\n        private static readonly int MEM_LEVEL_DEFAULT = 8;\n\n        internal delegate BlockState CompressFunc(FlushType flush);\n\n        internal class Config\n        {\n            // Use a faster search when the previous match is longer than this\n            internal int GoodLength; // reduce lazy search above this match length\n\n            // Attempt to find a better match only when the current match is\n            // strictly smaller than this value. This mechanism is used only for\n            // compression levels >= 4.  For levels 1,2,3: MaxLazy is actually\n            // MaxInsertLength. (See DeflateFast)\n\n            internal int MaxLazy;    // do not perform lazy search above this match length\n\n            internal int NiceLength; // quit search above this match length\n\n            // To speed up deflation, hash chains are never searched beyond this\n            // length.  A higher limit improves compression ratio but degrades the speed.\n\n            internal int MaxChainLength;\n\n            internal DeflateFlavor Flavor;\n\n            private Config(int goodLength, int maxLazy, int niceLength, int maxChainLength, DeflateFlavor flavor)\n            {\n                this.GoodLength = goodLength;\n                this.MaxLazy = maxLazy;\n                this.NiceLength = niceLength;\n                this.MaxChainLength = maxChainLength;\n                this.Flavor = flavor;\n            }\n\n            public static Config Lookup(CompressionLevel level)\n            {\n                return Table[(int)level];\n            }\n\n\n            static Config()\n            {\n                Table = new Config[] {\n                    new Config(0, 0, 0, 0, DeflateFlavor.Store),\n                    new Config(4, 4, 8, 4, DeflateFlavor.Fast),\n                    new Config(4, 5, 16, 8, DeflateFlavor.Fast),\n                    new Config(4, 6, 32, 32, DeflateFlavor.Fast),\n\n                    new Config(4, 4, 16, 16, DeflateFlavor.Slow),\n                    new Config(8, 16, 32, 32, DeflateFlavor.Slow),\n                    new Config(8, 16, 128, 128, DeflateFlavor.Slow),\n                    new Config(8, 32, 128, 256, DeflateFlavor.Slow),\n                    new Config(32, 128, 258, 1024, DeflateFlavor.Slow),\n                    new Config(32, 258, 258, 4096, DeflateFlavor.Slow),\n                };\n            }\n\n            private static readonly Config[] Table;\n        }\n\n\n        private CompressFunc DeflateFunction;\n\n        private static readonly System.String[] _ErrorMessage = new System.String[]\n        {\n            \"need dictionary\",\n            \"stream end\",\n            \"\",\n            \"file error\",\n            \"stream error\",\n            \"data error\",\n            \"insufficient memory\",\n            \"buffer error\",\n            \"incompatible version\",\n            \"\"\n        };\n\n        // preset dictionary flag in zlib header\n        private static readonly int PRESET_DICT = 0x20;\n\n        private static readonly int INIT_STATE = 42;\n        private static readonly int BUSY_STATE = 113;\n        private static readonly int FINISH_STATE = 666;\n\n        // The deflate compression method\n        private static readonly int Z_DEFLATED = 8;\n\n        private static readonly int STORED_BLOCK = 0;\n        private static readonly int STATIC_TREES = 1;\n        private static readonly int DYN_TREES = 2;\n\n        // The three kinds of block type\n        private static readonly int Z_BINARY = 0;\n        private static readonly int Z_ASCII = 1;\n        private static readonly int Z_UNKNOWN = 2;\n\n        private static readonly int Buf_size = 8 * 2;\n\n        private static readonly int MIN_MATCH = 3;\n        private static readonly int MAX_MATCH = 258;\n\n        private static readonly int MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1);\n\n        private static readonly int HEAP_SIZE = (2 * InternalConstants.L_CODES + 1);\n\n        private static readonly int END_BLOCK = 256;\n\n        internal ZlibCodec _codec; // the zlib encoder/decoder\n        internal int status;       // as the name implies\n        internal byte[] pending;   // output still pending - waiting to be compressed\n        internal int nextPending;  // index of next pending byte to output to the stream\n        internal int pendingCount; // number of bytes in the pending buffer\n\n        internal sbyte data_type;  // UNKNOWN, BINARY or ASCII\n        internal int last_flush;   // value of flush param for previous deflate call\n\n        internal int w_size;       // LZ77 window size (32K by default)\n        internal int w_bits;       // log2(w_size)  (8..16)\n        internal int w_mask;       // w_size - 1\n\n        //internal byte[] dictionary;\n        internal byte[] window;\n\n        // Sliding window. Input bytes are read into the second half of the window,\n        // and move to the first half later to keep a dictionary of at least wSize\n        // bytes. With this organization, matches are limited to a distance of\n        // wSize-MAX_MATCH bytes, but this ensures that IO is always\n        // performed with a length multiple of the block size.\n        //\n        // To do: use the user input buffer as sliding window.\n\n        internal int window_size;\n        // Actual size of window: 2*wSize, except when the user input buffer\n        // is directly used as sliding window.\n\n        internal short[] prev;\n        // Link to older string with same hash index. To limit the size of this\n        // array to 64K, this link is maintained only for the last 32K strings.\n        // An index in this array is thus a window index modulo 32K.\n\n        internal short[] head;  // Heads of the hash chains or NIL.\n\n        internal int ins_h;     // hash index of string to be inserted\n        internal int hash_size; // number of elements in hash table\n        internal int hash_bits; // log2(hash_size)\n        internal int hash_mask; // hash_size-1\n\n        // Number of bits by which ins_h must be shifted at each input\n        // step. It must be such that after MIN_MATCH steps, the oldest\n        // byte no longer takes part in the hash key, that is:\n        // hash_shift * MIN_MATCH >= hash_bits\n        internal int hash_shift;\n\n        // Window position at the beginning of the current output block. Gets\n        // negative when the window is moved backwards.\n\n        internal int block_start;\n\n        Config config;\n        internal int match_length;    // length of best match\n        internal int prev_match;      // previous match\n        internal int match_available; // set if previous match exists\n        internal int strstart;        // start of string to insert into.....????\n        internal int match_start;     // start of matching string\n        internal int lookahead;       // number of valid bytes ahead in window\n\n        // Length of the best match at previous step. Matches not greater than this\n        // are discarded. This is used in the lazy match evaluation.\n        internal int prev_length;\n\n        // Insert new strings in the hash table only if the match length is not\n        // greater than this length. This saves time but degrades compression.\n        // max_insert_length is used only for compression levels <= 3.\n\n        internal CompressionLevel compressionLevel; // compression level (1..9)\n        internal CompressionStrategy compressionStrategy; // favor or force Huffman coding\n\n\n        internal short[] dyn_ltree;         // literal and length tree\n        internal short[] dyn_dtree;         // distance tree\n        internal short[] bl_tree;           // Huffman tree for bit lengths\n\n        internal Tree treeLiterals = new Tree();  // desc for literal tree\n        internal Tree treeDistances = new Tree();  // desc for distance tree\n        internal Tree treeBitLengths = new Tree(); // desc for bit length tree\n\n        // number of codes at each bit length for an optimal tree\n        internal short[] bl_count = new short[InternalConstants.MAX_BITS + 1];\n\n        // heap used to build the Huffman trees\n        internal int[] heap = new int[2 * InternalConstants.L_CODES + 1];\n\n        internal int heap_len;              // number of elements in the heap\n        internal int heap_max;              // element of largest frequency\n\n        // The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.\n        // The same heap array is used to build all trees.\n\n        // Depth of each subtree used as tie breaker for trees of equal frequency\n        internal sbyte[] depth = new sbyte[2 * InternalConstants.L_CODES + 1];\n\n        internal int _lengthOffset;                 // index for literals or lengths\n\n\n        // Size of match buffer for literals/lengths.  There are 4 reasons for\n        // limiting lit_bufsize to 64K:\n        //   - frequencies can be kept in 16 bit counters\n        //   - if compression is not successful for the first block, all input\n        //     data is still in the window so we can still emit a stored block even\n        //     when input comes from standard input.  (This can also be done for\n        //     all blocks if lit_bufsize is not greater than 32K.)\n        //   - if compression is not successful for a file smaller than 64K, we can\n        //     even emit a stored file instead of a stored block (saving 5 bytes).\n        //     This is applicable only for zip (not gzip or zlib).\n        //   - creating new Huffman trees less frequently may not provide fast\n        //     adaptation to changes in the input data statistics. (Take for\n        //     example a binary file with poorly compressible code followed by\n        //     a highly compressible string table.) Smaller buffer sizes give\n        //     fast adaptation but have of course the overhead of transmitting\n        //     trees more frequently.\n\n        internal int lit_bufsize;\n\n        internal int last_lit;     // running index in l_buf\n\n        // Buffer for distances. To simplify the code, d_buf and l_buf have\n        // the same number of elements. To use different lengths, an extra flag\n        // array would be necessary.\n\n        internal int _distanceOffset;        // index into pending; points to distance data??\n\n        internal int opt_len;      // bit length of current block with optimal trees\n        internal int static_len;   // bit length of current block with static trees\n        internal int matches;      // number of string matches in current block\n        internal int last_eob_len; // bit length of EOB code for last block\n\n        // Output buffer. bits are inserted starting at the bottom (least\n        // significant bits).\n        internal short bi_buf;\n\n        // Number of valid bits in bi_buf.  All bits above the last valid bit\n        // are always zero.\n        internal int bi_valid;\n\n\n        internal DeflateManager()\n        {\n            dyn_ltree = new short[HEAP_SIZE * 2];\n            dyn_dtree = new short[(2 * InternalConstants.D_CODES + 1) * 2]; // distance tree\n            bl_tree = new short[(2 * InternalConstants.BL_CODES + 1) * 2]; // Huffman tree for bit lengths\n        }\n\n\n        // lm_init\n        private void _InitializeLazyMatch()\n        {\n            window_size = 2 * w_size;\n\n            // clear the hash - workitem 9063\n            Array.Clear(head, 0, hash_size);\n            //for (int i = 0; i < hash_size; i++) head[i] = 0;\n\n            config = Config.Lookup(compressionLevel);\n            SetDeflater();\n\n            strstart = 0;\n            block_start = 0;\n            lookahead = 0;\n            match_length = prev_length = MIN_MATCH - 1;\n            match_available = 0;\n            ins_h = 0;\n        }\n\n        // Initialize the tree data structures for a new zlib stream.\n        private void _InitializeTreeData()\n        {\n            treeLiterals.dyn_tree = dyn_ltree;\n            treeLiterals.staticTree = StaticTree.Literals;\n\n            treeDistances.dyn_tree = dyn_dtree;\n            treeDistances.staticTree = StaticTree.Distances;\n\n            treeBitLengths.dyn_tree = bl_tree;\n            treeBitLengths.staticTree = StaticTree.BitLengths;\n\n            bi_buf = 0;\n            bi_valid = 0;\n            last_eob_len = 8; // enough lookahead for inflate\n\n            // Initialize the first block of the first file:\n            _InitializeBlocks();\n        }\n\n        internal void _InitializeBlocks()\n        {\n            // Initialize the trees.\n            for (int i = 0; i < InternalConstants.L_CODES; i++)\n                dyn_ltree[i * 2] = 0;\n            for (int i = 0; i < InternalConstants.D_CODES; i++)\n                dyn_dtree[i * 2] = 0;\n            for (int i = 0; i < InternalConstants.BL_CODES; i++)\n                bl_tree[i * 2] = 0;\n\n            dyn_ltree[END_BLOCK * 2] = 1;\n            opt_len = static_len = 0;\n            last_lit = matches = 0;\n        }\n\n        // Restore the heap property by moving down the tree starting at node k,\n        // exchanging a node with the smallest of its two sons if necessary, stopping\n        // when the heap property is re-established (each father smaller than its\n        // two sons).\n        internal void pqdownheap(short[] tree, int k)\n        {\n            int v = heap[k];\n            int j = k << 1; // left son of k\n            while (j <= heap_len)\n            {\n                // Set j to the smallest of the two sons:\n                if (j < heap_len && _IsSmaller(tree, heap[j + 1], heap[j], depth))\n                {\n                    j++;\n                }\n                // Exit if v is smaller than both sons\n                if (_IsSmaller(tree, v, heap[j], depth))\n                    break;\n\n                // Exchange v with the smallest son\n                heap[k] = heap[j]; k = j;\n                // And continue down the tree, setting j to the left son of k\n                j <<= 1;\n            }\n            heap[k] = v;\n        }\n\n        internal static bool _IsSmaller(short[] tree, int n, int m, sbyte[] depth)\n        {\n            short tn2 = tree[n * 2];\n            short tm2 = tree[m * 2];\n            return (tn2 < tm2 || (tn2 == tm2 && depth[n] <= depth[m]));\n        }\n\n\n        // Scan a literal or distance tree to determine the frequencies of the codes\n        // in the bit length tree.\n        internal void scan_tree(short[] tree, int max_code)\n        {\n            int n; // iterates over all tree elements\n            int prevlen = -1; // last emitted length\n            int curlen; // length of current code\n            int nextlen = (int)tree[0 * 2 + 1]; // length of next code\n            int count = 0; // repeat count of the current code\n            int max_count = 7; // max repeat count\n            int min_count = 4; // min repeat count\n\n            if (nextlen == 0)\n            {\n                max_count = 138; min_count = 3;\n            }\n            tree[(max_code + 1) * 2 + 1] = (short)0x7fff; // guard //??\n\n            for (n = 0; n <= max_code; n++)\n            {\n                curlen = nextlen; nextlen = (int)tree[(n + 1) * 2 + 1];\n                if (++count < max_count && curlen == nextlen)\n                {\n                    continue;\n                }\n                else if (count < min_count)\n                {\n                    bl_tree[curlen * 2] = (short)(bl_tree[curlen * 2] + count);\n                }\n                else if (curlen != 0)\n                {\n                    if (curlen != prevlen)\n                        bl_tree[curlen * 2]++;\n                    bl_tree[InternalConstants.REP_3_6 * 2]++;\n                }\n                else if (count <= 10)\n                {\n                    bl_tree[InternalConstants.REPZ_3_10 * 2]++;\n                }\n                else\n                {\n                    bl_tree[InternalConstants.REPZ_11_138 * 2]++;\n                }\n                count = 0; prevlen = curlen;\n                if (nextlen == 0)\n                {\n                    max_count = 138; min_count = 3;\n                }\n                else if (curlen == nextlen)\n                {\n                    max_count = 6; min_count = 3;\n                }\n                else\n                {\n                    max_count = 7; min_count = 4;\n                }\n            }\n        }\n\n        // Construct the Huffman tree for the bit lengths and return the index in\n        // bl_order of the last bit length code to send.\n        internal int build_bl_tree()\n        {\n            int max_blindex; // index of last bit length code of non zero freq\n\n            // Determine the bit length frequencies for literal and distance trees\n            scan_tree(dyn_ltree, treeLiterals.max_code);\n            scan_tree(dyn_dtree, treeDistances.max_code);\n\n            // Build the bit length tree:\n            treeBitLengths.build_tree(this);\n            // opt_len now includes the length of the tree representations, except\n            // the lengths of the bit lengths codes and the 5+5+4 bits for the counts.\n\n            // Determine the number of bit length codes to send. The pkzip format\n            // requires that at least 4 bit length codes be sent. (appnote.txt says\n            // 3 but the actual value used is 4.)\n            for (max_blindex = InternalConstants.BL_CODES - 1; max_blindex >= 3; max_blindex--)\n            {\n                if (bl_tree[Tree.bl_order[max_blindex] * 2 + 1] != 0)\n                    break;\n            }\n            // Update opt_len to include the bit length tree and counts\n            opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n\n            return max_blindex;\n        }\n\n\n        // Send the header for a block using dynamic Huffman trees: the counts, the\n        // lengths of the bit length codes, the literal tree and the distance tree.\n        // IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.\n        internal void send_all_trees(int lcodes, int dcodes, int blcodes)\n        {\n            int rank; // index in bl_order\n\n            send_bits(lcodes - 257, 5); // not +255 as stated in appnote.txt\n            send_bits(dcodes - 1, 5);\n            send_bits(blcodes - 4, 4); // not -3 as stated in appnote.txt\n            for (rank = 0; rank < blcodes; rank++)\n            {\n                send_bits(bl_tree[Tree.bl_order[rank] * 2 + 1], 3);\n            }\n            send_tree(dyn_ltree, lcodes - 1); // literal tree\n            send_tree(dyn_dtree, dcodes - 1); // distance tree\n        }\n\n        // Send a literal or distance tree in compressed form, using the codes in\n        // bl_tree.\n        internal void send_tree(short[] tree, int max_code)\n        {\n            int n;                           // iterates over all tree elements\n            int prevlen   = -1;              // last emitted length\n            int curlen;                      // length of current code\n            int nextlen   = tree[0 * 2 + 1]; // length of next code\n            int count     = 0;               // repeat count of the current code\n            int max_count = 7;               // max repeat count\n            int min_count = 4;               // min repeat count\n\n            if (nextlen == 0)\n            {\n                max_count = 138; min_count = 3;\n            }\n\n            for (n = 0; n <= max_code; n++)\n            {\n                curlen = nextlen; nextlen = tree[(n + 1) * 2 + 1];\n                if (++count < max_count && curlen == nextlen)\n                {\n                    continue;\n                }\n                else if (count < min_count)\n                {\n                    do\n                    {\n                        send_code(curlen, bl_tree);\n                    }\n                    while (--count != 0);\n                }\n                else if (curlen != 0)\n                {\n                    if (curlen != prevlen)\n                    {\n                        send_code(curlen, bl_tree); count--;\n                    }\n                    send_code(InternalConstants.REP_3_6, bl_tree);\n                    send_bits(count - 3, 2);\n                }\n                else if (count <= 10)\n                {\n                    send_code(InternalConstants.REPZ_3_10, bl_tree);\n                    send_bits(count - 3, 3);\n                }\n                else\n                {\n                    send_code(InternalConstants.REPZ_11_138, bl_tree);\n                    send_bits(count - 11, 7);\n                }\n                count = 0; prevlen = curlen;\n                if (nextlen == 0)\n                {\n                    max_count = 138; min_count = 3;\n                }\n                else if (curlen == nextlen)\n                {\n                    max_count = 6; min_count = 3;\n                }\n                else\n                {\n                    max_count = 7; min_count = 4;\n                }\n            }\n        }\n\n        // Output a block of bytes on the stream.\n        // IN assertion: there is enough room in pending_buf.\n        private void put_bytes(byte[] p, int start, int len)\n        {\n            Array.Copy(p, start, pending, pendingCount, len);\n            pendingCount += len;\n        }\n\n#if NOTNEEDED\n        private void put_byte(byte c)\n        {\n            pending[pendingCount++] = c;\n        }\n        internal void put_short(int b)\n        {\n            unchecked\n            {\n                pending[pendingCount++] = (byte)b;\n                pending[pendingCount++] = (byte)(b >> 8);\n            }\n        }\n        internal void putShortMSB(int b)\n        {\n            unchecked\n            {\n                pending[pendingCount++] = (byte)(b >> 8);\n                pending[pendingCount++] = (byte)b;\n            }\n        }\n#endif\n\n        internal void send_code(int c, short[] tree)\n        {\n            int c2 = c * 2;\n            send_bits((tree[c2] & 0xffff), (tree[c2 + 1] & 0xffff));\n        }\n\n        internal void send_bits(int value, int length)\n        {\n            int len = length;\n            unchecked\n            {\n                if (bi_valid > (int)Buf_size - len)\n                {\n                    //int val = value;\n                    //      bi_buf |= (val << bi_valid);\n\n                    bi_buf |= (short)((value << bi_valid) & 0xffff);\n                    //put_short(bi_buf);\n                        pending[pendingCount++] = (byte)bi_buf;\n                        pending[pendingCount++] = (byte)(bi_buf >> 8);\n\n\n                    bi_buf = (short)((uint)value >> (Buf_size - bi_valid));\n                    bi_valid += len - Buf_size;\n                }\n                else\n                {\n                    //      bi_buf |= (value) << bi_valid;\n                    bi_buf |= (short)((value << bi_valid) & 0xffff);\n                    bi_valid += len;\n                }\n            }\n        }\n\n        // Send one empty static block to give enough lookahead for inflate.\n        // This takes 10 bits, of which 7 may remain in the bit buffer.\n        // The current inflate code requires 9 bits of lookahead. If the\n        // last two codes for the previous block (real code plus EOB) were coded\n        // on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode\n        // the last real code. In this case we send two empty static blocks instead\n        // of one. (There are no problems if the previous block is stored or fixed.)\n        // To simplify the code, we assume the worst case of last real code encoded\n        // on one bit only.\n        internal void _tr_align()\n        {\n            send_bits(STATIC_TREES << 1, 3);\n            send_code(END_BLOCK, StaticTree.lengthAndLiteralsTreeCodes);\n\n            bi_flush();\n\n            // Of the 10 bits for the empty block, we have already sent\n            // (10 - bi_valid) bits. The lookahead for the last real code (before\n            // the EOB of the previous block) was thus at least one plus the length\n            // of the EOB plus what we have just sent of the empty static block.\n            if (1 + last_eob_len + 10 - bi_valid < 9)\n            {\n                send_bits(STATIC_TREES << 1, 3);\n                send_code(END_BLOCK, StaticTree.lengthAndLiteralsTreeCodes);\n                bi_flush();\n            }\n            last_eob_len = 7;\n        }\n\n\n        // Save the match info and tally the frequency counts. Return true if\n        // the current block must be flushed.\n        internal bool _tr_tally(int dist, int lc)\n        {\n            pending[_distanceOffset + last_lit * 2] = unchecked((byte) ( (uint)dist >> 8 ) );\n            pending[_distanceOffset + last_lit * 2 + 1] = unchecked((byte)dist);\n            pending[_lengthOffset + last_lit] = unchecked((byte)lc);\n            last_lit++;\n\n            if (dist == 0)\n            {\n                // lc is the unmatched char\n                dyn_ltree[lc * 2]++;\n            }\n            else\n            {\n                matches++;\n                // Here, lc is the match length - MIN_MATCH\n                dist--; // dist = match distance - 1\n                dyn_ltree[(Tree.LengthCode[lc] + InternalConstants.LITERALS + 1) * 2]++;\n                dyn_dtree[Tree.DistanceCode(dist) * 2]++;\n            }\n\n            if ((last_lit & 0x1fff) == 0 && (int)compressionLevel > 2)\n            {\n                // Compute an upper bound for the compressed length\n                int out_length = last_lit << 3;\n                int in_length = strstart - block_start;\n                int dcode;\n                for (dcode = 0; dcode < InternalConstants.D_CODES; dcode++)\n                {\n                    out_length = (int)(out_length + (int)dyn_dtree[dcode * 2] * (5L + Tree.ExtraDistanceBits[dcode]));\n                }\n                out_length >>= 3;\n                if ((matches < (last_lit / 2)) && out_length < in_length / 2)\n                    return true;\n            }\n\n            return (last_lit == lit_bufsize - 1) || (last_lit == lit_bufsize);\n            // dinoch - wraparound?\n            // We avoid equality with lit_bufsize because of wraparound at 64K\n            // on 16 bit machines and because stored blocks are restricted to\n            // 64K-1 bytes.\n        }\n\n\n\n        // Send the block data compressed using the given Huffman trees\n        internal void send_compressed_block(short[] ltree, short[] dtree)\n        {\n            int distance; // distance of matched string\n            int lc;       // match length or unmatched char (if dist == 0)\n            int lx = 0;   // running index in l_buf\n            int code;     // the code to send\n            int extra;    // number of extra bits to send\n\n            if (last_lit != 0)\n            {\n                do\n                {\n                    int ix = _distanceOffset + lx * 2;\n                    distance = ((pending[ix] << 8) & 0xff00) |\n                        (pending[ix + 1] & 0xff);\n                    lc = (pending[_lengthOffset + lx]) & 0xff;\n                    lx++;\n\n                    if (distance == 0)\n                    {\n                        send_code(lc, ltree); // send a literal byte\n                    }\n                    else\n                    {\n                        // literal or match pair\n                        // Here, lc is the match length - MIN_MATCH\n                        code = Tree.LengthCode[lc];\n\n                        // send the length code\n                        send_code(code + InternalConstants.LITERALS + 1, ltree);\n                        extra = Tree.ExtraLengthBits[code];\n                        if (extra != 0)\n                        {\n                            // send the extra length bits\n                            lc -= Tree.LengthBase[code];\n                            send_bits(lc, extra);\n                        }\n                        distance--; // dist is now the match distance - 1\n                        code = Tree.DistanceCode(distance);\n\n                        // send the distance code\n                        send_code(code, dtree);\n\n                        extra = Tree.ExtraDistanceBits[code];\n                        if (extra != 0)\n                        {\n                            // send the extra distance bits\n                            distance -= Tree.DistanceBase[code];\n                            send_bits(distance, extra);\n                        }\n                    }\n\n                    // Check that the overlay between pending and d_buf+l_buf is ok:\n                }\n                while (lx < last_lit);\n            }\n\n            send_code(END_BLOCK, ltree);\n            last_eob_len = ltree[END_BLOCK * 2 + 1];\n        }\n\n\n\n        // Set the data type to ASCII or BINARY, using a crude approximation:\n        // binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise.\n        // IN assertion: the fields freq of dyn_ltree are set and the total of all\n        // frequencies does not exceed 64K (to fit in an int on 16 bit machines).\n        internal void set_data_type()\n        {\n            int n = 0;\n            int ascii_freq = 0;\n            int bin_freq = 0;\n            while (n < 7)\n            {\n                bin_freq += dyn_ltree[n * 2]; n++;\n            }\n            while (n < 128)\n            {\n                ascii_freq += dyn_ltree[n * 2]; n++;\n            }\n            while (n < InternalConstants.LITERALS)\n            {\n                bin_freq += dyn_ltree[n * 2]; n++;\n            }\n            data_type = (sbyte)(bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII);\n        }\n\n\n\n        // Flush the bit buffer, keeping at most 7 bits in it.\n        internal void bi_flush()\n        {\n            if (bi_valid == 16)\n            {\n                pending[pendingCount++] = (byte)bi_buf;\n                pending[pendingCount++] = (byte)(bi_buf >> 8);\n                bi_buf = 0;\n                bi_valid = 0;\n            }\n            else if (bi_valid >= 8)\n            {\n                //put_byte((byte)bi_buf);\n                pending[pendingCount++] = (byte)bi_buf;\n                bi_buf >>= 8;\n                bi_valid -= 8;\n            }\n        }\n\n        // Flush the bit buffer and align the output on a byte boundary\n        internal void bi_windup()\n        {\n            if (bi_valid > 8)\n            {\n                pending[pendingCount++] = (byte)bi_buf;\n                pending[pendingCount++] = (byte)(bi_buf >> 8);\n            }\n            else if (bi_valid > 0)\n            {\n                //put_byte((byte)bi_buf);\n                pending[pendingCount++] = (byte)bi_buf;\n            }\n            bi_buf = 0;\n            bi_valid = 0;\n        }\n\n        // Copy a stored block, storing first the length and its\n        // one's complement if requested.\n        internal void copy_block(int buf, int len, bool header)\n        {\n            bi_windup(); // align on byte boundary\n            last_eob_len = 8; // enough lookahead for inflate\n\n            if (header)\n                unchecked\n                {\n                    //put_short((short)len);\n                    pending[pendingCount++] = (byte)len;\n                    pending[pendingCount++] = (byte)(len >> 8);\n                    //put_short((short)~len);\n                    pending[pendingCount++] = (byte)~len;\n                    pending[pendingCount++] = (byte)(~len >> 8);\n                }\n\n            put_bytes(window, buf, len);\n        }\n\n        internal void flush_block_only(bool eof)\n        {\n            _tr_flush_block(block_start >= 0 ? block_start : -1, strstart - block_start, eof);\n            block_start = strstart;\n            _codec.flush_pending();\n        }\n\n        // Copy without compression as much as possible from the input stream, return\n        // the current block state.\n        // This function does not insert new strings in the dictionary since\n        // uncompressible data is probably not useful. This function is used\n        // only for the level=0 compression option.\n        // NOTE: this function should be optimized to avoid extra copying from\n        // window to pending_buf.\n        internal BlockState DeflateNone(FlushType flush)\n        {\n            // Stored blocks are limited to 0xffff bytes, pending is limited\n            // to pending_buf_size, and each stored block has a 5 byte header:\n\n            int max_block_size = 0xffff;\n            int max_start;\n\n            if (max_block_size > pending.Length - 5)\n            {\n                max_block_size = pending.Length - 5;\n            }\n\n            // Copy as much as possible from input to output:\n            while (true)\n            {\n                // Fill the window as much as possible:\n                if (lookahead <= 1)\n                {\n                    _fillWindow();\n                    if (lookahead == 0 && flush == FlushType.None)\n                        return BlockState.NeedMore;\n                    if (lookahead == 0)\n                        break; // flush the current block\n                }\n\n                strstart += lookahead;\n                lookahead = 0;\n\n                // Emit a stored block if pending will be full:\n                max_start = block_start + max_block_size;\n                if (strstart == 0 || strstart >= max_start)\n                {\n                    // strstart == 0 is possible when wraparound on 16-bit machine\n                    lookahead = (int)(strstart - max_start);\n                    strstart = (int)max_start;\n\n                    flush_block_only(false);\n                    if (_codec.AvailableBytesOut == 0)\n                        return BlockState.NeedMore;\n                }\n\n                // Flush if we may have to slide, otherwise block_start may become\n                // negative and the data will be gone:\n                if (strstart - block_start >= w_size - MIN_LOOKAHEAD)\n                {\n                    flush_block_only(false);\n                    if (_codec.AvailableBytesOut == 0)\n                        return BlockState.NeedMore;\n                }\n            }\n\n            flush_block_only(flush == FlushType.Finish);\n            if (_codec.AvailableBytesOut == 0)\n                return (flush == FlushType.Finish) ? BlockState.FinishStarted : BlockState.NeedMore;\n\n            return flush == FlushType.Finish ? BlockState.FinishDone : BlockState.BlockDone;\n        }\n\n\n        // Send a stored block\n        internal void _tr_stored_block(int buf, int stored_len, bool eof)\n        {\n            send_bits((STORED_BLOCK << 1) + (eof ? 1 : 0), 3); // send block type\n            copy_block(buf, stored_len, true); // with header\n        }\n\n        // Determine the best encoding for the current block: dynamic trees, static\n        // trees or store, and output the encoded block to the zip file.\n        internal void _tr_flush_block(int buf, int stored_len, bool eof)\n        {\n            int opt_lenb, static_lenb; // opt_len and static_len in bytes\n            int max_blindex = 0; // index of last bit length code of non zero freq\n\n            // Build the Huffman trees unless a stored block is forced\n            if (compressionLevel > 0)\n            {\n                // Check if the file is ascii or binary\n                if (data_type == Z_UNKNOWN)\n                    set_data_type();\n\n                // Construct the literal and distance trees\n                treeLiterals.build_tree(this);\n\n                treeDistances.build_tree(this);\n\n                // At this point, opt_len and static_len are the total bit lengths of\n                // the compressed block data, excluding the tree representations.\n\n                // Build the bit length tree for the above two trees, and get the index\n                // in bl_order of the last bit length code to send.\n                max_blindex = build_bl_tree();\n\n                // Determine the best encoding. Compute first the block length in bytes\n                opt_lenb = (opt_len + 3 + 7) >> 3;\n                static_lenb = (static_len + 3 + 7) >> 3;\n\n                if (static_lenb <= opt_lenb)\n                    opt_lenb = static_lenb;\n            }\n            else\n            {\n                opt_lenb = static_lenb = stored_len + 5; // force a stored block\n            }\n\n            if (stored_len + 4 <= opt_lenb && buf != -1)\n            {\n                // 4: two words for the lengths\n                // The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.\n                // Otherwise we can't have processed more than WSIZE input bytes since\n                // the last block flush, because compression would have been\n                // successful. If LIT_BUFSIZE <= WSIZE, it is never too late to\n                // transform a block into a stored block.\n                _tr_stored_block(buf, stored_len, eof);\n            }\n            else if (static_lenb == opt_lenb)\n            {\n                send_bits((STATIC_TREES << 1) + (eof ? 1 : 0), 3);\n                send_compressed_block(StaticTree.lengthAndLiteralsTreeCodes, StaticTree.distTreeCodes);\n            }\n            else\n            {\n                send_bits((DYN_TREES << 1) + (eof ? 1 : 0), 3);\n                send_all_trees(treeLiterals.max_code + 1, treeDistances.max_code + 1, max_blindex + 1);\n                send_compressed_block(dyn_ltree, dyn_dtree);\n            }\n\n            // The above check is made mod 2^32, for files larger than 512 MB\n            // and uLong implemented on 32 bits.\n\n            _InitializeBlocks();\n\n            if (eof)\n            {\n                bi_windup();\n            }\n        }\n\n        // Fill the window when the lookahead becomes insufficient.\n        // Updates strstart and lookahead.\n        //\n        // IN assertion: lookahead < MIN_LOOKAHEAD\n        // OUT assertions: strstart <= window_size-MIN_LOOKAHEAD\n        //    At least one byte has been read, or avail_in == 0; reads are\n        //    performed for at least two bytes (required for the zip translate_eol\n        //    option -- not supported here).\n        private void _fillWindow()\n        {\n            int n, m;\n            int p;\n            int more; // Amount of free space at the end of the window.\n\n            do\n            {\n                more = (window_size - lookahead - strstart);\n\n                // Deal with !@#$% 64K limit:\n                if (more == 0 && strstart == 0 && lookahead == 0)\n                {\n                    more = w_size;\n                }\n                else if (more == -1)\n                {\n                    // Very unlikely, but possible on 16 bit machine if strstart == 0\n                    // and lookahead == 1 (input done one byte at time)\n                    more--;\n\n                    // If the window is almost full and there is insufficient lookahead,\n                    // move the upper half to the lower one to make room in the upper half.\n                }\n                else if (strstart >= w_size + w_size - MIN_LOOKAHEAD)\n                {\n                    Array.Copy(window, w_size, window, 0, w_size);\n                    match_start -= w_size;\n                    strstart -= w_size; // we now have strstart >= MAX_DIST\n                    block_start -= w_size;\n\n                    // Slide the hash table (could be avoided with 32 bit values\n                    // at the expense of memory usage). We slide even when level == 0\n                    // to keep the hash table consistent if we switch back to level > 0\n                    // later. (Using level 0 permanently is not an optimal usage of\n                    // zlib, so we don't care about this pathological case.)\n\n                    n = hash_size;\n                    p = n;\n                    do\n                    {\n                        m = (head[--p] & 0xffff);\n                        head[p] = (short)((m >= w_size) ? (m - w_size) : 0);\n                    }\n                    while (--n != 0);\n\n                    n = w_size;\n                    p = n;\n                    do\n                    {\n                        m = (prev[--p] & 0xffff);\n                        prev[p] = (short)((m >= w_size) ? (m - w_size) : 0);\n                        // If n is not on any hash chain, prev[n] is garbage but\n                        // its value will never be used.\n                    }\n                    while (--n != 0);\n                    more += w_size;\n                }\n\n                if (_codec.AvailableBytesIn == 0)\n                    return;\n\n                // If there was no sliding:\n                //    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&\n                //    more == window_size - lookahead - strstart\n                // => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)\n                // => more >= window_size - 2*WSIZE + 2\n                // In the BIG_MEM or MMAP case (not yet supported),\n                //   window_size == input_size + MIN_LOOKAHEAD  &&\n                //   strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.\n                // Otherwise, window_size == 2*WSIZE so more >= 2.\n                // If there was sliding, more >= WSIZE. So in all cases, more >= 2.\n\n                n = _codec.read_buf(window, strstart + lookahead, more);\n                lookahead += n;\n\n                // Initialize the hash value now that we have some input:\n                if (lookahead >= MIN_MATCH)\n                {\n                    ins_h = window[strstart] & 0xff;\n                    ins_h = (((ins_h) << hash_shift) ^ (window[strstart + 1] & 0xff)) & hash_mask;\n                }\n                // If the whole input has less than MIN_MATCH bytes, ins_h is garbage,\n                // but this is not important since only literal bytes will be emitted.\n            }\n            while (lookahead < MIN_LOOKAHEAD && _codec.AvailableBytesIn != 0);\n        }\n\n        // Compress as much as possible from the input stream, return the current\n        // block state.\n        // This function does not perform lazy evaluation of matches and inserts\n        // new strings in the dictionary only for unmatched strings or for short\n        // matches. It is used only for the fast compression options.\n        internal BlockState DeflateFast(FlushType flush)\n        {\n            //    short hash_head = 0; // head of the hash chain\n            int hash_head = 0; // head of the hash chain\n            bool bflush; // set if current block must be flushed\n\n            while (true)\n            {\n                // Make sure that we always have enough lookahead, except\n                // at the end of the input file. We need MAX_MATCH bytes\n                // for the next match, plus MIN_MATCH bytes to insert the\n                // string following the next match.\n                if (lookahead < MIN_LOOKAHEAD)\n                {\n                    _fillWindow();\n                    if (lookahead < MIN_LOOKAHEAD && flush == FlushType.None)\n                    {\n                        return BlockState.NeedMore;\n                    }\n                    if (lookahead == 0)\n                        break; // flush the current block\n                }\n\n                // Insert the string window[strstart .. strstart+2] in the\n                // dictionary, and set hash_head to the head of the hash chain:\n                if (lookahead >= MIN_MATCH)\n                {\n                    ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask;\n\n                    //  prev[strstart&w_mask]=hash_head=head[ins_h];\n                    hash_head = (head[ins_h] & 0xffff);\n                    prev[strstart & w_mask] = head[ins_h];\n                    head[ins_h] = unchecked((short)strstart);\n                }\n\n                // Find the longest match, discarding those <= prev_length.\n                // At this point we have always match_length < MIN_MATCH\n\n                if (hash_head != 0L && ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD)\n                {\n                    // To simplify the code, we prevent matches with the string\n                    // of window index 0 (in particular we have to avoid a match\n                    // of the string with itself at the start of the input file).\n                    if (compressionStrategy != CompressionStrategy.HuffmanOnly)\n                    {\n                        match_length = longest_match(hash_head);\n                    }\n                    // longest_match() sets match_start\n                }\n                if (match_length >= MIN_MATCH)\n                {\n                    //        check_match(strstart, match_start, match_length);\n\n                    bflush = _tr_tally(strstart - match_start, match_length - MIN_MATCH);\n\n                    lookahead -= match_length;\n\n                    // Insert new strings in the hash table only if the match length\n                    // is not too large. This saves time but degrades compression.\n                    if (match_length <= config.MaxLazy && lookahead >= MIN_MATCH)\n                    {\n                        match_length--; // string at strstart already in hash table\n                        do\n                        {\n                            strstart++;\n\n                            ins_h = ((ins_h << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask;\n                            //      prev[strstart&w_mask]=hash_head=head[ins_h];\n                            hash_head = (head[ins_h] & 0xffff);\n                            prev[strstart & w_mask] = head[ins_h];\n                            head[ins_h] = unchecked((short)strstart);\n\n                            // strstart never exceeds WSIZE-MAX_MATCH, so there are\n                            // always MIN_MATCH bytes ahead.\n                        }\n                        while (--match_length != 0);\n                        strstart++;\n                    }\n                    else\n                    {\n                        strstart += match_length;\n                        match_length = 0;\n                        ins_h = window[strstart] & 0xff;\n\n                        ins_h = (((ins_h) << hash_shift) ^ (window[strstart + 1] & 0xff)) & hash_mask;\n                        // If lookahead < MIN_MATCH, ins_h is garbage, but it does not\n                        // matter since it will be recomputed at next deflate call.\n                    }\n                }\n                else\n                {\n                    // No match, output a literal byte\n\n                    bflush = _tr_tally(0, window[strstart] & 0xff);\n                    lookahead--;\n                    strstart++;\n                }\n                if (bflush)\n                {\n                    flush_block_only(false);\n                    if (_codec.AvailableBytesOut == 0)\n                        return BlockState.NeedMore;\n                }\n            }\n\n            flush_block_only(flush == FlushType.Finish);\n            if (_codec.AvailableBytesOut == 0)\n            {\n                if (flush == FlushType.Finish)\n                    return BlockState.FinishStarted;\n                else\n                    return BlockState.NeedMore;\n            }\n            return flush == FlushType.Finish ? BlockState.FinishDone : BlockState.BlockDone;\n        }\n\n        // Same as above, but achieves better compression. We use a lazy\n        // evaluation for matches: a match is finally adopted only if there is\n        // no better match at the next window position.\n        internal BlockState DeflateSlow(FlushType flush)\n        {\n            //    short hash_head = 0;    // head of hash chain\n            int hash_head = 0; // head of hash chain\n            bool bflush; // set if current block must be flushed\n\n            // Process the input block.\n            while (true)\n            {\n                // Make sure that we always have enough lookahead, except\n                // at the end of the input file. We need MAX_MATCH bytes\n                // for the next match, plus MIN_MATCH bytes to insert the\n                // string following the next match.\n\n                if (lookahead < MIN_LOOKAHEAD)\n                {\n                    _fillWindow();\n                    if (lookahead < MIN_LOOKAHEAD && flush == FlushType.None)\n                        return BlockState.NeedMore;\n\n                    if (lookahead == 0)\n                        break; // flush the current block\n                }\n\n                // Insert the string window[strstart .. strstart+2] in the\n                // dictionary, and set hash_head to the head of the hash chain:\n\n                if (lookahead >= MIN_MATCH)\n                {\n                    ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask;\n                    //  prev[strstart&w_mask]=hash_head=head[ins_h];\n                    hash_head = (head[ins_h] & 0xffff);\n                    prev[strstart & w_mask] = head[ins_h];\n                    head[ins_h] = unchecked((short)strstart);\n                }\n\n                // Find the longest match, discarding those <= prev_length.\n                prev_length = match_length;\n                prev_match = match_start;\n                match_length = MIN_MATCH - 1;\n\n                if (hash_head != 0 && prev_length < config.MaxLazy &&\n                    ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD)\n                {\n                    // To simplify the code, we prevent matches with the string\n                    // of window index 0 (in particular we have to avoid a match\n                    // of the string with itself at the start of the input file).\n\n                    if (compressionStrategy != CompressionStrategy.HuffmanOnly)\n                    {\n                        match_length = longest_match(hash_head);\n                    }\n                    // longest_match() sets match_start\n\n                    if (match_length <= 5 && (compressionStrategy == CompressionStrategy.Filtered ||\n                                              (match_length == MIN_MATCH && strstart - match_start > 4096)))\n                    {\n\n                        // If prev_match is also MIN_MATCH, match_start is garbage\n                        // but we will ignore the current match anyway.\n                        match_length = MIN_MATCH - 1;\n                    }\n                }\n\n                // If there was a match at the previous step and the current\n                // match is not better, output the previous match:\n                if (prev_length >= MIN_MATCH && match_length <= prev_length)\n                {\n                    int max_insert = strstart + lookahead - MIN_MATCH;\n                    // Do not insert strings in hash table beyond this.\n\n                    //          check_match(strstart-1, prev_match, prev_length);\n\n                    bflush = _tr_tally(strstart - 1 - prev_match, prev_length - MIN_MATCH);\n\n                    // Insert in hash table all strings up to the end of the match.\n                    // strstart-1 and strstart are already inserted. If there is not\n                    // enough lookahead, the last two strings are not inserted in\n                    // the hash table.\n                    lookahead -= (prev_length - 1);\n                    prev_length -= 2;\n                    do\n                    {\n                        if (++strstart <= max_insert)\n                        {\n                            ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask;\n                            //prev[strstart&w_mask]=hash_head=head[ins_h];\n                            hash_head = (head[ins_h] & 0xffff);\n                            prev[strstart & w_mask] = head[ins_h];\n                            head[ins_h] = unchecked((short)strstart);\n                        }\n                    }\n                    while (--prev_length != 0);\n                    match_available = 0;\n                    match_length = MIN_MATCH - 1;\n                    strstart++;\n\n                    if (bflush)\n                    {\n                        flush_block_only(false);\n                        if (_codec.AvailableBytesOut == 0)\n                            return BlockState.NeedMore;\n                    }\n                }\n                else if (match_available != 0)\n                {\n\n                    // If there was no match at the previous position, output a\n                    // single literal. If there was a match but the current match\n                    // is longer, truncate the previous match to a single literal.\n\n                    bflush = _tr_tally(0, window[strstart - 1] & 0xff);\n\n                    if (bflush)\n                    {\n                        flush_block_only(false);\n                    }\n                    strstart++;\n                    lookahead--;\n                    if (_codec.AvailableBytesOut == 0)\n                        return BlockState.NeedMore;\n                }\n                else\n                {\n                    // There is no previous match to compare with, wait for\n                    // the next step to decide.\n\n                    match_available = 1;\n                    strstart++;\n                    lookahead--;\n                }\n            }\n\n            if (match_available != 0)\n            {\n                bflush = _tr_tally(0, window[strstart - 1] & 0xff);\n                match_available = 0;\n            }\n            flush_block_only(flush == FlushType.Finish);\n\n            if (_codec.AvailableBytesOut == 0)\n            {\n                if (flush == FlushType.Finish)\n                    return BlockState.FinishStarted;\n                else\n                    return BlockState.NeedMore;\n            }\n\n            return flush == FlushType.Finish ? BlockState.FinishDone : BlockState.BlockDone;\n        }\n\n\n        internal int longest_match(int cur_match)\n        {\n            int chain_length = config.MaxChainLength; // max hash chain length\n            int scan         = strstart;              // current string\n            int match;                                // matched string\n            int len;                                  // length of current match\n            int best_len     = prev_length;           // best match length so far\n            int limit        = strstart > (w_size - MIN_LOOKAHEAD) ? strstart - (w_size - MIN_LOOKAHEAD) : 0;\n\n            int niceLength = config.NiceLength;\n\n            // Stop when cur_match becomes <= limit. To simplify the code,\n            // we prevent matches with the string of window index 0.\n\n            int wmask = w_mask;\n\n            int strend = strstart + MAX_MATCH;\n            byte scan_end1 = window[scan + best_len - 1];\n            byte scan_end = window[scan + best_len];\n\n            // The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.\n            // It is easy to get rid of this optimization if necessary.\n\n            // Do not waste too much time if we already have a good match:\n            if (prev_length >= config.GoodLength)\n            {\n                chain_length >>= 2;\n            }\n\n            // Do not look for matches beyond the end of the input. This is necessary\n            // to make deflate deterministic.\n            if (niceLength > lookahead)\n                niceLength = lookahead;\n\n            do\n            {\n                match = cur_match;\n\n                // Skip to next match if the match length cannot increase\n                // or if the match length is less than 2:\n                if (window[match + best_len] != scan_end ||\n                    window[match + best_len - 1] != scan_end1 ||\n                    window[match] != window[scan] ||\n                    window[++match] != window[scan + 1])\n                    continue;\n\n                // The check at best_len-1 can be removed because it will be made\n                // again later. (This heuristic is not always a win.)\n                // It is not necessary to compare scan[2] and match[2] since they\n                // are always equal when the other bytes match, given that\n                // the hash keys are equal and that HASH_BITS >= 8.\n                scan += 2; match++;\n\n                // We check for insufficient lookahead only every 8th comparison;\n                // the 256th check will be made at strstart+258.\n                do\n                {\n                }\n                while (window[++scan] == window[++match] &&\n                       window[++scan] == window[++match] &&\n                       window[++scan] == window[++match] &&\n                       window[++scan] == window[++match] &&\n                       window[++scan] == window[++match] &&\n                       window[++scan] == window[++match] &&\n                       window[++scan] == window[++match] &&\n                       window[++scan] == window[++match] && scan < strend);\n\n                len = MAX_MATCH - (int)(strend - scan);\n                scan = strend - MAX_MATCH;\n\n                if (len > best_len)\n                {\n                    match_start = cur_match;\n                    best_len = len;\n                    if (len >= niceLength)\n                        break;\n                    scan_end1 = window[scan + best_len - 1];\n                    scan_end = window[scan + best_len];\n                }\n            }\n            while ((cur_match = (prev[cur_match & wmask] & 0xffff)) > limit && --chain_length != 0);\n\n            if (best_len <= lookahead)\n                return best_len;\n            return lookahead;\n        }\n\n\n        private bool Rfc1950BytesEmitted = false;\n        private bool _WantRfc1950HeaderBytes = true;\n        internal bool WantRfc1950HeaderBytes\n        {\n            get { return _WantRfc1950HeaderBytes; }\n            set { _WantRfc1950HeaderBytes = value; }\n        }\n\n\n        internal int Initialize(ZlibCodec codec, CompressionLevel level)\n        {\n            return Initialize(codec, level, ZlibConstants.WindowBitsMax);\n        }\n\n        internal int Initialize(ZlibCodec codec, CompressionLevel level, int bits)\n        {\n            return Initialize(codec, level, bits, MEM_LEVEL_DEFAULT, CompressionStrategy.Default);\n        }\n\n        internal int Initialize(ZlibCodec codec, CompressionLevel level, int bits, CompressionStrategy compressionStrategy)\n        {\n            return Initialize(codec, level, bits, MEM_LEVEL_DEFAULT, compressionStrategy);\n        }\n\n        internal int Initialize(ZlibCodec codec, CompressionLevel level, int windowBits, int memLevel, CompressionStrategy strategy)\n        {\n            _codec = codec;\n            _codec.Message = null;\n\n            // validation\n            if (windowBits < 9 || windowBits > 15)\n                throw new ZlibException(\"windowBits must be in the range 9..15.\");\n\n            if (memLevel < 1 || memLevel > MEM_LEVEL_MAX)\n                throw new ZlibException(String.Format(\"memLevel must be in the range 1.. {0}\", MEM_LEVEL_MAX));\n\n            _codec.dstate = this;\n\n            w_bits = windowBits;\n            w_size = 1 << w_bits;\n            w_mask = w_size - 1;\n\n            hash_bits = memLevel + 7;\n            hash_size = 1 << hash_bits;\n            hash_mask = hash_size - 1;\n            hash_shift = ((hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n\n            window = new byte[w_size * 2];\n            prev = new short[w_size];\n            head = new short[hash_size];\n\n            // for memLevel==8, this will be 16384, 16k\n            lit_bufsize = 1 << (memLevel + 6);\n\n            // Use a single array as the buffer for data pending compression,\n            // the output distance codes, and the output length codes (aka tree).\n            // orig comment: This works just fine since the average\n            // output size for (length,distance) codes is <= 24 bits.\n            pending = new byte[lit_bufsize * 4];\n            _distanceOffset = lit_bufsize;\n            _lengthOffset = (1 + 2) * lit_bufsize;\n\n            // So, for memLevel 8, the length of the pending buffer is 65536. 64k.\n            // The first 16k are pending bytes.\n            // The middle slice, of 32k, is used for distance codes.\n            // The final 16k are length codes.\n\n            this.compressionLevel = level;\n            this.compressionStrategy = strategy;\n\n            Reset();\n            return ZlibConstants.Z_OK;\n        }\n\n\n        internal void Reset()\n        {\n            _codec.TotalBytesIn = _codec.TotalBytesOut = 0;\n            _codec.Message = null;\n            //strm.data_type = Z_UNKNOWN;\n\n            pendingCount = 0;\n            nextPending = 0;\n\n            Rfc1950BytesEmitted = false;\n\n            status = (WantRfc1950HeaderBytes) ? INIT_STATE : BUSY_STATE;\n            _codec._Adler32 = Adler.Adler32(0, null, 0, 0);\n\n            last_flush = (int)FlushType.None;\n\n            _InitializeTreeData();\n            _InitializeLazyMatch();\n        }\n\n\n        internal int End()\n        {\n            if (status != INIT_STATE && status != BUSY_STATE && status != FINISH_STATE)\n            {\n                return ZlibConstants.Z_STREAM_ERROR;\n            }\n            // Deallocate in reverse order of allocations:\n            pending = null;\n            head = null;\n            prev = null;\n            window = null;\n            // free\n            // dstate=null;\n            return status == BUSY_STATE ? ZlibConstants.Z_DATA_ERROR : ZlibConstants.Z_OK;\n        }\n\n\n        private void SetDeflater()\n        {\n            switch (config.Flavor)\n            {\n                case DeflateFlavor.Store:\n                    DeflateFunction = DeflateNone;\n                    break;\n                case DeflateFlavor.Fast:\n                    DeflateFunction = DeflateFast;\n                    break;\n                case DeflateFlavor.Slow:\n                    DeflateFunction = DeflateSlow;\n                    break;\n            }\n        }\n\n\n        internal int SetParams(CompressionLevel level, CompressionStrategy strategy)\n        {\n            int result = ZlibConstants.Z_OK;\n\n            if (compressionLevel != level)\n            {\n                Config newConfig = Config.Lookup(level);\n\n                // change in the deflate flavor (Fast vs slow vs none)?\n                if (newConfig.Flavor != config.Flavor && _codec.TotalBytesIn != 0)\n                {\n                    // Flush the last buffer:\n                    result = _codec.Deflate(FlushType.Partial);\n                }\n\n                compressionLevel = level;\n                config = newConfig;\n                SetDeflater();\n            }\n\n            // no need to flush with change in strategy?  Really?\n            compressionStrategy = strategy;\n\n            return result;\n        }\n\n\n        internal int SetDictionary(byte[] dictionary)\n        {\n            int length = dictionary.Length;\n            int index = 0;\n\n            if (dictionary == null || status != INIT_STATE)\n                throw new ZlibException(\"Stream error.\");\n\n            _codec._Adler32 = Adler.Adler32(_codec._Adler32, dictionary, 0, dictionary.Length);\n\n            if (length < MIN_MATCH)\n                return ZlibConstants.Z_OK;\n            if (length > w_size - MIN_LOOKAHEAD)\n            {\n                length = w_size - MIN_LOOKAHEAD;\n                index = dictionary.Length - length; // use the tail of the dictionary\n            }\n            Array.Copy(dictionary, index, window, 0, length);\n            strstart = length;\n            block_start = length;\n\n            // Insert all strings in the hash table (except for the last two bytes).\n            // s->lookahead stays null, so s->ins_h will be recomputed at the next\n            // call of fill_window.\n\n            ins_h = window[0] & 0xff;\n            ins_h = (((ins_h) << hash_shift) ^ (window[1] & 0xff)) & hash_mask;\n\n            for (int n = 0; n <= length - MIN_MATCH; n++)\n            {\n                ins_h = (((ins_h) << hash_shift) ^ (window[(n) + (MIN_MATCH - 1)] & 0xff)) & hash_mask;\n                prev[n & w_mask] = head[ins_h];\n                head[ins_h] = (short)n;\n            }\n            return ZlibConstants.Z_OK;\n        }\n\n\n\n        internal int Deflate(FlushType flush)\n        {\n            int old_flush;\n\n            if (_codec.OutputBuffer == null ||\n                (_codec.InputBuffer == null && _codec.AvailableBytesIn != 0) ||\n                (status == FINISH_STATE && flush != FlushType.Finish))\n            {\n                _codec.Message = _ErrorMessage[ZlibConstants.Z_NEED_DICT - (ZlibConstants.Z_STREAM_ERROR)];\n                throw new ZlibException(String.Format(\"Something is fishy. [{0}]\", _codec.Message));\n            }\n            if (_codec.AvailableBytesOut == 0)\n            {\n                _codec.Message = _ErrorMessage[ZlibConstants.Z_NEED_DICT - (ZlibConstants.Z_BUF_ERROR)];\n                throw new ZlibException(\"OutputBuffer is full (AvailableBytesOut == 0)\");\n            }\n\n            old_flush = last_flush;\n            last_flush = (int)flush;\n\n            // Write the zlib (rfc1950) header bytes\n            if (status == INIT_STATE)\n            {\n                int header = (Z_DEFLATED + ((w_bits - 8) << 4)) << 8;\n                int level_flags = (((int)compressionLevel - 1) & 0xff) >> 1;\n\n                if (level_flags > 3)\n                    level_flags = 3;\n                header |= (level_flags << 6);\n                if (strstart != 0)\n                    header |= PRESET_DICT;\n                header += 31 - (header % 31);\n\n                status = BUSY_STATE;\n                //putShortMSB(header);\n                unchecked\n                {\n                    pending[pendingCount++] = (byte)(header >> 8);\n                    pending[pendingCount++] = (byte)header;\n                }\n                // Save the adler32 of the preset dictionary:\n                if (strstart != 0)\n                {\n                    pending[pendingCount++] = (byte)((_codec._Adler32 & 0xFF000000) >> 24);\n                    pending[pendingCount++] = (byte)((_codec._Adler32 & 0x00FF0000) >> 16);\n                    pending[pendingCount++] = (byte)((_codec._Adler32 & 0x0000FF00) >> 8);\n                    pending[pendingCount++] = (byte)(_codec._Adler32 & 0x000000FF);\n                }\n                _codec._Adler32 = Adler.Adler32(0, null, 0, 0);\n            }\n\n            // Flush as much pending output as possible\n            if (pendingCount != 0)\n            {\n                _codec.flush_pending();\n                if (_codec.AvailableBytesOut == 0)\n                {\n                    //System.out.println(\"  avail_out==0\");\n                    // Since avail_out is 0, deflate will be called again with\n                    // more output space, but possibly with both pending and\n                    // avail_in equal to zero. There won't be anything to do,\n                    // but this is not an error situation so make sure we\n                    // return OK instead of BUF_ERROR at next call of deflate:\n                    last_flush = -1;\n                    return ZlibConstants.Z_OK;\n                }\n\n                // Make sure there is something to do and avoid duplicate consecutive\n                // flushes. For repeated and useless calls with Z_FINISH, we keep\n                // returning Z_STREAM_END instead of Z_BUFF_ERROR.\n            }\n            else if (_codec.AvailableBytesIn == 0 &&\n                     (int)flush <= old_flush &&\n                     flush != FlushType.Finish)\n            {\n                // workitem 8557\n                //\n                // Not sure why this needs to be an error.  pendingCount == 0, which\n                // means there's nothing to deflate.  And the caller has not asked\n                // for a FlushType.Finish, but...  that seems very non-fatal.  We\n                // can just say \"OK\" and do nothing.\n\n                // _codec.Message = z_errmsg[ZlibConstants.Z_NEED_DICT - (ZlibConstants.Z_BUF_ERROR)];\n                // throw new ZlibException(\"AvailableBytesIn == 0 && flush<=old_flush && flush != FlushType.Finish\");\n\n                return ZlibConstants.Z_OK;\n            }\n\n            // User must not provide more input after the first FINISH:\n            if (status == FINISH_STATE && _codec.AvailableBytesIn != 0)\n            {\n                _codec.Message = _ErrorMessage[ZlibConstants.Z_NEED_DICT - (ZlibConstants.Z_BUF_ERROR)];\n                throw new ZlibException(\"status == FINISH_STATE && _codec.AvailableBytesIn != 0\");\n            }\n\n            // Start a new block or continue the current one.\n            if (_codec.AvailableBytesIn != 0 || lookahead != 0 || (flush != FlushType.None && status != FINISH_STATE))\n            {\n                BlockState bstate = DeflateFunction(flush);\n\n                if (bstate == BlockState.FinishStarted || bstate == BlockState.FinishDone)\n                {\n                    status = FINISH_STATE;\n                }\n                if (bstate == BlockState.NeedMore || bstate == BlockState.FinishStarted)\n                {\n                    if (_codec.AvailableBytesOut == 0)\n                    {\n                        last_flush = -1; // avoid BUF_ERROR next call, see above\n                    }\n                    return ZlibConstants.Z_OK;\n                    // If flush != Z_NO_FLUSH && avail_out == 0, the next call\n                    // of deflate should use the same flush parameter to make sure\n                    // that the flush is complete. So we don't have to output an\n                    // empty block here, this will be done at next call. This also\n                    // ensures that for a very small output buffer, we emit at most\n                    // one empty block.\n                }\n\n                if (bstate == BlockState.BlockDone)\n                {\n                    if (flush == FlushType.Partial)\n                    {\n                        _tr_align();\n                    }\n                    else\n                    {\n                        // FlushType.Full or FlushType.Sync\n                        _tr_stored_block(0, 0, false);\n                        // For a full flush, this empty block will be recognized\n                        // as a special marker by inflate_sync().\n                        if (flush == FlushType.Full)\n                        {\n                            // clear hash (forget the history)\n                            for (int i = 0; i < hash_size; i++)\n                                head[i] = 0;\n                        }\n                    }\n                    _codec.flush_pending();\n                    if (_codec.AvailableBytesOut == 0)\n                    {\n                        last_flush = -1; // avoid BUF_ERROR at next call, see above\n                        return ZlibConstants.Z_OK;\n                    }\n                }\n            }\n\n            if (flush != FlushType.Finish)\n                return ZlibConstants.Z_OK;\n\n            if (!WantRfc1950HeaderBytes || Rfc1950BytesEmitted)\n                return ZlibConstants.Z_STREAM_END;\n\n            // Write the zlib trailer (adler32)\n            pending[pendingCount++] = (byte)((_codec._Adler32 & 0xFF000000) >> 24);\n            pending[pendingCount++] = (byte)((_codec._Adler32 & 0x00FF0000) >> 16);\n            pending[pendingCount++] = (byte)((_codec._Adler32 & 0x0000FF00) >> 8);\n            pending[pendingCount++] = (byte)(_codec._Adler32 & 0x000000FF);\n            //putShortMSB((int)(SharedUtils.URShift(_codec._Adler32, 16)));\n            //putShortMSB((int)(_codec._Adler32 & 0xffff));\n\n            _codec.flush_pending();\n\n            // If avail_out is zero, the application will call deflate again\n            // to flush the rest.\n\n            Rfc1950BytesEmitted = true; // write the trailer only once!\n\n            return pendingCount != 0 ? ZlibConstants.Z_OK : ZlibConstants.Z_STREAM_END;\n        }\n\n    }\n}"
  },
  {
    "path": "src/FirebirdSql.Data.External/zlib/InfTree.cs",
    "content": "// Inftree.cs\n// ------------------------------------------------------------------\n//\n// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.  \n// All rights reserved.\n//\n// This code module is part of DotNetZip, a zipfile class library.\n//\n// ------------------------------------------------------------------\n//\n// This code is licensed under the Microsoft Public License. \n// See the file License.txt for the license details.\n// More info on: http://dotnetzip.codeplex.com\n//\n// ------------------------------------------------------------------\n//\n// last saved (in emacs): \n// Time-stamp: <2009-October-28 12:43:54>\n//\n// ------------------------------------------------------------------\n//\n// This module defines classes used in  decompression. This code is derived\n// from the jzlib implementation of zlib. In keeping with the license for jzlib, \n// the copyright to that code is below.\n//\n// ------------------------------------------------------------------\n// \n// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.\n// \n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are met:\n// \n// 1. Redistributions of source code must retain the above copyright notice,\n// this list of conditions and the following disclaimer.\n// \n// 2. Redistributions in binary form must reproduce the above copyright \n// notice, this list of conditions and the following disclaimer in \n// the documentation and/or other materials provided with the distribution.\n// \n// 3. The names of the authors may not be used to endorse or promote products\n// derived from this software without specific prior written permission.\n// \n// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,\n// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\n// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,\n// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,\n// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\n// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n// \n// -----------------------------------------------------------------------\n//\n// This program is based on zlib-1.1.3; credit to authors\n// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)\n// and contributors of zlib.\n//\n// -----------------------------------------------------------------------\n\n\n\nusing System;\nnamespace Ionic.Zlib\n{\n        \n        sealed class InfTree\n        {\n                \n                private const int MANY = 1440;\n                \n                private const int Z_OK = 0;\n                private const int Z_STREAM_END = 1;\n                private const int Z_NEED_DICT = 2;\n                private const int Z_ERRNO = - 1;\n                private const int Z_STREAM_ERROR = - 2;\n                private const int Z_DATA_ERROR = - 3;\n                private const int Z_MEM_ERROR = - 4;\n                private const int Z_BUF_ERROR = - 5;\n                private const int Z_VERSION_ERROR = - 6;\n                \n                internal const int fixed_bl = 9;\n                internal const int fixed_bd = 5;\n                \n                //UPGRADE_NOTE: Final was removed from the declaration of 'fixed_tl'. \"ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'\"\n                internal static readonly int[] fixed_tl = new int[]{96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 192, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 160, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 224, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 144, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 208, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 176, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 240, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 200, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 168, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 232, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 152, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 216, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 184, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 248, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 196, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 164, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 228, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 148, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 212, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 180, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 244, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 204, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 172, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 236, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 156, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 220, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 188, 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 252, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 194, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 162, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 226, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 146, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 210, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 178, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 242, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 202, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 170, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 234, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 154, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 218, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 186, \n                        0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 250, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 198, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 166, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 230, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 150, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 214, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 182, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 246, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 206, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 174, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 238, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 222, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 190, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 193, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 209, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 201, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 169, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 233, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 153, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 217, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 185, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 249, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 197, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 165, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 229, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 149, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 213, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 181, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 245, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 205, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 173, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 237, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 157, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 221, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 189, 0, 8, \n                        14, 0, 8, 142, 0, 8, 78, 0, 9, 253, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 195, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 163, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 227, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 147, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 211, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 179, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 243, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 203, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 171, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 235, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 155, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 219, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 187, 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 251, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 199, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 167, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 231, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 151, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 215, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 183, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 247, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 207, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 175, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 239, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 159, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 223, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 191, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 255};\n                //UPGRADE_NOTE: Final was removed from the declaration of 'fixed_td'. \"ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'\"\n                internal static readonly int[] fixed_td = new int[]{80, 5, 1, 87, 5, 257, 83, 5, 17, 91, 5, 4097, 81, 5, 5, 89, 5, 1025, 85, 5, 65, 93, 5, 16385, 80, 5, 3, 88, 5, 513, 84, 5, 33, 92, 5, 8193, 82, 5, 9, 90, 5, 2049, 86, 5, 129, 192, 5, 24577, 80, 5, 2, 87, 5, 385, 83, 5, 25, 91, 5, 6145, 81, 5, 7, 89, 5, 1537, 85, 5, 97, 93, 5, 24577, 80, 5, 4, 88, 5, 769, 84, 5, 49, 92, 5, 12289, 82, 5, 13, 90, 5, 3073, 86, 5, 193, 192, 5, 24577};\n                \n                // Tables for deflate from PKZIP's appnote.txt.\n                //UPGRADE_NOTE: Final was removed from the declaration of 'cplens'. \"ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'\"\n                internal static readonly int[] cplens = new int[]{3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};\n                \n                // see note #13 above about 258\n                //UPGRADE_NOTE: Final was removed from the declaration of 'cplext'. \"ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'\"\n                internal static readonly int[] cplext = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112};\n                \n                //UPGRADE_NOTE: Final was removed from the declaration of 'cpdist'. \"ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'\"\n                internal static readonly int[] cpdist = new int[]{1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577};\n                \n                //UPGRADE_NOTE: Final was removed from the declaration of 'cpdext'. \"ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'\"\n                internal static readonly int[] cpdext = new int[]{0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13};\n                \n                // If BMAX needs to be larger than 16, then h and x[] should be uLong.\n                internal const int BMAX = 15; // maximum bit length of any code\n                \n                internal int[] hn = null; // hufts used in space\n                internal int[] v = null; // work area for huft_build \n                internal int[] c = null; // bit length count table\n                internal int[] r = null; // table entry for structure assignment\n                internal int[] u = null; // table stack\n                internal int[] x = null; // bit offsets, then code stack\n                \n                private int huft_build(int[] b, int bindex, int n, int s, int[] d, int[] e, int[] t, int[] m, int[] hp, int[] hn, int[] v)\n                {\n                        // Given a list of code lengths and a maximum table size, make a set of\n                        // tables to decode that set of codes.  Return Z_OK on success, Z_BUF_ERROR\n                        // if the given code set is incomplete (the tables are still built in this\n                        // case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of\n                        // lengths), or Z_MEM_ERROR if not enough memory.\n                        \n                        int a; // counter for codes of length k\n                        int f; // i repeats in table every f entries\n                        int g; // maximum code length\n                        int h; // table level\n                        int i; // counter, current code\n                        int j; // counter\n                        int k; // number of bits in current code\n                        int l; // bits per table (returned in m)\n                        int mask; // (1 << w) - 1, to avoid cc -O bug on HP\n                        int p; // pointer into c[], b[], or v[]\n                        int q; // points to current table\n                        int w; // bits before this table == (l * h)\n                        int xp; // pointer into x\n                        int y; // number of dummy codes added\n                        int z; // number of entries in current table\n                        \n                        // Generate counts for each bit length\n                        \n                        p = 0; i = n;\n                        do \n                        {\n                                c[b[bindex + p]]++; p++; i--; // assume all entries <= BMAX\n                        }\n                        while (i != 0);\n                        \n                        if (c[0] == n)\n                        {\n                                // null input--all zero length codes\n                                t[0] = - 1;\n                                m[0] = 0;\n                                return Z_OK;\n                        }\n                        \n                        // Find minimum and maximum length, bound *m by those\n                        l = m[0];\n                        for (j = 1; j <= BMAX; j++)\n                                if (c[j] != 0)\n                                        break;\n                        k = j; // minimum code length\n                        if (l < j)\n                        {\n                                l = j;\n                        }\n                        for (i = BMAX; i != 0; i--)\n                        {\n                                if (c[i] != 0)\n                                        break;\n                        }\n                        g = i; // maximum code length\n                        if (l > i)\n                        {\n                                l = i;\n                        }\n                        m[0] = l;\n                        \n                        // Adjust last length count to fill out codes, if needed\n                        for (y = 1 << j; j < i; j++, y <<= 1)\n                        {\n                                if ((y -= c[j]) < 0)\n                                {\n                                        return Z_DATA_ERROR;\n                                }\n                        }\n                        if ((y -= c[i]) < 0)\n                        {\n                                return Z_DATA_ERROR;\n                        }\n                        c[i] += y;\n                        \n                        // Generate starting offsets into the value table for each length\n                        x[1] = j = 0;\n                        p = 1; xp = 2;\n                        while (--i != 0)\n                        {\n                                // note that i == g from above\n                                x[xp] = (j += c[p]);\n                                xp++;\n                                p++;\n                        }\n                        \n                        // Make a table of values in order of bit lengths\n                        i = 0; p = 0;\n                        do \n                        {\n                                if ((j = b[bindex + p]) != 0)\n                                {\n                                        v[x[j]++] = i;\n                                }\n                                p++;\n                        }\n                        while (++i < n);\n                        n = x[g]; // set n to length of v\n                        \n                        // Generate the Huffman codes and for each, make the table entries\n                        x[0] = i = 0; // first Huffman code is zero\n                        p = 0; // grab values in bit order\n                        h = - 1; // no tables yet--level -1\n                        w = - l; // bits decoded == (l * h)\n                        u[0] = 0; // just to keep compilers happy\n                        q = 0; // ditto\n                        z = 0; // ditto\n                        \n                        // go through the bit lengths (k already is bits in shortest code)\n                        for (; k <= g; k++)\n                        {\n                                a = c[k];\n                                while (a-- != 0)\n                                {\n                                        // here i is the Huffman code of length k bits for value *p\n                                        // make tables up to required level\n                                        while (k > w + l)\n                                        {\n                                                h++;\n                                                w += l; // previous table always l bits\n                                                // compute minimum size table less than or equal to l bits\n                                                z = g - w;\n                                                z = (z > l)?l:z; // table size upper limit\n                                                if ((f = 1 << (j = k - w)) > a + 1)\n                                                {\n                                                        // try a k-w bit table\n                                                        // too few codes for k-w bit table\n                                                        f -= (a + 1); // deduct codes from patterns left\n                                                        xp = k;\n                                                        if (j < z)\n                                                        {\n                                                                while (++j < z)\n                                                                {\n                                                                        // try smaller tables up to z bits\n                                                                        if ((f <<= 1) <= c[++xp])\n                                                                                break; // enough codes to use up j bits\n                                                                        f -= c[xp]; // else deduct codes from patterns\n                                                                }\n                                                        }\n                                                }\n                                                z = 1 << j; // table entries for j-bit table\n                                                \n                                                // allocate new table\n                                                if (hn[0] + z > MANY)\n                                                {\n                                                        // (note: doesn't matter for fixed)\n                                                        return Z_DATA_ERROR; // overflow of MANY\n                                                }\n                                                u[h] = q = hn[0]; // DEBUG\n                                                hn[0] += z;\n                                                \n                                                // connect to last table, if there is one\n                                                if (h != 0)\n                                                {\n                                                        x[h] = i; // save pattern for backing up\n                                                        r[0] = (sbyte) j; // bits in this table\n                                                        r[1] = (sbyte) l; // bits to dump before this table\n                                                        j = SharedUtils.URShift(i, (w - l));\n                                                        r[2] = (int) (q - u[h - 1] - j); // offset to this table\n                                                        Array.Copy(r, 0, hp, (u[h - 1] + j) * 3, 3); // connect to last table\n                                                }\n                                                else\n                                                {\n                                                        t[0] = q; // first table is returned result\n                                                }\n                                        }\n                                        \n                                        // set up table entry in r\n                                        r[1] = (sbyte) (k - w);\n                                        if (p >= n)\n                                        {\n                                                r[0] = 128 + 64; // out of values--invalid code\n                                        }\n                                        else if (v[p] < s)\n                                        {\n                                                r[0] = (sbyte) (v[p] < 256?0:32 + 64); // 256 is end-of-block\n                                                r[2] = v[p++]; // simple code is just the value\n                                        }\n                                        else\n                                        {\n                                                r[0] = (sbyte) (e[v[p] - s] + 16 + 64); // non-simple--look up in lists\n                                                r[2] = d[v[p++] - s];\n                                        }\n                                        \n                                        // fill code-like entries with r\n                                        f = 1 << (k - w);\n                                        for (j = SharedUtils.URShift(i, w); j < z; j += f)\n                                        {\n                                                Array.Copy(r, 0, hp, (q + j) * 3, 3);\n                                        }\n                                        \n                                        // backwards increment the k-bit code i\n                                        for (j = 1 << (k - 1); (i & j) != 0; j = SharedUtils.URShift(j, 1))\n                                        {\n                                                i ^= j;\n                                        }\n                                        i ^= j;\n                                        \n                                        // backup over finished tables\n                                        mask = (1 << w) - 1; // needed on HP, cc -O bug\n                                        while ((i & mask) != x[h])\n                                        {\n                                                h--; // don't need to update q\n                                                w -= l;\n                                                mask = (1 << w) - 1;\n                                        }\n                                }\n                        }\n                        // Return Z_BUF_ERROR if we were given an incomplete table\n                        return y != 0 && g != 1?Z_BUF_ERROR:Z_OK;\n                }\n                \n                internal int inflate_trees_bits(int[] c, int[] bb, int[] tb, int[] hp, ZlibCodec z)\n                {\n                        int result;\n                        initWorkArea(19);\n                        hn[0] = 0;\n                        result = huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v);\n                        \n                        if (result == Z_DATA_ERROR)\n                        {\n                                z.Message = \"oversubscribed dynamic bit lengths tree\";\n                        }\n                        else if (result == Z_BUF_ERROR || bb[0] == 0)\n                        {\n                                z.Message = \"incomplete dynamic bit lengths tree\";\n                                result = Z_DATA_ERROR;\n                        }\n                        return result;\n                }\n                \n                internal int inflate_trees_dynamic(int nl, int nd, int[] c, int[] bl, int[] bd, int[] tl, int[] td, int[] hp, ZlibCodec z)\n                {\n                        int result;\n                        \n                        // build literal/length tree\n                        initWorkArea(288);\n                        hn[0] = 0;\n                        result = huft_build(c, 0, nl, 257, cplens, cplext, tl, bl, hp, hn, v);\n                        if (result != Z_OK || bl[0] == 0)\n                        {\n                                if (result == Z_DATA_ERROR)\n                                {\n                                        z.Message = \"oversubscribed literal/length tree\";\n                                }\n                                else if (result != Z_MEM_ERROR)\n                                {\n                                        z.Message = \"incomplete literal/length tree\";\n                                        result = Z_DATA_ERROR;\n                                }\n                                return result;\n                        }\n                        \n                        // build distance tree\n                        initWorkArea(288);\n                        result = huft_build(c, nl, nd, 0, cpdist, cpdext, td, bd, hp, hn, v);\n                        \n                        if (result != Z_OK || (bd[0] == 0 && nl > 257))\n                        {\n                                if (result == Z_DATA_ERROR)\n                                {\n                                        z.Message = \"oversubscribed distance tree\";\n                                }\n                                else if (result == Z_BUF_ERROR)\n                                {\n                                        z.Message = \"incomplete distance tree\";\n                                        result = Z_DATA_ERROR;\n                                }\n                                else if (result != Z_MEM_ERROR)\n                                {\n                                        z.Message = \"empty distance tree with lengths\";\n                                        result = Z_DATA_ERROR;\n                                }\n                                return result;\n                        }\n                        \n                        return Z_OK;\n                }\n                \n                internal static int inflate_trees_fixed(int[] bl, int[] bd, int[][] tl, int[][] td, ZlibCodec z)\n                {\n                        bl[0] = fixed_bl;\n                        bd[0] = fixed_bd;\n                        tl[0] = fixed_tl;\n                        td[0] = fixed_td;\n                        return Z_OK;\n                }\n                \n                private void  initWorkArea(int vsize)\n                {\n                        if (hn == null)\n                        {\n                                hn = new int[1];\n                                v = new int[vsize];\n                                c = new int[BMAX + 1];\n                                r = new int[3];\n                                u = new int[BMAX];\n                                x = new int[BMAX + 1];\n                        }\n                        else\n                        {\n                            if (v.Length < vsize)\n                            {\n                                v = new int[vsize];\n                            }\n                            Array.Clear(v,0,vsize);\n                            Array.Clear(c,0,BMAX+1);\n                            r[0]=0; r[1]=0; r[2]=0;\n                            //  for(int i=0; i<BMAX; i++){u[i]=0;}\n                            //Array.Copy(c, 0, u, 0, BMAX);\n                            Array.Clear(u,0,BMAX);\n                            //  for(int i=0; i<BMAX+1; i++){x[i]=0;}\n                            //Array.Copy(c, 0, x, 0, BMAX + 1);\n                            Array.Clear(x,0,BMAX+1);\n                        }\n                }\n        }\n}"
  },
  {
    "path": "src/FirebirdSql.Data.External/zlib/Inflate.cs",
    "content": "// Inflate.cs\n// ------------------------------------------------------------------\n//\n// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.\n// All rights reserved.\n//\n// This code module is part of DotNetZip, a zipfile class library.\n//\n// ------------------------------------------------------------------\n//\n// This code is licensed under the Microsoft Public License.\n// See the file License.txt for the license details.\n// More info on: http://dotnetzip.codeplex.com\n//\n// ------------------------------------------------------------------\n//\n// last saved (in emacs):\n// Time-stamp: <2010-January-08 18:32:12>\n//\n// ------------------------------------------------------------------\n//\n// This module defines classes for decompression. This code is derived\n// from the jzlib implementation of zlib, but significantly modified.\n// The object model is not the same, and many of the behaviors are\n// different.  Nonetheless, in keeping with the license for jzlib, I am\n// reproducing the copyright to that code here.\n//\n// ------------------------------------------------------------------\n//\n// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are met:\n//\n// 1. Redistributions of source code must retain the above copyright notice,\n// this list of conditions and the following disclaimer.\n//\n// 2. Redistributions in binary form must reproduce the above copyright\n// notice, this list of conditions and the following disclaimer in\n// the documentation and/or other materials provided with the distribution.\n//\n// 3. The names of the authors may not be used to endorse or promote products\n// derived from this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,\n// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\n// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,\n// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,\n// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\n// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// -----------------------------------------------------------------------\n//\n// This program is based on zlib-1.1.3; credit to authors\n// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)\n// and contributors of zlib.\n//\n// -----------------------------------------------------------------------\n\n\nusing System;\nnamespace Ionic.Zlib\n{\n    sealed class InflateBlocks\n    {\n        private const int MANY = 1440;\n\n        // Table for deflate from PKZIP's appnote.txt.\n        internal static readonly int[] border = new int[]\n        { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };\n\n        private enum InflateBlockMode\n        {\n            TYPE   = 0,                     // get type bits (3, including end bit)\n            LENS   = 1,                     // get lengths for stored\n            STORED = 2,                     // processing stored block\n            TABLE  = 3,                     // get table lengths\n            BTREE  = 4,                     // get bit lengths tree for a dynamic block\n            DTREE  = 5,                     // get length, distance trees for a dynamic block\n            CODES  = 6,                     // processing fixed or dynamic block\n            DRY    = 7,                     // output remaining window bytes\n            DONE   = 8,                     // finished last block, done\n            BAD    = 9,                     // ot a data error--stuck here\n        }\n\n        private InflateBlockMode mode;                    // current inflate_block mode\n\n        internal int left;                                // if STORED, bytes left to copy\n\n        internal int table;                               // table lengths (14 bits)\n        internal int index;                               // index into blens (or border)\n        internal int[] blens;                             // bit lengths of codes\n        internal int[] bb = new int[1];                   // bit length tree depth\n        internal int[] tb = new int[1];                   // bit length decoding tree\n\n        internal InflateCodes codes = new InflateCodes(); // if CODES, current state\n\n        internal int last;                                // true if this block is the last block\n\n        internal ZlibCodec _codec;                        // pointer back to this zlib stream\n\n                                                          // mode independent information\n        internal int bitk;                                // bits in bit buffer\n        internal int bitb;                                // bit buffer\n        internal int[] hufts;                             // single malloc for tree space\n        internal byte[] window;                           // sliding window\n        internal int end;                                 // one byte after sliding window\n        internal int readAt;                              // window read pointer\n        internal int writeAt;                             // window write pointer\n        internal System.Object checkfn;                   // check function\n        internal uint check;                              // check on output\n\n        internal InfTree inftree = new InfTree();\n\n        internal InflateBlocks(ZlibCodec codec, System.Object checkfn, int w)\n        {\n            _codec = codec;\n            hufts = new int[MANY * 3];\n            window = new byte[w];\n            end = w;\n            this.checkfn = checkfn;\n            mode = InflateBlockMode.TYPE;\n            Reset();\n        }\n\n        internal uint Reset()\n        {\n            uint oldCheck = check;\n            mode = InflateBlockMode.TYPE;\n            bitk = 0;\n            bitb = 0;\n            readAt = writeAt = 0;\n\n            if (checkfn != null)\n                _codec._Adler32 = check = Adler.Adler32(0, null, 0, 0);\n            return oldCheck;\n        }\n\n\n        internal int Process(int r)\n        {\n            int t; // temporary storage\n            int b; // bit buffer\n            int k; // bits in bit buffer\n            int p; // input data pointer\n            int n; // bytes available there\n            int q; // output window write pointer\n            int m; // bytes to end of window or read pointer\n\n            // copy input/output information to locals (UPDATE macro restores)\n\n            p = _codec.NextIn;\n            n = _codec.AvailableBytesIn;\n            b = bitb;\n            k = bitk;\n\n            q = writeAt;\n            m = (int)(q < readAt ? readAt - q - 1 : end - q);\n\n\n            // process input based on current state\n            while (true)\n            {\n                switch (mode)\n                {\n                    case InflateBlockMode.TYPE:\n\n                        while (k < (3))\n                        {\n                            if (n != 0)\n                            {\n                                r = ZlibConstants.Z_OK;\n                            }\n                            else\n                            {\n                                bitb = b; bitk = k;\n                                _codec.AvailableBytesIn = n;\n                                _codec.TotalBytesIn += p - _codec.NextIn;\n                                _codec.NextIn = p;\n                                writeAt = q;\n                                return Flush(r);\n                            }\n\n                            n--;\n                            b |= (_codec.InputBuffer[p++] & 0xff) << k;\n                            k += 8;\n                        }\n                        t = (int)(b & 7);\n                        last = t & 1;\n\n                        switch ((uint)t >> 1)\n                        {\n                            case 0:  // stored\n                                b >>= 3; k -= (3);\n                                t = k & 7; // go to byte boundary\n                                b >>= t; k -= t;\n                                mode = InflateBlockMode.LENS; // get length of stored block\n                                break;\n\n                            case 1:  // fixed\n                                int[] bl = new int[1];\n                                int[] bd = new int[1];\n                                int[][] tl = new int[1][];\n                                int[][] td = new int[1][];\n                                InfTree.inflate_trees_fixed(bl, bd, tl, td, _codec);\n                                codes.Init(bl[0], bd[0], tl[0], 0, td[0], 0);\n                                b >>= 3; k -= 3;\n                                mode = InflateBlockMode.CODES;\n                                break;\n\n                            case 2:  // dynamic\n                                b >>= 3; k -= 3;\n                                mode = InflateBlockMode.TABLE;\n                                break;\n\n                            case 3:  // illegal\n                                b >>= 3; k -= 3;\n                                mode = InflateBlockMode.BAD;\n                                _codec.Message = \"invalid block type\";\n                                r = ZlibConstants.Z_DATA_ERROR;\n                                bitb = b; bitk = k;\n                                _codec.AvailableBytesIn = n;\n                                _codec.TotalBytesIn += p - _codec.NextIn;\n                                _codec.NextIn = p;\n                                writeAt = q;\n                                return Flush(r);\n                        }\n                        break;\n\n                    case InflateBlockMode.LENS:\n\n                        while (k < (32))\n                        {\n                            if (n != 0)\n                            {\n                                r = ZlibConstants.Z_OK;\n                            }\n                            else\n                            {\n                                bitb = b; bitk = k;\n                                _codec.AvailableBytesIn = n;\n                                _codec.TotalBytesIn += p - _codec.NextIn;\n                                _codec.NextIn = p;\n                                writeAt = q;\n                                return Flush(r);\n                            }\n                            ;\n                            n--;\n                            b |= (_codec.InputBuffer[p++] & 0xff) << k;\n                            k += 8;\n                        }\n\n                        if ( ( ((~b)>>16) & 0xffff) != (b & 0xffff))\n                        {\n                            mode = InflateBlockMode.BAD;\n                            _codec.Message = \"invalid stored block lengths\";\n                            r = ZlibConstants.Z_DATA_ERROR;\n\n                            bitb = b; bitk = k;\n                            _codec.AvailableBytesIn = n;\n                            _codec.TotalBytesIn += p - _codec.NextIn;\n                            _codec.NextIn = p;\n                            writeAt = q;\n                            return Flush(r);\n                        }\n                        left = (b & 0xffff);\n                        b = k = 0; // dump bits\n                        mode = left != 0 ? InflateBlockMode.STORED : (last != 0 ? InflateBlockMode.DRY : InflateBlockMode.TYPE);\n                        break;\n\n                    case InflateBlockMode.STORED:\n                        if (n == 0)\n                        {\n                            bitb = b; bitk = k;\n                            _codec.AvailableBytesIn = n;\n                            _codec.TotalBytesIn += p - _codec.NextIn;\n                            _codec.NextIn = p;\n                            writeAt = q;\n                            return Flush(r);\n                        }\n\n                        if (m == 0)\n                        {\n                            if (q == end && readAt != 0)\n                            {\n                                q = 0; m = (int)(q < readAt ? readAt - q - 1 : end - q);\n                            }\n                            if (m == 0)\n                            {\n                                writeAt = q;\n                                r = Flush(r);\n                                q = writeAt; m = (int)(q < readAt ? readAt - q - 1 : end - q);\n                                if (q == end && readAt != 0)\n                                {\n                                    q = 0; m = (int)(q < readAt ? readAt - q - 1 : end - q);\n                                }\n                                if (m == 0)\n                                {\n                                    bitb = b; bitk = k;\n                                    _codec.AvailableBytesIn = n;\n                                    _codec.TotalBytesIn += p - _codec.NextIn;\n                                    _codec.NextIn = p;\n                                    writeAt = q;\n                                    return Flush(r);\n                                }\n                            }\n                        }\n                        r = ZlibConstants.Z_OK;\n\n                        t = left;\n                        if (t > n)\n                            t = n;\n                        if (t > m)\n                            t = m;\n                        Array.Copy(_codec.InputBuffer, p, window, q, t);\n                        p += t; n -= t;\n                        q += t; m -= t;\n                        if ((left -= t) != 0)\n                            break;\n                        mode = last != 0 ? InflateBlockMode.DRY : InflateBlockMode.TYPE;\n                        break;\n\n                    case InflateBlockMode.TABLE:\n\n                        while (k < (14))\n                        {\n                            if (n != 0)\n                            {\n                                r = ZlibConstants.Z_OK;\n                            }\n                            else\n                            {\n                                bitb = b; bitk = k;\n                                _codec.AvailableBytesIn = n;\n                                _codec.TotalBytesIn += p - _codec.NextIn;\n                                _codec.NextIn = p;\n                                writeAt = q;\n                                return Flush(r);\n                            }\n\n                            n--;\n                            b |= (_codec.InputBuffer[p++] & 0xff) << k;\n                            k += 8;\n                        }\n\n                        table = t = (b & 0x3fff);\n                        if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)\n                        {\n                            mode = InflateBlockMode.BAD;\n                            _codec.Message = \"too many length or distance symbols\";\n                            r = ZlibConstants.Z_DATA_ERROR;\n\n                            bitb = b; bitk = k;\n                            _codec.AvailableBytesIn = n;\n                            _codec.TotalBytesIn += p - _codec.NextIn;\n                            _codec.NextIn = p;\n                            writeAt = q;\n                            return Flush(r);\n                        }\n                        t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);\n                        if (blens == null || blens.Length < t)\n                        {\n                            blens = new int[t];\n                        }\n                        else\n                        {\n                            Array.Clear(blens, 0, t);\n                            // for (int i = 0; i < t; i++)\n                            // {\n                            //     blens[i] = 0;\n                            // }\n                        }\n\n                        b >>= 14;\n                        k -= 14;\n\n\n                        index = 0;\n                        mode = InflateBlockMode.BTREE;\n                        goto case InflateBlockMode.BTREE;\n\n                    case InflateBlockMode.BTREE:\n                        while (index < 4 + (table >> 10))\n                        {\n                            while (k < (3))\n                            {\n                                if (n != 0)\n                                {\n                                    r = ZlibConstants.Z_OK;\n                                }\n                                else\n                                {\n                                    bitb = b; bitk = k;\n                                    _codec.AvailableBytesIn = n;\n                                    _codec.TotalBytesIn += p - _codec.NextIn;\n                                    _codec.NextIn = p;\n                                    writeAt = q;\n                                    return Flush(r);\n                                }\n\n                                n--;\n                                b |= (_codec.InputBuffer[p++] & 0xff) << k;\n                                k += 8;\n                            }\n\n                            blens[border[index++]] = b & 7;\n\n                            b >>= 3; k -= 3;\n                        }\n\n                        while (index < 19)\n                        {\n                            blens[border[index++]] = 0;\n                        }\n\n                        bb[0] = 7;\n                        t = inftree.inflate_trees_bits(blens, bb, tb, hufts, _codec);\n                        if (t != ZlibConstants.Z_OK)\n                        {\n                            r = t;\n                            if (r == ZlibConstants.Z_DATA_ERROR)\n                            {\n                                blens = null;\n                                mode = InflateBlockMode.BAD;\n                            }\n\n                            bitb = b; bitk = k;\n                            _codec.AvailableBytesIn = n;\n                            _codec.TotalBytesIn += p - _codec.NextIn;\n                            _codec.NextIn = p;\n                            writeAt = q;\n                            return Flush(r);\n                        }\n\n                        index = 0;\n                        mode = InflateBlockMode.DTREE;\n                        goto case InflateBlockMode.DTREE;\n\n                    case InflateBlockMode.DTREE:\n                        while (true)\n                        {\n                            t = table;\n                            if (!(index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f)))\n                            {\n                                break;\n                            }\n\n                            int i, j, c;\n\n                            t = bb[0];\n\n                            while (k < t)\n                            {\n                                if (n != 0)\n                                {\n                                    r = ZlibConstants.Z_OK;\n                                }\n                                else\n                                {\n                                    bitb = b; bitk = k;\n                                    _codec.AvailableBytesIn = n;\n                                    _codec.TotalBytesIn += p - _codec.NextIn;\n                                    _codec.NextIn = p;\n                                    writeAt = q;\n                                    return Flush(r);\n                                }\n\n                                n--;\n                                b |= (_codec.InputBuffer[p++] & 0xff) << k;\n                                k += 8;\n                            }\n\n                            t = hufts[(tb[0] + (b & InternalInflateConstants.InflateMask[t])) * 3 + 1];\n                            c = hufts[(tb[0] + (b & InternalInflateConstants.InflateMask[t])) * 3 + 2];\n\n                            if (c < 16)\n                            {\n                                b >>= t; k -= t;\n                                blens[index++] = c;\n                            }\n                            else\n                            {\n                                // c == 16..18\n                                i = c == 18 ? 7 : c - 14;\n                                j = c == 18 ? 11 : 3;\n\n                                while (k < (t + i))\n                                {\n                                    if (n != 0)\n                                    {\n                                        r = ZlibConstants.Z_OK;\n                                    }\n                                    else\n                                    {\n                                        bitb = b; bitk = k;\n                                        _codec.AvailableBytesIn = n;\n                                        _codec.TotalBytesIn += p - _codec.NextIn;\n                                        _codec.NextIn = p;\n                                        writeAt = q;\n                                        return Flush(r);\n                                    }\n\n                                    n--;\n                                    b |= (_codec.InputBuffer[p++] & 0xff) << k;\n                                    k += 8;\n                                }\n\n                                b >>= t; k -= t;\n\n                                j += (b & InternalInflateConstants.InflateMask[i]);\n\n                                b >>= i; k -= i;\n\n                                i = index;\n                                t = table;\n                                if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || (c == 16 && i < 1))\n                                {\n                                    blens = null;\n                                    mode = InflateBlockMode.BAD;\n                                    _codec.Message = \"invalid bit length repeat\";\n                                    r = ZlibConstants.Z_DATA_ERROR;\n\n                                    bitb = b; bitk = k;\n                                    _codec.AvailableBytesIn = n;\n                                    _codec.TotalBytesIn += p - _codec.NextIn;\n                                    _codec.NextIn = p;\n                                    writeAt = q;\n                                    return Flush(r);\n                                }\n\n                                c = (c == 16) ? blens[i-1] : 0;\n                                do\n                                {\n                                    blens[i++] = c;\n                                }\n                                while (--j != 0);\n                                index = i;\n                            }\n                        }\n\n                        tb[0] = -1;\n                        {\n                            int[] bl = new int[] { 9 };  // must be <= 9 for lookahead assumptions\n                            int[] bd = new int[] { 6 }; // must be <= 9 for lookahead assumptions\n                            int[] tl = new int[1];\n                            int[] td = new int[1];\n\n                            t = table;\n                            t = inftree.inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), blens, bl, bd, tl, td, hufts, _codec);\n\n                            if (t != ZlibConstants.Z_OK)\n                            {\n                                if (t == ZlibConstants.Z_DATA_ERROR)\n                                {\n                                    blens = null;\n                                    mode = InflateBlockMode.BAD;\n                                }\n                                r = t;\n\n                                bitb = b; bitk = k;\n                                _codec.AvailableBytesIn = n;\n                                _codec.TotalBytesIn += p - _codec.NextIn;\n                                _codec.NextIn = p;\n                                writeAt = q;\n                                return Flush(r);\n                            }\n                            codes.Init(bl[0], bd[0], hufts, tl[0], hufts, td[0]);\n                        }\n                        mode = InflateBlockMode.CODES;\n                        goto case InflateBlockMode.CODES;\n\n                    case InflateBlockMode.CODES:\n                        bitb = b; bitk = k;\n                        _codec.AvailableBytesIn = n;\n                        _codec.TotalBytesIn += p - _codec.NextIn;\n                        _codec.NextIn = p;\n                        writeAt = q;\n\n                        r = codes.Process(this, r);\n                        if (r != ZlibConstants.Z_STREAM_END)\n                        {\n                            return Flush(r);\n                        }\n\n                        r = ZlibConstants.Z_OK;\n                        p = _codec.NextIn;\n                        n = _codec.AvailableBytesIn;\n                        b = bitb;\n                        k = bitk;\n                        q = writeAt;\n                        m = (int)(q < readAt ? readAt - q - 1 : end - q);\n\n                        if (last == 0)\n                        {\n                            mode = InflateBlockMode.TYPE;\n                            break;\n                        }\n                        mode = InflateBlockMode.DRY;\n                        goto case InflateBlockMode.DRY;\n\n                    case InflateBlockMode.DRY:\n                        writeAt = q;\n                        r = Flush(r);\n                        q = writeAt; m = (int)(q < readAt ? readAt - q - 1 : end - q);\n                        if (readAt != writeAt)\n                        {\n                            bitb = b; bitk = k;\n                            _codec.AvailableBytesIn = n;\n                            _codec.TotalBytesIn += p - _codec.NextIn;\n                            _codec.NextIn = p;\n                            writeAt = q;\n                            return Flush(r);\n                        }\n                        mode = InflateBlockMode.DONE;\n                        goto case InflateBlockMode.DONE;\n\n                    case InflateBlockMode.DONE:\n                        r = ZlibConstants.Z_STREAM_END;\n                        bitb = b;\n                        bitk = k;\n                        _codec.AvailableBytesIn = n;\n                        _codec.TotalBytesIn += p - _codec.NextIn;\n                        _codec.NextIn = p;\n                        writeAt = q;\n                        return Flush(r);\n\n                    case InflateBlockMode.BAD:\n                        r = ZlibConstants.Z_DATA_ERROR;\n\n                        bitb = b; bitk = k;\n                        _codec.AvailableBytesIn = n;\n                        _codec.TotalBytesIn += p - _codec.NextIn;\n                        _codec.NextIn = p;\n                        writeAt = q;\n                        return Flush(r);\n\n\n                    default:\n                        r = ZlibConstants.Z_STREAM_ERROR;\n\n                        bitb = b; bitk = k;\n                        _codec.AvailableBytesIn = n;\n                        _codec.TotalBytesIn += p - _codec.NextIn;\n                        _codec.NextIn = p;\n                        writeAt = q;\n                        return Flush(r);\n                }\n            }\n        }\n\n\n        internal void Free()\n        {\n            Reset();\n            window = null;\n            hufts = null;\n        }\n\n        internal void SetDictionary(byte[] d, int start, int n)\n        {\n            Array.Copy(d, start, window, 0, n);\n            readAt = writeAt = n;\n        }\n\n        // Returns true if inflate is currently at the end of a block generated\n        // by Z_SYNC_FLUSH or Z_FULL_FLUSH.\n        internal int SyncPoint()\n        {\n            return mode == InflateBlockMode.LENS ? 1 : 0;\n        }\n\n        // copy as much as possible from the sliding window to the output area\n        internal int Flush(int r)\n        {\n            int nBytes;\n\n            for (int pass=0; pass < 2; pass++)\n            {\n                if (pass==0)\n                {\n                    // compute number of bytes to copy as far as end of window\n                    nBytes = (int)((readAt <= writeAt ? writeAt : end) - readAt);\n                }\n                else\n                {\n                    // compute bytes to copy\n                    nBytes = writeAt - readAt;\n                }\n\n                // workitem 8870\n                if (nBytes == 0)\n                {\n                    if (r == ZlibConstants.Z_BUF_ERROR)\n                        r = ZlibConstants.Z_OK;\n                    return r;\n                }\n\n                if (nBytes > _codec.AvailableBytesOut)\n                    nBytes = _codec.AvailableBytesOut;\n\n                if (nBytes != 0 && r == ZlibConstants.Z_BUF_ERROR)\n                    r = ZlibConstants.Z_OK;\n\n                // update counters\n                _codec.AvailableBytesOut -= nBytes;\n                _codec.TotalBytesOut += nBytes;\n\n                // update check information\n                if (checkfn != null)\n                    _codec._Adler32 = check = Adler.Adler32(check, window, readAt, nBytes);\n\n                // copy as far as end of window\n                Array.Copy(window, readAt, _codec.OutputBuffer, _codec.NextOut, nBytes);\n                _codec.NextOut += nBytes;\n                readAt += nBytes;\n\n                // see if more to copy at beginning of window\n                if (readAt == end && pass == 0)\n                {\n                    // wrap pointers\n                    readAt = 0;\n                    if (writeAt == end)\n                        writeAt = 0;\n                }\n                else pass++;\n            }\n\n            // done\n            return r;\n        }\n    }\n\n\n    internal static class InternalInflateConstants\n    {\n        // And'ing with mask[n] masks the lower n bits\n        internal static readonly int[] InflateMask = new int[] {\n            0x00000000, 0x00000001, 0x00000003, 0x00000007,\n            0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,\n            0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,\n            0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff };\n    }\n\n\n    sealed class InflateCodes\n    {\n        // waiting for \"i:\"=input,\n        //             \"o:\"=output,\n        //             \"x:\"=nothing\n        private const int START   = 0; // x: set up for LEN\n        private const int LEN     = 1; // i: get length/literal/eob next\n        private const int LENEXT  = 2; // i: getting length extra (have base)\n        private const int DIST    = 3; // i: get distance next\n        private const int DISTEXT = 4; // i: getting distance extra\n        private const int COPY    = 5; // o: copying bytes in window, waiting for space\n        private const int LIT     = 6; // o: got literal, waiting for output space\n        private const int WASH    = 7; // o: got eob, possibly still output waiting\n        private const int END     = 8; // x: got eob and all data flushed\n        private const int BADCODE = 9; // x: got error\n\n        internal int mode;        // current inflate_codes mode\n\n        // mode dependent information\n        internal int len;\n\n        internal int[] tree;      // pointer into tree\n        internal int tree_index = 0;\n        internal int need;        // bits needed\n\n        internal int lit;\n\n        // if EXT or COPY, where and how much\n        internal int bitsToGet;   // bits to get for extra\n        internal int dist;        // distance back to copy from\n\n        internal byte lbits;      // ltree bits decoded per branch\n        internal byte dbits;      // dtree bits decoder per branch\n        internal int[] ltree;     // literal/length/eob tree\n        internal int ltree_index; // literal/length/eob tree\n        internal int[] dtree;     // distance tree\n        internal int dtree_index; // distance tree\n\n        internal InflateCodes()\n        {\n        }\n\n        internal void Init(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index)\n        {\n            mode = START;\n            lbits = (byte)bl;\n            dbits = (byte)bd;\n            ltree = tl;\n            ltree_index = tl_index;\n            dtree = td;\n            dtree_index = td_index;\n            tree = null;\n        }\n\n        internal int Process(InflateBlocks blocks, int r)\n        {\n            int j;      // temporary storage\n            int tindex; // temporary pointer\n            int e;      // extra bits or operation\n            int b = 0;  // bit buffer\n            int k = 0;  // bits in bit buffer\n            int p = 0;  // input data pointer\n            int n;      // bytes available there\n            int q;      // output window write pointer\n            int m;      // bytes to end of window or read pointer\n            int f;      // pointer to copy strings from\n\n            ZlibCodec z = blocks._codec;\n\n            // copy input/output information to locals (UPDATE macro restores)\n            p = z.NextIn;\n            n = z.AvailableBytesIn;\n            b = blocks.bitb;\n            k = blocks.bitk;\n            q = blocks.writeAt; m = q < blocks.readAt ? blocks.readAt - q - 1 : blocks.end - q;\n\n            // process input and output based on current state\n            while (true)\n            {\n                switch (mode)\n                {\n                    // waiting for \"i:\"=input, \"o:\"=output, \"x:\"=nothing\n                    case START:  // x: set up for LEN\n                        if (m >= 258 && n >= 10)\n                        {\n                            blocks.bitb = b; blocks.bitk = k;\n                            z.AvailableBytesIn = n;\n                            z.TotalBytesIn += p - z.NextIn;\n                            z.NextIn = p;\n                            blocks.writeAt = q;\n                            r = InflateFast(lbits, dbits, ltree, ltree_index, dtree, dtree_index, blocks, z);\n\n                            p = z.NextIn;\n                            n = z.AvailableBytesIn;\n                            b = blocks.bitb;\n                            k = blocks.bitk;\n                            q = blocks.writeAt; m = q < blocks.readAt ? blocks.readAt - q - 1 : blocks.end - q;\n\n                            if (r != ZlibConstants.Z_OK)\n                            {\n                                mode = (r == ZlibConstants.Z_STREAM_END) ? WASH : BADCODE;\n                                break;\n                            }\n                        }\n                        need = lbits;\n                        tree = ltree;\n                        tree_index = ltree_index;\n\n                        mode = LEN;\n                        goto case LEN;\n\n                    case LEN:  // i: get length/literal/eob next\n                        j = need;\n\n                        while (k < j)\n                        {\n                            if (n != 0)\n                                r = ZlibConstants.Z_OK;\n                            else\n                            {\n                                blocks.bitb = b; blocks.bitk = k;\n                                z.AvailableBytesIn = n;\n                                z.TotalBytesIn += p - z.NextIn;\n                                z.NextIn = p;\n                                blocks.writeAt = q;\n                                return blocks.Flush(r);\n                            }\n                            n--;\n                            b |= (z.InputBuffer[p++] & 0xff) << k;\n                            k += 8;\n                        }\n\n                        tindex = (tree_index + (b & InternalInflateConstants.InflateMask[j])) * 3;\n\n                        b >>= (tree[tindex + 1]);\n                        k -= (tree[tindex + 1]);\n\n                        e = tree[tindex];\n\n                        if (e == 0)\n                        {\n                            // literal\n                            lit = tree[tindex + 2];\n                            mode = LIT;\n                            break;\n                        }\n                        if ((e & 16) != 0)\n                        {\n                            // length\n                            bitsToGet = e & 15;\n                            len = tree[tindex + 2];\n                            mode = LENEXT;\n                            break;\n                        }\n                        if ((e & 64) == 0)\n                        {\n                            // next table\n                            need = e;\n                            tree_index = tindex / 3 + tree[tindex + 2];\n                            break;\n                        }\n                        if ((e & 32) != 0)\n                        {\n                            // end of block\n                            mode = WASH;\n                            break;\n                        }\n                        mode = BADCODE; // invalid code\n                        z.Message = \"invalid literal/length code\";\n                        r = ZlibConstants.Z_DATA_ERROR;\n\n                        blocks.bitb = b; blocks.bitk = k;\n                        z.AvailableBytesIn = n;\n                        z.TotalBytesIn += p - z.NextIn;\n                        z.NextIn = p;\n                        blocks.writeAt = q;\n                        return blocks.Flush(r);\n\n\n                    case LENEXT:  // i: getting length extra (have base)\n                        j = bitsToGet;\n\n                        while (k < j)\n                        {\n                            if (n != 0)\n                                r = ZlibConstants.Z_OK;\n                            else\n                            {\n                                blocks.bitb = b; blocks.bitk = k;\n                                z.AvailableBytesIn = n; z.TotalBytesIn += p - z.NextIn; z.NextIn = p;\n                                blocks.writeAt = q;\n                                return blocks.Flush(r);\n                            }\n                            n--; b |= (z.InputBuffer[p++] & 0xff) << k;\n                            k += 8;\n                        }\n\n                        len += (b & InternalInflateConstants.InflateMask[j]);\n\n                        b >>= j;\n                        k -= j;\n\n                        need = dbits;\n                        tree = dtree;\n                        tree_index = dtree_index;\n                        mode = DIST;\n                        goto case DIST;\n\n                    case DIST:  // i: get distance next\n                        j = need;\n\n                        while (k < j)\n                        {\n                            if (n != 0)\n                                r = ZlibConstants.Z_OK;\n                            else\n                            {\n                                blocks.bitb = b; blocks.bitk = k;\n                                z.AvailableBytesIn = n; z.TotalBytesIn += p - z.NextIn; z.NextIn = p;\n                                blocks.writeAt = q;\n                                return blocks.Flush(r);\n                            }\n                            n--; b |= (z.InputBuffer[p++] & 0xff) << k;\n                            k += 8;\n                        }\n\n                        tindex = (tree_index + (b & InternalInflateConstants.InflateMask[j])) * 3;\n\n                        b >>= tree[tindex + 1];\n                        k -= tree[tindex + 1];\n\n                        e = (tree[tindex]);\n                        if ((e & 0x10) != 0)\n                        {\n                            // distance\n                            bitsToGet = e & 15;\n                            dist = tree[tindex + 2];\n                            mode = DISTEXT;\n                            break;\n                        }\n                        if ((e & 64) == 0)\n                        {\n                            // next table\n                            need = e;\n                            tree_index = tindex / 3 + tree[tindex + 2];\n                            break;\n                        }\n                        mode = BADCODE; // invalid code\n                        z.Message = \"invalid distance code\";\n                        r = ZlibConstants.Z_DATA_ERROR;\n\n                        blocks.bitb = b; blocks.bitk = k;\n                        z.AvailableBytesIn = n; z.TotalBytesIn += p - z.NextIn; z.NextIn = p;\n                        blocks.writeAt = q;\n                        return blocks.Flush(r);\n\n\n                    case DISTEXT:  // i: getting distance extra\n                        j = bitsToGet;\n\n                        while (k < j)\n                        {\n                            if (n != 0)\n                                r = ZlibConstants.Z_OK;\n                            else\n                            {\n                                blocks.bitb = b; blocks.bitk = k;\n                                z.AvailableBytesIn = n; z.TotalBytesIn += p - z.NextIn; z.NextIn = p;\n                                blocks.writeAt = q;\n                                return blocks.Flush(r);\n                            }\n                            n--; b |= (z.InputBuffer[p++] & 0xff) << k;\n                            k += 8;\n                        }\n\n                        dist += (b & InternalInflateConstants.InflateMask[j]);\n\n                        b >>= j;\n                        k -= j;\n\n                        mode = COPY;\n                        goto case COPY;\n\n                    case COPY:  // o: copying bytes in window, waiting for space\n                        f = q - dist;\n                        while (f < 0)\n                        {\n                            // modulo window size-\"while\" instead\n                            f += blocks.end; // of \"if\" handles invalid distances\n                        }\n                        while (len != 0)\n                        {\n                            if (m == 0)\n                            {\n                                if (q == blocks.end && blocks.readAt != 0)\n                                {\n                                    q = 0; m = q < blocks.readAt ? blocks.readAt - q - 1 : blocks.end - q;\n                                }\n                                if (m == 0)\n                                {\n                                    blocks.writeAt = q; r = blocks.Flush(r);\n                                    q = blocks.writeAt; m = q < blocks.readAt ? blocks.readAt - q - 1 : blocks.end - q;\n\n                                    if (q == blocks.end && blocks.readAt != 0)\n                                    {\n                                        q = 0; m = q < blocks.readAt ? blocks.readAt - q - 1 : blocks.end - q;\n                                    }\n\n                                    if (m == 0)\n                                    {\n                                        blocks.bitb = b; blocks.bitk = k;\n                                        z.AvailableBytesIn = n;\n                                        z.TotalBytesIn += p - z.NextIn;\n                                        z.NextIn = p;\n                                        blocks.writeAt = q;\n                                        return blocks.Flush(r);\n                                    }\n                                }\n                            }\n\n                            blocks.window[q++] = blocks.window[f++]; m--;\n\n                            if (f == blocks.end)\n                                f = 0;\n                            len--;\n                        }\n                        mode = START;\n                        break;\n\n                    case LIT:  // o: got literal, waiting for output space\n                        if (m == 0)\n                        {\n                            if (q == blocks.end && blocks.readAt != 0)\n                            {\n                                q = 0; m = q < blocks.readAt ? blocks.readAt - q - 1 : blocks.end - q;\n                            }\n                            if (m == 0)\n                            {\n                                blocks.writeAt = q; r = blocks.Flush(r);\n                                q = blocks.writeAt; m = q < blocks.readAt ? blocks.readAt - q - 1 : blocks.end - q;\n\n                                if (q == blocks.end && blocks.readAt != 0)\n                                {\n                                    q = 0; m = q < blocks.readAt ? blocks.readAt - q - 1 : blocks.end - q;\n                                }\n                                if (m == 0)\n                                {\n                                    blocks.bitb = b; blocks.bitk = k;\n                                    z.AvailableBytesIn = n; z.TotalBytesIn += p - z.NextIn; z.NextIn = p;\n                                    blocks.writeAt = q;\n                                    return blocks.Flush(r);\n                                }\n                            }\n                        }\n                        r = ZlibConstants.Z_OK;\n\n                        blocks.window[q++] = (byte)lit; m--;\n\n                        mode = START;\n                        break;\n\n                    case WASH:  // o: got eob, possibly more output\n                        if (k > 7)\n                        {\n                            // return unused byte, if any\n                            k -= 8;\n                            n++;\n                            p--; // can always return one\n                        }\n\n                        blocks.writeAt = q; r = blocks.Flush(r);\n                        q = blocks.writeAt; m = q < blocks.readAt ? blocks.readAt - q - 1 : blocks.end - q;\n\n                        if (blocks.readAt != blocks.writeAt)\n                        {\n                            blocks.bitb = b; blocks.bitk = k;\n                            z.AvailableBytesIn = n; z.TotalBytesIn += p - z.NextIn; z.NextIn = p;\n                            blocks.writeAt = q;\n                            return blocks.Flush(r);\n                        }\n                        mode = END;\n                        goto case END;\n\n                    case END:\n                        r = ZlibConstants.Z_STREAM_END;\n                        blocks.bitb = b; blocks.bitk = k;\n                        z.AvailableBytesIn = n; z.TotalBytesIn += p - z.NextIn; z.NextIn = p;\n                        blocks.writeAt = q;\n                        return blocks.Flush(r);\n\n                    case BADCODE:  // x: got error\n\n                        r = ZlibConstants.Z_DATA_ERROR;\n\n                        blocks.bitb = b; blocks.bitk = k;\n                        z.AvailableBytesIn = n; z.TotalBytesIn += p - z.NextIn; z.NextIn = p;\n                        blocks.writeAt = q;\n                        return blocks.Flush(r);\n\n                    default:\n                        r = ZlibConstants.Z_STREAM_ERROR;\n\n                        blocks.bitb = b; blocks.bitk = k;\n                        z.AvailableBytesIn = n; z.TotalBytesIn += p - z.NextIn; z.NextIn = p;\n                        blocks.writeAt = q;\n                        return blocks.Flush(r);\n                }\n            }\n        }\n\n\n        // Called with number of bytes left to write in window at least 258\n        // (the maximum string length) and number of input bytes available\n        // at least ten.  The ten bytes are six bytes for the longest length/\n        // distance pair plus four bytes for overloading the bit buffer.\n\n        internal int InflateFast(int bl, int bd, int[] tl, int tl_index, int[] td, int td_index, InflateBlocks s, ZlibCodec z)\n        {\n            int t;        // temporary pointer\n            int[] tp;     // temporary pointer\n            int tp_index; // temporary pointer\n            int e;        // extra bits or operation\n            int b;        // bit buffer\n            int k;        // bits in bit buffer\n            int p;        // input data pointer\n            int n;        // bytes available there\n            int q;        // output window write pointer\n            int m;        // bytes to end of window or read pointer\n            int ml;       // mask for literal/length tree\n            int md;       // mask for distance tree\n            int c;        // bytes to copy\n            int d;        // distance back to copy from\n            int r;        // copy source pointer\n\n            int tp_index_t_3; // (tp_index+t)*3\n\n            // load input, output, bit values\n            p = z.NextIn; n = z.AvailableBytesIn; b = s.bitb; k = s.bitk;\n            q = s.writeAt; m = q < s.readAt ? s.readAt - q - 1 : s.end - q;\n\n            // initialize masks\n            ml = InternalInflateConstants.InflateMask[bl];\n            md = InternalInflateConstants.InflateMask[bd];\n\n            // do until not enough input or output space for fast loop\n            do\n            {\n                // assume called with m >= 258 && n >= 10\n                // get literal/length code\n                while (k < (20))\n                {\n                    // max bits for literal/length code\n                    n--;\n                    b |= (z.InputBuffer[p++] & 0xff) << k; k += 8;\n                }\n\n                t = b & ml;\n                tp = tl;\n                tp_index = tl_index;\n                tp_index_t_3 = (tp_index + t) * 3;\n                if ((e = tp[tp_index_t_3]) == 0)\n                {\n                    b >>= (tp[tp_index_t_3 + 1]); k -= (tp[tp_index_t_3 + 1]);\n\n                    s.window[q++] = (byte)tp[tp_index_t_3 + 2];\n                    m--;\n                    continue;\n                }\n                do\n                {\n\n                    b >>= (tp[tp_index_t_3 + 1]); k -= (tp[tp_index_t_3 + 1]);\n\n                    if ((e & 16) != 0)\n                    {\n                        e &= 15;\n                        c = tp[tp_index_t_3 + 2] + ((int)b & InternalInflateConstants.InflateMask[e]);\n\n                        b >>= e; k -= e;\n\n                        // decode distance base of block to copy\n                        while (k < 15)\n                        {\n                            // max bits for distance code\n                            n--;\n                            b |= (z.InputBuffer[p++] & 0xff) << k; k += 8;\n                        }\n\n                        t = b & md;\n                        tp = td;\n                        tp_index = td_index;\n                        tp_index_t_3 = (tp_index + t) * 3;\n                        e = tp[tp_index_t_3];\n\n                        do\n                        {\n\n                            b >>= (tp[tp_index_t_3 + 1]); k -= (tp[tp_index_t_3 + 1]);\n\n                            if ((e & 16) != 0)\n                            {\n                                // get extra bits to add to distance base\n                                e &= 15;\n                                while (k < e)\n                                {\n                                    // get extra bits (up to 13)\n                                    n--;\n                                    b |= (z.InputBuffer[p++] & 0xff) << k; k += 8;\n                                }\n\n                                d = tp[tp_index_t_3 + 2] + (b & InternalInflateConstants.InflateMask[e]);\n\n                                b >>= e; k -= e;\n\n                                // do the copy\n                                m -= c;\n                                if (q >= d)\n                                {\n                                    // offset before dest\n                                    //  just copy\n                                    r = q - d;\n                                    if (q - r > 0 && 2 > (q - r))\n                                    {\n                                        s.window[q++] = s.window[r++]; // minimum count is three,\n                                        s.window[q++] = s.window[r++]; // so unroll loop a little\n                                        c -= 2;\n                                    }\n                                    else\n                                    {\n                                        Array.Copy(s.window, r, s.window, q, 2);\n                                        q += 2; r += 2; c -= 2;\n                                    }\n                                }\n                                else\n                                {\n                                    // else offset after destination\n                                    r = q - d;\n                                    do\n                                    {\n                                        r += s.end; // force pointer in window\n                                    }\n                                    while (r < 0); // covers invalid distances\n                                    e = s.end - r;\n                                    if (c > e)\n                                    {\n                                        // if source crosses,\n                                        c -= e; // wrapped copy\n                                        if (q - r > 0 && e > (q - r))\n                                        {\n                                            do\n                                            {\n                                                s.window[q++] = s.window[r++];\n                                            }\n                                            while (--e != 0);\n                                        }\n                                        else\n                                        {\n                                            Array.Copy(s.window, r, s.window, q, e);\n                                            q += e; r += e; e = 0;\n                                        }\n                                        r = 0; // copy rest from start of window\n                                    }\n                                }\n\n                                // copy all or what's left\n                                if (q - r > 0 && c > (q - r))\n                                {\n                                    do\n                                    {\n                                        s.window[q++] = s.window[r++];\n                                    }\n                                    while (--c != 0);\n                                }\n                                else\n                                {\n                                    Array.Copy(s.window, r, s.window, q, c);\n                                    q += c; r += c; c = 0;\n                                }\n                                break;\n                            }\n                            else if ((e & 64) == 0)\n                            {\n                                t += tp[tp_index_t_3 + 2];\n                                t += (b & InternalInflateConstants.InflateMask[e]);\n                                tp_index_t_3 = (tp_index + t) * 3;\n                                e = tp[tp_index_t_3];\n                            }\n                            else\n                            {\n                                z.Message = \"invalid distance code\";\n\n                                c = z.AvailableBytesIn - n; c = (k >> 3) < c ? k >> 3 : c; n += c; p -= c; k -= (c << 3);\n\n                                s.bitb = b; s.bitk = k;\n                                z.AvailableBytesIn = n; z.TotalBytesIn += p - z.NextIn; z.NextIn = p;\n                                s.writeAt = q;\n\n                                return ZlibConstants.Z_DATA_ERROR;\n                            }\n                        }\n                        while (true);\n                        break;\n                    }\n\n                    if ((e & 64) == 0)\n                    {\n                        t += tp[tp_index_t_3 + 2];\n                        t += (b & InternalInflateConstants.InflateMask[e]);\n                        tp_index_t_3 = (tp_index + t) * 3;\n                        if ((e = tp[tp_index_t_3]) == 0)\n                        {\n                            b >>= (tp[tp_index_t_3 + 1]); k -= (tp[tp_index_t_3 + 1]);\n                            s.window[q++] = (byte)tp[tp_index_t_3 + 2];\n                            m--;\n                            break;\n                        }\n                    }\n                    else if ((e & 32) != 0)\n                    {\n                        c = z.AvailableBytesIn - n; c = (k >> 3) < c ? k >> 3 : c; n += c; p -= c; k -= (c << 3);\n\n                        s.bitb = b; s.bitk = k;\n                        z.AvailableBytesIn = n; z.TotalBytesIn += p - z.NextIn; z.NextIn = p;\n                        s.writeAt = q;\n\n                        return ZlibConstants.Z_STREAM_END;\n                    }\n                    else\n                    {\n                        z.Message = \"invalid literal/length code\";\n\n                        c = z.AvailableBytesIn - n; c = (k >> 3) < c ? k >> 3 : c; n += c; p -= c; k -= (c << 3);\n\n                        s.bitb = b; s.bitk = k;\n                        z.AvailableBytesIn = n; z.TotalBytesIn += p - z.NextIn; z.NextIn = p;\n                        s.writeAt = q;\n\n                        return ZlibConstants.Z_DATA_ERROR;\n                    }\n                }\n                while (true);\n            }\n            while (m >= 258 && n >= 10);\n\n            // not enough input or output--restore pointers and return\n            c = z.AvailableBytesIn - n; c = (k >> 3) < c ? k >> 3 : c; n += c; p -= c; k -= (c << 3);\n\n            s.bitb = b; s.bitk = k;\n            z.AvailableBytesIn = n; z.TotalBytesIn += p - z.NextIn; z.NextIn = p;\n            s.writeAt = q;\n\n            return ZlibConstants.Z_OK;\n        }\n    }\n\n\n    internal sealed class InflateManager\n    {\n        // preset dictionary flag in zlib header\n        private const int PRESET_DICT = 0x20;\n\n        private const int Z_DEFLATED = 8;\n\n        private enum InflateManagerMode\n        {\n            METHOD = 0,  // waiting for method byte\n            FLAG   = 1,  // waiting for flag byte\n            DICT4  = 2,  // four dictionary check bytes to go\n            DICT3  = 3,  // three dictionary check bytes to go\n            DICT2  = 4,  // two dictionary check bytes to go\n            DICT1  = 5,  // one dictionary check byte to go\n            DICT0  = 6,  // waiting for inflateSetDictionary\n            BLOCKS = 7,  // decompressing blocks\n            CHECK4 = 8,  // four check bytes to go\n            CHECK3 = 9,  // three check bytes to go\n            CHECK2 = 10, // two check bytes to go\n            CHECK1 = 11, // one check byte to go\n            DONE   = 12, // finished check, done\n            BAD    = 13, // got an error--stay here\n        }\n\n        private InflateManagerMode mode; // current inflate mode\n        internal ZlibCodec _codec; // pointer back to this zlib stream\n\n        // mode dependent information\n        internal int method; // if FLAGS, method byte\n\n        // if CHECK, check values to compare\n        internal uint computedCheck; // computed check value\n        internal uint expectedCheck; // stream check value\n\n        // if BAD, inflateSync's marker bytes count\n        internal int marker;\n\n        // mode independent information\n        //internal int nowrap; // flag for no wrapper\n        private bool _handleRfc1950HeaderBytes = true;\n        internal bool HandleRfc1950HeaderBytes\n        {\n            get { return _handleRfc1950HeaderBytes; }\n            set { _handleRfc1950HeaderBytes = value; }\n        }\n        internal int wbits; // log2(window size)  (8..15, defaults to 15)\n\n        internal InflateBlocks blocks; // current inflate_blocks state\n\n        public InflateManager() { }\n\n        public InflateManager(bool expectRfc1950HeaderBytes)\n        {\n            _handleRfc1950HeaderBytes = expectRfc1950HeaderBytes;\n        }\n\n        internal int Reset()\n        {\n            _codec.TotalBytesIn = _codec.TotalBytesOut = 0;\n            _codec.Message = null;\n            mode = HandleRfc1950HeaderBytes ? InflateManagerMode.METHOD : InflateManagerMode.BLOCKS;\n            blocks.Reset();\n            return ZlibConstants.Z_OK;\n        }\n\n        internal int End()\n        {\n            if (blocks != null)\n                blocks.Free();\n            blocks = null;\n            return ZlibConstants.Z_OK;\n        }\n\n        internal int Initialize(ZlibCodec codec, int w)\n        {\n            _codec = codec;\n            _codec.Message = null;\n            blocks = null;\n\n            // handle undocumented nowrap option (no zlib header or check)\n            //nowrap = 0;\n            //if (w < 0)\n            //{\n            //    w = - w;\n            //    nowrap = 1;\n            //}\n\n            // set window size\n            if (w < 8 || w > 15)\n            {\n                End();\n                throw new ZlibException(\"Bad window size.\");\n\n                //return ZlibConstants.Z_STREAM_ERROR;\n            }\n            wbits = w;\n\n            blocks = new InflateBlocks(codec,\n                HandleRfc1950HeaderBytes ? this : null,\n                1 << w);\n\n            // reset state\n            Reset();\n            return ZlibConstants.Z_OK;\n        }\n\n\n        internal int Inflate(FlushType flush)\n        {\n            int b;\n\n            if (_codec.InputBuffer == null)\n                throw new ZlibException(\"InputBuffer is null. \");\n\n//             int f = (flush == FlushType.Finish)\n//                 ? ZlibConstants.Z_BUF_ERROR\n//                 : ZlibConstants.Z_OK;\n\n            // workitem 8870\n            int f = ZlibConstants.Z_OK;\n            int r = ZlibConstants.Z_BUF_ERROR;\n\n            while (true)\n            {\n                switch (mode)\n                {\n                    case InflateManagerMode.METHOD:\n                        if (_codec.AvailableBytesIn == 0) return r;\n                        r = f;\n                        _codec.AvailableBytesIn--;\n                        _codec.TotalBytesIn++;\n                        if (((method = _codec.InputBuffer[_codec.NextIn++]) & 0xf) != Z_DEFLATED)\n                        {\n                            mode = InflateManagerMode.BAD;\n                            _codec.Message = String.Format(\"unknown compression method (0x{0:X2})\", method);\n                            marker = 5; // can't try inflateSync\n                            break;\n                        }\n                        if ((method >> 4) + 8 > wbits)\n                        {\n                            mode = InflateManagerMode.BAD;\n                            _codec.Message = String.Format(\"invalid window size ({0})\", (method >> 4) + 8);\n                            marker = 5; // can't try inflateSync\n                            break;\n                        }\n                        mode = InflateManagerMode.FLAG;\n                        break;\n\n\n                    case InflateManagerMode.FLAG:\n                        if (_codec.AvailableBytesIn == 0) return r;\n                        r = f;\n                        _codec.AvailableBytesIn--;\n                        _codec.TotalBytesIn++;\n                        b = (_codec.InputBuffer[_codec.NextIn++]) & 0xff;\n\n                        if ((((method << 8) + b) % 31) != 0)\n                        {\n                            mode = InflateManagerMode.BAD;\n                            _codec.Message = \"incorrect header check\";\n                            marker = 5; // can't try inflateSync\n                            break;\n                        }\n\n                        mode = ((b & PRESET_DICT) == 0)\n                            ? InflateManagerMode.BLOCKS\n                            : InflateManagerMode.DICT4;\n                        break;\n\n                    case InflateManagerMode.DICT4:\n                        if (_codec.AvailableBytesIn == 0) return r;\n                        r = f;\n                        _codec.AvailableBytesIn--;\n                        _codec.TotalBytesIn++;\n                        expectedCheck = (uint)((_codec.InputBuffer[_codec.NextIn++] << 24) & 0xff000000);\n                        mode = InflateManagerMode.DICT3;\n                        break;\n\n                    case InflateManagerMode.DICT3:\n                        if (_codec.AvailableBytesIn == 0) return r;\n                        r = f;\n                        _codec.AvailableBytesIn--;\n                        _codec.TotalBytesIn++;\n                        expectedCheck += (uint)((_codec.InputBuffer[_codec.NextIn++] << 16) & 0x00ff0000);\n                        mode = InflateManagerMode.DICT2;\n                        break;\n\n                    case InflateManagerMode.DICT2:\n\n                        if (_codec.AvailableBytesIn == 0) return r;\n                        r = f;\n                        _codec.AvailableBytesIn--;\n                        _codec.TotalBytesIn++;\n                        expectedCheck += (uint)((_codec.InputBuffer[_codec.NextIn++] << 8) & 0x0000ff00);\n                        mode = InflateManagerMode.DICT1;\n                        break;\n\n\n                    case InflateManagerMode.DICT1:\n                        if (_codec.AvailableBytesIn == 0) return r;\n                        r = f;\n                        _codec.AvailableBytesIn--; _codec.TotalBytesIn++;\n                        expectedCheck += (uint)(_codec.InputBuffer[_codec.NextIn++] & 0x000000ff);\n                        _codec._Adler32 = expectedCheck;\n                        mode = InflateManagerMode.DICT0;\n                        return ZlibConstants.Z_NEED_DICT;\n\n\n                    case InflateManagerMode.DICT0:\n                        mode = InflateManagerMode.BAD;\n                        _codec.Message = \"need dictionary\";\n                        marker = 0; // can try inflateSync\n                        return ZlibConstants.Z_STREAM_ERROR;\n\n\n                    case InflateManagerMode.BLOCKS:\n                        r = blocks.Process(r);\n                        if (r == ZlibConstants.Z_DATA_ERROR)\n                        {\n                            mode = InflateManagerMode.BAD;\n                            marker = 0; // can try inflateSync\n                            break;\n                        }\n\n                        if (r == ZlibConstants.Z_OK) r = f;\n\n                        if (r != ZlibConstants.Z_STREAM_END)\n                            return r;\n\n                        r = f;\n                        computedCheck = blocks.Reset();\n                        if (!HandleRfc1950HeaderBytes)\n                        {\n                            mode = InflateManagerMode.DONE;\n                            return ZlibConstants.Z_STREAM_END;\n                        }\n                        mode = InflateManagerMode.CHECK4;\n                        break;\n\n                    case InflateManagerMode.CHECK4:\n                        if (_codec.AvailableBytesIn == 0) return r;\n                        r = f;\n                        _codec.AvailableBytesIn--;\n                        _codec.TotalBytesIn++;\n                        expectedCheck = (uint)((_codec.InputBuffer[_codec.NextIn++] << 24) & 0xff000000);\n                        mode = InflateManagerMode.CHECK3;\n                        break;\n\n                    case InflateManagerMode.CHECK3:\n                        if (_codec.AvailableBytesIn == 0) return r;\n                        r = f;\n                        _codec.AvailableBytesIn--; _codec.TotalBytesIn++;\n                        expectedCheck += (uint)((_codec.InputBuffer[_codec.NextIn++] << 16) & 0x00ff0000);\n                        mode = InflateManagerMode.CHECK2;\n                        break;\n\n                    case InflateManagerMode.CHECK2:\n                        if (_codec.AvailableBytesIn == 0) return r;\n                        r = f;\n                        _codec.AvailableBytesIn--;\n                        _codec.TotalBytesIn++;\n                        expectedCheck += (uint)((_codec.InputBuffer[_codec.NextIn++] << 8) & 0x0000ff00);\n                        mode = InflateManagerMode.CHECK1;\n                        break;\n\n                    case InflateManagerMode.CHECK1:\n                        if (_codec.AvailableBytesIn == 0) return r;\n                        r = f;\n                        _codec.AvailableBytesIn--; _codec.TotalBytesIn++;\n                        expectedCheck += (uint)(_codec.InputBuffer[_codec.NextIn++] & 0x000000ff);\n                        if (computedCheck != expectedCheck)\n                        {\n                            mode = InflateManagerMode.BAD;\n                            _codec.Message = \"incorrect data check\";\n                            marker = 5; // can't try inflateSync\n                            break;\n                        }\n                        mode = InflateManagerMode.DONE;\n                        return ZlibConstants.Z_STREAM_END;\n\n                    case InflateManagerMode.DONE:\n                        return ZlibConstants.Z_STREAM_END;\n\n                    case InflateManagerMode.BAD:\n                        throw new ZlibException(String.Format(\"Bad state ({0})\", _codec.Message));\n\n                    default:\n                        throw new ZlibException(\"Stream error.\");\n\n                }\n            }\n        }\n\n\n\n        internal int SetDictionary(byte[] dictionary)\n        {\n            int index = 0;\n            int length = dictionary.Length;\n            if (mode != InflateManagerMode.DICT0)\n                throw new ZlibException(\"Stream error.\");\n\n            if (Adler.Adler32(1, dictionary, 0, dictionary.Length) != _codec._Adler32)\n            {\n                return ZlibConstants.Z_DATA_ERROR;\n            }\n\n            _codec._Adler32 = Adler.Adler32(0, null, 0, 0);\n\n            if (length >= (1 << wbits))\n            {\n                length = (1 << wbits) - 1;\n                index = dictionary.Length - length;\n            }\n            blocks.SetDictionary(dictionary, index, length);\n            mode = InflateManagerMode.BLOCKS;\n            return ZlibConstants.Z_OK;\n        }\n\n\n        private static readonly byte[] mark = new byte[] { 0, 0, 0xff, 0xff };\n\n        internal int Sync()\n        {\n            int n; // number of bytes to look at\n            int p; // pointer to bytes\n            int m; // number of marker bytes found in a row\n            long r, w; // temporaries to save total_in and total_out\n\n            // set up\n            if (mode != InflateManagerMode.BAD)\n            {\n                mode = InflateManagerMode.BAD;\n                marker = 0;\n            }\n            if ((n = _codec.AvailableBytesIn) == 0)\n                return ZlibConstants.Z_BUF_ERROR;\n            p = _codec.NextIn;\n            m = marker;\n\n            // search\n            while (n != 0 && m < 4)\n            {\n                if (_codec.InputBuffer[p] == mark[m])\n                {\n                    m++;\n                }\n                else if (_codec.InputBuffer[p] != 0)\n                {\n                    m = 0;\n                }\n                else\n                {\n                    m = 4 - m;\n                }\n                p++; n--;\n            }\n\n            // restore\n            _codec.TotalBytesIn += p - _codec.NextIn;\n            _codec.NextIn = p;\n            _codec.AvailableBytesIn = n;\n            marker = m;\n\n            // return no joy or set up to restart on a new block\n            if (m != 4)\n            {\n                return ZlibConstants.Z_DATA_ERROR;\n            }\n            r = _codec.TotalBytesIn;\n            w = _codec.TotalBytesOut;\n            Reset();\n            _codec.TotalBytesIn = r;\n            _codec.TotalBytesOut = w;\n            mode = InflateManagerMode.BLOCKS;\n            return ZlibConstants.Z_OK;\n        }\n\n\n        // Returns true if inflate is currently at the end of a block generated\n        // by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP\n        // implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH\n        // but removes the length bytes of the resulting empty stored block. When\n        // decompressing, PPP checks that at the end of input packet, inflate is\n        // waiting for these length bytes.\n        internal int SyncPoint(ZlibCodec z)\n        {\n            return blocks.SyncPoint();\n        }\n    }\n}"
  },
  {
    "path": "src/FirebirdSql.Data.External/zlib/Tree.cs",
    "content": "// Tree.cs\n// ------------------------------------------------------------------\n//\n// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.  \n// All rights reserved.\n//\n// This code module is part of DotNetZip, a zipfile class library.\n//\n// ------------------------------------------------------------------\n//\n// This code is licensed under the Microsoft Public License. \n// See the file License.txt for the license details.\n// More info on: http://dotnetzip.codeplex.com\n//\n// ------------------------------------------------------------------\n//\n// last saved (in emacs): \n// Time-stamp: <2009-October-28 13:29:50>\n//\n// ------------------------------------------------------------------\n//\n// This module defines classes for zlib compression and\n// decompression. This code is derived from the jzlib implementation of\n// zlib. In keeping with the license for jzlib, the copyright to that\n// code is below.\n//\n// ------------------------------------------------------------------\n// \n// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.\n// \n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are met:\n// \n// 1. Redistributions of source code must retain the above copyright notice,\n// this list of conditions and the following disclaimer.\n// \n// 2. Redistributions in binary form must reproduce the above copyright \n// notice, this list of conditions and the following disclaimer in \n// the documentation and/or other materials provided with the distribution.\n// \n// 3. The names of the authors may not be used to endorse or promote products\n// derived from this software without specific prior written permission.\n// \n// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,\n// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\n// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,\n// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,\n// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\n// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n// \n// -----------------------------------------------------------------------\n//\n// This program is based on zlib-1.1.3; credit to authors\n// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)\n// and contributors of zlib.\n//\n// -----------------------------------------------------------------------\n\n\nusing System;\n\nnamespace Ionic.Zlib\n{\n    sealed class Tree\n    {\n        private static readonly int HEAP_SIZE = (2 * InternalConstants.L_CODES + 1);\n                \n        // extra bits for each length code\n        internal static readonly int[] ExtraLengthBits = new int[]\n        {\n            0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,\n            3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0\n        };\n                \n        // extra bits for each distance code\n        internal static readonly int[] ExtraDistanceBits = new int[]\n        {\n            0, 0, 0, 0, 1, 1,  2,  2,  3,  3,  4,  4,  5,  5,  6,  6,\n            7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13\n        };\n                \n        // extra bits for each bit length code\n        internal static readonly int[] extra_blbits = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7};\n                \n        internal static readonly sbyte[] bl_order = new sbyte[]{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};\n                \n                \n        // The lengths of the bit length codes are sent in order of decreasing\n        // probability, to avoid transmitting the lengths for unused bit\n        // length codes.\n                \n        internal const int Buf_size = 8 * 2;\n                \n        // see definition of array dist_code below\n        //internal const int DIST_CODE_LEN = 512;\n                \n        private static readonly sbyte[] _dist_code = new sbyte[]\n        {\n            0,  1,  2,  3,  4,  4,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7, \n            8,  8,  8,  8,  8,  8,  8,  8,  9,  9,  9,  9,  9,  9,  9,  9,\n            10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, \n            11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, \n            12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, \n            12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, \n            13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, \n            13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, \n            14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, \n            14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, \n            14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, \n            14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, \n            15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, \n            15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, \n            15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, \n            15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, \n            0,   0, 16, 17, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, \n            22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, \n            24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, \n            25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, \n            26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, \n            26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, \n            27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \n            27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, \n            28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, \n            28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, \n            28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, \n            28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, \n            29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, \n            29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, \n            29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, \n            29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29\n        };\n                \n        internal static readonly sbyte[] LengthCode = new sbyte[]\n        {\n            0,   1,  2,  3,  4,  5,  6,  7,  8,  8,  9,  9, 10, 10, 11, 11,\n            12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15,\n            16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17,\n            18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19,\n            20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,\n            21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,\n            22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,\n            23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,\n            24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n            24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n            25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,\n            25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,\n            26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,\n            26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,\n            27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,\n            27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28\n        };\n                \n\n        internal static readonly int[] LengthBase = new int[]\n        {\n            0,   1,  2,  3,  4,  5,  6,   7,   8,  10,  12,  14, 16, 20, 24, 28,\n            32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 0\n        };\n                \n\n        internal static readonly int[] DistanceBase = new int[]\n        {\n            0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192,\n            256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576\n        };\n\n        \n        /// <summary>\n        /// Map from a distance to a distance code.\n        /// </summary>\n        /// <remarks> \n        /// No side effects. _dist_code[256] and _dist_code[257] are never used.\n        /// </remarks>\n        internal static int DistanceCode(int dist)\n        {\n            return (dist < 256)\n                ? _dist_code[dist]\n                : _dist_code[256 + SharedUtils.URShift(dist, 7)];\n        }\n\n        internal short[] dyn_tree; // the dynamic tree\n        internal int max_code; // largest code with non zero frequency\n        internal StaticTree staticTree; // the corresponding static tree\n                \n        // Compute the optimal bit lengths for a tree and update the total bit length\n        // for the current block.\n        // IN assertion: the fields freq and dad are set, heap[heap_max] and\n        //    above are the tree nodes sorted by increasing frequency.\n        // OUT assertions: the field len is set to the optimal bit length, the\n        //     array bl_count contains the frequencies for each bit length.\n        //     The length opt_len is updated; static_len is also updated if stree is\n        //     not null.\n        internal void  gen_bitlen(DeflateManager s)\n        {\n            short[] tree = dyn_tree;\n            short[] stree = staticTree.treeCodes;\n            int[] extra = staticTree.extraBits;\n            int base_Renamed = staticTree.extraBase;\n            int max_length = staticTree.maxLength;\n            int h; // heap index\n            int n, m; // iterate over the tree elements\n            int bits; // bit length\n            int xbits; // extra bits\n            short f; // frequency\n            int overflow = 0; // number of elements with bit length too large\n                        \n            for (bits = 0; bits <= InternalConstants.MAX_BITS; bits++)\n                s.bl_count[bits] = 0;\n                        \n            // In a first pass, compute the optimal bit lengths (which may\n            // overflow in the case of the bit length tree).\n            tree[s.heap[s.heap_max] * 2 + 1] = 0; // root of the heap\n                        \n            for (h = s.heap_max + 1; h < HEAP_SIZE; h++)\n            {\n                n = s.heap[h];\n                bits = tree[tree[n * 2 + 1] * 2 + 1] + 1;\n                if (bits > max_length)\n                {\n                    bits = max_length; overflow++;\n                }\n                tree[n * 2 + 1] = (short) bits;\n                // We overwrite tree[n*2+1] which is no longer needed\n                                \n                if (n > max_code)\n                    continue; // not a leaf node\n                                \n                s.bl_count[bits]++;\n                xbits = 0;\n                if (n >= base_Renamed)\n                    xbits = extra[n - base_Renamed];\n                f = tree[n * 2];\n                s.opt_len += f * (bits + xbits);\n                if (stree != null)\n                    s.static_len += f * (stree[n * 2 + 1] + xbits);\n            }\n            if (overflow == 0)\n                return ;\n                        \n            // This happens for example on obj2 and pic of the Calgary corpus\n            // Find the first bit length which could increase:\n            do \n            {\n                bits = max_length - 1;\n                while (s.bl_count[bits] == 0)\n                    bits--;\n                s.bl_count[bits]--; // move one leaf down the tree\n                s.bl_count[bits + 1] = (short) (s.bl_count[bits + 1] + 2); // move one overflow item as its brother\n                s.bl_count[max_length]--;\n                // The brother of the overflow item also moves one step up,\n                // but this does not affect bl_count[max_length]\n                overflow -= 2;\n            }\n            while (overflow > 0);\n                        \n            for (bits = max_length; bits != 0; bits--)\n            {\n                n = s.bl_count[bits];\n                while (n != 0)\n                {\n                    m = s.heap[--h];\n                    if (m > max_code)\n                        continue;\n                    if (tree[m * 2 + 1] != bits)\n                    {\n                        s.opt_len = (int) (s.opt_len + ((long) bits - (long) tree[m * 2 + 1]) * (long) tree[m * 2]);\n                        tree[m * 2 + 1] = (short) bits;\n                    }\n                    n--;\n                }\n            }\n        }\n                \n        // Construct one Huffman tree and assigns the code bit strings and lengths.\n        // Update the total bit length for the current block.\n        // IN assertion: the field freq is set for all tree elements.\n        // OUT assertions: the fields len and code are set to the optimal bit length\n        //     and corresponding code. The length opt_len is updated; static_len is\n        //     also updated if stree is not null. The field max_code is set.\n        internal void  build_tree(DeflateManager s)\n        {\n            short[] tree  = dyn_tree;\n            short[] stree = staticTree.treeCodes;\n            int elems     = staticTree.elems;\n            int n, m;            // iterate over heap elements\n            int max_code  = -1;  // largest code with non zero frequency\n            int node;            // new node being created\n                        \n            // Construct the initial heap, with least frequent element in\n            // heap[1]. The sons of heap[n] are heap[2*n] and heap[2*n+1].\n            // heap[0] is not used.\n            s.heap_len = 0;\n            s.heap_max = HEAP_SIZE;\n                        \n            for (n = 0; n < elems; n++)\n            {\n                if (tree[n * 2] != 0)\n                {\n                    s.heap[++s.heap_len] = max_code = n;\n                    s.depth[n] = 0;\n                }\n                else\n                {\n                    tree[n * 2 + 1] = 0;\n                }\n            }\n                        \n            // The pkzip format requires that at least one distance code exists,\n            // and that at least one bit should be sent even if there is only one\n            // possible code. So to avoid special checks later on we force at least\n            // two codes of non zero frequency.\n            while (s.heap_len < 2)\n            {\n                node = s.heap[++s.heap_len] = (max_code < 2?++max_code:0);\n                tree[node * 2] = 1;\n                s.depth[node] = 0;\n                s.opt_len--;\n                if (stree != null)\n                    s.static_len -= stree[node * 2 + 1];\n                // node is 0 or 1 so it does not have extra bits\n            }\n            this.max_code = max_code;\n                        \n            // The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,\n            // establish sub-heaps of increasing lengths:\n                        \n            for (n = s.heap_len / 2; n >= 1; n--)\n                s.pqdownheap(tree, n);\n                        \n            // Construct the Huffman tree by repeatedly combining the least two\n            // frequent nodes.\n                        \n            node = elems; // next internal node of the tree\n            do \n            {\n                // n = node of least frequency\n                n = s.heap[1];\n                s.heap[1] = s.heap[s.heap_len--];\n                s.pqdownheap(tree, 1);\n                m = s.heap[1]; // m = node of next least frequency\n                                \n                s.heap[--s.heap_max] = n; // keep the nodes sorted by frequency\n                s.heap[--s.heap_max] = m;\n                                \n                // Create a new node father of n and m\n                tree[node * 2] = unchecked((short) (tree[n * 2] + tree[m * 2]));\n                s.depth[node] = (sbyte) (System.Math.Max((byte) s.depth[n], (byte) s.depth[m]) + 1);\n                tree[n * 2 + 1] = tree[m * 2 + 1] = (short) node;\n                                \n                // and insert the new node in the heap\n                s.heap[1] = node++;\n                s.pqdownheap(tree, 1);\n            }\n            while (s.heap_len >= 2);\n                        \n            s.heap[--s.heap_max] = s.heap[1];\n                        \n            // At this point, the fields freq and dad are set. We can now\n            // generate the bit lengths.\n                        \n            gen_bitlen(s);\n                        \n            // The field len is now set, we can generate the bit codes\n            gen_codes(tree, max_code, s.bl_count);\n        }\n                \n        // Generate the codes for a given tree and bit counts (which need not be\n        // optimal).\n        // IN assertion: the array bl_count contains the bit length statistics for\n        // the given tree and the field len is set for all tree elements.\n        // OUT assertion: the field code is set for all tree elements of non\n        //     zero code length.\n        internal static void  gen_codes(short[] tree, int max_code, short[] bl_count)\n        {\n            short[] next_code = new short[InternalConstants.MAX_BITS + 1]; // next code value for each bit length\n            short code = 0; // running code value\n            int bits; // bit index\n            int n; // code index\n                        \n            // The distribution counts are first used to generate the code values\n            // without bit reversal.\n            for (bits = 1; bits <= InternalConstants.MAX_BITS; bits++)\n                unchecked {\n                    next_code[bits] = code = (short) ((code + bl_count[bits - 1]) << 1);\n                }\n                        \n            // Check that the bit counts in bl_count are consistent. The last code\n            // must be all ones.\n            //Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,\n            //        \"inconsistent bit counts\");\n            //Tracev((stderr,\"\\ngen_codes: max_code %d \", max_code));\n                        \n            for (n = 0; n <= max_code; n++)\n            {\n                int len = tree[n * 2 + 1];\n                if (len == 0)\n                    continue;\n                // Now reverse the bits\n                tree[n * 2] =  unchecked((short) (bi_reverse(next_code[len]++, len)));\n            }\n        }\n                \n        // Reverse the first len bits of a code, using straightforward code (a faster\n        // method would use a table)\n        // IN assertion: 1 <= len <= 15\n        internal static int bi_reverse(int code, int len)\n        {\n            int res = 0;\n            do \n            {\n                res |= code & 1;\n                code >>= 1; //SharedUtils.URShift(code, 1);\n                res <<= 1;\n            }\n            while (--len > 0);\n            return res >> 1;\n        }\n    }\n}"
  },
  {
    "path": "src/FirebirdSql.Data.External/zlib/Zlib.cs",
    "content": "// Zlib.cs\n// ------------------------------------------------------------------\n//\n// Copyright (c) 2009-2011 Dino Chiesa and Microsoft Corporation.\n// All rights reserved.\n//\n// This code module is part of DotNetZip, a zipfile class library.\n//\n// ------------------------------------------------------------------\n//\n// This code is licensed under the Microsoft Public License.\n// See the file License.txt for the license details.\n// More info on: http://dotnetzip.codeplex.com\n//\n// ------------------------------------------------------------------\n//\n// Last Saved: <2011-August-03 19:52:28>\n//\n// ------------------------------------------------------------------\n//\n// This module defines classes for ZLIB compression and\n// decompression. This code is derived from the jzlib implementation of\n// zlib, but significantly modified.  The object model is not the same,\n// and many of the behaviors are new or different.  Nonetheless, in\n// keeping with the license for jzlib, the copyright to that code is\n// included below.\n//\n// ------------------------------------------------------------------\n//\n// The following notice applies to jzlib:\n//\n// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are met:\n//\n// 1. Redistributions of source code must retain the above copyright notice,\n// this list of conditions and the following disclaimer.\n//\n// 2. Redistributions in binary form must reproduce the above copyright\n// notice, this list of conditions and the following disclaimer in\n// the documentation and/or other materials provided with the distribution.\n//\n// 3. The names of the authors may not be used to endorse or promote products\n// derived from this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,\n// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\n// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,\n// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,\n// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\n// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// -----------------------------------------------------------------------\n//\n// jzlib is based on zlib-1.1.3.\n//\n// The following notice applies to zlib:\n//\n// -----------------------------------------------------------------------\n//\n// Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler\n//\n//   The ZLIB software is provided 'as-is', without any express or implied\n//   warranty.  In no event will the authors be held liable for any damages\n//   arising from the use of this software.\n//\n//   Permission is granted to anyone to use this software for any purpose,\n//   including commercial applications, and to alter it and redistribute it\n//   freely, subject to the following restrictions:\n//\n//   1. The origin of this software must not be misrepresented; you must not\n//      claim that you wrote the original software. If you use this software\n//      in a product, an acknowledgment in the product documentation would be\n//      appreciated but is not required.\n//   2. Altered source versions must be plainly marked as such, and must not be\n//      misrepresented as being the original software.\n//   3. This notice may not be removed or altered from any source distribution.\n//\n//   Jean-loup Gailly jloup@gzip.org\n//   Mark Adler madler@alumni.caltech.edu\n//\n// -----------------------------------------------------------------------\n\n\n\nusing System;\nusing Interop=System.Runtime.InteropServices;\n\nnamespace Ionic.Zlib\n{\n\n\t/// <summary>\n\t/// Describes how to flush the current deflate operation.\n\t/// </summary>\n\t/// <remarks>\n\t/// The different FlushType values are useful when using a Deflate in a streaming application.\n\t/// </remarks>\n\tinternal enum FlushType\n    {\n        /// <summary>No flush at all.</summary>\n        None = 0,\n\n        /// <summary>Closes the current block, but doesn't flush it to\n        /// the output. Used internally only in hypothetical\n        /// scenarios.  This was supposed to be removed by Zlib, but it is\n        /// still in use in some edge cases.\n        /// </summary>\n        Partial,\n\n        /// <summary>\n        /// Use this during compression to specify that all pending output should be\n        /// flushed to the output buffer and the output should be aligned on a byte\n        /// boundary.  You might use this in a streaming communication scenario, so that\n        /// the decompressor can get all input data available so far.  When using this\n        /// with a ZlibCodec, <c>AvailableBytesIn</c> will be zero after the call if\n        /// enough output space has been provided before the call.  Flushing will\n        /// degrade compression and so it should be used only when necessary.\n        /// </summary>\n        Sync,\n\n        /// <summary>\n        /// Use this during compression to specify that all output should be flushed, as\n        /// with <c>FlushType.Sync</c>, but also, the compression state should be reset\n        /// so that decompression can restart from this point if previous compressed\n        /// data has been damaged or if random access is desired.  Using\n        /// <c>FlushType.Full</c> too often can significantly degrade the compression.\n        /// </summary>\n        Full,\n\n        /// <summary>Signals the end of the compression/decompression stream.</summary>\n        Finish,\n    }\n\n\n\t/// <summary>\n\t/// The compression level to be used when using a DeflateStream or ZlibStream with CompressionMode.Compress.\n\t/// </summary>\n\tinternal enum CompressionLevel\n    {\n        /// <summary>\n        /// None means that the data will be simply stored, with no change at all.\n        /// If you are producing ZIPs for use on Mac OSX, be aware that archives produced with CompressionLevel.None\n        /// cannot be opened with the default zip reader. Use a different CompressionLevel.\n        /// </summary>\n        None= 0,\n        /// <summary>\n        /// Same as None.\n        /// </summary>\n        Level0 = 0,\n\n        /// <summary>\n        /// The fastest but least effective compression.\n        /// </summary>\n        BestSpeed = 1,\n\n        /// <summary>\n        /// A synonym for BestSpeed.\n        /// </summary>\n        Level1 = 1,\n\n        /// <summary>\n        /// A little slower, but better, than level 1.\n        /// </summary>\n        Level2 = 2,\n\n        /// <summary>\n        /// A little slower, but better, than level 2.\n        /// </summary>\n        Level3 = 3,\n\n        /// <summary>\n        /// A little slower, but better, than level 3.\n        /// </summary>\n        Level4 = 4,\n\n        /// <summary>\n        /// A little slower than level 4, but with better compression.\n        /// </summary>\n        Level5 = 5,\n\n        /// <summary>\n        /// The default compression level, with a good balance of speed and compression efficiency.\n        /// </summary>\n        Default = 6,\n        /// <summary>\n        /// A synonym for Default.\n        /// </summary>\n        Level6 = 6,\n\n        /// <summary>\n        /// Pretty good compression!\n        /// </summary>\n        Level7 = 7,\n\n        /// <summary>\n        ///  Better compression than Level7!\n        /// </summary>\n        Level8 = 8,\n\n        /// <summary>\n        /// The \"best\" compression, where best means greatest reduction in size of the input data stream.\n        /// This is also the slowest compression.\n        /// </summary>\n        BestCompression = 9,\n\n        /// <summary>\n        /// A synonym for BestCompression.\n        /// </summary>\n        Level9 = 9,\n    }\n\n\t/// <summary>\n\t/// Describes options for how the compression algorithm is executed.  Different strategies\n\t/// work better on different sorts of data.  The strategy parameter can affect the compression\n\t/// ratio and the speed of compression but not the correctness of the compresssion.\n\t/// </summary>\n\tinternal enum CompressionStrategy\n    {\n        /// <summary>\n        /// The default strategy is probably the best for normal data.\n        /// </summary>\n        Default = 0,\n\n        /// <summary>\n        /// The <c>Filtered</c> strategy is intended to be used most effectively with data produced by a\n        /// filter or predictor.  By this definition, filtered data consists mostly of small\n        /// values with a somewhat random distribution.  In this case, the compression algorithm\n        /// is tuned to compress them better.  The effect of <c>Filtered</c> is to force more Huffman\n        /// coding and less string matching; it is a half-step between <c>Default</c> and <c>HuffmanOnly</c>.\n        /// </summary>\n        Filtered = 1,\n\n        /// <summary>\n        /// Using <c>HuffmanOnly</c> will force the compressor to do Huffman encoding only, with no\n        /// string matching.\n        /// </summary>\n        HuffmanOnly = 2,\n    }\n\n\n\t/// <summary>\n\t/// An enum to specify the direction of transcoding - whether to compress or decompress.\n\t/// </summary>\n\tinternal enum CompressionMode\n    {\n        /// <summary>\n        /// Used to specify that the stream should compress the data.\n        /// </summary>\n        Compress= 0,\n        /// <summary>\n        /// Used to specify that the stream should decompress the data.\n        /// </summary>\n        Decompress = 1,\n    }\n\n\n    /// <summary>\n    /// A general purpose exception class for exceptions in the Zlib library.\n    /// </summary>\n    [Interop.GuidAttribute(\"ebc25cf6-9120-4283-b972-0e5520d0000E\")]\n\tinternal class ZlibException : System.Exception\n    {\n        /// <summary>\n        /// The ZlibException class captures exception information generated\n        /// by the Zlib library.\n        /// </summary>\n        public ZlibException()\n            : base()\n        {\n        }\n\n        /// <summary>\n        /// This ctor collects a message attached to the exception.\n        /// </summary>\n        /// <param name=\"s\">the message for the exception.</param>\n        public ZlibException(System.String s)\n            : base(s)\n        {\n        }\n    }\n\n\n    internal class SharedUtils\n    {\n        /// <summary>\n        /// Performs an unsigned bitwise right shift with the specified number\n        /// </summary>\n        /// <param name=\"number\">Number to operate on</param>\n        /// <param name=\"bits\">Ammount of bits to shift</param>\n        /// <returns>The resulting number from the shift operation</returns>\n        public static int URShift(int number, int bits)\n        {\n            return (int)((uint)number >> bits);\n        }\n\n#if NOT\n        /// <summary>\n        /// Performs an unsigned bitwise right shift with the specified number\n        /// </summary>\n        /// <param name=\"number\">Number to operate on</param>\n        /// <param name=\"bits\">Ammount of bits to shift</param>\n        /// <returns>The resulting number from the shift operation</returns>\n        public static long URShift(long number, int bits)\n        {\n            return (long) ((UInt64)number >> bits);\n        }\n#endif\n\n        /// <summary>\n        ///   Reads a number of characters from the current source TextReader and writes\n        ///   the data to the target array at the specified index.\n        /// </summary>\n        ///\n        /// <param name=\"sourceTextReader\">The source TextReader to read from</param>\n        /// <param name=\"target\">Contains the array of characteres read from the source TextReader.</param>\n        /// <param name=\"start\">The starting index of the target array.</param>\n        /// <param name=\"count\">The maximum number of characters to read from the source TextReader.</param>\n        ///\n        /// <returns>\n        ///   The number of characters read. The number will be less than or equal to\n        ///   count depending on the data available in the source TextReader. Returns -1\n        ///   if the end of the stream is reached.\n        /// </returns>\n        public static System.Int32 ReadInput(System.IO.TextReader sourceTextReader, byte[] target, int start, int count)\n        {\n            // Returns 0 bytes if not enough space in target\n            if (target.Length == 0) return 0;\n\n            char[] charArray = new char[target.Length];\n            int bytesRead = sourceTextReader.Read(charArray, start, count);\n\n            // Returns -1 if EOF\n            if (bytesRead == 0) return -1;\n\n            for (int index = start; index < start + bytesRead; index++)\n                target[index] = (byte)charArray[index];\n\n            return bytesRead;\n        }\n\n\n        internal static byte[] ToByteArray(System.String sourceString)\n        {\n            return System.Text.UTF8Encoding.UTF8.GetBytes(sourceString);\n        }\n\n\n        internal static char[] ToCharArray(byte[] byteArray)\n        {\n            return System.Text.UTF8Encoding.UTF8.GetChars(byteArray);\n        }\n    }\n\n    internal static class InternalConstants\n    {\n        internal static readonly int MAX_BITS     = 15;\n        internal static readonly int BL_CODES     = 19;\n        internal static readonly int D_CODES      = 30;\n        internal static readonly int LITERALS     = 256;\n        internal static readonly int LENGTH_CODES = 29;\n        internal static readonly int L_CODES      = (LITERALS + 1 + LENGTH_CODES);\n\n        // Bit length codes must not exceed MAX_BL_BITS bits\n        internal static readonly int MAX_BL_BITS  = 7;\n\n        // repeat previous bit length 3-6 times (2 bits of repeat count)\n        internal static readonly int REP_3_6      = 16;\n\n        // repeat a zero length 3-10 times  (3 bits of repeat count)\n        internal static readonly int REPZ_3_10    = 17;\n\n        // repeat a zero length 11-138 times  (7 bits of repeat count)\n        internal static readonly int REPZ_11_138  = 18;\n\n    }\n\n    internal sealed class StaticTree\n    {\n        internal static readonly short[] lengthAndLiteralsTreeCodes = new short[] {\n            12, 8, 140, 8, 76, 8, 204, 8, 44, 8, 172, 8, 108, 8, 236, 8,\n            28, 8, 156, 8, 92, 8, 220, 8, 60, 8, 188, 8, 124, 8, 252, 8,\n             2, 8, 130, 8, 66, 8, 194, 8, 34, 8, 162, 8, 98, 8, 226, 8,\n            18, 8, 146, 8, 82, 8, 210, 8, 50, 8, 178, 8, 114, 8, 242, 8,\n            10, 8, 138, 8, 74, 8, 202, 8, 42, 8, 170, 8, 106, 8, 234, 8,\n            26, 8, 154, 8, 90, 8, 218, 8, 58, 8, 186, 8, 122, 8, 250, 8,\n             6, 8, 134, 8, 70, 8, 198, 8, 38, 8, 166, 8, 102, 8, 230, 8,\n            22, 8, 150, 8, 86, 8, 214, 8, 54, 8, 182, 8, 118, 8, 246, 8,\n            14, 8, 142, 8, 78, 8, 206, 8, 46, 8, 174, 8, 110, 8, 238, 8,\n            30, 8, 158, 8, 94, 8, 222, 8, 62, 8, 190, 8, 126, 8, 254, 8,\n             1, 8, 129, 8, 65, 8, 193, 8, 33, 8, 161, 8, 97, 8, 225, 8,\n            17, 8, 145, 8, 81, 8, 209, 8, 49, 8, 177, 8, 113, 8, 241, 8,\n             9, 8, 137, 8, 73, 8, 201, 8, 41, 8, 169, 8, 105, 8, 233, 8,\n            25, 8, 153, 8, 89, 8, 217, 8, 57, 8, 185, 8, 121, 8, 249, 8,\n             5, 8, 133, 8, 69, 8, 197, 8, 37, 8, 165, 8, 101, 8, 229, 8,\n            21, 8, 149, 8, 85, 8, 213, 8, 53, 8, 181, 8, 117, 8, 245, 8,\n            13, 8, 141, 8, 77, 8, 205, 8, 45, 8, 173, 8, 109, 8, 237, 8,\n            29, 8, 157, 8, 93, 8, 221, 8, 61, 8, 189, 8, 125, 8, 253, 8,\n            19, 9, 275, 9, 147, 9, 403, 9, 83, 9, 339, 9, 211, 9, 467, 9,\n            51, 9, 307, 9, 179, 9, 435, 9, 115, 9, 371, 9, 243, 9, 499, 9,\n            11, 9, 267, 9, 139, 9, 395, 9, 75, 9, 331, 9, 203, 9, 459, 9,\n            43, 9, 299, 9, 171, 9, 427, 9, 107, 9, 363, 9, 235, 9, 491, 9,\n            27, 9, 283, 9, 155, 9, 411, 9, 91, 9, 347, 9, 219, 9, 475, 9,\n            59, 9, 315, 9, 187, 9, 443, 9, 123, 9, 379, 9, 251, 9, 507, 9,\n             7, 9, 263, 9, 135, 9, 391, 9, 71, 9, 327, 9, 199, 9, 455, 9,\n            39, 9, 295, 9, 167, 9, 423, 9, 103, 9, 359, 9, 231, 9, 487, 9,\n            23, 9, 279, 9, 151, 9, 407, 9, 87, 9, 343, 9, 215, 9, 471, 9,\n            55, 9, 311, 9, 183, 9, 439, 9, 119, 9, 375, 9, 247, 9, 503, 9,\n            15, 9, 271, 9, 143, 9, 399, 9, 79, 9, 335, 9, 207, 9, 463, 9,\n            47, 9, 303, 9, 175, 9, 431, 9, 111, 9, 367, 9, 239, 9, 495, 9,\n            31, 9, 287, 9, 159, 9, 415, 9, 95, 9, 351, 9, 223, 9, 479, 9,\n            63, 9, 319, 9, 191, 9, 447, 9, 127, 9, 383, 9, 255, 9, 511, 9,\n             0, 7, 64, 7, 32, 7, 96, 7, 16, 7, 80, 7, 48, 7, 112, 7,\n             8, 7, 72, 7, 40, 7, 104, 7, 24, 7, 88, 7, 56, 7, 120, 7,\n             4, 7, 68, 7, 36, 7, 100, 7, 20, 7, 84, 7, 52, 7, 116, 7,\n             3, 8, 131, 8, 67, 8, 195, 8, 35, 8, 163, 8, 99, 8, 227, 8\n        };\n\n        internal static readonly short[] distTreeCodes = new short[] {\n            0, 5, 16, 5, 8, 5, 24, 5, 4, 5, 20, 5, 12, 5, 28, 5,\n            2, 5, 18, 5, 10, 5, 26, 5, 6, 5, 22, 5, 14, 5, 30, 5,\n            1, 5, 17, 5, 9, 5, 25, 5, 5, 5, 21, 5, 13, 5, 29, 5,\n            3, 5, 19, 5, 11, 5, 27, 5, 7, 5, 23, 5 };\n\n        internal static readonly StaticTree Literals;\n        internal static readonly StaticTree Distances;\n        internal static readonly StaticTree BitLengths;\n\n        internal short[] treeCodes; // static tree or null\n        internal int[] extraBits;   // extra bits for each code or null\n        internal int extraBase;     // base index for extra_bits\n        internal int elems;         // max number of elements in the tree\n        internal int maxLength;     // max bit length for the codes\n\n        private StaticTree(short[] treeCodes, int[] extraBits, int extraBase, int elems, int maxLength)\n        {\n            this.treeCodes = treeCodes;\n            this.extraBits = extraBits;\n            this.extraBase = extraBase;\n            this.elems = elems;\n            this.maxLength = maxLength;\n        }\n        static StaticTree()\n        {\n            Literals = new StaticTree(lengthAndLiteralsTreeCodes, Tree.ExtraLengthBits, InternalConstants.LITERALS + 1, InternalConstants.L_CODES, InternalConstants.MAX_BITS);\n            Distances = new StaticTree(distTreeCodes, Tree.ExtraDistanceBits, 0, InternalConstants.D_CODES, InternalConstants.MAX_BITS);\n            BitLengths = new StaticTree(null, Tree.extra_blbits, 0, InternalConstants.BL_CODES, InternalConstants.MAX_BL_BITS);\n        }\n    }\n\n\n\n\t/// <summary>\n\t/// Computes an Adler-32 checksum.\n\t/// </summary>\n\t/// <remarks>\n\t/// The Adler checksum is similar to a CRC checksum, but faster to compute, though less\n\t/// reliable.  It is used in producing RFC1950 compressed streams.  The Adler checksum\n\t/// is a required part of the \"ZLIB\" standard.  Applications will almost never need to\n\t/// use this class directly.\n\t/// </remarks>\n\t///\n\t/// <exclude/>\n\tinternal sealed class Adler\n    {\n        // largest prime smaller than 65536\n        private static readonly uint BASE = 65521;\n        // NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1\n        private static readonly int NMAX = 5552;\n\n\n#pragma warning disable 3001\n#pragma warning disable 3002\n\n        /// <summary>\n        ///   Calculates the Adler32 checksum.\n        /// </summary>\n        /// <remarks>\n        ///   <para>\n        ///     This is used within ZLIB.  You probably don't need to use this directly.\n        ///   </para>\n        /// </remarks>\n        /// <example>\n        ///    To compute an Adler32 checksum on a byte array:\n        ///  <code>\n        ///    var adler = Adler.Adler32(0, null, 0, 0);\n        ///    adler = Adler.Adler32(adler, buffer, index, length);\n        ///  </code>\n        /// </example>\n        public static uint Adler32(uint adler, byte[] buf, int index, int len)\n        {\n            if (buf == null)\n                return 1;\n\n            uint s1 = (uint) (adler & 0xffff);\n            uint s2 = (uint) ((adler >> 16) & 0xffff);\n\n            while (len > 0)\n            {\n                int k = len < NMAX ? len : NMAX;\n                len -= k;\n                while (k >= 16)\n                {\n                    //s1 += (buf[index++] & 0xff); s2 += s1;\n                    s1 += buf[index++]; s2 += s1;\n                    s1 += buf[index++]; s2 += s1;\n                    s1 += buf[index++]; s2 += s1;\n                    s1 += buf[index++]; s2 += s1;\n                    s1 += buf[index++]; s2 += s1;\n                    s1 += buf[index++]; s2 += s1;\n                    s1 += buf[index++]; s2 += s1;\n                    s1 += buf[index++]; s2 += s1;\n                    s1 += buf[index++]; s2 += s1;\n                    s1 += buf[index++]; s2 += s1;\n                    s1 += buf[index++]; s2 += s1;\n                    s1 += buf[index++]; s2 += s1;\n                    s1 += buf[index++]; s2 += s1;\n                    s1 += buf[index++]; s2 += s1;\n                    s1 += buf[index++]; s2 += s1;\n                    s1 += buf[index++]; s2 += s1;\n                    k -= 16;\n                }\n                if (k != 0)\n                {\n                    do\n                    {\n                        s1 += buf[index++];\n                        s2 += s1;\n                    }\n                    while (--k != 0);\n                }\n                s1 %= BASE;\n                s2 %= BASE;\n            }\n            return (uint)((s2 << 16) | s1);\n        }\n#pragma warning restore 3001\n#pragma warning restore 3002\n\n    }\n\n}"
  },
  {
    "path": "src/FirebirdSql.Data.External/zlib/ZlibCodec.cs",
    "content": "// ZlibCodec.cs\n// ------------------------------------------------------------------\n//\n// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.  \n// All rights reserved.\n//\n// This code module is part of DotNetZip, a zipfile class library.\n//\n// ------------------------------------------------------------------\n//\n// This code is licensed under the Microsoft Public License. \n// See the file License.txt for the license details.\n// More info on: http://dotnetzip.codeplex.com\n//\n// ------------------------------------------------------------------\n//\n// last saved (in emacs): \n// Time-stamp: <2009-November-03 15:40:51>\n//\n// ------------------------------------------------------------------\n//\n// This module defines a Codec for ZLIB compression and\n// decompression. This code extends code that was based the jzlib\n// implementation of zlib, but this code is completely novel.  The codec\n// class is new, and encapsulates some behaviors that are new, and some\n// that were present in other classes in the jzlib code base.  In\n// keeping with the license for jzlib, the copyright to the jzlib code\n// is included below.\n//\n// ------------------------------------------------------------------\n// \n// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.\n// \n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are met:\n// \n// 1. Redistributions of source code must retain the above copyright notice,\n// this list of conditions and the following disclaimer.\n// \n// 2. Redistributions in binary form must reproduce the above copyright \n// notice, this list of conditions and the following disclaimer in \n// the documentation and/or other materials provided with the distribution.\n// \n// 3. The names of the authors may not be used to endorse or promote products\n// derived from this software without specific prior written permission.\n// \n// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,\n// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\n// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,\n// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,\n// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\n// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n// \n// -----------------------------------------------------------------------\n//\n// This program is based on zlib-1.1.3; credit to authors\n// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)\n// and contributors of zlib.\n//\n// -----------------------------------------------------------------------\n\n\nusing System;\nusing Interop=System.Runtime.InteropServices;\n\nnamespace Ionic.Zlib\n{\n    /// <summary>\n    /// Encoder and Decoder for ZLIB and DEFLATE (IETF RFC1950 and RFC1951).\n    /// </summary>\n    ///\n    /// <remarks>\n    /// This class compresses and decompresses data according to the Deflate algorithm\n    /// and optionally, the ZLIB format, as documented in <see\n    /// href=\"http://www.ietf.org/rfc/rfc1950.txt\">RFC 1950 - ZLIB</see> and <see\n    /// href=\"http://www.ietf.org/rfc/rfc1951.txt\">RFC 1951 - DEFLATE</see>.\n    /// </remarks>\n    [Interop.GuidAttribute(\"ebc25cf6-9120-4283-b972-0e5520d0000D\")]\n    [Interop.ComVisible(true)]\n#if !NETCF    \n    //[Interop.ClassInterface(Interop.ClassInterfaceType.AutoDispatch)]\n#endif\n    sealed internal class ZlibCodec\n    {\n        /// <summary>\n        /// The buffer from which data is taken.\n        /// </summary>\n        public byte[] InputBuffer;\n\n        /// <summary>\n        /// An index into the InputBuffer array, indicating where to start reading. \n        /// </summary>\n        public int NextIn;\n\n        /// <summary>\n        /// The number of bytes available in the InputBuffer, starting at NextIn. \n        /// </summary>\n        /// <remarks>\n        /// Generally you should set this to InputBuffer.Length before the first Inflate() or Deflate() call. \n        /// The class will update this number as calls to Inflate/Deflate are made.\n        /// </remarks>\n        public int AvailableBytesIn;\n\n        /// <summary>\n        /// Total number of bytes read so far, through all calls to Inflate()/Deflate().\n        /// </summary>\n        public long TotalBytesIn;\n\n        /// <summary>\n        /// Buffer to store output data.\n        /// </summary>\n        public byte[] OutputBuffer;\n\n        /// <summary>\n        /// An index into the OutputBuffer array, indicating where to start writing. \n        /// </summary>\n        public int NextOut;\n\n        /// <summary>\n        /// The number of bytes available in the OutputBuffer, starting at NextOut. \n        /// </summary>\n        /// <remarks>\n        /// Generally you should set this to OutputBuffer.Length before the first Inflate() or Deflate() call. \n        /// The class will update this number as calls to Inflate/Deflate are made.\n        /// </remarks>\n        public int AvailableBytesOut;\n\n        /// <summary>\n        /// Total number of bytes written to the output so far, through all calls to Inflate()/Deflate().\n        /// </summary>\n        public long TotalBytesOut;\n\n        /// <summary>\n        /// used for diagnostics, when something goes wrong!\n        /// </summary>\n        public System.String Message;\n\n        internal DeflateManager dstate;\n        internal InflateManager istate;\n\n        internal uint _Adler32;\n\n        /// <summary>\n        /// The compression level to use in this codec.  Useful only in compression mode.\n        /// </summary>\n        public CompressionLevel CompressLevel = CompressionLevel.Default;\n\n        /// <summary>\n        /// The number of Window Bits to use.  \n        /// </summary>\n        /// <remarks>\n        /// This gauges the size of the sliding window, and hence the \n        /// compression effectiveness as well as memory consumption. It's best to just leave this \n        /// setting alone if you don't know what it is.  The maximum value is 15 bits, which implies\n        /// a 32k window.  \n        /// </remarks>\n        public int WindowBits = ZlibConstants.WindowBitsDefault;\n\n        /// <summary>\n        /// The compression strategy to use.\n        /// </summary>\n        /// <remarks>\n        /// This is only effective in compression.  The theory offered by ZLIB is that different\n        /// strategies could potentially produce significant differences in compression behavior\n        /// for different data sets.  Unfortunately I don't have any good recommendations for how\n        /// to set it differently.  When I tested changing the strategy I got minimally different\n        /// compression performance. It's best to leave this property alone if you don't have a\n        /// good feel for it.  Or, you may want to produce a test harness that runs through the\n        /// different strategy options and evaluates them on different file types. If you do that,\n        /// let me know your results.\n        /// </remarks>\n        public CompressionStrategy Strategy = CompressionStrategy.Default;\n\n\n        /// <summary>\n        /// The Adler32 checksum on the data transferred through the codec so far. You probably don't need to look at this.\n        /// </summary>\n        public int Adler32 { get { return (int)_Adler32; } }\n\n\n        /// <summary>\n        /// Create a ZlibCodec.\n        /// </summary>\n        /// <remarks>\n        /// If you use this default constructor, you will later have to explicitly call \n        /// InitializeInflate() or InitializeDeflate() before using the ZlibCodec to compress \n        /// or decompress. \n        /// </remarks>\n        public ZlibCodec() { }\n\n        /// <summary>\n        /// Create a ZlibCodec that either compresses or decompresses.\n        /// </summary>\n        /// <param name=\"mode\">\n        /// Indicates whether the codec should compress (deflate) or decompress (inflate).\n        /// </param>\n        public ZlibCodec(CompressionMode mode)\n        {\n            if (mode == CompressionMode.Compress)\n            {\n                int rc = InitializeDeflate();\n                if (rc != ZlibConstants.Z_OK) throw new ZlibException(\"Cannot initialize for deflate.\");\n            }\n            else if (mode == CompressionMode.Decompress)\n            {\n                int rc = InitializeInflate();\n                if (rc != ZlibConstants.Z_OK) throw new ZlibException(\"Cannot initialize for inflate.\");\n            }\n            else throw new ZlibException(\"Invalid ZlibStreamFlavor.\");\n        }\n\n        /// <summary>\n        /// Initialize the inflation state. \n        /// </summary>\n        /// <remarks>\n        /// It is not necessary to call this before using the ZlibCodec to inflate data; \n        /// It is implicitly called when you call the constructor.\n        /// </remarks>\n        /// <returns>Z_OK if everything goes well.</returns>\n        public int InitializeInflate()\n        {\n            return InitializeInflate(this.WindowBits);\n        }\n\n        /// <summary>\n        /// Initialize the inflation state with an explicit flag to\n        /// govern the handling of RFC1950 header bytes.\n        /// </summary>\n        ///\n        /// <remarks>\n        /// By default, the ZLIB header defined in <see\n        /// href=\"http://www.ietf.org/rfc/rfc1950.txt\">RFC 1950</see> is expected.  If\n        /// you want to read a zlib stream you should specify true for\n        /// expectRfc1950Header.  If you have a deflate stream, you will want to specify\n        /// false. It is only necessary to invoke this initializer explicitly if you\n        /// want to specify false.\n        /// </remarks>\n        ///\n        /// <param name=\"expectRfc1950Header\">whether to expect an RFC1950 header byte\n        /// pair when reading the stream of data to be inflated.</param>\n        ///\n        /// <returns>Z_OK if everything goes well.</returns>\n        public int InitializeInflate(bool expectRfc1950Header)\n        {\n            return InitializeInflate(this.WindowBits, expectRfc1950Header);\n        }\n\n        /// <summary>\n        /// Initialize the ZlibCodec for inflation, with the specified number of window bits. \n        /// </summary>\n        /// <param name=\"windowBits\">The number of window bits to use. If you need to ask what that is, \n        /// then you shouldn't be calling this initializer.</param>\n        /// <returns>Z_OK if all goes well.</returns>\n        public int InitializeInflate(int windowBits)\n        {\n            this.WindowBits = windowBits;            \n            return InitializeInflate(windowBits, true);\n        }\n\n        /// <summary>\n        /// Initialize the inflation state with an explicit flag to govern the handling of\n        /// RFC1950 header bytes. \n        /// </summary>\n        ///\n        /// <remarks>\n        /// If you want to read a zlib stream you should specify true for\n        /// expectRfc1950Header. In this case, the library will expect to find a ZLIB\n        /// header, as defined in <see href=\"http://www.ietf.org/rfc/rfc1950.txt\">RFC\n        /// 1950</see>, in the compressed stream.  If you will be reading a DEFLATE or\n        /// GZIP stream, which does not have such a header, you will want to specify\n        /// false.\n        /// </remarks>\n        ///\n        /// <param name=\"expectRfc1950Header\">whether to expect an RFC1950 header byte pair when reading \n        /// the stream of data to be inflated.</param>\n        /// <param name=\"windowBits\">The number of window bits to use. If you need to ask what that is, \n        /// then you shouldn't be calling this initializer.</param>\n        /// <returns>Z_OK if everything goes well.</returns>\n        public int InitializeInflate(int windowBits, bool expectRfc1950Header)\n        {\n            this.WindowBits = windowBits;\n            if (dstate != null) throw new ZlibException(\"You may not call InitializeInflate() after calling InitializeDeflate().\");\n            istate = new InflateManager(expectRfc1950Header);\n            return istate.Initialize(this, windowBits);\n        }\n\n        /// <summary>\n        /// Inflate the data in the InputBuffer, placing the result in the OutputBuffer.\n        /// </summary>\n        /// <remarks>\n        /// You must have set InputBuffer and OutputBuffer, NextIn and NextOut, and AvailableBytesIn and \n        /// AvailableBytesOut  before calling this method.\n        /// </remarks>\n        /// <example>\n        /// <code>\n        /// private void InflateBuffer()\n        /// {\n        ///     int bufferSize = 1024;\n        ///     byte[] buffer = new byte[bufferSize];\n        ///     ZlibCodec decompressor = new ZlibCodec();\n        /// \n        ///     Console.WriteLine(\"\\n============================================\");\n        ///     Console.WriteLine(\"Size of Buffer to Inflate: {0} bytes.\", CompressedBytes.Length);\n        ///     MemoryStream ms = new MemoryStream(DecompressedBytes);\n        /// \n        ///     int rc = decompressor.InitializeInflate();\n        /// \n        ///     decompressor.InputBuffer = CompressedBytes;\n        ///     decompressor.NextIn = 0;\n        ///     decompressor.AvailableBytesIn = CompressedBytes.Length;\n        /// \n        ///     decompressor.OutputBuffer = buffer;\n        /// \n        ///     // pass 1: inflate \n        ///     do\n        ///     {\n        ///         decompressor.NextOut = 0;\n        ///         decompressor.AvailableBytesOut = buffer.Length;\n        ///         rc = decompressor.Inflate(FlushType.None);\n        /// \n        ///         if (rc != ZlibConstants.Z_OK &amp;&amp; rc != ZlibConstants.Z_STREAM_END)\n        ///             throw new Exception(\"inflating: \" + decompressor.Message);\n        /// \n        ///         ms.Write(decompressor.OutputBuffer, 0, buffer.Length - decompressor.AvailableBytesOut);\n        ///     }\n        ///     while (decompressor.AvailableBytesIn &gt; 0 || decompressor.AvailableBytesOut == 0);\n        /// \n        ///     // pass 2: finish and flush\n        ///     do\n        ///     {\n        ///         decompressor.NextOut = 0;\n        ///         decompressor.AvailableBytesOut = buffer.Length;\n        ///         rc = decompressor.Inflate(FlushType.Finish);\n        /// \n        ///         if (rc != ZlibConstants.Z_STREAM_END &amp;&amp; rc != ZlibConstants.Z_OK)\n        ///             throw new Exception(\"inflating: \" + decompressor.Message);\n        /// \n        ///         if (buffer.Length - decompressor.AvailableBytesOut &gt; 0)\n        ///             ms.Write(buffer, 0, buffer.Length - decompressor.AvailableBytesOut);\n        ///     }\n        ///     while (decompressor.AvailableBytesIn &gt; 0 || decompressor.AvailableBytesOut == 0);\n        /// \n        ///     decompressor.EndInflate();\n        /// }\n        ///\n        /// </code>\n        /// </example>\n        /// <param name=\"flush\">The flush to use when inflating.</param>\n        /// <returns>Z_OK if everything goes well.</returns>\n        public int Inflate(FlushType flush)\n        {\n            if (istate == null)\n                throw new ZlibException(\"No Inflate State!\");\n            return istate.Inflate(flush);\n        }\n\n\n        /// <summary>\n        /// Ends an inflation session. \n        /// </summary>\n        /// <remarks>\n        /// Call this after successively calling Inflate().  This will cause all buffers to be flushed. \n        /// After calling this you cannot call Inflate() without a intervening call to one of the\n        /// InitializeInflate() overloads.\n        /// </remarks>\n        /// <returns>Z_OK if everything goes well.</returns>\n        public int EndInflate()\n        {\n            if (istate == null)\n                throw new ZlibException(\"No Inflate State!\");\n            int ret = istate.End();\n            istate = null;\n            return ret;\n        }\n\n        /// <summary>\n        /// I don't know what this does!\n        /// </summary>\n        /// <returns>Z_OK if everything goes well.</returns>\n        public int SyncInflate()\n        {\n            if (istate == null)\n                throw new ZlibException(\"No Inflate State!\");\n            return istate.Sync();\n        }\n\n        /// <summary>\n        /// Initialize the ZlibCodec for deflation operation.\n        /// </summary>\n        /// <remarks>\n        /// The codec will use the MAX window bits and the default level of compression.\n        /// </remarks>\n        /// <example>\n        /// <code>\n        ///  int bufferSize = 40000;\n        ///  byte[] CompressedBytes = new byte[bufferSize];\n        ///  byte[] DecompressedBytes = new byte[bufferSize];\n        ///  \n        ///  ZlibCodec compressor = new ZlibCodec();\n        ///  \n        ///  compressor.InitializeDeflate(CompressionLevel.Default);\n        ///  \n        ///  compressor.InputBuffer = System.Text.ASCIIEncoding.ASCII.GetBytes(TextToCompress);\n        ///  compressor.NextIn = 0;\n        ///  compressor.AvailableBytesIn = compressor.InputBuffer.Length;\n        ///  \n        ///  compressor.OutputBuffer = CompressedBytes;\n        ///  compressor.NextOut = 0;\n        ///  compressor.AvailableBytesOut = CompressedBytes.Length;\n        ///  \n        ///  while (compressor.TotalBytesIn != TextToCompress.Length &amp;&amp; compressor.TotalBytesOut &lt; bufferSize)\n        ///  {\n        ///    compressor.Deflate(FlushType.None);\n        ///  }\n        ///  \n        ///  while (true)\n        ///  {\n        ///    int rc= compressor.Deflate(FlushType.Finish);\n        ///    if (rc == ZlibConstants.Z_STREAM_END) break;\n        ///  }\n        ///  \n        ///  compressor.EndDeflate();\n        ///   \n        /// </code>\n        /// </example>\n        /// <returns>Z_OK if all goes well. You generally don't need to check the return code.</returns>\n        public int InitializeDeflate()\n        {\n            return _InternalInitializeDeflate(true);\n        }\n\n        /// <summary>\n        /// Initialize the ZlibCodec for deflation operation, using the specified CompressionLevel.\n        /// </summary>\n        /// <remarks>\n        /// The codec will use the maximum window bits (15) and the specified\n        /// CompressionLevel.  It will emit a ZLIB stream as it compresses.\n        /// </remarks>\n        /// <param name=\"level\">The compression level for the codec.</param>\n        /// <returns>Z_OK if all goes well.</returns>\n        public int InitializeDeflate(CompressionLevel level)\n        {\n            this.CompressLevel = level;\n            return _InternalInitializeDeflate(true);\n        }\n\n\n        /// <summary>\n        /// Initialize the ZlibCodec for deflation operation, using the specified CompressionLevel, \n        /// and the explicit flag governing whether to emit an RFC1950 header byte pair.\n        /// </summary>\n        /// <remarks>\n        /// The codec will use the maximum window bits (15) and the specified CompressionLevel.\n        /// If you want to generate a zlib stream, you should specify true for\n        /// wantRfc1950Header. In this case, the library will emit a ZLIB\n        /// header, as defined in <see href=\"http://www.ietf.org/rfc/rfc1950.txt\">RFC\n        /// 1950</see>, in the compressed stream.  \n        /// </remarks>\n        /// <param name=\"level\">The compression level for the codec.</param>\n        /// <param name=\"wantRfc1950Header\">whether to emit an initial RFC1950 byte pair in the compressed stream.</param>\n        /// <returns>Z_OK if all goes well.</returns>\n        public int InitializeDeflate(CompressionLevel level, bool wantRfc1950Header)\n        {\n            this.CompressLevel = level;\n            return _InternalInitializeDeflate(wantRfc1950Header);\n        }\n\n\n        /// <summary>\n        /// Initialize the ZlibCodec for deflation operation, using the specified CompressionLevel, \n        /// and the specified number of window bits. \n        /// </summary>\n        /// <remarks>\n        /// The codec will use the specified number of window bits and the specified CompressionLevel.\n        /// </remarks>\n        /// <param name=\"level\">The compression level for the codec.</param>\n        /// <param name=\"bits\">the number of window bits to use.  If you don't know what this means, don't use this method.</param>\n        /// <returns>Z_OK if all goes well.</returns>\n        public int InitializeDeflate(CompressionLevel level, int bits)\n        {\n            this.CompressLevel = level;\n            this.WindowBits = bits;\n            return _InternalInitializeDeflate(true);\n        }\n\n        /// <summary>\n        /// Initialize the ZlibCodec for deflation operation, using the specified\n        /// CompressionLevel, the specified number of window bits, and the explicit flag\n        /// governing whether to emit an RFC1950 header byte pair.\n        /// </summary>\n        ///\n        /// <param name=\"level\">The compression level for the codec.</param>\n        /// <param name=\"wantRfc1950Header\">whether to emit an initial RFC1950 byte pair in the compressed stream.</param>\n        /// <param name=\"bits\">the number of window bits to use.  If you don't know what this means, don't use this method.</param>\n        /// <returns>Z_OK if all goes well.</returns>\n        public int InitializeDeflate(CompressionLevel level, int bits, bool wantRfc1950Header)\n        {\n            this.CompressLevel = level;\n            this.WindowBits = bits;\n            return _InternalInitializeDeflate(wantRfc1950Header);\n        }\n\n        private int _InternalInitializeDeflate(bool wantRfc1950Header)\n        {\n            if (istate != null) throw new ZlibException(\"You may not call InitializeDeflate() after calling InitializeInflate().\");\n            dstate = new DeflateManager();\n            dstate.WantRfc1950HeaderBytes = wantRfc1950Header;\n\n            return dstate.Initialize(this, this.CompressLevel, this.WindowBits, this.Strategy);\n        }\n\n        /// <summary>\n        /// Deflate one batch of data.\n        /// </summary>\n        /// <remarks>\n        /// You must have set InputBuffer and OutputBuffer before calling this method.\n        /// </remarks>\n        /// <example>\n        /// <code>\n        /// private void DeflateBuffer(CompressionLevel level)\n        /// {\n        ///     int bufferSize = 1024;\n        ///     byte[] buffer = new byte[bufferSize];\n        ///     ZlibCodec compressor = new ZlibCodec();\n        /// \n        ///     Console.WriteLine(\"\\n============================================\");\n        ///     Console.WriteLine(\"Size of Buffer to Deflate: {0} bytes.\", UncompressedBytes.Length);\n        ///     MemoryStream ms = new MemoryStream();\n        /// \n        ///     int rc = compressor.InitializeDeflate(level);\n        /// \n        ///     compressor.InputBuffer = UncompressedBytes;\n        ///     compressor.NextIn = 0;\n        ///     compressor.AvailableBytesIn = UncompressedBytes.Length;\n        /// \n        ///     compressor.OutputBuffer = buffer;\n        /// \n        ///     // pass 1: deflate \n        ///     do\n        ///     {\n        ///         compressor.NextOut = 0;\n        ///         compressor.AvailableBytesOut = buffer.Length;\n        ///         rc = compressor.Deflate(FlushType.None);\n        /// \n        ///         if (rc != ZlibConstants.Z_OK &amp;&amp; rc != ZlibConstants.Z_STREAM_END)\n        ///             throw new Exception(\"deflating: \" + compressor.Message);\n        /// \n        ///         ms.Write(compressor.OutputBuffer, 0, buffer.Length - compressor.AvailableBytesOut);\n        ///     }\n        ///     while (compressor.AvailableBytesIn &gt; 0 || compressor.AvailableBytesOut == 0);\n        /// \n        ///     // pass 2: finish and flush\n        ///     do\n        ///     {\n        ///         compressor.NextOut = 0;\n        ///         compressor.AvailableBytesOut = buffer.Length;\n        ///         rc = compressor.Deflate(FlushType.Finish);\n        /// \n        ///         if (rc != ZlibConstants.Z_STREAM_END &amp;&amp; rc != ZlibConstants.Z_OK)\n        ///             throw new Exception(\"deflating: \" + compressor.Message);\n        /// \n        ///         if (buffer.Length - compressor.AvailableBytesOut &gt; 0)\n        ///             ms.Write(buffer, 0, buffer.Length - compressor.AvailableBytesOut);\n        ///     }\n        ///     while (compressor.AvailableBytesIn &gt; 0 || compressor.AvailableBytesOut == 0);\n        /// \n        ///     compressor.EndDeflate();\n        /// \n        ///     ms.Seek(0, SeekOrigin.Begin);\n        ///     CompressedBytes = new byte[compressor.TotalBytesOut];\n        ///     ms.Read(CompressedBytes, 0, CompressedBytes.Length);\n        /// }\n        /// </code>\n        /// </example>\n        /// <param name=\"flush\">whether to flush all data as you deflate. Generally you will want to \n        /// use Z_NO_FLUSH here, in a series of calls to Deflate(), and then call EndDeflate() to \n        /// flush everything. \n        /// </param>\n        /// <returns>Z_OK if all goes well.</returns>\n        public int Deflate(FlushType flush)\n        {\n            if (dstate == null)\n                throw new ZlibException(\"No Deflate State!\");\n            return dstate.Deflate(flush);\n        }\n\n        /// <summary>\n        /// End a deflation session.\n        /// </summary>\n        /// <remarks>\n        /// Call this after making a series of one or more calls to Deflate(). All buffers are flushed.\n        /// </remarks>\n        /// <returns>Z_OK if all goes well.</returns>\n        public int EndDeflate()\n        {\n            if (dstate == null)\n                throw new ZlibException(\"No Deflate State!\");\n            // TODO: dinoch Tue, 03 Nov 2009  15:39 (test this)\n            //int ret = dstate.End();\n            dstate = null;\n            return ZlibConstants.Z_OK; //ret;\n        }\n\n        /// <summary>\n        /// Reset a codec for another deflation session.\n        /// </summary>\n        /// <remarks>\n        /// Call this to reset the deflation state.  For example if a thread is deflating\n        /// non-consecutive blocks, you can call Reset() after the Deflate(Sync) of the first\n        /// block and before the next Deflate(None) of the second block.\n        /// </remarks>\n        /// <returns>Z_OK if all goes well.</returns>\n        public void ResetDeflate()\n        {\n            if (dstate == null)\n                throw new ZlibException(\"No Deflate State!\");\n            dstate.Reset();\n        }\n\n\n        /// <summary>\n        /// Set the CompressionStrategy and CompressionLevel for a deflation session.\n        /// </summary>\n        /// <param name=\"level\">the level of compression to use.</param>\n        /// <param name=\"strategy\">the strategy to use for compression.</param>\n        /// <returns>Z_OK if all goes well.</returns>\n        public int SetDeflateParams(CompressionLevel level, CompressionStrategy strategy)\n        {\n            if (dstate == null)\n                throw new ZlibException(\"No Deflate State!\");\n            return dstate.SetParams(level, strategy);\n        }\n\n\n        /// <summary>\n        /// Set the dictionary to be used for either Inflation or Deflation.\n        /// </summary>\n        /// <param name=\"dictionary\">The dictionary bytes to use.</param>\n        /// <returns>Z_OK if all goes well.</returns>\n        public int SetDictionary(byte[] dictionary)\n        {\n            if (istate != null)\n                return istate.SetDictionary(dictionary);\n\n            if (dstate != null)\n                return dstate.SetDictionary(dictionary);\n\n            throw new ZlibException(\"No Inflate or Deflate state!\");\n        }\n\n        // Flush as much pending output as possible. All deflate() output goes\n        // through this function so some applications may wish to modify it\n        // to avoid allocating a large strm->next_out buffer and copying into it.\n        // (See also read_buf()).\n        internal void flush_pending()\n        {\n            int len = dstate.pendingCount;\n\n            if (len > AvailableBytesOut)\n                len = AvailableBytesOut;\n            if (len == 0)\n                return;\n\n            if (dstate.pending.Length <= dstate.nextPending ||\n                OutputBuffer.Length <= NextOut ||\n                dstate.pending.Length < (dstate.nextPending + len) ||\n                OutputBuffer.Length < (NextOut + len))\n            {\n                throw new ZlibException(String.Format(\"Invalid State. (pending.Length={0}, pendingCount={1})\",\n                    dstate.pending.Length, dstate.pendingCount));\n            }\n\n            Array.Copy(dstate.pending, dstate.nextPending, OutputBuffer, NextOut, len);\n\n            NextOut             += len;\n            dstate.nextPending  += len;\n            TotalBytesOut       += len;\n            AvailableBytesOut   -= len;\n            dstate.pendingCount -= len;\n            if (dstate.pendingCount == 0)\n            {\n                dstate.nextPending = 0;\n            }\n        }\n\n        // Read a new buffer from the current input stream, update the adler32\n        // and total number of bytes read.  All deflate() input goes through\n        // this function so some applications may wish to modify it to avoid\n        // allocating a large strm->next_in buffer and copying from it.\n        // (See also flush_pending()).\n        internal int read_buf(byte[] buf, int start, int size)\n        {\n            int len = AvailableBytesIn;\n\n            if (len > size)\n                len = size;\n            if (len == 0)\n                return 0;\n\n            AvailableBytesIn -= len;\n\n            if (dstate.WantRfc1950HeaderBytes)\n            {\n                _Adler32 = Adler.Adler32(_Adler32, InputBuffer, NextIn, len);\n            }\n            Array.Copy(InputBuffer, NextIn, buf, start, len);\n            NextIn += len;\n            TotalBytesIn += len;\n            return len;\n        }\n\n    }\n}"
  },
  {
    "path": "src/FirebirdSql.Data.External/zlib/ZlibConstants.cs",
    "content": "// ZlibConstants.cs\n// ------------------------------------------------------------------\n//\n// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.  \n// All rights reserved.\n//\n// This code module is part of DotNetZip, a zipfile class library.\n//\n// ------------------------------------------------------------------\n//\n// This code is licensed under the Microsoft Public License. \n// See the file License.txt for the license details.\n// More info on: http://dotnetzip.codeplex.com\n//\n// ------------------------------------------------------------------\n//\n// last saved (in emacs): \n// Time-stamp: <2009-November-03 18:50:19>\n//\n// ------------------------------------------------------------------\n//\n// This module defines constants used by the zlib class library.  This\n// code is derived from the jzlib implementation of zlib, but\n// significantly modified.  In keeping with the license for jzlib, the\n// copyright to that code is included here.\n//\n// ------------------------------------------------------------------\n// \n// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.\n// \n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are met:\n// \n// 1. Redistributions of source code must retain the above copyright notice,\n// this list of conditions and the following disclaimer.\n// \n// 2. Redistributions in binary form must reproduce the above copyright \n// notice, this list of conditions and the following disclaimer in \n// the documentation and/or other materials provided with the distribution.\n// \n// 3. The names of the authors may not be used to endorse or promote products\n// derived from this software without specific prior written permission.\n// \n// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,\n// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\n// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,\n// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,\n// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\n// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n// \n// -----------------------------------------------------------------------\n//\n// This program is based on zlib-1.1.3; credit to authors\n// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)\n// and contributors of zlib.\n//\n// -----------------------------------------------------------------------\n\n\nusing System;\n\nnamespace Ionic.Zlib\n{\n    /// <summary>\n    /// A bunch of constants used in the Zlib interface.\n    /// </summary>\n    internal static class ZlibConstants\n    {\n        /// <summary>\n        /// The maximum number of window bits for the Deflate algorithm.\n        /// </summary>\n        public const int WindowBitsMax = 15; // 32K LZ77 window\n\n        /// <summary>\n        /// The default number of window bits for the Deflate algorithm.\n        /// </summary>\n        public const int WindowBitsDefault = WindowBitsMax;\n\n        /// <summary>\n        /// indicates everything is A-OK\n        /// </summary>\n        public const int Z_OK = 0;\n\n        /// <summary>\n        /// Indicates that the last operation reached the end of the stream.\n        /// </summary>\n        public const int Z_STREAM_END = 1;\n\n        /// <summary>\n        /// The operation ended in need of a dictionary. \n        /// </summary>\n        public const int Z_NEED_DICT = 2;\n\n        /// <summary>\n        /// There was an error with the stream - not enough data, not open and readable, etc.\n        /// </summary>\n        public const int Z_STREAM_ERROR = -2;\n\n        /// <summary>\n        /// There was an error with the data - not enough data, bad data, etc.\n        /// </summary>\n        public const int Z_DATA_ERROR = -3;\n\n        /// <summary>\n        /// There was an error with the working buffer.\n        /// </summary>\n        public const int Z_BUF_ERROR = -5;\n\n        /// <summary>\n        /// The size of the working buffer used in the ZlibCodec class. Defaults to 8192 bytes.\n        /// </summary>\n#if NETCF        \n        public const int WorkingBufferSizeDefault = 8192;\n#else\n        public const int WorkingBufferSizeDefault = 16384; \n#endif\n        /// <summary>\n        /// The minimum size of the working buffer used in the ZlibCodec class.  Currently it is 128 bytes.\n        /// </summary>\n        public const int WorkingBufferSizeMin = 1024;\n    }\n\n}\n\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/ClientFactory.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Client.Managed;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\nusing WireCryptOption = FirebirdSql.Data.Client.Managed.Version13.WireCryptOption;\n\nnamespace FirebirdSql.Data.Client;\n\ninternal static class ClientFactory\n{\n\tpublic static DatabaseBase CreateDatabase(ConnectionString options)\n\t{\n\t\treturn options.ServerType switch\n\t\t{\n\t\t\tFbServerType.Default => CreateManagedDatabase(options),\n\t\t\tFbServerType.Embedded => CreateNativeDatabase(options),\n\t\t\t_ => throw IncorrectServerTypeException(),\n\t\t};\n\t}\n\tpublic static ValueTask<DatabaseBase> CreateDatabaseAsync(ConnectionString options, CancellationToken cancellationToken = default)\n\t{\n\t\treturn options.ServerType switch\n\t\t{\n\t\t\tFbServerType.Default => CreateManagedDatabaseAsync(options, cancellationToken),\n\t\t\tFbServerType.Embedded => CreateNativeDatabaseAsync(options),\n\t\t\t_ => throw IncorrectServerTypeException(),\n\t\t};\n\t}\n\n\tpublic static ServiceManagerBase CreateServiceManager(ConnectionString options)\n\t{\n\t\treturn options.ServerType switch\n\t\t{\n\t\t\tFbServerType.Default => CreateManagedServiceManager(options),\n\t\t\tFbServerType.Embedded => CreateNativeServiceManager(options),\n\t\t\t_ => throw IncorrectServerTypeException(),\n\t\t};\n\t}\n\tpublic static ValueTask<ServiceManagerBase> CreateServiceManagerAsync(ConnectionString options, CancellationToken cancellationToken = default)\n\t{\n\t\treturn options.ServerType switch\n\t\t{\n\t\t\tFbServerType.Default => CreateManagedServiceManagerAsync(options, cancellationToken),\n\t\t\tFbServerType.Embedded => CreateNativeServiceManagerAsync(options),\n\t\t\t_ => throw IncorrectServerTypeException(),\n\t\t};\n\t}\n\n\tprivate static DatabaseBase CreateManagedDatabase(ConnectionString options)\n\t{\n\t\tvar charset = GetCharset(options);\n\n\t\tvar connection = new GdsConnection(options.UserID, options.Password, options.DataSource, options.Port, options.ConnectionTimeout, options.PacketSize, charset, options.Dialect, options.Compression, FbWireCryptToWireCryptOption(options.WireCrypt), options.CryptKey);\n\t\tconnection.Connect();\n\t\ttry\n\t\t{\n\t\t\tconnection.Identify(options.Database);\n\t\t}\n\t\tcatch\n\t\t{\n\t\t\tconnection.Disconnect();\n\t\t\tthrow;\n\t\t}\n\t\treturn connection.ProtocolVersion switch\n\t\t{\n\t\t\tIscCodes.PROTOCOL_VERSION16 => new Managed.Version16.GdsDatabase(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION15 => new Managed.Version15.GdsDatabase(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION13 => new Managed.Version13.GdsDatabase(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION12 => new Managed.Version12.GdsDatabase(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION11 => new Managed.Version11.GdsDatabase(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION10 => new Managed.Version10.GdsDatabase(connection),\n\t\t\t_ => throw UnsupportedProtocolException(),\n\t\t};\n\t}\n\tprivate static async ValueTask<DatabaseBase> CreateManagedDatabaseAsync(ConnectionString options, CancellationToken cancellationToken = default)\n\t{\n\t\tvar charset = GetCharset(options);\n\n\t\tvar connection = new GdsConnection(options.UserID, options.Password, options.DataSource, options.Port, options.ConnectionTimeout, options.PacketSize, charset, options.Dialect, options.Compression, FbWireCryptToWireCryptOption(options.WireCrypt), options.CryptKey);\n\t\tawait connection.ConnectAsync(cancellationToken).ConfigureAwait(false);\n\t\ttry\n\t\t{\n\t\t\tawait connection.IdentifyAsync(options.Database, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch\n\t\t{\n\t\t\tawait connection.DisconnectAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tthrow;\n\t\t}\n\t\treturn connection.ProtocolVersion switch\n\t\t{\n\t\t\tIscCodes.PROTOCOL_VERSION16 => new Managed.Version16.GdsDatabase(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION15 => new Managed.Version15.GdsDatabase(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION13 => new Managed.Version13.GdsDatabase(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION12 => new Managed.Version12.GdsDatabase(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION11 => new Managed.Version11.GdsDatabase(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION10 => new Managed.Version10.GdsDatabase(connection),\n\t\t\t_ => throw UnsupportedProtocolException(),\n\t\t};\n\t}\n\n\tprivate static DatabaseBase CreateNativeDatabase(ConnectionString options)\n\t{\n\t\tvar charset = GetCharset(options);\n\n\t\treturn new Native.FesDatabase(options.ClientLibrary, charset, options.PacketSize, options.Dialect);\n\t}\n\tprivate static ValueTask<DatabaseBase> CreateNativeDatabaseAsync(ConnectionString options)\n\t{\n\t\tvar charset = GetCharset(options);\n\n\t\treturn ValueTask.FromResult<DatabaseBase>(new Native.FesDatabase(options.ClientLibrary, charset, options.PacketSize, options.Dialect));\n\t}\n\n\tprivate static ServiceManagerBase CreateManagedServiceManager(ConnectionString options)\n\t{\n\t\tvar charset = GetCharset(options);\n\n\t\tvar connection = new GdsConnection(options.UserID, options.Password, options.DataSource, options.Port, options.ConnectionTimeout, options.PacketSize, charset, options.Dialect, options.Compression, FbWireCryptToWireCryptOption(options.WireCrypt), options.CryptKey);\n\t\tconnection.Connect();\n\t\ttry\n\t\t{\n\t\t\tconnection.Identify(!string.IsNullOrEmpty(options.Database) ? options.Database : string.Empty);\n\t\t}\n\t\tcatch\n\t\t{\n\t\t\tconnection.Disconnect();\n\t\t\tthrow;\n\t\t}\n\t\treturn connection.ProtocolVersion switch\n\t\t{\n\t\t\tIscCodes.PROTOCOL_VERSION16 => new Managed.Version16.GdsServiceManager(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION15 => new Managed.Version15.GdsServiceManager(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION13 => new Managed.Version13.GdsServiceManager(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION12 => new Managed.Version12.GdsServiceManager(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION11 => new Managed.Version11.GdsServiceManager(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION10 => new Managed.Version10.GdsServiceManager(connection),\n\t\t\t_ => throw UnsupportedProtocolException(),\n\t\t};\n\t}\n\tprivate static async ValueTask<ServiceManagerBase> CreateManagedServiceManagerAsync(ConnectionString options, CancellationToken cancellationToken = default)\n\t{\n\t\tvar charset = GetCharset(options);\n\n\t\tvar connection = new GdsConnection(options.UserID, options.Password, options.DataSource, options.Port, options.ConnectionTimeout, options.PacketSize, charset, options.Dialect, options.Compression, FbWireCryptToWireCryptOption(options.WireCrypt), options.CryptKey);\n\t\tawait connection.ConnectAsync(cancellationToken).ConfigureAwait(false);\n\t\ttry\n\t\t{\n\t\t\tawait connection.IdentifyAsync(!string.IsNullOrEmpty(options.Database) ? options.Database : string.Empty, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch\n\t\t{\n\t\t\tawait connection.DisconnectAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tthrow;\n\t\t}\n\t\treturn connection.ProtocolVersion switch\n\t\t{\n\t\t\tIscCodes.PROTOCOL_VERSION16 => new Managed.Version16.GdsServiceManager(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION15 => new Managed.Version15.GdsServiceManager(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION13 => new Managed.Version13.GdsServiceManager(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION12 => new Managed.Version12.GdsServiceManager(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION11 => new Managed.Version11.GdsServiceManager(connection),\n\t\t\tIscCodes.PROTOCOL_VERSION10 => new Managed.Version10.GdsServiceManager(connection),\n\t\t\t_ => throw UnsupportedProtocolException(),\n\t\t};\n\t}\n\n\tprivate static ServiceManagerBase CreateNativeServiceManager(ConnectionString options)\n\t{\n\t\tvar charset = GetCharset(options);\n\n\t\treturn new Native.FesServiceManager(options.ClientLibrary, charset);\n\t}\n\tprivate static ValueTask<ServiceManagerBase> CreateNativeServiceManagerAsync(ConnectionString options)\n\t{\n\t\tvar charset = GetCharset(options);\n\n\t\treturn ValueTask.FromResult<ServiceManagerBase>(new Native.FesServiceManager(options.ClientLibrary, charset));\n\t}\n\n\tprivate static Exception UnsupportedProtocolException() => new NotSupportedException(\"Protocol not supported.\");\n\tprivate static Exception IncorrectServerTypeException() => new NotSupportedException(\"Specified server type is not correct.\");\n\tprivate static Exception InvalidCharsetException() => new ArgumentException(\"Invalid character set specified.\");\n\n\tprivate static Charset GetCharset(ConnectionString options)\n\t{\n\t\tif (!Charset.TryGetByName(options.Charset, out var charset))\n\t\t\tthrow InvalidCharsetException();\n\t\treturn charset;\n\t}\n\n\tprivate static WireCryptOption FbWireCryptToWireCryptOption(FbWireCrypt wireCrypt)\n\t{\n\t\treturn wireCrypt switch\n\t\t{\n\t\t\tFbWireCrypt.Disabled => WireCryptOption.Disabled,\n\t\t\tFbWireCrypt.Enabled => WireCryptOption.Enabled,\n\t\t\tFbWireCrypt.Required => WireCryptOption.Required,\n\t\t\t_ => throw new ArgumentOutOfRangeException(nameof(wireCrypt), $\"{nameof(wireCrypt)}={wireCrypt}\"),\n\t\t};\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/AuthBlock.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.IO;\nusing System.Net;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Client.Managed.Srp;\nusing FirebirdSql.Data.Client.Managed.Sspi;\nusing FirebirdSql.Data.Common;\nusing WireCryptOption = FirebirdSql.Data.Client.Managed.Version13.WireCryptOption;\n\nnamespace FirebirdSql.Data.Client.Managed;\n\nsealed class AuthBlock\n{\n\tSrp256Client _srp256;\n\tSrpClient _srp;\n\tSspiHelper _sspi;\n\n\tpublic GdsConnection Connection { get; }\n\tpublic string User { get; }\n\tpublic string Password { get; }\n\tpublic WireCryptOption WireCrypt { get; }\n\n\tpublic byte[] ServerData { get; private set; }\n\tpublic string AcceptPluginName { get; private set; }\n\tpublic bool IsAuthenticated { get; private set; }\n\tpublic byte[] ServerKeys { get; private set; }\n\n\tpublic byte[] PublicClientData { get; private set; }\n\tpublic bool HasClientData => ClientData != null;\n\tpublic byte[] ClientData { get; private set; }\n\tpublic byte[] SessionKey { get; private set; }\n\tpublic string SessionKeyName { get; private set; }\n\n\tpublic bool WireCryptInitialized { get; private set; }\n\n\tpublic AuthBlock(GdsConnection connection, string user, string password, WireCryptOption wireCrypt)\n\t{\n\t\t_srp256 = new Srp256Client();\n\t\t_srp = new SrpClient();\n\t\t_sspi = new SspiHelper();\n\n\t\tConnection = connection;\n\t\tUser = user;\n\t\tPassword = password;\n\t\tWireCrypt = wireCrypt;\n\t}\n\n\tpublic byte[] UserIdentificationData()\n\t{\n\t\tusing (var result = new MemoryStream(256))\n\t\t{\n\t\t\tvar userString = Environment.GetEnvironmentVariable(\"USERNAME\") ?? Environment.GetEnvironmentVariable(\"USER\") ?? string.Empty;\n\t\t\tvar user = Encoding.UTF8.GetBytes(userString);\n\t\t\tresult.WriteByte(IscCodes.CNCT_user);\n\t\t\tresult.WriteByte((byte)user.Length);\n\t\t\tresult.Write(user, 0, user.Length);\n\n\t\t\tvar host = Encoding.UTF8.GetBytes(Dns.GetHostName());\n\t\t\tresult.WriteByte(IscCodes.CNCT_host);\n\t\t\tresult.WriteByte((byte)host.Length);\n\t\t\tresult.Write(host, 0, host.Length);\n\n\t\t\tresult.WriteByte(IscCodes.CNCT_user_verification);\n\t\t\tresult.WriteByte(0);\n\n\t\t\tif (!string.IsNullOrEmpty(User))\n\t\t\t{\n\t\t\t\tvar login = Encoding.UTF8.GetBytes(User);\n\t\t\t\tresult.WriteByte(IscCodes.CNCT_login);\n\t\t\t\tresult.WriteByte((byte)login.Length);\n\t\t\t\tresult.Write(login, 0, login.Length);\n\n\t\t\t\tvar pluginNameBytes = Encoding.UTF8.GetBytes(_srp256.Name);\n\t\t\t\tresult.WriteByte(IscCodes.CNCT_plugin_name);\n\t\t\t\tresult.WriteByte((byte)pluginNameBytes.Length);\n\t\t\t\tresult.Write(pluginNameBytes, 0, pluginNameBytes.Length);\n\t\t\t\tvar specificData = Encoding.UTF8.GetBytes(_srp256.PublicKeyHex);\n\t\t\t\tWriteMultiPartHelper(result, IscCodes.CNCT_specific_data, specificData);\n\n\t\t\t\tvar plugins = string.Join(\",\", new[] { _srp256.Name, _srp.Name });\n\t\t\t\tvar pluginsBytes = Encoding.UTF8.GetBytes(plugins);\n\t\t\t\tresult.WriteByte(IscCodes.CNCT_plugin_list);\n\t\t\t\tresult.WriteByte((byte)pluginsBytes.Length);\n\t\t\t\tresult.Write(pluginsBytes, 0, pluginsBytes.Length);\n\n\t\t\t\tresult.WriteByte(IscCodes.CNCT_client_crypt);\n\t\t\t\tresult.WriteByte(4);\n\t\t\t\tresult.Write(TypeEncoder.EncodeInt32(WireCryptOptionValue(WireCrypt)), 0, 4);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tvar pluginNameBytes = Encoding.UTF8.GetBytes(_sspi.Name);\n\t\t\t\tresult.WriteByte(IscCodes.CNCT_plugin_name);\n\t\t\t\tresult.WriteByte((byte)pluginNameBytes.Length);\n\t\t\t\tresult.Write(pluginNameBytes, 0, pluginNameBytes.Length);\n\t\t\t\tvar specificData = _sspi.InitializeClientSecurity();\n\t\t\t\tWriteMultiPartHelper(result, IscCodes.CNCT_specific_data, specificData);\n\n\t\t\t\tresult.WriteByte(IscCodes.CNCT_plugin_list);\n\t\t\t\tresult.WriteByte((byte)pluginNameBytes.Length);\n\t\t\t\tresult.Write(pluginNameBytes, 0, pluginNameBytes.Length);\n\n\t\t\t\tresult.WriteByte(IscCodes.CNCT_client_crypt);\n\t\t\t\tresult.WriteByte(4);\n\t\t\t\tresult.Write(TypeEncoder.EncodeInt32(IscCodes.WIRE_CRYPT_DISABLED), 0, 4);\n\t\t\t}\n\n\t\t\treturn result.ToArray();\n\t\t}\n\t}\n\n\tpublic void SendContAuthToBuffer()\n\t{\n\t\tConnection.Xdr.Write(IscCodes.op_cont_auth);\n\t\tConnection.Xdr.WriteBuffer(HasClientData ? ClientData : PublicClientData); // p_data\n\t\tConnection.Xdr.Write(AcceptPluginName); // p_name\n\t\tConnection.Xdr.Write(AcceptPluginName); // p_list\n\t\tConnection.Xdr.WriteBuffer(ServerKeys); // p_keys\n\t}\n\tpublic async ValueTask SendContAuthToBufferAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tawait Connection.Xdr.WriteAsync(IscCodes.op_cont_auth, cancellationToken).ConfigureAwait(false);\n\t\tawait Connection.Xdr.WriteBufferAsync(HasClientData ? ClientData : PublicClientData, cancellationToken).ConfigureAwait(false); // p_data\n\t\tawait Connection.Xdr.WriteAsync(AcceptPluginName, cancellationToken).ConfigureAwait(false); // p_name\n\t\tawait Connection.Xdr.WriteAsync(AcceptPluginName, cancellationToken).ConfigureAwait(false); // p_list\n\t\tawait Connection.Xdr.WriteBufferAsync(ServerKeys, cancellationToken).ConfigureAwait(false); // p_keys\n\t}\n\n\t// TODO: maybe more logic can be pulled up here\n\tpublic IResponse ProcessContAuthResponse()\n\t{\n\t\tvar operation = Connection.Xdr.ReadOperation();\n\t\tvar response = Connection.ProcessOperation(operation);\n\t\tresponse.HandleResponseException();\n\t\tif (response is Version13.ContAuthResponse)\n\t\t{\n\t\t\treturn response;\n\t\t}\n\t\telse if (response is Version13.CryptKeyCallbackResponse || response is Version15.CryptKeyCallbackResponse)\n\t\t{\n\t\t\treturn response;\n\t\t}\n\t\telse if (response is GenericResponse genericResponse)\n\t\t{\n\t\t\tServerKeys = genericResponse.Data;\n\t\t\tComplete();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tthrow new InvalidOperationException($\"Unexpected response ({operation}).\");\n\t\t}\n\t\treturn response;\n\t}\n\tpublic async ValueTask<IResponse> ProcessContAuthResponseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar operation = await Connection.Xdr.ReadOperationAsync(cancellationToken).ConfigureAwait(false);\n\t\tvar response = await Connection.ProcessOperationAsync(operation, cancellationToken).ConfigureAwait(false);\n\t\tresponse.HandleResponseException();\n\t\tif (response is Version13.ContAuthResponse)\n\t\t{\n\t\t\treturn response;\n\t\t}\n\t\telse if (response is Version13.CryptKeyCallbackResponse || response is Version15.CryptKeyCallbackResponse)\n\t\t{\n\t\t\treturn response;\n\t\t}\n\t\telse if (response is GenericResponse genericResponse)\n\t\t{\n\t\t\tServerKeys = genericResponse.Data;\n\t\t\tComplete();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tthrow new InvalidOperationException($\"Unexpected response ({operation}).\");\n\t\t}\n\t\treturn response;\n\t}\n\n\tpublic void SendWireCryptToBuffer()\n\t{\n\t\tif (WireCrypt == WireCryptOption.Disabled)\n\t\t\treturn;\n\n\t\tConnection.Xdr.Write(IscCodes.op_crypt);\n\t\tConnection.Xdr.Write(FirebirdNetworkHandlingWrapper.EncryptionName);\n\t\tConnection.Xdr.Write(SessionKeyName);\n\t}\n\tpublic async ValueTask SendWireCryptToBufferAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (WireCrypt == WireCryptOption.Disabled)\n\t\t\treturn;\n\n\t\tawait Connection.Xdr.WriteAsync(IscCodes.op_crypt, cancellationToken).ConfigureAwait(false);\n\t\tawait Connection.Xdr.WriteAsync(FirebirdNetworkHandlingWrapper.EncryptionName, cancellationToken).ConfigureAwait(false);\n\t\tawait Connection.Xdr.WriteAsync(SessionKeyName, cancellationToken).ConfigureAwait(false);\n\t}\n\n\tpublic void ProcessWireCryptResponse()\n\t{\n\t\tif (WireCrypt == WireCryptOption.Disabled)\n\t\t\treturn;\n\n\t\t// after writing before reading\n\t\tConnection.StartEncryption();\n\n\t\tvar operation = Connection.Xdr.ReadOperation();\n\t\tvar response = Connection.ProcessOperation(operation);\n\t\tresponse.HandleResponseException();\n\n\t\tWireCryptInitialized = true;\n\t}\n\tpublic async ValueTask ProcessWireCryptResponseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (WireCrypt == WireCryptOption.Disabled)\n\t\t\treturn;\n\n\t\t// after writing before reading\n\t\tConnection.StartEncryption();\n\n\t\tvar operation = await Connection.Xdr.ReadOperationAsync(cancellationToken).ConfigureAwait(false);\n\t\tvar response = await Connection.ProcessOperationAsync(operation, cancellationToken).ConfigureAwait(false);\n\t\tresponse.HandleResponseException();\n\n\t\tWireCryptInitialized = true;\n\t}\n\n\tpublic void WireCryptValidate(int protocolVersion)\n\t{\n\t\tvar validProtocolVersion = protocolVersion == IscCodes.PROTOCOL_VERSION13\n\t\t\t|| protocolVersion == IscCodes.PROTOCOL_VERSION15\n\t\t\t|| protocolVersion == IscCodes.PROTOCOL_VERSION16;\n\t\tif (validProtocolVersion && WireCrypt == WireCryptOption.Required && IsAuthenticated && !WireCryptInitialized)\n\t\t{\n\t\t\tthrow IscException.ForErrorCode(IscCodes.isc_wirecrypt_incompatible);\n\t\t}\n\t}\n\n\tpublic void Start(byte[] serverData, string acceptPluginName, bool isAuthenticated, byte[] serverKeys)\n\t{\n\t\tServerData = serverData;\n\t\tAcceptPluginName = acceptPluginName;\n\t\tIsAuthenticated = isAuthenticated;\n\t\tServerKeys = serverKeys;\n\n\t\tvar hasServerData = ServerData.Length != 0;\n\t\tif (AcceptPluginName.Equals(_srp256.Name, StringComparison.Ordinal))\n\t\t{\n\t\t\tPublicClientData = Encoding.UTF8.GetBytes(_srp256.PublicKeyHex);\n\t\t\tif (hasServerData)\n\t\t\t{\n\t\t\t\tClientData = Encoding.UTF8.GetBytes(_srp256.ClientProof(NormalizeLogin(User), Password, ServerData).ToHexString());\n\t\t\t}\n\t\t\tSessionKey = _srp256.SessionKey;\n\t\t\tSessionKeyName = _srp256.SessionKeyName;\n\t\t}\n\t\telse if (AcceptPluginName.Equals(_srp.Name, StringComparison.Ordinal))\n\t\t{\n\t\t\tPublicClientData = Encoding.UTF8.GetBytes(_srp.PublicKeyHex);\n\t\t\tif (hasServerData)\n\t\t\t{\n\t\t\t\tClientData = Encoding.UTF8.GetBytes(_srp.ClientProof(NormalizeLogin(User), Password, ServerData).ToHexString());\n\t\t\t}\n\t\t\tSessionKey = _srp.SessionKey;\n\t\t\tSessionKeyName = _srp.SessionKeyName;\n\t\t}\n\t\telse if (AcceptPluginName.Equals(_sspi.Name, StringComparison.Ordinal))\n\t\t{\n\t\t\tif (hasServerData)\n\t\t\t{\n\t\t\t\tClientData = _sspi.GetClientSecurity(ServerData);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tthrow new NotSupportedException($\"Not supported plugin '{AcceptPluginName}'.\");\n\t\t}\n\t}\n\n\tpublic void Complete()\n\t{\n\t\tIsAuthenticated = true;\n\t\tReleaseAuth();\n\t}\n\n\tvoid ReleaseAuth()\n\t{\n\t\t_srp256 = null;\n\t\t_srp = null;\n\t\t_sspi?.Dispose();\n\t\t_sspi = null;\n\t}\n\n\tstatic void WriteMultiPartHelper(Stream stream, byte code, byte[] data)\n\t{\n\t\tconst int MaxLength = 255 - 1;\n\t\tvar part = 0;\n\t\tfor (var i = 0; i < data.Length; i += MaxLength)\n\t\t{\n\t\t\tstream.WriteByte(code);\n\t\t\tvar length = Math.Min(data.Length - i, MaxLength);\n\t\t\tstream.WriteByte((byte)(length + 1));\n\t\t\tstream.WriteByte((byte)part);\n\t\t\tstream.Write(data, i, length);\n\t\t\tpart++;\n\t\t}\n\t}\n\n\tstatic int WireCryptOptionValue(WireCryptOption wireCrypt)\n\t{\n\t\treturn wireCrypt switch\n\t\t{\n\t\t\tWireCryptOption.Disabled => IscCodes.WIRE_CRYPT_DISABLED,\n\t\t\tWireCryptOption.Enabled => IscCodes.WIRE_CRYPT_ENABLED,\n\t\t\tWireCryptOption.Required => IscCodes.WIRE_CRYPT_REQUIRED,\n\t\t\t_ => throw new ArgumentOutOfRangeException(nameof(wireCrypt), $\"{nameof(wireCrypt)}={wireCrypt}\"),\n\t\t};\n\t}\n\n\tinternal static string NormalizeLogin(string login)\n\t{\n\t\tif (string.IsNullOrEmpty(login))\n\t\t{\n\t\t\treturn login;\n\t\t}\n\t\tif (login.Length > 2 && login[0] == '\"' && login[login.Length - 1] == '\"')\n\t\t{\n\t\t\tvar sb = new StringBuilder(login, 1, login.Length - 2, login.Length - 2);\n\t\t\tfor (int idx = 0; idx < sb.Length; idx++)\n\t\t\t{\n\t\t\t\t// Double double quotes (\"\") escape a double quote in a quoted string\n\t\t\t\tif (sb[idx] == '\"')\n\t\t\t\t{\n\t\t\t\t\t// Strip double quote escape\n\t\t\t\t\tsb.Remove(idx, 1);\n\t\t\t\t\tif (idx < sb.Length && sb[idx] == '\"')\n\t\t\t\t\t{\n\t\t\t\t\t\t// Retain escaped double quote\n\t\t\t\t\t\tidx += 1;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t// The character after escape is not a double quote, we terminate the conversion and truncate.\n\t\t\t\t\t\t// Firebird does this as well (see common/utils.cpp#dpbItemUpper)\n\t\t\t\t\t\tsb.Length = idx;\n\t\t\t\t\t\treturn sb.ToString();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn sb.ToString();\n\t\t}\n\t\treturn login.ToUpperInvariant();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/DataProviderStreamWrapper.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.IO;\nusing System.Runtime.CompilerServices;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace FirebirdSql.Data.Client.Managed;\n\nsealed class DataProviderStreamWrapper : IDataProvider\n{\n\treadonly Stream _stream;\n\n\tpublic DataProviderStreamWrapper(Stream stream)\n\t{\n\t\t_stream = stream;\n\t}\n\n\t[MethodImpl(MethodImplOptions.AggressiveInlining)]\n\tpublic int Read(byte[] buffer, int offset, int count)\n\t{\n\t\treturn _stream.Read(buffer, offset, count);\n\t}\n\t[MethodImpl(MethodImplOptions.AggressiveInlining)]\n\tpublic ValueTask<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default)\n\t{\n\t\treturn new ValueTask<int>(_stream.ReadAsync(buffer, offset, count, cancellationToken));\n\t}\n\n\t[MethodImpl(MethodImplOptions.AggressiveInlining)]\n\tpublic void Write(byte[] buffer, int offset, int count)\n\t{\n\t\t_stream.Write(buffer, offset, count);\n\t}\n\t[MethodImpl(MethodImplOptions.AggressiveInlining)]\n\tpublic ValueTask WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default)\n\t{\n\t\treturn new ValueTask(_stream.WriteAsync(buffer, offset, count, cancellationToken));\n\t}\n\n\t[MethodImpl(MethodImplOptions.AggressiveInlining)]\n\tpublic void Flush()\n\t{\n\t\t_stream.Flush();\n\t}\n\t[MethodImpl(MethodImplOptions.AggressiveInlining)]\n\tpublic ValueTask FlushAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn new ValueTask(_stream.FlushAsync(cancellationToken));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/FetchResponse.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed;\n\ninternal class FetchResponse : IResponse\n{\n\tpublic int Status { get; }\n\tpublic int Count { get; }\n\n\tpublic FetchResponse(int status, int count)\n\t{\n\t\tStatus = status;\n\t\tCount = count;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/FirebirdNetworkHandlingWrapper.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed;\n\nsealed class FirebirdNetworkHandlingWrapper : IDataProvider, ITracksIOFailure\n{\n\tpublic const string CompressionName = \"zlib\";\n\tpublic const string EncryptionName = \"Arc4\";\n\n\tconst int PreferredBufferSize = 32 * 1024;\n\n\treadonly IDataProvider _dataProvider;\n\n\treadonly Queue<byte> _outputBuffer;\n\treadonly Queue<byte> _inputBuffer;\n\treadonly byte[] _readBuffer;\n\n\tbyte[] _compressionBuffer;\n\tIonic.Zlib.ZlibCodec _compressor;\n\tIonic.Zlib.ZlibCodec _decompressor;\n\n\tOrg.BouncyCastle.Crypto.Engines.RC4Engine _decryptor;\n\tOrg.BouncyCastle.Crypto.Engines.RC4Engine _encryptor;\n\n\tpublic FirebirdNetworkHandlingWrapper(IDataProvider dataProvider)\n\t{\n\t\t_dataProvider = dataProvider;\n\n\t\t_outputBuffer = new Queue<byte>(PreferredBufferSize);\n\t\t_inputBuffer = new Queue<byte>(PreferredBufferSize);\n\t\t_readBuffer = new byte[PreferredBufferSize];\n\t}\n\n\tpublic bool IOFailed { get; set; }\n\n\tpublic int Read(byte[] buffer, int offset, int count)\n\t{\n\t\tif (_inputBuffer.Count < count)\n\t\t{\n\t\t\tvar readBuffer = _readBuffer;\n\t\t\tint read;\n\t\t\ttry\n\t\t\t{\n\t\t\t\tread = _dataProvider.Read(readBuffer, 0, readBuffer.Length);\n\t\t\t}\n\t\t\tcatch (IOException)\n\t\t\t{\n\t\t\t\tIOFailed = true;\n\t\t\t\tthrow;\n\t\t\t}\n\t\t\tif (read != 0)\n\t\t\t{\n\t\t\t\tif (_decryptor != null)\n\t\t\t\t{\n\t\t\t\t\t_decryptor.ProcessBytes(readBuffer, 0, read, readBuffer, 0);\n\t\t\t\t}\n\t\t\t\tif (_decompressor != null)\n\t\t\t\t{\n\t\t\t\t\tread = HandleDecompression(readBuffer, read);\n\t\t\t\t\treadBuffer = _compressionBuffer;\n\t\t\t\t}\n\t\t\t\tWriteToInputBuffer(readBuffer, read);\n\t\t\t}\n\t\t}\n\t\tvar dataLength = ReadFromInputBuffer(buffer, offset, count);\n\t\treturn dataLength;\n\t}\n\tpublic async ValueTask<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default)\n\t{\n\t\tif (_inputBuffer.Count < count)\n\t\t{\n\t\t\tvar readBuffer = _readBuffer;\n\t\t\tint read;\n\t\t\ttry\n\t\t\t{\n\t\t\t\tread = await _dataProvider.ReadAsync(readBuffer, 0, readBuffer.Length, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch (IOException)\n\t\t\t{\n\t\t\t\tIOFailed = true;\n\t\t\t\tthrow;\n\t\t\t}\n\t\t\tif (read != 0)\n\t\t\t{\n\t\t\t\tif (_decryptor != null)\n\t\t\t\t{\n\t\t\t\t\t_decryptor.ProcessBytes(readBuffer, 0, read, readBuffer, 0);\n\t\t\t\t}\n\t\t\t\tif (_decompressor != null)\n\t\t\t\t{\n\t\t\t\t\tread = HandleDecompression(readBuffer, read);\n\t\t\t\t\treadBuffer = _compressionBuffer;\n\t\t\t\t}\n\t\t\t\tWriteToInputBuffer(readBuffer, read);\n\t\t\t}\n\t\t}\n\t\tvar dataLength = ReadFromInputBuffer(buffer, offset, count);\n\t\treturn dataLength;\n\t}\n\n\tpublic void Write(byte[] buffer, int offset, int count)\n\t{\n\t\tfor (var i = 0; i < count; i++)\n\t\t\t_outputBuffer.Enqueue(buffer[offset + i]);\n\t}\n\tpublic ValueTask WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default)\n\t{\n\t\tfor (var i = 0; i < count; i++)\n\t\t\t_outputBuffer.Enqueue(buffer[offset + i]);\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic void Flush()\n\t{\n\t\tvar buffer = _outputBuffer.ToArray();\n\t\t_outputBuffer.Clear();\n\t\tvar count = buffer.Length;\n\t\tif (_compressor != null)\n\t\t{\n\t\t\tcount = HandleCompression(buffer, count);\n\t\t\tbuffer = _compressionBuffer;\n\t\t}\n\t\tif (_encryptor != null)\n\t\t{\n\t\t\t_encryptor.ProcessBytes(buffer, 0, count, buffer, 0);\n\t\t}\n\t\ttry\n\t\t{\n\t\t\t_dataProvider.Write(buffer, 0, count);\n\t\t\t_dataProvider.Flush();\n\t\t}\n\t\tcatch (IOException)\n\t\t{\n\t\t\tIOFailed = true;\n\t\t\tthrow;\n\t\t}\n\t}\n\tpublic async ValueTask FlushAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar buffer = _outputBuffer.ToArray();\n\t\t_outputBuffer.Clear();\n\t\tvar count = buffer.Length;\n\t\tif (_compressor != null)\n\t\t{\n\t\t\tcount = HandleCompression(buffer, count);\n\t\t\tbuffer = _compressionBuffer;\n\t\t}\n\t\tif (_encryptor != null)\n\t\t{\n\t\t\t_encryptor.ProcessBytes(buffer, 0, count, buffer, 0);\n\t\t}\n\t\ttry\n\t\t{\n\t\t\tawait _dataProvider.WriteAsync(buffer, 0, count, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _dataProvider.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IOException)\n\t\t{\n\t\t\tIOFailed = true;\n\t\t\tthrow;\n\t\t}\n\t}\n\n\tpublic void StartCompression()\n\t{\n\t\t_compressionBuffer = new byte[PreferredBufferSize];\n\t\t_compressor = new Ionic.Zlib.ZlibCodec(Ionic.Zlib.CompressionMode.Compress);\n\t\t_decompressor = new Ionic.Zlib.ZlibCodec(Ionic.Zlib.CompressionMode.Decompress);\n\t}\n\n\tpublic void StartEncryption(byte[] key)\n\t{\n\t\t_encryptor = CreateCipher(key);\n\t\t_decryptor = CreateCipher(key);\n\t}\n\n\tint ReadFromInputBuffer(byte[] buffer, int offset, int count)\n\t{\n\t\tvar read = Math.Min(count, _inputBuffer.Count);\n\t\tfor (var i = 0; i < read; i++)\n\t\t{\n\t\t\tbuffer[offset + i] = _inputBuffer.Dequeue();\n\t\t}\n\t\treturn read;\n\t}\n\n\tvoid WriteToInputBuffer(byte[] data, int count)\n\t{\n\t\tfor (var i = 0; i < count; i++)\n\t\t{\n\t\t\t_inputBuffer.Enqueue(data[i]);\n\t\t}\n\t}\n\n\tint HandleDecompression(byte[] buffer, int count)\n\t{\n\t\t_decompressor.InputBuffer = buffer;\n\t\t_decompressor.NextOut = 0;\n\t\t_decompressor.NextIn = 0;\n\t\t_decompressor.AvailableBytesIn = count;\n\t\twhile (true)\n\t\t{\n\t\t\t_decompressor.OutputBuffer = _compressionBuffer;\n\t\t\t_decompressor.AvailableBytesOut = _compressionBuffer.Length - _decompressor.NextOut;\n\t\t\tvar rc = _decompressor.Inflate(Ionic.Zlib.FlushType.None);\n\t\t\tif (rc != Ionic.Zlib.ZlibConstants.Z_OK)\n\t\t\t\tthrow new IOException($\"Error '{rc}' while decompressing the data.\");\n\t\t\tif (_decompressor.AvailableBytesIn > 0 || _decompressor.AvailableBytesOut == 0)\n\t\t\t{\n\t\t\t\tResizeBuffer(ref _compressionBuffer);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\treturn _decompressor.NextOut;\n\t}\n\n\tint HandleCompression(byte[] buffer, int count)\n\t{\n\t\t_compressor.InputBuffer = buffer;\n\t\t_compressor.NextOut = 0;\n\t\t_compressor.NextIn = 0;\n\t\t_compressor.AvailableBytesIn = count;\n\t\twhile (true)\n\t\t{\n\t\t\t_compressor.OutputBuffer = _compressionBuffer;\n\t\t\t_compressor.AvailableBytesOut = _compressionBuffer.Length - _compressor.NextOut;\n\t\t\tvar rc = _compressor.Deflate(Ionic.Zlib.FlushType.None);\n\t\t\tif (rc != Ionic.Zlib.ZlibConstants.Z_OK)\n\t\t\t\tthrow new IOException($\"Error '{rc}' while compressing the data.\");\n\t\t\tif (_compressor.AvailableBytesIn > 0 || _compressor.AvailableBytesOut == 0)\n\t\t\t{\n\t\t\t\tResizeBuffer(ref _compressionBuffer);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\twhile (true)\n\t\t{\n\t\t\t_compressor.OutputBuffer = _compressionBuffer;\n\t\t\t_compressor.AvailableBytesOut = _compressionBuffer.Length - _compressor.NextOut;\n\t\t\tvar rc = _compressor.Deflate(Ionic.Zlib.FlushType.Sync);\n\t\t\tif (rc != Ionic.Zlib.ZlibConstants.Z_OK)\n\t\t\t\tthrow new IOException($\"Error '{rc}' while compressing the data.\");\n\t\t\tif (_compressor.AvailableBytesIn > 0 || _compressor.AvailableBytesOut == 0)\n\t\t\t{\n\t\t\t\tResizeBuffer(ref _compressionBuffer);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\treturn _compressor.NextOut;\n\t}\n\n\tstatic void ResizeBuffer(ref byte[] buffer)\n\t{\n\t\tArray.Resize(ref buffer, buffer.Length * 2);\n\t}\n\n\tstatic Org.BouncyCastle.Crypto.Engines.RC4Engine CreateCipher(byte[] key)\n\t{\n\t\tvar cipher = new Org.BouncyCastle.Crypto.Engines.RC4Engine();\n\t\tcipher.Init(default, new Org.BouncyCastle.Crypto.Parameters.KeyParameter(key));\n\t\treturn cipher;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/GdsConnection.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Net;\nusing System.Net.Sockets;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed;\n\ninternal sealed class GdsConnection\n{\n\tprivate NetworkStream _networkStream;\n\tprivate FirebirdNetworkHandlingWrapper _firebirdNetworkHandlingWrapper;\n\n\tpublic string User { get; private set; }\n\tpublic string Password { get; private set; }\n\tpublic string DataSource { get; private set; }\n\tpublic int PortNumber { get; private set; }\n\tpublic int Timeout { get; private set; }\n\tpublic int PacketSize { get; private set; }\n\tpublic Charset Charset { get; private set; }\n\tpublic short Dialect { get; private set; }\n\tpublic bool Compression { get; private set; }\n\tpublic Version13.WireCryptOption WireCrypt { get; private set; }\n\tpublic byte[] CryptKey { get; private set; }\n\n\tpublic int ProtocolVersion { get; private set; }\n\tpublic int ProtocolArchitecture { get; private set; }\n\tpublic int ProtocolMinimunType { get; private set; }\n\tpublic bool ConnectionBroken => _firebirdNetworkHandlingWrapper?.IOFailed ?? false;\n\n\tinternal IPAddress IPAddress { get; private set; }\n\tinternal XdrReaderWriter Xdr { get; private set; }\n\n\tinternal AuthBlock AuthBlock { get; private set; }\n\n\tpublic GdsConnection(string dataSource, int port, int timeout)\n\t\t: this(null, null, dataSource, port, timeout, 8192, Charset.DefaultCharset, 3, false, Version13.WireCryptOption.Enabled, null)\n\t{ }\n\n\tpublic GdsConnection(string user, string password, string dataSource, int portNumber, int timeout, int packetSize, Charset charset, short dialect, bool compression, Version13.WireCryptOption wireCrypt, byte[] cryptKey)\n\t{\n\t\tUser = user;\n\t\tPassword = password;\n\t\tDataSource = dataSource;\n\t\tPortNumber = portNumber;\n\t\tTimeout = timeout;\n\t\tPacketSize = packetSize;\n\t\tCharset = charset;\n\t\tDialect = dialect;\n\t\tCompression = compression;\n\t\tWireCrypt = wireCrypt;\n\t\tCryptKey = cryptKey;\n\t}\n\n\tpublic void Connect()\n\t{\n\t\ttry\n\t\t{\n\t\t\tIPAddress = GetIPAddress(DataSource);\n\t\t\tvar endPoint = new IPEndPoint(IPAddress, PortNumber);\n\n\t\t\tvar socket = new Socket(IPAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);\n\t\t\tsocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, PacketSize);\n\t\t\tsocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, PacketSize);\n\t\t\tsocket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1);\n\t\t\tsocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, 1);\n\n\t\t\tsocket.Connect(endPoint);\n\n\t\t\t_networkStream = new NetworkStream(socket, true);\n\t\t\t_firebirdNetworkHandlingWrapper = new FirebirdNetworkHandlingWrapper(new DataProviderStreamWrapper(_networkStream));\n\t\t\tXdr = new XdrReaderWriter(_firebirdNetworkHandlingWrapper, Charset);\n\t\t}\n\t\tcatch (SocketException ex)\n\t\t{\n\t\t\tthrow IscException.ForTypeErrorCodeStrParam(IscCodes.isc_arg_gds, IscCodes.isc_network_error, DataSource, ex);\n\t\t}\n\t}\n\tpublic async ValueTask ConnectAsync(CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tIPAddress = await GetIPAddressAsync(DataSource, cancellationToken).ConfigureAwait(false);\n\t\t\tvar endPoint = new IPEndPoint(IPAddress, PortNumber);\n\n\t\t\tvar socket = new Socket(IPAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);\n\t\t\tsocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, PacketSize);\n\t\t\tsocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, PacketSize);\n\t\t\tsocket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1);\n\t\t\tsocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, 1);\n\n\t\t\tusing (var timeoutCts = new CancellationTokenSource(TimeSpan.FromSeconds(Timeout)))\n\t\t\t{\n\t\t\t\tusing (var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(timeoutCts.Token, cancellationToken))\n\t\t\t\t{\n\t\t\t\t\tawait socket.ConnectAsync(endPoint, combinedCts.Token).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_networkStream = new NetworkStream(socket, true);\n\t\t\t_firebirdNetworkHandlingWrapper = new FirebirdNetworkHandlingWrapper(new DataProviderStreamWrapper(_networkStream));\n\t\t\tXdr = new XdrReaderWriter(_firebirdNetworkHandlingWrapper, Charset);\n\t\t}\n\t\tcatch (SocketException ex)\n\t\t{\n\t\t\tthrow IscException.ForTypeErrorCodeStrParam(IscCodes.isc_arg_gds, IscCodes.isc_network_error, DataSource, ex);\n\t\t}\n\t}\n\n\tpublic void Identify(string database)\n\t{\n\t\ttry\n\t\t{\n\t\t\tXdr.Write(IscCodes.op_connect);\n\t\t\tXdr.Write(IscCodes.op_attach);\n\t\t\tXdr.Write(IscCodes.CONNECT_VERSION3);\n\t\t\tXdr.Write(IscCodes.GenericAchitectureClient);\n\n\t\t\tXdr.Write(database);\n\n\t\t\tvar protocols = ProtocolsSupported.Get(Compression);\n\t\t\tXdr.Write(protocols.Count());\n\n\t\t\tAuthBlock = new AuthBlock(this, User, Password, WireCrypt);\n\n\t\t\tXdr.WriteBuffer(AuthBlock.UserIdentificationData());\n\n\t\t\tvar priority = 0;\n\t\t\tforeach (var protocol in protocols)\n\t\t\t{\n\t\t\t\tXdr.Write(protocol.Version);\n\t\t\t\tXdr.Write(IscCodes.GenericAchitectureClient);\n\t\t\t\tXdr.Write(IscCodes.p_cnct_min_type);\n\t\t\t\tXdr.Write(protocol.MaxPType);\n\t\t\t\tXdr.Write(priority);\n\t\t\t\tpriority++;\n\t\t\t}\n\n\t\t\tXdr.Flush();\n\n\t\t\tvar operation = Xdr.ReadOperation();\n\t\t\twhile (operation == IscCodes.op_crypt_key_callback)\n\t\t\t{\n\t\t\t\tvar data = Xdr.ReadBuffer();\n\t\t\t\tvar size = Xdr.ReadInt32();\n\n\t\t\t\tXdr.Write(IscCodes.op_crypt_key_callback);\n\t\t\t\tXdr.WriteBuffer(CryptKey);\n\t\t\t\tXdr.Write(size);\n\t\t\t\tXdr.Flush();\n\t\t\t\toperation = Xdr.ReadOperation();\n\t\t\t}\n\t\t\tif (operation == IscCodes.op_accept || operation == IscCodes.op_cond_accept || operation == IscCodes.op_accept_data)\n\t\t\t{\n\t\t\t\tProtocolVersion = Xdr.ReadInt32();\n\t\t\t\tProtocolArchitecture = Xdr.ReadInt32();\n\t\t\t\tProtocolMinimunType = Xdr.ReadInt32();\n\n\t\t\t\tif (ProtocolVersion < 0)\n\t\t\t\t{\n\t\t\t\t\tProtocolVersion = (ushort)(ProtocolVersion & IscCodes.FB_PROTOCOL_MASK) | IscCodes.FB_PROTOCOL_FLAG;\n\t\t\t\t}\n\n\t\t\t\tif (Compression && !((ProtocolMinimunType & IscCodes.pflag_compress) != 0))\n\t\t\t\t{\n\t\t\t\t\tCompression = false;\n\t\t\t\t}\n\n\t\t\t\tif (operation == IscCodes.op_cond_accept || operation == IscCodes.op_accept_data)\n\t\t\t\t{\n\t\t\t\t\tAuthBlock.Start(\n\t\t\t\t\t\tXdr.ReadBuffer(),\n\t\t\t\t\t\tXdr.ReadString(),\n\t\t\t\t\t\tXdr.ReadBoolean(),\n\t\t\t\t\t\tXdr.ReadBuffer());\n\n\t\t\t\t\tif (Compression)\n\t\t\t\t\t{\n\t\t\t\t\t\t// after reading before writing\n\t\t\t\t\t\tStartCompression();\n\t\t\t\t\t}\n\n\t\t\t\t\tif (operation == IscCodes.op_cond_accept)\n\t\t\t\t\t{\n\t\t\t\t\t\twhile (true)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tAuthBlock.SendContAuthToBuffer();\n\t\t\t\t\t\t\tXdr.Flush();\n\t\t\t\t\t\t\tvar response = AuthBlock.ProcessContAuthResponse();\n\t\t\t\t\t\t\tif (response is Version13.ContAuthResponse contAuthResponse)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tAuthBlock.Start(contAuthResponse.ServerData, contAuthResponse.AcceptPluginName, contAuthResponse.IsAuthenticated, contAuthResponse.ServerKeys);\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (AuthBlock.ServerKeys.Any())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tAuthBlock.SendWireCryptToBuffer();\n\t\t\t\t\t\t\tXdr.Flush();\n\t\t\t\t\t\t\tAuthBlock.ProcessWireCryptResponse();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tAuthBlock.WireCryptValidate(ProtocolVersion);\n\t\t\t}\n\t\t\telse if (operation == IscCodes.op_response)\n\t\t\t{\n\t\t\t\tvar response = (GenericResponse)ProcessOperation(operation);\n\t\t\t\tresponse.HandleResponseException();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthrow IscException.ForErrorCode(IscCodes.isc_connect_reject);\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic async ValueTask IdentifyAsync(string database, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait Xdr.WriteAsync(IscCodes.op_connect, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(IscCodes.op_attach, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(IscCodes.CONNECT_VERSION3, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(IscCodes.GenericAchitectureClient, cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait Xdr.WriteAsync(database, cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar protocols = ProtocolsSupported.Get(Compression);\n\t\t\tawait Xdr.WriteAsync(protocols.Count(), cancellationToken).ConfigureAwait(false);\n\n\t\t\tAuthBlock = new AuthBlock(this, User, Password, WireCrypt);\n\n\t\t\tawait Xdr.WriteBufferAsync(AuthBlock.UserIdentificationData(), cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar priority = 0;\n\t\t\tforeach (var protocol in protocols)\n\t\t\t{\n\t\t\t\tawait Xdr.WriteAsync(protocol.Version, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait Xdr.WriteAsync(IscCodes.GenericAchitectureClient, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait Xdr.WriteAsync(IscCodes.p_cnct_min_type, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait Xdr.WriteAsync(protocol.MaxPType, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait Xdr.WriteAsync(priority, cancellationToken).ConfigureAwait(false);\n\t\t\t\tpriority++;\n\t\t\t}\n\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar operation = await Xdr.ReadOperationAsync(cancellationToken).ConfigureAwait(false);\n\t\t\twhile (operation == IscCodes.op_crypt_key_callback)\n\t\t\t{\n\t\t\t\tvar data = await Xdr.ReadBufferAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar size = await Xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tawait Xdr.WriteAsync(IscCodes.op_crypt_key_callback, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait Xdr.WriteBufferAsync(CryptKey, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait Xdr.WriteAsync(size, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\toperation = await Xdr.ReadOperationAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tif (operation == IscCodes.op_accept || operation == IscCodes.op_cond_accept || operation == IscCodes.op_accept_data)\n\t\t\t{\n\t\t\t\tProtocolVersion = await Xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false);\n\t\t\t\tProtocolArchitecture = await Xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false);\n\t\t\t\tProtocolMinimunType = await Xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tif (ProtocolVersion < 0)\n\t\t\t\t{\n\t\t\t\t\tProtocolVersion = (ushort)(ProtocolVersion & IscCodes.FB_PROTOCOL_MASK) | IscCodes.FB_PROTOCOL_FLAG;\n\t\t\t\t}\n\n\t\t\t\tif (Compression && !((ProtocolMinimunType & IscCodes.pflag_compress) != 0))\n\t\t\t\t{\n\t\t\t\t\tCompression = false;\n\t\t\t\t}\n\n\t\t\t\tif (operation == IscCodes.op_cond_accept || operation == IscCodes.op_accept_data)\n\t\t\t\t{\n\t\t\t\t\tAuthBlock.Start(\n\t\t\t\t\t\tawait Xdr.ReadBufferAsync(cancellationToken).ConfigureAwait(false),\n\t\t\t\t\t\tawait Xdr.ReadStringAsync(cancellationToken).ConfigureAwait(false),\n\t\t\t\t\t\tawait Xdr.ReadBooleanAsync(cancellationToken).ConfigureAwait(false),\n\t\t\t\t\t\tawait Xdr.ReadBufferAsync(cancellationToken).ConfigureAwait(false));\n\n\t\t\t\t\tif (Compression)\n\t\t\t\t\t{\n\t\t\t\t\t\t// after reading before writing\n\t\t\t\t\t\tStartCompression();\n\t\t\t\t\t}\n\n\t\t\t\t\tif (operation == IscCodes.op_cond_accept)\n\t\t\t\t\t{\n\t\t\t\t\t\twhile (true)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tawait AuthBlock.SendContAuthToBufferAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\tvar response = await AuthBlock.ProcessContAuthResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\tif (response is Version13.ContAuthResponse contAuthResponse)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tAuthBlock.Start(contAuthResponse.ServerData, contAuthResponse.AcceptPluginName, contAuthResponse.IsAuthenticated, contAuthResponse.ServerKeys);\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (AuthBlock.ServerKeys.Any())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tawait AuthBlock.SendWireCryptToBufferAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\tawait AuthBlock.ProcessWireCryptResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tAuthBlock.WireCryptValidate(ProtocolVersion);\n\t\t\t}\n\t\t\telse if (operation == IscCodes.op_response)\n\t\t\t{\n\t\t\t\tvar response = (GenericResponse)await ProcessOperationAsync(operation, cancellationToken).ConfigureAwait(false);\n\t\t\t\tresponse.HandleResponseException();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthrow IscException.ForErrorCode(IscCodes.isc_connect_reject);\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic void Disconnect()\n\t{\n\t\tif (_networkStream != null)\n\t\t{\n\t\t\t_networkStream.Dispose();\n\t\t\t_networkStream = null;\n\t\t}\n\t}\n\tpublic async ValueTask DisconnectAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_networkStream != null)\n\t\t{\n\t\t\tawait _networkStream.DisposeAsync().ConfigureAwait(false);\n\t\t\t_networkStream = null;\n\t\t}\n\t}\n\n\tinternal IResponse ProcessOperation(int operation)\n\t{\n\t\tswitch (operation)\n\t\t{\n\t\t\tcase IscCodes.op_response:\n\t\t\t\treturn new GenericResponse(\n\t\t\t\t\tXdr.ReadInt32(),\n\t\t\t\t\tXdr.ReadInt64(),\n\t\t\t\t\tXdr.ReadBuffer(),\n\t\t\t\t\tXdr.ReadStatusVector());\n\n\t\t\tcase IscCodes.op_fetch_response:\n\t\t\t\treturn new FetchResponse(\n\t\t\t\t\tXdr.ReadInt32(),\n\t\t\t\t\tXdr.ReadInt32());\n\n\t\t\tcase IscCodes.op_sql_response:\n\t\t\t\treturn new SqlResponse(\n\t\t\t\t\tXdr.ReadInt32());\n\n\t\t\tcase IscCodes.op_trusted_auth:\n\t\t\t\treturn new Version11.AuthResponse(\n\t\t\t\t\tXdr.ReadBuffer());\n\n\t\t\tcase IscCodes.op_crypt_key_callback:\n\t\t\t\tif (ProtocolVersion == IscCodes.PROTOCOL_VERSION15\n\t\t\t\t\t|| ProtocolVersion == IscCodes.PROTOCOL_VERSION16)\n\t\t\t\t{\n\t\t\t\t\treturn new Version15.CryptKeyCallbackResponse(\n\t\t\t\t\t\tXdr.ReadBuffer(),\n\t\t\t\t\t\tXdr.ReadInt32());\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn new Version13.CryptKeyCallbackResponse(\n\t\t\t\t\t\tXdr.ReadBuffer());\n\t\t\t\t}\n\n\t\t\tcase IscCodes.op_cont_auth:\n\t\t\t\treturn new Version13.ContAuthResponse(\n\t\t\t\t\tXdr.ReadBuffer(),\n\t\t\t\t\tXdr.ReadString(),\n\t\t\t\t\tXdr.ReadBoolean(),\n\t\t\t\t\tXdr.ReadBuffer());\n\n\t\t\tcase IscCodes.op_batch_cs:\n\t\t\t\tvar statementHandle = Xdr.ReadInt16();\n\t\t\t\tvar p_batch_reccount = Xdr.ReadInt32();\n\t\t\t\tvar p_batch_updates = Xdr.ReadInt32();\n\t\t\t\tvar p_batch_vectors = Xdr.ReadInt32();\n\t\t\t\tvar p_batch_errors = Xdr.ReadInt32();\n\n\t\t\t\tvar p_batch_updates_data = new int[p_batch_updates];\n\t\t\t\tfor (var i = 0; i < p_batch_updates; i++)\n\t\t\t\t{\n\t\t\t\t\tp_batch_updates_data[i] = Xdr.ReadInt32();\n\t\t\t\t}\n\n\t\t\t\tvar p_batch_vectors_data = new (int messageNumber, IscException statusVector)[p_batch_vectors];\n\t\t\t\tfor (var i = 0; i < p_batch_vectors; i++)\n\t\t\t\t{\n\t\t\t\t\tvar messageNumber = Xdr.ReadInt32();\n\t\t\t\t\tvar statusVector = Xdr.ReadStatusVector();\n\t\t\t\t\tp_batch_vectors_data[i] = (messageNumber, statusVector);\n\t\t\t\t}\n\n\t\t\t\tvar p_batch_errors_data = new int[p_batch_errors];\n\t\t\t\tfor (var i = 0; i < p_batch_errors; i++)\n\t\t\t\t{\n\t\t\t\t\tp_batch_errors_data[i] = Xdr.ReadInt32();\n\t\t\t\t}\n\n\t\t\t\treturn new Version16.BatchCompletionStateResponse(\n\t\t\t\t\tstatementHandle,\n\t\t\t\t\tp_batch_reccount,\n\t\t\t\t\tp_batch_updates_data,\n\t\t\t\t\tp_batch_vectors_data,\n\t\t\t\t\tp_batch_errors_data);\n\n\t\t\tdefault:\n\t\t\t\tthrow new ArgumentOutOfRangeException(nameof(operation), $\"{nameof(operation)}={operation}\");\n\t\t}\n\t}\n\tinternal async ValueTask<IResponse> ProcessOperationAsync(int operation, CancellationToken cancellationToken = default)\n\t{\n\t\tswitch (operation)\n\t\t{\n\t\t\tcase IscCodes.op_response:\n\t\t\t\treturn new GenericResponse(\n\t\t\t\t\tawait Xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false),\n\t\t\t\t\tawait Xdr.ReadInt64Async(cancellationToken).ConfigureAwait(false),\n\t\t\t\t\tawait Xdr.ReadBufferAsync(cancellationToken).ConfigureAwait(false),\n\t\t\t\t\tawait Xdr.ReadStatusVectorAsync(cancellationToken).ConfigureAwait(false));\n\n\t\t\tcase IscCodes.op_fetch_response:\n\t\t\t\treturn new FetchResponse(\n\t\t\t\t\tawait Xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false),\n\t\t\t\t\tawait Xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false));\n\n\t\t\tcase IscCodes.op_sql_response:\n\t\t\t\treturn new SqlResponse(\n\t\t\t\t\tawait Xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false));\n\n\t\t\tcase IscCodes.op_trusted_auth:\n\t\t\t\treturn new Version11.AuthResponse(\n\t\t\t\t\tawait Xdr.ReadBufferAsync(cancellationToken).ConfigureAwait(false));\n\n\t\t\tcase IscCodes.op_crypt_key_callback:\n\t\t\t\tif (ProtocolVersion == IscCodes.PROTOCOL_VERSION15\n\t\t\t\t\t|| ProtocolVersion == IscCodes.PROTOCOL_VERSION16)\n\t\t\t\t{\n\t\t\t\t\treturn new Version15.CryptKeyCallbackResponse(\n\t\t\t\t\t\tawait Xdr.ReadBufferAsync(cancellationToken).ConfigureAwait(false),\n\t\t\t\t\t\tawait Xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false));\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn new Version13.CryptKeyCallbackResponse(\n\t\t\t\t\t\tawait Xdr.ReadBufferAsync(cancellationToken).ConfigureAwait(false));\n\t\t\t\t}\n\n\t\t\tcase IscCodes.op_cont_auth:\n\t\t\t\treturn new Version13.ContAuthResponse(\n\t\t\t\t\tawait Xdr.ReadBufferAsync(cancellationToken).ConfigureAwait(false),\n\t\t\t\t\tawait Xdr.ReadStringAsync(cancellationToken).ConfigureAwait(false),\n\t\t\t\t\tawait Xdr.ReadBooleanAsync(cancellationToken).ConfigureAwait(false),\n\t\t\t\t\tawait Xdr.ReadBufferAsync(cancellationToken).ConfigureAwait(false));\n\n\t\t\tcase IscCodes.op_batch_cs:\n\t\t\t\tvar statementHandle = await Xdr.ReadInt16Async().ConfigureAwait(false);\n\t\t\t\tvar p_batch_reccount = await Xdr.ReadInt32Async().ConfigureAwait(false);\n\t\t\t\tvar p_batch_updates = await Xdr.ReadInt32Async().ConfigureAwait(false);\n\t\t\t\tvar p_batch_vectors = await Xdr.ReadInt32Async().ConfigureAwait(false);\n\t\t\t\tvar p_batch_errors = await Xdr.ReadInt32Async().ConfigureAwait(false);\n\n\t\t\t\tvar p_batch_updates_data = new int[p_batch_updates];\n\t\t\t\tfor (var i = 0; i < p_batch_updates; i++)\n\t\t\t\t{\n\t\t\t\t\tp_batch_updates_data[i] = await Xdr.ReadInt32Async().ConfigureAwait(false);\n\t\t\t\t}\n\n\t\t\t\tvar p_batch_vectors_data = new (int messageNumber, IscException statusVector)[p_batch_vectors];\n\t\t\t\tfor (var i = 0; i < p_batch_vectors; i++)\n\t\t\t\t{\n\t\t\t\t\tvar messageNumber = await Xdr.ReadInt32Async().ConfigureAwait(false);\n\t\t\t\t\tvar statusVector = await Xdr.ReadStatusVectorAsync().ConfigureAwait(false);\n\t\t\t\t\tp_batch_vectors_data[i] = (messageNumber, statusVector);\n\t\t\t\t}\n\n\t\t\t\tvar p_batch_errors_data = new int[p_batch_errors];\n\t\t\t\tfor (var i = 0; i < p_batch_errors; i++)\n\t\t\t\t{\n\t\t\t\t\tp_batch_errors_data[i] = await Xdr.ReadInt32Async().ConfigureAwait(false);\n\t\t\t\t}\n\n\t\t\t\treturn new Version16.BatchCompletionStateResponse(\n\t\t\t\t\tstatementHandle,\n\t\t\t\t\tp_batch_reccount,\n\t\t\t\t\tp_batch_updates_data,\n\t\t\t\t\tp_batch_vectors_data,\n\t\t\t\t\tp_batch_errors_data);\n\n\t\t\tdefault:\n\t\t\t\tthrow new ArgumentOutOfRangeException(nameof(operation), $\"{nameof(operation)}={operation}\");\n\t\t}\n\t}\n\n\tinternal void StartCompression()\n\t{\n\t\t_firebirdNetworkHandlingWrapper.StartCompression();\n\t}\n\n\tinternal void StartEncryption()\n\t{\n\t\t_firebirdNetworkHandlingWrapper.StartEncryption(AuthBlock.SessionKey);\n\t}\n\n\tprivate static IPAddress GetIPAddress(string dataSource)\n\t{\n\t\tif (IPAddress.TryParse(dataSource, out var ipaddress))\n\t\t{\n\t\t\treturn ipaddress;\n\t\t}\n\n\t\tvar addresses = (Dns.GetHostEntry(dataSource)).AddressList;\n\t\tforeach (var address in addresses)\n\t\t{\n\t\t\t// IPv4 priority\n\t\t\tif (address.AddressFamily == AddressFamily.InterNetwork)\n\t\t\t{\n\t\t\t\treturn address;\n\t\t\t}\n\t\t}\n\t\treturn addresses[0];\n\t}\n\tprivate static async ValueTask<IPAddress> GetIPAddressAsync(string dataSource, CancellationToken cancellationToken = default)\n\t{\n\t\tif (IPAddress.TryParse(dataSource, out var ipaddress))\n\t\t{\n\t\t\treturn ipaddress;\n\t\t}\n\n\t\tvar addresses = (await Dns.GetHostEntryAsync(dataSource).ConfigureAwait(false)).AddressList;\n\t\tforeach (var address in addresses)\n\t\t{\n\t\t\t// IPv4 priority\n\t\t\tif (address.AddressFamily == AddressFamily.InterNetwork)\n\t\t\t{\n\t\t\t\treturn address;\n\t\t\t}\n\t\t}\n\t\treturn addresses[0];\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/GenericResponse.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed;\n\ninternal sealed class GenericResponse : IResponse\n{\n\tpublic int ObjectHandle { get; }\n\tpublic long BlobId { get; }\n\tpublic byte[] Data { get; }\n\tpublic IscException Exception { get; }\n\n\tpublic GenericResponse(int objectHandle, long blobId, byte[] data, IscException exception)\n\t{\n\t\tObjectHandle = objectHandle;\n\t\tBlobId = blobId;\n\t\tData = data;\n\t\tException = exception;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/IDataProvider.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace FirebirdSql.Data.Client.Managed;\n\ninterface IDataProvider\n{\n\tint Read(byte[] buffer, int offset, int count);\n\tValueTask<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default);\n\n\tvoid Write(byte[] buffer, int offset, int count);\n\tValueTask WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default);\n\n\tvoid Flush();\n\tValueTask FlushAsync(CancellationToken cancellationToken = default);\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/IResponse.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed;\n\ninterface IResponse\n{ }\n\nstatic class IResponseExtensions\n{\n\tpublic static void HandleResponseException(this IResponse response)\n\t{\n\t\tif (response is GenericResponse genericResponse)\n\t\t{\n\t\t\tif (genericResponse.Exception != null && !genericResponse.Exception.IsWarning)\n\t\t\t{\n\t\t\t\tthrow genericResponse.Exception;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static void HandleResponseWarning(this IResponse response, Action<IscException> onWarning)\n\t{\n\t\tif (response is GenericResponse genericResponse)\n\t\t{\n\t\t\tif (genericResponse.Exception != null && genericResponse.Exception.IsWarning)\n\t\t\t{\n\t\t\t\tonWarning?.Invoke(genericResponse.Exception);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/ITracksIOFailure.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nnamespace FirebirdSql.Data.Client.Managed;\n\ninterface ITracksIOFailure\n{\n\tbool IOFailed { get; set; }\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/IXdrReader.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Numerics;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.Types;\n\nnamespace FirebirdSql.Data.Client.Managed;\n\ninterface IXdrReader\n{\n\tbyte[] ReadBytes(byte[] buffer, int count);\n\tValueTask<byte[]> ReadBytesAsync(byte[] buffer, int count, CancellationToken cancellationToken = default);\n\n\tbyte[] ReadOpaque(int length);\n\tValueTask<byte[]> ReadOpaqueAsync(int length, CancellationToken cancellationToken = default);\n\n\tbyte[] ReadBuffer();\n\tValueTask<byte[]> ReadBufferAsync(CancellationToken cancellationToken = default);\n\n\tstring ReadString();\n\tValueTask<string> ReadStringAsync(CancellationToken cancellationToken = default);\n\n\tstring ReadString(int length);\n\tValueTask<string> ReadStringAsync(int length, CancellationToken cancellationToken = default);\n\n\tstring ReadString(Charset charset);\n\tValueTask<string> ReadStringAsync(Charset charset, CancellationToken cancellationToken = default);\n\n\tstring ReadString(Charset charset, int length);\n\tValueTask<string> ReadStringAsync(Charset charset, int length, CancellationToken cancellationToken = default);\n\n\tshort ReadInt16();\n\tValueTask<short> ReadInt16Async(CancellationToken cancellationToken = default);\n\n\tint ReadInt32();\n\tValueTask<int> ReadInt32Async(CancellationToken cancellationToken = default);\n\n\tlong ReadInt64();\n\tValueTask<long> ReadInt64Async(CancellationToken cancellationToken = default);\n\n\tGuid ReadGuid(int sqlType);\n\tValueTask<Guid> ReadGuidAsync(int sqlType, CancellationToken cancellationToken = default);\n\n\tfloat ReadSingle();\n\tValueTask<float> ReadSingleAsync(CancellationToken cancellationToken = default);\n\n\tdouble ReadDouble();\n\tValueTask<double> ReadDoubleAsync(CancellationToken cancellationToken = default);\n\n\tDateTime ReadDateTime();\n\tValueTask<DateTime> ReadDateTimeAsync(CancellationToken cancellationToken = default);\n\n\tDateTime ReadDate();\n\tValueTask<DateTime> ReadDateAsync(CancellationToken cancellationToken = default);\n\n\tTimeSpan ReadTime();\n\tValueTask<TimeSpan> ReadTimeAsync(CancellationToken cancellationToken = default);\n\n\tdecimal ReadDecimal(int type, int scale);\n\tValueTask<decimal> ReadDecimalAsync(int type, int scale, CancellationToken cancellationToken = default);\n\n\tbool ReadBoolean();\n\tValueTask<bool> ReadBooleanAsync(CancellationToken cancellationToken = default);\n\n\tFbZonedDateTime ReadZonedDateTime(bool isExtended);\n\tValueTask<FbZonedDateTime> ReadZonedDateTimeAsync(bool isExtended, CancellationToken cancellationToken = default);\n\n\tFbZonedTime ReadZonedTime(bool isExtended);\n\tValueTask<FbZonedTime> ReadZonedTimeAsync(bool isExtended, CancellationToken cancellationToken = default);\n\n\tFbDecFloat ReadDec16();\n\tValueTask<FbDecFloat> ReadDec16Async(CancellationToken cancellationToken = default);\n\n\tFbDecFloat ReadDec34();\n\tValueTask<FbDecFloat> ReadDec34Async(CancellationToken cancellationToken = default);\n\n\tBigInteger ReadInt128();\n\tValueTask<BigInteger> ReadInt128Async(CancellationToken cancellationToken = default);\n\n\tIscException ReadStatusVector();\n\tValueTask<IscException> ReadStatusVectorAsync(CancellationToken cancellationToken = default);\n\n\tint ReadOperation();\n\tValueTask<int> ReadOperationAsync(CancellationToken cancellationToken = default);\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/IXdrWriter.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Numerics;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Types;\n\nnamespace FirebirdSql.Data.Client.Managed;\n\ninterface IXdrWriter\n{\n\tvoid Flush();\n\tValueTask FlushAsync(CancellationToken cancellationToken = default);\n\n\tvoid WriteBytes(byte[] buffer, int count);\n\tValueTask WriteBytesAsync(byte[] buffer, int count, CancellationToken cancellationToken = default);\n\n\tvoid WriteOpaque(byte[] buffer);\n\tValueTask WriteOpaqueAsync(byte[] buffer, CancellationToken cancellationToken = default);\n\n\tvoid WriteOpaque(byte[] buffer, int length);\n\tValueTask WriteOpaqueAsync(byte[] buffer, int length, CancellationToken cancellationToken = default);\n\n\tvoid WriteBuffer(byte[] buffer);\n\tValueTask WriteBufferAsync(byte[] buffer, CancellationToken cancellationToken = default);\n\n\tvoid WriteBuffer(byte[] buffer, int length);\n\tValueTask WriteBufferAsync(byte[] buffer, int length, CancellationToken cancellationToken = default);\n\n\tvoid WriteBlobBuffer(byte[] buffer);\n\tValueTask WriteBlobBufferAsync(byte[] buffer, CancellationToken cancellationToken = default);\n\n\tvoid WriteTyped(int type, byte[] buffer);\n\tValueTask WriteTypedAsync(int type, byte[] buffer, CancellationToken cancellationToken = default);\n\n\tvoid Write(string value);\n\tValueTask WriteAsync(string value, CancellationToken cancellationToken = default);\n\n\tvoid Write(short value);\n\tValueTask WriteAsync(short value, CancellationToken cancellationToken = default);\n\n\tvoid Write(int value);\n\tValueTask WriteAsync(int value, CancellationToken cancellationToken = default);\n\n\tvoid Write(long value);\n\tValueTask WriteAsync(long value, CancellationToken cancellationToken = default);\n\n\tvoid Write(float value);\n\tValueTask WriteAsync(float value, CancellationToken cancellationToken = default);\n\n\tvoid Write(double value);\n\tValueTask WriteAsync(double value, CancellationToken cancellationToken = default);\n\n\tvoid Write(decimal value, int type, int scale);\n\tValueTask WriteAsync(decimal value, int type, int scale, CancellationToken cancellationToken = default);\n\n\tvoid Write(bool value);\n\tValueTask WriteAsync(bool value, CancellationToken cancellationToken = default);\n\n\tvoid Write(DateTime value);\n\tValueTask WriteAsync(DateTime value, CancellationToken cancellationToken = default);\n\n\tvoid Write(Guid value, int sqlType);\n\tValueTask WriteAsync(Guid value, int sqlType, CancellationToken cancellationToken = default);\n\n\tvoid Write(FbDecFloat value, int size);\n\tValueTask WriteAsync(FbDecFloat value, int size, CancellationToken cancellationToken = default);\n\n\tvoid Write(BigInteger value);\n\tValueTask WriteAsync(BigInteger value, CancellationToken cancellationToken = default);\n\n\tvoid WriteDate(DateTime value);\n\tValueTask WriteDateAsync(DateTime value, CancellationToken cancellationToken = default);\n\n\tvoid WriteTime(TimeSpan value);\n\tValueTask WriteTimeAsync(TimeSpan value, CancellationToken cancellationToken = default);\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/ProtocolsSupported.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed;\n\ninternal static class ProtocolsSupported\n{\n\tinternal class Protocol\n\t{\n\t\tpublic int Version { get; }\n\t\tpublic int MaxPType { get; }\n\n\t\tpublic Protocol(int version, int maxPType)\n\t\t{\n\t\t\tVersion = version;\n\t\t\tMaxPType = maxPType;\n\t\t}\n\t}\n\n\tpublic static ICollection<Protocol> Get(bool compression)\n\t{\n\t\treturn new[]\n\t\t{\n\t\t\t\tnew Protocol(IscCodes.PROTOCOL_VERSION10, IscCodes.ptype_batch_send),\n\t\t\t\tnew Protocol(IscCodes.PROTOCOL_VERSION11, IscCodes.ptype_lazy_send),\n\t\t\t\tnew Protocol(IscCodes.PROTOCOL_VERSION12, IscCodes.ptype_lazy_send),\n\t\t\t\tnew Protocol(IscCodes.PROTOCOL_VERSION13, IscCodes.ptype_lazy_send | (compression ? IscCodes.pflag_compress : 0)),\n\t\t\t\tnew Protocol(IscCodes.PROTOCOL_VERSION15, IscCodes.ptype_lazy_send | (compression ? IscCodes.pflag_compress : 0)),\n\t\t\t\tnew Protocol(IscCodes.PROTOCOL_VERSION16, IscCodes.ptype_lazy_send | (compression ? IscCodes.pflag_compress : 0)),\n\t\t\t};\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/SqlResponse.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed;\n\ninternal class SqlResponse : IResponse\n{\n\tpublic int Count { get; }\n\n\tpublic SqlResponse(int count)\n\t{\n\t\tCount = count;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Srp/Srp256Client.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Linq;\nusing System.Security.Cryptography;\n\nnamespace FirebirdSql.Data.Client.Managed.Srp;\n\ninternal sealed class Srp256Client : SrpClientBase\n{\n\tpublic override string Name => \"Srp256\";\n\n\tprotected override byte[] ComputeHash(params byte[][] ba)\n\t{\n\t\tusing (var hash = SHA256.Create())\n\t\t{\n\t\t\treturn hash.ComputeHash(ba.SelectMany(x => x).ToArray());\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Srp/SrpClient.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Linq;\nusing System.Security.Cryptography;\n\nnamespace FirebirdSql.Data.Client.Managed.Srp;\n\ninternal sealed class SrpClient : SrpClientBase\n{\n\tpublic override string Name => \"Srp\";\n\n\tprotected override byte[] ComputeHash(params byte[][] ba)\n\t{\n\t\tusing (var hash = SHA1.Create())\n\t\t{\n\t\t\treturn hash.ComputeHash(ba.SelectMany(x => x).ToArray());\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Srp/SrpClientBase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Hajime Nakagami (nakagami@gmail.com), Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Globalization;\nusing System.Linq;\nusing System.Numerics;\nusing System.Security.Cryptography;\nusing System.Text;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Srp;\n\n/// <remarks>\n/// http://srp.stanford.edu/design.html\n/// </remarks>\nabstract class SrpClientBase\n{\n\tpublic abstract string Name { get; }\n\n\tpublic string SessionKeyName { get; } = \"Symmetric\";\n\n\tprivate const int SRP_KEY_SIZE = 128;\n\tprivate const int SRP_SALT_SIZE = 32;\n\tprivate static readonly BigInteger N = BigInteger.Parse(\"00E67D2E994B2F900C3F41F08F5BB2627ED0D49EE1FE767A52EFCD565CD6E768812C3E1E9CE8F0A8BEA6CB13CD29DDEBF7A96D4A93B55D488DF099A15C89DCB0640738EB2CBDD9A8F7BAB561AB1B0DC1C6CDABF303264A08D1BCA932D1F1EE428B619D970F342ABA9A65793B8B2F041AE5364350C16F735F56ECBCA87BD57B29E7\", NumberStyles.HexNumber);\n\tprivate static readonly BigInteger g = new BigInteger(2);\n\tprivate static readonly BigInteger k = BigInteger.Parse(\"1277432915985975349439481660349303019122249719989\");\n\tprivate static readonly byte[] SEPARATOR_BYTES = Encoding.UTF8.GetBytes(\":\");\n\n\tpublic BigInteger PublicKey { get; } // A\n\tpublic string PublicKeyHex => Pad(PublicKey).ToHexString();\n\tpublic BigInteger PrivateKey { get; } // a\n\tpublic byte[] Proof { get; private set; } // M\n\tpublic byte[] SessionKey { get; private set; } // K\n\n\tpublic SrpClientBase()\n\t{\n\t\tPrivateKey = GetSecret();\n\t\tPublicKey = BigInteger.ModPow(g, PrivateKey, N);\n\t}\n\n\tpublic byte[] ClientProof(string user, string password, byte[] salt, BigInteger serverPublicKey)\n\t{\n\t\tvar K = GetClientSessionKey(user, password, salt, serverPublicKey);\n\n\t\tvar n1 = BigIntegerFromByteArray(ComputeSHA1Hash(BigIntegerToByteArray(N)));\n\t\tvar n2 = BigIntegerFromByteArray(ComputeSHA1Hash(BigIntegerToByteArray(g)));\n\n\t\tn1 = BigInteger.ModPow(n1, n2, N);\n\t\tn2 = BigIntegerFromByteArray(ComputeSHA1Hash(Encoding.UTF8.GetBytes(user)));\n\t\tvar M = ComputeHash(BigIntegerToByteArray(n1), BigIntegerToByteArray(n2), salt, BigIntegerToByteArray(PublicKey), BigIntegerToByteArray(serverPublicKey), K);\n\n\t\tSessionKey = K;\n\t\tProof = M;\n\n\t\treturn Proof;\n\t}\n\n\tpublic byte[] ClientProof(string user, string password, byte[] authData)\n\t{\n\t\tvar saltLength = authData[0] + authData[1] * 256;\n\t\tvar salt = new byte[saltLength];\n\t\tArray.Copy(authData, 2, salt, 0, saltLength);\n\n\t\tvar serverKeyStart = saltLength + 4;\n\t\tvar serverKeyLength = authData.Length - saltLength - 4;\n\t\tvar hexServerPublicKey = new byte[serverKeyLength];\n\t\tArray.Copy(authData, serverKeyStart, hexServerPublicKey, 0, serverKeyLength);\n\t\tvar hexServerPublicKeyString = Encoding.UTF8.GetString(hexServerPublicKey);\n\t\tvar serverPublicKey = BigInteger.Parse($\"00{hexServerPublicKeyString}\", NumberStyles.HexNumber);\n\t\treturn ClientProof(user, password, salt, serverPublicKey);\n\t}\n\n\tpublic (BigInteger, BigInteger) ServerSeed(string user, string password, byte[] salt)\n\t{\n\t\tvar v = BigInteger.ModPow(g, GetUserHash(user, password, salt), N);\n\t\tvar b = GetSecret();\n\t\tvar gb = BigInteger.ModPow(g, b, N);\n\t\tBigInteger.DivRem(k * v, N, out var kv);\n\t\tBigInteger.DivRem(BigInteger.Add(kv, gb), N, out var B);\n\t\treturn (B, b);\n\t}\n\n\tpublic byte[] GetServerSessionKey(string user, string password, byte[] salt, BigInteger A, BigInteger B, BigInteger b)\n\t{\n\t\tvar u = GetScramble(A, B);\n\t\tvar v = BigInteger.ModPow(g, GetUserHash(user, password, salt), N);\n\t\tvar vu = BigInteger.ModPow(v, u, N);\n\t\tBigInteger.DivRem(A * vu, N, out var Avu);\n\t\tvar sessionSecret = BigInteger.ModPow(Avu, b, N);\n\t\treturn ComputeSHA1Hash(BigIntegerToByteArray(sessionSecret));\n\t}\n\n\tpublic byte[] GetSalt()\n\t{\n\t\treturn GetRandomBytes(SRP_SALT_SIZE);\n\t}\n\n\tprivate BigInteger GetSecret()\n\t{\n\t\treturn new BigInteger(GetRandomBytes(SRP_KEY_SIZE / 8).Concat(new byte[] { 0 }).ToArray());\n\t}\n\n\tprivate byte[] GetClientSessionKey(string user, string password, byte[] salt, BigInteger serverPublicKey)\n\t{\n\t\tvar u = GetScramble(PublicKey, serverPublicKey);\n\t\tvar x = GetUserHash(user, password, salt);\n\t\tvar gx = BigInteger.ModPow(g, x, N);\n\t\tBigInteger.DivRem(k * gx, N, out var kgx);\n\t\tvar Bkgx = serverPublicKey - kgx;\n\t\tif (Bkgx < 0)\n\t\t{\n\t\t\tBkgx = Bkgx + N;\n\t\t}\n\t\tBigInteger.DivRem(Bkgx, N, out var diff);\n\t\tBigInteger.DivRem(u * x, N, out var ux);\n\t\tBigInteger.DivRem(PrivateKey + ux, N, out var aux);\n\t\tvar sessionSecret = BigInteger.ModPow(diff, aux, N);\n\t\treturn ComputeSHA1Hash(BigIntegerToByteArray(sessionSecret));\n\t}\n\n\tprotected abstract byte[] ComputeHash(params byte[][] ba);\n\n\tprivate static BigInteger GetUserHash(string user, string password, byte[] salt)\n\t{\n\t\tvar userBytes = Encoding.UTF8.GetBytes(user);\n\t\tvar passwordBytes = Encoding.UTF8.GetBytes(password);\n\t\tvar hash1 = ComputeSHA1Hash(userBytes, SEPARATOR_BYTES, passwordBytes);\n\t\tvar hash2 = ComputeSHA1Hash(salt, hash1);\n\t\treturn BigIntegerFromByteArray(hash2);\n\t}\n\n\tprivate static BigInteger BigIntegerFromByteArray(byte[] b)\n\t{\n\t\treturn new BigInteger(b.AsEnumerable().Reverse().Concat(new byte[] { 0 }).ToArray());\n\t}\n\n\tprivate static byte[] BigIntegerToByteArray(BigInteger n)\n\t{\n\t\treturn n.ToByteArray().AsEnumerable().Reverse().SkipWhile((e, i) => i == 0 && e == 0).ToArray();\n\t}\n\n\tprivate static byte[] ComputeSHA1Hash(params byte[][] ba)\n\t{\n\t\tusing (var hash = SHA1.Create())\n\t\t{\n\t\t\treturn hash.ComputeHash(ba.SelectMany(x => x).ToArray());\n\t\t}\n\t}\n\n\tprivate static byte[] Pad(BigInteger n)\n\t{\n\t\tvar bn = BigIntegerToByteArray(n);\n\t\treturn bn.SkipWhile((_, i) => i < bn.Length - SRP_KEY_SIZE).ToArray();\n\t}\n\n\tprivate static BigInteger GetScramble(BigInteger x, BigInteger y)\n\t{\n\t\treturn BigIntegerFromByteArray(ComputeSHA1Hash(Pad(x), Pad(y)));\n\t}\n\n\tprivate static byte[] GetRandomBytes(int count)\n\t{\n\t\tvar result = new byte[count];\n\t\tusing (var random = RandomNumberGenerator.Create())\n\t\t{\n\t\t\trandom.GetBytes(result);\n\t\t}\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Sspi/SspiHelper.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Vladimir Bodecek, Nathan Fox, Jiri Cincura (jiri@cincura.net)\n\n// Adapted from pinvoke.net\n\nusing System;\nusing System.Runtime.InteropServices;\n\nnamespace FirebirdSql.Data.Client.Managed.Sspi;\n\ninternal sealed class SspiHelper : IDisposable\n{\n\tpublic string Name { get; } = \"Win_Sspi\";\n\n\tprivate const int SECBUFFER_VERSION = 0;\n\n\tprivate enum SecBufferType\n\t{\n\t\tSECBUFFER_EMPTY = 0,\n\t\tSECBUFFER_DATA = 1,\n\t\tSECBUFFER_TOKEN = 2,\n\t}\n\n\t#region Structures used in native Win API calls\n\n\t[StructLayout(LayoutKind.Sequential)]\n\tpublic struct SecHandle\n\t{\n\t\tpublic IntPtr LowPart;\n\t\tpublic IntPtr HighPart;\n\n\t\tpublic SecHandle(int? dummy = null)\n\t\t{\n\t\t\tLowPart = IntPtr.Zero;\n\t\t\tHighPart = IntPtr.Zero;\n\t\t}\n\n\t\tpublic bool IsInvalid\n\t\t{\n\t\t\tget { return LowPart == IntPtr.Zero && HighPart == IntPtr.Zero; }\n\t\t}\n\t}\n\n\t[StructLayout(LayoutKind.Sequential)]\n\tpublic struct SecInteger\n\t{\n\t\tpublic uint LowPart;\n\t\tpublic int HighPart;\n\n\t\tpublic SecInteger(int? dummy = null)\n\t\t{\n\t\t\tLowPart = 0;\n\t\t\tHighPart = 0;\n\t\t}\n\t}\n\n\t[StructLayout(LayoutKind.Sequential)]\n\tprivate struct SecBuffer : IDisposable\n\t{\n\t\tprivate int cbBuffer;\n\t\tprivate int bufferType;\n\t\tprivate IntPtr pvBuffer;\n\n\t\tpublic SecBuffer(int bufferSize)\n\t\t{\n\t\t\tcbBuffer = bufferSize;\n\t\t\tbufferType = (int)SecBufferType.SECBUFFER_TOKEN;\n\t\t\tpvBuffer = Marshal.AllocHGlobal(bufferSize);\n\t\t}\n\n\t\tpublic SecBuffer(byte[] secBufferBytes)\n\t\t\t: this(secBufferBytes.Length)\n\t\t{\n\t\t\tMarshal.Copy(secBufferBytes, 0, pvBuffer, cbBuffer);\n\t\t}\n\n\t\tpublic SecBuffer(byte[] secBufferBytes, SecBufferType bufferType)\n\t\t\t: this(secBufferBytes)\n\t\t{\n\t\t\tthis.bufferType = (int)bufferType;\n\t\t}\n\n\t\tpublic void Dispose()\n\t\t{\n\t\t\tif (pvBuffer != IntPtr.Zero)\n\t\t\t{\n\t\t\t\tMarshal.FreeHGlobal(pvBuffer);\n\t\t\t\tpvBuffer = IntPtr.Zero;\n\t\t\t}\n\t\t}\n\n\t\tpublic byte[] GetBytes()\n\t\t{\n\t\t\tbyte[] buffer = null;\n\t\t\tif (cbBuffer > 0)\n\t\t\t{\n\t\t\t\tbuffer = new byte[cbBuffer];\n\t\t\t\tMarshal.Copy(pvBuffer, buffer, 0, cbBuffer);\n\t\t\t}\n\t\t\treturn buffer;\n\t\t}\n\t}\n\n\t[StructLayout(LayoutKind.Sequential)]\n\tprivate struct SecBufferDesc : IDisposable\n\t{\n\t\tpublic int ulVersion;\n\t\tpublic int cBuffers;\n\t\tpublic IntPtr pBuffers;\n\n\t\tpublic SecBufferDesc(int bufferSize)\n\t\t{\n\t\t\tulVersion = SECBUFFER_VERSION;\n\t\t\tcBuffers = 1;\n\t\t\tvar secBuffer = new SecBuffer(bufferSize);\n\t\t\tpBuffers = Marshal.AllocHGlobal(Marshal.SizeOf(secBuffer));\n\t\t\tMarshal.StructureToPtr(secBuffer, pBuffers, false);\n\t\t}\n\n\t\tpublic SecBufferDesc(byte[] secBufferBytes)\n\t\t{\n\t\t\tulVersion = SECBUFFER_VERSION;\n\t\t\tcBuffers = 1;\n\t\t\tvar secBuffer = new SecBuffer(secBufferBytes);\n\t\t\tpBuffers = Marshal.AllocHGlobal(Marshal.SizeOf(secBuffer));\n\t\t\tMarshal.StructureToPtr(secBuffer, pBuffers, false);\n\t\t}\n\n\t\tpublic void Dispose()\n\t\t{\n\t\t\tif (pBuffers != IntPtr.Zero)\n\t\t\t{\n\t\t\t\tvar secBuffer = Marshal.PtrToStructure<SecBuffer>(pBuffers);\n\t\t\t\tsecBuffer.Dispose();\n\t\t\t\tMarshal.FreeHGlobal(pBuffers);\n\t\t\t\tpBuffers = IntPtr.Zero;\n\t\t\t}\n\t\t}\n\n\t\tpublic byte[] GetSecBufferBytes()\n\t\t{\n\t\t\tif (pBuffers == IntPtr.Zero)\n\t\t\t\tthrow new ObjectDisposedException(nameof(SecBufferDesc));\n\t\t\tvar secBuffer = Marshal.PtrToStructure<SecBuffer>(pBuffers);\n\t\t\treturn secBuffer.GetBytes();\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Constants used in native Win API calls\n\n\tconst int TOKEN_QUERY = 0x00008;\n\n\tconst int SEC_E_OK = 0;\n\tconst int SEC_I_CONTINUE_NEEDED = 0x90312;\n\n\tconst int SECPKG_CRED_INBOUND = 1;\n\tconst int SECPKG_CRED_OUTBOUND = 2;\n\tconst int SECURITY_NATIVE_DREP = 0x10;\n\n\tconst int MAX_TOKEN_SIZE = 12288;\n\n\tconst int ISC_REQ_DELEGATE = 0x00000001;\n\tconst int ISC_REQ_MUTUAL_AUTH = 0x00000002;\n\tconst int ISC_REQ_REPLAY_DETECT = 0x00000004;\n\tconst int ISC_REQ_SEQUENCE_DETECT = 0x00000008;\n\tconst int ISC_REQ_CONFIDENTIALITY = 0x00000010;\n\tconst int ISC_REQ_USE_SESSION_KEY = 0x00000020;\n\tconst int ISC_REQ_PROMPT_FOR_CREDS = 0x00000040;\n\tconst int ISC_REQ_USE_SUPPLIED_CREDS = 0x00000080;\n\tconst int ISC_REQ_ALLOCATE_MEMORY = 0x00000100;\n\tconst int ISC_REQ_USE_DCE_STYLE = 0x00000200;\n\tconst int ISC_REQ_DATAGRAM = 0x00000400;\n\tconst int ISC_REQ_CONNECTION = 0x00000800;\n\tconst int ISC_REQ_CALL_LEVEL = 0x00001000;\n\tconst int ISC_REQ_FRAGMENT_SUPPLIED = 0x00002000;\n\tconst int ISC_REQ_EXTENDED_ERROR = 0x00004000;\n\tconst int ISC_REQ_STREAM = 0x00008000;\n\tconst int ISC_REQ_INTEGRITY = 0x00010000;\n\tconst int ISC_REQ_IDENTIFY = 0x00020000;\n\tconst int ISC_REQ_NULL_SESSION = 0x00040000;\n\tconst int ISC_REQ_MANUAL_CRED_VALIDATION = 0x00080000;\n\tconst int ISC_REQ_RESERVED1 = 0x00100000;\n\tconst int ISC_REQ_FRAGMENT_TO_FIT = 0x00200000;\n\n\tconst int SECPKG_ATTR_SIZES = 0;\n\n\tconst int STANDARD_CONTEXT_ATTRIBUTES = ISC_REQ_CONFIDENTIALITY | ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT | ISC_REQ_CONNECTION;\n\n\t#endregion\n\n\t#region Prototypes of native Win API functions\n\n\t[DllImport(\"secur32\")]\n\tstatic extern int AcquireCredentialsHandle(\n\t\tstring pszPrincipal, //SEC_CHAR*\n\t\tstring pszPackage, //SEC_CHAR* //\"Kerberos\",\"NTLM\",\"Negotiative\"\n\t\tint fCredentialUse,\n\t\tIntPtr PAuthenticationID,//_LUID AuthenticationID,//pvLogonID, //PLUID\n\t\tIntPtr pAuthData,//PVOID\n\t\tint pGetKeyFn, //SEC_GET_KEY_FN\n\t\tIntPtr pvGetKeyArgument, //PVOID\n\t\tout SecHandle phCredential, //SecHandle //PCtxtHandle ref\n\t\tout SecInteger ptsExpiry //PTimeStamp //TimeStamp ref\n\t);\n\n\t[DllImport(\"secur32\", SetLastError = true)]\n\tstatic extern int InitializeSecurityContext(\n\t\tref SecHandle phCredential,//PCredHandle\n\t\tIntPtr phContext, //PCtxtHandle\n\t\tstring pszTargetName,\n\t\tint fContextReq,\n\t\tint Reserved1,\n\t\tint TargetDataRep,\n\t\tIntPtr pInput, //PSecBufferDesc SecBufferDesc\n\t\tint Reserved2,\n\t\tout SecHandle phNewContext, //PCtxtHandle\n\t\tref SecBufferDesc pOutput, //PSecBufferDesc SecBufferDesc\n\t\tout uint pfContextAttr, //managed ulong == 64 bits!!!\n\t\tout SecInteger ptsExpiry //PTimeStamp\n\t);\n\n\t// 2 signatures of this API function needed because different usage\n\n\t[DllImport(\"secur32\", SetLastError = true)]\n\tstatic extern int InitializeSecurityContext(\n\t\tref SecHandle phCredential,//PCredHandle\n\t\tref SecHandle phContext, //PCtxtHandle\n\t\tstring pszTargetName,\n\t\tint fContextReq,\n\t\tint Reserved1,\n\t\tint TargetDataRep,\n\t\tref SecBufferDesc SecBufferDesc, //PSecBufferDesc SecBufferDesc\n\t\tint Reserved2,\n\t\tout SecHandle phNewContext, //PCtxtHandle\n\t\tref SecBufferDesc pOutput, //PSecBufferDesc SecBufferDesc\n\t\tout uint pfContextAttr, //managed ulong == 64 bits!!!\n\t\tout SecInteger ptsExpiry //PTimeStamp\n\t);\n\n\t[DllImport(\"secur32\")]\n\tstatic extern int FreeCredentialsHandle(ref SecHandle phCredential); //PCredHandle\n\n\t[DllImport(\"secur32\")]\n\tstatic extern int DeleteSecurityContext(ref SecHandle phContext); //PCtxtHandle\n\n\t#endregion\n\n\t#region Private members\n\n\tprivate SecHandle _clientCredentials;\n\tprivate SecHandle _clientContext;\n\tprivate bool _disposed;\n\n\tprivate string _securityPackage;\n\tprivate string _remotePrincipal;\n\n\t#endregion\n\n\t#region Constructors\n\n\t/// <summary>\n\t/// Creates SSPIHelper with default \"NTLM\" security package and no remote principal and gets client credentials\n\t/// </summary>\n\tpublic SspiHelper()\n\t\t: this(\"NTLM\")\n\t{ }\n\n\t/// <summary>\n\t/// Creates SSPIHelper with given security package and no remote principal and gets client credentials\n\t/// </summary>\n\t/// <param name=\"securityPackage\">Name of security package (e.g. NTLM, Kerberos, ...)</param>\n\tpublic SspiHelper(string securityPackage)\n\t\t: this(securityPackage, null)\n\t{ }\n\n\t/// <summary>\n\t/// Creates SSPIHelper with given security package and remote principal and gets client credentials\n\t/// </summary>\n\t/// <param name=\"securityPackage\">Name of security package (e.g. NTLM, Kerberos, ...)</param>\n\t/// <param name=\"remotePrincipal\">SPN of server (may be necessary for Kerberos</param>\n\tpublic SspiHelper(string securityPackage, string remotePrincipal)\n\t{\n\t\t_securityPackage = securityPackage;\n\t\t_remotePrincipal = remotePrincipal;\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\t/// <summary>\n\t/// Creates client security context and returns \"client token\"\n\t/// </summary>\n\t/// <returns>Client authentication data to be sent to server</returns>\n\tpublic byte[] InitializeClientSecurity()\n\t{\n\t\tEnsureDisposed();\n\t\tCloseClientContext();\n\t\tInitializeClientCredentials();\n\t\t_clientContext = new SecHandle();\n\t\tvar clientTokenBuf = new SecBufferDesc(MAX_TOKEN_SIZE);\n\t\ttry\n\t\t{\n\t\t\tvar resCode = InitializeSecurityContext(\n\t\t\t\tref _clientCredentials,\n\t\t\t\tIntPtr.Zero,\n\t\t\t\t_remotePrincipal,\n\t\t\t\tSTANDARD_CONTEXT_ATTRIBUTES,\n\t\t\t\t0,\n\t\t\t\tSECURITY_NATIVE_DREP,\n\t\t\t\tIntPtr.Zero,\n\t\t\t\t0,\n\t\t\t\tout _clientContext,\n\t\t\t\tref clientTokenBuf,\n\t\t\t\tout var contextAttributes,\n\t\t\t\tout var expiry);\n\t\t\tif (resCode != SEC_E_OK && resCode != SEC_I_CONTINUE_NEEDED)\n\t\t\t\tthrow new Exception($\"{nameof(InitializeSecurityContext)} failed\");\n\t\t\treturn clientTokenBuf.GetSecBufferBytes();\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tclientTokenBuf.Dispose();\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Creates client authentication data based on already existing security context and\n\t/// authentication data sent by server\n\t/// This method must not be called before InitializeClientSecurity\n\t/// </summary>\n\t/// <param name=\"serverToken\">Authentication data received from server</param>\n\t/// <returns>Client authentication data to be sent to server</returns>\n\tpublic byte[] GetClientSecurity(byte[] serverToken)\n\t{\n\t\tEnsureDisposed();\n\t\tif (_clientContext.IsInvalid)\n\t\t\tthrow new InvalidOperationException($\"{nameof(InitializeClientSecurity)} not called\");\n\t\tvar clientTokenBuf = new SecBufferDesc(MAX_TOKEN_SIZE);\n\t\ttry\n\t\t{\n\t\t\tvar serverTokenBuf = new SecBufferDesc(serverToken);\n\t\t\ttry\n\t\t\t{\n\t\t\t\tvar resCode = InitializeSecurityContext(\n\t\t\t\t\tref _clientCredentials,\n\t\t\t\t\tref _clientContext,\n\t\t\t\t\t_remotePrincipal,\n\t\t\t\t\tSTANDARD_CONTEXT_ATTRIBUTES,\n\t\t\t\t\t0,\n\t\t\t\t\tSECURITY_NATIVE_DREP,\n\t\t\t\t\tref serverTokenBuf,\n\t\t\t\t\t0,\n\t\t\t\t\tout _clientContext,\n\t\t\t\t\tref clientTokenBuf,\n\t\t\t\t\tout var contextAttributes,\n\t\t\t\t\tout var expiry);\n\t\t\t\tif (resCode != SEC_E_OK && resCode != SEC_I_CONTINUE_NEEDED)\n\t\t\t\t\tthrow new Exception($\"{nameof(InitializeSecurityContext)} failed\");\n\t\t\t\treturn clientTokenBuf.GetSecBufferBytes();\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tserverTokenBuf.Dispose();\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tclientTokenBuf.Dispose();\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Finalizer\n\n\t~SspiHelper()\n\t{\n\t\tDispose(false);\n\t}\n\n\t#endregion\n\n\t#region IDisposable Members\n\n\tpublic void Dispose()\n\t{\n\t\tDispose(true);\n\t\tGC.SuppressFinalize(this);\n\t}\n\n\t#endregion\n\n\t#region Private methods\n\n\tprivate void Dispose(bool disposing)\n\t{\n\t\tif (!_disposed)\n\t\t{\n\t\t\t_disposed = true;\n\t\t\tCloseClientContext();\n\t\t\tCloseClientCredentials();\n\t\t}\n\t}\n\n\tprivate void InitializeClientCredentials()\n\t{\n\t\t_clientCredentials = new SecHandle();\n\t\tvar resCode = AcquireCredentialsHandle(null, _securityPackage, SECPKG_CRED_OUTBOUND,\n\t\t\tIntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero,\n\t\t\tout _clientCredentials, out var expiry);\n\t\tif (resCode != SEC_E_OK)\n\t\t\tthrow new Exception($\"{nameof(AcquireCredentialsHandle)} failed\");\n\t}\n\n\tprivate void CloseClientContext()\n\t{\n\t\tif (!_clientContext.IsInvalid)\n\t\t\tDeleteSecurityContext(ref _clientContext);\n\t}\n\n\tprivate void CloseClientCredentials()\n\t{\n\t\tif (!_clientCredentials.IsInvalid)\n\t\t\tFreeCredentialsHandle(ref _clientCredentials);\n\t}\n\n\tprivate void EnsureDisposed()\n\t{\n\t\tif (_disposed)\n\t\t\tthrow new ObjectDisposedException(nameof(SspiHelper));\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version10/GdsArray.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Globalization;\nusing System.IO;\nusing System.Reflection;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version10;\n\ninternal sealed class GdsArray : ArrayBase\n{\n\tconst long ArrayHandle = 0;\n\n\t#region Fields\n\n\tprivate long _handle;\n\tprivate GdsDatabase _database;\n\tprivate GdsTransaction _transaction;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic override long Handle\n\t{\n\t\tget { return _handle; }\n\t\tset { _handle = value; }\n\t}\n\n\tpublic override DatabaseBase Database\n\t{\n\t\tget { return _database; }\n\t\tset { _database = (GdsDatabase)value; }\n\t}\n\n\tpublic override TransactionBase Transaction\n\t{\n\t\tget { return _transaction; }\n\t\tset { _transaction = (GdsTransaction)value; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic GdsArray(ArrayDesc descriptor)\n\t\t: base(descriptor)\n\t{ }\n\n\tpublic GdsArray(GdsDatabase database, GdsTransaction transaction, string tableName, string fieldName)\n\t\t: this(database, transaction, -1, tableName, fieldName)\n\t{ }\n\n\tpublic GdsArray(GdsDatabase database, GdsTransaction transaction, long handle, string tableName, string fieldName)\n\t\t: base(tableName, fieldName)\n\t{\n\t\t_database = database;\n\t\t_transaction = transaction;\n\t\t_handle = handle;\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic override byte[] GetSlice(int sliceLength)\n\t{\n\t\ttry\n\t\t{\n\t\t\tvar sdl = GenerateSDL(Descriptor);\n\n\t\t\t_database.Xdr.Write(IscCodes.op_get_slice);\n\t\t\t_database.Xdr.Write(_transaction.Handle);\n\t\t\t_database.Xdr.Write(_handle);\n\t\t\t_database.Xdr.Write(sliceLength);\n\t\t\t_database.Xdr.WriteBuffer(sdl);\n\t\t\t_database.Xdr.Write(string.Empty);\n\t\t\t_database.Xdr.Write(0);\n\t\t\t_database.Xdr.Flush();\n\n\t\t\treturn ReceiveSliceResponse(Descriptor);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask<byte[]> GetSliceAsync(int sliceLength, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tvar sdl = GenerateSDL(Descriptor);\n\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_get_slice, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_transaction.Handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(sliceLength, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteBufferAsync(sdl, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(string.Empty, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(0, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\treturn await ReceiveSliceResponseAsync(Descriptor, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override void PutSlice(Array sourceArray, int sliceLength)\n\t{\n\t\ttry\n\t\t{\n\t\t\tvar sdl = GenerateSDL(Descriptor);\n\t\t\tvar slice = EncodeSliceArray(sourceArray);\n\n\t\t\t_database.Xdr.Write(IscCodes.op_put_slice);\n\t\t\t_database.Xdr.Write(_transaction.Handle);\n\t\t\t_database.Xdr.Write(ArrayHandle);\n\t\t\t_database.Xdr.Write(sliceLength);\n\t\t\t_database.Xdr.WriteBuffer(sdl);\n\t\t\t_database.Xdr.Write(string.Empty);\n\t\t\t_database.Xdr.Write(sliceLength);\n\t\t\t_database.Xdr.WriteBytes(slice, slice.Length);\n\t\t\t_database.Xdr.Flush();\n\n\t\t\tvar response = (GenericResponse)_database.ReadResponse();\n\n\t\t\t_handle = response.BlobId;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask PutSliceAsync(Array sourceArray, int sliceLength, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tvar sdl = GenerateSDL(Descriptor);\n\t\t\tvar slice = await EncodeSliceArrayAsync(sourceArray, cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_put_slice, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_transaction.Handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(ArrayHandle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(sliceLength, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteBufferAsync(sdl, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(string.Empty, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(sliceLength, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteBytesAsync(slice, slice.Length, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar response = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t_handle = response.BlobId;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Protected Methods\n\n\tprotected override Array DecodeSlice(byte[] slice)\n\t{\n\t\tvar dbType = DbDataType.Array;\n\t\tArray sliceData = null;\n\t\tArray tempData = null;\n\t\tvar systemType = GetSystemType();\n\t\tvar lengths = new int[Descriptor.Dimensions];\n\t\tvar lowerBounds = new int[Descriptor.Dimensions];\n\t\tvar type = 0;\n\t\tvar index = 0;\n\n\t\tfor (var i = 0; i < Descriptor.Dimensions; i++)\n\t\t{\n\t\t\tlowerBounds[i] = Descriptor.Bounds[i].LowerBound;\n\t\t\tlengths[i] = Descriptor.Bounds[i].UpperBound;\n\n\t\t\tif (lowerBounds[i] == 0)\n\t\t\t{\n\t\t\t\tlengths[i]++;\n\t\t\t}\n\t\t}\n\n\t\tsliceData = Array.CreateInstance(systemType, lengths, lowerBounds);\n\t\ttempData = Array.CreateInstance(systemType, sliceData.Length);\n\n\t\ttype = TypeHelper.GetSqlTypeFromBlrType(Descriptor.DataType);\n\t\tdbType = TypeHelper.GetDbDataTypeFromBlrType(Descriptor.DataType, 0, Descriptor.Scale);\n\n\t\tusing (var ms = new MemoryStream(slice))\n\t\t{\n\t\t\tvar xdr = new XdrReaderWriter(new DataProviderStreamWrapper(ms), _database.Charset);\n\t\t\twhile (ms.Position < ms.Length)\n\t\t\t{\n\t\t\t\tswitch (dbType)\n\t\t\t\t{\n\t\t\t\t\tcase DbDataType.Char:\n\t\t\t\t\t\ttempData.SetValue(xdr.ReadString(Descriptor.Length), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.VarChar:\n\t\t\t\t\t\ttempData.SetValue(xdr.ReadString(), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.SmallInt:\n\t\t\t\t\t\ttempData.SetValue(xdr.ReadInt16(), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Integer:\n\t\t\t\t\t\ttempData.SetValue(xdr.ReadInt32(), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.BigInt:\n\t\t\t\t\t\ttempData.SetValue(xdr.ReadInt64(), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Numeric:\n\t\t\t\t\tcase DbDataType.Decimal:\n\t\t\t\t\t\ttempData.SetValue(xdr.ReadDecimal(type, Descriptor.Scale), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Float:\n\t\t\t\t\t\ttempData.SetValue(xdr.ReadSingle(), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Double:\n\t\t\t\t\t\ttempData.SetValue(xdr.ReadDouble(), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Date:\n\t\t\t\t\t\ttempData.SetValue(xdr.ReadDate(), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Time:\n\t\t\t\t\t\ttempData.SetValue(xdr.ReadTime(), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\t\t\ttempData.SetValue(xdr.ReadDateTime(), index);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tindex++;\n\t\t\t}\n\n\t\t\tif (systemType.GetTypeInfo().IsPrimitive)\n\t\t\t{\n\t\t\t\t// For primitive types we can use System.Buffer\tto copy\tgenerated data to destination array\n\t\t\t\tBuffer.BlockCopy(tempData, 0, sliceData, 0, Buffer.ByteLength(tempData));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tsliceData = tempData;\n\t\t\t}\n\t\t}\n\n\t\treturn sliceData;\n\t}\n\tprotected override async ValueTask<Array> DecodeSliceAsync(byte[] slice, CancellationToken cancellationToken = default)\n\t{\n\t\tvar dbType = DbDataType.Array;\n\t\tArray sliceData = null;\n\t\tArray tempData = null;\n\t\tvar systemType = GetSystemType();\n\t\tvar lengths = new int[Descriptor.Dimensions];\n\t\tvar lowerBounds = new int[Descriptor.Dimensions];\n\t\tvar type = 0;\n\t\tvar index = 0;\n\n\t\tfor (var i = 0; i < Descriptor.Dimensions; i++)\n\t\t{\n\t\t\tlowerBounds[i] = Descriptor.Bounds[i].LowerBound;\n\t\t\tlengths[i] = Descriptor.Bounds[i].UpperBound;\n\n\t\t\tif (lowerBounds[i] == 0)\n\t\t\t{\n\t\t\t\tlengths[i]++;\n\t\t\t}\n\t\t}\n\n\t\tsliceData = Array.CreateInstance(systemType, lengths, lowerBounds);\n\t\ttempData = Array.CreateInstance(systemType, sliceData.Length);\n\n\t\ttype = TypeHelper.GetSqlTypeFromBlrType(Descriptor.DataType);\n\t\tdbType = TypeHelper.GetDbDataTypeFromBlrType(Descriptor.DataType, 0, Descriptor.Scale);\n\n\t\tusing (var ms = new MemoryStream(slice))\n\t\t{\n\t\t\tvar xdr = new XdrReaderWriter(new DataProviderStreamWrapper(ms), _database.Charset);\n\t\t\twhile (ms.Position < ms.Length)\n\t\t\t{\n\t\t\t\tswitch (dbType)\n\t\t\t\t{\n\t\t\t\t\tcase DbDataType.Char:\n\t\t\t\t\t\ttempData.SetValue(await xdr.ReadStringAsync(Descriptor.Length, cancellationToken).ConfigureAwait(false), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.VarChar:\n\t\t\t\t\t\ttempData.SetValue(await xdr.ReadStringAsync(cancellationToken).ConfigureAwait(false), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.SmallInt:\n\t\t\t\t\t\ttempData.SetValue(await xdr.ReadInt16Async(cancellationToken).ConfigureAwait(false), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Integer:\n\t\t\t\t\t\ttempData.SetValue(await xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.BigInt:\n\t\t\t\t\t\ttempData.SetValue(await xdr.ReadInt64Async(cancellationToken).ConfigureAwait(false), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Numeric:\n\t\t\t\t\tcase DbDataType.Decimal:\n\t\t\t\t\t\ttempData.SetValue(await xdr.ReadDecimalAsync(type, Descriptor.Scale, cancellationToken).ConfigureAwait(false), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Float:\n\t\t\t\t\t\ttempData.SetValue(await xdr.ReadSingleAsync(cancellationToken).ConfigureAwait(false), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Double:\n\t\t\t\t\t\ttempData.SetValue(await xdr.ReadDoubleAsync(cancellationToken).ConfigureAwait(false), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Date:\n\t\t\t\t\t\ttempData.SetValue(await xdr.ReadDateAsync(cancellationToken).ConfigureAwait(false), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Time:\n\t\t\t\t\t\ttempData.SetValue(await xdr.ReadTimeAsync(cancellationToken).ConfigureAwait(false), index);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\t\t\ttempData.SetValue(await xdr.ReadDateTimeAsync(cancellationToken).ConfigureAwait(false), index);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tindex++;\n\t\t\t}\n\n\t\t\tif (systemType.GetTypeInfo().IsPrimitive)\n\t\t\t{\n\t\t\t\t// For primitive types we can use System.Buffer\tto copy\tgenerated data to destination array\n\t\t\t\tBuffer.BlockCopy(tempData, 0, sliceData, 0, Buffer.ByteLength(tempData));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tsliceData = tempData;\n\t\t\t}\n\t\t}\n\n\t\treturn sliceData;\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate byte[] ReceiveSliceResponse(ArrayDesc desc)\n\t{\n\t\ttry\n\t\t{\n\t\t\tvar operation = _database.ReadOperation();\n\t\t\tif (operation == IscCodes.op_slice)\n\t\t\t{\n\t\t\t\tvar isVariying = false;\n\t\t\t\tvar elements = 0;\n\t\t\t\tvar length = _database.Xdr.ReadInt32();\n\n\t\t\t\tlength = _database.Xdr.ReadInt32();\n\n\t\t\t\tswitch (desc.DataType)\n\t\t\t\t{\n\t\t\t\t\tcase IscCodes.blr_text:\n\t\t\t\t\tcase IscCodes.blr_text2:\n\t\t\t\t\tcase IscCodes.blr_cstring:\n\t\t\t\t\tcase IscCodes.blr_cstring2:\n\t\t\t\t\t\telements = length / desc.Length;\n\t\t\t\t\t\tlength += elements * ((4 - desc.Length) & 3);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.blr_varying:\n\t\t\t\t\tcase IscCodes.blr_varying2:\n\t\t\t\t\t\telements = length / desc.Length;\n\t\t\t\t\t\tisVariying = true;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.blr_short:\n\t\t\t\t\t\tlength = length * desc.Length;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (isVariying)\n\t\t\t\t{\n\t\t\t\t\tusing (var ms = new MemoryStream())\n\t\t\t\t\t{\n\t\t\t\t\t\tvar xdr = new XdrReaderWriter(new DataProviderStreamWrapper(ms));\n\t\t\t\t\t\tfor (var i = 0; i < elements; i++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvar buffer = _database.Xdr.ReadOpaque(_database.Xdr.ReadInt32());\n\t\t\t\t\t\t\txdr.WriteBuffer(buffer, buffer.Length);\n\t\t\t\t\t\t}\n\t\t\t\t\t\txdr.Flush();\n\t\t\t\t\t\treturn ms.ToArray();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn _database.Xdr.ReadOpaque(length);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_database.ReadResponse(operation);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tprivate async ValueTask<byte[]> ReceiveSliceResponseAsync(ArrayDesc desc, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tvar operation = await _database.ReadOperationAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tif (operation == IscCodes.op_slice)\n\t\t\t{\n\t\t\t\tvar isVariying = false;\n\t\t\t\tvar elements = 0;\n\t\t\t\tvar length = await _database.Xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tlength = await _database.Xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tswitch (desc.DataType)\n\t\t\t\t{\n\t\t\t\t\tcase IscCodes.blr_text:\n\t\t\t\t\tcase IscCodes.blr_text2:\n\t\t\t\t\tcase IscCodes.blr_cstring:\n\t\t\t\t\tcase IscCodes.blr_cstring2:\n\t\t\t\t\t\telements = length / desc.Length;\n\t\t\t\t\t\tlength += elements * ((4 - desc.Length) & 3);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.blr_varying:\n\t\t\t\t\tcase IscCodes.blr_varying2:\n\t\t\t\t\t\telements = length / desc.Length;\n\t\t\t\t\t\tisVariying = true;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.blr_short:\n\t\t\t\t\t\tlength = length * desc.Length;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (isVariying)\n\t\t\t\t{\n\t\t\t\t\tusing (var ms = new MemoryStream())\n\t\t\t\t\t{\n\t\t\t\t\t\tvar xdr = new XdrReaderWriter(new DataProviderStreamWrapper(ms));\n\t\t\t\t\t\tfor (var i = 0; i < elements; i++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvar buffer = await _database.Xdr.ReadOpaqueAsync(await _database.Xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\tawait xdr.WriteBufferAsync(buffer, buffer.Length, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\treturn ms.ToArray();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn await _database.Xdr.ReadOpaqueAsync(length, cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tawait _database.ReadResponseAsync(operation, cancellationToken).ConfigureAwait(false);\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tprivate byte[] EncodeSliceArray(Array sourceArray)\n\t{\n\t\tvar dbType = DbDataType.Array;\n\t\tvar charset = _database.Charset;\n\t\tvar subType = (Descriptor.Scale < 0) ? 2 : 0;\n\t\tvar type = 0;\n\n\t\tusing (var ms = new MemoryStream())\n\t\t{\n\t\t\tvar xdr = new XdrReaderWriter(new DataProviderStreamWrapper(ms), _database.Charset);\n\n\t\t\ttype = TypeHelper.GetSqlTypeFromBlrType(Descriptor.DataType);\n\t\t\tdbType = TypeHelper.GetDbDataTypeFromBlrType(Descriptor.DataType, subType, Descriptor.Scale);\n\n\t\t\tforeach (var source in sourceArray)\n\t\t\t{\n\t\t\t\tswitch (dbType)\n\t\t\t\t{\n\t\t\t\t\tcase DbDataType.Char:\n\t\t\t\t\t\tvar buffer = charset.GetBytes(source.ToString());\n\t\t\t\t\t\txdr.WriteOpaque(buffer, Descriptor.Length);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.VarChar:\n\t\t\t\t\t\txdr.Write((string)source);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.SmallInt:\n\t\t\t\t\t\txdr.Write((short)source);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Integer:\n\t\t\t\t\t\txdr.Write((int)source);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.BigInt:\n\t\t\t\t\t\txdr.Write((long)source);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Decimal:\n\t\t\t\t\tcase DbDataType.Numeric:\n\t\t\t\t\t\txdr.Write((decimal)source, type, Descriptor.Scale);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Float:\n\t\t\t\t\t\txdr.Write((float)source);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Double:\n\t\t\t\t\t\txdr.Write((double)source);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Date:\n\t\t\t\t\t\txdr.WriteDate(Convert.ToDateTime(source, CultureInfo.CurrentCulture.DateTimeFormat));\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Time:\n\t\t\t\t\t\txdr.WriteTime((TimeSpan)source);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\t\t\txdr.Write(Convert.ToDateTime(source, CultureInfo.CurrentCulture.DateTimeFormat));\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow TypeHelper.InvalidDataType((int)dbType);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\txdr.Flush();\n\t\t\treturn ms.ToArray();\n\t\t}\n\t}\n\tprivate async ValueTask<byte[]> EncodeSliceArrayAsync(Array sourceArray, CancellationToken cancellationToken = default)\n\t{\n\t\tvar dbType = DbDataType.Array;\n\t\tvar charset = _database.Charset;\n\t\tvar subType = (Descriptor.Scale < 0) ? 2 : 0;\n\t\tvar type = 0;\n\n\t\tusing (var ms = new MemoryStream())\n\t\t{\n\t\t\tvar xdr = new XdrReaderWriter(new DataProviderStreamWrapper(ms), _database.Charset);\n\n\t\t\ttype = TypeHelper.GetSqlTypeFromBlrType(Descriptor.DataType);\n\t\t\tdbType = TypeHelper.GetDbDataTypeFromBlrType(Descriptor.DataType, subType, Descriptor.Scale);\n\n\t\t\tforeach (var source in sourceArray)\n\t\t\t{\n\t\t\t\tswitch (dbType)\n\t\t\t\t{\n\t\t\t\t\tcase DbDataType.Char:\n\t\t\t\t\t\tvar buffer = charset.GetBytes(source.ToString());\n\t\t\t\t\t\tawait xdr.WriteOpaqueAsync(buffer, Descriptor.Length, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.VarChar:\n\t\t\t\t\t\tawait xdr.WriteAsync((string)source, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.SmallInt:\n\t\t\t\t\t\tawait xdr.WriteAsync((short)source, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Integer:\n\t\t\t\t\t\tawait xdr.WriteAsync((int)source, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.BigInt:\n\t\t\t\t\t\tawait xdr.WriteAsync((long)source, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Decimal:\n\t\t\t\t\tcase DbDataType.Numeric:\n\t\t\t\t\t\tawait xdr.WriteAsync((decimal)source, type, Descriptor.Scale, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Float:\n\t\t\t\t\t\tawait xdr.WriteAsync((float)source, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Double:\n\t\t\t\t\t\tawait xdr.WriteAsync((double)source, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Date:\n\t\t\t\t\t\tawait xdr.WriteDateAsync(Convert.ToDateTime(source, CultureInfo.CurrentCulture.DateTimeFormat), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.Time:\n\t\t\t\t\t\tawait xdr.WriteTimeAsync((TimeSpan)source, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\t\t\tawait xdr.WriteAsync(Convert.ToDateTime(source, CultureInfo.CurrentCulture.DateTimeFormat), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow TypeHelper.InvalidDataType((int)dbType);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\treturn ms.ToArray();\n\t\t}\n\t}\n\n\tprivate byte[] GenerateSDL(ArrayDesc desc)\n\t{\n\t\tint n;\n\t\tint from;\n\t\tint to;\n\t\tint increment;\n\t\tint dimensions;\n\t\tArrayBound tail;\n\t\tBinaryWriter sdl;\n\n\t\tdimensions = desc.Dimensions;\n\n\t\tif (dimensions > 16)\n\t\t{\n\t\t\tthrow IscException.ForErrorCode(IscCodes.isc_invalid_dimension);\n\t\t}\n\n\t\tsdl = new BinaryWriter(new MemoryStream());\n\t\tStuff(\n\t\t\tsdl, 4, IscCodes.isc_sdl_version1,\n\t\t\tIscCodes.isc_sdl_struct, 1, desc.DataType);\n\n\t\tswitch (desc.DataType)\n\t\t{\n\t\t\tcase IscCodes.blr_short:\n\t\t\tcase IscCodes.blr_long:\n\t\t\tcase IscCodes.blr_int64:\n\t\t\tcase IscCodes.blr_quad:\n\t\t\t\tStuffSdl(sdl, (byte)desc.Scale);\n\t\t\t\tbreak;\n\n\t\t\tcase IscCodes.blr_text:\n\t\t\tcase IscCodes.blr_cstring:\n\t\t\tcase IscCodes.blr_varying:\n\t\t\t\tStuffWord(sdl, desc.Length);\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\n\t\tStuffString(sdl, IscCodes.isc_sdl_relation, desc.RelationName);\n\t\tStuffString(sdl, IscCodes.isc_sdl_field, desc.FieldName);\n\n\t\tif ((desc.Flags & IscCodes.ARRAY_DESC_COLUMN_MAJOR) == IscCodes.ARRAY_DESC_COLUMN_MAJOR)\n\t\t{\n\t\t\tfrom = dimensions - 1;\n\t\t\tto = -1;\n\t\t\tincrement = -1;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfrom = 0;\n\t\t\tto = dimensions;\n\t\t\tincrement = 1;\n\t\t}\n\n\t\tfor (n = from; n != to; n += increment)\n\t\t{\n\t\t\ttail = desc.Bounds[n];\n\t\t\tif (tail.LowerBound == 1)\n\t\t\t{\n\t\t\t\tStuff(sdl, 2, IscCodes.isc_sdl_do1, n);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tStuff(sdl, 2, IscCodes.isc_sdl_do2, n);\n\n\t\t\t\tStuffLiteral(sdl, tail.LowerBound);\n\t\t\t}\n\n\t\t\tStuffLiteral(sdl, tail.UpperBound);\n\t\t}\n\n\t\tStuff(sdl, 5, IscCodes.isc_sdl_element, 1, IscCodes.isc_sdl_scalar, 0, dimensions);\n\n\t\tfor (n = 0; n < dimensions; n++)\n\t\t{\n\t\t\tStuff(sdl, 2, IscCodes.isc_sdl_variable, n);\n\t\t}\n\n\t\tStuffSdl(sdl, IscCodes.isc_sdl_eoc);\n\n\t\treturn ((MemoryStream)sdl.BaseStream).ToArray();\n\t}\n\n\tprivate void Stuff(BinaryWriter sdl, short count, params object[] args)\n\t{\n\t\tfor (var i = 0; i < count; i++)\n\t\t{\n\t\t\tsdl.Write(Convert.ToByte(args[i], CultureInfo.InvariantCulture));\n\t\t}\n\t}\n\n\tprivate void Stuff(BinaryWriter sdl, byte[] args)\n\t{\n\t\tsdl.Write(args);\n\t}\n\n\tprivate void StuffSdl(BinaryWriter sdl, byte sdl_byte)\n\t{\n\t\tStuff(sdl, 1, sdl_byte);\n\t}\n\n\tprivate void StuffWord(BinaryWriter sdl, short word)\n\t{\n\t\tStuff(sdl, BitConverter.GetBytes(word));\n\t}\n\n\tprivate void StuffLong(BinaryWriter sdl, int word)\n\t{\n\t\tStuff(sdl, BitConverter.GetBytes(word));\n\t}\n\n\tprivate void StuffLiteral(BinaryWriter sdl, int literal)\n\t{\n\t\tif (literal >= -128 && literal <= 127)\n\t\t{\n\t\t\tStuff(sdl, 2, IscCodes.isc_sdl_tiny_integer, literal);\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (literal >= -32768 && literal <= 32767)\n\t\t{\n\t\t\tStuffSdl(sdl, IscCodes.isc_sdl_short_integer);\n\t\t\tStuffWord(sdl, (short)literal);\n\n\t\t\treturn;\n\t\t}\n\n\t\tStuffSdl(sdl, IscCodes.isc_sdl_long_integer);\n\t\tStuffLong(sdl, literal);\n\t}\n\n\tprivate void StuffString(BinaryWriter sdl, int constant, string value)\n\t{\n\t\tStuffSdl(sdl, (byte)constant);\n\t\tStuffSdl(sdl, (byte)value.Length);\n\n\t\tfor (var i = 0; i < value.Length; i++)\n\t\t{\n\t\t\tStuffSdl(sdl, (byte)value[i]);\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version10/GdsBlob.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.IO;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version10;\n\ninternal sealed class GdsBlob : BlobBase\n{\n\tconst int DataSegment = 0;\n\tconst int SeekMode = 0;\n\n\t#region Fields\n\n\tprivate readonly GdsDatabase _database;\n\tprivate int _blobHandle;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic override DatabaseBase Database\n\t{\n\t\tget { return _database; }\n\t}\n\n\tpublic override int Handle\n\t{\n\t\tget { return _blobHandle; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic GdsBlob(GdsDatabase database, GdsTransaction transaction)\n\t\t: this(database, transaction, 0)\n\t{ }\n\n\tpublic GdsBlob(GdsDatabase database, GdsTransaction transaction, long blobId)\n\t\t: base(database)\n\t{\n\t\t_database = database;\n\t\t_transaction = transaction;\n\t\t_position = 0;\n\t\t_blobHandle = 0;\n\t\t_blobId = blobId;\n\t}\n\n\t#endregion\n\n\t#region Protected Methods\n\n\tpublic override void Create()\n\t{\n\t\ttry\n\t\t{\n\t\t\tCreateOrOpen(IscCodes.op_create_blob, null);\n\t\t\tRblAddValue(IscCodes.RBL_create);\n\t\t}\n\t\tcatch (IscException)\n\t\t{\n\t\t\tthrow;\n\t\t}\n\t}\n\tpublic override async ValueTask CreateAsync(CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait CreateOrOpenAsync(IscCodes.op_create_blob, null, cancellationToken).ConfigureAwait(false);\n\t\t\tRblAddValue(IscCodes.RBL_create);\n\t\t}\n\t\tcatch (IscException)\n\t\t{\n\t\t\tthrow;\n\t\t}\n\t}\n\n\tpublic override void Open()\n\t{\n\t\ttry\n\t\t{\n\t\t\tCreateOrOpen(IscCodes.op_open_blob, null);\n\t\t}\n\t\tcatch (IscException)\n\t\t{\n\t\t\tthrow;\n\t\t}\n\t}\n\tpublic override async ValueTask OpenAsync(CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait CreateOrOpenAsync(IscCodes.op_open_blob, null, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IscException)\n\t\t{\n\t\t\tthrow;\n\t\t}\n\t}\n\n\tpublic override int GetLength()\n\t{\n\t\ttry\n\t\t{\n\t\t\tif (!IsOpen)\n\t\t\t\tOpen();\n\n\t\t\tvar bufferLength = 20;\n\t\t\tvar buffer = new byte[bufferLength];\n\n\t\t\t_database.Xdr.Write(IscCodes.op_info_blob);\n\t\t\t_database.Xdr.Write(_blobHandle);\n\t\t\t_database.Xdr.Write(0);\n\t\t\t_database.Xdr.WriteBuffer(new byte[] { IscCodes.isc_info_blob_total_length }, 1);\n\t\t\t_database.Xdr.Write(bufferLength);\n\n\t\t\t_database.Xdr.Flush();\n\n\t\t\tvar response = (GenericResponse)_database.ReadResponse();\n\n\t\t\tvar responseLength = bufferLength;\n\n\t\t\tif (response.Data.Length < bufferLength)\n\t\t\t{\n\t\t\t\tresponseLength = response.Data.Length;\n\t\t\t}\n\n\t\t\tBuffer.BlockCopy(response.Data, 0, buffer, 0, responseLength);\n\n\t\t\tvar length = IscHelper.VaxInteger(buffer, 1, 2);\n\t\t\tvar size = IscHelper.VaxInteger(buffer, 3, (int)length);\n\n\t\t\treturn (int)size;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override async ValueTask<int> GetLengthAsync(CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tif (!IsOpen)\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar bufferLength = 20;\n\t\t\tvar buffer = new byte[bufferLength];\n\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_info_blob, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_blobHandle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(0, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteBufferAsync(new byte[] { IscCodes.isc_info_blob_total_length }, 1, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(bufferLength, cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar response = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar responseLength = bufferLength;\n\n\t\t\tif (response.Data.Length < bufferLength)\n\t\t\t{\n\t\t\t\tresponseLength = response.Data.Length;\n\t\t\t}\n\n\t\t\tBuffer.BlockCopy(response.Data, 0, buffer, 0, responseLength);\n\n\t\t\tvar length = IscHelper.VaxInteger(buffer, 1, 2);\n\t\t\tvar size = IscHelper.VaxInteger(buffer, 3, (int)length);\n\n\t\t\treturn (int)size;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override void GetSegment(Stream stream)\n\t{\n\t\tvar requested = SegmentSize;\n\n\t\ttry\n\t\t{\n\t\t\t_database.Xdr.Write(IscCodes.op_get_segment);\n\t\t\t_database.Xdr.Write(_blobHandle);\n\t\t\t_database.Xdr.Write(requested < short.MaxValue - 12 ? requested : short.MaxValue - 12);\n\t\t\t_database.Xdr.Write(DataSegment);\n\t\t\t_database.Xdr.Flush();\n\n\t\t\tvar response = (GenericResponse)_database.ReadResponse();\n\n\t\t\tRblRemoveValue(IscCodes.RBL_segment);\n\t\t\tif (response.ObjectHandle == 1)\n\t\t\t{\n\t\t\t\tRblAddValue(IscCodes.RBL_segment);\n\t\t\t}\n\t\t\telse if (response.ObjectHandle == 2)\n\t\t\t{\n\t\t\t\tRblAddValue(IscCodes.RBL_eof_pending);\n\t\t\t}\n\n\t\t\tvar buffer = response.Data;\n\n\t\t\tif (buffer.Length == 0)\n\t\t\t{\n\t\t\t\t// previous segment was last, this has no data\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar len = 0;\n\t\t\tvar srcpos = 0;\n\n\t\t\twhile (srcpos < buffer.Length)\n\t\t\t{\n\t\t\t\tlen = (int)IscHelper.VaxInteger(buffer, srcpos, 2);\n\t\t\t\tsrcpos += 2;\n\n\t\t\t\tstream.Write(buffer, srcpos, len);\n\t\t\t\tsrcpos += len;\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask GetSegmentAsync(Stream stream, CancellationToken cancellationToken = default)\n\t{\n\t\tvar requested = SegmentSize;\n\n\t\ttry\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_get_segment, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_blobHandle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(requested < short.MaxValue - 12 ? requested : short.MaxValue - 12, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(DataSegment, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar response = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tRblRemoveValue(IscCodes.RBL_segment);\n\t\t\tif (response.ObjectHandle == 1)\n\t\t\t{\n\t\t\t\tRblAddValue(IscCodes.RBL_segment);\n\t\t\t}\n\t\t\telse if (response.ObjectHandle == 2)\n\t\t\t{\n\t\t\t\tRblAddValue(IscCodes.RBL_eof_pending);\n\t\t\t}\n\n\t\t\tvar buffer = response.Data;\n\n\t\t\tif (buffer.Length == 0)\n\t\t\t{\n\t\t\t\t//previous segment was last, this has no data\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar len = 0;\n\t\t\tvar srcpos = 0;\n\n\t\t\twhile (srcpos < buffer.Length)\n\t\t\t{\n\t\t\t\tlen = (int)IscHelper.VaxInteger(buffer, srcpos, 2);\n\t\t\t\tsrcpos += 2;\n\n\t\t\t\tstream.Write(buffer, srcpos, len);\n\t\t\t\tsrcpos += len;\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override byte[] GetSegment()\n\t{\n\t\tvar requested = SegmentSize;\n\n\t\ttry\n\t\t{\n\t\t\t_database.Xdr.Write(IscCodes.op_get_segment);\n\t\t\t_database.Xdr.Write(_blobHandle);\n\t\t\t_database.Xdr.Write(requested < short.MaxValue - 12 ? requested : short.MaxValue - 12);\n\t\t\t_database.Xdr.Write(DataSegment);\n\t\t\t_database.Xdr.Flush();\n\n\t\t\tvar response = (GenericResponse)_database.ReadResponse();\n\n\t\t\tRblRemoveValue(IscCodes.RBL_segment);\n\t\t\tif (response.ObjectHandle == 1)\n\t\t\t{\n\t\t\t\tRblAddValue(IscCodes.RBL_segment);\n\t\t\t}\n\t\t\telse if (response.ObjectHandle == 2)\n\t\t\t{\n\t\t\t\tRblAddValue(IscCodes.RBL_eof_pending);\n\t\t\t}\n\n\t\t\tvar buffer = response.Data;\n\n\t\t\tif (buffer.Length == 0)\n\t\t\t{\n\t\t\t\t//previous segment was last, this has no data\n\t\t\t\treturn Array.Empty<byte>();\n\t\t\t}\n\n\t\t\tvar posInInput = 0;\n\t\t\tvar posInOutput = 0;\n\n\t\t\tvar tmp = new byte[requested * 2];\n\t\t\twhile (posInInput < buffer.Length)\n\t\t\t{\n\t\t\t\tvar len = (int)IscHelper.VaxInteger(buffer, posInInput, 2);\n\t\t\t\tposInInput += 2;\n\n\t\t\t\tArray.Copy(buffer, posInInput, tmp, posInOutput, len);\n\t\t\t\tposInOutput += len;\n\t\t\t\tposInInput += len;\n\t\t\t}\n\n\t\t\tvar actualBuffer = new byte[posInOutput];\n\t\t\tArray.Copy(tmp, actualBuffer, posInOutput);\n\n\t\t\treturn actualBuffer;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask<byte[]> GetSegmentAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar requested = SegmentSize;\n\n\t\ttry\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_get_segment, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_blobHandle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(requested < short.MaxValue - 12 ? requested : short.MaxValue - 12, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(DataSegment, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar response = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tRblRemoveValue(IscCodes.RBL_segment);\n\t\t\tif (response.ObjectHandle == 1)\n\t\t\t{\n\t\t\t\tRblAddValue(IscCodes.RBL_segment);\n\t\t\t}\n\t\t\telse if (response.ObjectHandle == 2)\n\t\t\t{\n\t\t\t\tRblAddValue(IscCodes.RBL_eof_pending);\n\t\t\t}\n\n\t\t\tvar buffer = response.Data;\n\n\t\t\tif (buffer.Length == 0)\n\t\t\t{\n\t\t\t\t// previous segment was last, this has no data\n\t\t\t\treturn Array.Empty<byte>();\n\t\t\t}\n\n\t\t\tvar posInInput = 0;\n\t\t\tvar posInOutput = 0;\n\n\t\t\tvar tmp = new byte[requested * 2];\n\t\t\twhile (posInInput < buffer.Length)\n\t\t\t{\n\t\t\t\tvar len = (int)IscHelper.VaxInteger(buffer, posInInput, 2);\n\t\t\t\tposInInput += 2;\n\n\t\t\t\tArray.Copy(buffer, posInInput, tmp, posInOutput, len);\n\t\t\t\tposInOutput += len;\n\t\t\t\tposInInput += len;\n\t\t\t}\n\n\t\t\tvar actualBuffer = new byte[posInOutput];\n\t\t\tArray.Copy(tmp, actualBuffer, posInOutput);\n\n\t\t\treturn actualBuffer;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override void PutSegment(byte[] buffer)\n\t{\n\t\ttry\n\t\t{\n\t\t\t_database.Xdr.Write(IscCodes.op_batch_segments);\n\t\t\t_database.Xdr.Write(_blobHandle);\n\t\t\t_database.Xdr.WriteBlobBuffer(buffer);\n\t\t\t_database.Xdr.Flush();\n\n\t\t\t_database.ReadResponse();\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask PutSegmentAsync(byte[] buffer, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_batch_segments, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_blobHandle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteBlobBufferAsync(buffer, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override void Seek(int offset, int seekMode)\n\t{\n\t\ttry\n\t\t{\n\t\t\t_database.Xdr.Write(IscCodes.op_seek_blob);\n\t\t\t_database.Xdr.Write(_blobHandle);\n\t\t\t_database.Xdr.Write(seekMode);\n\t\t\t_database.Xdr.Write(offset);\n\t\t\t_database.Xdr.Flush();\n\n\t\t\tvar response = (GenericResponse)_database.ReadResponse();\n\n\t\t\t_position = response.ObjectHandle;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask SeekAsync(int offset, int seekMode, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_seek_blob, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_blobHandle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(seekMode, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(offset, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar response = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t_position = response.ObjectHandle;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override void Close()\n\t{\n\t\t_database.ReleaseObject(IscCodes.op_close_blob, _blobHandle);\n\t}\n\tpublic override ValueTask CloseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn _database.ReleaseObjectAsync(IscCodes.op_close_blob, _blobHandle, cancellationToken);\n\t}\n\n\tpublic override void Cancel()\n\t{\n\t\t_database.ReleaseObject(IscCodes.op_cancel_blob, _blobHandle);\n\t}\n\tpublic override ValueTask CancelAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn _database.ReleaseObjectAsync(IscCodes.op_cancel_blob, _blobHandle, cancellationToken);\n\t}\n\n\t#endregion\n\n\t#region Private API Methods\n\n\tprivate void CreateOrOpen(int op, BlobParameterBuffer bpb)\n\t{\n\t\ttry\n\t\t{\n\t\t\t_database.Xdr.Write(op);\n\t\t\tif (bpb != null)\n\t\t\t{\n\t\t\t\t_database.Xdr.WriteTyped(IscCodes.isc_bpb_version1, bpb.ToArray());\n\t\t\t}\n\t\t\t_database.Xdr.Write(_transaction.Handle);\n\t\t\t_database.Xdr.Write(_blobId);\n\t\t\t_database.Xdr.Flush();\n\n\t\t\tvar response = (GenericResponse)_database.ReadResponse();\n\n\t\t\t_blobId = response.BlobId;\n\t\t\t_blobHandle = response.ObjectHandle;\n\t\t\t_isOpen = true;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tprivate async ValueTask CreateOrOpenAsync(int op, BlobParameterBuffer bpb, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(op, cancellationToken).ConfigureAwait(false);\n\t\t\tif (bpb != null)\n\t\t\t{\n\t\t\t\tawait _database.Xdr.WriteTypedAsync(IscCodes.isc_bpb_version1, bpb.ToArray(), cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tawait _database.Xdr.WriteAsync(_transaction.Handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_blobId, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar response = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t_blobId = response.BlobId;\n\t\t\t_blobHandle = response.ObjectHandle;\n\t\t\t_isOpen = true;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version10/GdsDatabase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Net;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version10;\n\ninternal class GdsDatabase : DatabaseBase\n{\n\tprotected const int PartnerIdentification = 0;\n\tprotected const int AddressOfAstRoutine = 0;\n\tprotected const int ArgumentToAstRoutine = 0;\n\tprotected internal const int DatabaseObjectId = 0;\n\tprotected internal const int Incarnation = 0;\n\n\t#region Fields\n\n\tprotected GdsConnection _connection;\n\tprotected GdsEventManager _eventManager;\n\tprotected int _handle;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic override bool UseUtf8ParameterBuffer => false;\n\n\tpublic override int Handle\n\t{\n\t\tget { return _handle; }\n\t}\n\n\tpublic override bool HasRemoteEventSupport\n\t{\n\t\tget { return true; }\n\t}\n\n\tpublic override bool ConnectionBroken\n\t{\n\t\tget { return _connection.ConnectionBroken; }\n\t}\n\n\tpublic XdrReaderWriter Xdr\n\t{\n\t\tget { return _connection.Xdr; }\n\t}\n\n\tpublic AuthBlock AuthBlock\n\t{\n\t\tget { return _connection.AuthBlock; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic GdsDatabase(GdsConnection connection)\n\t\t: base(connection.Charset, connection.PacketSize, connection.Dialect)\n\t{\n\t\t_connection = connection;\n\t\t_handle = -1;\n\t}\n\n\t#endregion\n\n\t#region Attach/Detach Methods\n\n\tpublic override void Attach(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey)\n\t{\n\t\ttry\n\t\t{\n\t\t\tSendAttachToBuffer(dpb, database);\n\t\t\tXdr.Flush();\n\t\t\tProcessAttachResponse((GenericResponse)ReadResponse());\n\t\t}\n\t\tcatch (IscException)\n\t\t{\n\t\t\tSafelyDetach();\n\t\t\tthrow;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tSafelyDetach();\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\n\t\tAfterAttachActions();\n\t}\n\tpublic override async ValueTask AttachAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait SendAttachToBufferAsync(dpb, database, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tawait ProcessAttachResponseAsync((GenericResponse)await ReadResponseAsync(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IscException)\n\t\t{\n\t\t\tawait SafelyDetachAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tthrow;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tawait SafelyDetachAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\n\t\tawait AfterAttachActionsAsync(cancellationToken).ConfigureAwait(false);\n\t}\n\n\tprotected virtual void SendAttachToBuffer(DatabaseParameterBufferBase dpb, string database)\n\t{\n\t\tXdr.Write(IscCodes.op_attach);\n\t\tXdr.Write(DatabaseObjectId);\n\t\tif (!string.IsNullOrEmpty(AuthBlock.Password))\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_password, AuthBlock.Password);\n\t\t}\n\t\tXdr.WriteBuffer(dpb.Encoding.GetBytes(database));\n\t\tXdr.WriteBuffer(dpb.ToArray());\n\t}\n\tprotected virtual async ValueTask SendAttachToBufferAsync(DatabaseParameterBufferBase dpb, string database, CancellationToken cancellationToken = default)\n\t{\n\t\tawait Xdr.WriteAsync(IscCodes.op_attach, cancellationToken).ConfigureAwait(false);\n\t\tawait Xdr.WriteAsync(DatabaseObjectId, cancellationToken).ConfigureAwait(false);\n\t\tif (!string.IsNullOrEmpty(AuthBlock.Password))\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_password, AuthBlock.Password);\n\t\t}\n\t\tawait Xdr.WriteBufferAsync(dpb.Encoding.GetBytes(database), cancellationToken).ConfigureAwait(false);\n\t\tawait Xdr.WriteBufferAsync(dpb.ToArray(), cancellationToken).ConfigureAwait(false);\n\t}\n\n\tprotected virtual void ProcessAttachResponse(GenericResponse response)\n\t{\n\t\t_handle = response.ObjectHandle;\n\t}\n\tprotected virtual ValueTask ProcessAttachResponseAsync(GenericResponse response, CancellationToken cancellationToken = default)\n\t{\n\t\t_handle = response.ObjectHandle;\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tprotected void AfterAttachActions()\n\t{\n\t\tServerVersion = GetServerVersion();\n\t}\n\tprotected async ValueTask AfterAttachActionsAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tServerVersion = await GetServerVersionAsync(cancellationToken).ConfigureAwait(false);\n\t}\n\n\tpublic override void AttachWithTrustedAuth(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey)\n\t{\n\t\tthrow new NotSupportedException(\"Trusted Auth isn't supported on < FB2.1.\");\n\t}\n\tpublic override ValueTask AttachWithTrustedAuthAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\tthrow new NotSupportedException(\"Trusted Auth isn't supported on < FB2.1.\");\n\t}\n\n\tpublic override void Detach()\n\t{\n\t\tif (TransactionCount > 0)\n\t\t{\n\t\t\tthrow IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount);\n\t\t}\n\n\t\ttry\n\t\t{\n\t\t\tCloseEventManager();\n\n\t\t\tvar detach = _handle != -1;\n\t\t\tif (detach)\n\t\t\t{\n\t\t\t\tXdr.Write(IscCodes.op_detach);\n\t\t\t\tXdr.Write(_handle);\n\t\t\t}\n\t\t\tXdr.Write(IscCodes.op_disconnect);\n\t\t\tXdr.Flush();\n\t\t\tif (detach)\n\t\t\t{\n\t\t\t\tReadResponse();\n\t\t\t}\n\n\t\t\tCloseConnection();\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tCloseConnection();\n\t\t\t}\n\t\t\tcatch (IOException)\n\t\t\t{ }\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\t_connection = null;\n\t\t\t_eventManager = null;\n\t\t\tServerVersion = null;\n\t\t\t_handle = -1;\n\t\t\tWarningMessage = null;\n\t\t\tTransactionCount = 0;\n\t\t}\n\t}\n\tpublic override async ValueTask DetachAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (TransactionCount > 0)\n\t\t{\n\t\t\tthrow IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount);\n\t\t}\n\n\t\ttry\n\t\t{\n\t\t\tawait CloseEventManagerAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar detach = _handle != -1;\n\t\t\tif (detach)\n\t\t\t{\n\t\t\t\tawait Xdr.WriteAsync(IscCodes.op_detach, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tawait Xdr.WriteAsync(IscCodes.op_disconnect, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tif (detach)\n\t\t\t{\n\t\t\t\tawait ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\n\t\t\tawait CloseConnectionAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait CloseConnectionAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch (IOException)\n\t\t\t{ }\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\t_connection = null;\n\t\t\t_eventManager = null;\n\t\t\tServerVersion = null;\n\t\t\t_handle = -1;\n\t\t\tWarningMessage = null;\n\t\t\tTransactionCount = 0;\n\t\t}\n\t}\n\n\tprotected internal void SafelyDetach()\n\t{\n\t\ttry\n\t\t{\n\t\t\tDetach();\n\t\t}\n\t\tcatch\n\t\t{ }\n\t}\n\tprotected internal async ValueTask SafelyDetachAsync(CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait DetachAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch\n\t\t{ }\n\t}\n\n\t#endregion\n\n\t#region Database Methods\n\n\tpublic override void CreateDatabase(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey)\n\t{\n\t\ttry\n\t\t{\n\t\t\tSendCreateToBuffer(dpb, database);\n\t\t\tXdr.Flush();\n\t\t\tProcessCreateResponse((GenericResponse)ReadResponse());\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask CreateDatabaseAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait SendCreateToBufferAsync(dpb, database, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tawait ProcessCreateResponseAsync((GenericResponse)await ReadResponseAsync(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tprotected virtual void SendCreateToBuffer(DatabaseParameterBufferBase dpb, string database)\n\t{\n\t\tXdr.Write(IscCodes.op_create);\n\t\tXdr.Write(DatabaseObjectId);\n\t\tif (!string.IsNullOrEmpty(AuthBlock.Password))\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_password, AuthBlock.Password);\n\t\t}\n\t\tXdr.WriteBuffer(dpb.Encoding.GetBytes(database));\n\t\tXdr.WriteBuffer(dpb.ToArray());\n\t}\n\tprotected virtual async ValueTask SendCreateToBufferAsync(DatabaseParameterBufferBase dpb, string database, CancellationToken cancellationToken = default)\n\t{\n\t\tawait Xdr.WriteAsync(IscCodes.op_create, cancellationToken).ConfigureAwait(false);\n\t\tawait Xdr.WriteAsync(DatabaseObjectId, cancellationToken).ConfigureAwait(false);\n\t\tif (!string.IsNullOrEmpty(AuthBlock.Password))\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_password, AuthBlock.Password);\n\t\t}\n\t\tawait Xdr.WriteBufferAsync(dpb.Encoding.GetBytes(database), cancellationToken).ConfigureAwait(false);\n\t\tawait Xdr.WriteBufferAsync(dpb.ToArray(), cancellationToken).ConfigureAwait(false);\n\t}\n\n\tprotected void ProcessCreateResponse(GenericResponse response)\n\t{\n\t\t_handle = response.ObjectHandle;\n\t}\n\tprotected ValueTask ProcessCreateResponseAsync(GenericResponse response, CancellationToken cancellationToken = default)\n\t{\n\t\t_handle = response.ObjectHandle;\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override void CreateDatabaseWithTrustedAuth(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey)\n\t{\n\t\tthrow new NotSupportedException(\"Trusted Auth isn't supported on < FB2.1.\");\n\t}\n\tpublic override ValueTask CreateDatabaseWithTrustedAuthAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\tthrow new NotSupportedException(\"Trusted Auth isn't supported on < FB2.1.\");\n\t}\n\n\tpublic override void DropDatabase()\n\t{\n\t\ttry\n\t\t{\n\t\t\tXdr.Write(IscCodes.op_drop_database);\n\t\t\tXdr.Write(_handle);\n\t\t\tXdr.Flush();\n\n\t\t\tReadResponse();\n\n\t\t\t_handle = -1;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask DropDatabaseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait Xdr.WriteAsync(IscCodes.op_drop_database, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t_handle = -1;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Auxiliary Connection Methods\n\n\tpublic virtual (int auxHandle, string ipAddress, int portNumber, int timeout) ConnectionRequest()\n\t{\n\t\ttry\n\t\t{\n\t\t\tXdr.Write(IscCodes.op_connect_request);\n\t\t\tXdr.Write(IscCodes.P_REQ_async);\n\t\t\tXdr.Write(_handle);\n\t\t\tXdr.Write(PartnerIdentification);\n\n\t\t\tXdr.Flush();\n\n\t\t\tReadOperation();\n\n\t\t\tvar auxHandle = Xdr.ReadInt32();\n\n\t\t\tvar garbage1 = new byte[8];\n\t\t\tXdr.ReadBytes(garbage1, 8);\n\n\t\t\tvar respLen = Xdr.ReadInt32();\n\t\t\trespLen += respLen % 4;\n\n\t\t\tvar sin_family = new byte[2];\n\t\t\tXdr.ReadBytes(sin_family, 2);\n\t\t\trespLen -= 2;\n\n\t\t\tvar sin_port = new byte[2];\n\t\t\tXdr.ReadBytes(sin_port, 2);\n\t\t\tvar portNumber = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(sin_port, 0));\n\t\t\trespLen -= 2;\n\n\t\t\t// * The address returned by the server may be incorrect if it is behind a NAT box\n\t\t\t// * so we must use the address that was used to connect the main socket, not the\n\t\t\t// * address reported by the server.\n\t\t\tvar sin_addr = new byte[4];\n\t\t\tXdr.ReadBytes(sin_addr, 4);\n\t\t\tvar ipAddress = _connection.IPAddress.ToString();\n\t\t\trespLen -= 4;\n\n\t\t\tvar garbage2 = new byte[respLen];\n\t\t\tXdr.ReadBytes(garbage2, respLen);\n\n\t\t\tXdr.ReadStatusVector();\n\n\t\t\treturn (auxHandle, ipAddress, portNumber, _connection.Timeout);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic virtual async ValueTask<(int auxHandle, string ipAddress, int portNumber, int timeout)> ConnectionRequestAsync(CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait Xdr.WriteAsync(IscCodes.op_connect_request, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(IscCodes.P_REQ_async, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(PartnerIdentification, cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait ReadOperationAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar auxHandle = await Xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar garbage1 = new byte[8];\n\t\t\tawait Xdr.ReadBytesAsync(garbage1, 8, cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar respLen = await Xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false);\n\t\t\trespLen += respLen % 4;\n\n\t\t\tvar sin_family = new byte[2];\n\t\t\tawait Xdr.ReadBytesAsync(sin_family, 2, cancellationToken).ConfigureAwait(false);\n\t\t\trespLen -= 2;\n\n\t\t\tvar sin_port = new byte[2];\n\t\t\tawait Xdr.ReadBytesAsync(sin_port, 2, cancellationToken).ConfigureAwait(false);\n\t\t\tvar portNumber = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(sin_port, 0));\n\t\t\trespLen -= 2;\n\n\t\t\t// * The address returned by the server may be incorrect if it is behind a NAT box\n\t\t\t// * so we must use the address that was used to connect the main socket, not the\n\t\t\t// * address reported by the server.\n\t\t\tvar sin_addr = new byte[4];\n\t\t\tawait Xdr.ReadBytesAsync(sin_addr, 4, cancellationToken).ConfigureAwait(false);\n\t\t\tvar ipAddress = _connection.IPAddress.ToString();\n\t\t\trespLen -= 4;\n\n\t\t\tvar garbage2 = new byte[respLen];\n\t\t\tawait Xdr.ReadBytesAsync(garbage2, respLen, cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait Xdr.ReadStatusVectorAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\treturn (auxHandle, ipAddress, portNumber, _connection.Timeout);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Connection Methods\n\n\tpublic void CloseConnection()\n\t{\n\t\t_connection.Disconnect();\n\t}\n\tpublic ValueTask CloseConnectionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn _connection.DisconnectAsync(cancellationToken);\n\t}\n\n\t#endregion\n\n\t#region Remote Events Methods\n\n\tpublic override void CloseEventManager()\n\t{\n\t\tif (_eventManager != null)\n\t\t{\n\t\t\t_eventManager.Close();\n\t\t\t_eventManager = null;\n\t\t}\n\t}\n\tpublic override async ValueTask CloseEventManagerAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_eventManager != null)\n\t\t{\n\t\t\tawait _eventManager.CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t_eventManager = null;\n\t\t}\n\t}\n\n\tpublic override void QueueEvents(RemoteEvent remoteEvent)\n\t{\n\t\ttry\n\t\t{\n\t\t\tif (_eventManager == null)\n\t\t\t{\n\t\t\t\tvar (auxHandle, ipAddress, portNumber, timeout) = ConnectionRequest();\n\t\t\t\t_eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber, timeout);\n\t\t\t\t_eventManager.Open();\n\t\t\t\tvar dummy = _eventManager.StartWaitingForEvents(remoteEvent);\n\t\t\t}\n\n\t\t\tremoteEvent.LocalId++;\n\n\t\t\tvar epb = remoteEvent.BuildEpb();\n\t\t\tvar epbData = epb.ToArray();\n\n\t\t\tXdr.Write(IscCodes.op_que_events);\n\t\t\tXdr.Write(_handle);\n\t\t\tXdr.WriteBuffer(epbData);\n\t\t\tXdr.Write(AddressOfAstRoutine);\n\t\t\tXdr.Write(ArgumentToAstRoutine);\n\t\t\tXdr.Write(remoteEvent.LocalId);\n\n\t\t\tXdr.Flush();\n\n\t\t\tvar response = (GenericResponse)ReadResponse();\n\n\t\t\tremoteEvent.RemoteId = response.ObjectHandle;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask QueueEventsAsync(RemoteEvent remoteEvent, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tif (_eventManager == null)\n\t\t\t{\n\t\t\t\tvar (auxHandle, ipAddress, portNumber, timeout) = await ConnectionRequestAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t_eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber, timeout);\n\t\t\t\tawait _eventManager.OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar dummy = _eventManager.StartWaitingForEvents(remoteEvent);\n\t\t\t}\n\n\t\t\tremoteEvent.LocalId++;\n\n\t\t\tvar epb = remoteEvent.BuildEpb();\n\t\t\tvar epbData = epb.ToArray();\n\n\t\t\tawait Xdr.WriteAsync(IscCodes.op_que_events, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteBufferAsync(epbData, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(AddressOfAstRoutine, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(ArgumentToAstRoutine, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(remoteEvent.LocalId, cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar response = (GenericResponse)await ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tremoteEvent.RemoteId = response.ObjectHandle;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override void CancelEvents(RemoteEvent events)\n\t{\n\t\ttry\n\t\t{\n\t\t\tXdr.Write(IscCodes.op_cancel_events);\n\t\t\tXdr.Write(_handle);\n\t\t\tXdr.Write(events.LocalId);\n\n\t\t\tXdr.Flush();\n\n\t\t\tReadResponse();\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask CancelEventsAsync(RemoteEvent events, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait Xdr.WriteAsync(IscCodes.op_cancel_events, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(events.LocalId, cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Transaction Methods\n\n\tpublic override TransactionBase BeginTransaction(TransactionParameterBuffer tpb)\n\t{\n\t\tvar transaction = new GdsTransaction(this);\n\n\t\ttransaction.BeginTransaction(tpb);\n\n\t\treturn transaction;\n\t}\n\tpublic override async ValueTask<TransactionBase> BeginTransactionAsync(TransactionParameterBuffer tpb, CancellationToken cancellationToken = default)\n\t{\n\t\tvar transaction = new GdsTransaction(this);\n\n\t\tawait transaction.BeginTransactionAsync(tpb, cancellationToken).ConfigureAwait(false);\n\n\t\treturn transaction;\n\t}\n\n\t#endregion\n\n\t#region Cancel Methods\n\n\tpublic override void CancelOperation(short kind)\n\t{\n\t\tthrow new NotSupportedException(\"Cancel Operation isn't supported on < FB2.5.\");\n\t}\n\tpublic override ValueTask CancelOperationAsync(short kind, CancellationToken cancellationToken = default)\n\t{\n\t\tthrow new NotSupportedException(\"Cancel Operation isn't supported on < FB2.5.\");\n\t}\n\n\t#endregion\n\n\t#region Statement Creation Methods\n\n\tpublic override StatementBase CreateStatement()\n\t{\n\t\treturn new GdsStatement(this);\n\t}\n\n\tpublic override StatementBase CreateStatement(TransactionBase transaction)\n\t{\n\t\treturn new GdsStatement(this, (GdsTransaction)transaction);\n\t}\n\n\t#endregion\n\n\t#region Parameter Buffers\n\n\tpublic override DatabaseParameterBufferBase CreateDatabaseParameterBuffer()\n\t{\n\t\treturn new DatabaseParameterBuffer1(ParameterBufferEncoding);\n\t}\n\n\tpublic override EventParameterBuffer CreateEventParameterBuffer()\n\t{\n\t\treturn new EventParameterBuffer(Charset.Encoding);\n\t}\n\n\tpublic override TransactionParameterBuffer CreateTransactionParameterBuffer()\n\t{\n\t\treturn new TransactionParameterBuffer(Charset.Encoding);\n\t}\n\n\t#endregion\n\n\t#region Database Information Methods\n\n\tpublic override List<object> GetDatabaseInfo(byte[] items)\n\t{\n\t\treturn GetDatabaseInfo(items, IscCodes.DEFAULT_MAX_BUFFER_SIZE);\n\t}\n\tpublic override ValueTask<List<object>> GetDatabaseInfoAsync(byte[] items, CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetDatabaseInfoAsync(items, IscCodes.DEFAULT_MAX_BUFFER_SIZE, cancellationToken);\n\t}\n\n\tpublic override List<object> GetDatabaseInfo(byte[] items, int bufferLength)\n\t{\n\t\tvar buffer = new byte[bufferLength];\n\t\tDatabaseInfo(items, buffer, buffer.Length);\n\t\treturn IscHelper.ParseDatabaseInfo(buffer, Charset);\n\t}\n\tpublic override async ValueTask<List<object>> GetDatabaseInfoAsync(byte[] items, int bufferLength, CancellationToken cancellationToken = default)\n\t{\n\t\tvar buffer = new byte[bufferLength];\n\t\tawait DatabaseInfoAsync(items, buffer, buffer.Length, cancellationToken).ConfigureAwait(false);\n\t\treturn IscHelper.ParseDatabaseInfo(buffer, Charset);\n\t}\n\n\t#endregion\n\n\t#region Release Object\n\n\tpublic virtual void ReleaseObject(int op, int id)\n\t{\n\t\ttry\n\t\t{\n\t\t\tSendReleaseObjectToBuffer(op, id);\n\t\t\tXdr.Flush();\n\t\t\tProcessReleaseObjectResponse(ReadResponse());\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic virtual async ValueTask ReleaseObjectAsync(int op, int id, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait SendReleaseObjectToBufferAsync(op, id, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tawait ProcessReleaseObjectResponseAsync(await ReadResponseAsync(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tprotected virtual void SendReleaseObjectToBuffer(int op, int id)\n\t{\n\t\tXdr.Write(op);\n\t\tXdr.Write(id);\n\t}\n\tprotected virtual async ValueTask SendReleaseObjectToBufferAsync(int op, int id, CancellationToken cancellationToken = default)\n\t{\n\t\tawait Xdr.WriteAsync(op, cancellationToken).ConfigureAwait(false);\n\t\tawait Xdr.WriteAsync(id, cancellationToken).ConfigureAwait(false);\n\t}\n\n\tprotected virtual void ProcessReleaseObjectResponse(IResponse response)\n\t{ }\n\tprotected virtual ValueTask ProcessReleaseObjectResponseAsync(IResponse response, CancellationToken cancellationToken = default)\n\t{\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\t#endregion\n\n\t#region Response Methods\n\n\tpublic virtual int ReadOperation()\n\t{\n\t\treturn Xdr.ReadOperation();\n\t}\n\tpublic virtual ValueTask<int> ReadOperationAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn Xdr.ReadOperationAsync(cancellationToken);\n\t}\n\n\tpublic virtual IResponse ReadResponse()\n\t{\n\t\tvar response = ReadSingleResponse();\n\t\tresponse.HandleResponseException();\n\t\treturn response;\n\t}\n\tpublic virtual async ValueTask<IResponse> ReadResponseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar response = await ReadSingleResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\tresponse.HandleResponseException();\n\t\treturn response;\n\t}\n\n\tpublic virtual IResponse ReadResponse(int operation)\n\t{\n\t\tvar response = ReadSingleResponse(operation);\n\t\tresponse.HandleResponseException();\n\t\treturn response;\n\t}\n\tpublic virtual async ValueTask<IResponse> ReadResponseAsync(int operation, CancellationToken cancellationToken = default)\n\t{\n\t\tvar response = await ReadSingleResponseAsync(operation, cancellationToken).ConfigureAwait(false);\n\t\tresponse.HandleResponseException();\n\t\treturn response;\n\t}\n\n\tpublic void SafeFinishFetching(int numberOfResponses)\n\t{\n\t\twhile (numberOfResponses > 0)\n\t\t{\n\t\t\tnumberOfResponses--;\n\t\t\ttry\n\t\t\t{\n\t\t\t\tReadResponse();\n\t\t\t}\n\t\t\tcatch (IscException)\n\t\t\t{ }\n\t\t}\n\t}\n\tpublic async ValueTask SafeFinishFetchingAsync(int numberOfResponses, CancellationToken cancellationToken = default)\n\t{\n\t\twhile (numberOfResponses > 0)\n\t\t{\n\t\t\tnumberOfResponses--;\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch (IscException)\n\t\t\t{ }\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Protected Methods\n\n\tprotected IResponse ReadSingleResponse()\n\t{\n\t\treturn ReadSingleResponse(ReadOperation());\n\t}\n\tprotected async ValueTask<IResponse> ReadSingleResponseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn await ReadSingleResponseAsync(await ReadOperationAsync(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);\n\t}\n\n\tprotected virtual IResponse ReadSingleResponse(int operation)\n\t{\n\t\tvar response = _connection.ProcessOperation(operation);\n\t\tresponse.HandleResponseWarning(WarningMessage);\n\t\treturn response;\n\t}\n\tprotected virtual async ValueTask<IResponse> ReadSingleResponseAsync(int operation, CancellationToken cancellationToken = default)\n\t{\n\t\tvar response = await _connection.ProcessOperationAsync(operation, cancellationToken).ConfigureAwait(false);\n\t\tresponse.HandleResponseWarning(WarningMessage);\n\t\treturn response;\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void DatabaseInfo(byte[] items, byte[] buffer, int bufferLength)\n\t{\n\t\ttry\n\t\t{\n\t\t\tXdr.Write(IscCodes.op_info_database);\n\t\t\tXdr.Write(_handle);\n\t\t\tXdr.Write(Incarnation);\n\t\t\tXdr.WriteBuffer(items, items.Length);\n\t\t\tXdr.Write(bufferLength);\n\n\t\t\tXdr.Flush();\n\n\t\t\tvar response = (GenericResponse)ReadResponse();\n\n\t\t\tvar responseLength = bufferLength;\n\n\t\t\tif (response.Data.Length < bufferLength)\n\t\t\t{\n\t\t\t\tresponseLength = response.Data.Length;\n\t\t\t}\n\n\t\t\tBuffer.BlockCopy(response.Data, 0, buffer, 0, responseLength);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tprivate async ValueTask DatabaseInfoAsync(byte[] items, byte[] buffer, int bufferLength, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait Xdr.WriteAsync(IscCodes.op_info_database, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(Incarnation, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteBufferAsync(items, items.Length, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(bufferLength, cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar response = (GenericResponse)await ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar responseLength = bufferLength;\n\n\t\t\tif (response.Data.Length < bufferLength)\n\t\t\t{\n\t\t\t\tresponseLength = response.Data.Length;\n\t\t\t}\n\n\t\t\tBuffer.BlockCopy(response.Data, 0, buffer, 0, responseLength);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version10/GdsEventManager.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Diagnostics;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version10;\n\ninternal class GdsEventManager\n{\n\tbool _closing;\n\tint _handle;\n\tstring _ipAddress;\n\tint _portNumber;\n\tint _timeout;\n\tGdsDatabase _database;\n\n\tpublic GdsEventManager(int handle, string ipAddress, int portNumber, int timeout)\n\t{\n\t\t_closing = false;\n\t\t_handle = handle;\n\t\t_ipAddress = ipAddress;\n\t\t_portNumber = portNumber;\n\t\t_timeout = timeout;\n\t}\n\n\tpublic void Open()\n\t{\n\t\tvar connection = new GdsConnection(_ipAddress, _portNumber, _timeout);\n\t\tconnection.Connect();\n\t\t_database = new GdsDatabase(connection);\n\t}\n\tpublic async ValueTask OpenAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar connection = new GdsConnection(_ipAddress, _portNumber, _timeout);\n\t\tawait connection.ConnectAsync(cancellationToken).ConfigureAwait(false);\n\t\t_database = new GdsDatabase(connection);\n\t}\n\n\t// this is a special method that's not awaited\n\tpublic async Task StartWaitingForEvents(RemoteEvent remoteEvent)\n\t{\n\t\twhile (true)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tvar operation = await _database.ReadOperationAsync(CancellationToken.None).ConfigureAwait(false);\n\n\t\t\t\tswitch (operation)\n\t\t\t\t{\n\t\t\t\t\tcase IscCodes.op_event:\n\t\t\t\t\t\tvar dbHandle = await _database.Xdr.ReadInt32Async(CancellationToken.None).ConfigureAwait(false);\n\t\t\t\t\t\tvar buffer = await _database.Xdr.ReadBufferAsync(CancellationToken.None).ConfigureAwait(false);\n\t\t\t\t\t\tvar ast = new byte[8];\n\t\t\t\t\t\tawait _database.Xdr.ReadBytesAsync(ast, 8, CancellationToken.None).ConfigureAwait(false);\n\t\t\t\t\t\tvar eventId = await _database.Xdr.ReadInt32Async(CancellationToken.None).ConfigureAwait(false);\n\n\t\t\t\t\t\tremoteEvent.EventCounts(buffer);\n\n\t\t\t\t\t\tawait remoteEvent.Database.QueueEventsAsync(remoteEvent, CancellationToken.None).ConfigureAwait(false);\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tDebug.Assert(false);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (Exception) when (Volatile.Read(ref _closing))\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcatch (Exception ex)\n\t\t\t{\n\t\t\t\tremoteEvent.EventError(ex);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic void Close()\n\t{\n\t\tVolatile.Write(ref _closing, true);\n\t\t_database.CloseConnection();\n\t}\n\tpublic ValueTask CloseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tVolatile.Write(ref _closing, true);\n\t\treturn _database.CloseConnectionAsync(cancellationToken);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version10/GdsServiceManager.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.IO;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version10;\n\ninternal class GdsServiceManager : ServiceManagerBase\n{\n\t#region Fields\n\n\tprivate GdsConnection _connection;\n\tprivate GdsDatabase _database;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic override bool UseUtf8ParameterBuffer => false;\n\n\tpublic GdsConnection Connection\n\t{\n\t\tget { return _connection; }\n\t}\n\n\tpublic GdsDatabase Database\n\t{\n\t\tget { return _database; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic GdsServiceManager(GdsConnection connection)\n\t\t: base(connection.Charset)\n\t{\n\t\t_connection = connection;\n\t\t_database = CreateDatabase(_connection);\n\t\tRewireWarningMessage();\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic override void Attach(ServiceParameterBufferBase spb, string dataSource, int port, string service, byte[] cryptKey)\n\t{\n\t\ttry\n\t\t{\n\t\t\tSendAttachToBuffer(spb, service);\n\t\t\t_database.Xdr.Flush();\n\t\t\tProcessAttachResponse((GenericResponse)_database.ReadResponse());\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\t_database.Detach();\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask AttachAsync(ServiceParameterBufferBase spb, string dataSource, int port, string service, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait SendAttachToBufferAsync(spb, service, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tawait ProcessAttachResponseAsync((GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tawait _database.DetachAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tprotected virtual void SendAttachToBuffer(ServiceParameterBufferBase spb, string service)\n\t{\n\t\t_database.Xdr.Write(IscCodes.op_service_attach);\n\t\t_database.Xdr.Write(GdsDatabase.DatabaseObjectId);\n\t\t_database.Xdr.Write(service);\n\t\t_database.Xdr.WriteBuffer(spb.ToArray());\n\t}\n\tprotected virtual async ValueTask SendAttachToBufferAsync(ServiceParameterBufferBase spb, string service, CancellationToken cancellationToken = default)\n\t{\n\t\tawait _database.Xdr.WriteAsync(IscCodes.op_service_attach, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.WriteAsync(GdsDatabase.DatabaseObjectId, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.WriteAsync(service, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.WriteBufferAsync(spb.ToArray(), cancellationToken).ConfigureAwait(false);\n\t}\n\n\tprotected virtual void ProcessAttachResponse(GenericResponse response)\n\t{\n\t\tHandle = response.ObjectHandle;\n\t}\n\tprotected virtual ValueTask ProcessAttachResponseAsync(GenericResponse response, CancellationToken cancellationToken = default)\n\t{\n\t\tHandle = response.ObjectHandle;\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override void Detach()\n\t{\n\t\ttry\n\t\t{\n\t\t\t_database.Xdr.Write(IscCodes.op_service_detach);\n\t\t\t_database.Xdr.Write(Handle);\n\t\t\t_database.Xdr.Write(IscCodes.op_disconnect);\n\t\t\t_database.Xdr.Flush();\n\n\t\t\tHandle = 0;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\t_connection.Disconnect();\n\t\t\t}\n\t\t\tcatch (IOException ex)\n\t\t\t{\n\t\t\t\tthrow IscException.ForIOException(ex);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\t_database = null;\n\t\t\t\t_connection = null;\n\t\t\t}\n\t\t}\n\t}\n\tpublic override async ValueTask DetachAsync(CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_service_detach, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(Handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_disconnect, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tHandle = 0;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait _connection.DisconnectAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch (IOException ex)\n\t\t\t{\n\t\t\t\tthrow IscException.ForIOException(ex);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\t_database = null;\n\t\t\t\t_connection = null;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override void Start(ServiceParameterBufferBase spb)\n\t{\n\t\ttry\n\t\t{\n\t\t\t_database.Xdr.Write(IscCodes.op_service_start);\n\t\t\t_database.Xdr.Write(Handle);\n\t\t\t_database.Xdr.Write(0);\n\t\t\t_database.Xdr.WriteBuffer(spb.ToArray(), spb.Length);\n\t\t\t_database.Xdr.Flush();\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\t_database.ReadResponse();\n\t\t\t}\n\t\t\tcatch (IscException)\n\t\t\t{\n\t\t\t\tthrow;\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask StartAsync(ServiceParameterBufferBase spb, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_service_start, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(Handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(0, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteBufferAsync(spb.ToArray(), spb.Length, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch (IscException)\n\t\t\t{\n\t\t\t\tthrow;\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override void Query(ServiceParameterBufferBase spb, int requestLength, byte[] requestBuffer, int bufferLength, byte[] buffer)\n\t{\n\t\ttry\n\t\t{\n\t\t\t_database.Xdr.Write(IscCodes.op_service_info);\n\t\t\t_database.Xdr.Write(Handle);\n\t\t\t_database.Xdr.Write(GdsDatabase.Incarnation);\n\t\t\t_database.Xdr.WriteBuffer(spb.ToArray(), spb.Length);\n\t\t\t_database.Xdr.WriteBuffer(requestBuffer, requestLength);\n\t\t\t_database.Xdr.Write(bufferLength);\n\n\t\t\t_database.Xdr.Flush();\n\n\t\t\tvar response = (GenericResponse)_database.ReadResponse();\n\n\t\t\tvar responseLength = bufferLength;\n\n\t\t\tif (response.Data.Length < bufferLength)\n\t\t\t{\n\t\t\t\tresponseLength = response.Data.Length;\n\t\t\t}\n\n\t\t\tBuffer.BlockCopy(response.Data, 0, buffer, 0, responseLength);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask QueryAsync(ServiceParameterBufferBase spb, int requestLength, byte[] requestBuffer, int bufferLength, byte[] buffer, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_service_info, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(Handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(GdsDatabase.Incarnation, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteBufferAsync(spb.ToArray(), spb.Length, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteBufferAsync(requestBuffer, requestLength, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(bufferLength, cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar response = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar responseLength = bufferLength;\n\n\t\t\tif (response.Data.Length < bufferLength)\n\t\t\t{\n\t\t\t\tresponseLength = response.Data.Length;\n\t\t\t}\n\n\t\t\tBuffer.BlockCopy(response.Data, 0, buffer, 0, responseLength);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override ServiceParameterBufferBase CreateServiceParameterBuffer()\n\t{\n\t\treturn new ServiceParameterBuffer2(Database.ParameterBufferEncoding);\n\t}\n\n\tprotected virtual GdsDatabase CreateDatabase(GdsConnection connection)\n\t{\n\t\treturn new GdsDatabase(connection);\n\t}\n\n\tprivate void RewireWarningMessage()\n\t{\n\t\t_database.WarningMessage = ex => WarningMessage?.Invoke(ex);\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version10/GdsStatement.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version10;\n\ninternal class GdsStatement : StatementBase\n{\n\t#region Fields\n\n\tprotected int _handle;\n\tprivate bool _disposed;\n\tprotected GdsDatabase _database;\n\tprivate GdsTransaction _transaction;\n\tprotected Descriptor _parameters;\n\tprotected Descriptor _fields;\n\tprotected bool _allRowsFetched;\n\tprivate Queue<DbValue[]> _rows;\n\tprivate int _fetchSize;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic override DatabaseBase Database\n\t{\n\t\tget { return _database; }\n\t}\n\n\tpublic override TransactionBase Transaction\n\t{\n\t\tget { return _transaction; }\n\t\tset\n\t\t{\n\t\t\tif (_transaction != value)\n\t\t\t{\n\t\t\t\tif (TransactionUpdate != null && _transaction != null)\n\t\t\t\t{\n\t\t\t\t\t_transaction.Update -= TransactionUpdate;\n\t\t\t\t\tTransactionUpdate = null;\n\t\t\t\t}\n\n\t\t\t\tif (value == null)\n\t\t\t\t{\n\t\t\t\t\t_transaction = null;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t_transaction = (GdsTransaction)value;\n\t\t\t\t\tTransactionUpdate = new EventHandler(TransactionUpdated);\n\t\t\t\t\t_transaction.Update += TransactionUpdate;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override Descriptor Parameters\n\t{\n\t\tget { return _parameters; }\n\t\tset { _parameters = value; }\n\t}\n\n\tpublic override Descriptor Fields\n\t{\n\t\tget { return _fields; }\n\t}\n\n\tpublic override int FetchSize\n\t{\n\t\tget { return _fetchSize; }\n\t\tset { _fetchSize = value; }\n\t}\n\n\tpublic int Handle\n\t{\n\t\tget { return _handle; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic GdsStatement(GdsDatabase database)\n\t\t: this(database, null)\n\t{\n\t}\n\n\tpublic GdsStatement(GdsDatabase database, GdsTransaction transaction)\n\t{\n\t\t_handle = IscCodes.INVALID_OBJECT;\n\t\t_fetchSize = 200;\n\t\t_rows = new Queue<DbValue[]>();\n\t\tOutputParameters = new Queue<DbValue[]>();\n\n\t\t_database = database;\n\n\t\tif (transaction != null)\n\t\t{\n\t\t\tTransaction = transaction;\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Dispose2\n\n\tpublic override void Dispose2()\n\t{\n\t\tif (!_disposed)\n\t\t{\n\t\t\t_disposed = true;\n\t\t\tRelease();\n\t\t\tClear();\n\t\t\t_rows = null;\n\t\t\tOutputParameters = null;\n\t\t\t_database = null;\n\t\t\t_fields = null;\n\t\t\t_parameters = null;\n\t\t\t_transaction = null;\n\t\t\t_allRowsFetched = false;\n\t\t\t_handle = 0;\n\t\t\t_fetchSize = 0;\n\t\t\tbase.Dispose2();\n\t\t}\n\t}\n\tpublic override async ValueTask Dispose2Async(CancellationToken cancellationToken = default)\n\t{\n\t\tif (!_disposed)\n\t\t{\n\t\t\t_disposed = true;\n\t\t\tawait ReleaseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tClear();\n\t\t\t_rows = null;\n\t\t\tOutputParameters = null;\n\t\t\t_database = null;\n\t\t\t_fields = null;\n\t\t\t_parameters = null;\n\t\t\t_transaction = null;\n\t\t\t_allRowsFetched = false;\n\t\t\t_handle = 0;\n\t\t\t_fetchSize = 0;\n\t\t\tawait base.Dispose2Async(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Blob Creation Metods\n\n\tpublic override BlobBase CreateBlob()\n\t{\n\t\treturn new GdsBlob(_database, _transaction);\n\t}\n\n\tpublic override BlobBase CreateBlob(long blobId)\n\t{\n\t\treturn new GdsBlob(_database, _transaction, blobId);\n\t}\n\n\t#endregion\n\n\t#region Array Creation Methods\n\n\tpublic override ArrayBase CreateArray(ArrayDesc descriptor)\n\t{\n\t\tvar array = new GdsArray(descriptor);\n\t\treturn array;\n\t}\n\tpublic override ValueTask<ArrayBase> CreateArrayAsync(ArrayDesc descriptor, CancellationToken cancellationToken = default)\n\t{\n\t\tvar array = new GdsArray(descriptor);\n\t\treturn ValueTask.FromResult<ArrayBase>(array);\n\t}\n\n\tpublic override ArrayBase CreateArray(string tableName, string fieldName)\n\t{\n\t\tvar array = new GdsArray(_database, _transaction, tableName, fieldName);\n\t\tarray.Initialize();\n\t\treturn array;\n\t}\n\tpublic override async ValueTask<ArrayBase> CreateArrayAsync(string tableName, string fieldName, CancellationToken cancellationToken = default)\n\t{\n\t\tvar array = new GdsArray(_database, _transaction, tableName, fieldName);\n\t\tawait array.InitializeAsync(cancellationToken).ConfigureAwait(false);\n\t\treturn array;\n\t}\n\n\tpublic override ArrayBase CreateArray(long handle, string tableName, string fieldName)\n\t{\n\t\tvar array = new GdsArray(_database, _transaction, handle, tableName, fieldName);\n\t\tarray.Initialize();\n\t\treturn array;\n\t}\n\tpublic override async ValueTask<ArrayBase> CreateArrayAsync(long handle, string tableName, string fieldName, CancellationToken cancellationToken = default)\n\t{\n\t\tvar array = new GdsArray(_database, _transaction, handle, tableName, fieldName);\n\t\tawait array.InitializeAsync(cancellationToken).ConfigureAwait(false);\n\t\treturn array;\n\t}\n\n\t#endregion\n\n\t#region Batch Creation Methods\n\n\tpublic override BatchBase CreateBatch()\n\t{\n\t\tthrow new NotSupportedException(\"Batching is not supported on this Firebird version.\");\n\t}\n\n\tpublic override BatchParameterBuffer CreateBatchParameterBuffer()\n\t{\n\t\tthrow new NotSupportedException(\"Batching is not supported on this Firebird version.\");\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic override void Prepare(string commandText)\n\t{\n\t\tClearAll();\n\n\t\ttry\n\t\t{\n\t\t\tif (State == StatementState.Deallocated)\n\t\t\t{\n\t\t\t\tSendAllocateToBuffer();\n\t\t\t\t_database.Xdr.Flush();\n\t\t\t\tProcessAllocateResponse((GenericResponse)_database.ReadResponse());\n\t\t\t}\n\n\t\t\tSendPrepareToBuffer(commandText);\n\t\t\t_database.Xdr.Flush();\n\t\t\tProcessPrepareResponse((GenericResponse)_database.ReadResponse());\n\n\t\t\tSendInfoSqlToBuffer(StatementTypeInfoItems, IscCodes.STATEMENT_TYPE_BUFFER_SIZE);\n\t\t\t_database.Xdr.Flush();\n\t\t\tStatementType = ProcessStatementTypeInfoBuffer(ProcessInfoSqlResponse((GenericResponse)_database.ReadResponse()));\n\n\t\t\tState = StatementState.Prepared;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tState = State == StatementState.Allocated ? StatementState.Error : State;\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask PrepareAsync(string commandText, CancellationToken cancellationToken = default)\n\t{\n\t\tClearAll();\n\n\t\ttry\n\t\t{\n\t\t\tif (State == StatementState.Deallocated)\n\t\t\t{\n\t\t\t\tawait SendAllocateToBufferAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ProcessAllocateResponseAsync((GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\n\t\t\tawait SendPrepareToBufferAsync(commandText, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tawait ProcessPrepareResponseAsync((GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait SendInfoSqlToBufferAsync(StatementTypeInfoItems, IscCodes.STATEMENT_TYPE_BUFFER_SIZE, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tStatementType = ProcessStatementTypeInfoBuffer(await ProcessInfoSqlResponseAsync((GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false));\n\n\t\t\tState = StatementState.Prepared;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tState = State == StatementState.Allocated ? StatementState.Error : State;\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override void Execute(int timeout, IDescriptorFiller descriptorFiller)\n\t{\n\t\tEnsureNotDeallocated();\n\n\t\tClear();\n\n\t\ttry\n\t\t{\n\t\t\tSendExecuteToBuffer(timeout, descriptorFiller);\n\n\t\t\t_database.Xdr.Flush();\n\n\t\t\tif (StatementType == DbStatementType.StoredProcedure)\n\t\t\t{\n\t\t\t\tProcessStoredProcedureExecuteResponse((SqlResponse)_database.ReadResponse());\n\t\t\t}\n\n\t\t\tvar executeResponse = (GenericResponse)_database.ReadResponse();\n\t\t\tProcessExecuteResponse(executeResponse);\n\n\t\t\tif (DoRecordsAffected)\n\t\t\t{\n\t\t\t\tSendInfoSqlToBuffer(RowsAffectedInfoItems, IscCodes.ROWS_AFFECTED_BUFFER_SIZE);\n\t\t\t\t_database.Xdr.Flush();\n\t\t\t\tRecordsAffected = ProcessRecordsAffectedBuffer(ProcessInfoSqlResponse((GenericResponse)_database.ReadResponse()));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tRecordsAffected = -1;\n\t\t\t}\n\n\t\t\tState = StatementState.Executed;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tState = StatementState.Error;\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask ExecuteAsync(int timeout, IDescriptorFiller descriptorFiller, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureNotDeallocated();\n\n\t\tClear();\n\n\t\ttry\n\t\t{\n\t\t\tawait SendExecuteToBufferAsync(timeout, descriptorFiller, cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tif (StatementType == DbStatementType.StoredProcedure)\n\t\t\t{\n\t\t\t\tawait ProcessStoredProcedureExecuteResponseAsync((SqlResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\n\t\t\tvar executeResponse = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tawait ProcessExecuteResponseAsync(executeResponse, cancellationToken).ConfigureAwait(false);\n\n\t\t\tif (DoRecordsAffected)\n\t\t\t{\n\t\t\t\tawait SendInfoSqlToBufferAsync(RowsAffectedInfoItems, IscCodes.ROWS_AFFECTED_BUFFER_SIZE, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tRecordsAffected = ProcessRecordsAffectedBuffer(await ProcessInfoSqlResponseAsync((GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tRecordsAffected = -1;\n\t\t\t}\n\n\t\t\tState = StatementState.Executed;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tState = StatementState.Error;\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override DbValue[] Fetch()\n\t{\n\t\tEnsureNotDeallocated();\n\n\t\tif (StatementType == DbStatementType.StoredProcedure && !_allRowsFetched)\n\t\t{\n\t\t\t_allRowsFetched = true;\n\t\t\treturn GetOutputParameters();\n\t\t}\n\t\telse if (StatementType == DbStatementType.Insert && _allRowsFetched)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\telse if (StatementType != DbStatementType.Select && StatementType != DbStatementType.SelectForUpdate)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\n\t\tif (!_allRowsFetched && _rows.Count == 0)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\t_database.Xdr.Write(IscCodes.op_fetch);\n\t\t\t\t_database.Xdr.Write(_handle);\n\t\t\t\t_database.Xdr.WriteBuffer(_fields.ToBlr().Data);\n\t\t\t\t_database.Xdr.Write(0); // p_sqldata_message_number\n\t\t\t\t_database.Xdr.Write(_fetchSize); // p_sqldata_messages\n\t\t\t\t_database.Xdr.Flush();\n\n\t\t\t\tvar operation = _database.ReadOperation();\n\t\t\t\tif (operation == IscCodes.op_fetch_response)\n\t\t\t\t{\n\t\t\t\t\tvar hasOperation = true;\n\t\t\t\t\twhile (!_allRowsFetched)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar response = hasOperation\n\t\t\t\t\t\t\t? _database.ReadResponse(operation)\n\t\t\t\t\t\t\t: _database.ReadResponse();\n\t\t\t\t\t\thasOperation = false;\n\t\t\t\t\t\tif (response is FetchResponse fetchResponse)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (fetchResponse.Count > 0 && fetchResponse.Status == 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t_rows.Enqueue(ReadRow());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (fetchResponse.Status == 100)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t_allRowsFetched = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t_database.ReadResponse(operation);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException ex)\n\t\t\t{\n\t\t\t\tthrow IscException.ForIOException(ex);\n\t\t\t}\n\t\t}\n\n\t\tif (_rows != null && _rows.Count > 0)\n\t\t{\n\t\t\treturn _rows.Dequeue();\n\t\t}\n\t\telse\n\t\t{\n\t\t\t_rows.Clear();\n\t\t\treturn null;\n\t\t}\n\t}\n\tpublic override async ValueTask<DbValue[]> FetchAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureNotDeallocated();\n\n\t\tif (StatementType == DbStatementType.StoredProcedure && !_allRowsFetched)\n\t\t{\n\t\t\t_allRowsFetched = true;\n\t\t\treturn GetOutputParameters();\n\t\t}\n\t\telse if (StatementType == DbStatementType.Insert && _allRowsFetched)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\telse if (StatementType != DbStatementType.Select && StatementType != DbStatementType.SelectForUpdate)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\n\t\tif (!_allRowsFetched && _rows.Count == 0)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_fetch, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait _database.Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait _database.Xdr.WriteBufferAsync(_fields.ToBlr().Data, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait _database.Xdr.WriteAsync(0, cancellationToken).ConfigureAwait(false); // p_sqldata_message_number\n\t\t\t\tawait _database.Xdr.WriteAsync(_fetchSize, cancellationToken).ConfigureAwait(false); // p_sqldata_messages\n\t\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tvar operation = await _database.ReadOperationAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tif (operation == IscCodes.op_fetch_response)\n\t\t\t\t{\n\t\t\t\t\tvar hasOperation = true;\n\t\t\t\t\twhile (!_allRowsFetched)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar response = hasOperation\n\t\t\t\t\t\t\t? await _database.ReadResponseAsync(operation, cancellationToken).ConfigureAwait(false)\n\t\t\t\t\t\t\t: await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\thasOperation = false;\n\t\t\t\t\t\tif (response is FetchResponse fetchResponse)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (fetchResponse.Count > 0 && fetchResponse.Status == 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t_rows.Enqueue(await ReadRowAsync(cancellationToken).ConfigureAwait(false));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (fetchResponse.Status == 100)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t_allRowsFetched = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tawait _database.ReadResponseAsync(operation, cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException ex)\n\t\t\t{\n\t\t\t\tthrow IscException.ForIOException(ex);\n\t\t\t}\n\t\t}\n\n\t\tif (_rows != null && _rows.Count > 0)\n\t\t{\n\t\t\treturn _rows.Dequeue();\n\t\t}\n\t\telse\n\t\t{\n\t\t\t_rows.Clear();\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Protected Methods\n\n\t#region op_prepare methods\n\tprotected void SendPrepareToBuffer(string commandText)\n\t{\n\t\t_database.Xdr.Write(IscCodes.op_prepare_statement);\n\t\t_database.Xdr.Write(_transaction.Handle);\n\t\t_database.Xdr.Write(_handle);\n\t\t_database.Xdr.Write((int)_database.Dialect);\n\t\t_database.Xdr.Write(commandText);\n\t\t_database.Xdr.WriteBuffer(DescribeInfoAndBindInfoItems, DescribeInfoAndBindInfoItems.Length);\n\t\t_database.Xdr.Write(IscCodes.PREPARE_INFO_BUFFER_SIZE);\n\t}\n\tprotected async ValueTask SendPrepareToBufferAsync(string commandText, CancellationToken cancellationToken = default)\n\t{\n\t\tawait _database.Xdr.WriteAsync(IscCodes.op_prepare_statement, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.WriteAsync(_transaction.Handle, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.WriteAsync((int)_database.Dialect, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.WriteAsync(commandText, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.WriteBufferAsync(DescribeInfoAndBindInfoItems, DescribeInfoAndBindInfoItems.Length, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.WriteAsync(IscCodes.PREPARE_INFO_BUFFER_SIZE, cancellationToken).ConfigureAwait(false);\n\t}\n\n\tprotected void ProcessPrepareResponse(GenericResponse response)\n\t{\n\t\tvar descriptors = ParseSqlInfo(response.Data, DescribeInfoAndBindInfoItems, new Descriptor[] { null, null });\n\t\t_fields = descriptors[0];\n\t\t_parameters = descriptors[1];\n\t}\n\tprotected async ValueTask ProcessPrepareResponseAsync(GenericResponse response, CancellationToken cancellationToken = default)\n\t{\n\t\tvar descriptors = await ParseSqlInfoAsync(response.Data, DescribeInfoAndBindInfoItems, new Descriptor[] { null, null }, cancellationToken).ConfigureAwait(false);\n\t\t_fields = descriptors[0];\n\t\t_parameters = descriptors[1];\n\t}\n\t#endregion\n\n\t#region op_info_sql methods\n\tprotected override byte[] GetSqlInfo(byte[] items, int bufferLength)\n\t{\n\t\tDoInfoSqlPacket(items, bufferLength);\n\t\t_database.Xdr.Flush();\n\t\treturn ProcessInfoSqlResponse((GenericResponse)_database.ReadResponse());\n\t}\n\tprotected override async ValueTask<byte[]> GetSqlInfoAsync(byte[] items, int bufferLength, CancellationToken cancellationToken = default)\n\t{\n\t\tawait DoInfoSqlPacketAsync(items, bufferLength, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\treturn await ProcessInfoSqlResponseAsync((GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);\n\t}\n\n\tprotected void DoInfoSqlPacket(byte[] items, int bufferLength)\n\t{\n\t\ttry\n\t\t{\n\t\t\tSendInfoSqlToBuffer(items, bufferLength);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tprotected async ValueTask DoInfoSqlPacketAsync(byte[] items, int bufferLength, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait SendInfoSqlToBufferAsync(items, bufferLength, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tprotected void SendInfoSqlToBuffer(byte[] items, int bufferLength)\n\t{\n\t\t_database.Xdr.Write(IscCodes.op_info_sql);\n\t\t_database.Xdr.Write(_handle);\n\t\t_database.Xdr.Write(0);\n\t\t_database.Xdr.WriteBuffer(items, items.Length);\n\t\t_database.Xdr.Write(bufferLength);\n\t}\n\tprotected async ValueTask SendInfoSqlToBufferAsync(byte[] items, int bufferLength, CancellationToken cancellationToken = default)\n\t{\n\t\tawait _database.Xdr.WriteAsync(IscCodes.op_info_sql, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.WriteAsync(0, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.WriteBufferAsync(items, items.Length, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.WriteAsync(bufferLength, cancellationToken).ConfigureAwait(false);\n\t}\n\n\tprotected byte[] ProcessInfoSqlResponse(GenericResponse response)\n\t{\n\t\tDebug.Assert(response.Data != null && response.Data.Length > 0);\n\n\t\treturn response.Data;\n\t}\n\tprotected ValueTask<byte[]> ProcessInfoSqlResponseAsync(GenericResponse response, CancellationToken cancellationToken = default)\n\t{\n\t\tDebug.Assert(response.Data != null && response.Data.Length > 0);\n\n\t\treturn ValueTask.FromResult(response.Data);\n\t}\n\t#endregion\n\n\t#region op_free_statement methods\n\tprotected override void Free(int option)\n\t{\n\t\tif (FreeNotNeeded(option))\n\t\t\treturn;\n\n\t\tDoFreePacket(option);\n\t\tProcessFreeResponse(_database.ReadResponse());\n\t}\n\tprotected override async ValueTask FreeAsync(int option, CancellationToken cancellationToken = default)\n\t{\n\t\tif (FreeNotNeeded(option))\n\t\t\treturn;\n\n\t\tawait DoFreePacketAsync(option, cancellationToken).ConfigureAwait(false);\n\t\tawait ProcessFreeResponseAsync(await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);\n\t}\n\n\tprotected bool FreeNotNeeded(int option)\n\t{\n\t\t// does not seem to be possible or necessary to close an execute procedure statement\n\t\tif (StatementType == DbStatementType.StoredProcedure && option == IscCodes.DSQL_close)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprotected void DoFreePacket(int option)\n\t{\n\t\ttry\n\t\t{\n\t\t\t_database.Xdr.Write(IscCodes.op_free_statement);\n\t\t\t_database.Xdr.Write(_handle);\n\t\t\t_database.Xdr.Write(option);\n\t\t\t_database.Xdr.Flush();\n\n\t\t\tif (option == IscCodes.DSQL_drop)\n\t\t\t{\n\t\t\t\t_parameters = null;\n\t\t\t\t_fields = null;\n\t\t\t}\n\n\t\t\tClear();\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tState = StatementState.Error;\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tprotected async ValueTask DoFreePacketAsync(int option, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_free_statement, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(option, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tif (option == IscCodes.DSQL_drop)\n\t\t\t{\n\t\t\t\t_parameters = null;\n\t\t\t\t_fields = null;\n\t\t\t}\n\n\t\t\tClear();\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tState = StatementState.Error;\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tprotected void ProcessFreeResponse(IResponse response)\n\t{ }\n\tprotected ValueTask ProcessFreeResponseAsync(IResponse response, CancellationToken cancellationToken = default)\n\t{\n\t\treturn ValueTask.CompletedTask;\n\t}\n\t#endregion\n\n\t#region op_allocate_statement methods\n\tprotected void SendAllocateToBuffer()\n\t{\n\t\t_database.Xdr.Write(IscCodes.op_allocate_statement);\n\t\t_database.Xdr.Write(_database.Handle);\n\t}\n\tprotected async ValueTask SendAllocateToBufferAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tawait _database.Xdr.WriteAsync(IscCodes.op_allocate_statement, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.WriteAsync(_database.Handle, cancellationToken).ConfigureAwait(false);\n\t}\n\n\tprotected void ProcessAllocateResponse(GenericResponse response)\n\t{\n\t\t_handle = response.ObjectHandle;\n\t\t_allRowsFetched = false;\n\t\tState = StatementState.Allocated;\n\t\tStatementType = DbStatementType.None;\n\t}\n\tprotected ValueTask ProcessAllocateResponseAsync(GenericResponse response, CancellationToken cancellationToken = default)\n\t{\n\t\t_handle = response.ObjectHandle;\n\t\t_allRowsFetched = false;\n\t\tState = StatementState.Allocated;\n\t\tStatementType = DbStatementType.None;\n\t\treturn ValueTask.CompletedTask;\n\t}\n\t#endregion\n\n\t#region op_execute/op_execute2 methods\n\tprotected virtual void SendExecuteToBuffer(int timeout, IDescriptorFiller descriptorFiller)\n\t{\n\t\t// this may throw error, so it needs to be before any writing\n\t\tvar parametersData = GetParameterData(descriptorFiller, 0);\n\n\t\tif (StatementType == DbStatementType.StoredProcedure)\n\t\t{\n\t\t\t_database.Xdr.Write(IscCodes.op_execute2);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t_database.Xdr.Write(IscCodes.op_execute);\n\t\t}\n\n\t\t_database.Xdr.Write(_handle);\n\t\t_database.Xdr.Write(_transaction.Handle);\n\n\t\tif (_parameters != null)\n\t\t{\n\t\t\t_database.Xdr.WriteBuffer(_parameters.ToBlr().Data);\n\t\t\t_database.Xdr.Write(0); // Message number\n\t\t\t_database.Xdr.Write(1); // Number of messages\n\t\t\t_database.Xdr.WriteBytes(parametersData, parametersData.Length);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t_database.Xdr.WriteBuffer(null);\n\t\t\t_database.Xdr.Write(0);\n\t\t\t_database.Xdr.Write(0);\n\t\t}\n\n\t\tif (StatementType == DbStatementType.StoredProcedure)\n\t\t{\n\t\t\t_database.Xdr.WriteBuffer(_fields?.ToBlr().Data);\n\t\t\t_database.Xdr.Write(0); // Output message number\n\t\t}\n\t}\n\tprotected virtual async ValueTask SendExecuteToBufferAsync(int timeout, IDescriptorFiller descriptorFiller, CancellationToken cancellationToken = default)\n\t{\n\t\t// this may throw error, so it needs to be before any writing\n\t\tvar parametersData = await GetParameterDataAsync(descriptorFiller, 0, cancellationToken).ConfigureAwait(false);\n\n\t\tif (StatementType == DbStatementType.StoredProcedure)\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_execute2, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_execute, cancellationToken).ConfigureAwait(false);\n\t\t}\n\n\t\tawait _database.Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.WriteAsync(_transaction.Handle, cancellationToken).ConfigureAwait(false);\n\n\t\tif (_parameters != null)\n\t\t{\n\t\t\tawait _database.Xdr.WriteBufferAsync(_parameters.ToBlr().Data, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(0, cancellationToken).ConfigureAwait(false); // Message number\n\t\t\tawait _database.Xdr.WriteAsync(1, cancellationToken).ConfigureAwait(false); // Number of messages\n\t\t\tawait _database.Xdr.WriteBytesAsync(parametersData, parametersData.Length, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tawait _database.Xdr.WriteBufferAsync(null, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(0, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(0, cancellationToken).ConfigureAwait(false);\n\t\t}\n\n\t\tif (StatementType == DbStatementType.StoredProcedure)\n\t\t{\n\t\t\tawait _database.Xdr.WriteBufferAsync(_fields?.ToBlr().Data, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(0, cancellationToken).ConfigureAwait(false); // Output message number\n\t\t}\n\t}\n\n\tprotected void ProcessExecuteResponse(GenericResponse response)\n\t{ }\n\tprotected ValueTask ProcessExecuteResponseAsync(GenericResponse response, CancellationToken cancellationToken = default)\n\t{\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tprotected void ProcessStoredProcedureExecuteResponse(SqlResponse response)\n\t{\n\t\ttry\n\t\t{\n\t\t\tif (response.Count > 0)\n\t\t\t{\n\t\t\t\tOutputParameters.Enqueue(ReadRow());\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tprotected async ValueTask ProcessStoredProcedureExecuteResponseAsync(SqlResponse response, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tif (response.Count > 0)\n\t\t\t{\n\t\t\t\tOutputParameters.Enqueue(await ReadRowAsync(cancellationToken).ConfigureAwait(false));\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\t#endregion\n\n\tprotected override void TransactionUpdated(object sender, EventArgs e)\n\t{\n\t\tif (Transaction != null && TransactionUpdate != null)\n\t\t{\n\t\t\tTransaction.Update -= TransactionUpdate;\n\t\t}\n\n\t\tState = StatementState.Closed;\n\t\tTransactionUpdate = null;\n\t\t_allRowsFetched = false;\n\t}\n\n\tprotected Descriptor[] ParseSqlInfo(byte[] info, byte[] items, Descriptor[] rowDescs)\n\t{\n\t\treturn ParseTruncSqlInfo(info, items, rowDescs);\n\t}\n\tprotected ValueTask<Descriptor[]> ParseSqlInfoAsync(byte[] info, byte[] items, Descriptor[] rowDescs, CancellationToken cancellationToken = default)\n\t{\n\t\treturn ParseTruncSqlInfoAsync(info, items, rowDescs, cancellationToken);\n\t}\n\n\tprotected Descriptor[] ParseTruncSqlInfo(byte[] info, byte[] items, Descriptor[] rowDescs)\n\t{\n\t\tvar currentPosition = 0;\n\t\tvar currentDescriptorIndex = -1;\n\t\tvar currentItemIndex = 0;\n\t\twhile (info[currentPosition] != IscCodes.isc_info_end)\n\t\t{\n\t\t\tbyte item;\n\t\t\twhile ((item = info[currentPosition++]) != IscCodes.isc_info_sql_describe_end)\n\t\t\t{\n\t\t\t\tswitch (item)\n\t\t\t\t{\n\t\t\t\t\tcase IscCodes.isc_info_truncated:\n\t\t\t\t\t\tcurrentItemIndex--;\n\n\t\t\t\t\t\tvar newItems = new List<byte>(items.Length);\n\t\t\t\t\t\tvar part = 0;\n\t\t\t\t\t\tvar chock = 0;\n\t\t\t\t\t\tfor (var i = 0; i < items.Length; i++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (items[i] == IscCodes.isc_info_sql_describe_end)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tnewItems.Insert(chock, IscCodes.isc_info_sql_sqlda_start);\n\t\t\t\t\t\t\t\tnewItems.Insert(chock + 1, 2);\n\n\t\t\t\t\t\t\t\tvar processedItems = (rowDescs[part] != null ? rowDescs[part].Count : (short)0);\n\t\t\t\t\t\t\t\tnewItems.Insert(chock + 2, (byte)((part == currentDescriptorIndex ? currentItemIndex : processedItems) & 255));\n\t\t\t\t\t\t\t\tnewItems.Insert(chock + 3, (byte)((part == currentDescriptorIndex ? currentItemIndex : processedItems) >> 8));\n\n\t\t\t\t\t\t\t\tpart++;\n\t\t\t\t\t\t\t\tchock = i + 4 + 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tnewItems.Add(items[i]);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tinfo = GetSqlInfo(newItems.ToArray(), info.Length);\n\n\t\t\t\t\t\tcurrentPosition = 0;\n\t\t\t\t\t\tcurrentDescriptorIndex = -1;\n\t\t\t\t\t\tgoto Break;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_select:\n\t\t\t\t\tcase IscCodes.isc_info_sql_bind:\n\t\t\t\t\t\tcurrentDescriptorIndex++;\n\n\t\t\t\t\t\tif (info[currentPosition] == IscCodes.isc_info_truncated)\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcurrentPosition++;\n\t\t\t\t\t\tvar len = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\tif (rowDescs[currentDescriptorIndex] == null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvar n = IscHelper.VaxInteger(info, currentPosition, len);\n\t\t\t\t\t\t\trowDescs[currentDescriptorIndex] = new Descriptor((short)n);\n\t\t\t\t\t\t\tif (n == 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\t\t\tgoto Break;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_sqlda_seq:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\tcurrentItemIndex = (int)IscHelper.VaxInteger(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_type:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\trowDescs[currentDescriptorIndex][currentItemIndex - 1].DataType = (short)IscHelper.VaxInteger(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_sub_type:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\trowDescs[currentDescriptorIndex][currentItemIndex - 1].SubType = (short)IscHelper.VaxInteger(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_scale:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\trowDescs[currentDescriptorIndex][currentItemIndex - 1].NumericScale = (short)IscHelper.VaxInteger(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_length:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\trowDescs[currentDescriptorIndex][currentItemIndex - 1].Length = (short)IscHelper.VaxInteger(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_field:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\trowDescs[currentDescriptorIndex][currentItemIndex - 1].Name = _database.Charset.GetString(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_relation:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\trowDescs[currentDescriptorIndex][currentItemIndex - 1].Relation = _database.Charset.GetString(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_owner:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\trowDescs[currentDescriptorIndex][currentItemIndex - 1].Owner = _database.Charset.GetString(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_alias:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\trowDescs[currentDescriptorIndex][currentItemIndex - 1].Alias = _database.Charset.GetString(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow IscException.ForErrorCode(IscCodes.isc_dsql_sqlda_err);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// just to get out of the loop\n\t\t\tBreak:\n\t\t\t{ }\n\t\t}\n\t\treturn rowDescs;\n\t}\n\tprotected async ValueTask<Descriptor[]> ParseTruncSqlInfoAsync(byte[] info, byte[] items, Descriptor[] rowDescs, CancellationToken cancellationToken = default)\n\t{\n\t\tvar currentPosition = 0;\n\t\tvar currentDescriptorIndex = -1;\n\t\tvar currentItemIndex = 0;\n\t\twhile (info[currentPosition] != IscCodes.isc_info_end)\n\t\t{\n\t\t\tbyte item;\n\t\t\twhile ((item = info[currentPosition++]) != IscCodes.isc_info_sql_describe_end)\n\t\t\t{\n\t\t\t\tswitch (item)\n\t\t\t\t{\n\t\t\t\t\tcase IscCodes.isc_info_truncated:\n\t\t\t\t\t\tcurrentItemIndex--;\n\n\t\t\t\t\t\tvar newItems = new List<byte>(items.Length);\n\t\t\t\t\t\tvar part = 0;\n\t\t\t\t\t\tvar chock = 0;\n\t\t\t\t\t\tfor (var i = 0; i < items.Length; i++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (items[i] == IscCodes.isc_info_sql_describe_end)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tnewItems.Insert(chock, IscCodes.isc_info_sql_sqlda_start);\n\t\t\t\t\t\t\t\tnewItems.Insert(chock + 1, 2);\n\n\t\t\t\t\t\t\t\tvar processedItems = (rowDescs[part] != null ? rowDescs[part].Count : (short)0);\n\t\t\t\t\t\t\t\tnewItems.Insert(chock + 2, (byte)((part == currentDescriptorIndex ? currentItemIndex : processedItems) & 255));\n\t\t\t\t\t\t\t\tnewItems.Insert(chock + 3, (byte)((part == currentDescriptorIndex ? currentItemIndex : processedItems) >> 8));\n\n\t\t\t\t\t\t\t\tpart++;\n\t\t\t\t\t\t\t\tchock = i + 4 + 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tnewItems.Add(items[i]);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tinfo = await GetSqlInfoAsync(newItems.ToArray(), info.Length, cancellationToken).ConfigureAwait(false);\n\n\t\t\t\t\t\tcurrentPosition = 0;\n\t\t\t\t\t\tcurrentDescriptorIndex = -1;\n\t\t\t\t\t\tgoto Break;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_select:\n\t\t\t\t\tcase IscCodes.isc_info_sql_bind:\n\t\t\t\t\t\tcurrentDescriptorIndex++;\n\n\t\t\t\t\t\tif (info[currentPosition] == IscCodes.isc_info_truncated)\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcurrentPosition++;\n\t\t\t\t\t\tvar len = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\tif (rowDescs[currentDescriptorIndex] == null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvar n = IscHelper.VaxInteger(info, currentPosition, len);\n\t\t\t\t\t\t\trowDescs[currentDescriptorIndex] = new Descriptor((short)n);\n\t\t\t\t\t\t\tif (n == 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\t\t\tgoto Break;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_sqlda_seq:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\tcurrentItemIndex = (int)IscHelper.VaxInteger(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_type:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\trowDescs[currentDescriptorIndex][currentItemIndex - 1].DataType = (short)IscHelper.VaxInteger(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_sub_type:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\trowDescs[currentDescriptorIndex][currentItemIndex - 1].SubType = (short)IscHelper.VaxInteger(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_scale:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\trowDescs[currentDescriptorIndex][currentItemIndex - 1].NumericScale = (short)IscHelper.VaxInteger(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_length:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\trowDescs[currentDescriptorIndex][currentItemIndex - 1].Length = (short)IscHelper.VaxInteger(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_field:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\trowDescs[currentDescriptorIndex][currentItemIndex - 1].Name = _database.Charset.GetString(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_relation:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\trowDescs[currentDescriptorIndex][currentItemIndex - 1].Relation = _database.Charset.GetString(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_owner:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\trowDescs[currentDescriptorIndex][currentItemIndex - 1].Owner = _database.Charset.GetString(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_info_sql_alias:\n\t\t\t\t\t\tlen = (int)IscHelper.VaxInteger(info, currentPosition, 2);\n\t\t\t\t\t\tcurrentPosition += 2;\n\t\t\t\t\t\trowDescs[currentDescriptorIndex][currentItemIndex - 1].Alias = _database.Charset.GetString(info, currentPosition, len);\n\t\t\t\t\t\tcurrentPosition += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow IscException.ForErrorCode(IscCodes.isc_dsql_sqlda_err);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// just to get out of the loop\n\t\t\tBreak:\n\t\t\t{ }\n\t\t}\n\t\treturn rowDescs;\n\t}\n\n\tprotected virtual byte[] WriteParameters()\n\t{\n\t\tif (_parameters == null)\n\t\t\treturn null;\n\n\t\tusing (var ms = new MemoryStream(256))\n\t\t{\n\t\t\tvar xdr = new XdrReaderWriter(new DataProviderStreamWrapper(ms), _database.Charset);\n\t\t\tfor (var i = 0; i < _parameters.Count; i++)\n\t\t\t{\n\t\t\t\tvar field = _parameters[i];\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tWriteRawParameter(xdr, field);\n\t\t\t\t\txdr.Write(field.NullFlag);\n\t\t\t\t}\n\t\t\t\tcatch (IOException ex)\n\t\t\t\t{\n\t\t\t\t\tthrow IscException.ForIOException(ex);\n\t\t\t\t}\n\t\t\t}\n\t\t\txdr.Flush();\n\t\t\treturn ms.ToArray();\n\t\t}\n\t}\n\tprotected virtual async ValueTask<byte[]> WriteParametersAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_parameters == null)\n\t\t\treturn null;\n\n\t\tusing (var ms = new MemoryStream(256))\n\t\t{\n\t\t\tvar xdr = new XdrReaderWriter(new DataProviderStreamWrapper(ms), _database.Charset);\n\t\t\tfor (var i = 0; i < _parameters.Count; i++)\n\t\t\t{\n\t\t\t\tvar field = _parameters[i];\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tawait WriteRawParameterAsync(xdr, field, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait xdr.WriteAsync(field.NullFlag, cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t\tcatch (IOException ex)\n\t\t\t\t{\n\t\t\t\t\tthrow IscException.ForIOException(ex);\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\treturn ms.ToArray();\n\t\t}\n\t}\n\n\tprotected void WriteRawParameter(IXdrWriter xdr, DbField field)\n\t{\n\t\tif (field.DbDataType != DbDataType.Null)\n\t\t{\n\t\t\tfield.FixNull();\n\n\t\t\tswitch (field.DbDataType)\n\t\t\t{\n\t\t\t\tcase DbDataType.Char:\n\t\t\t\t\tif (field.Charset.IsOctetsCharset)\n\t\t\t\t\t{\n\t\t\t\t\t\txdr.WriteOpaque(field.DbValue.GetBinary(), field.Length);\n\t\t\t\t\t}\n\t\t\t\t\telse if (field.Charset.IsNoneCharset)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar bvalue = field.Charset.GetBytes(field.DbValue.GetString());\n\t\t\t\t\t\tif (bvalue.Length > field.Length)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow IscException.ForErrorCodes(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });\n\t\t\t\t\t\t}\n\t\t\t\t\t\txdr.WriteOpaque(bvalue, field.Length);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tvar svalue = field.DbValue.GetString();\n\t\t\t\t\t\tif ((field.Length % field.Charset.BytesPerCharacter) == 0 && svalue.EnumerateRunesToChars().Count() > field.CharCount)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow IscException.ForErrorCodes(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });\n\t\t\t\t\t\t}\n\t\t\t\t\t\txdr.WriteOpaque(field.Charset.GetBytes(svalue), field.Length);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.VarChar:\n\t\t\t\t\tif (field.Charset.IsOctetsCharset)\n\t\t\t\t\t{\n\t\t\t\t\t\txdr.WriteBuffer(field.DbValue.GetBinary());\n\t\t\t\t\t}\n\t\t\t\t\telse if (field.Charset.IsNoneCharset)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar bvalue = field.Charset.GetBytes(field.DbValue.GetString());\n\t\t\t\t\t\tif (bvalue.Length > field.Length)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow IscException.ForErrorCodes(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });\n\t\t\t\t\t\t}\n\t\t\t\t\t\txdr.WriteBuffer(bvalue);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tvar svalue = field.DbValue.GetString();\n\t\t\t\t\t\tif ((field.Length % field.Charset.BytesPerCharacter) == 0 && svalue.EnumerateRunesToChars().Count() > field.CharCount)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow IscException.ForErrorCodes(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });\n\t\t\t\t\t\t}\n\t\t\t\t\t\txdr.WriteBuffer(field.Charset.GetBytes(svalue));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.SmallInt:\n\t\t\t\t\txdr.Write(field.DbValue.GetInt16());\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Integer:\n\t\t\t\t\txdr.Write(field.DbValue.GetInt32());\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.BigInt:\n\t\t\t\tcase DbDataType.Array:\n\t\t\t\tcase DbDataType.Binary:\n\t\t\t\tcase DbDataType.Text:\n\t\t\t\t\txdr.Write(field.DbValue.GetInt64());\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Decimal:\n\t\t\t\tcase DbDataType.Numeric:\n\t\t\t\t\txdr.Write(field.DbValue.GetDecimal(), field.DataType, field.NumericScale);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Float:\n\t\t\t\t\txdr.Write(field.DbValue.GetFloat());\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Guid:\n\t\t\t\t\txdr.Write(field.DbValue.GetGuid(), field.SqlType);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Double:\n\t\t\t\t\txdr.Write(field.DbValue.GetDouble());\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Date:\n\t\t\t\t\txdr.Write(field.DbValue.GetDate());\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Time:\n\t\t\t\t\txdr.Write(field.DbValue.GetTime());\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\t\txdr.Write(field.DbValue.GetDate());\n\t\t\t\t\txdr.Write(field.DbValue.GetTime());\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Boolean:\n\t\t\t\t\txdr.Write(field.DbValue.GetBoolean());\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.TimeStampTZ:\n\t\t\t\t\txdr.Write(field.DbValue.GetDate());\n\t\t\t\t\txdr.Write(field.DbValue.GetTime());\n\t\t\t\t\txdr.Write(field.DbValue.GetTimeZoneId());\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.TimeStampTZEx:\n\t\t\t\t\txdr.Write(field.DbValue.GetDate());\n\t\t\t\t\txdr.Write(field.DbValue.GetTime());\n\t\t\t\t\txdr.Write(field.DbValue.GetTimeZoneId());\n\t\t\t\t\txdr.Write((short)0);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.TimeTZ:\n\t\t\t\t\txdr.Write(field.DbValue.GetTime());\n\t\t\t\t\txdr.Write(field.DbValue.GetTimeZoneId());\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.TimeTZEx:\n\t\t\t\t\txdr.Write(field.DbValue.GetTime());\n\t\t\t\t\txdr.Write(field.DbValue.GetTimeZoneId());\n\t\t\t\t\txdr.Write((short)0);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Dec16:\n\t\t\t\t\txdr.Write(field.DbValue.GetDecFloat(), 16);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Dec34:\n\t\t\t\t\txdr.Write(field.DbValue.GetDecFloat(), 34);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Int128:\n\t\t\t\t\txdr.Write(field.DbValue.GetInt128());\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow IscException.ForStrParam($\"Unknown SQL data type: {field.DataType}.\");\n\t\t\t}\n\t\t}\n\t}\n\tprotected async ValueTask WriteRawParameterAsync(IXdrWriter xdr, DbField field, CancellationToken cancellationToken = default)\n\t{\n\t\tif (field.DbDataType != DbDataType.Null)\n\t\t{\n\t\t\tfield.FixNull();\n\n\t\t\tswitch (field.DbDataType)\n\t\t\t{\n\t\t\t\tcase DbDataType.Char:\n\t\t\t\t\tif (field.Charset.IsOctetsCharset)\n\t\t\t\t\t{\n\t\t\t\t\t\tawait xdr.WriteOpaqueAsync(await field.DbValue.GetBinaryAsync(cancellationToken).ConfigureAwait(false), field.Length, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t}\n\t\t\t\t\telse if (field.Charset.IsNoneCharset)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar bvalue = field.Charset.GetBytes(await field.DbValue.GetStringAsync(cancellationToken).ConfigureAwait(false));\n\t\t\t\t\t\tif (bvalue.Length > field.Length)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow IscException.ForErrorCodes(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait xdr.WriteOpaqueAsync(bvalue, field.Length, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tvar svalue = await field.DbValue.GetStringAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\tif ((field.Length % field.Charset.BytesPerCharacter) == 0 && svalue.EnumerateRunesToChars().Count() > field.CharCount)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow IscException.ForErrorCodes(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait xdr.WriteOpaqueAsync(field.Charset.GetBytes(svalue), field.Length, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.VarChar:\n\t\t\t\t\tif (field.Charset.IsOctetsCharset)\n\t\t\t\t\t{\n\t\t\t\t\t\tawait xdr.WriteBufferAsync(await field.DbValue.GetBinaryAsync(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t}\n\t\t\t\t\telse if (field.Charset.IsNoneCharset)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar bvalue = field.Charset.GetBytes(await field.DbValue.GetStringAsync(cancellationToken).ConfigureAwait(false));\n\t\t\t\t\t\tif (bvalue.Length > field.Length)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow IscException.ForErrorCodes(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait xdr.WriteBufferAsync(bvalue, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tvar svalue = await field.DbValue.GetStringAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\tif ((field.Length % field.Charset.BytesPerCharacter) == 0 && svalue.EnumerateRunesToChars().Count() > field.CharCount)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow IscException.ForErrorCodes(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait xdr.WriteBufferAsync(field.Charset.GetBytes(svalue), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.SmallInt:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetInt16(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Integer:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetInt32(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.BigInt:\n\t\t\t\tcase DbDataType.Array:\n\t\t\t\tcase DbDataType.Binary:\n\t\t\t\tcase DbDataType.Text:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetInt64(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Decimal:\n\t\t\t\tcase DbDataType.Numeric:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetDecimal(), field.DataType, field.NumericScale, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Float:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetFloat(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Guid:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetGuid(), field.SqlType, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Double:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetDouble(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Date:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetDate(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Time:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetTime(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetDate(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetTime(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Boolean:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetBoolean(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.TimeStampTZ:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetDate(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetTime(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetTimeZoneId(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.TimeStampTZEx:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetDate(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetTime(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetTimeZoneId(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait xdr.WriteAsync((short)0, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.TimeTZ:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetTime(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetTimeZoneId(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.TimeTZEx:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetTime(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetTimeZoneId(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait xdr.WriteAsync((short)0, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Dec16:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetDecFloat(), 16, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Dec34:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetDecFloat(), 34, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Int128:\n\t\t\t\t\tawait xdr.WriteAsync(field.DbValue.GetInt128(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow IscException.ForStrParam($\"Unknown SQL data type: {field.DataType}.\");\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected object ReadRawValue(IXdrReader xdr, DbField field)\n\t{\n\t\tvar innerCharset = !_database.Charset.IsNoneCharset ? _database.Charset : field.Charset;\n\n\t\tswitch (field.DbDataType)\n\t\t{\n\t\t\tcase DbDataType.Char:\n\t\t\t\tif (field.Charset.IsOctetsCharset)\n\t\t\t\t{\n\t\t\t\t\treturn xdr.ReadOpaque(field.Length);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tvar s = xdr.ReadString(innerCharset, field.Length);\n\t\t\t\t\tvar runes = s.EnumerateRunesToChars().ToList();\n\t\t\t\t\tif ((field.Length % field.Charset.BytesPerCharacter) == 0 &&\n\t\t\t\t\t\trunes.Count > field.CharCount)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn new string([.. runes.Take(field.CharCount).SelectMany(x => x)]);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\treturn s;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\tcase DbDataType.VarChar:\n\t\t\t\tif (field.Charset.IsOctetsCharset)\n\t\t\t\t{\n\t\t\t\t\treturn xdr.ReadBuffer();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn xdr.ReadString(innerCharset);\n\t\t\t\t}\n\n\t\t\tcase DbDataType.SmallInt:\n\t\t\t\treturn xdr.ReadInt16();\n\n\t\t\tcase DbDataType.Integer:\n\t\t\t\treturn xdr.ReadInt32();\n\n\t\t\tcase DbDataType.Array:\n\t\t\tcase DbDataType.Binary:\n\t\t\tcase DbDataType.Text:\n\t\t\tcase DbDataType.BigInt:\n\t\t\t\treturn xdr.ReadInt64();\n\n\t\t\tcase DbDataType.Decimal:\n\t\t\tcase DbDataType.Numeric:\n\t\t\t\treturn xdr.ReadDecimal(field.DataType, field.NumericScale);\n\n\t\t\tcase DbDataType.Float:\n\t\t\t\treturn xdr.ReadSingle();\n\n\t\t\tcase DbDataType.Guid:\n\t\t\t\treturn xdr.ReadGuid(field.SqlType);\n\n\t\t\tcase DbDataType.Double:\n\t\t\t\treturn xdr.ReadDouble();\n\n\t\t\tcase DbDataType.Date:\n\t\t\t\treturn xdr.ReadDate();\n\n\t\t\tcase DbDataType.Time:\n\t\t\t\treturn xdr.ReadTime();\n\n\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\treturn xdr.ReadDateTime();\n\n\t\t\tcase DbDataType.Boolean:\n\t\t\t\treturn xdr.ReadBoolean();\n\n\t\t\tcase DbDataType.TimeStampTZ:\n\t\t\t\treturn xdr.ReadZonedDateTime(false);\n\n\t\t\tcase DbDataType.TimeStampTZEx:\n\t\t\t\treturn xdr.ReadZonedDateTime(true);\n\n\t\t\tcase DbDataType.TimeTZ:\n\t\t\t\treturn xdr.ReadZonedTime(false);\n\n\t\t\tcase DbDataType.TimeTZEx:\n\t\t\t\treturn xdr.ReadZonedTime(true);\n\n\t\t\tcase DbDataType.Dec16:\n\t\t\t\treturn xdr.ReadDec16();\n\n\t\t\tcase DbDataType.Dec34:\n\t\t\t\treturn xdr.ReadDec34();\n\n\t\t\tcase DbDataType.Int128:\n\t\t\t\treturn xdr.ReadInt128();\n\n\t\t\tdefault:\n\t\t\t\tthrow TypeHelper.InvalidDataType((int)field.DbDataType);\n\t\t}\n\t}\n\tprotected async ValueTask<object> ReadRawValueAsync(IXdrReader xdr, DbField field, CancellationToken cancellationToken = default)\n\t{\n\t\tvar innerCharset = !_database.Charset.IsNoneCharset ? _database.Charset : field.Charset;\n\n\t\tswitch (field.DbDataType)\n\t\t{\n\t\t\tcase DbDataType.Char:\n\t\t\t\tif (field.Charset.IsOctetsCharset)\n\t\t\t\t{\n\t\t\t\t\treturn await xdr.ReadOpaqueAsync(field.Length, cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tvar s = await xdr.ReadStringAsync(innerCharset, field.Length, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tvar runes = s.EnumerateRunesToChars().ToList();\n\t\t\t\t\tif ((field.Length % field.Charset.BytesPerCharacter) == 0 &&\n\t\t\t\t\t\trunes.Count > field.CharCount)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn new string([.. runes.Take(field.CharCount).SelectMany(x => x)]);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\treturn s;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\tcase DbDataType.VarChar:\n\t\t\t\tif (field.Charset.IsOctetsCharset)\n\t\t\t\t{\n\t\t\t\t\treturn await xdr.ReadBufferAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn await xdr.ReadStringAsync(innerCharset, cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\n\t\t\tcase DbDataType.SmallInt:\n\t\t\t\treturn await xdr.ReadInt16Async(cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.Integer:\n\t\t\t\treturn await xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.Array:\n\t\t\tcase DbDataType.Binary:\n\t\t\tcase DbDataType.Text:\n\t\t\tcase DbDataType.BigInt:\n\t\t\t\treturn await xdr.ReadInt64Async(cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.Decimal:\n\t\t\tcase DbDataType.Numeric:\n\t\t\t\treturn await xdr.ReadDecimalAsync(field.DataType, field.NumericScale, cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.Float:\n\t\t\t\treturn await xdr.ReadSingleAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.Guid:\n\t\t\t\treturn await xdr.ReadGuidAsync(field.SqlType, cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.Double:\n\t\t\t\treturn await xdr.ReadDoubleAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.Date:\n\t\t\t\treturn await xdr.ReadDateAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.Time:\n\t\t\t\treturn await xdr.ReadTimeAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\treturn await xdr.ReadDateTimeAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.Boolean:\n\t\t\t\treturn await xdr.ReadBooleanAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.TimeStampTZ:\n\t\t\t\treturn await xdr.ReadZonedDateTimeAsync(false, cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.TimeStampTZEx:\n\t\t\t\treturn await xdr.ReadZonedDateTimeAsync(true, cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.TimeTZ:\n\t\t\t\treturn await xdr.ReadZonedTimeAsync(false, cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.TimeTZEx:\n\t\t\t\treturn await xdr.ReadZonedTimeAsync(true, cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.Dec16:\n\t\t\t\treturn await xdr.ReadDec16Async(cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.Dec34:\n\t\t\t\treturn await xdr.ReadDec34Async(cancellationToken).ConfigureAwait(false);\n\n\t\t\tcase DbDataType.Int128:\n\t\t\t\treturn await xdr.ReadInt128Async(cancellationToken).ConfigureAwait(false);\n\n\t\t\tdefault:\n\t\t\t\tthrow TypeHelper.InvalidDataType((int)field.DbDataType);\n\t\t}\n\t}\n\n\tprotected void Clear()\n\t{\n\t\tif (_rows != null && _rows.Count > 0)\n\t\t{\n\t\t\t_rows.Clear();\n\t\t}\n\t\tif (OutputParameters != null && OutputParameters.Count > 0)\n\t\t{\n\t\t\tOutputParameters.Clear();\n\t\t}\n\n\t\t_allRowsFetched = false;\n\t}\n\n\tprotected void ClearAll()\n\t{\n\t\tClear();\n\n\t\t_parameters = null;\n\t\t_fields = null;\n\t}\n\n\tprotected virtual DbValue[] ReadRow()\n\t{\n\t\tvar row = new DbValue[_fields.Count];\n\t\ttry\n\t\t{\n\t\t\tfor (var i = 0; i < _fields.Count; i++)\n\t\t\t{\n\t\t\t\tvar value = ReadRawValue(_database.Xdr, _fields[i]);\n\t\t\t\tvar sqlInd = _database.Xdr.ReadInt32();\n\t\t\t\tif (sqlInd == -1)\n\t\t\t\t{\n\t\t\t\t\trow[i] = new DbValue(this, _fields[i], null);\n\t\t\t\t}\n\t\t\t\telse if (sqlInd == 0)\n\t\t\t\t{\n\t\t\t\t\trow[i] = new DbValue(this, _fields[i], value);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tthrow IscException.ForStrParam($\"Invalid {nameof(sqlInd)} value: {sqlInd}.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t\treturn row;\n\t}\n\tprotected virtual async ValueTask<DbValue[]> ReadRowAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar row = new DbValue[_fields.Count];\n\t\ttry\n\t\t{\n\t\t\tfor (var i = 0; i < _fields.Count; i++)\n\t\t\t{\n\t\t\t\tvar value = await ReadRawValueAsync(_database.Xdr, _fields[i], cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar sqlInd = await _database.Xdr.ReadInt32Async(cancellationToken).ConfigureAwait(false);\n\t\t\t\tif (sqlInd == -1)\n\t\t\t\t{\n\t\t\t\t\trow[i] = new DbValue(this, _fields[i], null);\n\t\t\t\t}\n\t\t\t\telse if (sqlInd == 0)\n\t\t\t\t{\n\t\t\t\t\trow[i] = new DbValue(this, _fields[i], value);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tthrow IscException.ForStrParam($\"Invalid {nameof(sqlInd)} value: {sqlInd}.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t\treturn row;\n\t}\n\n\t#endregion\n\n\t#region Protected Internal Methods\n\n\tprotected internal byte[] GetParameterData(IDescriptorFiller descriptorFiller, int index)\n\t{\n\t\tdescriptorFiller.Fill(_parameters, index);\n\t\treturn WriteParameters();\n\t}\n\tprotected internal async ValueTask<byte[]> GetParameterDataAsync(IDescriptorFiller descriptorFiller, int index, CancellationToken cancellationToken = default)\n\t{\n\t\tawait descriptorFiller.FillAsync(_parameters, index, cancellationToken).ConfigureAwait(false);\n\t\treturn WriteParameters();\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version10/GdsTransaction.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version10;\n\ninternal class GdsTransaction : TransactionBase\n{\n\t#region Fields\n\n\tprivate int _handle;\n\tprivate bool _disposed;\n\tprivate GdsDatabase _database;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic override int Handle\n\t{\n\t\tget { return _handle; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic GdsTransaction(GdsDatabase database)\n\t{\n\t\t_database = database;\n\t\tState = TransactionState.NoTransaction;\n\t}\n\n\t#endregion\n\n\t#region Dispose2\n\n\tpublic override void Dispose2()\n\t{\n\t\tif (!_disposed)\n\t\t{\n\t\t\t_disposed = true;\n\t\t\tif (State != TransactionState.NoTransaction)\n\t\t\t{\n\t\t\t\tRollback();\n\t\t\t}\n\t\t\t_database = null;\n\t\t\t_handle = 0;\n\t\t\tState = TransactionState.NoTransaction;\n\t\t\tbase.Dispose2();\n\t\t}\n\t}\n\tpublic override async ValueTask Dispose2Async(CancellationToken cancellationToken = default)\n\t{\n\t\tif (!_disposed)\n\t\t{\n\t\t\t_disposed = true;\n\t\t\tif (State != TransactionState.NoTransaction)\n\t\t\t{\n\t\t\t\tawait RollbackAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\t_database = null;\n\t\t\t_handle = 0;\n\t\t\tState = TransactionState.NoTransaction;\n\t\t\tawait base.Dispose2Async(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic override void BeginTransaction(TransactionParameterBuffer tpb)\n\t{\n\t\tif (State != TransactionState.NoTransaction)\n\t\t{\n\t\t\tthrow new InvalidOperationException();\n\t\t}\n\n\t\ttry\n\t\t{\n\t\t\t_database.Xdr.Write(IscCodes.op_transaction);\n\t\t\t_database.Xdr.Write(_database.Handle);\n\t\t\t_database.Xdr.WriteBuffer(tpb.ToArray());\n\t\t\t_database.Xdr.Flush();\n\n\t\t\tvar response = (GenericResponse)_database.ReadResponse();\n\n\t\t\t_database.TransactionCount++;\n\n\t\t\t_handle = response.ObjectHandle;\n\t\t\tState = TransactionState.Active;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask BeginTransactionAsync(TransactionParameterBuffer tpb, CancellationToken cancellationToken = default)\n\t{\n\t\tif (State != TransactionState.NoTransaction)\n\t\t{\n\t\t\tthrow new InvalidOperationException();\n\t\t}\n\n\t\ttry\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_transaction, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_database.Handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteBufferAsync(tpb.ToArray(), cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar response = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t_database.TransactionCount++;\n\n\t\t\t_handle = response.ObjectHandle;\n\t\t\tState = TransactionState.Active;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override void Commit()\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\ttry\n\t\t{\n\t\t\t_database.Xdr.Write(IscCodes.op_commit);\n\t\t\t_database.Xdr.Write(_handle);\n\t\t\t_database.Xdr.Flush();\n\n\t\t\t_database.ReadResponse();\n\n\t\t\t_database.TransactionCount--;\n\n\t\t\tOnUpdate(EventArgs.Empty);\n\n\t\t\tState = TransactionState.NoTransaction;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask CommitAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\ttry\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_commit, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t_database.TransactionCount--;\n\n\t\t\tOnUpdate(EventArgs.Empty);\n\n\t\t\tState = TransactionState.NoTransaction;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override void Rollback()\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\ttry\n\t\t{\n\t\t\t_database.Xdr.Write(IscCodes.op_rollback);\n\t\t\t_database.Xdr.Write(_handle);\n\t\t\t_database.Xdr.Flush();\n\n\t\t\t_database.ReadResponse();\n\n\t\t\t_database.TransactionCount--;\n\n\t\t\tOnUpdate(EventArgs.Empty);\n\n\t\t\tState = TransactionState.NoTransaction;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask RollbackAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\ttry\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_rollback, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t_database.TransactionCount--;\n\n\t\t\tOnUpdate(EventArgs.Empty);\n\n\t\t\tState = TransactionState.NoTransaction;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override void CommitRetaining()\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\ttry\n\t\t{\n\t\t\t_database.Xdr.Write(IscCodes.op_commit_retaining);\n\t\t\t_database.Xdr.Write(_handle);\n\t\t\t_database.Xdr.Flush();\n\n\t\t\t_database.ReadResponse();\n\n\t\t\tState = TransactionState.Active;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask CommitRetainingAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\ttry\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_commit_retaining, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tState = TransactionState.Active;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override void RollbackRetaining()\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\ttry\n\t\t{\n\t\t\t_database.Xdr.Write(IscCodes.op_rollback_retaining);\n\t\t\t_database.Xdr.Write(_handle);\n\t\t\t_database.Xdr.Flush();\n\n\t\t\t_database.ReadResponse();\n\n\t\t\tState = TransactionState.Active;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask RollbackRetainingAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\ttry\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_rollback_retaining, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tState = TransactionState.Active;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override void Prepare()\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\ttry\n\t\t{\n\t\t\tState = TransactionState.NoTransaction;\n\n\t\t\t_database.Xdr.Write(IscCodes.op_prepare);\n\t\t\t_database.Xdr.Write(_handle);\n\t\t\t_database.Xdr.Flush();\n\n\t\t\t_database.ReadResponse();\n\n\t\t\tState = TransactionState.Prepared;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask PrepareAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\ttry\n\t\t{\n\t\t\tState = TransactionState.NoTransaction;\n\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_prepare, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tState = TransactionState.Prepared;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override void Prepare(byte[] buffer)\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\ttry\n\t\t{\n\t\t\tState = TransactionState.NoTransaction;\n\n\t\t\t_database.Xdr.Write(IscCodes.op_prepare2);\n\t\t\t_database.Xdr.Write(_handle);\n\t\t\t_database.Xdr.WriteBuffer(buffer, buffer.Length);\n\t\t\t_database.Xdr.Flush();\n\n\t\t\t_database.ReadResponse();\n\n\t\t\tState = TransactionState.Prepared;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask PrepareAsync(byte[] buffer, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\ttry\n\t\t{\n\t\t\tState = TransactionState.NoTransaction;\n\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_prepare2, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteBufferAsync(buffer, buffer.Length, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tState = TransactionState.Prepared;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override List<object> GetTransactionInfo(byte[] items)\n\t{\n\t\treturn GetTransactionInfo(items, IscCodes.DEFAULT_MAX_BUFFER_SIZE);\n\t}\n\tpublic override ValueTask<List<object>> GetTransactionInfoAsync(byte[] items, CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetTransactionInfoAsync(items, IscCodes.DEFAULT_MAX_BUFFER_SIZE, cancellationToken);\n\t}\n\n\tpublic override List<object> GetTransactionInfo(byte[] items, int bufferLength)\n\t{\n\t\tvar buffer = new byte[bufferLength];\n\t\tDatabaseInfo(items, buffer, buffer.Length);\n\t\treturn IscHelper.ParseTransactionInfo(buffer, _database.Charset);\n\t}\n\tpublic override async ValueTask<List<object>> GetTransactionInfoAsync(byte[] items, int bufferLength, CancellationToken cancellationToken = default)\n\t{\n\t\tvar buffer = new byte[bufferLength];\n\t\tawait DatabaseInfoAsync(items, buffer, buffer.Length, cancellationToken).ConfigureAwait(false);\n\t\treturn IscHelper.ParseTransactionInfo(buffer, _database.Charset);\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void DatabaseInfo(byte[] items, byte[] buffer, int bufferLength)\n\t{\n\t\ttry\n\t\t{\n\t\t\t_database.Xdr.Write(IscCodes.op_info_transaction);\n\t\t\t_database.Xdr.Write(_handle);\n\t\t\t_database.Xdr.Write(GdsDatabase.Incarnation);\n\t\t\t_database.Xdr.WriteBuffer(items, items.Length);\n\t\t\t_database.Xdr.Write(bufferLength);\n\n\t\t\t_database.Xdr.Flush();\n\n\t\t\tvar response = (GenericResponse)_database.ReadResponse();\n\n\t\t\tvar responseLength = bufferLength;\n\n\t\t\tif (response.Data.Length < bufferLength)\n\t\t\t{\n\t\t\t\tresponseLength = response.Data.Length;\n\t\t\t}\n\n\t\t\tBuffer.BlockCopy(response.Data, 0, buffer, 0, responseLength);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tprivate async ValueTask DatabaseInfoAsync(byte[] items, byte[] buffer, int bufferLength, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait _database.Xdr.WriteAsync(IscCodes.op_info_transaction, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(GdsDatabase.Incarnation, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteBufferAsync(items, items.Length, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _database.Xdr.WriteAsync(bufferLength, cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar response = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar responseLength = bufferLength;\n\n\t\t\tif (response.Data.Length < bufferLength)\n\t\t\t{\n\t\t\t\tresponseLength = response.Data.Length;\n\t\t\t}\n\n\t\t\tBuffer.BlockCopy(response.Data, 0, buffer, 0, responseLength);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version11/AuthResponse.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Vladimir Bodecek, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.Data.Client.Managed;\n\nnamespace FirebirdSql.Data.Client.Managed.Version11;\n\ninternal class AuthResponse : IResponse\n{\n\tpublic byte[] Data { get; }\n\n\tpublic AuthResponse(byte[] data)\n\t{\n\t\tData = data;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version11/GdsDatabase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net), Vladimir Bodecek\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Client.Managed.Sspi;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version11;\n\ninternal class GdsDatabase : Version10.GdsDatabase\n{\n\tprivate readonly Queue<(Action<IResponse>, Func<IResponse, CancellationToken, ValueTask>)> _deferredPackets;\n\n\tpublic GdsDatabase(GdsConnection connection)\n\t\t: base(connection)\n\t{\n\t\t_deferredPackets = new Queue<(Action<IResponse>, Func<IResponse, CancellationToken, ValueTask>)>();\n\t}\n\n\tpublic override StatementBase CreateStatement()\n\t{\n\t\treturn new GdsStatement(this);\n\t}\n\n\tpublic override StatementBase CreateStatement(TransactionBase transaction)\n\t{\n\t\treturn new GdsStatement(this, (Version10.GdsTransaction)transaction);\n\t}\n\n\tpublic override void AttachWithTrustedAuth(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey)\n\t{\n\t\ttry\n\t\t{\n\t\t\tusing (var sspiHelper = new SspiHelper())\n\t\t\t{\n\t\t\t\tvar authData = sspiHelper.InitializeClientSecurity();\n\t\t\t\tSendTrustedAuthToBuffer(dpb, authData);\n\t\t\t\tSendAttachToBuffer(dpb, database);\n\t\t\t\tXdr.Flush();\n\n\t\t\t\tvar response = ReadResponse();\n\t\t\t\tresponse = ProcessTrustedAuthResponse(sspiHelper, response);\n\t\t\t\tProcessAttachResponse((GenericResponse)response);\n\t\t\t}\n\t\t}\n\t\tcatch (IscException)\n\t\t{\n\t\t\tSafelyDetach();\n\t\t\tthrow;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tSafelyDetach();\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\n\t\tAfterAttachActions();\n\t}\n\tpublic override async ValueTask AttachWithTrustedAuthAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tusing (var sspiHelper = new SspiHelper())\n\t\t\t{\n\t\t\t\tvar authData = sspiHelper.InitializeClientSecurity();\n\t\t\t\tawait SendTrustedAuthToBufferAsync(dpb, authData, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait SendAttachToBufferAsync(dpb, database, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tvar response = await ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tresponse = await ProcessTrustedAuthResponseAsync(sspiHelper, response, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ProcessAttachResponseAsync((GenericResponse)response, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (IscException)\n\t\t{\n\t\t\tawait SafelyDetachAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tthrow;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tawait SafelyDetachAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\n\t\tawait AfterAttachActionsAsync(cancellationToken).ConfigureAwait(false);\n\t}\n\n\tprotected virtual void SendTrustedAuthToBuffer(DatabaseParameterBufferBase dpb, byte[] authData)\n\t{\n\t\tdpb.Append(IscCodes.isc_dpb_trusted_auth, authData);\n\t}\n\tprotected virtual ValueTask SendTrustedAuthToBufferAsync(DatabaseParameterBufferBase dpb, byte[] authData, CancellationToken cancellationToken = default)\n\t{\n\t\tdpb.Append(IscCodes.isc_dpb_trusted_auth, authData);\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tprotected IResponse ProcessTrustedAuthResponse(SspiHelper sspiHelper, IResponse response)\n\t{\n\t\twhile (response is AuthResponse authResponse)\n\t\t{\n\t\t\tvar authData = sspiHelper.GetClientSecurity(authResponse.Data);\n\t\t\tXdr.Write(IscCodes.op_trusted_auth);\n\t\t\tXdr.WriteBuffer(authData);\n\t\t\tXdr.Flush();\n\t\t\tresponse = ReadResponse();\n\t\t}\n\t\treturn response;\n\t}\n\tprotected async ValueTask<IResponse> ProcessTrustedAuthResponseAsync(SspiHelper sspiHelper, IResponse response, CancellationToken cancellationToken = default)\n\t{\n\t\twhile (response is AuthResponse authResponse)\n\t\t{\n\t\t\tvar authData = sspiHelper.GetClientSecurity(authResponse.Data);\n\t\t\tawait Xdr.WriteAsync(IscCodes.op_trusted_auth, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteBufferAsync(authData, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tresponse = await ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\treturn response;\n\t}\n\n\tpublic override void CreateDatabaseWithTrustedAuth(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey)\n\t{\n\t\tusing (var sspiHelper = new SspiHelper())\n\t\t{\n\t\t\tvar authData = sspiHelper.InitializeClientSecurity();\n\t\t\tSendTrustedAuthToBuffer(dpb, authData);\n\t\t\tSendCreateToBuffer(dpb, database);\n\t\t\tXdr.Flush();\n\n\t\t\tvar response = ReadResponse();\n\t\t\tresponse = ProcessTrustedAuthResponse(sspiHelper, response);\n\t\t\tProcessCreateResponse((GenericResponse)response);\n\t\t}\n\t}\n\tpublic override async ValueTask CreateDatabaseWithTrustedAuthAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\tusing (var sspiHelper = new SspiHelper())\n\t\t{\n\t\t\tvar authData = sspiHelper.InitializeClientSecurity();\n\t\t\tawait SendTrustedAuthToBufferAsync(dpb, authData, cancellationToken).ConfigureAwait(false);\n\t\t\tawait SendCreateToBufferAsync(dpb, database, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar response = await ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tresponse = await ProcessTrustedAuthResponseAsync(sspiHelper, response, cancellationToken).ConfigureAwait(false);\n\t\t\tawait ProcessCreateResponseAsync((GenericResponse)response, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\tpublic override void ReleaseObject(int op, int id)\n\t{\n\t\ttry\n\t\t{\n\t\t\tSendReleaseObjectToBuffer(op, id);\n\t\t\tAppendDeferredPacket(ProcessReleaseObjectResponse);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask ReleaseObjectAsync(int op, int id, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait SendReleaseObjectToBufferAsync(op, id, cancellationToken).ConfigureAwait(false);\n\t\t\tAppendDeferredPacket(ProcessReleaseObjectResponseAsync);\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override async ValueTask<int> ReadOperationAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tawait ProcessDeferredPacketsAsync(cancellationToken).ConfigureAwait(false);\n\t\treturn await base.ReadOperationAsync(cancellationToken).ConfigureAwait(false);\n\t}\n\tpublic override int ReadOperation()\n\t{\n\t\tProcessDeferredPackets();\n\t\treturn base.ReadOperation();\n\t}\n\n\tpublic void AppendDeferredPacket(Action<IResponse> packet)\n\t{\n\t\t_deferredPackets.Enqueue((packet, null));\n\t}\n\tpublic void AppendDeferredPacket(Func<IResponse, CancellationToken, ValueTask> packet)\n\t{\n\t\t_deferredPackets.Enqueue((null, packet));\n\t}\n\n\tprivate void ProcessDeferredPackets()\n\t{\n\t\tif (_deferredPackets.Count > 0)\n\t\t{\n\t\t\t// copy it to local collection and clear to not get same processing when the method is hit again from ReadSingleResponse\n\t\t\tvar methods = _deferredPackets.ToArray();\n\t\t\t_deferredPackets.Clear();\n\t\t\tforeach (var (method, methodAsync) in methods)\n\t\t\t{\n\t\t\t\tvar response = ReadSingleResponse();\n\t\t\t\tif (method != null)\n\t\t\t\t{\n\t\t\t\t\tmethod(response);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (methodAsync != null)\n\t\t\t\t{\n\t\t\t\t\tmethodAsync(response, CancellationToken.None).GetAwaiter().GetResult();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprivate async ValueTask ProcessDeferredPacketsAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_deferredPackets.Count > 0)\n\t\t{\n\t\t\t// copy it to local collection and clear to not get same processing when the method is hit again from ReadSingleResponse\n\t\t\tvar methods = _deferredPackets.ToArray();\n\t\t\t_deferredPackets.Clear();\n\t\t\tforeach (var (method, methodAsync) in methods)\n\t\t\t{\n\t\t\t\tvar response = await ReadSingleResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tif (method != null)\n\t\t\t\t{\n\t\t\t\t\tmethod(response);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (methodAsync != null)\n\t\t\t\t{\n\t\t\t\t\tawait methodAsync(response, cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version11/GdsServiceManager.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version11;\n\ninternal class GdsServiceManager : Version10.GdsServiceManager\n{\n\tpublic GdsServiceManager(GdsConnection connection)\n\t\t: base(connection)\n\t{ }\n\n\tprotected override Version10.GdsDatabase CreateDatabase(GdsConnection connection)\n\t{\n\t\treturn new GdsDatabase(connection);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version11/GdsStatement.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.IO;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Client.Managed.Version10;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version11;\n\ninternal class GdsStatement : Version10.GdsStatement\n{\n\t#region Constructors\n\n\tpublic GdsStatement(GdsDatabase database)\n\t\t: base(database)\n\t{ }\n\n\tpublic GdsStatement(GdsDatabase database, Version10.GdsTransaction transaction)\n\t\t: base(database, transaction)\n\t{ }\n\n\t#endregion\n\n\t#region Overriden Methods\n\n\tpublic override void Prepare(string commandText)\n\t{\n\t\tClearAll();\n\n\t\ttry\n\t\t{\n\t\t\tvar numberOfResponses = 0;\n\t\t\tif (State == StatementState.Deallocated)\n\t\t\t{\n\t\t\t\tSendAllocateToBuffer();\n\t\t\t\tnumberOfResponses++;\n\t\t\t}\n\n\t\t\tSendPrepareToBuffer(commandText);\n\t\t\tnumberOfResponses++;\n\n\t\t\tSendInfoSqlToBuffer(StatementTypeInfoItems, IscCodes.STATEMENT_TYPE_BUFFER_SIZE);\n\t\t\tnumberOfResponses++;\n\n\t\t\t_database.Xdr.Flush();\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\tGenericResponse allocateResponse = null;\n\t\t\t\tif (State == StatementState.Deallocated)\n\t\t\t\t{\n\t\t\t\t\tnumberOfResponses--;\n\t\t\t\t\tallocateResponse = (GenericResponse)_database.ReadResponse();\n\t\t\t\t}\n\n\t\t\t\tnumberOfResponses--;\n\t\t\t\tvar prepareResponse = (GenericResponse)_database.ReadResponse();\n\t\t\t\tvar deferredExecute = ((prepareResponse.ObjectHandle & IscCodes.STMT_DEFER_EXECUTE) == IscCodes.STMT_DEFER_EXECUTE);\n\n\t\t\t\tnumberOfResponses--;\n\t\t\t\tvar statementTypeResponse = (GenericResponse)_database.ReadResponse();\n\n\t\t\t\tif (allocateResponse != null)\n\t\t\t\t{\n\t\t\t\t\tProcessAllocateResponse(allocateResponse);\n\t\t\t\t}\n\t\t\t\tProcessPrepareResponse(prepareResponse);\n\t\t\t\tStatementType = ProcessStatementTypeInfoBuffer(ProcessInfoSqlResponse(statementTypeResponse));\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\t(Database as GdsDatabase).SafeFinishFetching(numberOfResponses);\n\t\t\t}\n\n\t\t\tState = StatementState.Prepared;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tState = State == StatementState.Allocated ? StatementState.Error : State;\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask PrepareAsync(string commandText, CancellationToken cancellationToken = default)\n\t{\n\t\tClearAll();\n\n\t\ttry\n\t\t{\n\t\t\tvar numberOfResponses = 0;\n\t\t\tif (State == StatementState.Deallocated)\n\t\t\t{\n\t\t\t\tawait SendAllocateToBufferAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tnumberOfResponses++;\n\t\t\t}\n\n\t\t\tawait SendPrepareToBufferAsync(commandText, cancellationToken).ConfigureAwait(false);\n\t\t\tnumberOfResponses++;\n\n\t\t\tawait SendInfoSqlToBufferAsync(StatementTypeInfoItems, IscCodes.STATEMENT_TYPE_BUFFER_SIZE, cancellationToken).ConfigureAwait(false);\n\t\t\tnumberOfResponses++;\n\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\tGenericResponse allocateResponse = null;\n\t\t\t\tif (State == StatementState.Deallocated)\n\t\t\t\t{\n\t\t\t\t\tnumberOfResponses--;\n\t\t\t\t\tallocateResponse = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\n\t\t\t\tnumberOfResponses--;\n\t\t\t\tvar prepareResponse = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar deferredExecute = ((prepareResponse.ObjectHandle & IscCodes.STMT_DEFER_EXECUTE) == IscCodes.STMT_DEFER_EXECUTE);\n\n\t\t\t\tnumberOfResponses--;\n\t\t\t\tvar statementTypeResponse = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tif (allocateResponse != null)\n\t\t\t\t{\n\t\t\t\t\tawait ProcessAllocateResponseAsync(allocateResponse, cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t\tawait ProcessPrepareResponseAsync(prepareResponse, cancellationToken).ConfigureAwait(false);\n\t\t\t\tStatementType = ProcessStatementTypeInfoBuffer(await ProcessInfoSqlResponseAsync(statementTypeResponse, cancellationToken).ConfigureAwait(false));\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait (Database as GdsDatabase).SafeFinishFetchingAsync(numberOfResponses, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\n\t\t\tState = StatementState.Prepared;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tState = State == StatementState.Allocated ? StatementState.Error : State;\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override void Execute(int timeout, IDescriptorFiller descriptorFiller)\n\t{\n\t\tEnsureNotDeallocated();\n\n\t\tClear();\n\n\t\ttry\n\t\t{\n\t\t\tRecordsAffected = -1;\n\n\t\t\tSendExecuteToBuffer(timeout, descriptorFiller);\n\n\t\t\tvar readRowsAffectedResponse = false;\n\t\t\tif (DoRecordsAffected)\n\t\t\t{\n\t\t\t\tSendInfoSqlToBuffer(RowsAffectedInfoItems, IscCodes.ROWS_AFFECTED_BUFFER_SIZE);\n\n\t\t\t\treadRowsAffectedResponse = true;\n\t\t\t}\n\n\t\t\t_database.Xdr.Flush();\n\n\t\t\tvar numberOfResponses = (StatementType == DbStatementType.StoredProcedure ? 1 : 0) + 1 + (readRowsAffectedResponse ? 1 : 0);\n\t\t\ttry\n\t\t\t{\n\t\t\t\tSqlResponse sqlStoredProcedureResponse = null;\n\t\t\t\tif (StatementType == DbStatementType.StoredProcedure)\n\t\t\t\t{\n\t\t\t\t\tnumberOfResponses--;\n\t\t\t\t\tsqlStoredProcedureResponse = (SqlResponse)_database.ReadResponse();\n\t\t\t\t\tProcessStoredProcedureExecuteResponse(sqlStoredProcedureResponse);\n\t\t\t\t}\n\n\t\t\t\tnumberOfResponses--;\n\t\t\t\tvar executeResponse = (GenericResponse)_database.ReadResponse();\n\n\t\t\t\tGenericResponse rowsAffectedResponse = null;\n\t\t\t\tif (readRowsAffectedResponse)\n\t\t\t\t{\n\t\t\t\t\tnumberOfResponses--;\n\t\t\t\t\trowsAffectedResponse = (GenericResponse)_database.ReadResponse();\n\t\t\t\t}\n\n\t\t\t\tProcessExecuteResponse(executeResponse);\n\t\t\t\tif (readRowsAffectedResponse)\n\t\t\t\t{\n\t\t\t\t\tRecordsAffected = ProcessRecordsAffectedBuffer(ProcessInfoSqlResponse(rowsAffectedResponse));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\t(Database as GdsDatabase).SafeFinishFetching(numberOfResponses);\n\t\t\t}\n\n\t\t\tState = StatementState.Executed;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tState = StatementState.Error;\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask ExecuteAsync(int timeout, IDescriptorFiller descriptorFiller, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureNotDeallocated();\n\n\t\tClear();\n\n\t\ttry\n\t\t{\n\t\t\tRecordsAffected = -1;\n\n\t\t\tawait SendExecuteToBufferAsync(timeout, descriptorFiller, cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar readRowsAffectedResponse = false;\n\t\t\tif (DoRecordsAffected)\n\t\t\t{\n\t\t\t\tawait SendInfoSqlToBufferAsync(RowsAffectedInfoItems, IscCodes.ROWS_AFFECTED_BUFFER_SIZE, cancellationToken).ConfigureAwait(false);\n\n\t\t\t\treadRowsAffectedResponse = true;\n\t\t\t}\n\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar numberOfResponses = (StatementType == DbStatementType.StoredProcedure ? 1 : 0) + 1 + (readRowsAffectedResponse ? 1 : 0);\n\t\t\ttry\n\t\t\t{\n\t\t\t\tSqlResponse sqlStoredProcedureResponse = null;\n\t\t\t\tif (StatementType == DbStatementType.StoredProcedure)\n\t\t\t\t{\n\t\t\t\t\tnumberOfResponses--;\n\t\t\t\t\tsqlStoredProcedureResponse = (SqlResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait ProcessStoredProcedureExecuteResponseAsync(sqlStoredProcedureResponse, cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\n\t\t\t\tnumberOfResponses--;\n\t\t\t\tvar executeResponse = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tGenericResponse rowsAffectedResponse = null;\n\t\t\t\tif (readRowsAffectedResponse)\n\t\t\t\t{\n\t\t\t\t\tnumberOfResponses--;\n\t\t\t\t\trowsAffectedResponse = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\n\t\t\t\tawait ProcessExecuteResponseAsync(executeResponse, cancellationToken).ConfigureAwait(false);\n\t\t\t\tif (readRowsAffectedResponse)\n\t\t\t\t{\n\t\t\t\t\tRecordsAffected = ProcessRecordsAffectedBuffer(await ProcessInfoSqlResponseAsync(rowsAffectedResponse, cancellationToken).ConfigureAwait(false));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait (Database as GdsDatabase).SafeFinishFetchingAsync(numberOfResponses, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\n\t\t\tState = StatementState.Executed;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tState = StatementState.Error;\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Protected methods\n\tprotected override void Free(int option)\n\t{\n\t\tif (FreeNotNeeded(option))\n\t\t\treturn;\n\n\t\tDoFreePacket(option);\n\t\t(Database as GdsDatabase).AppendDeferredPacket(ProcessFreeResponse);\n\t}\n\tprotected override async ValueTask FreeAsync(int option, CancellationToken cancellationToken = default)\n\t{\n\t\tif (FreeNotNeeded(option))\n\t\t\treturn;\n\n\t\tawait DoFreePacketAsync(option, cancellationToken).ConfigureAwait(false);\n\t\t(Database as GdsDatabase).AppendDeferredPacket(ProcessFreeResponseAsync);\n\t}\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version12/GdsDatabase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.IO;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version12;\n\ninternal class GdsDatabase : Version11.GdsDatabase\n{\n\tpublic override bool UseUtf8ParameterBuffer => true;\n\n\tpublic GdsDatabase(GdsConnection connection)\n\t\t: base(connection)\n\t{ }\n\n\tpublic override StatementBase CreateStatement()\n\t{\n\t\treturn new GdsStatement(this);\n\t}\n\n\tpublic override StatementBase CreateStatement(TransactionBase transaction)\n\t{\n\t\treturn new GdsStatement(this, (Version10.GdsTransaction)transaction);\n\t}\n\n\tpublic override void CancelOperation(short kind)\n\t{\n\t\ttry\n\t\t{\n\t\t\tSendCancelOperationToBuffer(kind);\n\t\t\tXdr.Flush();\n\t\t\t// no response, this is out-of-band\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask CancelOperationAsync(short kind, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait SendCancelOperationToBufferAsync(kind, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t// no response, this is out-of-band\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tprotected void SendCancelOperationToBuffer(short kind)\n\t{\n\t\tXdr.Write(IscCodes.op_cancel);\n\t\tXdr.Write(kind);\n\t}\n\tprotected async ValueTask SendCancelOperationToBufferAsync(int kind, CancellationToken cancellationToken = default)\n\t{\n\t\tawait Xdr.WriteAsync(IscCodes.op_cancel, cancellationToken).ConfigureAwait(false);\n\t\tawait Xdr.WriteAsync(kind, cancellationToken).ConfigureAwait(false);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version12/GdsServiceManager.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version12;\n\ninternal class GdsServiceManager : Version11.GdsServiceManager\n{\n\tpublic GdsServiceManager(GdsConnection connection)\n\t\t: base(connection)\n\t{ }\n\n\tprotected override Version10.GdsDatabase CreateDatabase(GdsConnection connection)\n\t{\n\t\treturn new GdsDatabase(connection);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version12/GdsStatement.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.IO;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version12;\n\ninternal class GdsStatement : Version11.GdsStatement\n{\n\t#region Constructors\n\n\tpublic GdsStatement(GdsDatabase database)\n\t\t: base(database)\n\t{ }\n\n\tpublic GdsStatement(GdsDatabase database, Version10.GdsTransaction transaction)\n\t\t: base(database, transaction)\n\t{ }\n\n\t#endregion\n\n\t#region Overriden Methods\n\n\tpublic override void Execute(int timeout, IDescriptorFiller descriptorFiller)\n\t{\n\t\tEnsureNotDeallocated();\n\n\t\tClear();\n\n\t\ttry\n\t\t{\n\t\t\tRecordsAffected = -1;\n\n\t\t\tSendExecuteToBuffer(timeout, descriptorFiller);\n\n\t\t\t_database.Xdr.Flush();\n\n\t\t\tvar numberOfResponses = (StatementType == DbStatementType.StoredProcedure ? 1 : 0) + 1;\n\t\t\ttry\n\t\t\t{\n\t\t\t\tSqlResponse sqlStoredProcedureResponse = null;\n\t\t\t\tif (StatementType == DbStatementType.StoredProcedure)\n\t\t\t\t{\n\t\t\t\t\tnumberOfResponses--;\n\t\t\t\t\tsqlStoredProcedureResponse = (SqlResponse)_database.ReadResponse();\n\t\t\t\t\tProcessStoredProcedureExecuteResponse(sqlStoredProcedureResponse);\n\t\t\t\t}\n\n\t\t\t\tnumberOfResponses--;\n\t\t\t\tvar executeResponse = (GenericResponse)_database.ReadResponse();\n\t\t\t\tProcessExecuteResponse(executeResponse);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\t(Database as GdsDatabase).SafeFinishFetching(numberOfResponses);\n\t\t\t}\n\n\t\t\t// we need to split this in two, to allow server handle op_cancel properly\n\n\t\t\tif (DoRecordsAffected)\n\t\t\t{\n\t\t\t\tSendInfoSqlToBuffer(RowsAffectedInfoItems, IscCodes.ROWS_AFFECTED_BUFFER_SIZE);\n\n\t\t\t\t_database.Xdr.Flush();\n\n\t\t\t\tnumberOfResponses = 1;\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tnumberOfResponses--;\n\t\t\t\t\tvar rowsAffectedResponse = (GenericResponse)_database.ReadResponse();\n\t\t\t\t\tRecordsAffected = ProcessRecordsAffectedBuffer(ProcessInfoSqlResponse(rowsAffectedResponse));\n\t\t\t\t}\n\t\t\t\tfinally\n\t\t\t\t{\n\t\t\t\t\t(Database as GdsDatabase).SafeFinishFetching(numberOfResponses);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tState = StatementState.Executed;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tState = StatementState.Error;\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask ExecuteAsync(int timeout, IDescriptorFiller descriptorFiller, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureNotDeallocated();\n\n\t\tClear();\n\n\t\ttry\n\t\t{\n\t\t\tRecordsAffected = -1;\n\n\t\t\tawait SendExecuteToBufferAsync(timeout, descriptorFiller, cancellationToken).ConfigureAwait(false);\n\n\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar numberOfResponses = (StatementType == DbStatementType.StoredProcedure ? 1 : 0) + 1;\n\t\t\ttry\n\t\t\t{\n\t\t\t\tSqlResponse sqlStoredProcedureResponse = null;\n\t\t\t\tif (StatementType == DbStatementType.StoredProcedure)\n\t\t\t\t{\n\t\t\t\t\tnumberOfResponses--;\n\t\t\t\t\tsqlStoredProcedureResponse = (SqlResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait ProcessStoredProcedureExecuteResponseAsync(sqlStoredProcedureResponse, cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\n\t\t\t\tnumberOfResponses--;\n\t\t\t\tvar executeResponse = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ProcessExecuteResponseAsync(executeResponse, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait (Database as GdsDatabase).SafeFinishFetchingAsync(numberOfResponses, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\n\t\t\t// we need to split this in two, to allow server handle op_cancel properly\n\n\t\t\tif (DoRecordsAffected)\n\t\t\t{\n\t\t\t\tawait SendInfoSqlToBufferAsync(RowsAffectedInfoItems, IscCodes.ROWS_AFFECTED_BUFFER_SIZE, cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tawait _database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tnumberOfResponses = 1;\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tnumberOfResponses--;\n\t\t\t\t\tvar rowsAffectedResponse = (GenericResponse)await _database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tRecordsAffected = ProcessRecordsAffectedBuffer(await ProcessInfoSqlResponseAsync(rowsAffectedResponse, cancellationToken).ConfigureAwait(false));\n\t\t\t\t}\n\t\t\t\tfinally\n\t\t\t\t{\n\t\t\t\t\tawait (Database as GdsDatabase).SafeFinishFetchingAsync(numberOfResponses, cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tState = StatementState.Executed;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tState = StatementState.Error;\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version13/ContAuthResponse.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.Client.Managed.Version13;\n\ninternal class ContAuthResponse : IResponse\n{\n\tpublic byte[] ServerData { get; }\n\tpublic string AcceptPluginName { get; }\n\tpublic bool IsAuthenticated { get; }\n\tpublic byte[] ServerKeys { get; }\n\n\tpublic ContAuthResponse(byte[] serverData, string acceptPluginName, bool isAuthenticated, byte[] serverKeys)\n\t{\n\t\tServerData = serverData;\n\t\tAcceptPluginName = acceptPluginName;\n\t\tIsAuthenticated = isAuthenticated;\n\t\tServerKeys = serverKeys;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version13/CryptKeyCallbackResponse.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.Data.Client.Managed;\n\nnamespace FirebirdSql.Data.Client.Managed.Version13;\n\ninternal class CryptKeyCallbackResponse : IResponse\n{\n\tpublic byte[] Data { get; }\n\n\tpublic CryptKeyCallbackResponse(byte[] data)\n\t{\n\t\tData = data;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version13/GdsDatabase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Hajime Nakagami, Jiri Cincura (jiri@cincura.net)\n\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version13;\n\ninternal class GdsDatabase : Version12.GdsDatabase\n{\n\tpublic GdsDatabase(GdsConnection connection)\n\t\t: base(connection)\n\t{ }\n\n\tpublic override void Attach(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey)\n\t{\n\t\ttry\n\t\t{\n\t\t\tSendAttachToBuffer(dpb, database);\n\t\t\tXdr.Flush();\n\t\t\tvar response = ReadResponse();\n\t\t\tif (response is ContAuthResponse)\n\t\t\t{\n\t\t\t\twhile (response is ContAuthResponse contAuthResponse)\n\t\t\t\t{\n\t\t\t\t\tAuthBlock.Start(contAuthResponse.ServerData, contAuthResponse.AcceptPluginName, contAuthResponse.IsAuthenticated, contAuthResponse.ServerKeys);\n\n\t\t\t\t\tAuthBlock.SendContAuthToBuffer();\n\t\t\t\t\tXdr.Flush();\n\t\t\t\t\tresponse = AuthBlock.ProcessContAuthResponse();\n\t\t\t\t\tresponse = ProcessCryptCallbackResponseIfNeeded(response, cryptKey);\n\t\t\t\t}\n\t\t\t\tvar genericResponse = (GenericResponse)response;\n\t\t\t\tProcessAttachResponse(genericResponse);\n\n\t\t\t\tif (genericResponse.Data.Any())\n\t\t\t\t{\n\t\t\t\t\tAuthBlock.SendWireCryptToBuffer();\n\t\t\t\t\tXdr.Flush();\n\t\t\t\t\tAuthBlock.ProcessWireCryptResponse();\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tresponse = ProcessCryptCallbackResponseIfNeeded(response, cryptKey);\n\t\t\t\tProcessAttachResponse((GenericResponse)response);\n\t\t\t\tAuthBlock.Complete();\n\t\t\t}\n\t\t\tAuthBlock.WireCryptValidate(IscCodes.PROTOCOL_VERSION13);\n\t\t}\n\t\tcatch (IscException)\n\t\t{\n\t\t\tSafelyDetach();\n\t\t\tthrow;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tSafelyDetach();\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\n\t\tAfterAttachActions();\n\t}\n\tpublic override async ValueTask AttachAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait SendAttachToBufferAsync(dpb, database, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tvar response = await ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tif (response is ContAuthResponse)\n\t\t\t{\n\t\t\t\twhile (response is ContAuthResponse contAuthResponse)\n\t\t\t\t{\n\t\t\t\t\tAuthBlock.Start(contAuthResponse.ServerData, contAuthResponse.AcceptPluginName, contAuthResponse.IsAuthenticated, contAuthResponse.ServerKeys);\n\n\t\t\t\t\tawait AuthBlock.SendContAuthToBufferAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tresponse = await AuthBlock.ProcessContAuthResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tresponse = await ProcessCryptCallbackResponseIfNeededAsync(response, cryptKey, cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t\tvar genericResponse = (GenericResponse)response;\n\t\t\t\tawait ProcessAttachResponseAsync(genericResponse, cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tif (genericResponse.Data.Any())\n\t\t\t\t{\n\t\t\t\t\tawait AuthBlock.SendWireCryptToBufferAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait AuthBlock.ProcessWireCryptResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tresponse = await ProcessCryptCallbackResponseIfNeededAsync(response, cryptKey, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ProcessAttachResponseAsync((GenericResponse)response, cancellationToken).ConfigureAwait(false);\n\t\t\t\tAuthBlock.Complete();\n\t\t\t}\n\t\t\tAuthBlock.WireCryptValidate(IscCodes.PROTOCOL_VERSION13);\n\t\t}\n\t\tcatch (IscException)\n\t\t{\n\t\t\tawait SafelyDetachAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tthrow;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tawait SafelyDetachAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\n\t\tawait AfterAttachActionsAsync(cancellationToken).ConfigureAwait(false);\n\t}\n\n\tprotected override void SendAttachToBuffer(DatabaseParameterBufferBase dpb, string database)\n\t{\n\t\tXdr.Write(IscCodes.op_attach);\n\t\tXdr.Write(DatabaseObjectId);\n\t\tif (!AuthBlock.HasClientData)\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_auth_plugin_name, AuthBlock.AcceptPluginName);\n\t\t\tdpb.Append(IscCodes.isc_dpb_specific_auth_data, AuthBlock.PublicClientData);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_specific_auth_data, AuthBlock.ClientData);\n\t\t}\n\t\tXdr.WriteBuffer(dpb.Encoding.GetBytes(database));\n\t\tXdr.WriteBuffer(dpb.ToArray());\n\t}\n\tprotected override async ValueTask SendAttachToBufferAsync(DatabaseParameterBufferBase dpb, string database, CancellationToken cancellationToken = default)\n\t{\n\t\tawait Xdr.WriteAsync(IscCodes.op_attach, cancellationToken).ConfigureAwait(false);\n\t\tawait Xdr.WriteAsync(DatabaseObjectId, cancellationToken).ConfigureAwait(false);\n\t\tif (!AuthBlock.HasClientData)\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_auth_plugin_name, AuthBlock.AcceptPluginName);\n\t\t\tdpb.Append(IscCodes.isc_dpb_specific_auth_data, AuthBlock.PublicClientData);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_specific_auth_data, AuthBlock.ClientData);\n\t\t}\n\t\tawait Xdr.WriteBufferAsync(dpb.Encoding.GetBytes(database), cancellationToken).ConfigureAwait(false);\n\t\tawait Xdr.WriteBufferAsync(dpb.ToArray(), cancellationToken).ConfigureAwait(false);\n\t}\n\n\tpublic override void CreateDatabase(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey)\n\t{\n\t\ttry\n\t\t{\n\t\t\tSendCreateToBuffer(dpb, database);\n\t\t\tXdr.Flush();\n\t\t\tvar response = ReadResponse();\n\t\t\tif (response is ContAuthResponse)\n\t\t\t{\n\t\t\t\twhile (response is ContAuthResponse contAuthResponse)\n\t\t\t\t{\n\t\t\t\t\tAuthBlock.Start(contAuthResponse.ServerData, contAuthResponse.AcceptPluginName, contAuthResponse.IsAuthenticated, contAuthResponse.ServerKeys);\n\n\t\t\t\t\tAuthBlock.SendContAuthToBuffer();\n\t\t\t\t\tXdr.Flush();\n\t\t\t\t\tresponse = AuthBlock.ProcessContAuthResponse();\n\t\t\t\t\tresponse = ProcessCryptCallbackResponseIfNeeded(response, cryptKey);\n\t\t\t\t}\n\t\t\t\tvar genericResponse = (GenericResponse)response;\n\t\t\t\tProcessCreateResponse(genericResponse);\n\n\t\t\t\tif (genericResponse.Data.Any())\n\t\t\t\t{\n\t\t\t\t\tAuthBlock.SendWireCryptToBuffer();\n\t\t\t\t\tXdr.Flush();\n\t\t\t\t\tAuthBlock.ProcessWireCryptResponse();\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tresponse = ProcessCryptCallbackResponseIfNeeded(response, cryptKey);\n\t\t\t\tProcessCreateResponse((GenericResponse)response);\n\t\t\t\tAuthBlock.Complete();\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask CreateDatabaseAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait SendCreateToBufferAsync(dpb, database, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tvar response = await ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tif (response is ContAuthResponse)\n\t\t\t{\n\t\t\t\twhile (response is ContAuthResponse contAuthResponse)\n\t\t\t\t{\n\t\t\t\t\tAuthBlock.Start(contAuthResponse.ServerData, contAuthResponse.AcceptPluginName, contAuthResponse.IsAuthenticated, contAuthResponse.ServerKeys);\n\n\t\t\t\t\tawait AuthBlock.SendContAuthToBufferAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tresponse = await AuthBlock.ProcessContAuthResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tresponse = await ProcessCryptCallbackResponseIfNeededAsync(response, cryptKey, cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t\tvar genericResponse = (GenericResponse)response;\n\t\t\t\tawait ProcessCreateResponseAsync(genericResponse, cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tif (genericResponse.Data.Any())\n\t\t\t\t{\n\t\t\t\t\tawait AuthBlock.SendWireCryptToBufferAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait AuthBlock.ProcessWireCryptResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tresponse = await ProcessCryptCallbackResponseIfNeededAsync(response, cryptKey, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ProcessCreateResponseAsync((GenericResponse)response, cancellationToken).ConfigureAwait(false);\n\t\t\t\tAuthBlock.Complete();\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tprotected override void SendCreateToBuffer(DatabaseParameterBufferBase dpb, string database)\n\t{\n\t\tXdr.Write(IscCodes.op_create);\n\t\tXdr.Write(DatabaseObjectId);\n\t\tif (!AuthBlock.HasClientData)\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_auth_plugin_name, AuthBlock.AcceptPluginName);\n\t\t\tdpb.Append(IscCodes.isc_dpb_specific_auth_data, AuthBlock.PublicClientData);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_specific_auth_data, AuthBlock.ClientData);\n\t\t}\n\t\tXdr.WriteBuffer(dpb.Encoding.GetBytes(database));\n\t\tXdr.WriteBuffer(dpb.ToArray());\n\t}\n\tprotected override async ValueTask SendCreateToBufferAsync(DatabaseParameterBufferBase dpb, string database, CancellationToken cancellationToken = default)\n\t{\n\t\tawait Xdr.WriteAsync(IscCodes.op_create, cancellationToken).ConfigureAwait(false);\n\t\tawait Xdr.WriteAsync(DatabaseObjectId, cancellationToken).ConfigureAwait(false);\n\t\tif (!AuthBlock.HasClientData)\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_auth_plugin_name, AuthBlock.AcceptPluginName);\n\t\t\tdpb.Append(IscCodes.isc_dpb_specific_auth_data, AuthBlock.PublicClientData);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_specific_auth_data, AuthBlock.ClientData);\n\t\t}\n\t\tawait Xdr.WriteBufferAsync(dpb.Encoding.GetBytes(database), cancellationToken).ConfigureAwait(false);\n\t\tawait Xdr.WriteBufferAsync(dpb.ToArray(), cancellationToken).ConfigureAwait(false);\n\t}\n\n\tpublic override void AttachWithTrustedAuth(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey)\n\t{\n\t\tAttach(dpb, database, cryptKey);\n\t}\n\tpublic override ValueTask AttachWithTrustedAuthAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\treturn AttachAsync(dpb, database, cryptKey, cancellationToken);\n\t}\n\n\tpublic override void CreateDatabaseWithTrustedAuth(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey)\n\t{\n\t\tCreateDatabase(dpb, database, cryptKey);\n\t}\n\tpublic override ValueTask CreateDatabaseWithTrustedAuthAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\treturn CreateDatabaseAsync(dpb, database, cryptKey, cancellationToken);\n\t}\n\n\tprotected internal virtual IResponse ProcessCryptCallbackResponseIfNeeded(IResponse response, byte[] cryptKey)\n\t{\n\t\twhile (response is CryptKeyCallbackResponse)\n\t\t{\n\t\t\tXdr.Write(IscCodes.op_crypt_key_callback);\n\t\t\tXdr.WriteBuffer(cryptKey);\n\t\t\tXdr.Flush();\n\t\t\tresponse = ReadResponse();\n\t\t}\n\t\treturn response;\n\t}\n\tprotected internal virtual async ValueTask<IResponse> ProcessCryptCallbackResponseIfNeededAsync(IResponse response, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\twhile (response is CryptKeyCallbackResponse)\n\t\t{\n\t\t\tawait Xdr.WriteAsync(IscCodes.op_crypt_key_callback, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteBufferAsync(cryptKey, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tresponse = await ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\treturn response;\n\t}\n\n\tpublic override StatementBase CreateStatement()\n\t{\n\t\treturn new GdsStatement(this);\n\t}\n\n\tpublic override StatementBase CreateStatement(TransactionBase transaction)\n\t{\n\t\treturn new GdsStatement(this, (Version10.GdsTransaction)transaction);\n\t}\n\n\tpublic override DatabaseParameterBufferBase CreateDatabaseParameterBuffer()\n\t{\n\t\treturn new DatabaseParameterBuffer2(ParameterBufferEncoding);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version13/GdsServiceManager.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.IO;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version13;\n\ninternal class GdsServiceManager : Version12.GdsServiceManager\n{\n\tpublic GdsServiceManager(GdsConnection connection)\n\t\t: base(connection)\n\t{ }\n\n\tpublic override bool UseUtf8ParameterBuffer => true;\n\n\tpublic override void Attach(ServiceParameterBufferBase spb, string dataSource, int port, string service, byte[] cryptKey)\n\t{\n\t\ttry\n\t\t{\n\t\t\tSendAttachToBuffer(spb, service);\n\t\t\tDatabase.Xdr.Flush();\n\t\t\tvar response = Database.ReadResponse();\n\t\t\tif (response is ContAuthResponse)\n\t\t\t{\n\t\t\t\twhile (response is ContAuthResponse contAuthResponse)\n\t\t\t\t{\n\t\t\t\t\tConnection.AuthBlock.Start(contAuthResponse.ServerData, contAuthResponse.AcceptPluginName, contAuthResponse.IsAuthenticated, contAuthResponse.ServerKeys);\n\n\t\t\t\t\tConnection.AuthBlock.SendContAuthToBuffer();\n\t\t\t\t\tDatabase.Xdr.Flush();\n\t\t\t\t\tresponse = Connection.AuthBlock.ProcessContAuthResponse();\n\t\t\t\t\tresponse = (Database as GdsDatabase).ProcessCryptCallbackResponseIfNeeded(response, cryptKey);\n\t\t\t\t}\n\t\t\t\tvar genericResponse = (GenericResponse)response;\n\t\t\t\tbase.ProcessAttachResponse(genericResponse);\n\n\t\t\t\tif (genericResponse.Data.Any())\n\t\t\t\t{\n\t\t\t\t\tDatabase.AuthBlock.SendWireCryptToBuffer();\n\t\t\t\t\tDatabase.Xdr.Flush();\n\t\t\t\t\tDatabase.AuthBlock.ProcessWireCryptResponse();\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tresponse = (Database as GdsDatabase).ProcessCryptCallbackResponseIfNeeded(response, cryptKey);\n\t\t\t\tProcessAttachResponse((GenericResponse)response);\n\t\t\t\tDatabase.AuthBlock.Complete();\n\t\t\t}\n\t\t}\n\t\tcatch (IscException)\n\t\t{\n\t\t\tDatabase.SafelyDetach();\n\t\t\tthrow;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tDatabase.SafelyDetach();\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\tpublic override async ValueTask AttachAsync(ServiceParameterBufferBase spb, string dataSource, int port, string service, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait SendAttachToBufferAsync(spb, service, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tvar response = await Database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tif (response is ContAuthResponse)\n\t\t\t{\n\t\t\t\twhile (response is ContAuthResponse contAuthResponse)\n\t\t\t\t{\n\t\t\t\t\tConnection.AuthBlock.Start(contAuthResponse.ServerData, contAuthResponse.AcceptPluginName, contAuthResponse.IsAuthenticated, contAuthResponse.ServerKeys);\n\n\t\t\t\t\tawait Connection.AuthBlock.SendContAuthToBufferAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait Database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tresponse = await Connection.AuthBlock.ProcessContAuthResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tresponse = await (Database as GdsDatabase).ProcessCryptCallbackResponseIfNeededAsync(response, cryptKey, cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t\tvar genericResponse = (GenericResponse)response;\n\t\t\t\tawait base.ProcessAttachResponseAsync(genericResponse, cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tif (genericResponse.Data.Any())\n\t\t\t\t{\n\t\t\t\t\tawait Database.AuthBlock.SendWireCryptToBufferAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait Database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tawait Database.AuthBlock.ProcessWireCryptResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tresponse = await (Database as GdsDatabase).ProcessCryptCallbackResponseIfNeededAsync(response, cryptKey, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ProcessAttachResponseAsync((GenericResponse)response, cancellationToken).ConfigureAwait(false);\n\t\t\t\tDatabase.AuthBlock.Complete();\n\t\t\t}\n\t\t}\n\t\tcatch (IscException)\n\t\t{\n\t\t\tawait Database.SafelyDetachAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tthrow;\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tawait Database.SafelyDetachAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t}\n\n\tpublic override ServiceParameterBufferBase CreateServiceParameterBuffer()\n\t{\n\t\treturn new ServiceParameterBuffer3(Database.ParameterBufferEncoding);\n\t}\n\n\tprotected override Version10.GdsDatabase CreateDatabase(GdsConnection connection)\n\t{\n\t\treturn new GdsDatabase(connection);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version13/GdsStatement.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections;\nusing System.IO;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version13;\n\ninternal class GdsStatement : Version12.GdsStatement\n{\n\t#region Constructors\n\n\tpublic GdsStatement(GdsDatabase database)\n\t\t: base(database)\n\t{ }\n\n\tpublic GdsStatement(GdsDatabase database, Version10.GdsTransaction transaction)\n\t\t: base(database, transaction)\n\t{ }\n\n\t#endregion\n\n\t#region Overriden Methods\n\n\tprotected override byte[] WriteParameters()\n\t{\n\t\tif (_parameters == null)\n\t\t\treturn null;\n\n\t\tusing (var ms = new MemoryStream(256))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tvar xdr = new XdrReaderWriter(new DataProviderStreamWrapper(ms), _database.Charset);\n\n\t\t\t\tvar bits = new BitArray(_parameters.Count);\n\t\t\t\tfor (var i = 0; i < _parameters.Count; i++)\n\t\t\t\t{\n\t\t\t\t\tvar field = _parameters[i];\n\t\t\t\t\tbits.Set(i, field.DbValue.IsDBNull());\n\t\t\t\t}\n\t\t\t\tvar buffer = new byte[(int)Math.Ceiling(_parameters.Count / 8d)];\n\t\t\t\tfor (var i = 0; i < buffer.Length * 8; i++)\n\t\t\t\t{\n\t\t\t\t\tvar index = i / 8;\n\t\t\t\t\t// LSB\n\t\t\t\t\tbuffer[index] = (byte)((buffer[index] >> 1) | (bits.Length > i && bits[i] ? 1 << 7 : 0));\n\t\t\t\t}\n\t\t\t\txdr.WriteOpaque(buffer);\n\n\t\t\t\tfor (var i = 0; i < _parameters.Count; i++)\n\t\t\t\t{\n\t\t\t\t\tvar field = _parameters[i];\n\t\t\t\t\tif (field.DbValue.IsDBNull())\n\t\t\t\t\t{\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tWriteRawParameter(xdr, field);\n\t\t\t\t}\n\n\t\t\t\txdr.Flush();\n\t\t\t\treturn ms.ToArray();\n\t\t\t}\n\t\t\tcatch (IOException ex)\n\t\t\t{\n\t\t\t\tthrow IscException.ForIOException(ex);\n\t\t\t}\n\t\t}\n\t}\n\tprotected override async ValueTask<byte[]> WriteParametersAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_parameters == null)\n\t\t\treturn null;\n\n\t\tusing (var ms = new MemoryStream(256))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tvar xdr = new XdrReaderWriter(new DataProviderStreamWrapper(ms), _database.Charset);\n\n\t\t\t\tvar bits = new BitArray(_parameters.Count);\n\t\t\t\tfor (var i = 0; i < _parameters.Count; i++)\n\t\t\t\t{\n\t\t\t\t\tvar field = _parameters[i];\n\t\t\t\t\tbits.Set(i, field.DbValue.IsDBNull());\n\t\t\t\t}\n\t\t\t\tvar buffer = new byte[(int)Math.Ceiling(_parameters.Count / 8d)];\n\t\t\t\tfor (var i = 0; i < buffer.Length * 8; i++)\n\t\t\t\t{\n\t\t\t\t\tvar index = i / 8;\n\t\t\t\t\t// LSB\n\t\t\t\t\tbuffer[index] = (byte)((buffer[index] >> 1) | (bits.Length > i && bits[i] ? 1 << 7 : 0));\n\t\t\t\t}\n\t\t\t\tawait xdr.WriteOpaqueAsync(buffer, cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tfor (var i = 0; i < _parameters.Count; i++)\n\t\t\t\t{\n\t\t\t\t\tvar field = _parameters[i];\n\t\t\t\t\tif (field.DbValue.IsDBNull())\n\t\t\t\t\t{\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tawait WriteRawParameterAsync(xdr, field, cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\n\t\t\t\tawait xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\treturn ms.ToArray();\n\t\t\t}\n\t\t\tcatch (IOException ex)\n\t\t\t{\n\t\t\t\tthrow IscException.ForIOException(ex);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected override DbValue[] ReadRow()\n\t{\n\t\tvar row = new DbValue[_fields.Count];\n\t\ttry\n\t\t{\n\t\t\tif (_fields.Count > 0)\n\t\t\t{\n\t\t\t\tvar nullBytes = _database.Xdr.ReadOpaque((int)Math.Ceiling(_fields.Count / 8d));\n\t\t\t\tvar nullBits = new BitArray(nullBytes);\n\t\t\t\tfor (var i = 0; i < _fields.Count; i++)\n\t\t\t\t{\n\t\t\t\t\tif (nullBits.Get(i))\n\t\t\t\t\t{\n\t\t\t\t\t\trow[i] = new DbValue(this, _fields[i], null);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tvar value = ReadRawValue(_database.Xdr, _fields[i]);\n\t\t\t\t\t\trow[i] = new DbValue(this, _fields[i], value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t\treturn row;\n\t}\n\tprotected override async ValueTask<DbValue[]> ReadRowAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar row = new DbValue[_fields.Count];\n\t\ttry\n\t\t{\n\t\t\tif (_fields.Count > 0)\n\t\t\t{\n\t\t\t\tvar nullBytes = await _database.Xdr.ReadOpaqueAsync((int)Math.Ceiling(_fields.Count / 8d), cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar nullBits = new BitArray(nullBytes);\n\t\t\t\tfor (var i = 0; i < _fields.Count; i++)\n\t\t\t\t{\n\t\t\t\t\tif (nullBits.Get(i))\n\t\t\t\t\t{\n\t\t\t\t\t\trow[i] = new DbValue(this, _fields[i], null);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tvar value = await ReadRawValueAsync(_database.Xdr, _fields[i], cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\trow[i] = new DbValue(this, _fields[i], value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ex)\n\t\t{\n\t\t\tthrow IscException.ForIOException(ex);\n\t\t}\n\t\treturn row;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version13/WireCryptOption.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nnamespace FirebirdSql.Data.Client.Managed.Version13;\n\ninternal enum WireCryptOption\n{\n\tDisabled,\n\tEnabled,\n\tRequired,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version15/CryptKeyCallbackResponse.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.Data.Client.Managed;\n\nnamespace FirebirdSql.Data.Client.Managed.Version15;\n\ninternal class CryptKeyCallbackResponse : IResponse\n{\n\tpublic byte[] Data { get; }\n\tpublic int Size { get; }\n\n\tpublic CryptKeyCallbackResponse(byte[] data, int size)\n\t{\n\t\tData = data;\n\t\tSize = size;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version15/GdsDatabase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version15;\n\ninternal class GdsDatabase : Version13.GdsDatabase\n{\n\tpublic GdsDatabase(GdsConnection connection)\n\t\t: base(connection)\n\t{ }\n\n\tprotected internal override IResponse ProcessCryptCallbackResponseIfNeeded(IResponse response, byte[] cryptKey)\n\t{\n\t\twhile (response is CryptKeyCallbackResponse cryptKeyCallbackResponse)\n\t\t{\n\t\t\tXdr.Write(IscCodes.op_crypt_key_callback);\n\t\t\tXdr.WriteBuffer(cryptKey);\n\t\t\tXdr.Write(cryptKeyCallbackResponse.Size);\n\t\t\tXdr.Flush();\n\t\t\tresponse = ReadResponse();\n\t\t}\n\t\treturn response;\n\t}\n\tprotected internal override async ValueTask<IResponse> ProcessCryptCallbackResponseIfNeededAsync(IResponse response, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\twhile (response is CryptKeyCallbackResponse cryptKeyCallbackResponse)\n\t\t{\n\t\t\tawait Xdr.WriteAsync(IscCodes.op_crypt_key_callback, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteBufferAsync(cryptKey, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(cryptKeyCallbackResponse.Size).ConfigureAwait(false);\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tresponse = await ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\treturn response;\n\t}\n\n\tpublic override StatementBase CreateStatement()\n\t{\n\t\treturn new GdsStatement(this);\n\t}\n\n\tpublic override StatementBase CreateStatement(TransactionBase transaction)\n\t{\n\t\treturn new GdsStatement(this, (Version10.GdsTransaction)transaction);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version15/GdsServiceManager.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.IO;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version15;\n\ninternal class GdsServiceManager : Version13.GdsServiceManager\n{\n\tpublic GdsServiceManager(GdsConnection connection)\n\t\t: base(connection)\n\t{ }\n\n\tprotected override Version10.GdsDatabase CreateDatabase(GdsConnection connection)\n\t{\n\t\treturn new GdsDatabase(connection);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version15/GdsStatement.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections;\nusing System.IO;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version15;\n\ninternal class GdsStatement : Version13.GdsStatement\n{\n\tpublic GdsStatement(GdsDatabase database)\n\t\t: base(database)\n\t{ }\n\n\tpublic GdsStatement(GdsDatabase database, Version10.GdsTransaction transaction)\n\t\t: base(database, transaction)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version16/BatchCompletionStateResponse.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version16;\n\ninternal class BatchCompletionStateResponse : IResponse\n{\n\tpublic short StatementHandle { get; }\n\tpublic int ProcessedMessages { get; }\n\tpublic int[] UpdatedRecordsPerMessage { get; }\n\tpublic (int, IscException)[] DetailedErrors { get; }\n\tpublic int[] AdditionalErrorsPerMessage { get; }\n\n\tpublic BatchCompletionStateResponse(short statementHandle, int processedMessages, int[] updatedRecordsPerMessage, (int, IscException)[] detailedErrors, int[] errorsPerMessage)\n\t{\n\t\tStatementHandle = statementHandle;\n\t\tProcessedMessages = processedMessages;\n\t\tUpdatedRecordsPerMessage = updatedRecordsPerMessage;\n\t\tDetailedErrors = detailedErrors;\n\t\tAdditionalErrorsPerMessage = errorsPerMessage;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version16/GdsBatch.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version16;\n\ninternal class GdsBatch : BatchBase\n{\n\tprotected GdsStatement _statement;\n\n\tpublic override StatementBase Statement => _statement;\n\n\tpublic GdsDatabase Database => (GdsDatabase)_statement.Database;\n\n\tpublic GdsBatch(GdsStatement statement)\n\t{\n\t\t_statement = statement;\n\t}\n\n\tpublic override ExecuteResultItem[] Execute(int count, IDescriptorFiller descriptorFiller)\n\t{\n\t\t// this may throw error, so it needs to be before any writing\n\t\tvar parametersData = GetParametersData(count, descriptorFiller);\n\n\t\tDatabase.Xdr.Write(IscCodes.op_batch_create);\n\t\tDatabase.Xdr.Write(_statement.Handle); // p_batch_statement\n\t\tvar blr = _statement.Parameters.ToBlr();\n\t\tDatabase.Xdr.WriteBuffer(blr.Data); // p_batch_blr\n\t\tDatabase.Xdr.Write(blr.Length); // p_batch_msglen\n\t\tvar pb = _statement.CreateBatchParameterBuffer();\n\t\tif (_statement.ReturnRecordsAffected)\n\t\t{\n\t\t\tpb.Append(IscCodes.Batch.TAG_RECORD_COUNTS, 1);\n\t\t}\n\t\tif (MultiError)\n\t\t{\n\t\t\tpb.Append(IscCodes.Batch.TAG_MULTIERROR, 1);\n\t\t}\n\t\tpb.Append(IscCodes.Batch.TAG_BUFFER_BYTES_SIZE, BatchBufferSize);\n\t\tDatabase.Xdr.WriteBuffer(pb.ToArray()); // p_batch_pb\n\n\t\tDatabase.Xdr.Write(IscCodes.op_batch_msg);\n\t\tDatabase.Xdr.Write(_statement.Handle); // p_batch_statement\n\t\tDatabase.Xdr.Write(parametersData.Length); // p_batch_messages\n\t\tforeach (var item in parametersData)\n\t\t{\n\t\t\tDatabase.Xdr.WriteOpaque(item, item.Length); // p_batch_data\n\t\t}\n\n\t\tDatabase.Xdr.Write(IscCodes.op_batch_exec);\n\t\tDatabase.Xdr.Write(_statement.Handle); // p_batch_statement\n\t\tDatabase.Xdr.Write(_statement.Transaction.Handle); // p_batch_transaction;\t\t\n\n\t\tDatabase.Xdr.Flush();\n\n\t\tvar numberOfResponses = 3;\n\t\ttry\n\t\t{\n\t\t\tnumberOfResponses--;\n\t\t\tvar batchCreateResponse = Database.ReadResponse();\n\t\t\tnumberOfResponses--;\n\t\t\tvar batchMsgResponse = Database.ReadResponse();\n\t\t\tnumberOfResponses--;\n\t\t\tvar batchExecResponse = (BatchCompletionStateResponse)Database.ReadResponse();\n\n\t\t\treturn BuildResult(batchExecResponse);\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tDatabase.SafeFinishFetching(numberOfResponses);\n\t\t}\n\t}\n\tpublic override async ValueTask<ExecuteResultItem[]> ExecuteAsync(int count, IDescriptorFiller descriptorFiller, CancellationToken cancellationToken = default)\n\t{\n\t\t// this may throw error, so it needs to be before any writing\n\t\tvar parametersData = await GetParametersDataAsync(count, descriptorFiller, cancellationToken).ConfigureAwait(false);\n\n\t\tawait Database.Xdr.WriteAsync(IscCodes.op_batch_create, cancellationToken).ConfigureAwait(false);\n\t\tawait Database.Xdr.WriteAsync(_statement.Handle, cancellationToken).ConfigureAwait(false); // p_batch_statement\n\t\tvar blr = _statement.Parameters.ToBlr();\n\t\tawait Database.Xdr.WriteBufferAsync(blr.Data, cancellationToken).ConfigureAwait(false); // p_batch_blr\n\t\tawait Database.Xdr.WriteAsync(blr.Length, cancellationToken).ConfigureAwait(false); // p_batch_msglen\n\t\tvar pb = _statement.CreateBatchParameterBuffer();\n\t\tif (_statement.ReturnRecordsAffected)\n\t\t{\n\t\t\tpb.Append(IscCodes.Batch.TAG_RECORD_COUNTS, 1);\n\t\t}\n\t\tif (MultiError)\n\t\t{\n\t\t\tpb.Append(IscCodes.Batch.TAG_MULTIERROR, 1);\n\t\t}\n\t\tpb.Append(IscCodes.Batch.TAG_BUFFER_BYTES_SIZE, BatchBufferSize);\n\t\tawait Database.Xdr.WriteBufferAsync(pb.ToArray(), cancellationToken).ConfigureAwait(false); // p_batch_pb\n\n\t\tawait Database.Xdr.WriteAsync(IscCodes.op_batch_msg, cancellationToken).ConfigureAwait(false);\n\t\tawait Database.Xdr.WriteAsync(_statement.Handle, cancellationToken).ConfigureAwait(false); // p_batch_statement\n\t\tawait Database.Xdr.WriteAsync(parametersData.Length, cancellationToken).ConfigureAwait(false); // p_batch_messages\n\t\tforeach (var item in parametersData)\n\t\t{\n\t\t\tawait Database.Xdr.WriteOpaqueAsync(item, item.Length, cancellationToken).ConfigureAwait(false); // p_batch_data\n\t\t}\n\n\t\tawait Database.Xdr.WriteAsync(IscCodes.op_batch_exec, cancellationToken).ConfigureAwait(false);\n\t\tawait Database.Xdr.WriteAsync(_statement.Handle, cancellationToken).ConfigureAwait(false); // p_batch_statement\n\t\tawait Database.Xdr.WriteAsync(_statement.Transaction.Handle, cancellationToken).ConfigureAwait(false); // p_batch_transaction;\t\t\n\n\t\tawait Database.Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\n\t\tvar numberOfResponses = 3;\n\t\ttry\n\t\t{\n\t\t\tnumberOfResponses--;\n\t\t\tvar batchCreateResponse = await Database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tnumberOfResponses--;\n\t\t\tvar batchMsgResponse = await Database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tnumberOfResponses--;\n\t\t\tvar batchExecResponse = (BatchCompletionStateResponse)await Database.ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\treturn BuildResult(batchExecResponse);\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tawait Database.SafeFinishFetchingAsync(numberOfResponses, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\tpublic override int ComputeBatchSize(int count, IDescriptorFiller descriptorFiller)\n\t{\n\t\tvar parametersData = GetParametersData(count, descriptorFiller);\n\t\treturn parametersData.Sum(x => x.Length);\n\t}\n\tpublic override async ValueTask<int> ComputeBatchSizeAsync(int count, IDescriptorFiller descriptorFiller, CancellationToken cancellationToken = default)\n\t{\n\t\tvar parametersData = await GetParametersDataAsync(count, descriptorFiller, cancellationToken).ConfigureAwait(false);\n\t\treturn parametersData.Sum(x => x.Length);\n\t}\n\n\tpublic override void Release()\n\t{\n\t\tDatabase.Xdr.Write(IscCodes.op_batch_rls);\n\t\tDatabase.Xdr.Write(_statement.Handle);\n\t\tDatabase.AppendDeferredPacket(ProcessReleaseResponse);\n\t}\n\n\tpublic override async ValueTask ReleaseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tawait Database.Xdr.WriteAsync(IscCodes.op_batch_rls, cancellationToken).ConfigureAwait(false);\n\t\tawait Database.Xdr.WriteAsync(_statement.Handle, cancellationToken).ConfigureAwait(false);\n\t\tDatabase.AppendDeferredPacket(ProcessReleaseResponseAsync);\n\t}\n\n\tprotected void ProcessReleaseResponse(IResponse response)\n\t{ }\n\tprotected ValueTask ProcessReleaseResponseAsync(IResponse response, CancellationToken cancellationToken = default)\n\t{\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tprotected ExecuteResultItem[] BuildResult(BatchCompletionStateResponse response)\n\t{\n\t\tvar detailedErrors = response.DetailedErrors.ToDictionary(x => x.Item1, x => x.Item2);\n\t\tvar additionalErrorsPerMessage = response.AdditionalErrorsPerMessage.ToHashSet();\n\t\tvar result = new ExecuteResultItem[response.ProcessedMessages];\n\t\tfor (var i = 0; i < result.Length; i++)\n\t\t{\n\t\t\tvar recordsAffected = i < response.UpdatedRecordsPerMessage.Length\n\t\t\t\t? response.UpdatedRecordsPerMessage[i]\n\t\t\t\t: -1;\n\t\t\tif (detailedErrors.TryGetValue(i, out var exception))\n\t\t\t{\n\t\t\t\tresult[i] = new ExecuteResultItem()\n\t\t\t\t{\n\t\t\t\t\tRecordsAffected = recordsAffected,\n\t\t\t\t\tIsError = true,\n\t\t\t\t\tException = exception,\n\t\t\t\t};\n\t\t\t}\n\t\t\telse if (additionalErrorsPerMessage.Contains(i))\n\t\t\t{\n\t\t\t\tresult[i] = new ExecuteResultItem()\n\t\t\t\t{\n\t\t\t\t\tRecordsAffected = recordsAffected,\n\t\t\t\t\tIsError = true,\n\t\t\t\t\tException = null,\n\t\t\t\t};\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tresult[i] = new ExecuteResultItem()\n\t\t\t\t{\n\t\t\t\t\tRecordsAffected = recordsAffected,\n\t\t\t\t\tIsError = false,\n\t\t\t\t\tException = null,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected byte[][] GetParametersData(int count, IDescriptorFiller descriptorFiller)\n\t{\n\t\tvar parametersData = new byte[count][];\n\t\tfor (var i = 0; i < parametersData.Length; i++)\n\t\t{\n\t\t\tparametersData[i] = _statement.GetParameterData(descriptorFiller, i);\n\t\t}\n\t\treturn parametersData;\n\t}\n\tprotected async ValueTask<byte[][]> GetParametersDataAsync(int count, IDescriptorFiller descriptorFiller, CancellationToken cancellationToken = default)\n\t{\n\t\tvar parametersData = new byte[count][];\n\t\tfor (var i = 0; i < parametersData.Length; i++)\n\t\t{\n\t\t\tparametersData[i] = await _statement.GetParameterDataAsync(descriptorFiller, i, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\treturn parametersData;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version16/GdsDatabase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version16;\n\ninternal class GdsDatabase : Version15.GdsDatabase\n{\n\tpublic GdsDatabase(GdsConnection connection)\n\t\t: base(connection)\n\t{ }\n\n\tprotected internal override IResponse ProcessCryptCallbackResponseIfNeeded(IResponse response, byte[] cryptKey)\n\t{\n\t\twhile (response is Version15.CryptKeyCallbackResponse cryptKeyCallbackResponse)\n\t\t{\n\t\t\tXdr.Write(IscCodes.op_crypt_key_callback);\n\t\t\tXdr.WriteBuffer(cryptKey);\n\t\t\tXdr.Write(cryptKeyCallbackResponse.Size);\n\t\t\tXdr.Flush();\n\t\t\tresponse = ReadResponse();\n\t\t}\n\t\treturn response;\n\t}\n\tprotected internal override async ValueTask<IResponse> ProcessCryptCallbackResponseIfNeededAsync(IResponse response, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\twhile (response is Version15.CryptKeyCallbackResponse cryptKeyCallbackResponse)\n\t\t{\n\t\t\tawait Xdr.WriteAsync(IscCodes.op_crypt_key_callback, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteBufferAsync(cryptKey, cancellationToken).ConfigureAwait(false);\n\t\t\tawait Xdr.WriteAsync(cryptKeyCallbackResponse.Size).ConfigureAwait(false);\n\t\t\tawait Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tresponse = await ReadResponseAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\treturn response;\n\t}\n\n\tpublic override StatementBase CreateStatement()\n\t{\n\t\treturn new GdsStatement(this);\n\t}\n\n\tpublic override StatementBase CreateStatement(TransactionBase transaction)\n\t{\n\t\treturn new GdsStatement(this, (Version10.GdsTransaction)transaction);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version16/GdsServiceManager.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.IO;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version16;\n\ninternal class GdsServiceManager : Version15.GdsServiceManager\n{\n\tpublic GdsServiceManager(GdsConnection connection)\n\t\t: base(connection)\n\t{ }\n\n\tprotected override Version10.GdsDatabase CreateDatabase(GdsConnection connection)\n\t{\n\t\treturn new GdsDatabase(connection);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/Version16/GdsStatement.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Managed.Version16;\n\ninternal class GdsStatement : Version15.GdsStatement\n{\n\tpublic GdsStatement(GdsDatabase database)\n\t\t: base(database)\n\t{ }\n\n\tpublic GdsStatement(GdsDatabase database, Version10.GdsTransaction transaction)\n\t\t: base(database, transaction)\n\t{ }\n\n\tprotected override void SendExecuteToBuffer(int timeout, IDescriptorFiller descriptorFiller)\n\t{\n\t\tbase.SendExecuteToBuffer(timeout, descriptorFiller);\n\t\t_database.Xdr.Write(timeout);\n\t}\n\n\tprotected override async ValueTask SendExecuteToBufferAsync(int timeout, IDescriptorFiller descriptorFiller, CancellationToken cancellationToken = default)\n\t{\n\t\tawait base.SendExecuteToBufferAsync(timeout, descriptorFiller, cancellationToken).ConfigureAwait(false);\n\t\tawait _database.Xdr.WriteAsync(timeout, cancellationToken).ConfigureAwait(false);\n\t}\n\n\tpublic override BatchBase CreateBatch()\n\t{\n\t\treturn new GdsBatch(this);\n\t}\n\n\tpublic override BatchParameterBuffer CreateBatchParameterBuffer()\n\t{\n\t\treturn new BatchParameterBuffer(Database.Charset.Encoding);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Managed/XdrReaderWriter.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.Types;\n\nnamespace FirebirdSql.Data.Client.Managed;\n\nsealed class XdrReaderWriter : IXdrReader, IXdrWriter\n{\n\treadonly IDataProvider _dataProvider;\n\treadonly Charset _charset;\n\n\tbyte[] _smallBuffer;\n\n\tpublic XdrReaderWriter(IDataProvider dataProvider, Charset charset)\n\t{\n\t\t_dataProvider = dataProvider;\n\t\t_charset = charset;\n\n\t\t_smallBuffer = new byte[8];\n\t}\n\n\tpublic XdrReaderWriter(IDataProvider dataProvider)\n\t\t: this(dataProvider, Charset.DefaultCharset)\n\t{ }\n\n\t#region Read\n\n\tpublic byte[] ReadBytes(byte[] buffer, int count)\n\t{\n\t\tif (count > 0)\n\t\t{\n\t\t\tvar toRead = count;\n\t\t\tvar currentlyRead = -1;\n\t\t\twhile (toRead > 0 && currentlyRead != 0)\n\t\t\t{\n\t\t\t\ttoRead -= (currentlyRead = _dataProvider.Read(buffer, count - toRead, toRead));\n\t\t\t}\n\t\t\tif (currentlyRead == 0)\n\t\t\t{\n\t\t\t\tif (_dataProvider is ITracksIOFailure tracksIOFailure)\n\t\t\t\t{\n\t\t\t\t\ttracksIOFailure.IOFailed = true;\n\t\t\t\t}\n\t\t\t\tthrow new IOException($\"Missing {toRead} bytes to fill total {count}.\");\n\t\t\t}\n\t\t}\n\t\treturn buffer;\n\t}\n\tpublic async ValueTask<byte[]> ReadBytesAsync(byte[] buffer, int count, CancellationToken cancellationToken = default)\n\t{\n\t\tif (count > 0)\n\t\t{\n\t\t\tvar toRead = count;\n\t\t\tvar currentlyRead = -1;\n\t\t\twhile (toRead > 0 && currentlyRead != 0)\n\t\t\t{\n\t\t\t\ttoRead -= (currentlyRead = await _dataProvider.ReadAsync(buffer, count - toRead, toRead, cancellationToken).ConfigureAwait(false));\n\t\t\t}\n\t\t\tif (currentlyRead == 0)\n\t\t\t{\n\t\t\t\tif (_dataProvider is ITracksIOFailure tracksIOFailure)\n\t\t\t\t{\n\t\t\t\t\ttracksIOFailure.IOFailed = true;\n\t\t\t\t}\n\t\t\t\tthrow new IOException($\"Missing {toRead} bytes to fill total {count}.\");\n\t\t\t}\n\t\t}\n\t\treturn buffer;\n\t}\n\n\tpublic byte[] ReadOpaque(int length)\n\t{\n\t\tvar buffer = new byte[length];\n\t\tReadBytes(buffer, length);\n\t\tReadPad((4 - length) & 3);\n\t\treturn buffer;\n\t}\n\tpublic async ValueTask<byte[]> ReadOpaqueAsync(int length, CancellationToken cancellationToken = default)\n\t{\n\t\tvar buffer = new byte[length];\n\t\tawait ReadBytesAsync(buffer, length, cancellationToken).ConfigureAwait(false);\n\t\tawait ReadPadAsync((4 - length) & 3, cancellationToken).ConfigureAwait(false);\n\t\treturn buffer;\n\t}\n\n\tpublic byte[] ReadBuffer()\n\t{\n\t\treturn ReadOpaque((ushort)ReadInt32());\n\t}\n\tpublic async ValueTask<byte[]> ReadBufferAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn await ReadOpaqueAsync((ushort)await ReadInt32Async(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);\n\t}\n\n\tpublic string ReadString()\n\t{\n\t\treturn ReadString(_charset);\n\t}\n\tpublic ValueTask<string> ReadStringAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn ReadStringAsync(_charset, cancellationToken);\n\t}\n\n\tpublic string ReadString(int length)\n\t{\n\t\treturn ReadString(_charset, length);\n\t}\n\tpublic ValueTask<string> ReadStringAsync(int length, CancellationToken cancellationToken = default)\n\t{\n\t\treturn ReadStringAsync(_charset, length, cancellationToken);\n\t}\n\n\tpublic string ReadString(Charset charset)\n\t{\n\t\treturn ReadString(charset, ReadInt32());\n\t}\n\tpublic async ValueTask<string> ReadStringAsync(Charset charset, CancellationToken cancellationToken = default)\n\t{\n\t\treturn await ReadStringAsync(charset, await ReadInt32Async(cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);\n\t}\n\n\tpublic string ReadString(Charset charset, int length)\n\t{\n\t\tvar buffer = ReadOpaque(length);\n\t\treturn charset.GetString(buffer, 0, buffer.Length);\n\t}\n\tpublic async ValueTask<string> ReadStringAsync(Charset charset, int length, CancellationToken cancellationToken = default)\n\t{\n\t\tvar buffer = await ReadOpaqueAsync(length, cancellationToken).ConfigureAwait(false);\n\t\treturn charset.GetString(buffer, 0, buffer.Length);\n\t}\n\n\tpublic short ReadInt16()\n\t{\n\t\treturn Convert.ToInt16(ReadInt32());\n\t}\n\tpublic async ValueTask<short> ReadInt16Async(CancellationToken cancellationToken = default)\n\t{\n\t\treturn Convert.ToInt16(await ReadInt32Async(cancellationToken).ConfigureAwait(false));\n\t}\n\n\tpublic int ReadInt32()\n\t{\n\t\tReadBytes(_smallBuffer, 4);\n\t\treturn TypeDecoder.DecodeInt32(_smallBuffer);\n\t}\n\tpublic async ValueTask<int> ReadInt32Async(CancellationToken cancellationToken = default)\n\t{\n\t\tawait ReadBytesAsync(_smallBuffer, 4, cancellationToken).ConfigureAwait(false);\n\t\treturn TypeDecoder.DecodeInt32(_smallBuffer);\n\t}\n\n\tpublic long ReadInt64()\n\t{\n\t\tReadBytes(_smallBuffer, 8);\n\t\treturn TypeDecoder.DecodeInt64(_smallBuffer);\n\t}\n\tpublic async ValueTask<long> ReadInt64Async(CancellationToken cancellationToken = default)\n\t{\n\t\tawait ReadBytesAsync(_smallBuffer, 8, cancellationToken).ConfigureAwait(false);\n\t\treturn TypeDecoder.DecodeInt64(_smallBuffer);\n\t}\n\n\tpublic Guid ReadGuid(int sqlType)\n\t{\n\t\tif (sqlType == IscCodes.SQL_VARYING)\n\t\t{\n\t\t\treturn TypeDecoder.DecodeGuid(ReadBuffer());\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn TypeDecoder.DecodeGuid(ReadOpaque(16));\n\t\t}\n\t}\n\tpublic async ValueTask<Guid> ReadGuidAsync(int sqlType, CancellationToken cancellationToken = default)\n\t{\n\t\tif (sqlType == IscCodes.SQL_VARYING)\n\t\t{\n\t\t\treturn TypeDecoder.DecodeGuid(await ReadBufferAsync(cancellationToken).ConfigureAwait(false));\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn TypeDecoder.DecodeGuid(await ReadOpaqueAsync(16, cancellationToken).ConfigureAwait(false));\n\t\t}\n\t}\n\n\tpublic float ReadSingle()\n\t{\n\t\treturn BitConverter.ToSingle(BitConverter.GetBytes(ReadInt32()), 0);\n\t}\n\tpublic async ValueTask<float> ReadSingleAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn BitConverter.ToSingle(BitConverter.GetBytes(await ReadInt32Async(cancellationToken).ConfigureAwait(false)), 0);\n\t}\n\n\tpublic double ReadDouble()\n\t{\n\t\treturn BitConverter.ToDouble(BitConverter.GetBytes(ReadInt64()), 0);\n\t}\n\tpublic async ValueTask<double> ReadDoubleAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn BitConverter.ToDouble(BitConverter.GetBytes(await ReadInt64Async(cancellationToken).ConfigureAwait(false)), 0);\n\t}\n\n\tpublic DateTime ReadDateTime()\n\t{\n\t\tvar date = ReadDate();\n\t\tvar time = ReadTime();\n\t\treturn date.Add(time);\n\t}\n\tpublic async ValueTask<DateTime> ReadDateTimeAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar date = await ReadDateAsync(cancellationToken).ConfigureAwait(false);\n\t\tvar time = await ReadTimeAsync(cancellationToken).ConfigureAwait(false);\n\t\treturn date.Add(time);\n\t}\n\n\tpublic DateTime ReadDate()\n\t{\n\t\treturn TypeDecoder.DecodeDate(ReadInt32());\n\t}\n\tpublic async ValueTask<DateTime> ReadDateAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn TypeDecoder.DecodeDate(await ReadInt32Async(cancellationToken).ConfigureAwait(false));\n\t}\n\n\tpublic TimeSpan ReadTime()\n\t{\n\t\treturn TypeDecoder.DecodeTime(ReadInt32());\n\t}\n\tpublic async ValueTask<TimeSpan> ReadTimeAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn TypeDecoder.DecodeTime(await ReadInt32Async(cancellationToken).ConfigureAwait(false));\n\t}\n\n\tpublic decimal ReadDecimal(int type, int scale)\n\t{\n\t\tswitch (type & ~1)\n\t\t{\n\t\t\tcase IscCodes.SQL_SHORT:\n\t\t\t\treturn TypeDecoder.DecodeDecimal(ReadInt16(), scale, type);\n\t\t\tcase IscCodes.SQL_LONG:\n\t\t\t\treturn TypeDecoder.DecodeDecimal(ReadInt32(), scale, type);\n\t\t\tcase IscCodes.SQL_QUAD:\n\t\t\tcase IscCodes.SQL_INT64:\n\t\t\t\treturn TypeDecoder.DecodeDecimal(ReadInt64(), scale, type);\n\t\t\tcase IscCodes.SQL_DOUBLE:\n\t\t\tcase IscCodes.SQL_D_FLOAT:\n\t\t\t\treturn TypeDecoder.DecodeDecimal(ReadDouble(), scale, type);\n\t\t\tcase IscCodes.SQL_INT128:\n\t\t\t\treturn TypeDecoder.DecodeDecimal(ReadInt128(), scale, type);\n\t\t\tdefault:\n\t\t\t\tthrow new ArgumentOutOfRangeException(nameof(type), $\"{nameof(type)}={type}\");\n\t\t}\n\t}\n\tpublic async ValueTask<decimal> ReadDecimalAsync(int type, int scale, CancellationToken cancellationToken = default)\n\t{\n\t\tswitch (type & ~1)\n\t\t{\n\t\t\tcase IscCodes.SQL_SHORT:\n\t\t\t\treturn TypeDecoder.DecodeDecimal(await ReadInt16Async(cancellationToken).ConfigureAwait(false), scale, type);\n\t\t\tcase IscCodes.SQL_LONG:\n\t\t\t\treturn TypeDecoder.DecodeDecimal(await ReadInt32Async(cancellationToken).ConfigureAwait(false), scale, type);\n\t\t\tcase IscCodes.SQL_QUAD:\n\t\t\tcase IscCodes.SQL_INT64:\n\t\t\t\treturn TypeDecoder.DecodeDecimal(await ReadInt64Async(cancellationToken).ConfigureAwait(false), scale, type);\n\t\t\tcase IscCodes.SQL_DOUBLE:\n\t\t\tcase IscCodes.SQL_D_FLOAT:\n\t\t\t\treturn TypeDecoder.DecodeDecimal(await ReadDoubleAsync(cancellationToken).ConfigureAwait(false), scale, type);\n\t\t\tcase IscCodes.SQL_INT128:\n\t\t\t\treturn TypeDecoder.DecodeDecimal(await ReadInt128Async(cancellationToken).ConfigureAwait(false), scale, type);\n\t\t\tdefault:\n\t\t\t\tthrow new ArgumentOutOfRangeException(nameof(type), $\"{nameof(type)}={type}\");\n\t\t}\n\t}\n\n\tpublic bool ReadBoolean()\n\t{\n\t\treturn TypeDecoder.DecodeBoolean(ReadOpaque(1));\n\t}\n\tpublic async ValueTask<bool> ReadBooleanAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn TypeDecoder.DecodeBoolean(await ReadOpaqueAsync(1, cancellationToken).ConfigureAwait(false));\n\t}\n\n\tpublic FbZonedDateTime ReadZonedDateTime(bool isExtended)\n\t{\n\t\tvar dt = ReadDateTime();\n\t\tdt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);\n\t\treturn TypeHelper.CreateZonedDateTime(dt, (ushort)ReadInt16(), isExtended ? ReadInt16() : (short?)null);\n\t}\n\tpublic async ValueTask<FbZonedDateTime> ReadZonedDateTimeAsync(bool isExtended, CancellationToken cancellationToken = default)\n\t{\n\t\tvar dt = await ReadDateTimeAsync(cancellationToken).ConfigureAwait(false);\n\t\tdt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);\n\t\treturn TypeHelper.CreateZonedDateTime(dt, (ushort)await ReadInt16Async(cancellationToken).ConfigureAwait(false), isExtended ? await ReadInt16Async(cancellationToken).ConfigureAwait(false) : (short?)null);\n\t}\n\n\tpublic FbZonedTime ReadZonedTime(bool isExtended)\n\t{\n\t\treturn TypeHelper.CreateZonedTime(ReadTime(), (ushort)ReadInt16(), isExtended ? ReadInt16() : (short?)null);\n\t}\n\tpublic async ValueTask<FbZonedTime> ReadZonedTimeAsync(bool isExtended, CancellationToken cancellationToken = default)\n\t{\n\t\treturn TypeHelper.CreateZonedTime(await ReadTimeAsync(cancellationToken).ConfigureAwait(false), (ushort)await ReadInt16Async(cancellationToken).ConfigureAwait(false), isExtended ? await ReadInt16Async(cancellationToken).ConfigureAwait(false) : (short?)null);\n\t}\n\n\tpublic FbDecFloat ReadDec16()\n\t{\n\t\treturn TypeDecoder.DecodeDec16(ReadOpaque(8));\n\t}\n\tpublic async ValueTask<FbDecFloat> ReadDec16Async(CancellationToken cancellationToken = default)\n\t{\n\t\treturn TypeDecoder.DecodeDec16(await ReadOpaqueAsync(8, cancellationToken).ConfigureAwait(false));\n\t}\n\n\tpublic FbDecFloat ReadDec34()\n\t{\n\t\treturn TypeDecoder.DecodeDec34(ReadOpaque(16));\n\t}\n\tpublic async ValueTask<FbDecFloat> ReadDec34Async(CancellationToken cancellationToken = default)\n\t{\n\t\treturn TypeDecoder.DecodeDec34(await ReadOpaqueAsync(16, cancellationToken).ConfigureAwait(false));\n\t}\n\n\tpublic BigInteger ReadInt128()\n\t{\n\t\treturn TypeDecoder.DecodeInt128(ReadOpaque(16));\n\t}\n\tpublic async ValueTask<BigInteger> ReadInt128Async(CancellationToken cancellationToken = default)\n\t{\n\t\treturn TypeDecoder.DecodeInt128(await ReadOpaqueAsync(16, cancellationToken).ConfigureAwait(false));\n\t}\n\n\tpublic IscException ReadStatusVector()\n\t{\n\t\tIscException exception = null;\n\t\tvar eof = false;\n\n\t\twhile (!eof)\n\t\t{\n\t\t\tvar arg = ReadInt32();\n\n\t\t\tswitch (arg)\n\t\t\t{\n\t\t\t\tcase IscCodes.isc_arg_gds:\n\t\t\t\tdefault:\n\t\t\t\t\tvar er = ReadInt32();\n\t\t\t\t\tif (er != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (exception == null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\texception = IscException.ForBuilding();\n\t\t\t\t\t\t}\n\t\t\t\t\t\texception.Errors.Add(new IscError(arg, er));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_arg_end:\n\t\t\t\t\texception?.BuildExceptionData();\n\t\t\t\t\teof = true;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_arg_interpreted:\n\t\t\t\tcase IscCodes.isc_arg_string:\n\t\t\t\tcase IscCodes.isc_arg_sql_state:\n\t\t\t\t\texception.Errors.Add(new IscError(arg, ReadString()));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_arg_number:\n\t\t\t\t\texception.Errors.Add(new IscError(arg, ReadInt32()));\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn exception;\n\t}\n\tpublic async ValueTask<IscException> ReadStatusVectorAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tIscException exception = null;\n\t\tvar eof = false;\n\n\t\twhile (!eof)\n\t\t{\n\t\t\tvar arg = await ReadInt32Async(cancellationToken).ConfigureAwait(false);\n\n\t\t\tswitch (arg)\n\t\t\t{\n\t\t\t\tcase IscCodes.isc_arg_gds:\n\t\t\t\tdefault:\n\t\t\t\t\tvar er = await ReadInt32Async(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\tif (er != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (exception == null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\texception = IscException.ForBuilding();\n\t\t\t\t\t\t}\n\t\t\t\t\t\texception.Errors.Add(new IscError(arg, er));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_arg_end:\n\t\t\t\t\texception?.BuildExceptionData();\n\t\t\t\t\teof = true;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_arg_interpreted:\n\t\t\t\tcase IscCodes.isc_arg_string:\n\t\t\t\tcase IscCodes.isc_arg_sql_state:\n\t\t\t\t\texception.Errors.Add(new IscError(arg, await ReadStringAsync(cancellationToken).ConfigureAwait(false)));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_arg_number:\n\t\t\t\t\texception.Errors.Add(new IscError(arg, await ReadInt32Async(cancellationToken).ConfigureAwait(false)));\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn exception;\n\t}\n\n\t/* loop\tas long\tas we are receiving\tdummy packets, just\n\t * throwing\tthem away--note\tthat if\twe are a server\twe won't\n\t * be receiving\tthem, but it is\tbetter to check\tfor\tthem at\n\t * this\tlevel rather than try to catch them\tin all places where\n\t * this\troutine\tis called\n\t */\n\tpublic int ReadOperation()\n\t{\n\t\tint operation;\n\t\tdo\n\t\t{\n\t\t\toperation = ReadInt32();\n\t\t} while (operation == IscCodes.op_dummy);\n\t\treturn operation;\n\t}\n\tpublic async ValueTask<int> ReadOperationAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tint operation;\n\t\tdo\n\t\t{\n\t\t\toperation = await ReadInt32Async(cancellationToken).ConfigureAwait(false);\n\t\t} while (operation == IscCodes.op_dummy);\n\t\treturn operation;\n\t}\n\n\t#endregion\n\n\t#region Write\n\n\tpublic void Flush()\n\t{\n\t\t_dataProvider.Flush();\n\t}\n\tpublic ValueTask FlushAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn _dataProvider.FlushAsync(cancellationToken);\n\t}\n\n\tpublic void WriteBytes(byte[] buffer, int count)\n\t{\n\t\t_dataProvider.Write(buffer, 0, count);\n\t}\n\tpublic ValueTask WriteBytesAsync(byte[] buffer, int count, CancellationToken cancellationToken = default)\n\t{\n\t\treturn _dataProvider.WriteAsync(buffer, 0, count, cancellationToken);\n\t}\n\n\tpublic void WriteOpaque(byte[] buffer)\n\t{\n\t\tWriteOpaque(buffer, buffer.Length);\n\t}\n\tpublic ValueTask WriteOpaqueAsync(byte[] buffer, CancellationToken cancellationToken = default)\n\t{\n\t\treturn WriteOpaqueAsync(buffer, buffer.Length, cancellationToken);\n\t}\n\n\tpublic void WriteOpaque(byte[] buffer, int length)\n\t{\n\t\tif (buffer != null && length > 0)\n\t\t{\n\t\t\t_dataProvider.Write(buffer, 0, buffer.Length);\n\t\t\tWriteFill(length - buffer.Length);\n\t\t\tWritePad((4 - length) & 3);\n\t\t}\n\t}\n\tpublic async ValueTask WriteOpaqueAsync(byte[] buffer, int length, CancellationToken cancellationToken = default)\n\t{\n\t\tif (buffer != null && length > 0)\n\t\t{\n\t\t\tawait _dataProvider.WriteAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false);\n\t\t\tawait WriteFillAsync(length - buffer.Length, cancellationToken).ConfigureAwait(false);\n\t\t\tawait WritePadAsync((4 - length) & 3, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\tpublic void WriteBuffer(byte[] buffer)\n\t{\n\t\tWriteBuffer(buffer, buffer?.Length ?? 0);\n\t}\n\tpublic ValueTask WriteBufferAsync(byte[] buffer, CancellationToken cancellationToken = default)\n\t{\n\t\treturn WriteBufferAsync(buffer, buffer?.Length ?? 0, cancellationToken);\n\t}\n\n\tpublic void WriteBuffer(byte[] buffer, int length)\n\t{\n\t\tWrite(length);\n\t\tif (buffer != null && length > 0)\n\t\t{\n\t\t\t_dataProvider.Write(buffer, 0, length);\n\t\t\tWritePad((4 - length) & 3);\n\t\t}\n\t}\n\tpublic async ValueTask WriteBufferAsync(byte[] buffer, int length, CancellationToken cancellationToken = default)\n\t{\n\t\tawait WriteAsync(length, cancellationToken).ConfigureAwait(false);\n\t\tif (buffer != null && length > 0)\n\t\t{\n\t\t\tawait _dataProvider.WriteAsync(buffer, 0, length, cancellationToken).ConfigureAwait(false);\n\t\t\tawait WritePadAsync((4 - length) & 3, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\tpublic void WriteBlobBuffer(byte[] buffer)\n\t{\n\t\tvar length = buffer.Length; // 2 for short for buffer length\n\t\tif (length > short.MaxValue)\n\t\t\tthrow new IOException(\"Blob buffer too big.\");\n\t\tWrite(length + 2);\n\t\tWrite(length + 2);  //bizarre but true! three copies of the length\n\t\t_dataProvider.Write(new[] { (byte)((length >> 0) & 0xff), (byte)((length >> 8) & 0xff) }, 0, 2);\n\t\t_dataProvider.Write(buffer, 0, length);\n\t\tWritePad((4 - length + 2) & 3);\n\t}\n\tpublic async ValueTask WriteBlobBufferAsync(byte[] buffer, CancellationToken cancellationToken = default)\n\t{\n\t\tvar length = buffer.Length; // 2 for short for buffer length\n\t\tif (length > short.MaxValue)\n\t\t\tthrow new IOException(\"Blob buffer too big.\");\n\t\tawait WriteAsync(length + 2, cancellationToken).ConfigureAwait(false);\n\t\tawait WriteAsync(length + 2, cancellationToken).ConfigureAwait(false);  //bizarre but true! three copies of the length\n\t\tawait _dataProvider.WriteAsync(new[] { (byte)((length >> 0) & 0xff), (byte)((length >> 8) & 0xff) }, 0, 2, cancellationToken).ConfigureAwait(false);\n\t\tawait _dataProvider.WriteAsync(buffer, 0, length, cancellationToken).ConfigureAwait(false);\n\t\tawait WritePadAsync((4 - length + 2) & 3, cancellationToken).ConfigureAwait(false);\n\t}\n\n\tpublic void WriteTyped(int type, byte[] buffer)\n\t{\n\t\tint length;\n\t\tif (buffer == null)\n\t\t{\n\t\t\tWrite(1);\n\t\t\t_dataProvider.Write(new[] { (byte)type }, 0, 1);\n\t\t\tlength = 1;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlength = buffer.Length + 1;\n\t\t\tWrite(length);\n\t\t\t_dataProvider.Write(new[] { (byte)type }, 0, 1);\n\t\t\t_dataProvider.Write(buffer, 0, buffer.Length);\n\t\t}\n\t\tWritePad((4 - length) & 3);\n\t}\n\tpublic async ValueTask WriteTypedAsync(int type, byte[] buffer, CancellationToken cancellationToken = default)\n\t{\n\t\tint length;\n\t\tif (buffer == null)\n\t\t{\n\t\t\tawait WriteAsync(1, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _dataProvider.WriteAsync(new[] { (byte)type }, 0, 1, cancellationToken).ConfigureAwait(false);\n\t\t\tlength = 1;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlength = buffer.Length + 1;\n\t\t\tawait WriteAsync(length, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _dataProvider.WriteAsync(new[] { (byte)type }, 0, 1, cancellationToken).ConfigureAwait(false);\n\t\t\tawait _dataProvider.WriteAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tawait WritePadAsync((4 - length) & 3, cancellationToken).ConfigureAwait(false);\n\t}\n\n\tpublic void Write(string value)\n\t{\n\t\tvar buffer = _charset.GetBytes(value);\n\t\tWriteBuffer(buffer, buffer.Length);\n\t}\n\tpublic ValueTask WriteAsync(string value, CancellationToken cancellationToken = default)\n\t{\n\t\tvar buffer = _charset.GetBytes(value);\n\t\treturn WriteBufferAsync(buffer, buffer.Length, cancellationToken);\n\t}\n\n\tpublic void Write(short value)\n\t{\n\t\tWrite((int)value);\n\t}\n\tpublic ValueTask WriteAsync(short value, CancellationToken cancellationToken = default)\n\t{\n\t\treturn WriteAsync((int)value, cancellationToken);\n\t}\n\n\tpublic void Write(int value)\n\t{\n\t\t_dataProvider.Write(TypeEncoder.EncodeInt32(value), 0, 4);\n\t}\n\tpublic ValueTask WriteAsync(int value, CancellationToken cancellationToken = default)\n\t{\n\t\treturn _dataProvider.WriteAsync(TypeEncoder.EncodeInt32(value), 0, 4, cancellationToken);\n\t}\n\n\tpublic void Write(long value)\n\t{\n\t\t_dataProvider.Write(TypeEncoder.EncodeInt64(value), 0, 8);\n\t}\n\tpublic ValueTask WriteAsync(long value, CancellationToken cancellationToken = default)\n\t{\n\t\treturn _dataProvider.WriteAsync(TypeEncoder.EncodeInt64(value), 0, 8, cancellationToken);\n\t}\n\n\tpublic void Write(float value)\n\t{\n\t\tvar buffer = BitConverter.GetBytes(value);\n\t\tWrite(BitConverter.ToInt32(buffer, 0));\n\t}\n\tpublic ValueTask WriteAsync(float value, CancellationToken cancellationToken = default)\n\t{\n\t\tvar buffer = BitConverter.GetBytes(value);\n\t\treturn WriteAsync(BitConverter.ToInt32(buffer, 0), cancellationToken);\n\t}\n\n\tpublic void Write(double value)\n\t{\n\t\tvar buffer = BitConverter.GetBytes(value);\n\t\tWrite(BitConverter.ToInt64(buffer, 0));\n\t}\n\tpublic ValueTask WriteAsync(double value, CancellationToken cancellationToken = default)\n\t{\n\t\tvar buffer = BitConverter.GetBytes(value);\n\t\treturn WriteAsync(BitConverter.ToInt64(buffer, 0), cancellationToken);\n\t}\n\n\tpublic void Write(decimal value, int type, int scale)\n\t{\n\t\tvar numeric = TypeEncoder.EncodeDecimal(value, scale, type);\n\t\tswitch (type & ~1)\n\t\t{\n\t\t\tcase IscCodes.SQL_SHORT:\n\t\t\t\tWrite((short)numeric);\n\t\t\t\tbreak;\n\t\t\tcase IscCodes.SQL_LONG:\n\t\t\t\tWrite((int)numeric);\n\t\t\t\tbreak;\n\t\t\tcase IscCodes.SQL_QUAD:\n\t\t\tcase IscCodes.SQL_INT64:\n\t\t\t\tWrite((long)numeric);\n\t\t\t\tbreak;\n\t\t\tcase IscCodes.SQL_DOUBLE:\n\t\t\tcase IscCodes.SQL_D_FLOAT:\n\t\t\t\tWrite((double)numeric);\n\t\t\t\tbreak;\n\t\t\tcase IscCodes.SQL_INT128:\n\t\t\t\tWrite((BigInteger)numeric);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new ArgumentOutOfRangeException(nameof(type), $\"{nameof(type)}={type}\");\n\t\t}\n\t}\n\tpublic ValueTask WriteAsync(decimal value, int type, int scale, CancellationToken cancellationToken = default)\n\t{\n\t\tvar numeric = TypeEncoder.EncodeDecimal(value, scale, type);\n\t\tswitch (type & ~1)\n\t\t{\n\t\t\tcase IscCodes.SQL_SHORT:\n\t\t\t\treturn WriteAsync((short)numeric, cancellationToken);\n\t\t\tcase IscCodes.SQL_LONG:\n\t\t\t\treturn WriteAsync((int)numeric, cancellationToken);\n\t\t\tcase IscCodes.SQL_QUAD:\n\t\t\tcase IscCodes.SQL_INT64:\n\t\t\t\treturn WriteAsync((long)numeric, cancellationToken);\n\t\t\tcase IscCodes.SQL_DOUBLE:\n\t\t\tcase IscCodes.SQL_D_FLOAT:\n\t\t\t\treturn WriteAsync((double)numeric, cancellationToken);\n\t\t\tcase IscCodes.SQL_INT128:\n\t\t\t\treturn WriteAsync((BigInteger)numeric, cancellationToken);\n\t\t\tdefault:\n\t\t\t\tthrow new ArgumentOutOfRangeException(nameof(type), $\"{nameof(type)}={type}\");\n\t\t}\n\t}\n\n\tpublic void Write(bool value)\n\t{\n\t\tWriteOpaque(TypeEncoder.EncodeBoolean(value));\n\t}\n\tpublic ValueTask WriteAsync(bool value, CancellationToken cancellationToken = default)\n\t{\n\t\treturn WriteOpaqueAsync(TypeEncoder.EncodeBoolean(value), cancellationToken);\n\t}\n\n\tpublic void Write(DateTime value)\n\t{\n\t\tWriteDate(value);\n\t\tWriteTime(TypeHelper.DateTimeTimeToTimeSpan(value));\n\t}\n\tpublic async ValueTask WriteAsync(DateTime value, CancellationToken cancellationToken = default)\n\t{\n\t\tawait WriteDateAsync(value, cancellationToken).ConfigureAwait(false);\n\t\tawait WriteTimeAsync(TypeHelper.DateTimeTimeToTimeSpan(value), cancellationToken).ConfigureAwait(false);\n\t}\n\n\tpublic void Write(Guid value, int sqlType)\n\t{\n\t\tvar bytes = TypeEncoder.EncodeGuid(value);\n\t\tif (sqlType == IscCodes.SQL_VARYING)\n\t\t{\n\t\t\tWriteBuffer(bytes);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tWriteOpaque(bytes);\n\t\t}\n\t}\n\tpublic ValueTask WriteAsync(Guid value, int sqlType, CancellationToken cancellationToken = default)\n\t{\n\t\tvar bytes = TypeEncoder.EncodeGuid(value);\n\t\tif (sqlType == IscCodes.SQL_VARYING)\n\t\t{\n\t\t\treturn WriteBufferAsync(bytes, cancellationToken);\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn WriteOpaqueAsync(bytes, cancellationToken);\n\t\t}\n\t}\n\n\tpublic void Write(FbDecFloat value, int size)\n\t{\n\t\tWriteOpaque(size switch\n\t\t{\n\t\t\t16 => TypeEncoder.EncodeDec16(value),\n\t\t\t34 => TypeEncoder.EncodeDec34(value),\n\t\t\t_ => throw new ArgumentOutOfRangeException(),\n\t\t});\n\t}\n\tpublic ValueTask WriteAsync(FbDecFloat value, int size, CancellationToken cancellationToken = default)\n\t{\n\t\treturn WriteOpaqueAsync(size switch\n\t\t{\n\t\t\t16 => TypeEncoder.EncodeDec16(value),\n\t\t\t34 => TypeEncoder.EncodeDec34(value),\n\t\t\t_ => throw new ArgumentOutOfRangeException(),\n\t\t}, cancellationToken);\n\t}\n\n\tpublic void Write(BigInteger value)\n\t{\n\t\tWriteOpaqueAsync(TypeEncoder.EncodeInt128(value));\n\t}\n\tpublic ValueTask WriteAsync(BigInteger value, CancellationToken cancellationToken = default)\n\t{\n\t\treturn WriteOpaqueAsync(TypeEncoder.EncodeInt128(value), cancellationToken);\n\t}\n\n\tpublic void WriteDate(DateTime value)\n\t{\n\t\tWrite(TypeEncoder.EncodeDate(Convert.ToDateTime(value)));\n\t}\n\tpublic ValueTask WriteDateAsync(DateTime value, CancellationToken cancellationToken = default)\n\t{\n\t\treturn WriteAsync(TypeEncoder.EncodeDate(Convert.ToDateTime(value)), cancellationToken);\n\t}\n\n\tpublic void WriteTime(TimeSpan value)\n\t{\n\t\tWrite(TypeEncoder.EncodeTime(value));\n\t}\n\tpublic ValueTask WriteTimeAsync(TimeSpan value, CancellationToken cancellationToken = default)\n\t{\n\t\treturn WriteAsync(TypeEncoder.EncodeTime(value), cancellationToken);\n\t}\n\n\t#endregion\n\n\t#region Pad + Fill\n\n\tstatic readonly byte[] PadArray = new byte[] { 0, 0, 0, 0 };\n\tvoid WritePad(int length)\n\t{\n\t\t_dataProvider.Write(PadArray, 0, length);\n\t}\n\tValueTask WritePadAsync(int length, CancellationToken cancellationToken = default)\n\t{\n\t\treturn _dataProvider.WriteAsync(PadArray, 0, length, cancellationToken);\n\t}\n\n\tvoid ReadPad(int length)\n\t{\n\t\tDebug.Assert(length < _smallBuffer.Length);\n\t\tReadBytes(_smallBuffer, length);\n\t}\n\tasync ValueTask ReadPadAsync(int length, CancellationToken cancellationToken = default)\n\t{\n\t\tDebug.Assert(length < _smallBuffer.Length);\n\t\tawait ReadBytesAsync(_smallBuffer, length, cancellationToken).ConfigureAwait(false);\n\t}\n\n\tstatic readonly byte[] FillArray = Enumerable.Repeat((byte)32, 32767).ToArray();\n\tvoid WriteFill(int length)\n\t{\n\t\t_dataProvider.Write(FillArray, 0, length);\n\t}\n\tValueTask WriteFillAsync(int length, CancellationToken cancellationToken = default)\n\t{\n\t\treturn _dataProvider.WriteAsync(FillArray, 0, length, cancellationToken);\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/FbClientFactory.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Dean Harding, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing System.Reflection.Emit;\nusing System.Runtime.InteropServices;\nusing System.Threading;\nusing FirebirdSql.Data.Client.Native.Handles;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Native;\n\n/// <summary>\n/// This class generates a dynamic class that implements the <see cref=\"IFbClient\"/> interface and\n/// calls the native methods in a given \"fbembed.dll\" (though you can name it anything you like).\n/// </summary>\ninternal static class FbClientFactory\n{\n\tprivate static readonly string DefaultDllName = \"fbembed\";\n\n\t/// <summary>\n\t/// Because generating the class at runtime is expensive, we cache it here based on the name\n\t/// specified.\n\t/// </summary>\n\tprivate static readonly Dictionary<string, IFbClient> cache;\n\tprivate static readonly ReaderWriterLockSlim cacheLock;\n\tprivate static readonly HashSet<Type> injectionTypes;\n\n\t/// <summary>\n\t/// Static constructor sets up member variables.\n\t/// </summary>\n\tstatic FbClientFactory()\n\t{\n\t\tcache = new Dictionary<string, IFbClient>();\n\t\tcacheLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion);\n\t\tinjectionTypes = new HashSet<Type>(typeof(FbClientFactory).Assembly.GetTypes()\n\t\t\t.Where(x => !x.IsAbstract && !x.IsInterface)\n\t\t\t.Where(x => typeof(IFirebirdHandle).IsAssignableFrom(x))\n\t\t\t.Select(x => x.MakeByRefType()));\n\t}\n\n\t/// <summary>\n\t/// Dynamically generates a class that will load the \"fbembed.dll\" given in <c>dllName</c>, and that\n\t/// also implements <see cref=\"IFbClient\"/>, which you can use to call the library.\n\t/// </summary>\n\t/// <param name=\"dllName\">The name of the DLL to load (e.g. \"fbembed\", \"C:\\path\\to\\fbembed.dll\", etc)</param>\n\t/// <returns>A class that implements <see cref=\"IFbClient\"/> and calls into the native library you specify.</returns>\n\tpublic static IFbClient Create(string dllName)\n\t{\n\t\tif (string.IsNullOrEmpty(dllName))\n\t\t{\n\t\t\tdllName = DefaultDllName;\n\t\t}\n\n\t\tcacheLock.EnterUpgradeableReadLock();\n\t\ttry\n\t\t{\n\t\t\tif (cache.TryGetValue(dllName, out var result))\n\t\t\t{\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcacheLock.EnterWriteLock();\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tresult = BuildFbClient(dllName);\n\t\t\t\t\tcache.Add(dllName, result);\n\t\t\t\t\tShutdownHelper.RegisterFbClientShutdown(() => NativeHelpers.CallIfExists(nameof(IFbClient.fb_shutdown), () => result.fb_shutdown(0, 0)));\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t\tfinally\n\t\t\t\t{\n\t\t\t\t\tcacheLock.ExitWriteLock();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tcacheLock.ExitUpgradeableReadLock();\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// This method does the \"heavy-lifting\" of actually generating a dynamic class that implements\n\t/// <see cref=\"IFbClient\"/>, and calls the native library specified to do the actual work.\n\t/// </summary>\n\t/// <param name=\"dllName\">The name of the libarary to use, as passed into the\n\t/// <see cref=\"DllImportAttribute\"/> that is dynamically generated.</param>\n\t/// <returns>An implementation of <see cref=\"IFbClient\"/>.</returns>\n\t/// <remarks>\n\t/// <para>Note: To be completly generic, we actually reflect through <see cref=\"IFbClient\"/>\n\t/// to get the methods and parameters to generate.</para>\n\t/// </remarks>\n\tprivate static IFbClient BuildFbClient(string dllName)\n\t{\n\t\t// Get the initial TypeBuilder, with a \"blank\" class definition\n\t\tvar tb = CreateTypeBuilder(dllName);\n\n\t\t// It needs to implement IFbClient, obviously!\n\t\ttb.AddInterfaceImplementation(typeof(IFbClient));\n\n\t\t// Now, go through all the methods in IFbClient and generate the corresponding methods\n\t\t// in our dynamic type.\n\t\tforeach (var mi in typeof(IFbClient).GetMethods())\n\t\t{\n\t\t\tGenerateMethod(tb, mi, dllName);\n\t\t}\n\n\t\t// Finally, create and return an instance of the type itself. Woot!\n\t\treturn CreateInstance(tb);\n\t}\n\n\t/// <summary>\n\t/// Generates a method on our <see cref=\"TypeBuilder\"/> for the specified <see cref=\"MethodInfo\"/>\n\t/// </summary>\n\t/// <param name=\"tb\">The <see cref=\"TypeBuilder\"/> we're generating our type with.</param>\n\t/// <param name=\"mi\">The <see cref=\"MethodInfo\"/> which represents the \"template\" method.</param>\n\t/// <param name=\"dllName\">The path to the DLL that we'll put in the <see cref=\"DllImportAttribute\"/>.</param>\n\tprivate static void GenerateMethod(TypeBuilder tb, MethodInfo mi, string dllName)\n\t{\n\t\t// These are all the parameters in our method\n\t\tvar pis = new List<ParameterInfo>(mi.GetParameters());\n\n\t\t// We need to keep the parameter types and attributes in a separate array.\n\t\tvar ptypes = new Type[pis.Count];\n\t\tvar attrs = new ParameterAttributes[pis.Count];\n\t\tfor (var i = 0; i < pis.Count; i++)\n\t\t{\n\t\t\tptypes[i] = pis[i].ParameterType;\n\t\t\tattrs[i] = pis[i].Attributes;\n\t\t}\n\n\t\t// We actually need to create TWO methods - one for the interface implementation, and one for the\n\t\t// P/Invoke declaration. We'll create the P/Invoke definition first.\n\t\tvar smb = tb.DefineMethod(\n\t\t\tmi.Name, // The name is the same as the interface name\n\t\t\t\t\t // P/Invoke methods need special attributes...\n\t\t\tMethodAttributes.Static | MethodAttributes.Private | MethodAttributes.HideBySig,\n\t\t\tmi.ReturnType, ptypes);\n\n\t\t// Get the type of the DllImportAttribute, which we'll attach to this method\n\t\tvar diaType = typeof(DllImportAttribute);\n\n\t\t// Create a CustomAttributeBuilder for the DLLImportAttribute, specifying the constructor that takes a string argument.\n\t\tvar ctor = diaType.GetConstructor(new Type[] { typeof(string) });\n\t\tvar cab = new CustomAttributeBuilder(ctor, new object[] { dllName });\n\n\t\t// Assign the DllImport attribute to the smb\n\t\tsmb.SetCustomAttribute(cab);\n\n\t\t// Also, any attributes on the actual parameters need to be copied to the P/Invoke declaration as well.\n\t\tfor (var i = 0; i < attrs.Length; i++)\n\t\t{\n\t\t\tsmb.DefineParameter(i + 1, attrs[i], pis[i].Name);\n\t\t}\n\n\t\t// Now create the interface implementation method\n\t\tvar mb = tb.DefineMethod(\n\t\t\t\"IFbClient.\" + mi.Name, // We use the standard \"Interface.Method\" to do an explicit interface implementation\n\t\t\tMethodAttributes.Private | MethodAttributes.HideBySig | MethodAttributes.NewSlot | MethodAttributes.Virtual |\n\t\t\tMethodAttributes.Final,\n\t\t\tmi.ReturnType, ptypes);\n\n\t\t// Also, any attributes on the actual parameters need to be copied to the P/Invoke declaration as well.\n\t\tfor (var i = 0; i < attrs.Length; i++)\n\t\t{\n\t\t\tmb.DefineParameter(i + 1, attrs[i], pis[i].Name);\n\t\t}\n\n\t\t// We need to generate a little IL here to actually call the P/Invoke declaration. Luckily for us, since we're just\n\t\t// going to pass our parameters to the P/Invoke method as-is, we don't need to muck with the eval stack ;-)\n\t\tvar il = mb.GetILGenerator();\n\t\tfor (var i = 1; i <= pis.Count; i++)\n\t\t{\n\t\t\tEmitLdarg(il, i);\n\t\t}\n\n\t\til.EmitCall(OpCodes.Call, smb, null);\n\n\t\tEmitClientInjectionToFirebirdHandleOjects(mi.ReturnType, pis, il);\n\n\t\til.Emit(OpCodes.Ret);\n\n\t\t// Define the fact that our IFbClient.Method is the explicit interface implementation of that method\n\t\ttb.DefineMethodOverride(mb, mi);\n\t}\n\n\tprivate static void EmitClientInjectionToFirebirdHandleOjects(\n\t\tType returnType,\n\t\tList<ParameterInfo> pis,\n\t\tILGenerator il)\n\t{\n\t\tvar injectProperties = pis.Select(x => x.ParameterType).Intersect(injectionTypes).Any();\n\t\tif (injectProperties)\n\t\t{\n\t\t\til.DeclareLocal(returnType);\n\t\t\til.Emit(OpCodes.Stloc_0);\n\t\t\tfor (var i = 0; i < pis.Count; i++)\n\t\t\t{\n\t\t\t\tif (injectionTypes.Contains(pis[i].ParameterType))\n\t\t\t\t{\n\t\t\t\t\tEmitLdarg(il, i + 1);\n\t\t\t\t\til.Emit(OpCodes.Ldind_Ref);\n\t\t\t\t\til.Emit(OpCodes.Ldarg_0);\n\t\t\t\t\til.Emit(OpCodes.Callvirt, typeof(IFirebirdHandle).GetMethod(\"SetClient\"));\n\t\t\t\t\til.Emit(OpCodes.Nop);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\til.Emit(OpCodes.Ldloc_0);\n\t\t}\n\t}\n\n\tprivate static void EmitLdarg(ILGenerator il, int i)\n\t{\n\t\tif (i == 1)\n\t\t{\n\t\t\til.Emit(OpCodes.Ldarg_1);\n\t\t}\n\t\telse if (i == 2)\n\t\t{\n\t\t\til.Emit(OpCodes.Ldarg_2);\n\t\t}\n\t\telse if (i == 3)\n\t\t{\n\t\t\til.Emit(OpCodes.Ldarg_3);\n\t\t}\n\t\telse\n\t\t{\n\t\t\til.Emit(OpCodes.Ldarg_S, (short)i);\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Creates an instance of the type itself and returns it. Cool!!\n\t/// </summary>\n\t/// <param name=\"tb\">The <see cref=\"TypeBuilder\"/> that we created our type with.</param>\n\t/// <returns>An instance of our type, cast as an <see cref=\"IFbClient\"/>.</returns>\n\tprivate static IFbClient CreateInstance(TypeBuilder tb)\n\t{\n\t\tvar t = tb.CreateTypeInfo().AsType();\n\t\treturn (IFbClient)Activator.CreateInstance(t);\n\t}\n\n\t/// <summary>\n\t/// Creates the assembly and module into which we'll generate our class, and returns\n\t/// a <see cref=\"TypeBuilder\"/> we can use for building up our type.\n\t/// </summary>\n\t/// <param name=\"baseName\">The \"base name\" to use for the name of the assembly and mode.</param>\n\t/// <returns>A <see cref=\"TypeBuilder\"/> which we can use for building our type.</returns>\n\t/// <remarks>\n\t/// <para>Notice that we actually generate a new assembly for every different <c>dllName</c> that is\n\t/// passed into <see cref=\"BuildFbClient\"/>. This might be inefficient, but since we're mostly\n\t/// only ever going to have one (or maybe two) different <c>dllName</c>s, it's not a big deal.</para>\n\t/// </remarks>\n\tprivate static TypeBuilder CreateTypeBuilder(string baseName)\n\t{\n\t\tbaseName = SanitizeBaseName(baseName);\n\n\t\t// Generate a name for our assembly, based on the name of the DLL.\n\t\tvar assemblyName = new AssemblyName();\n\t\tassemblyName.Name = baseName + \"_Assembly\";\n\n\t\t// We create the dynamic assembly in our current AppDomain\n\t\tvar assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);\n\n\t\t// Generate the actual module (which is the DLL itself)\n\t\tvar moduleBuilder = assemblyBuilder.DefineDynamicModule(baseName + \"_Module\");\n\n\t\t// Add our type to the module.\n\t\treturn moduleBuilder.DefineType(baseName + \"_Class\", TypeAttributes.Class);\n\t}\n\n\t/// <summary>\n\t/// Because the <c>baseName</c> could include things like '\\' and '/' - which are not legal\n\t/// type names, we need to \"sanitize\" the name and make it acceptable.\n\t/// </summary>\n\t/// <param name=\"baseName\">The \"base name\" which we'll make sure contains only legal\n\t/// identfier characters.</param>\n\t/// <returns>A new string that is a value type name.</returns>\n\tprivate static string SanitizeBaseName(string baseName)\n\t{\n\t\t// Note: We could actually go through and replace invalid characters with different\n\t\t// characters, and so on, but that's too much work. Besides, you never really see the\n\t\t// dynamic type name (expect maybe in a stack trace). If you really don't like this method,\n\t\t// you're free to change it ;)\n\n\t\treturn \"FB_\" + Math.Abs(baseName.GetHashCode());\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/FesArray.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Globalization;\nusing System.IO;\nusing System.Reflection;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Client.Native.Marshalers;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Native;\n\ninternal sealed class FesArray : ArrayBase\n{\n\t#region Fields\n\n\tprivate long _handle;\n\tprivate FesDatabase _database;\n\tprivate FesTransaction _transaction;\n\tprivate IntPtr[] _statusVector;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic override long Handle\n\t{\n\t\tget { return _handle; }\n\t\tset { _handle = value; }\n\t}\n\n\tpublic override DatabaseBase Database\n\t{\n\t\tget { return _database; }\n\t\tset { _database = (FesDatabase)value; }\n\t}\n\n\tpublic override TransactionBase Transaction\n\t{\n\t\tget { return _transaction; }\n\t\tset { _transaction = (FesTransaction)value; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FesArray(ArrayDesc descriptor)\n\t\t: base(descriptor)\n\t{\n\t\t_statusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH];\n\t}\n\n\tpublic FesArray(FesDatabase database, FesTransaction transaction, string tableName, string fieldName)\n\t\t: this(database, transaction, -1, tableName, fieldName)\n\t{ }\n\n\tpublic FesArray(FesDatabase database, FesTransaction transaction, long handle, string tableName, string fieldName)\n\t\t: base(tableName, fieldName)\n\t{\n\t\t_database = database;\n\t\t_transaction = transaction;\n\t\t_handle = handle;\n\t\t_statusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH];\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic override byte[] GetSlice(int sliceLength)\n\t{\n\t\tClearStatusVector();\n\n\t\tvar dbHandle = _database.HandlePtr;\n\t\tvar trHandle = _transaction.HandlePtr;\n\n\t\tvar arrayDesc = ArrayDescMarshaler.MarshalManagedToNative(Descriptor);\n\n\t\tvar buffer = new byte[sliceLength];\n\n\t\t_database.FbClient.isc_array_get_slice(\n\t\t\t_statusVector,\n\t\t\tref dbHandle,\n\t\t\tref trHandle,\n\t\t\tref _handle,\n\t\t\tarrayDesc,\n\t\t\tbuffer,\n\t\t\tref sliceLength);\n\n\t\tArrayDescMarshaler.CleanUpNativeData(ref arrayDesc);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\treturn buffer;\n\t}\n\tpublic override ValueTask<byte[]> GetSliceAsync(int sliceLength, CancellationToken cancellationToken = default)\n\t{\n\t\tClearStatusVector();\n\n\t\tvar dbHandle = _database.HandlePtr;\n\t\tvar trHandle = _transaction.HandlePtr;\n\n\t\tvar arrayDesc = ArrayDescMarshaler.MarshalManagedToNative(Descriptor);\n\n\t\tvar buffer = new byte[sliceLength];\n\n\t\t_database.FbClient.isc_array_get_slice(\n\t\t\t_statusVector,\n\t\t\tref dbHandle,\n\t\t\tref trHandle,\n\t\t\tref _handle,\n\t\t\tarrayDesc,\n\t\t\tbuffer,\n\t\t\tref sliceLength);\n\n\t\tArrayDescMarshaler.CleanUpNativeData(ref arrayDesc);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\treturn ValueTask.FromResult(buffer);\n\t}\n\n\tpublic override void PutSlice(Array sourceArray, int sliceLength)\n\t{\n\t\tClearStatusVector();\n\n\t\tvar dbHandle = _database.HandlePtr;\n\t\tvar trHandle = _transaction.HandlePtr;\n\n\t\tvar arrayDesc = ArrayDescMarshaler.MarshalManagedToNative(Descriptor);\n\n\t\tvar systemType = GetSystemType();\n\n\t\tvar buffer = new byte[sliceLength];\n\t\tif (systemType.GetTypeInfo().IsPrimitive)\n\t\t{\n\t\t\tBuffer.BlockCopy(sourceArray, 0, buffer, 0, buffer.Length);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tbuffer = EncodeSlice(Descriptor, sourceArray, sliceLength);\n\t\t}\n\n\t\t_database.FbClient.isc_array_put_slice(\n\t\t\t_statusVector,\n\t\t\tref dbHandle,\n\t\t\tref trHandle,\n\t\t\tref _handle,\n\t\t\tarrayDesc,\n\t\t\tbuffer,\n\t\t\tref sliceLength);\n\n\t\tArrayDescMarshaler.CleanUpNativeData(ref arrayDesc);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\t}\n\tpublic override ValueTask PutSliceAsync(Array sourceArray, int sliceLength, CancellationToken cancellationToken = default)\n\t{\n\t\tClearStatusVector();\n\n\t\tvar dbHandle = _database.HandlePtr;\n\t\tvar trHandle = _transaction.HandlePtr;\n\n\t\tvar arrayDesc = ArrayDescMarshaler.MarshalManagedToNative(Descriptor);\n\n\t\tvar systemType = GetSystemType();\n\n\t\tvar buffer = new byte[sliceLength];\n\t\tif (systemType.GetTypeInfo().IsPrimitive)\n\t\t{\n\t\t\tBuffer.BlockCopy(sourceArray, 0, buffer, 0, buffer.Length);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tbuffer = EncodeSlice(Descriptor, sourceArray, sliceLength);\n\t\t}\n\n\t\t_database.FbClient.isc_array_put_slice(\n\t\t\t_statusVector,\n\t\t\tref dbHandle,\n\t\t\tref trHandle,\n\t\t\tref _handle,\n\t\t\tarrayDesc,\n\t\t\tbuffer,\n\t\t\tref sliceLength);\n\n\t\tArrayDescMarshaler.CleanUpNativeData(ref arrayDesc);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\t#endregion\n\n\t#region Protected Methods\n\n\tprotected override Array DecodeSlice(byte[] slice)\n\t{\n\t\tArray sliceData = null;\n\t\tvar slicePosition = 0;\n\t\tvar type = 0;\n\t\tvar dbType = DbDataType.Array;\n\t\tvar systemType = GetSystemType();\n\t\tvar charset = _database.Charset;\n\t\tvar lengths = new int[Descriptor.Dimensions];\n\t\tvar lowerBounds = new int[Descriptor.Dimensions];\n\n\t\tfor (var i = 0; i < Descriptor.Dimensions; i++)\n\t\t{\n\t\t\tlowerBounds[i] = Descriptor.Bounds[i].LowerBound;\n\t\t\tlengths[i] = Descriptor.Bounds[i].UpperBound;\n\n\t\t\tif (lowerBounds[i] == 0)\n\t\t\t{\n\t\t\t\tlengths[i]++;\n\t\t\t}\n\t\t}\n\n\t\tsliceData = Array.CreateInstance(systemType, lengths, lowerBounds);\n\n\t\tvar tempData = Array.CreateInstance(systemType, sliceData.Length);\n\n\t\ttype = TypeHelper.GetSqlTypeFromBlrType(Descriptor.DataType);\n\t\tdbType = TypeHelper.GetDbDataTypeFromBlrType(Descriptor.DataType, 0, Descriptor.Scale);\n\n\t\tint itemLength = Descriptor.Length;\n\n\t\tfor (var i = 0; i < tempData.Length; i++)\n\t\t{\n\t\t\tif (slicePosition >= slice.Length)\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tswitch (dbType)\n\t\t\t{\n\t\t\t\tcase DbDataType.Char:\n\t\t\t\t\ttempData.SetValue(charset.GetString(slice, slicePosition, itemLength), i);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.VarChar:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar index = slicePosition;\n\t\t\t\t\t\tvar count = 0;\n\t\t\t\t\t\twhile (slice[index++] != 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcount++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttempData.SetValue(charset.GetString(slice, slicePosition, count), i);\n\n\t\t\t\t\t\tslicePosition += 2;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.SmallInt:\n\t\t\t\t\ttempData.SetValue(BitConverter.ToInt16(slice, slicePosition), i);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Integer:\n\t\t\t\t\ttempData.SetValue(BitConverter.ToInt32(slice, slicePosition), i);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.BigInt:\n\t\t\t\t\ttempData.SetValue(BitConverter.ToInt64(slice, slicePosition), i);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Decimal:\n\t\t\t\tcase DbDataType.Numeric:\n\t\t\t\t\t{\n\t\t\t\t\t\tobject evalue = null;\n\n\t\t\t\t\t\tswitch (type)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcase IscCodes.SQL_SHORT:\n\t\t\t\t\t\t\t\tevalue = BitConverter.ToInt16(slice, slicePosition);\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase IscCodes.SQL_LONG:\n\t\t\t\t\t\t\t\tevalue = BitConverter.ToInt32(slice, slicePosition);\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase IscCodes.SQL_QUAD:\n\t\t\t\t\t\t\tcase IscCodes.SQL_INT64:\n\t\t\t\t\t\t\t\tevalue = BitConverter.ToInt64(slice, slicePosition);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvar dvalue = TypeDecoder.DecodeDecimal(evalue, Descriptor.Scale, type);\n\n\t\t\t\t\t\ttempData.SetValue(dvalue, i);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Double:\n\t\t\t\t\ttempData.SetValue(BitConverter.ToDouble(slice, slicePosition), i);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Float:\n\t\t\t\t\ttempData.SetValue(BitConverter.ToSingle(slice, slicePosition), i);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Date:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar idate = BitConverter.ToInt32(slice, slicePosition);\n\n\t\t\t\t\t\tvar date = TypeDecoder.DecodeDate(idate);\n\n\t\t\t\t\t\ttempData.SetValue(date, i);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Time:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar itime = BitConverter.ToInt32(slice, slicePosition);\n\n\t\t\t\t\t\tvar time = TypeDecoder.DecodeTime(itime);\n\n\t\t\t\t\t\ttempData.SetValue(time, i);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar idate = BitConverter.ToInt32(slice, slicePosition);\n\t\t\t\t\t\tvar itime = BitConverter.ToInt32(slice, slicePosition + 4);\n\n\t\t\t\t\t\tvar date = TypeDecoder.DecodeDate(idate);\n\t\t\t\t\t\tvar time = TypeDecoder.DecodeTime(itime);\n\n\t\t\t\t\t\tvar timestamp = date.Add(time);\n\n\t\t\t\t\t\ttempData.SetValue(timestamp, i);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tslicePosition += itemLength;\n\t\t}\n\n\t\tif (systemType.GetTypeInfo().IsPrimitive)\n\t\t{\n\t\t\t// For primitive types we can use System.Buffer\tto copy\tgenerated data to destination array\n\t\t\tBuffer.BlockCopy(tempData, 0, sliceData, 0, Buffer.ByteLength(tempData));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tsliceData = tempData;\n\t\t}\n\n\t\treturn sliceData;\n\t}\n\tprotected override ValueTask<Array> DecodeSliceAsync(byte[] slice, CancellationToken cancellationToken = default)\n\t{\n\t\tArray sliceData = null;\n\t\tvar slicePosition = 0;\n\t\tvar type = 0;\n\t\tvar dbType = DbDataType.Array;\n\t\tvar systemType = GetSystemType();\n\t\tvar charset = _database.Charset;\n\t\tvar lengths = new int[Descriptor.Dimensions];\n\t\tvar lowerBounds = new int[Descriptor.Dimensions];\n\n\t\tfor (var i = 0; i < Descriptor.Dimensions; i++)\n\t\t{\n\t\t\tlowerBounds[i] = Descriptor.Bounds[i].LowerBound;\n\t\t\tlengths[i] = Descriptor.Bounds[i].UpperBound;\n\n\t\t\tif (lowerBounds[i] == 0)\n\t\t\t{\n\t\t\t\tlengths[i]++;\n\t\t\t}\n\t\t}\n\n\t\tsliceData = Array.CreateInstance(systemType, lengths, lowerBounds);\n\n\t\tvar tempData = Array.CreateInstance(systemType, sliceData.Length);\n\n\t\ttype = TypeHelper.GetSqlTypeFromBlrType(Descriptor.DataType);\n\t\tdbType = TypeHelper.GetDbDataTypeFromBlrType(Descriptor.DataType, 0, Descriptor.Scale);\n\n\t\tint itemLength = Descriptor.Length;\n\n\t\tfor (var i = 0; i < tempData.Length; i++)\n\t\t{\n\t\t\tif (slicePosition >= slice.Length)\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tswitch (dbType)\n\t\t\t{\n\t\t\t\tcase DbDataType.Char:\n\t\t\t\t\ttempData.SetValue(charset.GetString(slice, slicePosition, itemLength), i);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.VarChar:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar index = slicePosition;\n\t\t\t\t\t\tvar count = 0;\n\t\t\t\t\t\twhile (slice[index++] != 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcount++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttempData.SetValue(charset.GetString(slice, slicePosition, count), i);\n\n\t\t\t\t\t\tslicePosition += 2;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.SmallInt:\n\t\t\t\t\ttempData.SetValue(BitConverter.ToInt16(slice, slicePosition), i);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Integer:\n\t\t\t\t\ttempData.SetValue(BitConverter.ToInt32(slice, slicePosition), i);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.BigInt:\n\t\t\t\t\ttempData.SetValue(BitConverter.ToInt64(slice, slicePosition), i);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Decimal:\n\t\t\t\tcase DbDataType.Numeric:\n\t\t\t\t\t{\n\t\t\t\t\t\tobject evalue = null;\n\n\t\t\t\t\t\tswitch (type)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcase IscCodes.SQL_SHORT:\n\t\t\t\t\t\t\t\tevalue = BitConverter.ToInt16(slice, slicePosition);\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase IscCodes.SQL_LONG:\n\t\t\t\t\t\t\t\tevalue = BitConverter.ToInt32(slice, slicePosition);\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase IscCodes.SQL_QUAD:\n\t\t\t\t\t\t\tcase IscCodes.SQL_INT64:\n\t\t\t\t\t\t\t\tevalue = BitConverter.ToInt64(slice, slicePosition);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvar dvalue = TypeDecoder.DecodeDecimal(evalue, Descriptor.Scale, type);\n\n\t\t\t\t\t\ttempData.SetValue(dvalue, i);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Double:\n\t\t\t\t\ttempData.SetValue(BitConverter.ToDouble(slice, slicePosition), i);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Float:\n\t\t\t\t\ttempData.SetValue(BitConverter.ToSingle(slice, slicePosition), i);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Date:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar idate = BitConverter.ToInt32(slice, slicePosition);\n\n\t\t\t\t\t\tvar date = TypeDecoder.DecodeDate(idate);\n\n\t\t\t\t\t\ttempData.SetValue(date, i);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Time:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar itime = BitConverter.ToInt32(slice, slicePosition);\n\n\t\t\t\t\t\tvar time = TypeDecoder.DecodeTime(itime);\n\n\t\t\t\t\t\ttempData.SetValue(time, i);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar idate = BitConverter.ToInt32(slice, slicePosition);\n\t\t\t\t\t\tvar itime = BitConverter.ToInt32(slice, slicePosition + 4);\n\n\t\t\t\t\t\tvar date = TypeDecoder.DecodeDate(idate);\n\t\t\t\t\t\tvar time = TypeDecoder.DecodeTime(itime);\n\n\t\t\t\t\t\tvar timestamp = date.Add(time);\n\n\t\t\t\t\t\ttempData.SetValue(timestamp, i);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tslicePosition += itemLength;\n\t\t}\n\n\t\tif (systemType.GetTypeInfo().IsPrimitive)\n\t\t{\n\t\t\t// For primitive types we can use System.Buffer\tto copy\tgenerated data to destination array\n\t\t\tBuffer.BlockCopy(tempData, 0, sliceData, 0, Buffer.ByteLength(tempData));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tsliceData = tempData;\n\t\t}\n\n\t\treturn ValueTask.FromResult(sliceData);\n\t}\n\n\t#endregion\n\n\t#region Private Metods\n\n\tprivate void ClearStatusVector()\n\t{\n\t\tArray.Clear(_statusVector, 0, _statusVector.Length);\n\t}\n\n\tprivate byte[] EncodeSlice(ArrayDesc desc, Array sourceArray, int length)\n\t{\n\t\tusing (var ms = new MemoryStream())\n\t\t{\n\t\t\tusing (var writer = new BinaryWriter(ms))\n\t\t\t{\n\t\t\t\tvar charset = _database.Charset;\n\t\t\t\tvar dbType = DbDataType.Array;\n\t\t\t\tvar subType = (Descriptor.Scale < 0) ? 2 : 0;\n\t\t\t\tvar type = 0;\n\n\t\t\t\ttype = TypeHelper.GetSqlTypeFromBlrType(Descriptor.DataType);\n\t\t\t\tdbType = TypeHelper.GetDbDataTypeFromBlrType(Descriptor.DataType, subType, Descriptor.Scale);\n\n\t\t\t\tforeach (var source in sourceArray)\n\t\t\t\t{\n\t\t\t\t\tswitch (dbType)\n\t\t\t\t\t{\n\t\t\t\t\t\tcase DbDataType.Char:\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvar value = source != null ? (string)source : string.Empty;\n\t\t\t\t\t\t\t\tvar buffer = charset.GetBytes(value);\n\n\t\t\t\t\t\t\t\twriter.Write(buffer);\n\n\t\t\t\t\t\t\t\tif (desc.Length > buffer.Length)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tfor (var j = buffer.Length; j < desc.Length; j++)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\twriter.Write((byte)32);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.VarChar:\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvar value = source != null ? (string)source : string.Empty;\n\n\t\t\t\t\t\t\t\tvar buffer = charset.GetBytes(value);\n\t\t\t\t\t\t\t\twriter.Write(buffer);\n\n\t\t\t\t\t\t\t\tif (desc.Length > buffer.Length)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tfor (var j = buffer.Length; j < desc.Length; j++)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\twriter.Write((byte)0);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\twriter.Write((short)0);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.SmallInt:\n\t\t\t\t\t\t\twriter.Write((short)source);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Integer:\n\t\t\t\t\t\t\twriter.Write((int)source);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.BigInt:\n\t\t\t\t\t\t\twriter.Write((long)source);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Float:\n\t\t\t\t\t\t\twriter.Write((float)source);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Double:\n\t\t\t\t\t\t\twriter.Write((double)source);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Numeric:\n\t\t\t\t\t\tcase DbDataType.Decimal:\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvar numeric = TypeEncoder.EncodeDecimal((decimal)source, desc.Scale, type);\n\n\t\t\t\t\t\t\t\tswitch (type)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcase IscCodes.SQL_SHORT:\n\t\t\t\t\t\t\t\t\t\twriter.Write((short)numeric);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\tcase IscCodes.SQL_LONG:\n\t\t\t\t\t\t\t\t\t\twriter.Write((int)numeric);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\tcase IscCodes.SQL_QUAD:\n\t\t\t\t\t\t\t\t\tcase IscCodes.SQL_INT64:\n\t\t\t\t\t\t\t\t\t\twriter.Write((long)numeric);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Date:\n\t\t\t\t\t\t\twriter.Write(TypeEncoder.EncodeDate(Convert.ToDateTime(source, CultureInfo.CurrentCulture.DateTimeFormat)));\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Time:\n\t\t\t\t\t\t\twriter.Write(TypeEncoder.EncodeTime((TimeSpan)source));\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\t\t\t\tvar dt = Convert.ToDateTime(source, CultureInfo.CurrentCulture.DateTimeFormat);\n\t\t\t\t\t\t\twriter.Write(TypeEncoder.EncodeDate(dt));\n\t\t\t\t\t\t\twriter.Write(TypeEncoder.EncodeTime(TypeHelper.DateTimeTimeToTimeSpan(dt)));\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow TypeHelper.InvalidDataType((int)dbType);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\twriter.Flush();\n\t\t\t\treturn ms.ToArray();\n\t\t\t}\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/FesBlob.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.IO;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Client.Native.Handles;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Native;\n\ninternal sealed class FesBlob : BlobBase\n{\n\t#region Fields\n\n\tprivate FesDatabase _database;\n\tprivate IntPtr[] _statusVector;\n\tprivate BlobHandle _blobHandle;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic override DatabaseBase Database\n\t{\n\t\tget { return _database; }\n\t}\n\n\tpublic override int Handle\n\t{\n\t\tget { return _blobHandle.DangerousGetHandle().AsInt(); }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FesBlob(FesDatabase database, FesTransaction transaction)\n\t\t: this(database, transaction, 0)\n\t{\n\t}\n\n\tpublic FesBlob(FesDatabase database, FesTransaction transaction, long blobId)\n\t\t: base(database)\n\t{\n\t\t_database = database;\n\t\t_transaction = transaction;\n\t\t_position = 0;\n\t\t_blobHandle = new BlobHandle();\n\t\t_blobId = blobId;\n\t\t_statusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH];\n\t}\n\n\t#endregion\n\n\t#region Protected Methods\n\n\tpublic override void Create()\n\t{\n\t\tClearStatusVector();\n\n\t\tvar dbHandle = _database.HandlePtr;\n\t\tvar trHandle = ((FesTransaction)_transaction).HandlePtr;\n\n\t\t_database.FbClient.isc_create_blob2(\n\t\t\t_statusVector,\n\t\t\tref dbHandle,\n\t\t\tref trHandle,\n\t\t\tref _blobHandle,\n\t\t\tref _blobId,\n\t\t\t0,\n\t\t\tnew byte[0]);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\t_isOpen = true;\n\n\t\tRblAddValue(IscCodes.RBL_create);\n\t}\n\tpublic override ValueTask CreateAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tClearStatusVector();\n\n\t\tvar dbHandle = _database.HandlePtr;\n\t\tvar trHandle = ((FesTransaction)_transaction).HandlePtr;\n\n\t\t_database.FbClient.isc_create_blob2(\n\t\t\t_statusVector,\n\t\t\tref dbHandle,\n\t\t\tref trHandle,\n\t\t\tref _blobHandle,\n\t\t\tref _blobId,\n\t\t\t0,\n\t\t\tnew byte[0]);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\t_isOpen = true;\n\n\t\tRblAddValue(IscCodes.RBL_create);\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override void Open()\n\t{\n\t\tClearStatusVector();\n\n\t\tvar dbHandle = _database.HandlePtr;\n\t\tvar trHandle = ((FesTransaction)_transaction).HandlePtr;\n\n\t\t_database.FbClient.isc_open_blob2(\n\t\t\t_statusVector,\n\t\t\tref dbHandle,\n\t\t\tref trHandle,\n\t\t\tref _blobHandle,\n\t\t\tref _blobId,\n\t\t\t0,\n\t\t\tnew byte[0]);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\t_isOpen = true;\n\t}\n\tpublic override ValueTask OpenAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tClearStatusVector();\n\n\t\tvar dbHandle = _database.HandlePtr;\n\t\tvar trHandle = ((FesTransaction)_transaction).HandlePtr;\n\n\t\t_database.FbClient.isc_open_blob2(\n\t\t\t_statusVector,\n\t\t\tref dbHandle,\n\t\t\tref trHandle,\n\t\t\tref _blobHandle,\n\t\t\tref _blobId,\n\t\t\t0,\n\t\t\tnew byte[0]);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\t_isOpen = true;\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override int GetLength()\n\t{\n\t\tClearStatusVector();\n\n\t\tvar buffer = new byte[20];\n\n\t\t_database.FbClient.isc_blob_info(\n\t\t\t_statusVector,\n\t\t\tref _blobHandle,\n\t\t\t1,\n\t\t\tnew byte[] { IscCodes.isc_info_blob_total_length },\n\t\t\t(short)buffer.Length,\n\t\t\tbuffer);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\tvar length = IscHelper.VaxInteger(buffer, 1, 2);\n\t\tvar size = IscHelper.VaxInteger(buffer, 3, (int)length);\n\n\t\treturn (int)size;\n\t}\n\n\tpublic override ValueTask<int> GetLengthAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tClearStatusVector();\n\n\t\tvar buffer = new byte[20];\n\n\t\t_database.FbClient.isc_blob_info(\n\t\t\t_statusVector,\n\t\t\tref _blobHandle,\n\t\t\t1,\n\t\t\tnew byte[] { IscCodes.isc_info_blob_total_length },\n\t\t\t(short)buffer.Length,\n\t\t\tbuffer);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\tvar length = IscHelper.VaxInteger(buffer, 1, 2);\n\t\tvar size = IscHelper.VaxInteger(buffer, 3, (int)length);\n\n\t\treturn ValueTask.FromResult((int)size);\n\t}\n\n\tpublic override void GetSegment(Stream stream)\n\t{\n\t\tvar requested = (short)SegmentSize;\n\t\tshort segmentLength = 0;\n\n\t\tClearStatusVector();\n\n\t\tvar tmp = new byte[requested];\n\n\t\tvar status = _database.FbClient.isc_get_segment(\n\t\t\t_statusVector,\n\t\t\tref _blobHandle,\n\t\t\tref segmentLength,\n\t\t\trequested,\n\t\t\ttmp);\n\n\t\tRblRemoveValue(IscCodes.RBL_segment);\n\n\t\tif (_statusVector[1] == new IntPtr(IscCodes.isc_segstr_eof))\n\t\t{\n\t\t\tRblAddValue(IscCodes.RBL_eof_pending);\n\t\t\treturn;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (status == IntPtr.Zero || _statusVector[1] == new IntPtr(IscCodes.isc_segment))\n\t\t\t{\n\t\t\t\tRblAddValue(IscCodes.RBL_segment);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_database.ProcessStatusVector(_statusVector);\n\t\t\t}\n\t\t}\n\n\t\tstream.Write(tmp, 0, segmentLength);\n\t}\n\tpublic override ValueTask GetSegmentAsync(Stream stream, CancellationToken cancellationToken = default)\n\t{\n\t\tvar requested = (short)SegmentSize;\n\t\tshort segmentLength = 0;\n\n\t\tClearStatusVector();\n\n\t\tvar tmp = new byte[requested];\n\n\t\tvar status = _database.FbClient.isc_get_segment(\n\t\t\t_statusVector,\n\t\t\tref _blobHandle,\n\t\t\tref segmentLength,\n\t\t\trequested,\n\t\t\ttmp);\n\n\n\t\tRblRemoveValue(IscCodes.RBL_segment);\n\n\t\tif (_statusVector[1] == new IntPtr(IscCodes.isc_segstr_eof))\n\t\t{\n\t\t\tRblAddValue(IscCodes.RBL_eof_pending);\n\t\t\treturn ValueTask.CompletedTask;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (status == IntPtr.Zero || _statusVector[1] == new IntPtr(IscCodes.isc_segment))\n\t\t\t{\n\t\t\t\tRblAddValue(IscCodes.RBL_segment);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_database.ProcessStatusVector(_statusVector);\n\t\t\t}\n\t\t}\n\n\t\tstream.Write(tmp, 0, segmentLength);\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override byte[] GetSegment()\n\t{\n\t\tvar requested = (short)(SegmentSize - 2);\n\t\tshort segmentLength = 0;\n\n\t\tClearStatusVector();\n\n\t\tvar tmp = new byte[requested];\n\n\t\tvar status = _database.FbClient.isc_get_segment(\n\t\t\t_statusVector,\n\t\t\tref _blobHandle,\n\t\t\tref segmentLength,\n\t\t\trequested,\n\t\t\ttmp);\n\n\n\t\tRblRemoveValue(IscCodes.RBL_segment);\n\n\t\tif (_statusVector[1] == new IntPtr(IscCodes.isc_segstr_eof))\n\t\t{\n\t\t\tRblAddValue(IscCodes.RBL_eof_pending);\n\t\t\treturn Array.Empty<byte>();\n\t\t}\n\n\t\tif (status == IntPtr.Zero || _statusVector[1] == new IntPtr(IscCodes.isc_segment))\n\t\t{\n\t\t\tRblAddValue(IscCodes.RBL_segment);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t_database.ProcessStatusVector(_statusVector);\n\t\t}\n\n\t\tvar actualSegment = tmp;\n\t\tif (actualSegment.Length != segmentLength)\n\t\t{\n\t\t\ttmp = new byte[segmentLength];\n\t\t\tArray.Copy(actualSegment, tmp, segmentLength);\n\t\t\tactualSegment = tmp;\n\t\t}\n\n\t\treturn actualSegment;\n\t}\n\tpublic override ValueTask<byte[]> GetSegmentAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar requested = (short)SegmentSize;\n\t\tshort segmentLength = 0;\n\n\t\tClearStatusVector();\n\n\t\tvar tmp = new byte[requested];\n\n\t\tvar status = _database.FbClient.isc_get_segment(\n\t\t\t_statusVector,\n\t\t\tref _blobHandle,\n\t\t\tref segmentLength,\n\t\t\trequested,\n\t\t\ttmp);\n\n\n\t\tRblRemoveValue(IscCodes.RBL_segment);\n\n\t\tif (_statusVector[1] == new IntPtr(IscCodes.isc_segstr_eof))\n\t\t{\n\t\t\tRblAddValue(IscCodes.RBL_eof_pending);\n\t\t\treturn ValueTask.FromResult(Array.Empty<byte>());\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (status == IntPtr.Zero || _statusVector[1] == new IntPtr(IscCodes.isc_segment))\n\t\t\t{\n\t\t\t\tRblAddValue(IscCodes.RBL_segment);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_database.ProcessStatusVector(_statusVector);\n\t\t\t}\n\t\t}\n\n\t\tvar actualSegment = tmp;\n\t\tif (actualSegment.Length != segmentLength)\n\t\t{\n\t\t\ttmp = new byte[segmentLength];\n\t\t\tArray.Copy(actualSegment, tmp, segmentLength);\n\t\t\tactualSegment = tmp;\n\t\t}\n\n\t\treturn ValueTask.FromResult(actualSegment);\n\t}\n\n\tpublic override void PutSegment(byte[] buffer)\n\t{\n\t\tClearStatusVector();\n\n\t\t_database.FbClient.isc_put_segment(\n\t\t\t_statusVector,\n\t\t\tref _blobHandle,\n\t\t\t(short)buffer.Length,\n\t\t\tbuffer);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\t}\n\tpublic override ValueTask PutSegmentAsync(byte[] buffer, CancellationToken cancellationToken = default)\n\t{\n\t\tClearStatusVector();\n\n\t\t_database.FbClient.isc_put_segment(\n\t\t\t_statusVector,\n\t\t\tref _blobHandle,\n\t\t\t(short)buffer.Length,\n\t\t\tbuffer);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override void Seek(int position, int seekOperation)\n\t{\n\t\tClearStatusVector();\n\n\t\tvar resultingPosition = 0;\n\t\t_database.FbClient.isc_seek_blob(\n\t\t\t_statusVector,\n\t\t\tref _blobHandle,\n\t\t\t(short)seekOperation,\n\t\t\tposition,\n\t\t\tref resultingPosition);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\t}\n\tpublic override ValueTask SeekAsync(int position, int seekOperation, CancellationToken cancellationToken = default)\n\t{\n\t\tClearStatusVector();\n\n\t\tvar resultingPosition = 0;\n\t\t_database.FbClient.isc_seek_blob(\n\t\t\t_statusVector,\n\t\t\tref _blobHandle,\n\t\t\t(short)seekOperation,\n\t\t\tposition,\n\t\t\tref resultingPosition);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override void Close()\n\t{\n\t\tClearStatusVector();\n\n\t\t_database.FbClient.isc_close_blob(_statusVector, ref _blobHandle);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\t}\n\tpublic override ValueTask CloseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tClearStatusVector();\n\n\t\t_database.FbClient.isc_close_blob(_statusVector, ref _blobHandle);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override void Cancel()\n\t{\n\t\tClearStatusVector();\n\n\t\t_database.FbClient.isc_cancel_blob(_statusVector, ref _blobHandle);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\t}\n\tpublic override ValueTask CancelAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tClearStatusVector();\n\n\t\t_database.FbClient.isc_cancel_blob(_statusVector, ref _blobHandle);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void ClearStatusVector()\n\t{\n\t\tArray.Clear(_statusVector, 0, _statusVector.Length);\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/FesConnection.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Text;\nusing System.Text.RegularExpressions;\n\nnamespace FirebirdSql.Data.Client.Native;\n\ninternal sealed class FesConnection\n{\n\tprivate FesConnection()\n\t{ }\n\n\tpublic static Version GetClientVersion(IFbClient fbClient)\n\t{\n\t\tvar sb = new StringBuilder(64);\n\t\tfbClient.isc_get_client_version(sb);\n\t\tvar version = sb.ToString();\n\t\tvar m = Regex.Match(version, @\"Firebird (\\d+.\\d+)\");\n\t\tif (!m.Success)\n\t\t\treturn null;\n\t\treturn new Version(m.Groups[1].Value);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/FesDatabase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Client.Native.Handles;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Native;\n\ninternal sealed class FesDatabase : DatabaseBase\n{\n\t#region Fields\n\n\tprivate static readonly Version Version25 = new Version(2, 5);\n\n\tprivate readonly IFbClient _fbClient;\n\tprivate readonly Version _fbClientVersion;\n\tprivate DatabaseHandle _handle;\n\tprivate IntPtr[] _statusVector;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic override bool UseUtf8ParameterBuffer => _fbClientVersion >= Version25;\n\tpublic override int Handle => _handle.DangerousGetHandle().AsInt();\n\tpublic override bool HasRemoteEventSupport => false;\n\tpublic override bool ConnectionBroken => false;\n\tpublic IFbClient FbClient => _fbClient;\n\tpublic Version FbClientVersion => _fbClientVersion;\n\tpublic DatabaseHandle HandlePtr => _handle;\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FesDatabase(string dllName, Charset charset, int packetSize, short dialect)\n\t\t: base(charset, packetSize, dialect)\n\t{\n\t\t_fbClient = FbClientFactory.Create(dllName);\n\t\t_fbClientVersion = FesConnection.GetClientVersion(_fbClient);\n\t\t_handle = new DatabaseHandle();\n\t\t_statusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH];\n\t}\n\n\t#endregion\n\n\t#region Database Methods\n\n\tpublic override void CreateDatabase(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey)\n\t{\n\t\tCheckCryptKeyForSupport(cryptKey);\n\n\t\tvar databaseBuffer = dpb.Encoding.GetBytes(database);\n\n\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\t_fbClient.isc_create_database(\n\t\t\t_statusVector,\n\t\t\t(short)databaseBuffer.Length,\n\t\t\tdatabaseBuffer,\n\t\t\tref _handle,\n\t\t\tdpb.Length,\n\t\t\tdpb.ToArray(),\n\t\t\t0);\n\n\t\tProcessStatusVector(Charset.DefaultCharset);\n\t}\n\tpublic override ValueTask CreateDatabaseAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\tCheckCryptKeyForSupport(cryptKey);\n\n\t\tvar databaseBuffer = dpb.Encoding.GetBytes(database);\n\n\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\t_fbClient.isc_create_database(\n\t\t\t_statusVector,\n\t\t\t(short)databaseBuffer.Length,\n\t\t\tdatabaseBuffer,\n\t\t\tref _handle,\n\t\t\tdpb.Length,\n\t\t\tdpb.ToArray(),\n\t\t\t0);\n\n\t\tProcessStatusVector(Charset.DefaultCharset);\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override void CreateDatabaseWithTrustedAuth(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey)\n\t{\n\t\tthrow new NotSupportedException(\"Trusted Auth isn't supported on Firebird Embedded.\");\n\t}\n\tpublic override ValueTask CreateDatabaseWithTrustedAuthAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\tthrow new NotSupportedException(\"Trusted Auth isn't supported on Firebird Embedded.\");\n\t}\n\n\tpublic override void DropDatabase()\n\t{\n\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\t_fbClient.isc_drop_database(_statusVector, ref _handle);\n\n\t\tProcessStatusVector();\n\n\t\t_handle.Dispose();\n\t}\n\tpublic override ValueTask DropDatabaseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\t_fbClient.isc_drop_database(_statusVector, ref _handle);\n\n\t\tProcessStatusVector();\n\n\t\t_handle.Dispose();\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\t#endregion\n\n\t#region Remote Events Methods\n\n\tpublic override void CloseEventManager()\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\tpublic override ValueTask CloseEventManagerAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\n\tpublic override void QueueEvents(RemoteEvent events)\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\tpublic override ValueTask QueueEventsAsync(RemoteEvent events, CancellationToken cancellationToken = default)\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\n\tpublic override void CancelEvents(RemoteEvent events)\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\tpublic override ValueTask CancelEventsAsync(RemoteEvent events, CancellationToken cancellationToken = default)\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic override void Attach(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey)\n\t{\n\t\tCheckCryptKeyForSupport(cryptKey);\n\n\t\tvar databaseBuffer = dpb.Encoding.GetBytes(database);\n\n\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\t_fbClient.isc_attach_database(\n\t\t\t_statusVector,\n\t\t\t(short)databaseBuffer.Length,\n\t\t\tdatabaseBuffer,\n\t\t\tref _handle,\n\t\t\tdpb.Length,\n\t\t\tdpb.ToArray());\n\n\t\tProcessStatusVector(Charset.DefaultCharset);\n\n\t\tServerVersion = GetServerVersion();\n\t}\n\tpublic override async ValueTask AttachAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\tCheckCryptKeyForSupport(cryptKey);\n\n\t\tvar databaseBuffer = dpb.Encoding.GetBytes(database);\n\n\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\t_fbClient.isc_attach_database(\n\t\t\t_statusVector,\n\t\t\t(short)databaseBuffer.Length,\n\t\t\tdatabaseBuffer,\n\t\t\tref _handle,\n\t\t\tdpb.Length,\n\t\t\tdpb.ToArray());\n\n\t\tProcessStatusVector(Charset.DefaultCharset);\n\n\t\tServerVersion = await GetServerVersionAsync(cancellationToken).ConfigureAwait(false);\n\t}\n\n\tpublic override void AttachWithTrustedAuth(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey)\n\t{\n\t\tthrow new NotSupportedException(\"Trusted Auth isn't supported on Firebird Embedded.\");\n\t}\n\tpublic override ValueTask AttachWithTrustedAuthAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\tthrow new NotSupportedException(\"Trusted Auth isn't supported on Firebird Embedded.\");\n\t}\n\n\tpublic override void Detach()\n\t{\n\t\tif (TransactionCount > 0)\n\t\t{\n\t\t\tthrow IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount);\n\t\t}\n\n\t\tif (!_handle.IsInvalid)\n\t\t{\n\t\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\t\t_fbClient.isc_detach_database(_statusVector, ref _handle);\n\n\t\t\tProcessStatusVector();\n\n\t\t\t_handle.Dispose();\n\t\t}\n\n\t\tWarningMessage = null;\n\t\tServerVersion = null;\n\t\t_statusVector = null;\n\t\tTransactionCount = 0;\n\t}\n\tpublic override ValueTask DetachAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (TransactionCount > 0)\n\t\t{\n\t\t\tthrow IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount);\n\t\t}\n\n\t\tif (!_handle.IsInvalid)\n\t\t{\n\t\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\t\t_fbClient.isc_detach_database(_statusVector, ref _handle);\n\n\t\t\tProcessStatusVector();\n\n\t\t\t_handle.Dispose();\n\t\t}\n\n\t\tWarningMessage = null;\n\t\tServerVersion = null;\n\t\t_statusVector = null;\n\t\tTransactionCount = 0;\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\t#endregion\n\n\t#region Transaction Methods\n\n\tpublic override TransactionBase BeginTransaction(TransactionParameterBuffer tpb)\n\t{\n\t\tvar transaction = new FesTransaction(this);\n\t\ttransaction.BeginTransaction(tpb);\n\t\treturn transaction;\n\t}\n\tpublic override async ValueTask<TransactionBase> BeginTransactionAsync(TransactionParameterBuffer tpb, CancellationToken cancellationToken = default)\n\t{\n\t\tvar transaction = new FesTransaction(this);\n\t\tawait transaction.BeginTransactionAsync(tpb, cancellationToken).ConfigureAwait(false);\n\t\treturn transaction;\n\t}\n\n\t#endregion\n\n\t#region Cancel Methods\n\n\tpublic override void CancelOperation(short kind)\n\t{\n\t\tvar localStatusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH];\n\n\t\t_fbClient.fb_cancel_operation(localStatusVector, ref _handle, (ushort)kind);\n\n\t\ttry\n\t\t{\n\t\t\tProcessStatusVector(localStatusVector);\n\t\t}\n\t\tcatch (IscException ex) when (ex.ErrorCode == IscCodes.isc_nothing_to_cancel)\n\t\t{ }\n\t}\n\tpublic override ValueTask CancelOperationAsync(short kind, CancellationToken cancellationToken = default)\n\t{\n\t\tvar localStatusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH];\n\n\t\t_fbClient.fb_cancel_operation(localStatusVector, ref _handle, (ushort)kind);\n\n\t\ttry\n\t\t{\n\t\t\tProcessStatusVector(localStatusVector);\n\t\t}\n\t\tcatch (IscException ex) when (ex.ErrorCode == IscCodes.isc_nothing_to_cancel)\n\t\t{ }\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\t#endregion\n\n\t#region Statement Creation Methods\n\n\tpublic override StatementBase CreateStatement()\n\t{\n\t\treturn new FesStatement(this);\n\t}\n\n\tpublic override StatementBase CreateStatement(TransactionBase transaction)\n\t{\n\t\treturn new FesStatement(this, transaction as FesTransaction);\n\t}\n\n\t#endregion\n\n\t#region Parameter Buffers\n\n\tpublic override DatabaseParameterBufferBase CreateDatabaseParameterBuffer()\n\t{\n\t\treturn new DatabaseParameterBuffer1(ParameterBufferEncoding);\n\t}\n\n\tpublic override EventParameterBuffer CreateEventParameterBuffer()\n\t{\n\t\treturn new EventParameterBuffer(Charset.Encoding);\n\t}\n\n\tpublic override TransactionParameterBuffer CreateTransactionParameterBuffer()\n\t{\n\t\treturn new TransactionParameterBuffer(Charset.Encoding);\n\t}\n\n\t#endregion\n\n\t#region Database Information Methods\n\n\tpublic override List<object> GetDatabaseInfo(byte[] items)\n\t{\n\t\treturn GetDatabaseInfo(items, IscCodes.DEFAULT_MAX_BUFFER_SIZE);\n\t}\n\tpublic override ValueTask<List<object>> GetDatabaseInfoAsync(byte[] items, CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetDatabaseInfoAsync(items, IscCodes.DEFAULT_MAX_BUFFER_SIZE, cancellationToken);\n\t}\n\n\tpublic override List<object> GetDatabaseInfo(byte[] items, int bufferLength)\n\t{\n\t\tvar buffer = new byte[bufferLength];\n\n\t\tDatabaseInfo(items, buffer, buffer.Length);\n\n\t\treturn IscHelper.ParseDatabaseInfo(buffer, Charset);\n\t}\n\tpublic override ValueTask<List<object>> GetDatabaseInfoAsync(byte[] items, int bufferLength, CancellationToken cancellationToken = default)\n\t{\n\t\tvar buffer = new byte[bufferLength];\n\n\t\tDatabaseInfo(items, buffer, buffer.Length);\n\n\t\treturn ValueTask.FromResult(IscHelper.ParseDatabaseInfo(buffer, Charset));\n\t}\n\n\t#endregion\n\n\t#region Internal Methods\n\n\tinternal void ProcessStatusVector(IntPtr[] statusVector)\n\t{\n\t\tStatusVectorHelper.ProcessStatusVector(statusVector, Charset, WarningMessage);\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void DatabaseInfo(byte[] items, byte[] buffer, int bufferLength)\n\t{\n\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\t_fbClient.isc_database_info(\n\t\t\t_statusVector,\n\t\t\tref _handle,\n\t\t\t(short)items.Length,\n\t\t\titems,\n\t\t\t(short)bufferLength,\n\t\t\tbuffer);\n\n\t\tProcessStatusVector();\n\t}\n\n\tprivate void ProcessStatusVector()\n\t{\n\t\tStatusVectorHelper.ProcessStatusVector(_statusVector, Charset, WarningMessage);\n\t}\n\n\tprivate void ProcessStatusVector(Charset charset)\n\t{\n\t\tStatusVectorHelper.ProcessStatusVector(_statusVector, charset, WarningMessage);\n\t}\n\n\t#endregion\n\n\t#region Internal Static Methods\n\n\tinternal static void CheckCryptKeyForSupport(byte[] cryptKey)\n\t{\n\t\t// ICryptKeyCallbackImpl would have to be passed from C# for 'cryptKey' passing\n\t\tif (cryptKey?.Length > 0)\n\t\t\tthrow new NotSupportedException(\"Passing Encryption Key isn't, yet, supported on Firebird Embedded.\");\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/FesServiceManager.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Native;\n\ninternal sealed class FesServiceManager : ServiceManagerBase\n{\n\t#region Fields\n\n\tprivate static readonly Version Version30 = new Version(3, 0);\n\n\tprivate readonly IFbClient _fbClient;\n\tprivate readonly Version _fbClientVersion;\n\tprivate IntPtr[] _statusVector;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic override bool UseUtf8ParameterBuffer => _fbClientVersion >= Version30;\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FesServiceManager(string dllName, Charset charset)\n\t\t: base(charset)\n\t{\n\t\t_fbClient = FbClientFactory.Create(dllName);\n\t\t_fbClientVersion = FesConnection.GetClientVersion(_fbClient);\n\t\t_statusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH];\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic override void Attach(ServiceParameterBufferBase spb, string dataSource, int port, string service, byte[] cryptKey)\n\t{\n\t\tFesDatabase.CheckCryptKeyForSupport(cryptKey);\n\n\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\tvar svcHandle = Handle;\n\n\t\t_fbClient.isc_service_attach(\n\t\t\t_statusVector,\n\t\t\t(short)service.Length,\n\t\t\tservice,\n\t\t\tref svcHandle,\n\t\t\tspb.Length,\n\t\t\tspb.ToArray());\n\n\t\tProcessStatusVector(Charset.DefaultCharset);\n\n\t\tHandle = svcHandle;\n\t}\n\tpublic override ValueTask AttachAsync(ServiceParameterBufferBase spb, string dataSource, int port, string service, byte[] cryptKey, CancellationToken cancellationToken = default)\n\t{\n\t\tFesDatabase.CheckCryptKeyForSupport(cryptKey);\n\n\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\tvar svcHandle = Handle;\n\n\t\t_fbClient.isc_service_attach(\n\t\t\t_statusVector,\n\t\t\t(short)service.Length,\n\t\t\tservice,\n\t\t\tref svcHandle,\n\t\t\tspb.Length,\n\t\t\tspb.ToArray());\n\n\t\tProcessStatusVector(Charset.DefaultCharset);\n\n\t\tHandle = svcHandle;\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override void Detach()\n\t{\n\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\tvar svcHandle = Handle;\n\n\t\t_fbClient.isc_service_detach(_statusVector, ref svcHandle);\n\n\t\tProcessStatusVector();\n\n\t\tHandle = svcHandle;\n\t}\n\tpublic override ValueTask DetachAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\tvar svcHandle = Handle;\n\n\t\t_fbClient.isc_service_detach(_statusVector, ref svcHandle);\n\n\t\tProcessStatusVector();\n\n\t\tHandle = svcHandle;\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override void Start(ServiceParameterBufferBase spb)\n\t{\n\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\tvar svcHandle = Handle;\n\t\tvar reserved = 0;\n\n\t\t_fbClient.isc_service_start(\n\t\t\t_statusVector,\n\t\t\tref svcHandle,\n\t\t\tref reserved,\n\t\t\tspb.Length,\n\t\t\tspb.ToArray());\n\n\t\tProcessStatusVector();\n\t}\n\tpublic override ValueTask StartAsync(ServiceParameterBufferBase spb, CancellationToken cancellationToken = default)\n\t{\n\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\tvar svcHandle = Handle;\n\t\tvar reserved = 0;\n\n\t\t_fbClient.isc_service_start(\n\t\t\t_statusVector,\n\t\t\tref svcHandle,\n\t\t\tref reserved,\n\t\t\tspb.Length,\n\t\t\tspb.ToArray());\n\n\t\tProcessStatusVector();\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override void Query(ServiceParameterBufferBase spb, int requestLength, byte[] requestBuffer, int bufferLength, byte[] buffer)\n\t{\n\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\tvar svcHandle = Handle;\n\t\tvar reserved = 0;\n\n\t\t_fbClient.isc_service_query(\n\t\t\t_statusVector,\n\t\t\tref svcHandle,\n\t\t\tref reserved,\n\t\t\tspb.Length,\n\t\t\tspb.ToArray(),\n\t\t\t(short)requestLength,\n\t\t\trequestBuffer,\n\t\t\t(short)buffer.Length,\n\t\t\tbuffer);\n\n\t\tProcessStatusVector();\n\t}\n\tpublic override ValueTask QueryAsync(ServiceParameterBufferBase spb, int requestLength, byte[] requestBuffer, int bufferLength, byte[] buffer, CancellationToken cancellationToken = default)\n\t{\n\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\tvar svcHandle = Handle;\n\t\tvar reserved = 0;\n\n\t\t_fbClient.isc_service_query(\n\t\t\t_statusVector,\n\t\t\tref svcHandle,\n\t\t\tref reserved,\n\t\t\tspb.Length,\n\t\t\tspb.ToArray(),\n\t\t\t(short)requestLength,\n\t\t\trequestBuffer,\n\t\t\t(short)buffer.Length,\n\t\t\tbuffer);\n\n\t\tProcessStatusVector();\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override ServiceParameterBufferBase CreateServiceParameterBuffer()\n\t{\n\t\treturn new ServiceParameterBuffer2(ParameterBufferEncoding);\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void ProcessStatusVector()\n\t{\n\t\tStatusVectorHelper.ProcessStatusVector(_statusVector, Charset, WarningMessage);\n\t}\n\n\tprivate void ProcessStatusVector(Charset charset)\n\t{\n\t\tStatusVectorHelper.ProcessStatusVector(_statusVector, charset, WarningMessage);\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/FesStatement.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Client.Native.Handles;\nusing FirebirdSql.Data.Client.Native.Marshalers;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Native;\n\ninternal sealed class FesStatement : StatementBase\n{\n\t#region Fields\n\n\tprivate StatementHandle _handle;\n\tprivate bool _disposed;\n\tprivate FesDatabase _database;\n\tprivate FesTransaction _transaction;\n\tprivate Descriptor _parameters;\n\tprivate Descriptor _fields;\n\tprivate bool _allRowsFetched;\n\tprivate IntPtr[] _statusVector;\n\tprivate IntPtr _fetchSqlDa;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic override DatabaseBase Database\n\t{\n\t\tget { return _database; }\n\t}\n\n\tpublic override TransactionBase Transaction\n\t{\n\t\tget { return _transaction; }\n\t\tset\n\t\t{\n\t\t\tif (_transaction != value)\n\t\t\t{\n\t\t\t\tif (TransactionUpdate != null && _transaction != null)\n\t\t\t\t{\n\t\t\t\t\t_transaction.Update -= TransactionUpdate;\n\t\t\t\t\tTransactionUpdate = null;\n\t\t\t\t}\n\n\t\t\t\tif (value == null)\n\t\t\t\t{\n\t\t\t\t\t_transaction = null;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t_transaction = (FesTransaction)value;\n\t\t\t\t\tTransactionUpdate = new EventHandler(TransactionUpdated);\n\t\t\t\t\t_transaction.Update += TransactionUpdate;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override Descriptor Parameters\n\t{\n\t\tget { return _parameters; }\n\t\tset { _parameters = value; }\n\t}\n\n\tpublic override Descriptor Fields\n\t{\n\t\tget { return _fields; }\n\t}\n\n\tpublic override int FetchSize\n\t{\n\t\tget { return 200; }\n\t\tset { }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FesStatement(FesDatabase database)\n\t\t: this(database, null)\n\t{\n\t}\n\n\tpublic FesStatement(FesDatabase database, FesTransaction transaction)\n\t{\n\t\t_database = database;\n\t\t_handle = new StatementHandle();\n\t\tOutputParameters = new Queue<DbValue[]>();\n\t\t_statusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH];\n\t\t_fetchSqlDa = IntPtr.Zero;\n\n\t\tif (transaction != null)\n\t\t{\n\t\t\tTransaction = transaction;\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Dispose2\n\n\tpublic override void Dispose2()\n\t{\n\t\tif (!_disposed)\n\t\t{\n\t\t\t_disposed = true;\n\t\t\tRelease();\n\t\t\tClear();\n\t\t\t_database = null;\n\t\t\t_fields = null;\n\t\t\t_parameters = null;\n\t\t\t_transaction = null;\n\t\t\tOutputParameters = null;\n\t\t\t_statusVector = null;\n\t\t\t_allRowsFetched = false;\n\t\t\t_handle.Dispose();\n\t\t\tFetchSize = 0;\n\t\t\tbase.Dispose2();\n\t\t}\n\t}\n\tpublic override async ValueTask Dispose2Async(CancellationToken cancellationToken = default)\n\t{\n\t\tif (!_disposed)\n\t\t{\n\t\t\t_disposed = true;\n\t\t\tawait ReleaseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tClear();\n\t\t\t_database = null;\n\t\t\t_fields = null;\n\t\t\t_parameters = null;\n\t\t\t_transaction = null;\n\t\t\tOutputParameters = null;\n\t\t\t_statusVector = null;\n\t\t\t_allRowsFetched = false;\n\t\t\t_handle.Dispose();\n\t\t\tFetchSize = 0;\n\t\t\tawait base.Dispose2Async(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Blob Creation Metods\n\n\tpublic override BlobBase CreateBlob()\n\t{\n\t\treturn new FesBlob(_database, _transaction);\n\t}\n\n\tpublic override BlobBase CreateBlob(long blobId)\n\t{\n\t\treturn new FesBlob(_database, _transaction, blobId);\n\t}\n\n\t#endregion\n\n\t#region Array Creation Methods\n\n\tpublic override ArrayBase CreateArray(ArrayDesc descriptor)\n\t{\n\t\tvar array = new FesArray(descriptor);\n\t\treturn array;\n\t}\n\tpublic override ValueTask<ArrayBase> CreateArrayAsync(ArrayDesc descriptor, CancellationToken cancellationToken = default)\n\t{\n\t\tvar array = new FesArray(descriptor);\n\t\treturn ValueTask.FromResult<ArrayBase>(array);\n\t}\n\n\tpublic override ArrayBase CreateArray(string tableName, string fieldName)\n\t{\n\t\tvar array = new FesArray(_database, _transaction, tableName, fieldName);\n\t\tarray.Initialize();\n\t\treturn array;\n\t}\n\tpublic override async ValueTask<ArrayBase> CreateArrayAsync(string tableName, string fieldName, CancellationToken cancellationToken = default)\n\t{\n\t\tvar array = new FesArray(_database, _transaction, tableName, fieldName);\n\t\tawait array.InitializeAsync(cancellationToken).ConfigureAwait(false);\n\t\treturn array;\n\t}\n\n\tpublic override ArrayBase CreateArray(long handle, string tableName, string fieldName)\n\t{\n\t\tvar array = new FesArray(_database, _transaction, handle, tableName, fieldName);\n\t\tarray.Initialize();\n\t\treturn array;\n\t}\n\tpublic override async ValueTask<ArrayBase> CreateArrayAsync(long handle, string tableName, string fieldName, CancellationToken cancellationToken = default)\n\t{\n\t\tvar array = new FesArray(_database, _transaction, handle, tableName, fieldName);\n\t\tawait array.InitializeAsync(cancellationToken).ConfigureAwait(false);\n\t\treturn array;\n\t}\n\n\tpublic override BatchBase CreateBatch()\n\t{\n\t\tthrow new NotSupportedException(\"Batching isn't, yet, supported on Firebird Embedded.\");\n\t}\n\n\tpublic override BatchParameterBuffer CreateBatchParameterBuffer()\n\t{\n\t\tthrow new NotSupportedException(\"Batching isn't, yet, supported on Firebird Embedded.\");\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic override void Release()\n\t{\n\t\tXsqldaMarshaler.CleanUpNativeData(ref _fetchSqlDa);\n\n\t\tbase.Release();\n\t}\n\tpublic override ValueTask ReleaseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tXsqldaMarshaler.CleanUpNativeData(ref _fetchSqlDa);\n\n\t\treturn base.ReleaseAsync(cancellationToken);\n\t}\n\n\tpublic override void Close()\n\t{\n\t\tXsqldaMarshaler.CleanUpNativeData(ref _fetchSqlDa);\n\n\t\tbase.Close();\n\t}\n\tpublic override ValueTask CloseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tXsqldaMarshaler.CleanUpNativeData(ref _fetchSqlDa);\n\n\t\treturn base.CloseAsync(cancellationToken);\n\t}\n\n\tpublic override void Prepare(string commandText)\n\t{\n\t\tClearAll();\n\n\t\tClearStatusVector();\n\n\t\tif (State == StatementState.Deallocated)\n\t\t{\n\t\t\tAllocate();\n\t\t}\n\n\t\t_fields = new Descriptor(1);\n\n\t\tvar sqlda = XsqldaMarshaler.MarshalManagedToNative(_database.Charset, _fields);\n\t\tvar trHandle = _transaction.HandlePtr;\n\n\t\tvar buffer = _database.Charset.GetBytes(commandText);\n\n\t\t_database.FbClient.isc_dsql_prepare(\n\t\t\t_statusVector,\n\t\t\tref trHandle,\n\t\t\tref _handle,\n\t\t\t(short)buffer.Length,\n\t\t\tbuffer,\n\t\t\t_database.Dialect,\n\t\t\tsqlda);\n\n\t\tvar descriptor = XsqldaMarshaler.MarshalNativeToManaged(_database.Charset, sqlda);\n\n\t\tXsqldaMarshaler.CleanUpNativeData(ref sqlda);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\t_fields = descriptor;\n\n\t\tif (_fields.ActualCount > 0 && _fields.ActualCount != _fields.Count)\n\t\t{\n\t\t\tDescribe();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (_fields.ActualCount == 0)\n\t\t\t{\n\t\t\t\t_fields = new Descriptor(0);\n\t\t\t}\n\t\t}\n\n\t\t_fields.ResetValues();\n\n\t\tDescribeParameters();\n\n\t\tStatementType = GetStatementType();\n\n\t\tState = StatementState.Prepared;\n\t}\n\tpublic override async ValueTask PrepareAsync(string commandText, CancellationToken cancellationToken = default)\n\t{\n\t\tClearAll();\n\n\t\tClearStatusVector();\n\n\t\tif (State == StatementState.Deallocated)\n\t\t{\n\t\t\tAllocate();\n\t\t}\n\n\t\t_fields = new Descriptor(1);\n\n\t\tvar sqlda = XsqldaMarshaler.MarshalManagedToNative(_database.Charset, _fields);\n\t\tvar trHandle = _transaction.HandlePtr;\n\n\t\tvar buffer = _database.Charset.GetBytes(commandText);\n\n\t\t_database.FbClient.isc_dsql_prepare(\n\t\t\t_statusVector,\n\t\t\tref trHandle,\n\t\t\tref _handle,\n\t\t\t(short)buffer.Length,\n\t\t\tbuffer,\n\t\t\t_database.Dialect,\n\t\t\tsqlda);\n\n\t\tvar descriptor = XsqldaMarshaler.MarshalNativeToManaged(_database.Charset, sqlda);\n\n\t\tXsqldaMarshaler.CleanUpNativeData(ref sqlda);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\t_fields = descriptor;\n\n\t\tif (_fields.ActualCount > 0 && _fields.ActualCount != _fields.Count)\n\t\t{\n\t\t\tDescribe();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (_fields.ActualCount == 0)\n\t\t\t{\n\t\t\t\t_fields = new Descriptor(0);\n\t\t\t}\n\t\t}\n\n\t\t_fields.ResetValues();\n\n\t\tDescribeParameters();\n\n\t\tStatementType = await GetStatementTypeAsync(cancellationToken).ConfigureAwait(false);\n\n\t\tState = StatementState.Prepared;\n\t}\n\n\tpublic override void Execute(int timeout, IDescriptorFiller descriptorFiller)\n\t{\n\t\tEnsureNotDeallocated();\n\n\t\tdescriptorFiller.Fill(_parameters, 0);\n\n\t\tClearStatusVector();\n\t\tNativeHelpers.CallIfExists(\n\t\t\tnameof(IFbClient.fb_dsql_set_timeout),\n\t\t\t() =>\n\t\t\t{\n\t\t\t\t_database.FbClient.fb_dsql_set_timeout(_statusVector, ref _handle, (uint)timeout);\n\t\t\t\t_database.ProcessStatusVector(_statusVector);\n\t\t\t});\n\n\t\tClearStatusVector();\n\n\t\tvar inSqlda = IntPtr.Zero;\n\t\tvar outSqlda = IntPtr.Zero;\n\n\t\tif (_parameters != null)\n\t\t{\n\t\t\tinSqlda = XsqldaMarshaler.MarshalManagedToNative(_database.Charset, _parameters);\n\t\t}\n\t\tif (StatementType == DbStatementType.StoredProcedure)\n\t\t{\n\t\t\tFields.ResetValues();\n\t\t\toutSqlda = XsqldaMarshaler.MarshalManagedToNative(_database.Charset, _fields);\n\t\t}\n\n\t\tvar trHandle = _transaction.HandlePtr;\n\n\t\t_database.FbClient.isc_dsql_execute2(\n\t\t\t_statusVector,\n\t\t\tref trHandle,\n\t\t\tref _handle,\n\t\t\tIscCodes.SQLDA_VERSION1,\n\t\t\tinSqlda,\n\t\t\toutSqlda);\n\n\t\tif (outSqlda != IntPtr.Zero)\n\t\t{\n\t\t\tvar descriptor = XsqldaMarshaler.MarshalNativeToManaged(_database.Charset, outSqlda, true);\n\n\t\t\tvar values = new DbValue[descriptor.Count];\n\n\t\t\tfor (var i = 0; i < values.Length; i++)\n\t\t\t{\n\t\t\t\tvar d = descriptor[i];\n\t\t\t\tvar value = d.DbValue.GetValue();\n\t\t\t\tvalues[i] = new DbValue(this, d, value);\n\t\t\t}\n\n\t\t\tOutputParameters.Enqueue(values);\n\t\t}\n\n\t\tXsqldaMarshaler.CleanUpNativeData(ref inSqlda);\n\t\tXsqldaMarshaler.CleanUpNativeData(ref outSqlda);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\tif (DoRecordsAffected)\n\t\t{\n\t\t\tRecordsAffected = GetRecordsAffected();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tRecordsAffected = -1;\n\t\t}\n\n\t\tState = StatementState.Executed;\n\t}\n\tpublic override async ValueTask ExecuteAsync(int timeout, IDescriptorFiller descriptorFiller, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureNotDeallocated();\n\n\t\tawait descriptorFiller.FillAsync(_parameters, 0, cancellationToken).ConfigureAwait(false);\n\n\t\tClearStatusVector();\n\t\tNativeHelpers.CallIfExists(\n\t\t\tnameof(IFbClient.fb_dsql_set_timeout),\n\t\t\t() =>\n\t\t\t{\n\t\t\t\t_database.FbClient.fb_dsql_set_timeout(_statusVector, ref _handle, (uint)timeout);\n\t\t\t\t_database.ProcessStatusVector(_statusVector);\n\t\t\t});\n\n\t\tClearStatusVector();\n\n\t\tvar inSqlda = IntPtr.Zero;\n\t\tvar outSqlda = IntPtr.Zero;\n\n\t\tif (_parameters != null)\n\t\t{\n\t\t\tinSqlda = XsqldaMarshaler.MarshalManagedToNative(_database.Charset, _parameters);\n\t\t}\n\t\tif (StatementType == DbStatementType.StoredProcedure)\n\t\t{\n\t\t\tFields.ResetValues();\n\t\t\toutSqlda = XsqldaMarshaler.MarshalManagedToNative(_database.Charset, _fields);\n\t\t}\n\n\t\tvar trHandle = _transaction.HandlePtr;\n\n\t\t_database.FbClient.isc_dsql_execute2(\n\t\t\t_statusVector,\n\t\t\tref trHandle,\n\t\t\tref _handle,\n\t\t\tIscCodes.SQLDA_VERSION1,\n\t\t\tinSqlda,\n\t\t\toutSqlda);\n\n\t\tif (outSqlda != IntPtr.Zero)\n\t\t{\n\t\t\tvar descriptor = XsqldaMarshaler.MarshalNativeToManaged(_database.Charset, outSqlda, true);\n\n\t\t\tvar values = new DbValue[descriptor.Count];\n\n\t\t\tfor (var i = 0; i < values.Length; i++)\n\t\t\t{\n\t\t\t\tvar d = descriptor[i];\n\t\t\t\tvar value = await d.DbValue.GetValueAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvalues[i] = new DbValue(this, d, value);\n\t\t\t}\n\n\t\t\tOutputParameters.Enqueue(values);\n\t\t}\n\n\t\tXsqldaMarshaler.CleanUpNativeData(ref inSqlda);\n\t\tXsqldaMarshaler.CleanUpNativeData(ref outSqlda);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\tif (DoRecordsAffected)\n\t\t{\n\t\t\tRecordsAffected = await GetRecordsAffectedAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tRecordsAffected = -1;\n\t\t}\n\n\t\tState = StatementState.Executed;\n\t}\n\n\tpublic override DbValue[] Fetch()\n\t{\n\t\tEnsureNotDeallocated();\n\n\t\tif (StatementType == DbStatementType.StoredProcedure && !_allRowsFetched)\n\t\t{\n\t\t\t_allRowsFetched = true;\n\t\t\treturn GetOutputParameters();\n\t\t}\n\t\telse if (StatementType == DbStatementType.Insert && _allRowsFetched)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\telse if (StatementType != DbStatementType.Select && StatementType != DbStatementType.SelectForUpdate)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\n\t\tif (_allRowsFetched)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\n\t\t_fields.ResetValues();\n\n\t\tif (_fetchSqlDa == IntPtr.Zero)\n\t\t{\n\t\t\t_fetchSqlDa = XsqldaMarshaler.MarshalManagedToNative(_database.Charset, _fields);\n\t\t}\n\n\t\tClearStatusVector();\n\n\t\tvar status = _database.FbClient.isc_dsql_fetch(_statusVector, ref _handle, IscCodes.SQLDA_VERSION1, _fetchSqlDa);\n\t\tif (status == new IntPtr(100))\n\t\t{\n\t\t\t_allRowsFetched = true;\n\n\t\t\tXsqldaMarshaler.CleanUpNativeData(ref _fetchSqlDa);\n\n\t\t\treturn null;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tvar rowDesc = XsqldaMarshaler.MarshalNativeToManaged(_database.Charset, _fetchSqlDa, true);\n\n\t\t\tif (_fields.Count == rowDesc.Count)\n\t\t\t{\n\t\t\t\tfor (var i = 0; i < _fields.Count; i++)\n\t\t\t\t{\n\t\t\t\t\tif (_fields[i].IsArray() && _fields[i].ArrayHandle != null)\n\t\t\t\t\t{\n\t\t\t\t\t\trowDesc[i].ArrayHandle = _fields[i].ArrayHandle;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_fields = rowDesc;\n\n\t\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\t\tvar row = new DbValue[_fields.ActualCount];\n\t\t\tfor (var i = 0; i < row.Length; i++)\n\t\t\t{\n\t\t\t\tvar d = _fields[i];\n\t\t\t\tvar value = d.DbValue.GetValue();\n\t\t\t\trow[i] = new DbValue(this, d, value);\n\t\t\t}\n\t\t\treturn row;\n\t\t}\n\t}\n\tpublic override async ValueTask<DbValue[]> FetchAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureNotDeallocated();\n\n\t\tif (StatementType == DbStatementType.StoredProcedure && !_allRowsFetched)\n\t\t{\n\t\t\t_allRowsFetched = true;\n\t\t\treturn GetOutputParameters();\n\t\t}\n\t\telse if (StatementType == DbStatementType.Insert && _allRowsFetched)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\telse if (StatementType != DbStatementType.Select && StatementType != DbStatementType.SelectForUpdate)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\n\t\tif (_allRowsFetched)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\n\t\t_fields.ResetValues();\n\n\t\tif (_fetchSqlDa == IntPtr.Zero)\n\t\t{\n\t\t\t_fetchSqlDa = XsqldaMarshaler.MarshalManagedToNative(_database.Charset, _fields);\n\t\t}\n\n\t\tClearStatusVector();\n\n\t\tvar status = _database.FbClient.isc_dsql_fetch(_statusVector, ref _handle, IscCodes.SQLDA_VERSION1, _fetchSqlDa);\n\t\tif (status == new IntPtr(100))\n\t\t{\n\t\t\t_allRowsFetched = true;\n\n\t\t\tXsqldaMarshaler.CleanUpNativeData(ref _fetchSqlDa);\n\n\t\t\treturn null;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tvar rowDesc = XsqldaMarshaler.MarshalNativeToManaged(_database.Charset, _fetchSqlDa, true);\n\n\t\t\tif (_fields.Count == rowDesc.Count)\n\t\t\t{\n\t\t\t\tfor (var i = 0; i < _fields.Count; i++)\n\t\t\t\t{\n\t\t\t\t\tif (_fields[i].IsArray() && _fields[i].ArrayHandle != null)\n\t\t\t\t\t{\n\t\t\t\t\t\trowDesc[i].ArrayHandle = _fields[i].ArrayHandle;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_fields = rowDesc;\n\n\t\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\t\tvar row = new DbValue[_fields.ActualCount];\n\t\t\tfor (var i = 0; i < row.Length; i++)\n\t\t\t{\n\t\t\t\tvar d = _fields[i];\n\t\t\t\tvar value = await d.DbValue.GetValueAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\trow[i] = new DbValue(this, d, value);\n\t\t\t}\n\t\t\treturn row;\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Protected Methods\n\n\tprotected override void Free(int option)\n\t{\n\t\t// Does\tnot\tseem to\tbe possible\tor necessary to\tclose\n\t\t// an execute procedure\tstatement.\n\t\tif (StatementType == DbStatementType.StoredProcedure && option == IscCodes.DSQL_close)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tClearStatusVector();\n\n\t\t_database.FbClient.isc_dsql_free_statement(\n\t\t\t_statusVector,\n\t\t\tref _handle,\n\t\t\t(short)option);\n\n\t\tif (option == IscCodes.DSQL_drop)\n\t\t{\n\t\t\t_parameters = null;\n\t\t\t_fields = null;\n\t\t}\n\n\t\tClear();\n\t\t_allRowsFetched = false;\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\t}\n\tprotected override ValueTask FreeAsync(int option, CancellationToken cancellationToken = default)\n\t{\n\t\t// Does\tnot\tseem to\tbe possible\tor necessary to\tclose\n\t\t// an execute procedure\tstatement.\n\t\tif (StatementType == DbStatementType.StoredProcedure && option == IscCodes.DSQL_close)\n\t\t{\n\t\t\treturn ValueTask.CompletedTask;\n\t\t}\n\n\t\tClearStatusVector();\n\n\t\t_database.FbClient.isc_dsql_free_statement(\n\t\t\t_statusVector,\n\t\t\tref _handle,\n\t\t\t(short)option);\n\n\t\tif (option == IscCodes.DSQL_drop)\n\t\t{\n\t\t\t_parameters = null;\n\t\t\t_fields = null;\n\t\t}\n\n\t\tClear();\n\t\t_allRowsFetched = false;\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tprotected override void TransactionUpdated(object sender, EventArgs e)\n\t{\n\t\tif (Transaction != null && TransactionUpdate != null)\n\t\t{\n\t\t\tTransaction.Update -= TransactionUpdate;\n\t\t}\n\t\tClear();\n\t\tState = StatementState.Closed;\n\t\tTransactionUpdate = null;\n\t\t_allRowsFetched = false;\n\t}\n\n\tprotected override byte[] GetSqlInfo(byte[] items, int bufferLength)\n\t{\n\t\tClearStatusVector();\n\n\t\tvar buffer = new byte[bufferLength];\n\n\t\t_database.FbClient.isc_dsql_sql_info(\n\t\t\t_statusVector,\n\t\t\tref _handle,\n\t\t\t(short)items.Length,\n\t\t\titems,\n\t\t\t(short)bufferLength,\n\t\t\tbuffer);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\treturn buffer;\n\t}\n\tprotected override ValueTask<byte[]> GetSqlInfoAsync(byte[] items, int bufferLength, CancellationToken cancellationToken = default)\n\t{\n\t\tClearStatusVector();\n\n\t\tvar buffer = new byte[bufferLength];\n\n\t\t_database.FbClient.isc_dsql_sql_info(\n\t\t\t_statusVector,\n\t\t\tref _handle,\n\t\t\t(short)items.Length,\n\t\t\titems,\n\t\t\t(short)bufferLength,\n\t\t\tbuffer);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\treturn ValueTask.FromResult(buffer);\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void ClearStatusVector()\n\t{\n\t\tArray.Clear(_statusVector, 0, _statusVector.Length);\n\t}\n\n\tprivate void Clear()\n\t{\n\t\tOutputParameters?.Clear();\n\t}\n\n\tprivate void ClearAll()\n\t{\n\t\tClear();\n\n\t\t_parameters = null;\n\t\t_fields = null;\n\t}\n\n\tprivate void Allocate()\n\t{\n\t\tClearStatusVector();\n\n\t\tvar dbHandle = _database.HandlePtr;\n\n\t\t_database.FbClient.isc_dsql_allocate_statement(\n\t\t\t_statusVector,\n\t\t\tref dbHandle,\n\t\t\tref _handle);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\t_allRowsFetched = false;\n\t\tState = StatementState.Allocated;\n\t\tStatementType = DbStatementType.None;\n\t}\n\n\tprivate void Describe()\n\t{\n\t\tClearStatusVector();\n\n\t\t_fields = new Descriptor(_fields.ActualCount);\n\n\t\tvar sqlda = XsqldaMarshaler.MarshalManagedToNative(_database.Charset, _fields);\n\n\t\t_database.FbClient.isc_dsql_describe(\n\t\t\t_statusVector,\n\t\t\tref _handle,\n\t\t\tIscCodes.SQLDA_VERSION1,\n\t\t\tsqlda);\n\n\t\tvar descriptor = XsqldaMarshaler.MarshalNativeToManaged(_database.Charset, sqlda);\n\n\t\tXsqldaMarshaler.CleanUpNativeData(ref sqlda);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\t_fields = descriptor;\n\t}\n\n\tprivate void DescribeParameters()\n\t{\n\t\tClearStatusVector();\n\n\t\t_parameters = new Descriptor(1);\n\n\t\tvar sqlda = XsqldaMarshaler.MarshalManagedToNative(_database.Charset, _parameters);\n\n\n\t\t_database.FbClient.isc_dsql_describe_bind(\n\t\t\t_statusVector,\n\t\t\tref _handle,\n\t\t\tIscCodes.SQLDA_VERSION1,\n\t\t\tsqlda);\n\n\t\tvar descriptor = XsqldaMarshaler.MarshalNativeToManaged(_database.Charset, sqlda);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\tif (descriptor.ActualCount != 0 && descriptor.Count != descriptor.ActualCount)\n\t\t{\n\t\t\tvar n = descriptor.ActualCount;\n\t\t\tdescriptor = new Descriptor(n);\n\n\t\t\tXsqldaMarshaler.CleanUpNativeData(ref sqlda);\n\n\t\t\tsqlda = XsqldaMarshaler.MarshalManagedToNative(_database.Charset, descriptor);\n\n\t\t\t_database.FbClient.isc_dsql_describe_bind(\n\t\t\t\t_statusVector,\n\t\t\t\tref _handle,\n\t\t\t\tIscCodes.SQLDA_VERSION1,\n\t\t\t\tsqlda);\n\n\t\t\tdescriptor = XsqldaMarshaler.MarshalNativeToManaged(_database.Charset, sqlda);\n\n\t\t\tXsqldaMarshaler.CleanUpNativeData(ref sqlda);\n\n\t\t\t_database.ProcessStatusVector(_statusVector);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (descriptor.ActualCount == 0)\n\t\t\t{\n\t\t\t\tdescriptor = new Descriptor(0);\n\t\t\t}\n\t\t}\n\n\t\tif (sqlda != IntPtr.Zero)\n\t\t{\n\t\t\tXsqldaMarshaler.CleanUpNativeData(ref sqlda);\n\t\t}\n\n\t\t_parameters = descriptor;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/FesTransaction.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.IO;\nusing System.Data;\nusing System.Runtime.InteropServices;\n\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.Client.Native.Handles;\nusing System.Threading.Tasks;\nusing System.Threading;\nusing System.Net;\nusing System.Collections.Generic;\n\nnamespace FirebirdSql.Data.Client.Native;\n\ninternal sealed class FesTransaction : TransactionBase\n{\n\t#region Inner Structs\n\n\t[StructLayout(LayoutKind.Sequential)]\n\tstruct IscTeb\n\t{\n\t\tpublic IntPtr dbb_ptr;\n\t\tpublic int tpb_len;\n\t\tpublic IntPtr tpb_ptr;\n\t}\n\n\t#endregion\n\n\t#region Fields\n\n\tprivate TransactionHandle _handle;\n\tprivate FesDatabase _database;\n\tprivate bool _disposed;\n\tprivate IntPtr[] _statusVector;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic override int Handle\n\t{\n\t\tget { return _handle.DangerousGetHandle().AsInt(); }\n\t}\n\n\tpublic TransactionHandle HandlePtr\n\t{\n\t\tget { return _handle; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FesTransaction(FesDatabase database)\n\t{\n\t\t_database = database;\n\t\t_handle = new TransactionHandle();\n\t\tState = TransactionState.NoTransaction;\n\t\t_statusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH];\n\t}\n\n\t#endregion\n\n\t#region Dispose2\n\n\tpublic override void Dispose2()\n\t{\n\t\tif (!_disposed)\n\t\t{\n\t\t\t_disposed = true;\n\t\t\tif (State != TransactionState.NoTransaction)\n\t\t\t{\n\t\t\t\tRollback();\n\t\t\t}\n\t\t\t_database = null;\n\t\t\t_handle.Dispose();\n\t\t\tState = TransactionState.NoTransaction;\n\t\t\t_statusVector = null;\n\t\t\tbase.Dispose2();\n\t\t}\n\t}\n\tpublic override async ValueTask Dispose2Async(CancellationToken cancellationToken = default)\n\t{\n\t\tif (!_disposed)\n\t\t{\n\t\t\t_disposed = true;\n\t\t\tif (State != TransactionState.NoTransaction)\n\t\t\t{\n\t\t\t\tawait RollbackAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\t_database = null;\n\t\t\t_handle.Dispose();\n\t\t\tState = TransactionState.NoTransaction;\n\t\t\t_statusVector = null;\n\t\t\tawait base.Dispose2Async(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic override void BeginTransaction(TransactionParameterBuffer tpb)\n\t{\n\t\tif (State != TransactionState.NoTransaction)\n\t\t{\n\t\t\tthrow new InvalidOperationException();\n\t\t}\n\n\t\tvar teb = new IscTeb();\n\t\tvar tebData = IntPtr.Zero;\n\n\t\ttry\n\t\t{\n\t\t\tClearStatusVector();\n\n\t\t\tteb.dbb_ptr = Marshal.AllocHGlobal(4);\n\t\t\tMarshal.WriteInt32(teb.dbb_ptr, _database.Handle);\n\n\t\t\tteb.tpb_len = tpb.Length;\n\n\t\t\tteb.tpb_ptr = Marshal.AllocHGlobal(tpb.Length);\n\t\t\tMarshal.Copy(tpb.ToArray(), 0, teb.tpb_ptr, tpb.Length);\n\n\t\t\tvar size = Marshal.SizeOf<IscTeb>();\n\t\t\ttebData = Marshal.AllocHGlobal(size);\n\n\t\t\tMarshal.StructureToPtr(teb, tebData, true);\n\n\t\t\t_database.FbClient.isc_start_multiple(\n\t\t\t\t_statusVector,\n\t\t\t\tref _handle,\n\t\t\t\t1,\n\t\t\t\ttebData);\n\n\t\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\t\tState = TransactionState.Active;\n\n\t\t\t_database.TransactionCount++;\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tif (teb.dbb_ptr != IntPtr.Zero)\n\t\t\t{\n\t\t\t\tMarshal.FreeHGlobal(teb.dbb_ptr);\n\t\t\t}\n\t\t\tif (teb.tpb_ptr != IntPtr.Zero)\n\t\t\t{\n\t\t\t\tMarshal.FreeHGlobal(teb.tpb_ptr);\n\t\t\t}\n\t\t\tif (tebData != IntPtr.Zero)\n\t\t\t{\n\t\t\t\tMarshal.DestroyStructure<IscTeb>(tebData);\n\t\t\t\tMarshal.FreeHGlobal(tebData);\n\t\t\t}\n\t\t}\n\t}\n\tpublic override ValueTask BeginTransactionAsync(TransactionParameterBuffer tpb, CancellationToken cancellationToken = default)\n\t{\n\t\tif (State != TransactionState.NoTransaction)\n\t\t{\n\t\t\tthrow new InvalidOperationException();\n\t\t}\n\n\t\tvar teb = new IscTeb();\n\t\tvar tebData = IntPtr.Zero;\n\n\t\ttry\n\t\t{\n\t\t\tClearStatusVector();\n\n\t\t\tteb.dbb_ptr = Marshal.AllocHGlobal(4);\n\t\t\tMarshal.WriteInt32(teb.dbb_ptr, _database.Handle);\n\n\t\t\tteb.tpb_len = tpb.Length;\n\n\t\t\tteb.tpb_ptr = Marshal.AllocHGlobal(tpb.Length);\n\t\t\tMarshal.Copy(tpb.ToArray(), 0, teb.tpb_ptr, tpb.Length);\n\n\t\t\tvar size = Marshal.SizeOf<IscTeb>();\n\t\t\ttebData = Marshal.AllocHGlobal(size);\n\n\t\t\tMarshal.StructureToPtr(teb, tebData, true);\n\n\t\t\t_database.FbClient.isc_start_multiple(\n\t\t\t\t_statusVector,\n\t\t\t\tref _handle,\n\t\t\t\t1,\n\t\t\t\ttebData);\n\n\t\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\t\tState = TransactionState.Active;\n\n\t\t\t_database.TransactionCount++;\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tif (teb.dbb_ptr != IntPtr.Zero)\n\t\t\t{\n\t\t\t\tMarshal.FreeHGlobal(teb.dbb_ptr);\n\t\t\t}\n\t\t\tif (teb.tpb_ptr != IntPtr.Zero)\n\t\t\t{\n\t\t\t\tMarshal.FreeHGlobal(teb.tpb_ptr);\n\t\t\t}\n\t\t\tif (tebData != IntPtr.Zero)\n\t\t\t{\n\t\t\t\tMarshal.DestroyStructure<IscTeb>(tebData);\n\t\t\t\tMarshal.FreeHGlobal(tebData);\n\t\t\t}\n\t\t}\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override void Commit()\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\tClearStatusVector();\n\n\t\t_database.FbClient.isc_commit_transaction(_statusVector, ref _handle);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\t_database.TransactionCount--;\n\n\t\tOnUpdate(EventArgs.Empty);\n\n\t\tState = TransactionState.NoTransaction;\n\t}\n\tpublic override ValueTask CommitAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\tClearStatusVector();\n\n\t\t_database.FbClient.isc_commit_transaction(_statusVector, ref _handle);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\t_database.TransactionCount--;\n\n\t\tOnUpdate(EventArgs.Empty);\n\n\t\tState = TransactionState.NoTransaction;\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override void Rollback()\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\tClearStatusVector();\n\n\t\t_database.FbClient.isc_rollback_transaction(_statusVector, ref _handle);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\t_database.TransactionCount--;\n\n\t\tOnUpdate(EventArgs.Empty);\n\n\t\tState = TransactionState.NoTransaction;\n\t}\n\tpublic override ValueTask RollbackAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\tClearStatusVector();\n\n\t\t_database.FbClient.isc_rollback_transaction(_statusVector, ref _handle);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\t_database.TransactionCount--;\n\n\t\tOnUpdate(EventArgs.Empty);\n\n\t\tState = TransactionState.NoTransaction;\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override void CommitRetaining()\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\tClearStatusVector();\n\n\t\t_database.FbClient.isc_commit_retaining(_statusVector, ref _handle);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\tState = TransactionState.Active;\n\t}\n\tpublic override ValueTask CommitRetainingAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\tClearStatusVector();\n\n\t\t_database.FbClient.isc_commit_retaining(_statusVector, ref _handle);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\tState = TransactionState.Active;\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override void RollbackRetaining()\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\tClearStatusVector();\n\n\t\t_database.FbClient.isc_rollback_retaining(_statusVector, ref _handle);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\tState = TransactionState.Active;\n\t}\n\tpublic override ValueTask RollbackRetainingAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureActiveTransactionState();\n\n\t\tClearStatusVector();\n\n\t\t_database.FbClient.isc_rollback_retaining(_statusVector, ref _handle);\n\n\t\t_database.ProcessStatusVector(_statusVector);\n\n\t\tState = TransactionState.Active;\n\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override void Prepare()\n\t{ }\n\tpublic override ValueTask PrepareAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override void Prepare(byte[] buffer)\n\t{ }\n\tpublic override ValueTask PrepareAsync(byte[] buffer, CancellationToken cancellationToken = default)\n\t{\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tpublic override List<object> GetTransactionInfo(byte[] items)\n\t{\n\t\treturn GetTransactionInfo(items, IscCodes.DEFAULT_MAX_BUFFER_SIZE);\n\t}\n\tpublic override ValueTask<List<object>> GetTransactionInfoAsync(byte[] items, CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetTransactionInfoAsync(items, IscCodes.DEFAULT_MAX_BUFFER_SIZE, cancellationToken);\n\t}\n\n\tpublic override List<object> GetTransactionInfo(byte[] items, int bufferLength)\n\t{\n\t\tvar buffer = new byte[bufferLength];\n\n\t\tTransactionInfo(items, buffer, buffer.Length);\n\n\t\treturn IscHelper.ParseTransactionInfo(buffer, _database.Charset);\n\t}\n\tpublic override ValueTask<List<object>> GetTransactionInfoAsync(byte[] items, int bufferLength, CancellationToken cancellationToken = default)\n\t{\n\t\tvar buffer = new byte[bufferLength];\n\n\t\tTransactionInfo(items, buffer, buffer.Length);\n\n\t\treturn ValueTask.FromResult(IscHelper.ParseTransactionInfo(buffer, _database.Charset));\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void TransactionInfo(byte[] items, byte[] buffer, int bufferLength)\n\t{\n\t\tStatusVectorHelper.ClearStatusVector(_statusVector);\n\n\t\t_database.FbClient.isc_transaction_info(\n\t\t\t_statusVector,\n\t\t\tref _handle,\n\t\t\t(short)items.Length,\n\t\t\titems,\n\t\t\t(short)bufferLength,\n\t\t\tbuffer);\n\n\t\tProcessStatusVector();\n\t}\n\n\tprivate void ClearStatusVector()\n\t{\n\t\tArray.Clear(_statusVector, 0, _statusVector.Length);\n\t}\n\n\tprivate void ProcessStatusVector()\n\t{\n\t\tStatusVectorHelper.ProcessStatusVector(_statusVector, _database.Charset, _database.WarningMessage);\n\t}\n\n\tprivate void ProcessStatusVector(Charset charset)\n\t{\n\t\tStatusVectorHelper.ProcessStatusVector(_statusVector, charset, _database.WarningMessage);\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/Handles/BlobHandle.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Hennadii Zabula, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Diagnostics.Contracts;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Native.Handles;\n\n// public visibility added, because auto-generated assembly can't work with internal types\npublic class BlobHandle : FirebirdHandle\n{\n\tprotected override bool ReleaseHandle()\n\t{\n\t\tContract.Requires(FbClient != null);\n\n\t\tif (IsClosed)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\n\t\tvar statusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH];\n\t\tvar @ref = this;\n\t\tFbClient.isc_close_blob(statusVector, ref @ref);\n\t\thandle = @ref.handle;\n\t\tvar exception = StatusVectorHelper.ParseStatusVector(statusVector, Charset.DefaultCharset);\n\t\treturn exception == null || exception.IsWarning;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/Handles/DatabaseHandle.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Hennadii Zabula, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Diagnostics.Contracts;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Native.Handles;\n\n// public visibility added, because auto-generated assembly can't work with internal types\npublic class DatabaseHandle : FirebirdHandle\n{\n\tprotected override bool ReleaseHandle()\n\t{\n\t\tContract.Requires(FbClient != null);\n\n\t\tif (IsClosed)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\n\t\tvar statusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH];\n\t\tvar @ref = this;\n\t\tFbClient.isc_detach_database(statusVector, ref @ref);\n\t\thandle = @ref.handle;\n\t\tvar exception = StatusVectorHelper.ParseStatusVector(statusVector, Charset.DefaultCharset);\n\t\treturn exception == null || exception.IsWarning;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/Handles/FirebirdHandle.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Hennadii Zabula\n\nusing System;\nusing System.Diagnostics.Contracts;\nusing System.Runtime.InteropServices;\n\nnamespace FirebirdSql.Data.Client.Native.Handles;\n\n// public visibility added, because auto-generated assembly can't work with internal types\npublic abstract class FirebirdHandle : SafeHandle, IFirebirdHandle\n{\n\tprivate IFbClient _fbClient;\n\n\tprotected FirebirdHandle()\n\t\t: base(IntPtr.Zero, true)\n\t{ }\n\n\t// Method added because we can't inject IFbClient in ctor\n\tpublic void SetClient(IFbClient fbClient)\n\t{\n\t\tContract.Requires(_fbClient == null);\n\t\tContract.Requires(fbClient != null);\n\t\tContract.Ensures(_fbClient != null);\n\n\t\t_fbClient = fbClient;\n\t}\n\n\tpublic IFbClient FbClient => _fbClient;\n\n\tpublic override bool IsInvalid => handle == IntPtr.Zero;\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/Handles/IFirebirdHandle.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Hennadii Zabula\n\nusing System;\n\nnamespace FirebirdSql.Data.Client.Native.Handles;\n\n// public visibility added, because auto-generated assembly can't work with internal types\npublic interface IFirebirdHandle\n{\n\tvoid SetClient(IFbClient fbClient);\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/Handles/StatementHandle.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Hennadii Zabula, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Diagnostics.Contracts;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Native.Handles;\n\n// public visibility added, because auto-generated assembly can't work with internal types\npublic class StatementHandle : FirebirdHandle\n{\n\tprotected override bool ReleaseHandle()\n\t{\n\t\tContract.Requires(FbClient != null);\n\n\t\tif (IsClosed)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\n\t\tvar statusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH];\n\t\tvar @ref = this;\n\t\tFbClient.isc_dsql_free_statement(statusVector, ref @ref, IscCodes.DSQL_drop);\n\t\thandle = @ref.handle;\n\n\t\tvar exception = StatusVectorHelper.ParseStatusVector(statusVector, Charset.DefaultCharset);\n\t\treturn exception == null || exception.IsWarning;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/Handles/TransactionHandle.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Hennadii Zabula, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Diagnostics.Contracts;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Native.Handles;\n\n// public visibility added, because auto-generated assembly can't work with internal types\npublic class TransactionHandle : FirebirdHandle\n{\n\tprotected override bool ReleaseHandle()\n\t{\n\t\tContract.Requires(FbClient != null);\n\n\t\tif (IsClosed)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\n\t\tvar statusVector = new IntPtr[IscCodes.ISC_STATUS_LENGTH];\n\t\tvar @ref = this;\n\t\tFbClient.isc_rollback_transaction(statusVector, ref @ref);\n\t\thandle = @ref.handle;\n\t\tvar exception = StatusVectorHelper.ParseStatusVector(statusVector, Charset.DefaultCharset);\n\t\treturn exception == null || exception.IsWarning;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/IFbClient.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Dean Harding, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Runtime.InteropServices;\nusing System.Text;\nusing FirebirdSql.Data.Client.Native.Handles;\n\nnamespace FirebirdSql.Data.Client.Native;\n\n/// <summary>\n/// This is the interface that the dynamically-generated class uses to call the native library.\n/// Each connection can specify different client library to use even on the same OS.\n/// IFbClient and FbClientactory classes are implemented to support this feature.\n/// Public visibility added, because auto-generated assembly can't work with internal types\n/// </summary>\npublic interface IFbClient\n{\n#pragma warning disable IDE1006\n\n\tIntPtr isc_array_get_slice(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref DatabaseHandle dbHandle,\n\t\t[MarshalAs(UnmanagedType.I4)] ref TransactionHandle trHandle,\n\t\tref long arrayId,\n\t\tIntPtr desc,\n\t\tbyte[] destArray,\n\t\tref int sliceLength);\n\n\tIntPtr isc_array_put_slice(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref DatabaseHandle dbHandle,\n\t\t[MarshalAs(UnmanagedType.I4)] ref TransactionHandle trHandle,\n\t\tref long arrayId,\n\t\tIntPtr desc,\n\t\tbyte[] sourceArray,\n\t\tref int sliceLength);\n\n\tIntPtr isc_create_blob2(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref DatabaseHandle dbHandle,\n\t\t[MarshalAs(UnmanagedType.I4)] ref TransactionHandle trHandle,\n\t\t[MarshalAs(UnmanagedType.I4)] ref BlobHandle blobHandle,\n\t\tref long blobId,\n\t\tshort bpbLength,\n\t\tbyte[] bpbAddress);\n\n\tIntPtr isc_open_blob2(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref DatabaseHandle dbHandle,\n\t\t[MarshalAs(UnmanagedType.I4)] ref TransactionHandle trHandle,\n\t\t[MarshalAs(UnmanagedType.I4)] ref BlobHandle blobHandle,\n\t\tref long blobId,\n\t\tshort bpbLength,\n\t\tbyte[] bpbAddress);\n\n\tIntPtr isc_blob_info(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\tref BlobHandle blobHandle,\n\t\tshort itemListBufferLength,\n\t\tbyte[] itemListBuffer,\n\t\tshort resultBufferLength,\n\t\tbyte[] resultBuffer);\n\n\tIntPtr isc_get_segment(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref BlobHandle blobHandle,\n\t\tref short actualSegLength,\n\t\tshort segBufferLength,\n\t\tbyte[] segBuffer);\n\n\tIntPtr isc_put_segment(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref BlobHandle blobHandle,\n\t\tshort segBufferLength,\n\t\tbyte[] segBuffer);\n\n\tIntPtr isc_seek_blob(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref BlobHandle blobHandle,\n\t\tshort mode,\n\t\tint offset,\n\t\tref int resultingBlobPosition);\n\n\tIntPtr isc_cancel_blob(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref BlobHandle blobHandle);\n\n\tIntPtr isc_close_blob(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref BlobHandle blobHandle);\n\n\tIntPtr isc_attach_database(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\tshort dbNameLength,\n\t\tbyte[] dbName,\n\t\t[MarshalAs(UnmanagedType.I4)] ref DatabaseHandle dbHandle,\n\t\tshort parmBufferLength,\n\t\tbyte[] parmBuffer);\n\n\tIntPtr isc_detach_database(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref DatabaseHandle dbHandle);\n\n\tIntPtr isc_database_info(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref DatabaseHandle dbHandle,\n\t\tshort itemListBufferLength,\n\t\tbyte[] itemListBuffer,\n\t\tshort resultBufferLength,\n\t\tbyte[] resultBuffer);\n\n\tIntPtr isc_create_database(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\tshort dbNameLength,\n\t\tbyte[] dbName,\n\t\t[MarshalAs(UnmanagedType.I4)] ref DatabaseHandle dbHandle,\n\t\tshort parmBufferLength,\n\t\tbyte[] parmBuffer,\n\t\tshort dbType);\n\n\tIntPtr isc_drop_database(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref DatabaseHandle dbHandle);\n\n\tIntPtr isc_start_multiple(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref TransactionHandle trHandle,\n\t\tshort dbHandleCount,\n\t\tIntPtr tebVectorAddress);\n\n\tIntPtr isc_commit_transaction(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref TransactionHandle trHandle);\n\n\tIntPtr isc_commit_retaining(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref TransactionHandle trHandle);\n\n\tIntPtr isc_rollback_transaction(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref TransactionHandle trHandle);\n\n\tIntPtr isc_rollback_retaining(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref TransactionHandle trHandle);\n\n\tIntPtr fb_shutdown(\n\t\tuint timeout,\n\t\tint reason);\n\n\tIntPtr fb_cancel_operation(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref DatabaseHandle dbHandle,\n\t\tushort option);\n\n\tIntPtr isc_dsql_allocate_statement(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref DatabaseHandle dbHandle,\n\t\t[MarshalAs(UnmanagedType.I4)] ref StatementHandle stmtHandle);\n\n\tIntPtr isc_dsql_describe(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref StatementHandle stmtHandle,\n\t\tshort daVersion,\n\t\tIntPtr xsqlda);\n\n\tIntPtr isc_dsql_describe_bind(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref StatementHandle stmtHandle,\n\t\tshort daVersion,\n\t\tIntPtr xsqlda);\n\n\tIntPtr isc_dsql_prepare(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref TransactionHandle trHandle,\n\t\t[MarshalAs(UnmanagedType.I4)] ref StatementHandle stmtHandle,\n\t\tshort length,\n\t\tbyte[] statement,\n\t\tshort dialect,\n\t\tIntPtr xsqlda);\n\n\tIntPtr isc_dsql_execute(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref TransactionHandle trHandle,\n\t\t[MarshalAs(UnmanagedType.I4)] ref StatementHandle stmtHandle,\n\t\tshort daVersion,\n\t\tIntPtr xsqlda);\n\n\tIntPtr isc_dsql_execute2(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref TransactionHandle trHandle,\n\t\t[MarshalAs(UnmanagedType.I4)] ref StatementHandle stmtHandle,\n\t\tshort da_version,\n\t\tIntPtr inXsqlda,\n\t\tIntPtr outXsqlda);\n\n\tIntPtr isc_dsql_fetch(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref StatementHandle stmtHandle,\n\t\tshort daVersion,\n\t\tIntPtr xsqlda);\n\n\tIntPtr isc_dsql_free_statement(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref StatementHandle stmtHandle,\n\t\tshort option);\n\n\tIntPtr isc_dsql_sql_info(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref StatementHandle stmtHandle,\n\t\tshort itemsLength,\n\t\tbyte[] items,\n\t\tshort bufferLength,\n\t\tbyte[] buffer);\n\n\tIntPtr isc_service_attach(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\tshort serviceLength,\n\t\tstring service,\n\t\tref int svcHandle,\n\t\tshort spbLength,\n\t\tbyte[] spb);\n\n\tIntPtr isc_service_start(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\tref int svcHandle,\n\t\tref int reserved,\n\t\tshort spbLength,\n\t\tbyte[] spb);\n\n\tIntPtr isc_service_detach(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\tref int svcHandle);\n\n\tIntPtr isc_service_query(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\tref int svcHandle,\n\t\tref int reserved,\n\t\tshort sendSpbLength,\n\t\tbyte[] sendSpb,\n\t\tshort requestSpbLength,\n\t\tbyte[] requestSpb,\n\t\tshort bufferLength,\n\t\tbyte[] buffer);\n\n\tIntPtr fb_dsql_set_timeout(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref StatementHandle stmtHandle,\n\t\tuint timeout);\n\n\tvoid isc_get_client_version(\n\t\t[MarshalAs(UnmanagedType.LPStr)] StringBuilder version);\n\n\tIntPtr isc_transaction_info(\n\t\t[In, Out] IntPtr[] statusVector,\n\t\t[MarshalAs(UnmanagedType.I4)] ref TransactionHandle trHandle,\n\t\tshort itemListBufferLength,\n\t\tbyte[] itemListBuffer,\n\t\tshort resultBufferLength,\n\t\tbyte[] resultBuffer);\n\n#pragma warning restore IDE1006\n}"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/Marshalers/ArrayBoundMarshal.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System.Runtime.InteropServices;\n\nnamespace FirebirdSql.Data.Client.Native.Marshalers;\n\n[StructLayout(LayoutKind.Sequential)]\ninternal struct ArrayBoundMarshal\n{\n\tpublic short LowerBound;\n\tpublic short UpperBound;\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/Marshalers/ArrayDescMarshal.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System.Runtime.InteropServices;\n\nnamespace FirebirdSql.Data.Client.Native.Marshalers;\n\n[StructLayout(LayoutKind.Sequential)]\ninternal struct ArrayDescMarshal\n{\n\tpublic byte DataType;\n\tpublic byte Scale;\n\tpublic short Length;\n\t[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]\n\tpublic string FieldName;\n\t[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]\n\tpublic string RelationName;\n\tpublic short Dimensions;\n\tpublic short Flags;\n\n\tpublic static int ComputeLength(int n)\n\t{\n\t\treturn Marshal.SizeOf<ArrayDescMarshal>() + n * Marshal.SizeOf<ArrayBoundMarshal>();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/Marshalers/ArrayDescMarshaler.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Runtime.InteropServices;\n\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Native.Marshalers;\n\ninternal static class ArrayDescMarshaler\n{\n\tpublic static void CleanUpNativeData(ref IntPtr pNativeData)\n\t{\n\t\tif (pNativeData != IntPtr.Zero)\n\t\t{\n\t\t\tMarshal.DestroyStructure<ArrayDescMarshal>(pNativeData);\n\n\t\t\tfor (var i = 0; i < 16; i++)\n\t\t\t{\n\t\t\t\tMarshal.DestroyStructure<ArrayBoundMarshal>(pNativeData + ArrayDescMarshal.ComputeLength(i));\n\t\t\t}\n\n\t\t\tMarshal.FreeHGlobal(pNativeData);\n\n\t\t\tpNativeData = IntPtr.Zero;\n\t\t}\n\t}\n\n\tpublic static IntPtr MarshalManagedToNative(ArrayDesc descriptor)\n\t{\n\t\tvar arrayDesc = new ArrayDescMarshal();\n\n\t\tarrayDesc.DataType = descriptor.DataType;\n\t\tarrayDesc.Scale = (byte)descriptor.Scale;\n\t\tarrayDesc.Length = descriptor.Length;\n\t\tarrayDesc.FieldName = descriptor.FieldName;\n\t\tarrayDesc.RelationName = descriptor.RelationName;\n\t\tarrayDesc.Dimensions = descriptor.Dimensions;\n\t\tarrayDesc.Flags = descriptor.Flags;\n\n\t\tvar arrayBounds = new ArrayBoundMarshal[descriptor.Bounds.Length];\n\n\t\tfor (var i = 0; i < descriptor.Dimensions; i++)\n\t\t{\n\t\t\tarrayBounds[i].LowerBound = (short)descriptor.Bounds[i].LowerBound;\n\t\t\tarrayBounds[i].UpperBound = (short)descriptor.Bounds[i].UpperBound;\n\t\t}\n\n\t\treturn MarshalManagedToNative(arrayDesc, arrayBounds);\n\t}\n\n\tpublic static IntPtr MarshalManagedToNative(ArrayDescMarshal arrayDesc, ArrayBoundMarshal[] arrayBounds)\n\t{\n\t\tvar size = ArrayDescMarshal.ComputeLength(arrayBounds.Length);\n\t\tvar ptr = Marshal.AllocHGlobal(size);\n\n\t\tMarshal.StructureToPtr(arrayDesc, ptr, true);\n\t\tfor (var i = 0; i < arrayBounds.Length; i++)\n\t\t{\n\t\t\tMarshal.StructureToPtr(arrayBounds[i], ptr + ArrayDescMarshal.ComputeLength(i), true);\n\t\t}\n\n\t\treturn ptr;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/Marshalers/XSQLDA.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System.Runtime.InteropServices;\n\nnamespace FirebirdSql.Data.Client.Native.Marshalers;\n\n[StructLayout(LayoutKind.Sequential)]\ninternal struct XSQLDA\n{\n\tpublic short version;\n\t[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)]\n\tpublic string sqldaid;\n\tpublic int sqldabc;\n\tpublic short sqln;\n\tpublic short sqld;\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/Marshalers/XSQLVAR.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Runtime.InteropServices;\n\nnamespace FirebirdSql.Data.Client.Native.Marshalers;\n\n[StructLayout(LayoutKind.Sequential)]\ninternal class XSQLVAR\n{\n\tpublic short sqltype;\n\tpublic short sqlscale;\n\tpublic short sqlsubtype;\n\tpublic short sqllen;\n\tpublic IntPtr sqldata;\n\tpublic IntPtr sqlind;\n\tpublic short sqlname_length;\n\t[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]\n\tpublic byte[] sqlname;\n\tpublic short relname_length;\n\t[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]\n\tpublic byte[] relname;\n\tpublic short ownername_length;\n\t[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]\n\tpublic byte[] ownername;\n\tpublic short aliasname_length;\n\t[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]\n\tpublic byte[] aliasname;\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/Marshalers/XsqldaMarshaler.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net), Hennadii Zabula\n\nusing System;\nusing System.Runtime.InteropServices;\nusing System.IO;\nusing FirebirdSql.Data.Common;\nusing System.Threading.Tasks;\n\nnamespace FirebirdSql.Data.Client.Native.Marshalers;\n\ninternal static class XsqldaMarshaler\n{\n\tprivate static int SizeOfXSQLDA = Marshal.SizeOf<XSQLDA>();\n\tprivate static int SizeOfXSQLVAR = Marshal.SizeOf<XSQLVAR>();\n\n\tpublic static void CleanUpNativeData(ref IntPtr pNativeData)\n\t{\n\t\tif (pNativeData != IntPtr.Zero)\n\t\t{\n\t\t\tvar xsqlda = Marshal.PtrToStructure<XSQLDA>(pNativeData);\n\n\t\t\tMarshal.DestroyStructure<XSQLDA>(pNativeData);\n\n\t\t\tfor (var i = 0; i < xsqlda.sqln; i++)\n\t\t\t{\n\t\t\t\tvar ptr = IntPtr.Add(pNativeData, ComputeLength(i));\n\n\t\t\t\tvar sqlvar = new XSQLVAR();\n\t\t\t\tMarshalXSQLVARNativeToManaged(ptr, sqlvar, true);\n\n\t\t\t\tif (sqlvar.sqldata != IntPtr.Zero)\n\t\t\t\t{\n\t\t\t\t\tMarshal.FreeHGlobal(sqlvar.sqldata);\n\t\t\t\t\tsqlvar.sqldata = IntPtr.Zero;\n\t\t\t\t}\n\n\t\t\t\tif (sqlvar.sqlind != IntPtr.Zero)\n\t\t\t\t{\n\t\t\t\t\tMarshal.FreeHGlobal(sqlvar.sqlind);\n\t\t\t\t\tsqlvar.sqlind = IntPtr.Zero;\n\t\t\t\t}\n\n\t\t\t\tMarshal.DestroyStructure<XSQLVAR>(ptr);\n\t\t\t}\n\n\t\t\tMarshal.FreeHGlobal(pNativeData);\n\n\t\t\tpNativeData = IntPtr.Zero;\n\t\t}\n\t}\n\n\tpublic static IntPtr MarshalManagedToNative(Charset charset, Descriptor descriptor)\n\t{\n\t\tvar xsqlda = new XSQLDA\n\t\t{\n\t\t\tversion = descriptor.Version,\n\t\t\tsqln = descriptor.Count,\n\t\t\tsqld = descriptor.ActualCount\n\t\t};\n\n\t\tvar xsqlvar = new XSQLVAR[descriptor.Count];\n\n\t\tfor (var i = 0; i < xsqlvar.Length; i++)\n\t\t{\n\t\t\txsqlvar[i] = new XSQLVAR\n\t\t\t{\n\t\t\t\tsqltype = descriptor[i].DataType,\n\t\t\t\tsqlscale = descriptor[i].NumericScale,\n\t\t\t\tsqlsubtype = descriptor[i].SubType,\n\t\t\t\tsqllen = descriptor[i].Length\n\t\t\t};\n\n\n\t\t\tif (descriptor[i].HasDataType() && descriptor[i].DbDataType != DbDataType.Null)\n\t\t\t{\n\t\t\t\tvar buffer = descriptor[i].DbValue.GetBytes();\n\t\t\t\txsqlvar[i].sqldata = Marshal.AllocHGlobal(buffer.Length);\n\t\t\t\tMarshal.Copy(buffer, 0, xsqlvar[i].sqldata, buffer.Length);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\txsqlvar[i].sqldata = Marshal.AllocHGlobal(0);\n\t\t\t}\n\n\t\t\txsqlvar[i].sqlind = Marshal.AllocHGlobal(Marshal.SizeOf<short>());\n\t\t\tMarshal.WriteInt16(xsqlvar[i].sqlind, descriptor[i].NullFlag);\n\n\t\t\txsqlvar[i].sqlname = GetStringBuffer(charset, descriptor[i].Name);\n\t\t\txsqlvar[i].sqlname_length = (short)descriptor[i].Name.Length;\n\n\t\t\txsqlvar[i].relname = GetStringBuffer(charset, descriptor[i].Relation);\n\t\t\txsqlvar[i].relname_length = (short)descriptor[i].Relation.Length;\n\n\t\t\txsqlvar[i].ownername = GetStringBuffer(charset, descriptor[i].Owner);\n\t\t\txsqlvar[i].ownername_length = (short)descriptor[i].Owner.Length;\n\n\t\t\txsqlvar[i].aliasname = GetStringBuffer(charset, descriptor[i].Alias);\n\t\t\txsqlvar[i].aliasname_length = (short)descriptor[i].Alias.Length;\n\t\t}\n\n\t\treturn MarshalManagedToNative(xsqlda, xsqlvar);\n\t}\n\n\tpublic static IntPtr MarshalManagedToNative(XSQLDA xsqlda, XSQLVAR[] xsqlvar)\n\t{\n\t\tvar size = ComputeLength(xsqlda.sqln);\n\t\tvar ptr = Marshal.AllocHGlobal(size);\n\n\t\tMarshal.StructureToPtr(xsqlda, ptr, true);\n\n\t\tfor (var i = 0; i < xsqlvar.Length; i++)\n\t\t{\n\t\t\tvar offset = ComputeLength(i);\n\t\t\tMarshal.StructureToPtr(xsqlvar[i], IntPtr.Add(ptr, offset), true);\n\t\t}\n\n\t\treturn ptr;\n\t}\n\n\tpublic static Descriptor MarshalNativeToManaged(Charset charset, IntPtr pNativeData)\n\t{\n\t\treturn MarshalNativeToManaged(charset, pNativeData, false);\n\t}\n\n\tpublic static Descriptor MarshalNativeToManaged(Charset charset, IntPtr pNativeData, bool fetching)\n\t{\n\t\tvar xsqlda = Marshal.PtrToStructure<XSQLDA>(pNativeData);\n\n\t\tvar descriptor = new Descriptor(xsqlda.sqln) { ActualCount = xsqlda.sqld };\n\n\t\tvar xsqlvar = new XSQLVAR();\n\t\tfor (var i = 0; i < xsqlda.sqln; i++)\n\t\t{\n\t\t\tvar ptr = IntPtr.Add(pNativeData, ComputeLength(i));\n\t\t\tMarshalXSQLVARNativeToManaged(ptr, xsqlvar);\n\n\t\t\tdescriptor[i].DataType = xsqlvar.sqltype;\n\t\t\tdescriptor[i].NumericScale = xsqlvar.sqlscale;\n\t\t\tdescriptor[i].SubType = xsqlvar.sqlsubtype;\n\t\t\tdescriptor[i].Length = xsqlvar.sqllen;\n\n\t\t\tdescriptor[i].NullFlag = xsqlvar.sqlind == IntPtr.Zero\n\t\t\t\t? (short)0\n\t\t\t\t: Marshal.ReadInt16(xsqlvar.sqlind);\n\n\t\t\tif (fetching)\n\t\t\t{\n\t\t\t\tif (descriptor[i].NullFlag != -1)\n\t\t\t\t{\n\t\t\t\t\tdescriptor[i].SetValue(GetBytes(xsqlvar));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdescriptor[i].Name = GetString(charset, xsqlvar.sqlname, xsqlvar.sqlname_length);\n\t\t\tdescriptor[i].Relation = GetString(charset, xsqlvar.relname, xsqlvar.relname_length);\n\t\t\tdescriptor[i].Owner = GetString(charset, xsqlvar.ownername, xsqlvar.ownername_length);\n\t\t\tdescriptor[i].Alias = GetString(charset, xsqlvar.aliasname, xsqlvar.aliasname_length);\n\t\t}\n\n\t\treturn descriptor;\n\t}\n\n\tprivate static void MarshalXSQLVARNativeToManaged(IntPtr ptr, XSQLVAR xsqlvar, bool onlyPointers = false)\n\t{\n\t\tunsafe\n\t\t{\n\t\t\tusing (var reader = new BinaryReader(new UnmanagedMemoryStream((byte*)ptr.ToPointer(), SizeOfXSQLVAR)))\n\t\t\t{\n\t\t\t\tif (!onlyPointers) xsqlvar.sqltype = reader.ReadInt16(); else reader.BaseStream.Position += sizeof(short);\n\t\t\t\tif (!onlyPointers) xsqlvar.sqlscale = reader.ReadInt16(); else reader.BaseStream.Position += sizeof(short);\n\t\t\t\tif (!onlyPointers) xsqlvar.sqlsubtype = reader.ReadInt16(); else reader.BaseStream.Position += sizeof(short);\n\t\t\t\tif (!onlyPointers) xsqlvar.sqllen = reader.ReadInt16(); else reader.BaseStream.Position += sizeof(short);\n\t\t\t\txsqlvar.sqldata = reader.ReadIntPtr();\n\t\t\t\txsqlvar.sqlind = reader.ReadIntPtr();\n\t\t\t\tif (!onlyPointers) xsqlvar.sqlname_length = reader.ReadInt16(); else reader.BaseStream.Position += sizeof(short);\n\t\t\t\tif (!onlyPointers) xsqlvar.sqlname = reader.ReadBytes(32); else reader.BaseStream.Position += 32;\n\t\t\t\tif (!onlyPointers) xsqlvar.relname_length = reader.ReadInt16(); else reader.BaseStream.Position += sizeof(short);\n\t\t\t\tif (!onlyPointers) xsqlvar.relname = reader.ReadBytes(32); else reader.BaseStream.Position += 32;\n\t\t\t\tif (!onlyPointers) xsqlvar.ownername_length = reader.ReadInt16(); else reader.BaseStream.Position += sizeof(short);\n\t\t\t\tif (!onlyPointers) xsqlvar.ownername = reader.ReadBytes(32); else reader.BaseStream.Position += 32;\n\t\t\t\tif (!onlyPointers) xsqlvar.aliasname_length = reader.ReadInt16(); else reader.BaseStream.Position += sizeof(short);\n\t\t\t\tif (!onlyPointers) xsqlvar.aliasname = reader.ReadBytes(32); else reader.BaseStream.Position += 32;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static int ComputeLength(int n)\n\t{\n\t\tvar length = (SizeOfXSQLDA + n * SizeOfXSQLVAR);\n\t\tif (IntPtr.Size == 8)\n\t\t{\n\t\t\tlength += 4;\n\t\t}\n\t\treturn length;\n\t}\n\n\tprivate static byte[] GetBytes(XSQLVAR xsqlvar)\n\t{\n\t\tif (xsqlvar.sqllen == 0 || xsqlvar.sqldata == IntPtr.Zero)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\n\t\tvar type = xsqlvar.sqltype & ~1;\n\t\tswitch (type)\n\t\t{\n\t\t\tcase IscCodes.SQL_VARYING:\n\t\t\t\t{\n\t\t\t\t\tvar buffer = new byte[Marshal.ReadInt16(xsqlvar.sqldata)];\n\t\t\t\t\tvar tmp = IntPtr.Add(xsqlvar.sqldata, 2);\n\t\t\t\t\tMarshal.Copy(tmp, buffer, 0, buffer.Length);\n\t\t\t\t\treturn buffer;\n\t\t\t\t}\n\t\t\tcase IscCodes.SQL_TEXT:\n\t\t\tcase IscCodes.SQL_SHORT:\n\t\t\tcase IscCodes.SQL_LONG:\n\t\t\tcase IscCodes.SQL_FLOAT:\n\t\t\tcase IscCodes.SQL_DOUBLE:\n\t\t\tcase IscCodes.SQL_D_FLOAT:\n\t\t\tcase IscCodes.SQL_QUAD:\n\t\t\tcase IscCodes.SQL_INT64:\n\t\t\tcase IscCodes.SQL_BLOB:\n\t\t\tcase IscCodes.SQL_ARRAY:\n\t\t\tcase IscCodes.SQL_TIMESTAMP:\n\t\t\tcase IscCodes.SQL_TYPE_TIME:\n\t\t\tcase IscCodes.SQL_TYPE_DATE:\n\t\t\tcase IscCodes.SQL_BOOLEAN:\n\t\t\tcase IscCodes.SQL_TIMESTAMP_TZ:\n\t\t\tcase IscCodes.SQL_TIMESTAMP_TZ_EX:\n\t\t\tcase IscCodes.SQL_TIME_TZ:\n\t\t\tcase IscCodes.SQL_TIME_TZ_EX:\n\t\t\tcase IscCodes.SQL_DEC16:\n\t\t\tcase IscCodes.SQL_DEC34:\n\t\t\tcase IscCodes.SQL_INT128:\n\t\t\t\t{\n\t\t\t\t\tvar buffer = new byte[xsqlvar.sqllen];\n\t\t\t\t\tMarshal.Copy(xsqlvar.sqldata, buffer, 0, buffer.Length);\n\t\t\t\t\treturn buffer;\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow TypeHelper.InvalidDataType(type);\n\t\t}\n\t}\n\n\tprivate static byte[] GetStringBuffer(Charset charset, string value)\n\t{\n\t\tvar buffer = new byte[32];\n\t\tcharset.GetBytes(value, 0, value.Length, buffer, 0);\n\t\treturn buffer;\n\t}\n\n\tprivate static string GetString(Charset charset, byte[] buffer)\n\t{\n\t\tvar value = charset.GetString(buffer);\n\t\treturn value.TrimEnd('\\0', ' ');\n\t}\n\n\tprivate static string GetString(Charset charset, byte[] buffer, short bufferLength)\n\t{\n\t\treturn charset.GetString(buffer, 0, bufferLength);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Client/Native/StatusVectorHelper.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Runtime.InteropServices;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Client.Native\n{\n\tstatic class StatusVectorHelper\n\t{\n\t\tpublic static void ProcessStatusVector(IntPtr[] statusVector, Charset charset, Action<IscException> warningMessage)\n\t\t{\n\t\t\tvar ex = ParseStatusVector(statusVector, charset);\n\n\t\t\tif (ex != null)\n\t\t\t{\n\t\t\t\tif (ex.IsWarning)\n\t\t\t\t{\n\t\t\t\t\twarningMessage?.Invoke(ex);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tthrow ex;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic static void ClearStatusVector(IntPtr[] statusVector)\n\t\t{\n\t\t\tArray.Clear(statusVector, 0, statusVector.Length);\n\t\t}\n\n\t\tpublic static IscException ParseStatusVector(IntPtr[] statusVector, Charset charset)\n\t\t{\n\t\t\tIscException exception = null;\n\t\t\tvar eof = false;\n\n\t\t\tfor (var i = 0; i < statusVector.Length;)\n\t\t\t{\n\t\t\t\tvar arg = statusVector[i++];\n\n\t\t\t\tswitch (arg.AsInt())\n\t\t\t\t{\n\t\t\t\t\tcase IscCodes.isc_arg_gds:\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tvar er = statusVector[i++];\n\t\t\t\t\t\tif (er != IntPtr.Zero)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (exception == null)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\texception = IscException.ForBuilding();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\texception.Errors.Add(new IscError(arg.AsInt(), er.AsInt()));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_arg_end:\n\t\t\t\t\t\texception?.BuildExceptionData();\n\t\t\t\t\t\teof = true;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_arg_interpreted:\n\t\t\t\t\tcase IscCodes.isc_arg_string:\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvar ptr = statusVector[i++];\n\t\t\t\t\t\t\tvar buffer = ReadStringData(ptr);\n\t\t\t\t\t\t\tvar value = charset.GetString(buffer);\n\t\t\t\t\t\t\texception.Errors.Add(new IscError(arg.AsInt(), value));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_arg_cstring:\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ti++;\n\n\t\t\t\t\t\t\tvar ptr = statusVector[i++];\n\t\t\t\t\t\t\tvar buffer = ReadStringData(ptr);\n\t\t\t\t\t\t\tvar value = charset.GetString(buffer);\n\t\t\t\t\t\t\texception.Errors.Add(new IscError(arg.AsInt(), value));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.isc_arg_win32:\n\t\t\t\t\tcase IscCodes.isc_arg_number:\n\t\t\t\t\t\texception.Errors.Add(new IscError(arg.AsInt(), statusVector[i++].AsInt()));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase IscCodes.isc_arg_sql_state:\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvar ptr = statusVector[i++];\n\t\t\t\t\t\t\tvar buffer = ReadStringData(ptr);\n\t\t\t\t\t\t\tvar value = charset.GetString(buffer);\n\t\t\t\t\t\t\texception.Errors.Add(new IscError(arg.AsInt(), value));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (eof)\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn exception;\n\t\t}\n\n\t\tprivate static byte[] ReadStringData(IntPtr ptr)\n\t\t{\n\t\t\tvar buffer = new List<byte>();\n\t\t\tvar offset = 0;\n\t\t\twhile (true)\n\t\t\t{\n\t\t\t\tvar b = Marshal.ReadByte(ptr, offset);\n\t\t\t\tif (b == 0)\n\t\t\t\t\tbreak;\n\t\t\t\tbuffer.Add(b);\n\t\t\t\toffset++;\n\t\t\t}\n\t\t\treturn buffer.ToArray();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/ArrayBase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Text;\nusing System.Globalization;\nusing System.Threading.Tasks;\nusing System.Threading;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal abstract class ArrayBase\n{\n\t#region Fields\n\n\tprivate ArrayDesc _descriptor;\n\tprivate string _tableName;\n\tprivate string _fieldName;\n\tprivate string _rdbFieldName;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic ArrayDesc Descriptor => _descriptor;\n\n\t#endregion\n\n\t#region Abstract Properties\n\n\tpublic abstract long Handle { get; set; }\n\tpublic abstract DatabaseBase Database { get; set; }\n\tpublic abstract TransactionBase Transaction { get; set; }\n\n\t#endregion\n\n\t#region Constructors\n\n\tprotected ArrayBase(ArrayDesc descriptor)\n\t{\n\t\t_tableName = descriptor.RelationName;\n\t\t_fieldName = descriptor.FieldName;\n\t\t_descriptor = descriptor;\n\t}\n\n\tprotected ArrayBase(string tableName, string fieldName)\n\t{\n\t\t_tableName = tableName;\n\t\t_fieldName = fieldName;\n\t\t_rdbFieldName = string.Empty;\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic void Initialize()\n\t{\n\t\tLookupBounds();\n\t}\n\tpublic ValueTask InitializeAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn LookupBoundsAsync(cancellationToken);\n\t}\n\n\tpublic Array Read()\n\t{\n\t\tvar slice = GetSlice(GetSliceLength(true));\n\t\treturn DecodeSlice(slice);\n\t}\n\tpublic async ValueTask<Array> ReadAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar slice = await GetSliceAsync(GetSliceLength(true), cancellationToken).ConfigureAwait(false);\n\t\treturn await DecodeSliceAsync(slice, cancellationToken).ConfigureAwait(false);\n\t}\n\n\tpublic void Write(Array sourceArray)\n\t{\n\t\tSetDesc(sourceArray);\n\t\tPutSlice(sourceArray, GetSliceLength(false));\n\t}\n\tpublic async ValueTask WriteAsync(Array sourceArray, CancellationToken cancellationToken = default)\n\t{\n\t\tSetDesc(sourceArray);\n\t\tawait PutSliceAsync(sourceArray, GetSliceLength(false), cancellationToken).ConfigureAwait(false);\n\t}\n\n\tpublic void SetDesc(Array sourceArray)\n\t{\n\t\t_descriptor.Dimensions = (short)sourceArray.Rank;\n\n\t\tfor (var i = 0; i < sourceArray.Rank; i++)\n\t\t{\n\t\t\tvar lb = _descriptor.Bounds[i].LowerBound;\n\t\t\tvar ub = sourceArray.GetLength(i) - 1 + lb;\n\n\t\t\t_descriptor.Bounds[i].UpperBound = ub;\n\t\t}\n\t}\n\n\tprivate void LookupBounds()\n\t{\n\t\tLookupDesc();\n\n\t\tvar lookup = Database.CreateStatement(Transaction);\n\t\ttry\n\t\t{\n\t\t\tlookup.Prepare(GetArrayBounds());\n\t\t\tlookup.Execute(0, EmptyDescriptorFiller.Instance);\n\n\t\t\t_descriptor.Bounds = new ArrayBound[16];\n\t\t\tDbValue[] values;\n\t\t\tvar i = 0;\n\t\t\twhile ((values = lookup.Fetch()) != null)\n\t\t\t{\n\t\t\t\t_descriptor.Bounds[i].LowerBound = values[0].GetInt32();\n\t\t\t\t_descriptor.Bounds[i].UpperBound = values[1].GetInt32();\n\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tlookup.Dispose2();\n\t\t}\n\t}\n\tprivate async ValueTask LookupBoundsAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tawait LookupDescAsync(cancellationToken).ConfigureAwait(false);\n\n\t\tvar lookup = Database.CreateStatement(Transaction);\n\t\ttry\n\t\t{\n\t\t\tawait lookup.PrepareAsync(GetArrayBounds(), cancellationToken).ConfigureAwait(false);\n\t\t\tawait lookup.ExecuteAsync(0, EmptyDescriptorFiller.Instance, cancellationToken).ConfigureAwait(false);\n\n\t\t\t_descriptor.Bounds = new ArrayBound[16];\n\t\t\tDbValue[] values;\n\t\t\tvar i = 0;\n\t\t\twhile ((values = await lookup.FetchAsync(cancellationToken).ConfigureAwait(false)) != null)\n\t\t\t{\n\t\t\t\t_descriptor.Bounds[i].LowerBound = values[0].GetInt32();\n\t\t\t\t_descriptor.Bounds[i].UpperBound = values[1].GetInt32();\n\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tawait lookup.Dispose2Async(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\tprivate void LookupDesc()\n\t{\n\t\tvar lookup = Database.CreateStatement(Transaction);\n\t\ttry\n\t\t{\n\t\t\tlookup.Prepare(GetArrayDesc());\n\t\t\tlookup.Execute(0, EmptyDescriptorFiller.Instance);\n\n\t\t\t_descriptor = new ArrayDesc();\n\t\t\tvar values = lookup.Fetch();\n\t\t\tif (values != null && values.Length > 0)\n\t\t\t{\n\t\t\t\t_descriptor.RelationName = _tableName;\n\t\t\t\t_descriptor.FieldName = _fieldName;\n\t\t\t\t_descriptor.DataType = values[0].GetByte();\n\t\t\t\t_descriptor.Scale = values[1].GetInt16();\n\t\t\t\t_descriptor.Length = values[2].GetInt16();\n\t\t\t\t_descriptor.Dimensions = values[3].GetInt16();\n\t\t\t\t_descriptor.Flags = 0;\n\n\t\t\t\t_rdbFieldName = (values[4].GetString()).Trim();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException();\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tlookup.Dispose2();\n\t\t}\n\t}\n\tprivate async ValueTask LookupDescAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar lookup = Database.CreateStatement(Transaction);\n\t\ttry\n\t\t{\n\t\t\tawait lookup.PrepareAsync(GetArrayDesc(), cancellationToken).ConfigureAwait(false);\n\t\t\tawait lookup.ExecuteAsync(0, EmptyDescriptorFiller.Instance, cancellationToken).ConfigureAwait(false);\n\n\t\t\t_descriptor = new ArrayDesc();\n\t\t\tvar values = await lookup.FetchAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tif (values != null && values.Length > 0)\n\t\t\t{\n\t\t\t\t_descriptor.RelationName = _tableName;\n\t\t\t\t_descriptor.FieldName = _fieldName;\n\t\t\t\t_descriptor.DataType = values[0].GetByte();\n\t\t\t\t_descriptor.Scale = values[1].GetInt16();\n\t\t\t\t_descriptor.Length = values[2].GetInt16();\n\t\t\t\t_descriptor.Dimensions = values[3].GetInt16();\n\t\t\t\t_descriptor.Flags = 0;\n\n\t\t\t\t_rdbFieldName = (await values[4].GetStringAsync(cancellationToken).ConfigureAwait(false)).Trim();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException();\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tawait lookup.Dispose2Async(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Protected Methods\n\n\tprotected int GetSliceLength(bool read)\n\t{\n\t\tvar elements = 1;\n\t\tfor (var i = 0; i < _descriptor.Dimensions; i++)\n\t\t{\n\t\t\tvar bound = _descriptor.Bounds[i];\n\t\t\telements *= bound.UpperBound - bound.LowerBound + 1;\n\t\t}\n\n\t\tvar length = elements * _descriptor.Length;\n\n\t\tswitch (_descriptor.DataType)\n\t\t{\n\t\t\tcase IscCodes.blr_varying:\n\t\t\tcase IscCodes.blr_varying2:\n\t\t\t\tlength += elements * 2;\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn length;\n\t}\n\n\tprotected Type GetSystemType()\n\t{\n\t\treturn TypeHelper.GetTypeFromBlrType(_descriptor.DataType, default, _descriptor.Scale);\n\t}\n\n\t#endregion\n\n\t#region Abstract Methods\n\n\tpublic abstract byte[] GetSlice(int slice_length);\n\tpublic abstract ValueTask<byte[]> GetSliceAsync(int slice_length, CancellationToken cancellationToken = default);\n\n\tpublic abstract void PutSlice(Array source_array, int slice_length);\n\tpublic abstract ValueTask PutSliceAsync(Array source_array, int slice_length, CancellationToken cancellationToken = default);\n\n\t#endregion\n\n\t#region Protected Abstract Methods\n\n\tprotected abstract Array DecodeSlice(byte[] slice);\n\tprotected abstract ValueTask<Array> DecodeSliceAsync(byte[] slice, CancellationToken cancellationToken = default);\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate string GetArrayDesc()\n\t{\n\t\tvar sql = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t\"SELECT Y.RDB$FIELD_TYPE, Y.RDB$FIELD_SCALE, Y.RDB$FIELD_LENGTH, Y.RDB$DIMENSIONS, X.RDB$FIELD_SOURCE \" +\n\t\t\t\"FROM RDB$RELATION_FIELDS X, RDB$FIELDS Y \" +\n\t\t\t\"WHERE X.RDB$FIELD_SOURCE = Y.RDB$FIELD_NAME \");\n\n\t\tif (_tableName != null && _tableName.Length != 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" AND X.RDB$RELATION_NAME = '{0}'\", _tableName);\n\t\t}\n\n\t\tif (_fieldName != null && _fieldName.Length != 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" AND X.RDB$FIELD_NAME = '{0}'\", _fieldName);\n\t\t}\n\n\t\treturn sql.ToString();\n\t}\n\n\tprivate string GetArrayBounds()\n\t{\n\t\tvar sql = new StringBuilder();\n\n\t\tsql.Append(\"SELECT X.RDB$LOWER_BOUND, X.RDB$UPPER_BOUND FROM RDB$FIELD_DIMENSIONS X \");\n\n\t\tif (_fieldName != null && _fieldName.Length != 0)\n\t\t{\n\t\t\tsql.AppendFormat(\"WHERE X.RDB$FIELD_NAME = '{0}'\", _rdbFieldName);\n\t\t}\n\n\t\tsql.Append(\" ORDER BY X.RDB$DIMENSION\");\n\n\t\treturn sql.ToString();\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/ArrayBound.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Runtime.InteropServices;\n\nnamespace FirebirdSql.Data.Common;\n\n[StructLayout(LayoutKind.Auto)]\ninternal struct ArrayBound\n{\n\tpublic int LowerBound { get; set; }\n\tpublic int UpperBound { get; set; }\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/ArrayDesc.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Runtime.InteropServices;\n\nnamespace FirebirdSql.Data.Common;\n\n[StructLayout(LayoutKind.Auto)]\ninternal struct ArrayDesc\n{\n\tpublic byte DataType { get; set; }\n\tpublic short Scale { get; set; }\n\tpublic short Length { get; set; }\n\tpublic string FieldName { get; set; }\n\tpublic string RelationName { get; set; }\n\tpublic short Dimensions { get; set; }\n\t// Specifies wheter array is to be accesed in\n\t// row mayor or column-mayor order\n\tpublic short Flags { get; set; }\n\tpublic ArrayBound[] Bounds { get; set; }\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/BatchBase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal abstract class BatchBase\n{\n\tpublic abstract StatementBase Statement { get; }\n\tpublic bool MultiError { get; set; }\n\tpublic int BatchBufferSize { get; set; }\n\n\tpublic class ExecuteResultItem\n\t{\n\t\tpublic int RecordsAffected { get; set; }\n\t\tpublic bool IsError { get; set; }\n\t\tpublic IscException Exception { get; set; }\n\t}\n\tpublic abstract ExecuteResultItem[] Execute(int count, IDescriptorFiller descriptorFiller);\n\tpublic abstract ValueTask<ExecuteResultItem[]> ExecuteAsync(int count, IDescriptorFiller descriptorFiller, CancellationToken cancellationToken = default);\n\n\tpublic abstract int ComputeBatchSize(int count, IDescriptorFiller descriptorFiller);\n\tpublic abstract ValueTask<int> ComputeBatchSizeAsync(int count, IDescriptorFiller descriptorFiller, CancellationToken cancellationToken = default);\n\n\tpublic abstract void Release();\n\tpublic abstract ValueTask ReleaseAsync(CancellationToken cancellationToken = default);\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/BatchParameterBuffer.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Text;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal sealed class BatchParameterBuffer : DatabaseParameterBufferBase\n{\n\tpublic BatchParameterBuffer(Encoding encoding)\n\t\t: base(IscCodes.Batch.VERSION1, encoding)\n\t{ }\n\n\tpublic override void Append(int type, byte value)\n\t{\n\t\tWriteByte(type);\n\t\tWrite(1);\n\t\tWrite(value);\n\t}\n\n\tpublic override void Append(int type, short value)\n\t{\n\t\tWriteByte(type);\n\t\tWrite(2);\n\t\tWrite(value);\n\t}\n\n\tpublic override void Append(int type, int value)\n\t{\n\t\tWriteByte(type);\n\t\tWrite(4);\n\t\tWrite(value);\n\t}\n\n\tpublic override void Append(int type, byte[] buffer)\n\t{\n\t\tWriteByte(type);\n\t\tWrite(buffer.Length);\n\t\tWrite(buffer);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/BinaryEncoding.cs",
    "content": "﻿/*\n *  BinaryEncoding handler for .Net.  This class implements\n *\ta symmetric encoding that will convert string to byte[]\n *  and byte[] to string without any character set\n *  transliteration.\n *\n *  The contents of this file were written by jimb\n *  at connectedsw.com on Dec 9, 2004.  It is placed in\n *  the Public Domain and may be used as you see fit.\n */\n \nusing System;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal class BinaryEncoding : Encoding\n{\n\tpublic static string BytesToString(byte[] byteArray)\n\t{\n\t\t// This code isn't great because it requires a double copy,\n\t\t// but it requires unsafe code to solve the problem efficiently.\n\t\tvar charArray = new char[byteArray.GetLength(0)];\n\t\tArray.Copy(byteArray, charArray, byteArray.Length);\n\n\t\treturn new string(charArray);\n\t}\n\n\tstatic void Validate(object data, int dataLength, int index, int count)\n\t{\n\t\tif (data == null)\n\t\t{\n\t\t\tthrow new ArgumentNullException();\n\t\t}\n\n\t\tif (index < 0 || count < 0 || dataLength - index < count)\n\t\t{\n\t\t\tthrow new ArgumentOutOfRangeException();\n\t\t}\n\t}\n\n\tpublic override int GetByteCount(char[] chars, int index, int count)\n\t{\n\t\tValidate(chars, chars.Length, index, count);\n\n\t\treturn count;\n\t}\n\n\tpublic override int GetByteCount(string chars)\n\t{\n\t\treturn chars.Length;\n\t}\n\n\tpublic override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int index)\n\t{\n\t\tValidate(chars, chars.Length, charIndex, charCount);\n\n\t\tif (index < 0 || index > bytes.Length)\n\t\t{\n\t\t\tthrow new ArgumentOutOfRangeException();\n\t\t}\n\t\tif (bytes.Length - index < charCount)\n\t\t{\n\t\t\tthrow new ArgumentException();\n\t\t}\n\n\t\tvar charEnd = charIndex + charCount;\n\t\twhile (charIndex < charEnd)\n\t\t{\n\t\t\tbytes[index++] = (byte)chars[charIndex++];\n\t\t}\n\n\t\treturn charCount;\n\t}\n\n\tpublic override int GetBytes(string chars, int charIndex, int charCount, byte[] bytes, int index)\n\t{\n\t\tValidate(chars, chars.Length, charIndex, charCount);\n\n\t\tif (index < 0 || index > bytes.Length)\n\t\t{\n\t\t\tthrow new ArgumentOutOfRangeException();\n\t\t}\n\t\tif (bytes.Length - index < charCount)\n\t\t{\n\t\t\tthrow new ArgumentException();\n\t\t}\n\n\t\tvar charEnd = charIndex + charCount;\n\t\twhile (charIndex < charEnd)\n\t\t{\n\t\t\tbytes[index++] = (byte)chars[charIndex++];\n\t\t}\n\n\t\treturn charCount;\n\t}\n\n\tpublic override int GetCharCount(byte[] bytes, int index, int count)\n\t{\n\t\tValidate(bytes, bytes.Length, index, count);\n\n\t\treturn (count);\n\t}\n\n\tpublic override int GetChars(byte[] bytes, int index, int count, char[] chars, int charIndex)\n\t{\n\t\tValidate(bytes, bytes.Length, index, count);\n\n\t\tif (charIndex < 0 || charIndex > chars.Length)\n\t\t{\n\t\t\tthrow new ArgumentOutOfRangeException();\n\t\t}\n\t\tif (chars.Length - charIndex < count)\n\t\t{\n\t\t\tthrow new ArgumentException();\n\t\t}\n\n\t\tvar byteEnd = index + count;\n\t\twhile (index < byteEnd)\n\t\t{\n\t\t\tchars[charIndex++] = (char)bytes[index++];\n\t\t}\n\n\t\treturn count;\n\t}\n\n\tpublic override string GetString(byte[] bytes)\n\t{\n\t\treturn BytesToString(bytes);\n\t}\n\n\tpublic override string GetString(byte[] bytes, int index, int count)\n\t{\n\t\tValidate(bytes, bytes.Length, index, count);\n\n\t\treturn BytesToString(bytes);\n\t}\n\n\tpublic override int GetMaxByteCount(int charCount)\n\t{\n\t\treturn charCount;\n\t}\n\n\tpublic override int GetMaxCharCount(int count)\n\t{\n\t\treturn count;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/BlobBase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.IO;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal abstract class BlobBase\n{\n\tprivate int _rblFlags;\n\tprivate Charset _charset;\n\tprivate int _segmentSize;\n\n\tprotected long _blobId;\n\tprotected bool _isOpen;\n\tprotected int _position;\n\tprotected TransactionBase _transaction;\n\n\tpublic abstract int Handle { get; }\n\tpublic long Id => _blobId;\n\tpublic bool EOF => (_rblFlags & IscCodes.RBL_eof_pending) != 0;\n\tpublic bool IsOpen => _isOpen;\n\n\tpublic int SegmentSize => _segmentSize;\n\tpublic int Position => _position;\n\n\tpublic abstract DatabaseBase Database { get; }\n\n\tprotected BlobBase(DatabaseBase db)\n\t{\n\t\t_segmentSize = db.PacketSize;\n\t\t_charset = db.Charset;\n\t}\n\n\tpublic string ReadString()\n\t{\n\t\tvar buffer = Read();\n\t\treturn _charset.GetString(buffer, 0, buffer.Length);\n\t}\n\tpublic async ValueTask<string> ReadStringAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar buffer = await ReadAsync(cancellationToken).ConfigureAwait(false);\n\t\treturn _charset.GetString(buffer, 0, buffer.Length);\n\t}\n\n\tpublic byte[] Read()\n\t{\n\t\tusing (var ms = new MemoryStream())\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\n\t\t\t\twhile (!EOF)\n\t\t\t\t{\n\t\t\t\t\tGetSegment(ms);\n\t\t\t\t}\n\n\t\t\t\tClose();\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\t// Cancel the blob and rethrow the exception\n\t\t\t\tCancel();\n\n\t\t\t\tthrow;\n\t\t\t}\n\n\t\t\treturn ms.ToArray();\n\t\t}\n\t}\n\tpublic async ValueTask<byte[]> ReadAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tusing (var ms = new MemoryStream())\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\twhile (!EOF)\n\t\t\t\t{\n\t\t\t\t\tawait GetSegmentAsync(ms, cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\t// Cancel the blob and rethrow the exception\n\t\t\t\tawait CancelAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tthrow;\n\t\t\t}\n\n\t\t\treturn ms.ToArray();\n\t\t}\n\t}\n\n\tpublic void Write(string data)\n\t{\n\t\tWrite(_charset.GetBytes(data));\n\t}\n\tpublic ValueTask WriteAsync(string data, CancellationToken cancellationToken = default)\n\t{\n\t\treturn WriteAsync(_charset.GetBytes(data), cancellationToken);\n\t}\n\n\tpublic void Write(byte[] buffer)\n\t{\n\t\tWrite(buffer, 0, buffer.Length);\n\t}\n\tpublic ValueTask WriteAsync(byte[] buffer, CancellationToken cancellationToken = default)\n\t{\n\t\treturn WriteAsync(buffer, 0, buffer.Length, cancellationToken);\n\t}\n\n\tpublic void Write(byte[] buffer, int index, int count)\n\t{\n\t\ttry\n\t\t{\n\t\t\tCreate();\n\n\t\t\tvar length = count;\n\t\t\tvar offset = index;\n\t\t\tvar chunk = length >= _segmentSize ? _segmentSize : length;\n\n\t\t\tvar tmpBuffer = new byte[chunk];\n\n\t\t\twhile (length > 0)\n\t\t\t{\n\t\t\t\tif (chunk > length)\n\t\t\t\t{\n\t\t\t\t\tchunk = length;\n\t\t\t\t\ttmpBuffer = new byte[chunk];\n\t\t\t\t}\n\n\t\t\t\tArray.Copy(buffer, offset, tmpBuffer, 0, chunk);\n\t\t\t\tPutSegment(tmpBuffer);\n\n\t\t\t\toffset += chunk;\n\t\t\t\tlength -= chunk;\n\t\t\t}\n\n\t\t\tClose();\n\t\t}\n\t\tcatch\n\t\t{\n\t\t\t// Cancel the blob and rethrow the exception\n\t\t\tCancel();\n\n\t\t\tthrow;\n\t\t}\n\t}\n\tpublic async ValueTask WriteAsync(byte[] buffer, int index, int count, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait CreateAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar length = count;\n\t\t\tvar offset = index;\n\t\t\tvar chunk = length >= _segmentSize ? _segmentSize : length;\n\n\t\t\tvar tmpBuffer = new byte[chunk];\n\n\t\t\twhile (length > 0)\n\t\t\t{\n\t\t\t\tif (chunk > length)\n\t\t\t\t{\n\t\t\t\t\tchunk = length;\n\t\t\t\t\ttmpBuffer = new byte[chunk];\n\t\t\t\t}\n\n\t\t\t\tArray.Copy(buffer, offset, tmpBuffer, 0, chunk);\n\t\t\t\tawait PutSegmentAsync(tmpBuffer, cancellationToken).ConfigureAwait(false);\n\n\t\t\t\toffset += chunk;\n\t\t\t\tlength -= chunk;\n\t\t\t}\n\n\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch\n\t\t{\n\t\t\t// Cancel the blob and rethrow the exception\n\t\t\tawait CancelAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tthrow;\n\t\t}\n\t}\n\n\tpublic abstract void Create();\n\tpublic abstract ValueTask CreateAsync(CancellationToken cancellationToken = default);\n\n\tpublic abstract void Open();\n\tpublic abstract ValueTask OpenAsync(CancellationToken cancellationToken = default);\n\n\tpublic abstract int GetLength();\n\tpublic abstract ValueTask<int> GetLengthAsync(CancellationToken cancellationToken = default);\n\n\tpublic abstract byte[] GetSegment();\n\tpublic abstract ValueTask<byte[]> GetSegmentAsync(CancellationToken cancellationToken = default);\n\n\tpublic abstract void GetSegment(Stream stream);\n\tpublic abstract ValueTask GetSegmentAsync(Stream stream, CancellationToken cancellationToken = default);\n\n\tpublic abstract void PutSegment(byte[] buffer);\n\tpublic abstract ValueTask PutSegmentAsync(byte[] buffer, CancellationToken cancellationToken = default);\n\n\tpublic abstract void Seek(int offset, int seekMode);\n\tpublic abstract ValueTask SeekAsync(int offset, int seekMode, CancellationToken cancellationToken = default);\n\n\tpublic abstract void Close();\n\tpublic abstract ValueTask CloseAsync(CancellationToken cancellationToken = default);\n\n\tpublic abstract void Cancel();\n\tpublic abstract ValueTask CancelAsync(CancellationToken cancellationToken = default);\n\n\tprotected void RblAddValue(int rblValue)\n\t{\n\t\t_rblFlags |= rblValue;\n\t}\n\n\tprotected void RblRemoveValue(int rblValue)\n\t{\n\t\t_rblFlags &= ~rblValue;\n\t}\n}"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/BlobParameterBuffer.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System.Text;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal sealed class BlobParameterBuffer : ParameterBuffer\n{\n\tpublic BlobParameterBuffer(Encoding encoding)\n\t{\n\t\tEncoding = encoding;\n\t}\n\n\tpublic Encoding Encoding { get; }\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/BlobStream.cs",
    "content": "﻿using System;\nusing System.IO;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace FirebirdSql.Data.Common;\n\npublic sealed class BlobStream : Stream\n{\n\tprivate readonly BlobBase _blobHandle;\n\tprivate int _position;\n\n\tprivate byte[] _currentSegment;\n\tprivate int _segmentPosition;\n\n\tprivate int Available => _currentSegment?.Length - _segmentPosition ?? 0;\n\n\tinternal BlobStream(BlobBase blob)\n\t{\n\t\t_blobHandle = blob;\n\t\t_position = 0;\n\t}\n\n\tpublic override long Position\n\t{\n\t\tget => _position;\n\t\tset => Seek(value, SeekOrigin.Begin);\n\t}\n\n\tpublic override long Length\n\t{\n\t\tget\n\t\t{\n\t\t\tif (!_blobHandle.IsOpen)\n\t\t\t\t_blobHandle.Open();\n\n\t\t\treturn _blobHandle.GetLength();\n\t\t}\n\t}\n\n\tpublic override void Flush()\n\t{\n\t}\n\n\tpublic override int Read(byte[] buffer, int offset, int count)\n\t{\n\t\tValidateBufferSize(buffer, offset, count);\n\n\t\tif (!_blobHandle.IsOpen)\n\t\t\t_blobHandle.Open();\n\n\t\tvar copied = 0;\n\t\tvar remainingBufferSize = buffer.Length - offset;\n\t\tdo\n\t\t{\n\t\t\tif (remainingBufferSize == 0)\n\t\t\t\tbreak;\n\n\t\t\tif (Available > 0)\n\t\t\t{\n\t\t\t\tvar toCopy = Math.Min(Available, remainingBufferSize);\n\t\t\t\tArray.Copy(_currentSegment, _segmentPosition, buffer, offset + copied, toCopy);\n\t\t\t\tcopied += toCopy;\n\t\t\t\t_segmentPosition += toCopy;\n\t\t\t\tremainingBufferSize -= toCopy;\n\t\t\t\t_position += toCopy;\n\t\t\t}\n\n\t\t\tif (_blobHandle.EOF)\n\t\t\t\tbreak;\n\n\t\t\tif (Available == 0)\n\t\t\t{\n\t\t\t\t_currentSegment = _blobHandle.GetSegment();\n\t\t\t\t_segmentPosition = 0;\n\t\t\t}\n\t\t} while (copied < count);\n\n\t\treturn copied;\n\t}\n\tpublic override async Task<int> ReadAsync(byte[] buffer, int offset, int count,\n\t\tCancellationToken cancellationToken)\n\t{\n\t\tValidateBufferSize(buffer, offset, count);\n\n\t\tif (!_blobHandle.IsOpen)\n\t\t\tawait _blobHandle.OpenAsync(cancellationToken).ConfigureAwait(false);\n\n\t\tvar copied = 0;\n\t\tvar remainingBufferSize = buffer.Length - offset;\n\t\tdo\n\t\t{\n\t\t\tif (remainingBufferSize == 0)\n\t\t\t\tbreak;\n\n\t\t\tif (Available > 0)\n\t\t\t{\n\t\t\t\tvar toCopy = Math.Min(Available, remainingBufferSize);\n\t\t\t\tArray.Copy(_currentSegment, _segmentPosition, buffer, offset + copied, toCopy);\n\t\t\t\tcopied += toCopy;\n\t\t\t\t_segmentPosition += toCopy;\n\t\t\t\tremainingBufferSize -= toCopy;\n\t\t\t\t_position += toCopy;\n\t\t\t}\n\n\t\t\tif (_blobHandle.EOF)\n\t\t\t\tbreak;\n\n\t\t\tif (Available == 0)\n\t\t\t{\n\t\t\t\t_currentSegment = await _blobHandle.GetSegmentAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t_segmentPosition = 0;\n\t\t\t}\n\t\t} while (copied < count);\n\n\t\treturn copied;\n\t}\n\n\tpublic override long Seek(long offset, SeekOrigin origin)\n\t{\n\t\tif (!_blobHandle.IsOpen)\n\t\t\t_blobHandle.Open();\n\n\t\tvar seekMode = origin switch\n\t\t{\n\t\t\tSeekOrigin.Begin => IscCodes.isc_blb_seek_from_head,\n\t\t\tSeekOrigin.Current => IscCodes.isc_blb_seek_relative,\n\t\t\tSeekOrigin.End => IscCodes.isc_blb_seek_from_tail,\n\t\t\t_ => throw new ArgumentOutOfRangeException(nameof(origin))\n\t\t};\n\n\t\t_blobHandle.Seek((int)offset, seekMode);\n\t\treturn _position = _blobHandle.Position;\n\t}\n\n\tpublic override void SetLength(long value)\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\n\tpublic override void Write(byte[] buffer, int offset, int count)\n\t{\n\t\ttry\n\t\t{\n\t\t\tif (!_blobHandle.IsOpen)\n\t\t\t\t_blobHandle.Create();\n\n\t\t\tvar chunk = count >= _blobHandle.SegmentSize ? _blobHandle.SegmentSize : count;\n\t\t\tvar tmpBuffer = new byte[chunk];\n\n\t\t\twhile (count > 0)\n\t\t\t{\n\t\t\t\tif (chunk > count)\n\t\t\t\t{\n\t\t\t\t\tchunk = count;\n\t\t\t\t\ttmpBuffer = new byte[chunk];\n\t\t\t\t}\n\n\t\t\t\tArray.Copy(buffer, offset, tmpBuffer, 0, chunk);\n\t\t\t\t_blobHandle.PutSegment(tmpBuffer);\n\n\t\t\t\toffset += chunk;\n\t\t\t\tcount -= chunk;\n\t\t\t\t_position += chunk;\n\t\t\t}\n\t\t}\n\t\tcatch\n\t\t{\n\t\t\t_blobHandle.Cancel();\n\t\t\tthrow;\n\t\t}\n\t}\n\tpublic override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)\n\t{\n\t\ttry\n\t\t{\n\t\t\tif (!_blobHandle.IsOpen)\n\t\t\t\tawait _blobHandle.CreateAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tvar chunk = count >= _blobHandle.SegmentSize ? _blobHandle.SegmentSize : count;\n\t\t\tvar tmpBuffer = new byte[chunk];\n\n\t\t\twhile (count > 0)\n\t\t\t{\n\t\t\t\tif (chunk > count)\n\t\t\t\t{\n\t\t\t\t\tchunk = count;\n\t\t\t\t\ttmpBuffer = new byte[chunk];\n\t\t\t\t}\n\n\t\t\t\tArray.Copy(buffer, offset, tmpBuffer, 0, chunk);\n\t\t\t\tawait _blobHandle.PutSegmentAsync(tmpBuffer, cancellationToken).ConfigureAwait(false);\n\n\t\t\t\toffset += chunk;\n\t\t\t\tcount -= chunk;\n\t\t\t\t_position += chunk;\n\t\t\t}\n\t\t}\n\t\tcatch\n\t\t{\n\t\t\tawait _blobHandle.CancelAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tthrow;\n\t\t}\n\t}\n\n\tpublic override bool CanRead => true;\n\tpublic override bool CanSeek => true;\n\tpublic override bool CanWrite => true;\n\n\tprotected override void Dispose(bool disposing)\n\t{\n\t\t_blobHandle.Close();\n\t}\n\n\tpublic override ValueTask DisposeAsync()\n\t{\n\t\treturn _blobHandle.CloseAsync();\n\t}\n\n\tprivate static void ValidateBufferSize(byte[] buffer, int offset, int count)\n\t{\n\t\tif (buffer is null)\n\t\t\tthrow new ArgumentNullException(nameof(buffer));\n\n\t\tif (buffer.Length < offset + count)\n\t\t\tthrow new InvalidOperationException();\n\t}\n}"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/Charset.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal sealed class Charset\n{\n\tinternal const string Octets = \"OCTETS\";\n\tinternal const string None = \"NONE\";\n\n\tprivate readonly static Dictionary<int, Charset> charsetsById;\n\tprivate readonly static Dictionary<string, Charset> charsetsByName;\n\n\tstatic Charset()\n\t{\n\t\tvar charsets = GetSupportedCharsets();\n\t\tcharsetsById = charsets.ToDictionary(x => x.Identifier);\n\t\tcharsetsByName = charsets.ToDictionary(x => x.Name, StringComparer.CurrentCultureIgnoreCase);\n\t}\n\n\tpublic static Charset DefaultCharset => charsetsByName[None];\n\n\tpublic static bool TryGetById(int id, out Charset charset) => charsetsById.TryGetValue(id, out charset);\n\n\tpublic static bool TryGetByName(string name, out Charset charset) => charsetsByName.TryGetValue(name, out charset);\n\n\tprivate static List<Charset> GetSupportedCharsets()\n\t{\n\t\tvar charsets = new List<Charset>();\n\n\t\tcharsets.Add(new Charset(0, None, 1, None));\n\t\tcharsets.Add(new Charset(1, Octets, 1, Octets));\n\t\tcharsets.Add(new Charset(2, \"ASCII\", 1, \"ascii\"));\n\t\tcharsets.Add(new Charset(3, \"UNICODE_FSS\", 3, \"UTF-8\"));\n\t\tcharsets.Add(new Charset(4, \"UTF8\", 4, \"UTF-8\"));\n\n\t\tTryAddCharset(charsets, () => new Charset(5, \"SJIS_0208\", 2, \"shift_jis\"));\n\t\tTryAddCharset(charsets, () => new Charset(6, \"EUCJ_0208\", 2, \"euc-jp\"));\n\t\tTryAddCharset(charsets, () => new Charset(7, \"ISO2022-JP\", 2, \"iso-2022-jp\"));\n\t\tTryAddCharset(charsets, () => new Charset(10, \"DOS437\", 1, \"IBM437\"));\n\t\tTryAddCharset(charsets, () => new Charset(11, \"DOS850\", 1, \"ibm850\"));\n\t\tTryAddCharset(charsets, () => new Charset(12, \"DOS865\", 1, \"IBM865\"));\n\t\tTryAddCharset(charsets, () => new Charset(13, \"DOS860\", 1, \"IBM860\"));\n\t\tTryAddCharset(charsets, () => new Charset(14, \"DOS863\", 1, \"IBM863\"));\n\t\tTryAddCharset(charsets, () => new Charset(21, \"ISO8859_1\", 1, \"iso-8859-1\"));\n\t\tTryAddCharset(charsets, () => new Charset(22, \"ISO8859_2\", 1, \"iso-8859-2\"));\n\t\tTryAddCharset(charsets, () => new Charset(44, \"KSC_5601\", 2, \"ks_c_5601-1987\"));\n\t\tTryAddCharset(charsets, () => new Charset(47, \"DOS861\", 1, \"ibm861\"));\n\t\tTryAddCharset(charsets, () => new Charset(51, \"WIN1250\", 1, \"windows-1250\"));\n\t\tTryAddCharset(charsets, () => new Charset(52, \"WIN1251\", 1, \"windows-1251\"));\n\t\tTryAddCharset(charsets, () => new Charset(53, \"WIN1252\", 1, \"windows-1252\"));\n\t\tTryAddCharset(charsets, () => new Charset(54, \"WIN1253\", 1, \"windows-1253\"));\n\t\tTryAddCharset(charsets, () => new Charset(55, \"WIN1254\", 1, \"windows-1254\"));\n\t\tTryAddCharset(charsets, () => new Charset(56, \"BIG_5\", 2, \"big5\"));\n\t\tTryAddCharset(charsets, () => new Charset(57, \"GB_2312\", 2, \"gb2312\"));\n\t\tTryAddCharset(charsets, () => new Charset(58, \"WIN1255\", 1, \"windows-1255\"));\n\t\tTryAddCharset(charsets, () => new Charset(59, \"WIN1256\", 1, \"windows-1256\"));\n\t\tTryAddCharset(charsets, () => new Charset(60, \"WIN1257\", 1, \"windows-1257\"));\n\t\t//TryAddCharset(charsets, () => new Charset(61, \"UTF16\", 4, \"utf-16\"));\n\t\t//TryAddCharset(charsets, () => new Charset(62, \"UTF32\", 4, \"utf-32\"));\n\t\tTryAddCharset(charsets, () => new Charset(63, \"KOI8R\", 2, \"koi8-r\"));\n\t\tTryAddCharset(charsets, () => new Charset(64, \"KOI8U\", 2, \"koi8-u\"));\n\t\tTryAddCharset(charsets, () => new Charset(65, \"TIS620\", 1, \"tis-620\"));\n\n\t\treturn charsets;\n\t}\n\n\tprivate static void TryAddCharset(List<Charset> charsets, Func<Charset> charsetCreator)\n\t{\n\t\ttry\n\t\t{\n\t\t\tcharsets.Add(charsetCreator());\n\t\t}\n\t\tcatch\n\t\t{ }\n\t}\n\n\tpublic int Identifier { get; }\n\tpublic string Name { get; }\n\tpublic string SystemName { get; private set; }\n\tpublic int BytesPerCharacter { get; }\n\tpublic Encoding Encoding { get; }\n\tpublic bool IsOctetsCharset { get; }\n\tpublic bool IsNoneCharset { get; }\n\n\tpublic Charset(int id, string name, int bytesPerCharacter, string systemName)\n\t{\n\t\tIdentifier = id;\n\t\tName = name;\n\t\tBytesPerCharacter = bytesPerCharacter;\n\t\tSystemName = systemName;\n\t\tIsNoneCharset = false;\n\t\tIsOctetsCharset = false;\n\t\tswitch (SystemName)\n\t\t{\n\t\t\tcase None:\n\t\t\t\tEncoding = Encoding.GetANSIEncoding();\n\t\t\t\tIsNoneCharset = true;\n\t\t\t\tbreak;\n\t\t\tcase Octets:\n\t\t\t\tEncoding = new BinaryEncoding();\n\t\t\t\tIsOctetsCharset = true;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tEncoding = Encoding.GetEncoding(SystemName);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tpublic byte[] GetBytes(string s)\n\t{\n\t\treturn Encoding.GetBytes(s);\n\t}\n\n\tpublic int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)\n\t{\n\t\treturn Encoding.GetBytes(s, charIndex, charCount, bytes, byteIndex);\n\t}\n\n\tpublic string GetString(byte[] buffer)\n\t{\n\t\treturn Encoding.GetString(buffer);\n\t}\n\n\tpublic string GetString(byte[] buffer, int index, int count)\n\t{\n\t\treturn Encoding.GetString(buffer, index, count);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/ConnectionPoolLifetimeHelper.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = @realic, Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class ConnectionPoolLifetimeHelper\n{\n\tinternal static bool IsAlive(long connectionLifetime, long created, long now)\n\t{\n\t\tif (connectionLifetime == 0)\n\t\t\treturn true;\n\t\treturn (now - created) < (connectionLifetime * 1000);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/ConnectionString.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Data;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text.RegularExpressions;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal sealed class ConnectionString\n{\n\t#region Constants\n\tinternal const string DefaultValueDataSource = \"\";\n\tinternal const int DefaultValuePortNumber = 3050;\n\tinternal const string DefaultValueUserId = \"\";\n\tinternal const string DefaultValuePassword = \"\";\n\tinternal const string DefaultValueRoleName = \"\";\n\tinternal const string DefaultValueCatalog = \"\";\n\tinternal const string DefaultValueCharacterSet = \"UTF8\";\n\tinternal const int DefaultValueDialect = 3;\n\tinternal const int DefaultValuePacketSize = 8192;\n\tinternal const bool DefaultValuePooling = true;\n\tinternal const int DefaultValueConnectionLifetime = 0;\n\tinternal const int DefaultValueMinPoolSize = 0;\n\tinternal const int DefaultValueMaxPoolSize = 100;\n\tinternal const int DefaultValueConnectionTimeout = 15;\n\tinternal const int DefaultValueFetchSize = 200;\n\tinternal const FbServerType DefaultValueServerType = FbServerType.Default;\n\tinternal const IsolationLevel DefaultValueIsolationLevel = IsolationLevel.ReadCommitted;\n\tinternal const bool DefaultValueRecordsAffected = true;\n\tinternal const bool DefaultValueEnlist = true;\n\tinternal const string DefaultValueClientLibrary = \"fbembed\";\n\tinternal const int DefaultValueDbCachePages = 0;\n\tinternal const bool DefaultValueNoDbTriggers = false;\n\tinternal const bool DefaultValueNoGarbageCollect = false;\n\tinternal const bool DefaultValueCompression = false;\n\tinternal const byte[] DefaultValueCryptKey = null;\n\tinternal const FbWireCrypt DefaultValueWireCrypt = FbWireCrypt.Enabled;\n\tinternal const string DefaultValueApplicationName = \"\";\n\tinternal const int DefaultValueCommandTimeout = 0;\n\tinternal const int DefaultValueParallelWorkers = 0;\n\n\tinternal const string DefaultKeyUserId = \"user id\";\n\tinternal const string DefaultKeyPortNumber = \"port number\";\n\tinternal const string DefaultKeyDataSource = \"data source\";\n\tinternal const string DefaultKeyPassword = \"password\";\n\tinternal const string DefaultKeyRoleName = \"role name\";\n\tinternal const string DefaultKeyCatalog = \"initial catalog\";\n\tinternal const string DefaultKeyCharacterSet = \"character set\";\n\tinternal const string DefaultKeyDialect = \"dialect\";\n\tinternal const string DefaultKeyPacketSize = \"packet size\";\n\tinternal const string DefaultKeyPooling = \"pooling\";\n\tinternal const string DefaultKeyConnectionLifetime = \"connection lifetime\";\n\tinternal const string DefaultKeyMinPoolSize = \"min pool size\";\n\tinternal const string DefaultKeyMaxPoolSize = \"max pool size\";\n\tinternal const string DefaultKeyConnectionTimeout = \"connection timeout\";\n\tinternal const string DefaultKeyFetchSize = \"fetch size\";\n\tinternal const string DefaultKeyServerType = \"server type\";\n\tinternal const string DefaultKeyIsolationLevel = \"isolation level\";\n\tinternal const string DefaultKeyRecordsAffected = \"records affected\";\n\tinternal const string DefaultKeyEnlist = \"enlist\";\n\tinternal const string DefaultKeyClientLibrary = \"client library\";\n\tinternal const string DefaultKeyDbCachePages = \"cache pages\";\n\tinternal const string DefaultKeyNoDbTriggers = \"no db triggers\";\n\tinternal const string DefaultKeyNoGarbageCollect = \"no garbage collect\";\n\tinternal const string DefaultKeyCompression = \"compression\";\n\tinternal const string DefaultKeyCryptKey = \"crypt key\";\n\tinternal const string DefaultKeyWireCrypt = \"wire crypt\";\n\tinternal const string DefaultKeyApplicationName = \"application name\";\n\tinternal const string DefaultKeyCommandTimeout = \"command timeout\";\n\tinternal const string DefaultKeyParallelWorkers = \"parallel workers\";\n\t#endregion\n\n\t#region Static Fields\n\n\tinternal static readonly IDictionary<string, string> Synonyms = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)\n\t\t{\n\t\t\t{ DefaultKeyDataSource, DefaultKeyDataSource },\n\t\t\t{ \"datasource\", DefaultKeyDataSource },\n\t\t\t{ \"server\", DefaultKeyDataSource },\n\t\t\t{ \"host\", DefaultKeyDataSource },\n\t\t\t{ \"port\", DefaultKeyPortNumber },\n\t\t\t{ DefaultKeyPortNumber, DefaultKeyPortNumber },\n\t\t\t{ \"database\", DefaultKeyCatalog },\n\t\t\t{ DefaultKeyCatalog, DefaultKeyCatalog },\n\t\t\t{ DefaultKeyUserId, DefaultKeyUserId },\n\t\t\t{ \"userid\", DefaultKeyUserId },\n\t\t\t{ \"uid\", DefaultKeyUserId },\n\t\t\t{ \"user\", DefaultKeyUserId },\n\t\t\t{ \"user name\", DefaultKeyUserId },\n\t\t\t{ \"username\", DefaultKeyUserId },\n\t\t\t{ DefaultKeyPassword, DefaultKeyPassword },\n\t\t\t{ \"user password\", DefaultKeyPassword },\n\t\t\t{ \"userpassword\", DefaultKeyPassword },\n\t\t\t{ DefaultKeyDialect, DefaultKeyDialect },\n\t\t\t{ DefaultKeyPooling, DefaultKeyPooling },\n\t\t\t{ DefaultKeyMaxPoolSize, DefaultKeyMaxPoolSize },\n\t\t\t{ \"maxpoolsize\", DefaultKeyMaxPoolSize },\n\t\t\t{ DefaultKeyMinPoolSize, DefaultKeyMinPoolSize },\n\t\t\t{ \"minpoolsize\", DefaultKeyMinPoolSize },\n\t\t\t{ DefaultKeyCharacterSet, DefaultKeyCharacterSet },\n\t\t\t{ \"charset\", DefaultKeyCharacterSet },\n\t\t\t{ DefaultKeyConnectionLifetime, DefaultKeyConnectionLifetime },\n\t\t\t{ \"connectionlifetime\", DefaultKeyConnectionLifetime },\n\t\t\t{ \"timeout\", DefaultKeyConnectionTimeout },\n\t\t\t{ DefaultKeyConnectionTimeout, DefaultKeyConnectionTimeout },\n\t\t\t{ \"connectiontimeout\", DefaultKeyConnectionTimeout },\n\t\t\t{ DefaultKeyPacketSize, DefaultKeyPacketSize },\n\t\t\t{ \"packetsize\", DefaultKeyPacketSize },\n\t\t\t{ \"role\", DefaultKeyRoleName },\n\t\t\t{ DefaultKeyRoleName, DefaultKeyRoleName },\n\t\t\t{ DefaultKeyFetchSize, DefaultKeyFetchSize },\n\t\t\t{ \"fetchsize\", DefaultKeyFetchSize },\n\t\t\t{ DefaultKeyServerType, DefaultKeyServerType },\n\t\t\t{ \"servertype\", DefaultKeyServerType },\n\t\t\t{ DefaultKeyIsolationLevel, DefaultKeyIsolationLevel },\n\t\t\t{ \"isolationlevel\", DefaultKeyIsolationLevel },\n\t\t\t{ DefaultKeyRecordsAffected, DefaultKeyRecordsAffected },\n\t\t\t{ DefaultKeyEnlist, DefaultKeyEnlist },\n\t\t\t{ \"clientlibrary\", DefaultKeyClientLibrary },\n\t\t\t{ DefaultKeyClientLibrary, DefaultKeyClientLibrary },\n\t\t\t{ DefaultKeyDbCachePages, DefaultKeyDbCachePages },\n\t\t\t{ \"cachepages\", DefaultKeyDbCachePages },\n\t\t\t{ \"pagebuffers\", DefaultKeyDbCachePages },\n\t\t\t{ \"page buffers\", DefaultKeyDbCachePages },\n\t\t\t{ DefaultKeyNoDbTriggers, DefaultKeyNoDbTriggers },\n\t\t\t{ \"nodbtriggers\", DefaultKeyNoDbTriggers },\n\t\t\t{ \"no dbtriggers\", DefaultKeyNoDbTriggers },\n\t\t\t{ \"no database triggers\", DefaultKeyNoDbTriggers },\n\t\t\t{ \"nodatabasetriggers\", DefaultKeyNoDbTriggers },\n\t\t\t{ DefaultKeyNoGarbageCollect, DefaultKeyNoGarbageCollect },\n\t\t\t{ \"nogarbagecollect\", DefaultKeyNoGarbageCollect },\n\t\t\t{ DefaultKeyCompression, DefaultKeyCompression },\n\t\t\t{ \"wire compression\", DefaultKeyCompression },\n\t\t\t{ DefaultKeyCryptKey, DefaultKeyCryptKey },\n\t\t\t{ \"cryptkey\", DefaultKeyCryptKey },\n\t\t\t{ DefaultKeyWireCrypt, DefaultKeyWireCrypt },\n\t\t\t{ \"wirecrypt\", DefaultKeyWireCrypt },\n\t\t\t{ DefaultKeyApplicationName, DefaultKeyApplicationName },\n\t\t\t{ \"applicationname\", DefaultKeyApplicationName },\n\t\t\t{ \"app\", DefaultKeyApplicationName },\n\t\t\t{ DefaultKeyCommandTimeout, DefaultKeyCommandTimeout },\n\t\t\t{ \"commandtimeout\", DefaultKeyCommandTimeout },\n\t\t\t{ DefaultKeyParallelWorkers, DefaultKeyParallelWorkers },\n\t\t\t{ \"parallelworkers\", DefaultKeyParallelWorkers },\n\t\t\t{ \"parallel\", DefaultKeyParallelWorkers },\n\t\t};\n\n\tinternal static readonly IDictionary<string, object> DefaultValues = new Dictionary<string, object>(StringComparer.Ordinal)\n\t\t{\n\t\t\t{ DefaultKeyDataSource, DefaultValueDataSource },\n\t\t\t{ DefaultKeyPortNumber, DefaultValuePortNumber },\n\t\t\t{ DefaultKeyUserId, DefaultValueUserId },\n\t\t\t{ DefaultKeyPassword, DefaultValuePassword },\n\t\t\t{ DefaultKeyRoleName, DefaultValueRoleName },\n\t\t\t{ DefaultKeyCatalog, DefaultValueCatalog },\n\t\t\t{ DefaultKeyCharacterSet, DefaultValueCharacterSet },\n\t\t\t{ DefaultKeyDialect, DefaultValueDialect },\n\t\t\t{ DefaultKeyPacketSize, DefaultValuePacketSize },\n\t\t\t{ DefaultKeyPooling, DefaultValuePooling },\n\t\t\t{ DefaultKeyConnectionLifetime, DefaultValueConnectionLifetime },\n\t\t\t{ DefaultKeyMinPoolSize, DefaultValueMinPoolSize },\n\t\t\t{ DefaultKeyMaxPoolSize, DefaultValueMaxPoolSize },\n\t\t\t{ DefaultKeyConnectionTimeout, DefaultValueConnectionTimeout },\n\t\t\t{ DefaultKeyFetchSize, DefaultValueFetchSize },\n\t\t\t{ DefaultKeyServerType, DefaultValueServerType },\n\t\t\t{ DefaultKeyIsolationLevel, DefaultValueIsolationLevel },\n\t\t\t{ DefaultKeyRecordsAffected, DefaultValueRecordsAffected },\n\t\t\t{ DefaultKeyEnlist, DefaultValueEnlist },\n\t\t\t{ DefaultKeyClientLibrary, DefaultValueClientLibrary },\n\t\t\t{ DefaultKeyDbCachePages, DefaultValueDbCachePages },\n\t\t\t{ DefaultKeyNoDbTriggers, DefaultValueNoDbTriggers },\n\t\t\t{ DefaultKeyNoGarbageCollect, DefaultValueNoGarbageCollect },\n\t\t\t{ DefaultKeyCompression, DefaultValueCompression },\n\t\t\t{ DefaultKeyCryptKey, DefaultValueCryptKey },\n\t\t\t{ DefaultKeyWireCrypt, DefaultValueWireCrypt },\n\t\t\t{ DefaultKeyApplicationName, DefaultValueApplicationName },\n\t\t\t{ DefaultKeyCommandTimeout, DefaultValueCommandTimeout },\n\t\t\t{ DefaultKeyParallelWorkers, DefaultValueParallelWorkers },\n\t\t};\n\n\t#endregion\n\n\t#region Fields\n\n\tprivate Dictionary<string, object> _options;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic string UserID => GetString(DefaultKeyUserId, _options.TryGetValue);\n\tpublic string Password => GetString(DefaultKeyPassword, _options.TryGetValue);\n\tpublic string DataSource => GetString(DefaultKeyDataSource, _options.TryGetValue);\n\tpublic int Port => GetInt32(DefaultKeyPortNumber, _options.TryGetValue);\n\tpublic string Database => ExpandDataDirectory(GetString(DefaultKeyCatalog, _options.TryGetValue));\n\tpublic int PacketSize => GetInt32(DefaultKeyPacketSize, _options.TryGetValue);\n\tpublic string Role => GetString(DefaultKeyRoleName, _options.TryGetValue);\n\tpublic short Dialect => GetInt16(DefaultKeyDialect, _options.TryGetValue);\n\tpublic string Charset => GetString(DefaultKeyCharacterSet, _options.TryGetValue);\n\tpublic int ConnectionTimeout => GetInt32(DefaultKeyConnectionTimeout, _options.TryGetValue);\n\tpublic bool Pooling => GetBoolean(DefaultKeyPooling, _options.TryGetValue);\n\tpublic long ConnectionLifetime => GetInt64(DefaultKeyConnectionLifetime, _options.TryGetValue);\n\tpublic int MinPoolSize => GetInt32(DefaultKeyMinPoolSize, _options.TryGetValue);\n\tpublic int MaxPoolSize => GetInt32(DefaultKeyMaxPoolSize, _options.TryGetValue);\n\tpublic int FetchSize => GetInt32(DefaultKeyFetchSize, _options.TryGetValue);\n\tpublic FbServerType ServerType => GetServerType(DefaultKeyServerType, _options.TryGetValue);\n\tpublic IsolationLevel IsolationLevel => GetIsolationLevel(DefaultKeyIsolationLevel, _options.TryGetValue);\n\tpublic bool ReturnRecordsAffected => GetBoolean(DefaultKeyRecordsAffected, _options.TryGetValue);\n\tpublic bool Enlist => GetBoolean(DefaultKeyEnlist, _options.TryGetValue);\n\tpublic string ClientLibrary => GetString(DefaultKeyClientLibrary, _options.TryGetValue);\n\tpublic int DbCachePages => GetInt32(DefaultKeyDbCachePages, _options.TryGetValue);\n\tpublic bool NoDatabaseTriggers => GetBoolean(DefaultKeyNoDbTriggers, _options.TryGetValue);\n\tpublic bool NoGarbageCollect => GetBoolean(DefaultKeyNoGarbageCollect, _options.TryGetValue);\n\tpublic bool Compression => GetBoolean(DefaultKeyCompression, _options.TryGetValue);\n\tpublic byte[] CryptKey => GetBytes(DefaultKeyCryptKey, _options.TryGetValue);\n\tpublic FbWireCrypt WireCrypt => GetWireCrypt(DefaultKeyWireCrypt, _options.TryGetValue);\n\tpublic string ApplicationName => GetString(DefaultKeyApplicationName, _options.TryGetValue);\n\tpublic int CommandTimeout => GetInt32(DefaultKeyCommandTimeout, _options.TryGetValue);\n\tpublic int ParallelWorkers => GetInt32(DefaultKeyParallelWorkers, _options.TryGetValue);\n\n\t#endregion\n\n\t#region Internal Properties\n\tinternal string NormalizedConnectionString\n\t{\n\t\tget { return string.Join(\";\", _options.OrderBy(x => x.Key, StringComparer.Ordinal).Where(x => x.Value != null).Select(x => string.Format(\"{0}={1}\", x.Key, WrapValueIfNeeded(x.Value.ToString())))); }\n\t}\n\t#endregion\n\n\t#region Constructors\n\n\tpublic ConnectionString()\n\t{\n\t\tSetDefaultOptions();\n\t}\n\n\tpublic ConnectionString(string connectionString)\n\t\t: this()\n\t{\n\t\tLoad(connectionString);\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic void Validate()\n\t{\n\t\tif (\n\t\t\t(string.IsNullOrEmpty(Database)) ||\n\t\t\t(string.IsNullOrEmpty(DataSource) && ServerType != FbServerType.Embedded) ||\n\t\t\t(string.IsNullOrEmpty(Charset))\n\t\t   )\n\t\t{\n\t\t\tthrow new ArgumentException(\"An invalid connection string argument has been supplied or a required connection string argument has not been supplied.\");\n\t\t}\n\t\tif (Port <= 0 || Port > 65535)\n\t\t{\n\t\t\tthrow new ArgumentException(\"Incorrect port.\");\n\t\t}\n\t\tif (MinPoolSize > MaxPoolSize)\n\t\t{\n\t\t\tthrow new ArgumentException(\"Incorrect pool size.\");\n\t\t}\n\t\tif (Dialect < 1 || Dialect > 3)\n\t\t{\n\t\t\tthrow new ArgumentException(\"Incorrect database dialect it should be 1, 2, or 3.\");\n\t\t}\n\t\tif (PacketSize < 512 || PacketSize > 32767)\n\t\t{\n\t\t\tthrow new ArgumentException(string.Format(CultureInfo.CurrentCulture, \"'Packet Size' value of {0} is not valid.{1}The value should be an integer >= 512 and <= 32767.\", PacketSize, Environment.NewLine));\n\t\t}\n\t\tif (DbCachePages < 0)\n\t\t{\n\t\t\tthrow new ArgumentException(string.Format(CultureInfo.CurrentCulture, \"'Cache Pages' value of {0} is not valid.{1}The value should be an integer >= 0.\", DbCachePages, Environment.NewLine));\n\t\t}\n\t\tif (Pooling && NoDatabaseTriggers)\n\t\t{\n\t\t\tthrow new ArgumentException(\"Cannot use Pooling and NoDatabaseTriggers together.\");\n\t\t}\n\t\tif (ParallelWorkers < 0)\n\t\t{\n\t\t\tthrow new ArgumentException(string.Format(CultureInfo.CurrentCulture, \"'Parallel Workers' value of {0} is not valid.{1}The value should be an integer >= 0.\", ParallelWorkers, Environment.NewLine));\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void Load(string connectionString)\n\t{\n\t\tconst string KeyPairsRegex = \"(([\\\\w\\\\s\\\\d]*)\\\\s*?=\\\\s*?\\\"([^\\\"]*)\\\"|([\\\\w\\\\s\\\\d]*)\\\\s*?=\\\\s*?'([^']*)'|([\\\\w\\\\s\\\\d]*)\\\\s*?=\\\\s*?([^\\\"';][^;]*))\";\n\n\t\tif (!string.IsNullOrEmpty(connectionString))\n\t\t{\n\t\t\tvar keyPairs = Regex.Matches(connectionString, KeyPairsRegex);\n\n\t\t\tforeach (Match keyPair in keyPairs)\n\t\t\t{\n\t\t\t\tif (keyPair.Groups.Count == 8)\n\t\t\t\t{\n\t\t\t\t\tvar values = new string[]\n\t\t\t\t\t{\n\t\t\t\t\t\t\t(keyPair.Groups[2].Success ? keyPair.Groups[2].Value\n\t\t\t\t\t\t\t\t: keyPair.Groups[4].Success ? keyPair.Groups[4].Value\n\t\t\t\t\t\t\t\t\t: keyPair.Groups[6].Success ? keyPair.Groups[6].Value\n\t\t\t\t\t\t\t\t\t\t: string.Empty)\n\t\t\t\t\t\t\t.Trim().ToLowerInvariant(),\n\t\t\t\t\t\t\t(keyPair.Groups[3].Success ? keyPair.Groups[3].Value\n\t\t\t\t\t\t\t\t: keyPair.Groups[5].Success ? keyPair.Groups[5].Value\n\t\t\t\t\t\t\t\t\t: keyPair.Groups[7].Success ? keyPair.Groups[7].Value\n\t\t\t\t\t\t\t\t\t\t: string.Empty)\n\t\t\t\t\t\t\t.Trim()\n\t\t\t\t\t};\n\n\t\t\t\t\tif (values.Length == 2 && !string.IsNullOrEmpty(values[0]) && !string.IsNullOrEmpty(values[1]))\n\t\t\t\t\t{\n\t\t\t\t\t\tif (Synonyms.TryGetValue(values[0], out var key))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tswitch (key)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcase DefaultKeyServerType:\n\t\t\t\t\t\t\t\t\t_options[key] = ParseEnum<FbServerType>(values[1], DefaultKeyServerType);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase DefaultKeyIsolationLevel:\n\t\t\t\t\t\t\t\t\t_options[key] = ParseEnum<IsolationLevel>(values[1], DefaultKeyIsolationLevel);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase DefaultKeyCryptKey:\n\t\t\t\t\t\t\t\t\tvar cryptKey = default(byte[]);\n\t\t\t\t\t\t\t\t\ttry\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcryptKey = Convert.FromBase64String(values[1]);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcatch\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tthrow NotSupported(DefaultKeyCryptKey);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t_options[key] = cryptKey;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase DefaultKeyWireCrypt:\n\t\t\t\t\t\t\t\t\t_options[key] = ParseEnum<FbWireCrypt>(values[1], DefaultKeyWireCrypt);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\t_options[key] = values[1];\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!string.IsNullOrEmpty(Database))\n\t\t\t{\n\t\t\t\tParseConnectionInfo(Database);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void SetDefaultOptions()\n\t{\n\t\t_options = new Dictionary<string, object>(DefaultValues);\n\t}\n\n\t// it is expected the hostname do be at least 2 characters to prevent possible ambiguity (DNET-892)\n\tprivate void ParseConnectionInfo(string connectionInfo)\n\t{\n\t\tconnectionInfo = connectionInfo.Trim();\n\n\t\t{\n\t\t\t// URL style inet://[hostv6]:port/database\n\t\t\tvar match = Regex.Match(connectionInfo, \"^inet://\\\\[(?<host>[A-Za-z0-9:]{2,})\\\\]:(?<port>\\\\d+)/(?<database>.+)$\");\n\t\t\tif (match.Success)\n\t\t\t{\n\t\t\t\t_options[DefaultKeyCatalog] = match.Groups[\"database\"].Value;\n\t\t\t\t_options[DefaultKeyDataSource] = match.Groups[\"host\"].Value;\n\t\t\t\t_options[DefaultKeyPortNumber] = int.Parse(match.Groups[\"port\"].Value, CultureInfo.InvariantCulture);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t{\n\t\t\t// URL style inet://host:port/database\n\t\t\tvar match = Regex.Match(connectionInfo, \"^inet://(?<host>[A-Za-z0-9\\\\.-]{2,}):(?<port>\\\\d+)/(?<database>.+)$\");\n\t\t\tif (match.Success)\n\t\t\t{\n\t\t\t\t_options[DefaultKeyCatalog] = match.Groups[\"database\"].Value;\n\t\t\t\t_options[DefaultKeyDataSource] = match.Groups[\"host\"].Value;\n\t\t\t\t_options[DefaultKeyPortNumber] = int.Parse(match.Groups[\"port\"].Value, CultureInfo.InvariantCulture);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t{\n\t\t\t// URL style inet://host/database\n\t\t\tvar match = Regex.Match(connectionInfo, \"^inet://(?<host>[A-Za-z0-9\\\\.:-]{2,})/(?<database>.+)$\");\n\t\t\tif (match.Success)\n\t\t\t{\n\t\t\t\t_options[DefaultKeyCatalog] = match.Groups[\"database\"].Value;\n\t\t\t\t_options[DefaultKeyDataSource] = match.Groups[\"host\"].Value;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t{\n\t\t\t// URL style inet:///database\n\t\t\tvar match = Regex.Match(connectionInfo, \"^inet:///(?<database>.+)$\");\n\t\t\tif (match.Success)\n\t\t\t{\n\t\t\t\t_options[DefaultKeyCatalog] = match.Groups[\"database\"].Value;\n\t\t\t\t_options[DefaultKeyDataSource] = \"localhost\";\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t{\n\t\t\t// new style //[hostv6]:port/database\n\t\t\tvar match = Regex.Match(connectionInfo, \"^//\\\\[(?<host>[A-Za-z0-9:]{2,})\\\\]:(?<port>\\\\d+)/(?<database>.+)$\");\n\t\t\tif (match.Success)\n\t\t\t{\n\t\t\t\t_options[DefaultKeyCatalog] = match.Groups[\"database\"].Value;\n\t\t\t\t_options[DefaultKeyDataSource] = match.Groups[\"host\"].Value;\n\t\t\t\t_options[DefaultKeyPortNumber] = int.Parse(match.Groups[\"port\"].Value, CultureInfo.InvariantCulture);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t{\n\t\t\t// new style //host:port/database\n\t\t\tvar match = Regex.Match(connectionInfo, \"^//(?<host>[A-Za-z0-9\\\\.-]{2,}):(?<port>\\\\d+)/(?<database>.+)$\");\n\t\t\tif (match.Success)\n\t\t\t{\n\t\t\t\t_options[DefaultKeyCatalog] = match.Groups[\"database\"].Value;\n\t\t\t\t_options[DefaultKeyDataSource] = match.Groups[\"host\"].Value;\n\t\t\t\t_options[DefaultKeyPortNumber] = int.Parse(match.Groups[\"port\"].Value, CultureInfo.InvariantCulture);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t{\n\t\t\t// new style //host/database\n\t\t\tvar match = Regex.Match(connectionInfo, \"^//(?<host>[A-Za-z0-9\\\\.:-]{2,})/(?<database>.+)$\");\n\t\t\tif (match.Success)\n\t\t\t{\n\t\t\t\t_options[DefaultKeyCatalog] = match.Groups[\"database\"].Value;\n\t\t\t\t_options[DefaultKeyDataSource] = match.Groups[\"host\"].Value;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t{\n\t\t\t// old style host:X:\\database\n\t\t\tvar match = Regex.Match(connectionInfo, \"^(?<host>[A-Za-z0-9\\\\.:-]{2,}):(?<database>[A-Za-z]:\\\\\\\\.+)$\");\n\t\t\tif (match.Success)\n\t\t\t{\n\t\t\t\t_options[DefaultKeyCatalog] = match.Groups[\"database\"].Value;\n\t\t\t\t_options[DefaultKeyDataSource] = match.Groups[\"host\"].Value;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t{\n\t\t\t// old style host/port:database\n\t\t\tvar match = Regex.Match(connectionInfo, \"^(?<host>[A-Za-z0-9\\\\.:-]{2,})/(?<port>\\\\d+):(?<database>.+)$\");\n\t\t\tif (match.Success)\n\t\t\t{\n\t\t\t\t_options[DefaultKeyCatalog] = match.Groups[\"database\"].Value;\n\t\t\t\t_options[DefaultKeyDataSource] = match.Groups[\"host\"].Value;\n\t\t\t\t_options[DefaultKeyPortNumber] = int.Parse(match.Groups[\"port\"].Value, CultureInfo.InvariantCulture);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t{\n\t\t\t// old style host:database\n\t\t\tvar match = Regex.Match(connectionInfo, \"^(?<host>[A-Za-z0-9\\\\.:-]{2,}):(?<database>.+)$\");\n\t\t\tif (match.Success)\n\t\t\t{\n\t\t\t\t_options[DefaultKeyCatalog] = match.Groups[\"database\"].Value;\n\t\t\t\t_options[DefaultKeyDataSource] = match.Groups[\"host\"].Value;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t_options[DefaultKeyCatalog] = connectionInfo;\n\t}\n\n\t#endregion\n\n\t#region Internal Static Methods\n\n\tinternal delegate bool TryGetValueDelegate(string key, out object value);\n\n\tinternal static short GetInt16(string key, TryGetValueDelegate tryGetValue, short defaultValue = default)\n\t{\n\t\treturn tryGetValue(key, out var value)\n\t\t\t? Convert.ToInt16(value, CultureInfo.InvariantCulture)\n\t\t\t: defaultValue;\n\t}\n\n\tinternal static int GetInt32(string key, TryGetValueDelegate tryGetValue, int defaultValue = default)\n\t{\n\t\treturn tryGetValue(key, out var value)\n\t\t\t? Convert.ToInt32(value, CultureInfo.InvariantCulture)\n\t\t\t: defaultValue;\n\t}\n\n\tinternal static long GetInt64(string key, TryGetValueDelegate tryGetValue, long defaultValue = default)\n\t{\n\t\treturn tryGetValue(key, out var value)\n\t\t\t? Convert.ToInt64(value, CultureInfo.InvariantCulture)\n\t\t\t: defaultValue;\n\t}\n\n\tinternal static string GetString(string key, TryGetValueDelegate tryGetValue, string defaultValue = default)\n\t{\n\t\treturn tryGetValue(key, out var value)\n\t\t\t? Convert.ToString(value, CultureInfo.InvariantCulture)\n\t\t\t: defaultValue;\n\t}\n\n\tinternal static bool GetBoolean(string key, TryGetValueDelegate tryGetValue, bool defaultValue = default)\n\t{\n\t\treturn tryGetValue(key, out var value)\n\t\t\t? Convert.ToBoolean(value, CultureInfo.InvariantCulture)\n\t\t\t: defaultValue;\n\t}\n\n\tinternal static byte[] GetBytes(string key, TryGetValueDelegate tryGetValue, byte[] defaultValue = default)\n\t{\n\t\treturn tryGetValue(key, out var value)\n\t\t\t? (byte[])value\n\t\t\t: defaultValue;\n\t}\n\n\tinternal static FbServerType GetServerType(string key, TryGetValueDelegate tryGetValue, FbServerType defaultValue = default)\n\t{\n\t\treturn tryGetValue(key, out var value)\n\t\t\t? (FbServerType)value\n\t\t\t: defaultValue;\n\t}\n\n\tinternal static IsolationLevel GetIsolationLevel(string key, TryGetValueDelegate tryGetValue, IsolationLevel defaultValue = default)\n\t{\n\t\treturn tryGetValue(key, out var value)\n\t\t\t? (IsolationLevel)value\n\t\t\t: defaultValue;\n\t}\n\n\tinternal static FbWireCrypt GetWireCrypt(string key, TryGetValueDelegate tryGetValue, FbWireCrypt defaultValue = default)\n\t{\n\t\treturn tryGetValue(key, out var value)\n\t\t\t? (FbWireCrypt)value\n\t\t\t: defaultValue;\n\t}\n\n\t#endregion\n\n\t#region Private Static Methods\n\n\tprivate static string ExpandDataDirectory(string s)\n\t{\n\t\tconst string DataDirectoryKeyword = \"|DataDirectory|\";\n\t\tif (s == null)\n\t\t\treturn s;\n\n\t\tvar dataDirectoryLocation = (string)AppDomain.CurrentDomain.GetData(\"DataDirectory\") ?? string.Empty;\n\t\tvar pattern = string.Format(\"{0}{1}?\", Regex.Escape(DataDirectoryKeyword), Regex.Escape(Path.DirectorySeparatorChar.ToString()));\n\t\treturn Regex.Replace(s, pattern, dataDirectoryLocation + Path.DirectorySeparatorChar, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);\n\t}\n\n\tprivate static T ParseEnum<T>(string value, string name) where T : struct\n\t{\n\t\tif (!Enum.TryParse<T>(value, true, out var result))\n\t\t\tthrow NotSupported(name);\n\t\treturn result;\n\t}\n\n\tprivate static Exception NotSupported(string name) => new NotSupportedException($\"Not supported '{name}'.\");\n\n\tprivate static string WrapValueIfNeeded(string value)\n\t{\n\t\tif (value != null && value.Contains(';'))\n\t\t\treturn \"'\" + value + \"'\";\n\t\treturn value;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/DatabaseBase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal abstract class DatabaseBase\n{\n\tpublic Action<IscException> WarningMessage { get; set; }\n\n\tpublic abstract bool UseUtf8ParameterBuffer { get; }\n\tpublic Encoding ParameterBufferEncoding => UseUtf8ParameterBuffer ? Encoding.UTF8 : Encoding.GetANSIEncoding();\n\n\tpublic abstract int Handle { get; }\n\tpublic Charset Charset { get; }\n\tpublic int PacketSize { get; }\n\tpublic short Dialect { get; }\n\tpublic int TransactionCount { get; set; }\n\tpublic string ServerVersion { get; protected set; }\n\tpublic abstract bool HasRemoteEventSupport { get; }\n\tpublic abstract bool ConnectionBroken { get; }\n\n\tpublic DatabaseBase(Charset charset, int packetSize, short dialect)\n\t{\n\t\tCharset = charset;\n\t\tPacketSize = packetSize;\n\t\tDialect = dialect;\n\t}\n\n\tpublic abstract void Attach(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey);\n\tpublic abstract ValueTask AttachAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default);\n\n\tpublic abstract void AttachWithTrustedAuth(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey);\n\tpublic abstract ValueTask AttachWithTrustedAuthAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default);\n\n\tpublic abstract void Detach();\n\tpublic abstract ValueTask DetachAsync(CancellationToken cancellationToken = default);\n\n\tpublic abstract void CreateDatabase(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey);\n\tpublic abstract ValueTask CreateDatabaseAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default);\n\n\tpublic abstract void CreateDatabaseWithTrustedAuth(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey);\n\tpublic abstract ValueTask CreateDatabaseWithTrustedAuthAsync(DatabaseParameterBufferBase dpb, string database, byte[] cryptKey, CancellationToken cancellationToken = default);\n\n\tpublic abstract void DropDatabase();\n\tpublic abstract ValueTask DropDatabaseAsync(CancellationToken cancellationToken = default);\n\n\tpublic abstract TransactionBase BeginTransaction(TransactionParameterBuffer tpb);\n\tpublic abstract ValueTask<TransactionBase> BeginTransactionAsync(TransactionParameterBuffer tpb, CancellationToken cancellationToken = default);\n\n\tpublic abstract StatementBase CreateStatement();\n\tpublic abstract StatementBase CreateStatement(TransactionBase transaction);\n\n\tpublic abstract DatabaseParameterBufferBase CreateDatabaseParameterBuffer();\n\tpublic abstract EventParameterBuffer CreateEventParameterBuffer();\n\tpublic abstract TransactionParameterBuffer CreateTransactionParameterBuffer();\n\n\tpublic abstract List<object> GetDatabaseInfo(byte[] items);\n\tpublic abstract ValueTask<List<object>> GetDatabaseInfoAsync(byte[] items, CancellationToken cancellationToken = default);\n\n\tpublic abstract List<object> GetDatabaseInfo(byte[] items, int bufferLength);\n\tpublic abstract ValueTask<List<object>> GetDatabaseInfoAsync(byte[] items, int bufferLength, CancellationToken cancellationToken = default);\n\n\tpublic abstract void CloseEventManager();\n\tpublic abstract ValueTask CloseEventManagerAsync(CancellationToken cancellationToken = default);\n\n\tpublic abstract void QueueEvents(RemoteEvent events);\n\tpublic abstract ValueTask QueueEventsAsync(RemoteEvent events, CancellationToken cancellationToken = default);\n\n\tpublic abstract void CancelEvents(RemoteEvent events);\n\tpublic abstract ValueTask CancelEventsAsync(RemoteEvent events, CancellationToken cancellationToken = default);\n\n\tpublic abstract void CancelOperation(short kind);\n\tpublic abstract ValueTask CancelOperationAsync(short kind, CancellationToken cancellationToken = default);\n\n\tpublic string GetServerVersion()\n\t{\n\t\tvar items = new byte[]\n\t\t{\n\t\t\t\tIscCodes.isc_info_firebird_version,\n\t\t\t\tIscCodes.isc_info_end\n\t\t};\n\t\tvar info = GetDatabaseInfo(items, IscCodes.BUFFER_SIZE_256);\n\t\treturn (string)info[info.Count - 1];\n\t}\n\tpublic async ValueTask<string> GetServerVersionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar items = new byte[]\n\t\t{\n\t\t\t\tIscCodes.isc_info_firebird_version,\n\t\t\t\tIscCodes.isc_info_end\n\t\t};\n\t\tvar info = await GetDatabaseInfoAsync(items, IscCodes.BUFFER_SIZE_256, cancellationToken).ConfigureAwait(false);\n\t\treturn (string)info[info.Count - 1];\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/DatabaseParameterBuffer1.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Text;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal sealed class DatabaseParameterBuffer1 : DatabaseParameterBufferBase\n{\n\tpublic DatabaseParameterBuffer1(Encoding encoding)\n\t\t: base(IscCodes.isc_dpb_version1, encoding)\n\t{ }\n\n\tpublic override void Append(int type, byte value)\n\t{\n\t\tWriteByte(type);\n\t\tWriteByte(1);\n\t\tWrite(value);\n\t}\n\n\tpublic override void Append(int type, short value)\n\t{\n\t\tWriteByte(type);\n\t\tWriteByte(2);\n\t\tWrite(value);\n\t}\n\n\tpublic override void Append(int type, int value)\n\t{\n\t\tWriteByte(type);\n\t\tWriteByte(4);\n\t\tWrite(value);\n\t}\n\n\tpublic override void Append(int type, byte[] buffer)\n\t{\n\t\tWriteByte(type);\n\t\tWriteByte(buffer.Length);\n\t\tWrite(buffer);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/DatabaseParameterBuffer2.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Text;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal sealed class DatabaseParameterBuffer2 : DatabaseParameterBufferBase\n{\n\tpublic DatabaseParameterBuffer2(Encoding encoding)\n\t\t: base(IscCodes.isc_dpb_version2, encoding)\n\t{ }\n\n\tpublic override void Append(int type, byte value)\n\t{\n\t\tWriteByte(type);\n\t\tWrite(1);\n\t\tWrite(value);\n\t}\n\n\tpublic override void Append(int type, short value)\n\t{\n\t\tWriteByte(type);\n\t\tWrite(2);\n\t\tWrite(value);\n\t}\n\n\tpublic override void Append(int type, int value)\n\t{\n\t\tWriteByte(type);\n\t\tWrite(4);\n\t\tWrite(value);\n\t}\n\n\tpublic override void Append(int type, byte[] buffer)\n\t{\n\t\tWriteByte(type);\n\t\tWrite(buffer.Length);\n\t\tWrite(buffer);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/DatabaseParameterBufferBase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Text;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal abstract class DatabaseParameterBufferBase : ParameterBuffer\n{\n\tpublic DatabaseParameterBufferBase(int version, Encoding encoding)\n\t{\n\t\tEncoding = encoding;\n\t\tAppend(version);\n\t}\n\n\tpublic abstract void Append(int type, byte value);\n\tpublic abstract void Append(int type, short value);\n\tpublic abstract void Append(int type, int value);\n\tpublic abstract void Append(int type, byte[] buffer);\n\n\tpublic void Append(int type, string content) => Append(type, Encoding.GetBytes(content));\n\n\tpublic Encoding Encoding { get; }\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/DbDataType.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal enum DbDataType\n{\n\tArray,\n\tBigInt,\n\tBinary,\n\tBoolean,\n\tChar,\n\tDate,\n\tDecimal,\n\tDouble,\n\tFloat,\n\tGuid,\n\tInteger,\n\tNumeric,\n\tSmallInt,\n\tText,\n\tTime,\n\tTimeStamp,\n\tVarChar,\n\tTimeStampTZ,\n\tTimeStampTZEx,\n\tTimeTZ,\n\tTimeTZEx,\n\tDec16,\n\tDec34,\n\tInt128,\n\tNull,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/DbField.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Linq;\nusing System.Numerics;\nusing FirebirdSql.Data.Types;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal sealed class DbField\n{\n\t#region Fields\n\n\tprivate short _dataType;\n\tprivate short _numericScale;\n\tprivate short _subType;\n\tprivate short _length;\n\tprivate short _nullFlag;\n\tprivate string _name;\n\tprivate string _relation;\n\tprivate string _owner;\n\tprivate string _alias;\n\tprivate int _charCount;\n\tprivate DbValue _dbValue;\n\tprivate Charset _charset;\n\tprivate ArrayBase _arrayHandle;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic DbDataType DbDataType\n\t{\n\t\tget { return TypeHelper.GetDbDataTypeFromSqlType(SqlType, SubType, NumericScale, Length, Charset); }\n\t}\n\n\tpublic int SqlType\n\t{\n\t\tget { return _dataType & ~1; }\n\t}\n\n\tpublic short DataType\n\t{\n\t\tget { return _dataType; }\n\t\tset { _dataType = value; }\n\t}\n\n\tpublic short NumericScale\n\t{\n\t\tget { return _numericScale; }\n\t\tset { _numericScale = value; }\n\t}\n\n\tpublic short SubType\n\t{\n\t\tget { return _subType; }\n\t\tset\n\t\t{\n\t\t\t_subType = value;\n\t\t\tif (IsCharacter())\n\t\t\t{\n\t\t\t\t// Bits 0-7 of sqlsubtype is charset_id (127 is a special value -\n\t\t\t\t// current attachment charset).\n\t\t\t\t// Bits 8-17 hold collation_id for this value.\n\t\t\t\tvar cs = BitConverter.GetBytes(value);\n\t\t\t\t_charset = Charset.TryGetById(cs[0], out var charset)\n\t\t\t\t\t? charset\n\t\t\t\t\t: Charset.DefaultCharset;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic short Length\n\t{\n\t\tget { return _length; }\n\t\tset\n\t\t{\n\t\t\t_length = value;\n\t\t\tif (IsCharacter())\n\t\t\t{\n\t\t\t\t_charCount = _length / _charset.BytesPerCharacter;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic short NullFlag\n\t{\n\t\tget { return _nullFlag; }\n\t\tset { _nullFlag = value; }\n\t}\n\n\tpublic string Name\n\t{\n\t\tget { return _name; }\n\t\tset { _name = value.Trim(); }\n\t}\n\n\tpublic string Relation\n\t{\n\t\tget { return _relation; }\n\t\tset { _relation = value.Trim(); }\n\t}\n\n\tpublic string Owner\n\t{\n\t\tget { return _owner; }\n\t\tset { _owner = value.Trim(); }\n\t}\n\n\tpublic string Alias\n\t{\n\t\tget { return _alias; }\n\t\tset { _alias = value.Trim(); }\n\t}\n\n\tpublic Charset Charset\n\t{\n\t\tget { return _charset; }\n\t}\n\n\tpublic int CharCount\n\t{\n\t\tget { return _charCount; }\n\t}\n\n\tpublic ArrayBase ArrayHandle\n\t{\n\t\tget\n\t\t{\n\t\t\tEnsureArray();\n\t\t\treturn _arrayHandle;\n\t\t}\n\n\t\tset\n\t\t{\n\t\t\tEnsureArray();\n\t\t\t_arrayHandle = value;\n\t\t}\n\t}\n\n\tpublic DbValue DbValue\n\t{\n\t\tget { return _dbValue; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic DbField()\n\t{\n\t\t_charCount = -1;\n\t\t_name = string.Empty;\n\t\t_relation = string.Empty;\n\t\t_owner = string.Empty;\n\t\t_alias = string.Empty;\n\t\t_dbValue = new DbValue(this, DBNull.Value);\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic bool IsNumeric()\n\t{\n\t\tif (_dataType == 0)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\n\t\tswitch (DbDataType)\n\t\t{\n\t\t\tcase DbDataType.SmallInt:\n\t\t\tcase DbDataType.Integer:\n\t\t\tcase DbDataType.BigInt:\n\t\t\tcase DbDataType.Numeric:\n\t\t\tcase DbDataType.Decimal:\n\t\t\tcase DbDataType.Float:\n\t\t\tcase DbDataType.Double:\n\t\t\t\treturn true;\n\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tpublic bool IsDecimal()\n\t{\n\t\tif (_dataType == 0)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\n\t\tswitch (DbDataType)\n\t\t{\n\t\t\tcase DbDataType.Numeric:\n\t\t\tcase DbDataType.Decimal:\n\t\t\t\treturn true;\n\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tpublic bool IsLong()\n\t{\n\t\tif (_dataType == 0)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\n\t\tswitch (DbDataType)\n\t\t{\n\t\t\tcase DbDataType.Binary:\n\t\t\tcase DbDataType.Text:\n\t\t\t\treturn true;\n\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tpublic bool IsCharacter()\n\t{\n\t\tif (_dataType == 0)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\n\t\tswitch (DbDataType)\n\t\t{\n\t\t\tcase DbDataType.Char:\n\t\t\tcase DbDataType.VarChar:\n\t\t\tcase DbDataType.Text:\n\t\t\t\treturn true;\n\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tpublic bool IsArray()\n\t{\n\t\tif (_dataType == 0)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\n\t\tswitch (DbDataType)\n\t\t{\n\t\t\tcase DbDataType.Array:\n\t\t\t\treturn true;\n\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tpublic bool IsAliased()\n\t{\n\t\treturn (Name != Alias) ? true : false;\n\t}\n\n\tpublic int GetSize()\n\t{\n\t\tif (IsLong())\n\t\t{\n\t\t\treturn int.MaxValue;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (IsCharacter())\n\t\t\t{\n\t\t\t\treturn CharCount;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn Length;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic bool AllowDBNull()\n\t{\n\t\treturn ((DataType & 1) == 1);\n\t}\n\n\tpublic void SetValue(byte[] buffer)\n\t{\n\t\tif (buffer == null || NullFlag == -1)\n\t\t{\n\t\t\tDbValue.SetValue(DBNull.Value);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tswitch (SqlType)\n\t\t\t{\n\t\t\t\tcase IscCodes.SQL_TEXT:\n\t\t\t\tcase IscCodes.SQL_VARYING:\n\t\t\t\t\tif (DbDataType == DbDataType.Guid)\n\t\t\t\t\t{\n\t\t\t\t\t\tDbValue.SetValue(TypeDecoder.DecodeGuid(buffer));\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif (Charset.IsOctetsCharset)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tDbValue.SetValue(buffer);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvar s = Charset.GetString(buffer, 0, buffer.Length);\n\n\t\t\t\t\t\t\tvar runes = s.EnumerateRunesToChars().ToList();\n\t\t\t\t\t\t\tif ((Length % Charset.BytesPerCharacter) == 0 &&\n\t\t\t\t\t\t\t\trunes.Count > CharCount)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ts = new string([.. runes.Take(CharCount).SelectMany(x => x)]);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tDbValue.SetValue(s);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.SQL_SHORT:\n\t\t\t\t\tif (_numericScale < 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tDbValue.SetValue(TypeDecoder.DecodeDecimal(BitConverter.ToInt16(buffer, 0), _numericScale, _dataType));\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tDbValue.SetValue(BitConverter.ToInt16(buffer, 0));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.SQL_LONG:\n\t\t\t\t\tif (_numericScale < 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tDbValue.SetValue(TypeDecoder.DecodeDecimal(BitConverter.ToInt32(buffer, 0), _numericScale, _dataType));\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tDbValue.SetValue(BitConverter.ToInt32(buffer, 0));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.SQL_FLOAT:\n\t\t\t\t\tDbValue.SetValue(BitConverter.ToSingle(buffer, 0));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.SQL_DOUBLE:\n\t\t\t\tcase IscCodes.SQL_D_FLOAT:\n\t\t\t\t\tDbValue.SetValue(BitConverter.ToDouble(buffer, 0));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.SQL_QUAD:\n\t\t\t\tcase IscCodes.SQL_INT64:\n\t\t\t\tcase IscCodes.SQL_BLOB:\n\t\t\t\tcase IscCodes.SQL_ARRAY:\n\t\t\t\t\tif (_numericScale < 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tDbValue.SetValue(TypeDecoder.DecodeDecimal(BitConverter.ToInt64(buffer, 0), _numericScale, _dataType));\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tDbValue.SetValue(BitConverter.ToInt64(buffer, 0));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.SQL_TIMESTAMP:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar date = TypeDecoder.DecodeDate(BitConverter.ToInt32(buffer, 0));\n\t\t\t\t\t\tvar time = TypeDecoder.DecodeTime(BitConverter.ToInt32(buffer, 4));\n\t\t\t\t\t\tDbValue.SetValue(date.Add(time));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.SQL_TYPE_TIME:\n\t\t\t\t\tDbValue.SetValue(TypeDecoder.DecodeTime(BitConverter.ToInt32(buffer, 0)));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.SQL_TYPE_DATE:\n\t\t\t\t\tDbValue.SetValue(TypeDecoder.DecodeDate(BitConverter.ToInt32(buffer, 0)));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.SQL_BOOLEAN:\n\t\t\t\t\tDbValue.SetValue(TypeDecoder.DecodeBoolean(buffer));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.SQL_TIMESTAMP_TZ:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar date = TypeDecoder.DecodeDate(BitConverter.ToInt32(buffer, 0));\n\t\t\t\t\t\tvar time = TypeDecoder.DecodeTime(BitConverter.ToInt32(buffer, 4));\n\t\t\t\t\t\tvar tzId = BitConverter.ToUInt16(buffer, 8);\n\t\t\t\t\t\tvar dt = DateTime.SpecifyKind(date.Add(time), DateTimeKind.Utc);\n\t\t\t\t\t\tDbValue.SetValue(TypeHelper.CreateZonedDateTime(dt, tzId, null));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.SQL_TIMESTAMP_TZ_EX:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar date = TypeDecoder.DecodeDate(BitConverter.ToInt32(buffer, 0));\n\t\t\t\t\t\tvar time = TypeDecoder.DecodeTime(BitConverter.ToInt32(buffer, 4));\n\t\t\t\t\t\tvar tzId = BitConverter.ToUInt16(buffer, 8);\n\t\t\t\t\t\tvar offset = BitConverter.ToInt16(buffer, 10);\n\t\t\t\t\t\tvar dt = DateTime.SpecifyKind(date.Add(time), DateTimeKind.Utc);\n\t\t\t\t\t\tDbValue.SetValue(TypeHelper.CreateZonedDateTime(dt, tzId, offset));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.SQL_TIME_TZ:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar time = TypeDecoder.DecodeTime(BitConverter.ToInt32(buffer, 0));\n\t\t\t\t\t\tvar tzId = BitConverter.ToUInt16(buffer, 4);\n\t\t\t\t\t\tDbValue.SetValue(TypeHelper.CreateZonedTime(time, tzId, null));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.SQL_TIME_TZ_EX:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar time = TypeDecoder.DecodeTime(BitConverter.ToInt32(buffer, 0));\n\t\t\t\t\t\tvar tzId = BitConverter.ToUInt16(buffer, 4);\n\t\t\t\t\t\tvar offset = BitConverter.ToInt16(buffer, 6);\n\t\t\t\t\t\tDbValue.SetValue(TypeHelper.CreateZonedTime(time, tzId, offset));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.SQL_DEC16:\n\t\t\t\t\tDbValue.SetValue(DecimalCodec.DecFloat16.ParseBytes(buffer));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.SQL_DEC34:\n\t\t\t\t\tDbValue.SetValue(DecimalCodec.DecFloat34.ParseBytes(buffer));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.SQL_INT128:\n\t\t\t\t\tif (_numericScale < 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tDbValue.SetValue(TypeDecoder.DecodeDecimal(Int128Helper.GetInt128(buffer), _numericScale, _dataType));\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tDbValue.SetValue(Int128Helper.GetInt128(buffer));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow TypeHelper.InvalidDataType(SqlType);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic void FixNull()\n\t{\n\t\tif (NullFlag == -1 && _dbValue.IsDBNull())\n\t\t{\n\t\t\tswitch (DbDataType)\n\t\t\t{\n\t\t\t\tcase DbDataType.Char:\n\t\t\t\tcase DbDataType.VarChar:\n\t\t\t\t\tDbValue.SetValue(string.Empty);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Guid:\n\t\t\t\t\tDbValue.SetValue(Guid.Empty);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.SmallInt:\n\t\t\t\t\tDbValue.SetValue((short)0);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Integer:\n\t\t\t\t\tDbValue.SetValue((int)0);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.BigInt:\n\t\t\t\tcase DbDataType.Binary:\n\t\t\t\tcase DbDataType.Array:\n\t\t\t\tcase DbDataType.Text:\n\t\t\t\t\tDbValue.SetValue((long)0);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Numeric:\n\t\t\t\tcase DbDataType.Decimal:\n\t\t\t\t\tDbValue.SetValue((decimal)0);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Float:\n\t\t\t\t\tDbValue.SetValue((float)0);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Double:\n\t\t\t\t\tDbValue.SetValue((double)0);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Date:\n\t\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\t\tDbValue.SetValue(DateTime.UnixEpoch);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Time:\n\t\t\t\t\tDbValue.SetValue(TimeSpan.Zero);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Boolean:\n\t\t\t\t\tDbValue.SetValue(false);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.TimeStampTZ:\n\t\t\t\tcase DbDataType.TimeStampTZEx:\n\t\t\t\t\tDbValue.SetValue(new FbZonedDateTime(DateTime.UnixEpoch, TimeZoneMapping.DefaultTimeZoneName));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.TimeTZ:\n\t\t\t\tcase DbDataType.TimeTZEx:\n\t\t\t\t\tDbValue.SetValue(new FbZonedTime(TimeSpan.Zero, TimeZoneMapping.DefaultTimeZoneName));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Dec16:\n\t\t\t\tcase DbDataType.Dec34:\n\t\t\t\t\tDbValue.SetValue(new FbDecFloat(0, 0));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DbDataType.Int128:\n\t\t\t\t\tDbValue.SetValue((BigInteger)0);\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow IscException.ForStrParam($\"Unknown sql data type: {DataType}.\");\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic Type GetSystemType()\n\t{\n\t\treturn TypeHelper.GetTypeFromDbDataType(DbDataType);\n\t}\n\n\tpublic bool HasDataType()\n\t{\n\t\treturn _dataType != 0;\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void EnsureArray()\n\t{\n\t\tif (!IsArray())\n\t\t\tthrow IscException.ForStrParam(\"Field is not an array type.\");\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/DbStatementType.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal enum DbStatementType : int\n{\n\tNone = 0,\n\tSelect = IscCodes.isc_info_sql_stmt_select,\n\tInsert = IscCodes.isc_info_sql_stmt_insert,\n\tUpdate = IscCodes.isc_info_sql_stmt_update,\n\tDelete = IscCodes.isc_info_sql_stmt_delete,\n\tDDL = IscCodes.isc_info_sql_stmt_ddl,\n\tGetSegment = IscCodes.isc_info_sql_stmt_get_segment,\n\tPutSegment = IscCodes.isc_info_sql_stmt_put_segment,\n\tStoredProcedure = IscCodes.isc_info_sql_stmt_exec_procedure,\n\tStartTrans = IscCodes.isc_info_sql_stmt_start_trans,\n\tCommit = IscCodes.isc_info_sql_stmt_commit,\n\tRollback = IscCodes.isc_info_sql_stmt_rollback,\n\tSelectForUpdate = IscCodes.isc_info_sql_stmt_select_for_upd,\n\tSetGenerator = IscCodes.isc_info_sql_stmt_set_generator,\n\tSavePoint = IscCodes.isc_info_sql_stmt_savepoint\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/DbValue.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Globalization;\nusing System.Linq;\nusing System.Numerics;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.FirebirdClient;\nusing FirebirdSql.Data.Types;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal sealed class DbValue\n{\n\tprivate StatementBase _statement;\n\tprivate DbField _field;\n\tprivate object _value;\n\n\tpublic DbField Field\n\t{\n\t\tget { return _field; }\n\t}\n\n\tpublic DbValue(DbField field, object value)\n\t{\n\t\t_field = field;\n\t\t_value = value ?? DBNull.Value;\n\t}\n\n\tpublic DbValue(StatementBase statement, DbField field, object value)\n\t{\n\t\t_statement = statement;\n\t\t_field = field;\n\t\t_value = value ?? DBNull.Value;\n\t}\n\n\tpublic bool IsDBNull()\n\t{\n\t\treturn TypeHelper.IsDBNull(_value);\n\t}\n\n\tpublic object GetValue()\n\t{\n\t\tif (IsDBNull())\n\t\t{\n\t\t\treturn DBNull.Value;\n\t\t}\n\n\t\tswitch (_field.DbDataType)\n\t\t{\n\t\t\tcase DbDataType.Text:\n\t\t\t\tif (_statement == null)\n\t\t\t\t{\n\t\t\t\t\treturn GetInt64();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn GetString();\n\t\t\t\t}\n\n\t\t\tcase DbDataType.Binary:\n\t\t\t\tif (_statement == null)\n\t\t\t\t{\n\t\t\t\t\treturn GetInt64();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn GetBinary();\n\t\t\t\t}\n\n\t\t\tcase DbDataType.Array:\n\t\t\t\tif (_statement == null)\n\t\t\t\t{\n\t\t\t\t\treturn GetInt64();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn GetArray();\n\t\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\treturn _value;\n\t\t}\n\t}\n\tpublic async ValueTask<object> GetValueAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (IsDBNull())\n\t\t{\n\t\t\treturn DBNull.Value;\n\t\t}\n\n\t\tswitch (_field.DbDataType)\n\t\t{\n\t\t\tcase DbDataType.Text:\n\t\t\t\tif (_statement == null)\n\t\t\t\t{\n\t\t\t\t\treturn GetInt64();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn await GetStringAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\n\t\t\tcase DbDataType.Binary:\n\t\t\t\tif (_statement == null)\n\t\t\t\t{\n\t\t\t\t\treturn GetInt64();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn await GetBinaryAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\n\t\t\tcase DbDataType.Array:\n\t\t\t\tif (_statement == null)\n\t\t\t\t{\n\t\t\t\t\treturn GetInt64();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn await GetArrayAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\treturn _value;\n\t\t}\n\t}\n\n\tpublic void SetValue(object value)\n\t{\n\t\t_value = value;\n\t}\n\n\tpublic string GetString()\n\t{\n\t\tif (Field.DbDataType == DbDataType.Text && _value is long l)\n\t\t{\n\t\t\t_value = GetClobData(l);\n\t\t}\n\n\t\tif (_value is byte[] bytes)\n\t\t{\n\t\t\treturn Field.Charset.GetString(bytes);\n\t\t}\n\t\treturn _value.ToString();\n\t}\n\tpublic async ValueTask<string> GetStringAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (Field.DbDataType == DbDataType.Text && _value is long l)\n\t\t{\n\t\t\t_value = await GetClobDataAsync(l, cancellationToken).ConfigureAwait(false);\n\t\t}\n\n\t\tif (_value is byte[] bytes)\n\t\t{\n\t\t\treturn Field.Charset.GetString(bytes);\n\t\t}\n\t\treturn _value.ToString();\n\t}\n\n\tpublic char GetChar()\n\t{\n\t\treturn Convert.ToChar(_value, CultureInfo.CurrentCulture);\n\t}\n\n\tpublic bool GetBoolean()\n\t{\n\t\treturn Convert.ToBoolean(_value, CultureInfo.InvariantCulture);\n\t}\n\n\tpublic byte GetByte()\n\t{\n\t\treturn _value switch\n\t\t{\n\t\t\tBigInteger bi => (byte)bi,\n\t\t\t_ => Convert.ToByte(_value, CultureInfo.InvariantCulture),\n\t\t};\n\t}\n\n\tpublic short GetInt16()\n\t{\n\t\treturn _value switch\n\t\t{\n\t\t\tBigInteger bi => (short)bi,\n\t\t\t_ => Convert.ToInt16(_value, CultureInfo.InvariantCulture),\n\t\t};\n\t}\n\n\tpublic int GetInt32()\n\t{\n\t\treturn _value switch\n\t\t{\n\t\t\tBigInteger bi => (int)bi,\n\t\t\t_ => Convert.ToInt32(_value, CultureInfo.InvariantCulture),\n\t\t};\n\t}\n\n\tpublic long GetInt64()\n\t{\n\t\treturn _value switch\n\t\t{\n\t\t\tBigInteger bi => (long)bi,\n\t\t\t_ => Convert.ToInt64(_value, CultureInfo.InvariantCulture),\n\t\t};\n\t}\n\n\tpublic decimal GetDecimal()\n\t{\n\t\treturn Convert.ToDecimal(_value, CultureInfo.InvariantCulture);\n\t}\n\n\tpublic float GetFloat()\n\t{\n\t\treturn Convert.ToSingle(_value, CultureInfo.InvariantCulture);\n\t}\n\n\tpublic Guid GetGuid()\n\t{\n\t\treturn _value switch\n\t\t{\n\t\t\tGuid guid => guid,\n\t\t\tbyte[] bytes => TypeDecoder.DecodeGuid(bytes),\n\t\t\t_ => throw new InvalidOperationException($\"Incorrect {nameof(Guid)} value.\"),\n\t\t};\n\t}\n\n\tpublic double GetDouble()\n\t{\n\t\treturn Convert.ToDouble(_value, CultureInfo.InvariantCulture);\n\t}\n\n\tpublic DateTime GetDateTime()\n\t{\n\t\treturn _value switch\n\t\t{\n\t\t\tDateTimeOffset dto => dto.DateTime,\n\t\t\tFbZonedDateTime zdt => zdt.DateTime,\n\t\t\t_ => Convert.ToDateTime(_value, CultureInfo.CurrentCulture.DateTimeFormat),\n\t\t};\n\t}\n\n\tpublic TimeSpan GetTimeSpan()\n\t{\n\t\treturn (TimeSpan)_value;\n\t}\n\n\tpublic FbDecFloat GetDecFloat()\n\t{\n\t\treturn (FbDecFloat)_value;\n\t}\n\n\tpublic BigInteger GetInt128()\n\t{\n\t\treturn _value switch\n\t\t{\n\t\t\tbyte b => b,\n\t\t\tshort s => s,\n\t\t\tint i => i,\n\t\t\tlong l => l,\n\t\t\t_ => (BigInteger)_value,\n\t\t};\n\t}\n\n\tpublic FbZonedDateTime GetZonedDateTime()\n\t{\n\t\treturn (FbZonedDateTime)_value;\n\t}\n\n\tpublic FbZonedTime GetZonedTime()\n\t{\n\t\treturn (FbZonedTime)_value;\n\t}\n\n\tpublic Array GetArray()\n\t{\n\t\tif (_value is long l)\n\t\t{\n\t\t\t_value = GetArrayData(l);\n\t\t}\n\n\t\treturn (Array)_value;\n\t}\n\tpublic async ValueTask<Array> GetArrayAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_value is long l)\n\t\t{\n\t\t\t_value = await GetArrayDataAsync(l, cancellationToken).ConfigureAwait(false);\n\t\t}\n\n\t\treturn (Array)_value;\n\t}\n\n\tpublic byte[] GetBinary()\n\t{\n\t\tif (_value is long l)\n\t\t{\n\t\t\t_value = GetBlobData(l);\n\t\t}\n\t\tif (_value is Guid guid)\n\t\t{\n\t\t\treturn TypeEncoder.EncodeGuid(guid);\n\t\t}\n\n\t\treturn (byte[])_value;\n\t}\n\tpublic async ValueTask<byte[]> GetBinaryAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_value is long l)\n\t\t{\n\t\t\t_value = await GetBlobDataAsync(l, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tif (_value is Guid guid)\n\t\t{\n\t\t\treturn TypeEncoder.EncodeGuid(guid);\n\t\t}\n\n\t\treturn (byte[])_value;\n\t}\n\n\tpublic BlobStream GetBinaryStream()\n\t{\n\t\tif (_value is not long l)\n\t\t\tthrow new NotSupportedException();\n\n\t\treturn GetBlobStream(l);\n\t}\n\tpublic ValueTask<BlobStream> GetBinaryStreamAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_value is not long l)\n\t\t\tthrow new NotSupportedException();\n\n\t\treturn GetBlobStreamAsync(l, cancellationToken);\n\t}\n\n\tpublic int GetDate()\n\t{\n\t\treturn _value switch\n\t\t{\n\t\t\tDateOnly @do => TypeEncoder.EncodeDate(@do),\n\t\t\t_ => TypeEncoder.EncodeDate(GetDateTime()),\n\t\t};\n\t}\n\n\tpublic int GetTime()\n\t{\n\t\treturn _value switch\n\t\t{\n\t\t\tTimeSpan ts => TypeEncoder.EncodeTime(ts),\n\t\t\tFbZonedTime zt => TypeEncoder.EncodeTime(zt.Time),\n\t\t\tTimeOnly to => TypeEncoder.EncodeTime(to),\n\t\t\t_ => TypeEncoder.EncodeTime(TypeHelper.DateTimeTimeToTimeSpan(GetDateTime())),\n\t\t};\n\t}\n\n\tpublic ushort GetTimeZoneId()\n\t{\n\t\t{\n\t\t\tif (_value is FbZonedDateTime zdt && TimeZoneMapping.TryGetByName(zdt.TimeZone, out var id))\n\t\t\t{\n\t\t\t\treturn id;\n\t\t\t}\n\t\t}\n\t\t{\n\t\t\tif (_value is FbZonedTime zt && TimeZoneMapping.TryGetByName(zt.TimeZone, out var id))\n\t\t\t{\n\t\t\t\treturn id;\n\t\t\t}\n\t\t}\n\t\tthrow new InvalidOperationException($\"Incorrect time zone value.\");\n\t}\n\n\tpublic byte[] GetBytes()\n\t{\n\t\tif (IsDBNull())\n\t\t{\n\t\t\tint length = _field.Length;\n\n\t\t\tif (Field.SqlType == IscCodes.SQL_VARYING)\n\t\t\t{\n\t\t\t\t// Add two bytes more for store\tvalue length\n\t\t\t\tlength += 2;\n\t\t\t}\n\n\t\t\treturn new byte[length];\n\t\t}\n\n\n\t\tswitch (Field.DbDataType)\n\t\t{\n\t\t\tcase DbDataType.Char:\n\t\t\t\t{\n\t\t\t\t\tvar buffer = new byte[Field.Length];\n\t\t\t\t\tbyte[] bytes;\n\n\t\t\t\t\tif (Field.Charset.IsOctetsCharset)\n\t\t\t\t\t{\n\t\t\t\t\t\tbytes = GetBinary();\n\t\t\t\t\t}\n\t\t\t\t\telse if (Field.Charset.IsNoneCharset)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar bvalue = Field.Charset.GetBytes(GetString());\n\t\t\t\t\t\tif (bvalue.Length > Field.Length)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow IscException.ForErrorCodes(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbytes = bvalue;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tvar svalue = GetString();\n\t\t\t\t\t\tif ((Field.Length % Field.Charset.BytesPerCharacter) == 0 && svalue.EnumerateRunesToChars().Count() > Field.CharCount)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow IscException.ForErrorCodes(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbytes = Field.Charset.GetBytes(svalue);\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (var i = 0; i < buffer.Length; i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tbuffer[i] = (byte)' ';\n\t\t\t\t\t}\n\t\t\t\t\tBuffer.BlockCopy(bytes, 0, buffer, 0, bytes.Length);\n\t\t\t\t\treturn buffer;\n\t\t\t\t}\n\n\t\t\tcase DbDataType.VarChar:\n\t\t\t\t{\n\t\t\t\t\tvar buffer = new byte[Field.Length + 2];\n\t\t\t\t\tbyte[] bytes;\n\n\t\t\t\t\tif (Field.Charset.IsOctetsCharset)\n\t\t\t\t\t{\n\t\t\t\t\t\tbytes = GetBinary();\n\t\t\t\t\t}\n\t\t\t\t\telse if (Field.Charset.IsNoneCharset)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar bvalue = Field.Charset.GetBytes(GetString());\n\t\t\t\t\t\tif (bvalue.Length > Field.Length)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow IscException.ForErrorCodes(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbytes = bvalue;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tvar svalue = GetString();\n\t\t\t\t\t\tif ((Field.Length % Field.Charset.BytesPerCharacter) == 0 && svalue.EnumerateRunesToChars().Count() > Field.CharCount)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow IscException.ForErrorCodes(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbytes = Field.Charset.GetBytes(svalue);\n\t\t\t\t\t}\n\n\t\t\t\t\tBuffer.BlockCopy(BitConverter.GetBytes((short)bytes.Length), 0, buffer, 0, 2);\n\t\t\t\t\tBuffer.BlockCopy(bytes, 0, buffer, 2, bytes.Length);\n\t\t\t\t\treturn buffer;\n\t\t\t\t}\n\n\t\t\tcase DbDataType.Numeric:\n\t\t\tcase DbDataType.Decimal:\n\t\t\t\treturn GetNumericBytes();\n\n\t\t\tcase DbDataType.SmallInt:\n\t\t\t\treturn BitConverter.GetBytes(GetInt16());\n\n\t\t\tcase DbDataType.Integer:\n\t\t\t\treturn BitConverter.GetBytes(GetInt32());\n\n\t\t\tcase DbDataType.Array:\n\t\t\tcase DbDataType.Binary:\n\t\t\tcase DbDataType.Text:\n\t\t\tcase DbDataType.BigInt:\n\t\t\t\treturn BitConverter.GetBytes(GetInt64());\n\n\t\t\tcase DbDataType.Float:\n\t\t\t\treturn BitConverter.GetBytes(GetFloat());\n\n\t\t\tcase DbDataType.Double:\n\t\t\t\treturn BitConverter.GetBytes(GetDouble());\n\n\t\t\tcase DbDataType.Date:\n\t\t\t\treturn BitConverter.GetBytes(GetDate());\n\n\t\t\tcase DbDataType.Time:\n\t\t\t\treturn BitConverter.GetBytes(GetTime());\n\n\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\t{\n\t\t\t\t\tvar dt = GetDateTime();\n\t\t\t\t\tvar date = BitConverter.GetBytes(TypeEncoder.EncodeDate(dt));\n\t\t\t\t\tvar time = BitConverter.GetBytes(TypeEncoder.EncodeTime(TypeHelper.DateTimeTimeToTimeSpan(dt)));\n\n\t\t\t\t\tvar result = new byte[8];\n\t\t\t\t\tBuffer.BlockCopy(date, 0, result, 0, date.Length);\n\t\t\t\t\tBuffer.BlockCopy(time, 0, result, 4, time.Length);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\tcase DbDataType.Guid:\n\t\t\t\t{\n\t\t\t\t\tvar bytes = TypeEncoder.EncodeGuid(GetGuid());\n\t\t\t\t\tbyte[] buffer;\n\t\t\t\t\tif (Field.SqlType == IscCodes.SQL_VARYING)\n\t\t\t\t\t{\n\t\t\t\t\t\tbuffer = new byte[bytes.Length + 2];\n\t\t\t\t\t\tBuffer.BlockCopy(BitConverter.GetBytes((short)bytes.Length), 0, buffer, 0, 2);\n\t\t\t\t\t\tBuffer.BlockCopy(bytes, 0, buffer, 2, bytes.Length);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tbuffer = new byte[bytes.Length];\n\t\t\t\t\t\tBuffer.BlockCopy(bytes, 0, buffer, 0, bytes.Length);\n\t\t\t\t\t}\n\t\t\t\t\treturn buffer;\n\t\t\t\t}\n\n\t\t\tcase DbDataType.Boolean:\n\t\t\t\treturn BitConverter.GetBytes(GetBoolean());\n\n\t\t\tcase DbDataType.TimeStampTZ:\n\t\t\t\t{\n\t\t\t\t\tvar dt = GetDateTime();\n\t\t\t\t\tvar date = BitConverter.GetBytes(TypeEncoder.EncodeDate(dt));\n\t\t\t\t\tvar time = BitConverter.GetBytes(TypeEncoder.EncodeTime(TypeHelper.DateTimeTimeToTimeSpan(dt)));\n\t\t\t\t\tvar tzId = BitConverter.GetBytes(GetTimeZoneId());\n\n\t\t\t\t\tvar result = new byte[10];\n\t\t\t\t\tBuffer.BlockCopy(date, 0, result, 0, date.Length);\n\t\t\t\t\tBuffer.BlockCopy(time, 0, result, 4, time.Length);\n\t\t\t\t\tBuffer.BlockCopy(tzId, 0, result, 8, tzId.Length);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\tcase DbDataType.TimeStampTZEx:\n\t\t\t\t{\n\t\t\t\t\tvar dt = GetDateTime();\n\t\t\t\t\tvar date = BitConverter.GetBytes(TypeEncoder.EncodeDate(dt));\n\t\t\t\t\tvar time = BitConverter.GetBytes(TypeEncoder.EncodeTime(TypeHelper.DateTimeTimeToTimeSpan(dt)));\n\t\t\t\t\tvar tzId = BitConverter.GetBytes(GetTimeZoneId());\n\t\t\t\t\tvar offset = new byte[] { 0, 0 };\n\n\t\t\t\t\tvar result = new byte[12];\n\t\t\t\t\tBuffer.BlockCopy(date, 0, result, 0, date.Length);\n\t\t\t\t\tBuffer.BlockCopy(time, 0, result, 4, time.Length);\n\t\t\t\t\tBuffer.BlockCopy(tzId, 0, result, 8, tzId.Length);\n\t\t\t\t\tBuffer.BlockCopy(offset, 0, result, 10, offset.Length);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\tcase DbDataType.TimeTZ:\n\t\t\t\t{\n\t\t\t\t\tvar time = BitConverter.GetBytes(GetTime());\n\t\t\t\t\tvar tzId = BitConverter.GetBytes(GetTimeZoneId());\n\n\t\t\t\t\tvar result = new byte[6];\n\t\t\t\t\tBuffer.BlockCopy(time, 0, result, 0, time.Length);\n\t\t\t\t\tBuffer.BlockCopy(tzId, 0, result, 4, tzId.Length);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\tcase DbDataType.TimeTZEx:\n\t\t\t\t{\n\t\t\t\t\tvar time = BitConverter.GetBytes(GetTime());\n\t\t\t\t\tvar tzId = BitConverter.GetBytes(GetTimeZoneId());\n\t\t\t\t\tvar offset = new byte[] { 0, 0 };\n\n\t\t\t\t\tvar result = new byte[8];\n\t\t\t\t\tBuffer.BlockCopy(time, 0, result, 0, time.Length);\n\t\t\t\t\tBuffer.BlockCopy(tzId, 0, result, 4, tzId.Length);\n\t\t\t\t\tBuffer.BlockCopy(offset, 0, result, 6, offset.Length);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\tcase DbDataType.Dec16:\n\t\t\t\treturn DecimalCodec.DecFloat16.EncodeDecimal(GetDecFloat());\n\n\t\t\tcase DbDataType.Dec34:\n\t\t\t\treturn DecimalCodec.DecFloat34.EncodeDecimal(GetDecFloat());\n\n\t\t\tcase DbDataType.Int128:\n\t\t\t\treturn Int128Helper.GetBytes(GetInt128());\n\n\t\t\tdefault:\n\t\t\t\tthrow TypeHelper.InvalidDataType((int)Field.DbDataType);\n\t\t}\n\t}\n\tpublic async ValueTask<byte[]> GetBytesAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (IsDBNull())\n\t\t{\n\t\t\tint length = _field.Length;\n\n\t\t\tif (Field.SqlType == IscCodes.SQL_VARYING)\n\t\t\t{\n\t\t\t\t// Add two bytes more for store\tvalue length\n\t\t\t\tlength += 2;\n\t\t\t}\n\n\t\t\treturn new byte[length];\n\t\t}\n\n\n\t\tswitch (Field.DbDataType)\n\t\t{\n\t\t\tcase DbDataType.Char:\n\t\t\t\t{\n\t\t\t\t\tvar buffer = new byte[Field.Length];\n\t\t\t\t\tbyte[] bytes;\n\n\t\t\t\t\tif (Field.Charset.IsOctetsCharset)\n\t\t\t\t\t{\n\t\t\t\t\t\tbytes = await GetBinaryAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t}\n\t\t\t\t\telse if (Field.Charset.IsNoneCharset)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar bvalue = Field.Charset.GetBytes(await GetStringAsync(cancellationToken).ConfigureAwait(false));\n\t\t\t\t\t\tif (bvalue.Length > Field.Length)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow IscException.ForErrorCodes(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbytes = bvalue;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tvar svalue = await GetStringAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\tif ((Field.Length % Field.Charset.BytesPerCharacter) == 0 && svalue.EnumerateRunesToChars().Count() > Field.CharCount)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow IscException.ForErrorCodes(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbytes = Field.Charset.GetBytes(svalue);\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (var i = 0; i < buffer.Length; i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tbuffer[i] = (byte)' ';\n\t\t\t\t\t}\n\t\t\t\t\tBuffer.BlockCopy(bytes, 0, buffer, 0, bytes.Length);\n\t\t\t\t\treturn buffer;\n\t\t\t\t}\n\n\t\t\tcase DbDataType.VarChar:\n\t\t\t\t{\n\t\t\t\t\tvar buffer = new byte[Field.Length + 2];\n\t\t\t\t\tbyte[] bytes;\n\n\t\t\t\t\tif (Field.Charset.IsOctetsCharset)\n\t\t\t\t\t{\n\t\t\t\t\t\tbytes = await GetBinaryAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t}\n\t\t\t\t\telse if (Field.Charset.IsNoneCharset)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar bvalue = Field.Charset.GetBytes(await GetStringAsync(cancellationToken).ConfigureAwait(false));\n\t\t\t\t\t\tif (bvalue.Length > Field.Length)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow IscException.ForErrorCodes(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbytes = bvalue;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tvar svalue = await GetStringAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\tif ((Field.Length % Field.Charset.BytesPerCharacter) == 0 && svalue.EnumerateRunesToChars().Count() > Field.CharCount)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow IscException.ForErrorCodes(new[] { IscCodes.isc_arith_except, IscCodes.isc_string_truncation });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbytes = Field.Charset.GetBytes(svalue);\n\t\t\t\t\t}\n\n\t\t\t\t\tBuffer.BlockCopy(BitConverter.GetBytes((short)bytes.Length), 0, buffer, 0, 2);\n\t\t\t\t\tBuffer.BlockCopy(bytes, 0, buffer, 2, bytes.Length);\n\t\t\t\t\treturn buffer;\n\t\t\t\t}\n\n\t\t\tcase DbDataType.Numeric:\n\t\t\tcase DbDataType.Decimal:\n\t\t\t\treturn GetNumericBytes();\n\n\t\t\tcase DbDataType.SmallInt:\n\t\t\t\treturn BitConverter.GetBytes(GetInt16());\n\n\t\t\tcase DbDataType.Integer:\n\t\t\t\treturn BitConverter.GetBytes(GetInt32());\n\n\t\t\tcase DbDataType.Array:\n\t\t\tcase DbDataType.Binary:\n\t\t\tcase DbDataType.Text:\n\t\t\tcase DbDataType.BigInt:\n\t\t\t\treturn BitConverter.GetBytes(GetInt64());\n\n\t\t\tcase DbDataType.Float:\n\t\t\t\treturn BitConverter.GetBytes(GetFloat());\n\n\t\t\tcase DbDataType.Double:\n\t\t\t\treturn BitConverter.GetBytes(GetDouble());\n\n\t\t\tcase DbDataType.Date:\n\t\t\t\treturn BitConverter.GetBytes(GetDate());\n\n\t\t\tcase DbDataType.Time:\n\t\t\t\treturn BitConverter.GetBytes(GetTime());\n\n\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\t{\n\t\t\t\t\tvar dt = GetDateTime();\n\t\t\t\t\tvar date = BitConverter.GetBytes(TypeEncoder.EncodeDate(dt));\n\t\t\t\t\tvar time = BitConverter.GetBytes(TypeEncoder.EncodeTime(TypeHelper.DateTimeTimeToTimeSpan(dt)));\n\n\t\t\t\t\tvar result = new byte[8];\n\t\t\t\t\tBuffer.BlockCopy(date, 0, result, 0, date.Length);\n\t\t\t\t\tBuffer.BlockCopy(time, 0, result, 4, time.Length);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\tcase DbDataType.Guid:\n\t\t\t\t{\n\t\t\t\t\tvar bytes = TypeEncoder.EncodeGuid(GetGuid());\n\t\t\t\t\tbyte[] buffer;\n\t\t\t\t\tif (Field.SqlType == IscCodes.SQL_VARYING)\n\t\t\t\t\t{\n\t\t\t\t\t\tbuffer = new byte[bytes.Length + 2];\n\t\t\t\t\t\tBuffer.BlockCopy(BitConverter.GetBytes((short)bytes.Length), 0, buffer, 0, 2);\n\t\t\t\t\t\tBuffer.BlockCopy(bytes, 0, buffer, 2, bytes.Length);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tbuffer = new byte[bytes.Length];\n\t\t\t\t\t\tBuffer.BlockCopy(bytes, 0, buffer, 0, bytes.Length);\n\t\t\t\t\t}\n\t\t\t\t\treturn buffer;\n\t\t\t\t}\n\n\t\t\tcase DbDataType.Boolean:\n\t\t\t\treturn BitConverter.GetBytes(GetBoolean());\n\n\t\t\tcase DbDataType.TimeStampTZ:\n\t\t\t\t{\n\t\t\t\t\tvar dt = GetDateTime();\n\t\t\t\t\tvar date = BitConverter.GetBytes(TypeEncoder.EncodeDate(dt));\n\t\t\t\t\tvar time = BitConverter.GetBytes(TypeEncoder.EncodeTime(TypeHelper.DateTimeTimeToTimeSpan(dt)));\n\t\t\t\t\tvar tzId = BitConverter.GetBytes(GetTimeZoneId());\n\n\t\t\t\t\tvar result = new byte[10];\n\t\t\t\t\tBuffer.BlockCopy(date, 0, result, 0, date.Length);\n\t\t\t\t\tBuffer.BlockCopy(time, 0, result, 4, time.Length);\n\t\t\t\t\tBuffer.BlockCopy(tzId, 0, result, 8, tzId.Length);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\tcase DbDataType.TimeStampTZEx:\n\t\t\t\t{\n\t\t\t\t\tvar dt = GetDateTime();\n\t\t\t\t\tvar date = BitConverter.GetBytes(TypeEncoder.EncodeDate(dt));\n\t\t\t\t\tvar time = BitConverter.GetBytes(TypeEncoder.EncodeTime(TypeHelper.DateTimeTimeToTimeSpan(dt)));\n\t\t\t\t\tvar tzId = BitConverter.GetBytes(GetTimeZoneId());\n\t\t\t\t\tvar offset = new byte[] { 0, 0 };\n\n\t\t\t\t\tvar result = new byte[12];\n\t\t\t\t\tBuffer.BlockCopy(date, 0, result, 0, date.Length);\n\t\t\t\t\tBuffer.BlockCopy(time, 0, result, 4, time.Length);\n\t\t\t\t\tBuffer.BlockCopy(tzId, 0, result, 8, tzId.Length);\n\t\t\t\t\tBuffer.BlockCopy(offset, 0, result, 10, offset.Length);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\tcase DbDataType.TimeTZ:\n\t\t\t\t{\n\t\t\t\t\tvar time = BitConverter.GetBytes(GetTime());\n\t\t\t\t\tvar tzId = BitConverter.GetBytes(GetTimeZoneId());\n\n\t\t\t\t\tvar result = new byte[6];\n\t\t\t\t\tBuffer.BlockCopy(time, 0, result, 0, time.Length);\n\t\t\t\t\tBuffer.BlockCopy(tzId, 0, result, 4, tzId.Length);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\tcase DbDataType.TimeTZEx:\n\t\t\t\t{\n\t\t\t\t\tvar time = BitConverter.GetBytes(GetTime());\n\t\t\t\t\tvar tzId = BitConverter.GetBytes(GetTimeZoneId());\n\t\t\t\t\tvar offset = new byte[] { 0, 0 };\n\n\t\t\t\t\tvar result = new byte[8];\n\t\t\t\t\tBuffer.BlockCopy(time, 0, result, 0, time.Length);\n\t\t\t\t\tBuffer.BlockCopy(tzId, 0, result, 4, tzId.Length);\n\t\t\t\t\tBuffer.BlockCopy(offset, 0, result, 6, offset.Length);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\tcase DbDataType.Dec16:\n\t\t\t\treturn DecimalCodec.DecFloat16.EncodeDecimal(GetDecFloat());\n\n\t\t\tcase DbDataType.Dec34:\n\t\t\t\treturn DecimalCodec.DecFloat34.EncodeDecimal(GetDecFloat());\n\n\t\t\tcase DbDataType.Int128:\n\t\t\t\treturn Int128Helper.GetBytes(GetInt128());\n\n\t\t\tdefault:\n\t\t\t\tthrow TypeHelper.InvalidDataType((int)Field.DbDataType);\n\t\t}\n\t}\n\n\tprivate byte[] GetNumericBytes()\n\t{\n\t\tvar value = GetDecimal();\n\t\tvar numeric = TypeEncoder.EncodeDecimal(value, Field.NumericScale, Field.DataType);\n\n\t\tswitch (_field.SqlType)\n\t\t{\n\t\t\tcase IscCodes.SQL_SHORT:\n\t\t\t\treturn BitConverter.GetBytes((short)numeric);\n\n\t\t\tcase IscCodes.SQL_LONG:\n\t\t\t\treturn BitConverter.GetBytes((int)numeric);\n\n\t\t\tcase IscCodes.SQL_QUAD:\n\t\t\tcase IscCodes.SQL_INT64:\n\t\t\t\treturn BitConverter.GetBytes((long)numeric);\n\n\t\t\tcase IscCodes.SQL_DOUBLE:\n\t\t\tcase IscCodes.SQL_D_FLOAT:\n\t\t\t\treturn BitConverter.GetBytes((double)numeric);\n\n\t\t\tcase IscCodes.SQL_INT128:\n\t\t\t\treturn Int128Helper.GetBytes((BigInteger)numeric);\n\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate string GetClobData(long blobId)\n\t{\n\t\tvar clob = _statement.CreateBlob(blobId);\n\t\treturn clob.ReadString();\n\t}\n\tprivate ValueTask<string> GetClobDataAsync(long blobId, CancellationToken cancellationToken = default)\n\t{\n\t\tvar clob = _statement.CreateBlob(blobId);\n\t\treturn clob.ReadStringAsync(cancellationToken);\n\t}\n\n\tprivate byte[] GetBlobData(long blobId)\n\t{\n\t\tvar blob = _statement.CreateBlob(blobId);\n\t\treturn blob.Read();\n\t}\n\tprivate ValueTask<byte[]> GetBlobDataAsync(long blobId, CancellationToken cancellationToken = default)\n\t{\n\t\tvar blob = _statement.CreateBlob(blobId);\n\t\treturn blob.ReadAsync(cancellationToken);\n\t}\n\n\tprivate BlobStream GetBlobStream(long blobId)\n\t{\n\t\tvar blob = _statement.CreateBlob(blobId);\n\t\treturn new BlobStream(blob);\n\t}\n\tprivate ValueTask<BlobStream> GetBlobStreamAsync(long blobId, CancellationToken cancellationToken = default)\n\t{\n\t\tvar blob = _statement.CreateBlob(blobId);\n\t\treturn ValueTask.FromResult(new BlobStream(blob));\n\t}\n\n\tprivate Array GetArrayData(long handle)\n\t{\n\t\tif (_field.ArrayHandle == null)\n\t\t{\n\t\t\t_field.ArrayHandle = _statement.CreateArray(handle, Field.Relation, Field.Name);\n\t\t}\n\n\t\tvar gdsArray = _statement.CreateArray(_field.ArrayHandle.Descriptor);\n\t\tgdsArray.Handle = handle;\n\t\tgdsArray.Database = _statement.Database;\n\t\tgdsArray.Transaction = _statement.Transaction;\n\t\treturn gdsArray.Read();\n\t}\n\tprivate async ValueTask<Array> GetArrayDataAsync(long handle, CancellationToken cancellationToken = default)\n\t{\n\t\tif (_field.ArrayHandle == null)\n\t\t{\n\t\t\t_field.ArrayHandle = await _statement.CreateArrayAsync(handle, Field.Relation, Field.Name, cancellationToken).ConfigureAwait(false);\n\t\t}\n\n\t\tvar gdsArray = await _statement.CreateArrayAsync(_field.ArrayHandle.Descriptor, cancellationToken).ConfigureAwait(false);\n\t\tgdsArray.Handle = handle;\n\t\tgdsArray.Database = _statement.Database;\n\t\tgdsArray.Transaction = _statement.Transaction;\n\t\treturn await gdsArray.ReadAsync(cancellationToken).ConfigureAwait(false);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/DecimalCodec.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Diagnostics;\nusing FirebirdSql.Data.Types;\n\nnamespace FirebirdSql.Data.Common;\n\n// based on Jaybird's implementation\nclass DecimalCodec\n{\n\tclass DecimalFormat\n\t{\n\t\tconst int SignBits = 1;\n\t\tconst int CombinationBits = 5;\n\t\tconst int BitsPerGroup = DenselyPackedDecimalCodec.BitsPerGroup;\n\t\tconst int DigitsPerGroup = DenselyPackedDecimalCodec.DigitsPerGroup;\n\n\t\tpublic DecimalFormat(int formatBitLength, int coefficientDigits)\n\t\t{\n\t\t\tFormatBitLength = formatBitLength;\n\t\t\tCoefficientDigits = coefficientDigits;\n\t\t\tFormatByteLength = FormatBitLength / 8;\n\t\t\tCoefficientContinuationBits = BitsPerGroup * (CoefficientDigits - 1) / DigitsPerGroup;\n\t\t\tExponentContinuationBits = FormatBitLength - SignBits - CombinationBits - CoefficientContinuationBits;\n\t\t\tELimit = 3 * (1 << ExponentContinuationBits) - 1;\n\t\t\tEMin = -ELimit / 2;\n\t\t\tExponentBias = -EMin + CoefficientDigits - 1;\n\t\t}\n\n\t\tpublic int FormatBitLength { get; }\n\t\tpublic int CoefficientDigits { get; }\n\t\tpublic int FormatByteLength { get; }\n\t\tpublic int CoefficientContinuationBits { get; }\n\t\tpublic int ExponentContinuationBits { get; }\n\t\tpublic int ELimit { get; }\n\t\tpublic int EMin { get; }\n\t\tpublic int ExponentBias { get; }\n\n\t\tpublic void ValidateByteLength(byte[] decBytes)\n\t\t{\n\t\t\tif (decBytes.Length != FormatByteLength)\n\t\t\t{\n\t\t\t\tthrow new ArgumentException(nameof(decBytes), $\"{nameof(decBytes)} argument must be {FormatByteLength} bytes.\");\n\t\t\t}\n\t\t}\n\n\t\tpublic int BiasedExponent(int unbiasedExponent)\n\t\t{\n\t\t\treturn unbiasedExponent + ExponentBias;\n\t\t}\n\n\t\tpublic int UnbiasedExponent(int biasedExponent)\n\t\t{\n\t\t\treturn biasedExponent - ExponentBias;\n\t\t}\n\t}\n\n\t// Byte pattern that signals that the combination field contains 1 bit of the first digit (for value 8 or 9).\n\tconst int Combination2 = 0b0_11000_00;\n\tconst int NegativeBit = 0b1000_0000;\n\tconst int NegativeSignum = DenselyPackedDecimalCodec.NegativeSignum;\n\n\tconst byte TypeMask = 0b0_11111_10;\n\tconst byte Infinity0 = 0b0_11110_00;\n\tconst byte Infinity2 = 0b0_11110_10;\n\tconst byte NaNQuiet = 0b0_11111_00;\n\tconst byte NaNSignal = 0b0_11111_10;\n\n\treadonly DecimalFormat _decimalFormat;\n\treadonly DenselyPackedDecimalCodec _coefficientCoder;\n\n\tpublic DecimalCodec(int formatBitLength, int coefficientDigits)\n\t{\n\t\t_decimalFormat = new DecimalFormat(formatBitLength, coefficientDigits);\n\t\t_coefficientCoder = new DenselyPackedDecimalCodec(coefficientDigits);\n\t}\n\n\tpublic static DecimalCodec DecFloat16 { get; } = new DecimalCodec(64, 16);\n\tpublic static DecimalCodec DecFloat34 { get; } = new DecimalCodec(128, 34);\n\n\t// Parse an IEEE-754 decimal format to a FbDecFloat.\n\tpublic FbDecFloat ParseBytes(byte[] decBytes)\n\t{\n\t\t// this (and related) code works with BE\n\t\tif (BitConverter.IsLittleEndian)\n\t\t{\n\t\t\tArray.Reverse(decBytes);\n\t\t}\n\n\t\t_decimalFormat.ValidateByteLength(decBytes);\n\n\t\tvar firstByte = decBytes[0] & 0xff;\n\t\tvar signum = -1 * (firstByte >>> 7) | 1;\n\t\tvar decimalType = DecimalTypeFromFirstByte(firstByte);\n\t\tswitch (decimalType)\n\t\t{\n\t\t\tcase DecimalType.Infinity:\n\t\t\t\treturn signum == NegativeSignum ? FbDecFloat.NegativeInfinity : FbDecFloat.PositiveInfinity;\n\t\t\tcase DecimalType.NaN:\n\t\t\t\treturn signum == NegativeSignum ? FbDecFloat.NegativeNaN : FbDecFloat.PositiveNaN;\n\t\t\tcase DecimalType.SignalingNaN:\n\t\t\t\treturn signum == NegativeSignum ? FbDecFloat.NegativeSignalingNaN : FbDecFloat.PositiveSignalingNaN;\n\t\t\tcase DecimalType.Finite:\n\t\t\t\t{\n\t\t\t\t\t// NOTE: get exponent MSB from combination field and first 2 bits of exponent continuation in one go\n\t\t\t\t\tint exponentMSB;\n\t\t\t\t\tint firstDigit;\n\t\t\t\t\tif ((firstByte & Combination2) != Combination2)\n\t\t\t\t\t{\n\t\t\t\t\t\texponentMSB = (firstByte >>> 3) & 0b01100 | (firstByte & 0b011);\n\t\t\t\t\t\tfirstDigit = (firstByte >>> 2) & 0b0111;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\texponentMSB = (firstByte >>> 1) & 0b01100 | (firstByte & 0b011);\n\t\t\t\t\t\tfirstDigit = 0b01000 | ((firstByte >>> 2) & 0b01);\n\t\t\t\t\t}\n\t\t\t\t\tvar exponentBitsRemaining = _decimalFormat.ExponentContinuationBits - 2;\n\t\t\t\t\tDebug.Assert(exponentBitsRemaining == _decimalFormat.FormatBitLength - 8 - _decimalFormat.CoefficientContinuationBits, $\"Unexpected exponent remaining length {exponentBitsRemaining}.\");\n\t\t\t\t\tvar exponent = _decimalFormat.UnbiasedExponent(DecodeExponent(decBytes, exponentMSB, exponentBitsRemaining));\n\t\t\t\t\tvar coefficient = _coefficientCoder.DecodeValue(signum, firstDigit, decBytes);\n\t\t\t\t\treturn new FbDecFloat(DecimalType.Finite, signum == NegativeSignum, coefficient, exponent);\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new ArgumentOutOfRangeException();\n\t\t}\n\t}\n\n\t// Encodes a FbDecFloat to its IEEE-754 format.\n\tpublic byte[] EncodeDecimal(FbDecFloat @decimal)\n\t{\n\t\tvar decBytes = new byte[_decimalFormat.FormatByteLength];\n\n\t\tif (@decimal.Negative)\n\t\t{\n\t\t\tdecBytes[0] = NegativeBit;\n\t\t}\n\n\t\tif (@decimal.Type == DecimalType.Finite)\n\t\t{\n\t\t\tEncodeFinite(@decimal, decBytes);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tdecBytes[0] |= GetSpecialBits(@decimal.Type);\n\t\t}\n\n\t\t// this (and related) code works with BE\n\t\tif (BitConverter.IsLittleEndian)\n\t\t{\n\t\t\tArray.Reverse(decBytes);\n\t\t}\n\t\treturn decBytes;\n\t}\n\n\tvoid EncodeFinite(FbDecFloat @decimal, byte[] decBytes)\n\t{\n\t\tvar biasedExponent = _decimalFormat.BiasedExponent(@decimal.Exponent);\n\t\tvar coefficient = @decimal.Coefficient;\n\t\tvar mostSignificantDigit = _coefficientCoder.EncodeValue(coefficient, decBytes);\n\t\tvar expMSB = biasedExponent >>> _decimalFormat.ExponentContinuationBits;\n\t\tvar expTwoBitCont = (biasedExponent >>> _decimalFormat.ExponentContinuationBits - 2) & 0b011;\n\t\tif (mostSignificantDigit <= 7)\n\t\t{\n\t\t\tdecBytes[0] |= (byte)((expMSB << 5)\n\t\t\t\t\t| (mostSignificantDigit << 2)\n\t\t\t\t\t| expTwoBitCont);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tdecBytes[0] |= (byte)(Combination2\n\t\t\t\t\t| (expMSB << 3)\n\t\t\t\t\t| ((mostSignificantDigit & 0b01) << 2)\n\t\t\t\t\t| expTwoBitCont);\n\t\t}\n\t\tEncodeExponentContinuation(decBytes, biasedExponent, _decimalFormat.ExponentContinuationBits - 2);\n\t}\n\n\tstatic void EncodeExponentContinuation(byte[] decBytes, int expAndBias, int expBitsRemaining)\n\t{\n\t\tvar expByteIndex = 1;\n\t\twhile (expBitsRemaining > 8)\n\t\t{\n\t\t\tdecBytes[expByteIndex++] = (byte)(expAndBias >>> expBitsRemaining - 8);\n\t\t\texpBitsRemaining -= 8;\n\t\t}\n\t\tif (expBitsRemaining > 0)\n\t\t{\n\t\t\tdecBytes[expByteIndex] |= (byte)(expAndBias << 8 - expBitsRemaining);\n\t\t}\n\t}\n\n\tstatic int DecodeExponent(byte[] decBytes, int exponentMSB, int exponentBitsRemaining)\n\t{\n\t\tvar exponent = exponentMSB;\n\t\tvar byteIndex = 1;\n\t\twhile (exponentBitsRemaining > 8)\n\t\t{\n\t\t\texponent = (exponent << 8) | (decBytes[byteIndex] & 0xFF);\n\t\t\texponentBitsRemaining -= 8;\n\t\t\tbyteIndex += 1;\n\t\t}\n\t\tif (exponentBitsRemaining > 0)\n\t\t{\n\t\t\texponent = (exponent << exponentBitsRemaining)\n\t\t\t\t| ((decBytes[byteIndex] & 0xFF) >>> (8 - exponentBitsRemaining));\n\t\t}\n\t\treturn exponent;\n\t}\n\n\tstatic DecimalType DecimalTypeFromFirstByte(int firstByte)\n\t{\n\t\treturn (firstByte & TypeMask) switch\n\t\t{\n\t\t\tInfinity0 => DecimalType.Infinity,\n\t\t\tInfinity2 => DecimalType.Infinity,\n\t\t\tNaNQuiet => DecimalType.NaN,\n\t\t\tNaNSignal => DecimalType.SignalingNaN,\n\t\t\t_ => DecimalType.Finite,\n\t\t};\n\t}\n\n\tstatic byte GetSpecialBits(DecimalType decimalType)\n\t{\n\t\treturn decimalType switch\n\t\t{\n\t\t\tDecimalType.Finite => throw new InvalidOperationException($\"{nameof(DecimalType)} {nameof(DecimalType.Finite)} has no special bits.\"),\n\t\t\tDecimalType.Infinity => Infinity0,\n\t\t\tDecimalType.NaN => NaNQuiet,\n\t\t\tDecimalType.SignalingNaN => NaNSignal,\n\t\t\t_ => throw new ArgumentOutOfRangeException(),\n\t\t};\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/DecimalShiftHelper.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class DecimalShiftHelper\n{\n\tpublic static decimal ShiftDecimalLeft(decimal d, int shift)\n\t{\n\t\twhile (shift-- > 0)\n\t\t{\n\t\t\td /= 10;\n\t\t}\n\t\treturn d;\n\t}\n\n\tpublic static decimal ShiftDecimalRight(decimal d, int shift)\n\t{\n\t\twhile (shift-- > 0)\n\t\t{\n\t\t\td *= 10;\n\t\t}\n\t\treturn d;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/DecimalType.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nnamespace FirebirdSql.Data.Common;\n\npublic enum DecimalType\n{\n\tFinite,\n\tInfinity,\n\tNaN,\n\tSignalingNaN,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/DenselyPackedDecimalCodec.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Diagnostics;\nusing System.Numerics;\n\nnamespace FirebirdSql.Data.Common;\n\n// based on Jaybird's implementation\nclass DenselyPackedDecimalCodec\n{\n\tinternal const int DigitsPerGroup = 3;\n\tinternal const int BitsPerGroup = 10;\n\tinternal const int NegativeSignum = -1;\n\tconst int BitPerByte = 8;\n\tstatic readonly BigInteger OneThousand = new BigInteger(1000);\n\n\t//@formatter:off\n\t// Generated using org.firebirdsql.decimal.generator.GenerateLookupTable\n\tstatic readonly char[] DPDGroupBits2Digits = (\n\t\t\t\"000\" + \"001\" + \"002\" + \"003\" + \"004\" + \"005\" + \"006\" + \"007\" +\n\t\t\t\"008\" + \"009\" + \"080\" + \"081\" + \"800\" + \"801\" + \"880\" + \"881\" +\n\t\t\t\"010\" + \"011\" + \"012\" + \"013\" + \"014\" + \"015\" + \"016\" + \"017\" +\n\t\t\t\"018\" + \"019\" + \"090\" + \"091\" + \"810\" + \"811\" + \"890\" + \"891\" +\n\t\t\t\"020\" + \"021\" + \"022\" + \"023\" + \"024\" + \"025\" + \"026\" + \"027\" +\n\t\t\t\"028\" + \"029\" + \"082\" + \"083\" + \"820\" + \"821\" + \"808\" + \"809\" +\n\t\t\t\"030\" + \"031\" + \"032\" + \"033\" + \"034\" + \"035\" + \"036\" + \"037\" +\n\t\t\t\"038\" + \"039\" + \"092\" + \"093\" + \"830\" + \"831\" + \"818\" + \"819\" +\n\t\t\t\"040\" + \"041\" + \"042\" + \"043\" + \"044\" + \"045\" + \"046\" + \"047\" +\n\t\t\t\"048\" + \"049\" + \"084\" + \"085\" + \"840\" + \"841\" + \"088\" + \"089\" +\n\t\t\t\"050\" + \"051\" + \"052\" + \"053\" + \"054\" + \"055\" + \"056\" + \"057\" +\n\t\t\t\"058\" + \"059\" + \"094\" + \"095\" + \"850\" + \"851\" + \"098\" + \"099\" +\n\t\t\t\"060\" + \"061\" + \"062\" + \"063\" + \"064\" + \"065\" + \"066\" + \"067\" +\n\t\t\t\"068\" + \"069\" + \"086\" + \"087\" + \"860\" + \"861\" + \"888\" + \"889\" +\n\t\t\t\"070\" + \"071\" + \"072\" + \"073\" + \"074\" + \"075\" + \"076\" + \"077\" +\n\t\t\t\"078\" + \"079\" + \"096\" + \"097\" + \"870\" + \"871\" + \"898\" + \"899\" +\n\t\t\t\"100\" + \"101\" + \"102\" + \"103\" + \"104\" + \"105\" + \"106\" + \"107\" +\n\t\t\t\"108\" + \"109\" + \"180\" + \"181\" + \"900\" + \"901\" + \"980\" + \"981\" +\n\t\t\t\"110\" + \"111\" + \"112\" + \"113\" + \"114\" + \"115\" + \"116\" + \"117\" +\n\t\t\t\"118\" + \"119\" + \"190\" + \"191\" + \"910\" + \"911\" + \"990\" + \"991\" +\n\t\t\t\"120\" + \"121\" + \"122\" + \"123\" + \"124\" + \"125\" + \"126\" + \"127\" +\n\t\t\t\"128\" + \"129\" + \"182\" + \"183\" + \"920\" + \"921\" + \"908\" + \"909\" +\n\t\t\t\"130\" + \"131\" + \"132\" + \"133\" + \"134\" + \"135\" + \"136\" + \"137\" +\n\t\t\t\"138\" + \"139\" + \"192\" + \"193\" + \"930\" + \"931\" + \"918\" + \"919\" +\n\t\t\t\"140\" + \"141\" + \"142\" + \"143\" + \"144\" + \"145\" + \"146\" + \"147\" +\n\t\t\t\"148\" + \"149\" + \"184\" + \"185\" + \"940\" + \"941\" + \"188\" + \"189\" +\n\t\t\t\"150\" + \"151\" + \"152\" + \"153\" + \"154\" + \"155\" + \"156\" + \"157\" +\n\t\t\t\"158\" + \"159\" + \"194\" + \"195\" + \"950\" + \"951\" + \"198\" + \"199\" +\n\t\t\t\"160\" + \"161\" + \"162\" + \"163\" + \"164\" + \"165\" + \"166\" + \"167\" +\n\t\t\t\"168\" + \"169\" + \"186\" + \"187\" + \"960\" + \"961\" + \"988\" + \"989\" +\n\t\t\t\"170\" + \"171\" + \"172\" + \"173\" + \"174\" + \"175\" + \"176\" + \"177\" +\n\t\t\t\"178\" + \"179\" + \"196\" + \"197\" + \"970\" + \"971\" + \"998\" + \"999\" +\n\t\t\t\"200\" + \"201\" + \"202\" + \"203\" + \"204\" + \"205\" + \"206\" + \"207\" +\n\t\t\t\"208\" + \"209\" + \"280\" + \"281\" + \"802\" + \"803\" + \"882\" + \"883\" +\n\t\t\t\"210\" + \"211\" + \"212\" + \"213\" + \"214\" + \"215\" + \"216\" + \"217\" +\n\t\t\t\"218\" + \"219\" + \"290\" + \"291\" + \"812\" + \"813\" + \"892\" + \"893\" +\n\t\t\t\"220\" + \"221\" + \"222\" + \"223\" + \"224\" + \"225\" + \"226\" + \"227\" +\n\t\t\t\"228\" + \"229\" + \"282\" + \"283\" + \"822\" + \"823\" + \"828\" + \"829\" +\n\t\t\t\"230\" + \"231\" + \"232\" + \"233\" + \"234\" + \"235\" + \"236\" + \"237\" +\n\t\t\t\"238\" + \"239\" + \"292\" + \"293\" + \"832\" + \"833\" + \"838\" + \"839\" +\n\t\t\t\"240\" + \"241\" + \"242\" + \"243\" + \"244\" + \"245\" + \"246\" + \"247\" +\n\t\t\t\"248\" + \"249\" + \"284\" + \"285\" + \"842\" + \"843\" + \"288\" + \"289\" +\n\t\t\t\"250\" + \"251\" + \"252\" + \"253\" + \"254\" + \"255\" + \"256\" + \"257\" +\n\t\t\t\"258\" + \"259\" + \"294\" + \"295\" + \"852\" + \"853\" + \"298\" + \"299\" +\n\t\t\t\"260\" + \"261\" + \"262\" + \"263\" + \"264\" + \"265\" + \"266\" + \"267\" +\n\t\t\t\"268\" + \"269\" + \"286\" + \"287\" + \"862\" + \"863\" + \"888\" + \"889\" +\n\t\t\t\"270\" + \"271\" + \"272\" + \"273\" + \"274\" + \"275\" + \"276\" + \"277\" +\n\t\t\t\"278\" + \"279\" + \"296\" + \"297\" + \"872\" + \"873\" + \"898\" + \"899\" +\n\t\t\t\"300\" + \"301\" + \"302\" + \"303\" + \"304\" + \"305\" + \"306\" + \"307\" +\n\t\t\t\"308\" + \"309\" + \"380\" + \"381\" + \"902\" + \"903\" + \"982\" + \"983\" +\n\t\t\t\"310\" + \"311\" + \"312\" + \"313\" + \"314\" + \"315\" + \"316\" + \"317\" +\n\t\t\t\"318\" + \"319\" + \"390\" + \"391\" + \"912\" + \"913\" + \"992\" + \"993\" +\n\t\t\t\"320\" + \"321\" + \"322\" + \"323\" + \"324\" + \"325\" + \"326\" + \"327\" +\n\t\t\t\"328\" + \"329\" + \"382\" + \"383\" + \"922\" + \"923\" + \"928\" + \"929\" +\n\t\t\t\"330\" + \"331\" + \"332\" + \"333\" + \"334\" + \"335\" + \"336\" + \"337\" +\n\t\t\t\"338\" + \"339\" + \"392\" + \"393\" + \"932\" + \"933\" + \"938\" + \"939\" +\n\t\t\t\"340\" + \"341\" + \"342\" + \"343\" + \"344\" + \"345\" + \"346\" + \"347\" +\n\t\t\t\"348\" + \"349\" + \"384\" + \"385\" + \"942\" + \"943\" + \"388\" + \"389\" +\n\t\t\t\"350\" + \"351\" + \"352\" + \"353\" + \"354\" + \"355\" + \"356\" + \"357\" +\n\t\t\t\"358\" + \"359\" + \"394\" + \"395\" + \"952\" + \"953\" + \"398\" + \"399\" +\n\t\t\t\"360\" + \"361\" + \"362\" + \"363\" + \"364\" + \"365\" + \"366\" + \"367\" +\n\t\t\t\"368\" + \"369\" + \"386\" + \"387\" + \"962\" + \"963\" + \"988\" + \"989\" +\n\t\t\t\"370\" + \"371\" + \"372\" + \"373\" + \"374\" + \"375\" + \"376\" + \"377\" +\n\t\t\t\"378\" + \"379\" + \"396\" + \"397\" + \"972\" + \"973\" + \"998\" + \"999\" +\n\t\t\t\"400\" + \"401\" + \"402\" + \"403\" + \"404\" + \"405\" + \"406\" + \"407\" +\n\t\t\t\"408\" + \"409\" + \"480\" + \"481\" + \"804\" + \"805\" + \"884\" + \"885\" +\n\t\t\t\"410\" + \"411\" + \"412\" + \"413\" + \"414\" + \"415\" + \"416\" + \"417\" +\n\t\t\t\"418\" + \"419\" + \"490\" + \"491\" + \"814\" + \"815\" + \"894\" + \"895\" +\n\t\t\t\"420\" + \"421\" + \"422\" + \"423\" + \"424\" + \"425\" + \"426\" + \"427\" +\n\t\t\t\"428\" + \"429\" + \"482\" + \"483\" + \"824\" + \"825\" + \"848\" + \"849\" +\n\t\t\t\"430\" + \"431\" + \"432\" + \"433\" + \"434\" + \"435\" + \"436\" + \"437\" +\n\t\t\t\"438\" + \"439\" + \"492\" + \"493\" + \"834\" + \"835\" + \"858\" + \"859\" +\n\t\t\t\"440\" + \"441\" + \"442\" + \"443\" + \"444\" + \"445\" + \"446\" + \"447\" +\n\t\t\t\"448\" + \"449\" + \"484\" + \"485\" + \"844\" + \"845\" + \"488\" + \"489\" +\n\t\t\t\"450\" + \"451\" + \"452\" + \"453\" + \"454\" + \"455\" + \"456\" + \"457\" +\n\t\t\t\"458\" + \"459\" + \"494\" + \"495\" + \"854\" + \"855\" + \"498\" + \"499\" +\n\t\t\t\"460\" + \"461\" + \"462\" + \"463\" + \"464\" + \"465\" + \"466\" + \"467\" +\n\t\t\t\"468\" + \"469\" + \"486\" + \"487\" + \"864\" + \"865\" + \"888\" + \"889\" +\n\t\t\t\"470\" + \"471\" + \"472\" + \"473\" + \"474\" + \"475\" + \"476\" + \"477\" +\n\t\t\t\"478\" + \"479\" + \"496\" + \"497\" + \"874\" + \"875\" + \"898\" + \"899\" +\n\t\t\t\"500\" + \"501\" + \"502\" + \"503\" + \"504\" + \"505\" + \"506\" + \"507\" +\n\t\t\t\"508\" + \"509\" + \"580\" + \"581\" + \"904\" + \"905\" + \"984\" + \"985\" +\n\t\t\t\"510\" + \"511\" + \"512\" + \"513\" + \"514\" + \"515\" + \"516\" + \"517\" +\n\t\t\t\"518\" + \"519\" + \"590\" + \"591\" + \"914\" + \"915\" + \"994\" + \"995\" +\n\t\t\t\"520\" + \"521\" + \"522\" + \"523\" + \"524\" + \"525\" + \"526\" + \"527\" +\n\t\t\t\"528\" + \"529\" + \"582\" + \"583\" + \"924\" + \"925\" + \"948\" + \"949\" +\n\t\t\t\"530\" + \"531\" + \"532\" + \"533\" + \"534\" + \"535\" + \"536\" + \"537\" +\n\t\t\t\"538\" + \"539\" + \"592\" + \"593\" + \"934\" + \"935\" + \"958\" + \"959\" +\n\t\t\t\"540\" + \"541\" + \"542\" + \"543\" + \"544\" + \"545\" + \"546\" + \"547\" +\n\t\t\t\"548\" + \"549\" + \"584\" + \"585\" + \"944\" + \"945\" + \"588\" + \"589\" +\n\t\t\t\"550\" + \"551\" + \"552\" + \"553\" + \"554\" + \"555\" + \"556\" + \"557\" +\n\t\t\t\"558\" + \"559\" + \"594\" + \"595\" + \"954\" + \"955\" + \"598\" + \"599\" +\n\t\t\t\"560\" + \"561\" + \"562\" + \"563\" + \"564\" + \"565\" + \"566\" + \"567\" +\n\t\t\t\"568\" + \"569\" + \"586\" + \"587\" + \"964\" + \"965\" + \"988\" + \"989\" +\n\t\t\t\"570\" + \"571\" + \"572\" + \"573\" + \"574\" + \"575\" + \"576\" + \"577\" +\n\t\t\t\"578\" + \"579\" + \"596\" + \"597\" + \"974\" + \"975\" + \"998\" + \"999\" +\n\t\t\t\"600\" + \"601\" + \"602\" + \"603\" + \"604\" + \"605\" + \"606\" + \"607\" +\n\t\t\t\"608\" + \"609\" + \"680\" + \"681\" + \"806\" + \"807\" + \"886\" + \"887\" +\n\t\t\t\"610\" + \"611\" + \"612\" + \"613\" + \"614\" + \"615\" + \"616\" + \"617\" +\n\t\t\t\"618\" + \"619\" + \"690\" + \"691\" + \"816\" + \"817\" + \"896\" + \"897\" +\n\t\t\t\"620\" + \"621\" + \"622\" + \"623\" + \"624\" + \"625\" + \"626\" + \"627\" +\n\t\t\t\"628\" + \"629\" + \"682\" + \"683\" + \"826\" + \"827\" + \"868\" + \"869\" +\n\t\t\t\"630\" + \"631\" + \"632\" + \"633\" + \"634\" + \"635\" + \"636\" + \"637\" +\n\t\t\t\"638\" + \"639\" + \"692\" + \"693\" + \"836\" + \"837\" + \"878\" + \"879\" +\n\t\t\t\"640\" + \"641\" + \"642\" + \"643\" + \"644\" + \"645\" + \"646\" + \"647\" +\n\t\t\t\"648\" + \"649\" + \"684\" + \"685\" + \"846\" + \"847\" + \"688\" + \"689\" +\n\t\t\t\"650\" + \"651\" + \"652\" + \"653\" + \"654\" + \"655\" + \"656\" + \"657\" +\n\t\t\t\"658\" + \"659\" + \"694\" + \"695\" + \"856\" + \"857\" + \"698\" + \"699\" +\n\t\t\t\"660\" + \"661\" + \"662\" + \"663\" + \"664\" + \"665\" + \"666\" + \"667\" +\n\t\t\t\"668\" + \"669\" + \"686\" + \"687\" + \"866\" + \"867\" + \"888\" + \"889\" +\n\t\t\t\"670\" + \"671\" + \"672\" + \"673\" + \"674\" + \"675\" + \"676\" + \"677\" +\n\t\t\t\"678\" + \"679\" + \"696\" + \"697\" + \"876\" + \"877\" + \"898\" + \"899\" +\n\t\t\t\"700\" + \"701\" + \"702\" + \"703\" + \"704\" + \"705\" + \"706\" + \"707\" +\n\t\t\t\"708\" + \"709\" + \"780\" + \"781\" + \"906\" + \"907\" + \"986\" + \"987\" +\n\t\t\t\"710\" + \"711\" + \"712\" + \"713\" + \"714\" + \"715\" + \"716\" + \"717\" +\n\t\t\t\"718\" + \"719\" + \"790\" + \"791\" + \"916\" + \"917\" + \"996\" + \"997\" +\n\t\t\t\"720\" + \"721\" + \"722\" + \"723\" + \"724\" + \"725\" + \"726\" + \"727\" +\n\t\t\t\"728\" + \"729\" + \"782\" + \"783\" + \"926\" + \"927\" + \"968\" + \"969\" +\n\t\t\t\"730\" + \"731\" + \"732\" + \"733\" + \"734\" + \"735\" + \"736\" + \"737\" +\n\t\t\t\"738\" + \"739\" + \"792\" + \"793\" + \"936\" + \"937\" + \"978\" + \"979\" +\n\t\t\t\"740\" + \"741\" + \"742\" + \"743\" + \"744\" + \"745\" + \"746\" + \"747\" +\n\t\t\t\"748\" + \"749\" + \"784\" + \"785\" + \"946\" + \"947\" + \"788\" + \"789\" +\n\t\t\t\"750\" + \"751\" + \"752\" + \"753\" + \"754\" + \"755\" + \"756\" + \"757\" +\n\t\t\t\"758\" + \"759\" + \"794\" + \"795\" + \"956\" + \"957\" + \"798\" + \"799\" +\n\t\t\t\"760\" + \"761\" + \"762\" + \"763\" + \"764\" + \"765\" + \"766\" + \"767\" +\n\t\t\t\"768\" + \"769\" + \"786\" + \"787\" + \"966\" + \"967\" + \"988\" + \"989\" +\n\t\t\t\"770\" + \"771\" + \"772\" + \"773\" + \"774\" + \"775\" + \"776\" + \"777\" +\n\t\t\t\"778\" + \"779\" + \"796\" + \"797\" + \"976\" + \"977\" + \"998\" + \"999\"\n\t).ToCharArray();\n\n\t// from ICU decNumber decDPD.h\n\tstatic readonly int[] Bin2DPD = {\n\t\t\t0,      1,    2,    3,    4,    5,    6,    7,\n\t\t\t8,      9,   16,   17,   18,   19,   20,   21,   22,   23,   24,   25,   32,\n\t\t\t33,    34,   35,   36,   37,   38,   39,   40,   41,   48,   49,   50,   51,\n\t\t\t52,    53,   54,   55,   56,   57,   64,   65,   66,   67,   68,   69,   70,\n\t\t\t71,    72,   73,   80,   81,   82,   83,   84,   85,   86,   87,   88,   89,\n\t\t\t96,    97,   98,   99,  100,  101,  102,  103,  104,  105,  112,  113,  114,\n\t\t\t115,  116,  117,  118,  119,  120,  121,   10,   11,   42,   43,   74,   75,\n\t\t\t106,  107,   78,   79,   26,   27,   58,   59,   90,   91,  122,  123,   94,\n\t\t\t95,   128,  129,  130,  131,  132,  133,  134,  135,  136,  137,  144,  145,\n\t\t\t146,  147,  148,  149,  150,  151,  152,  153,  160,  161,  162,  163,  164,\n\t\t\t165,  166,  167,  168,  169,  176,  177,  178,  179,  180,  181,  182,  183,\n\t\t\t184,  185,  192,  193,  194,  195,  196,  197,  198,  199,  200,  201,  208,\n\t\t\t209,  210,  211,  212,  213,  214,  215,  216,  217,  224,  225,  226,  227,\n\t\t\t228,  229,  230,  231,  232,  233,  240,  241,  242,  243,  244,  245,  246,\n\t\t\t247,  248,  249,  138,  139,  170,  171,  202,  203,  234,  235,  206,  207,\n\t\t\t154,  155,  186,  187,  218,  219,  250,  251,  222,  223,  256,  257,  258,\n\t\t\t259,  260,  261,  262,  263,  264,  265,  272,  273,  274,  275,  276,  277,\n\t\t\t278,  279,  280,  281,  288,  289,  290,  291,  292,  293,  294,  295,  296,\n\t\t\t297,  304,  305,  306,  307,  308,  309,  310,  311,  312,  313,  320,  321,\n\t\t\t322,  323,  324,  325,  326,  327,  328,  329,  336,  337,  338,  339,  340,\n\t\t\t341,  342,  343,  344,  345,  352,  353,  354,  355,  356,  357,  358,  359,\n\t\t\t360,  361,  368,  369,  370,  371,  372,  373,  374,  375,  376,  377,  266,\n\t\t\t267,  298,  299,  330,  331,  362,  363,  334,  335,  282,  283,  314,  315,\n\t\t\t346,  347,  378,  379,  350,  351,  384,  385,  386,  387,  388,  389,  390,\n\t\t\t391,  392,  393,  400,  401,  402,  403,  404,  405,  406,  407,  408,  409,\n\t\t\t416,  417,  418,  419,  420,  421,  422,  423,  424,  425,  432,  433,  434,\n\t\t\t435,  436,  437,  438,  439,  440,  441,  448,  449,  450,  451,  452,  453,\n\t\t\t454,  455,  456,  457,  464,  465,  466,  467,  468,  469,  470,  471,  472,\n\t\t\t473,  480,  481,  482,  483,  484,  485,  486,  487,  488,  489,  496,  497,\n\t\t\t498,  499,  500,  501,  502,  503,  504,  505,  394,  395,  426,  427,  458,\n\t\t\t459,  490,  491,  462,  463,  410,  411,  442,  443,  474,  475,  506,  507,\n\t\t\t478,  479,  512,  513,  514,  515,  516,  517,  518,  519,  520,  521,  528,\n\t\t\t529,  530,  531,  532,  533,  534,  535,  536,  537,  544,  545,  546,  547,\n\t\t\t548,  549,  550,  551,  552,  553,  560,  561,  562,  563,  564,  565,  566,\n\t\t\t567,  568,  569,  576,  577,  578,  579,  580,  581,  582,  583,  584,  585,\n\t\t\t592,  593,  594,  595,  596,  597,  598,  599,  600,  601,  608,  609,  610,\n\t\t\t611,  612,  613,  614,  615,  616,  617,  624,  625,  626,  627,  628,  629,\n\t\t\t630,  631,  632,  633,  522,  523,  554,  555,  586,  587,  618,  619,  590,\n\t\t\t591,  538,  539,  570,  571,  602,  603,  634,  635,  606,  607,  640,  641,\n\t\t\t642,  643,  644,  645,  646,  647,  648,  649,  656,  657,  658,  659,  660,\n\t\t\t661,  662,  663,  664,  665,  672,  673,  674,  675,  676,  677,  678,  679,\n\t\t\t680,  681,  688,  689,  690,  691,  692,  693,  694,  695,  696,  697,  704,\n\t\t\t705,  706,  707,  708,  709,  710,  711,  712,  713,  720,  721,  722,  723,\n\t\t\t724,  725,  726,  727,  728,  729,  736,  737,  738,  739,  740,  741,  742,\n\t\t\t743,  744,  745,  752,  753,  754,  755,  756,  757,  758,  759,  760,  761,\n\t\t\t650,  651,  682,  683,  714,  715,  746,  747,  718,  719,  666,  667,  698,\n\t\t\t699,  730,  731,  762,  763,  734,  735,  768,  769,  770,  771,  772,  773,\n\t\t\t774,  775,  776,  777,  784,  785,  786,  787,  788,  789,  790,  791,  792,\n\t\t\t793,  800,  801,  802,  803,  804,  805,  806,  807,  808,  809,  816,  817,\n\t\t\t818,  819,  820,  821,  822,  823,  824,  825,  832,  833,  834,  835,  836,\n\t\t\t837,  838,  839,  840,  841,  848,  849,  850,  851,  852,  853,  854,  855,\n\t\t\t856,  857,  864,  865,  866,  867,  868,  869,  870,  871,  872,  873,  880,\n\t\t\t881,  882,  883,  884,  885,  886,  887,  888,  889,  778,  779,  810,  811,\n\t\t\t842,  843,  874,  875,  846,  847,  794,  795,  826,  827,  858,  859,  890,\n\t\t\t891,  862,  863,  896,  897,  898,  899,  900,  901,  902,  903,  904,  905,\n\t\t\t912,  913,  914,  915,  916,  917,  918,  919,  920,  921,  928,  929,  930,\n\t\t\t931,  932,  933,  934,  935,  936,  937,  944,  945,  946,  947,  948,  949,\n\t\t\t950,  951,  952,  953,  960,  961,  962,  963,  964,  965,  966,  967,  968,\n\t\t\t969,  976,  977,  978,  979,  980,  981,  982,  983,  984,  985,  992,  993,\n\t\t\t994,  995,  996,  997,  998,  999, 1000, 1001, 1008, 1009, 1010, 1011, 1012,\n\t\t   1013, 1014, 1015, 1016, 1017,  906,  907,  938,  939,  970,  971, 1002, 1003,\n\t\t\t974,  975,  922,  923,  954,  955,  986,  987, 1018, 1019,  990,  991,   12,\n\t\t\t13,   268,  269,  524,  525,  780,  781,   46,   47,   28,   29,  284,  285,\n\t\t\t540,  541,  796,  797,   62,   63,   44,   45,  300,  301,  556,  557,  812,\n\t\t\t813,  302,  303,   60,   61,  316,  317,  572,  573,  828,  829,  318,  319,\n\t\t\t76,    77,  332,  333,  588,  589,  844,  845,  558,  559,   92,   93,  348,\n\t\t\t349,  604,  605,  860,  861,  574,  575,  108,  109,  364,  365,  620,  621,\n\t\t\t876,  877,  814,  815,  124,  125,  380,  381,  636,  637,  892,  893,  830,\n\t\t\t831,   14,   15,  270,  271,  526,  527,  782,  783,  110,  111,   30,   31,\n\t\t\t286,  287,  542,  543,  798,  799,  126,  127,  140,  141,  396,  397,  652,\n\t\t\t653,  908,  909,  174,  175,  156,  157,  412,  413,  668,  669,  924,  925,\n\t\t\t190,  191,  172,  173,  428,  429,  684,  685,  940,  941,  430,  431,  188,\n\t\t\t189,  444,  445,  700,  701,  956,  957,  446,  447,  204,  205,  460,  461,\n\t\t\t716,  717,  972,  973,  686,  687,  220,  221,  476,  477,  732,  733,  988,\n\t\t\t989,  702,  703,  236,  237,  492,  493,  748,  749, 1004, 1005,  942,  943,\n\t\t\t252,  253,  508,  509,  764,  765, 1020, 1021,  958,  959,  142,  143,  398,\n\t\t\t399,  654,  655,  910,  911,  238,  239,  158,  159,  414,  415,  670,  671,\n\t\t\t926,  927,  254,  255\n\t\t};\n\t//@formatter:on\n\n\treadonly int _numberOfDigits;\n\treadonly int _digitGroups;\n\n\t// Creates a densely packed decimal coder for the specified number of digits.\n\t// Current implementation only supports decoding and encoding `n * 3 + 1` number of digits with\n\t// `n > 0`, where the most significant digit is provided by the caller during decoding.\n\tpublic DenselyPackedDecimalCodec(int numberOfDigits)\n\t{\n\t\tif (numberOfDigits / DigitsPerGroup <= 0 || numberOfDigits % DigitsPerGroup != 1)\n\t\t\tthrow new ArgumentOutOfRangeException(nameof(numberOfDigits), $\"{nameof(numberOfDigits)} must be of form n * 3 + 1 with n > 0, was {numberOfDigits}.\");\n\t\t_numberOfDigits = numberOfDigits;\n\t\t_digitGroups = numberOfDigits / DigitsPerGroup;\n\t}\n\n\t// Decodes a densely packed decimal from a byte array to a BigInteger.\n\t// Digits are read from the end of the array to the front.\n\tpublic BigInteger DecodeValue(int signum, int firstDigit, byte[] decBytes)\n\t{\n\t\treturn DecodeValue(signum, firstDigit, decBytes, decBytes.Length - 1);\n\t}\n\n\t// Decodes a densely packed decimal from a byte array to a BigInteger.\n\t// Digits are read from `lsbIndex` of the array to the front.\n\tpublic BigInteger DecodeValue(int signum, int firstDigit, byte[] decBytes, int lsbIndex)\n\t{\n\t\tif (firstDigit < 0 || firstDigit > 9)\n\t\t\tthrow new ArgumentOutOfRangeException(nameof(firstDigit), $\"{nameof(firstDigit)} must be in range 0 <= firstDigit <= 9, was {firstDigit}.\");\n\t\tValidateLsbIndex(lsbIndex, decBytes.Length);\n\t\treturn DecodeValue0(signum, firstDigit, decBytes, lsbIndex);\n\t}\n\n\t// Encodes a BigInteger to a densely packed decimal in a byte array.\n\t// Digits are written from the end of the array to the front. The most significant digit is not encoded\n\t// into the array, but instead returned to the caller.\n\tpublic int EncodeValue(BigInteger value, byte[] decBytes)\n\t{\n\t\treturn EncodeValue(BigInteger.Abs(value), decBytes, decBytes.Length - 1);\n\t}\n\n\t// Encodes a BigInteger to a densely packed decimal in a byte array.\n\t// Digits are written from `lsbIndex` of the array to the front. The most significant digit is not encoded\n\t// into the array, but instead returned to the caller.\n\tpublic int EncodeValue(BigInteger value, byte[] decBytes, int lsbIndex)\n\t{\n\t\tValidateLsbIndex(lsbIndex, decBytes.Length);\n\n\t\treturn EncodeValue0(BigInteger.Abs(value), decBytes, lsbIndex);\n\t}\n\n\tBigInteger DecodeValue0(int signum, int firstDigit, byte[] decBytes, int lsbIndex)\n\t{\n\t\tvar digitChars = CreateZeroedCharArray();\n\t\tfor (var digitGroup = 0; digitGroup < _digitGroups; digitGroup++)\n\t\t{\n\t\t\t// Each digit group is 10 bits in two bytes in the array as [.., second, first, ..],\n\t\t\t// moving to the left for next digit groups. If there are unconsumed bits in the second byte,\n\t\t\t// the second byte becomes the first byte of the next group.\n\t\t\tvar digitBitsFromEnd = digitGroup * BitsPerGroup;\n\t\t\tvar firstByteBitOffset = digitBitsFromEnd % BitPerByte;\n\t\t\tvar firstByteIndex = lsbIndex - digitBitsFromEnd / BitPerByte;\n\n\t\t\tvar dpdGroupBits = 0x3FF & (\n\t\t\t\t\t(decBytes[firstByteIndex] & 0xFF) >>> firstByteBitOffset\n\t\t\t\t\t\t\t| decBytes[firstByteIndex - 1] << BitPerByte - firstByteBitOffset);\n\n\t\t\tif (dpdGroupBits != 0)\n\t\t\t{\n\t\t\t\tArray.Copy(DPDGroupBits2Digits, dpdGroupBits * DigitsPerGroup, digitChars, digitChars.Length - (digitGroup + 1) * DigitsPerGroup, DigitsPerGroup);\n\t\t\t}\n\t\t}\n\t\tif (firstDigit != 0)\n\t\t{\n\t\t\tdigitChars[1] = char.Parse(firstDigit.ToString());\n\t\t}\n\n\t\treturn ToBigInteger(signum, digitChars);\n\t}\n\n\tint EncodeValue0(BigInteger value, byte[] decBytes, int lsbIndex)\n\t{\n\t\tvar remainingValue = value;\n\t\tfor (var digitGroup = 0; digitGroup < _digitGroups; digitGroup++)\n\t\t{\n\t\t\t// Each digit group is 10 bits in two bytes in the array as [.., second, first, ..],\n\t\t\t// moving to the left for next digit groups. If there are unconsumed bits in the second byte,\n\t\t\t// the second byte becomes the first byte of the next group.\n\t\t\tvar digitBitsFromEnd = digitGroup * BitsPerGroup;\n\t\t\tvar firstByteBitOffset = digitBitsFromEnd % BitPerByte;\n\t\t\tvar firstByteIndex = lsbIndex - digitBitsFromEnd / BitPerByte;\n\n\t\t\tremainingValue = BigInteger.DivRem(remainingValue, OneThousand, out var remainder);\n\t\t\tvar currentGroup = Bin2DPD[(int)remainder];\n\n\t\t\tdecBytes[firstByteIndex] =\n\t\t\t\t\t(byte)(decBytes[firstByteIndex] | (currentGroup << firstByteBitOffset));\n\t\t\tdecBytes[firstByteIndex - 1] =\n\t\t\t\t\t(byte)(decBytes[firstByteIndex - 1] | (currentGroup >>> BitPerByte - firstByteBitOffset));\n\t\t}\n\t\tvar mostSignificantDigit = (int)remainingValue;\n\t\tDebug.Assert(0 <= mostSignificantDigit && mostSignificantDigit <= 9, $\"{nameof(mostSignificantDigit)} out of range, was {mostSignificantDigit}.\");\n\t\treturn mostSignificantDigit;\n\t}\n\n\tchar[] CreateZeroedCharArray()\n\t{\n\t\tvar digitChars = new char[_numberOfDigits + 1];\n\t\tfor (var i = 0; i < digitChars.Length; i++)\n\t\t{\n\t\t\tdigitChars[i] = '0';\n\t\t}\n\t\treturn digitChars;\n\t}\n\n\tvoid ValidateLsbIndex(int lsbIndex, int decBytesLength)\n\t{\n\t\tif (lsbIndex < 0 || lsbIndex >= decBytesLength)\n\t\t{\n\t\t\tthrow new IndexOutOfRangeException($\"{nameof(lsbIndex)} must be within array {nameof(decBytesLength)} with length of {decBytesLength}, was {lsbIndex}.\");\n\t\t}\n\t\tif ((lsbIndex + 1) * BitPerByte < BitsPerGroup * _digitGroups)\n\t\t{\n\t\t\tthrow new ArgumentException($\"Need at least {(BitsPerGroup * _digitGroups + 7) / BitPerByte} bytes for value, have {lsbIndex + 1} (lsbIndex = {lsbIndex})\");\n\t\t}\n\t}\n\n\tstatic BigInteger ToBigInteger(int signum, char[] digitChars)\n\t{\n\t\tvar digitCharIndex = FindFirstNonZero(digitChars);\n\t\tif (digitCharIndex == -1)\n\t\t{\n\t\t\t// All zeroes\n\t\t\treturn BigInteger.Zero;\n\t\t}\n\t\tif (signum == NegativeSignum)\n\t\t{\n\t\t\tdigitChars[--digitCharIndex] = '-';\n\t\t}\n\t\tvar s = new string(digitChars, digitCharIndex, digitChars.Length - digitCharIndex);\n\t\treturn BigInteger.Parse(s);\n\t}\n\n\tstatic int FindFirstNonZero(char[] digitChars)\n\t{\n\t\tfor (var index = 0; index < digitChars.Length; index++)\n\t\t{\n\t\t\tif (digitChars[index] != '0')\n\t\t\t{\n\t\t\t\treturn index;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/Descriptor.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.IO;\n\nnamespace FirebirdSql.Data.Common;\n\n/// <summary>\n/// Descriptor of query input and output parameters.\n/// </summary>\n/// <remarks>\n/// This is similar to the XSQLDA structure described\n/// in the Interbase 6.0 API docs.\n/// </remarks>\ninternal sealed class Descriptor\n{\n\t#region Fields\n\n\tprivate short _version;\n\tprivate short _count;\n\tprivate short _actualCount;\n\tprivate DbField[] _fields;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic short Version\n\t{\n\t\tget { return _version; }\n\t}\n\n\tpublic short Count\n\t{\n\t\tget { return _count; }\n\t}\n\n\tpublic short ActualCount\n\t{\n\t\tget { return _actualCount; }\n\t\tset { _actualCount = value; }\n\t}\n\n\t#endregion\n\n\t#region Indexers\n\n\tpublic DbField this[int index]\n\t{\n\t\tget { return _fields[index]; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tprivate Descriptor()\n\t{ }\n\n\tpublic Descriptor(short n)\n\t\t: this()\n\t{\n\t\t_version = IscCodes.SQLDA_VERSION1;\n\t\t_count = n;\n\t\t_actualCount = n;\n\t\t_fields = new DbField[n];\n\n\t\tfor (var i = 0; i < n; i++)\n\t\t{\n\t\t\t_fields[i] = new DbField();\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic void ResetValues()\n\t{\n\t\tfor (var i = 0; i < _fields.Length; i++)\n\t\t{\n\t\t\t_fields[i].SetValue(null);\n\t\t}\n\t}\n\n\tinternal sealed class BlrData\n\t{\n\t\tpublic byte[] Data { get; }\n\t\tpublic int Length { get; }\n\n\t\tpublic BlrData(byte[] data, int length)\n\t\t{\n\t\t\tData = data;\n\t\t\tLength = length;\n\t\t}\n\t}\n\tpublic BlrData ToBlr()\n\t{\n\t\tusing (var blr = new MemoryStream(256))\n\t\t{\n\t\t\tvar length = 0;\n\n\t\t\tblr.WriteByte(IscCodes.blr_version5);\n\t\t\tblr.WriteByte(IscCodes.blr_begin);\n\t\t\tblr.WriteByte(IscCodes.blr_message);\n\t\t\tblr.WriteByte(0);\n\t\t\tvar par_count = Count * 2;\n\t\t\tblr.WriteByte((byte)(par_count & 255));\n\t\t\tblr.WriteByte((byte)(par_count >> 8));\n\n\t\t\tfor (var i = 0; i < _fields.Length; i++)\n\t\t\t{\n\t\t\t\tvar dtype = _fields[i].SqlType;\n\t\t\t\tint len = _fields[i].Length;\n\n\t\t\t\tswitch (dtype)\n\t\t\t\t{\n\t\t\t\t\tcase IscCodes.SQL_VARYING:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_varying);\n\t\t\t\t\t\tblr.WriteByte((byte)(len & 255));\n\t\t\t\t\t\tblr.WriteByte((byte)(len >> 8));\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 2);\n\t\t\t\t\t\tlength += len + 2;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_TEXT:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_text);\n\t\t\t\t\t\tblr.WriteByte((byte)(len & 255));\n\t\t\t\t\t\tblr.WriteByte((byte)(len >> 8));\n\t\t\t\t\t\t// no align\n\t\t\t\t\t\tlength += len;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_DOUBLE:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_double);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 8);\n\t\t\t\t\t\tlength += 8;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_FLOAT:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_float);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 4);\n\t\t\t\t\t\tlength += 4;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_D_FLOAT:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_d_float);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 8);\n\t\t\t\t\t\tlength += 8;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_TYPE_DATE:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_sql_date);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 4);\n\t\t\t\t\t\tlength += 4;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_TYPE_TIME:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_sql_time);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 4);\n\t\t\t\t\t\tlength += 4;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_TIMESTAMP:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_timestamp);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 4);\n\t\t\t\t\t\tlength += 8;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_BLOB:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_quad);\n\t\t\t\t\t\tblr.WriteByte(0);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 4);\n\t\t\t\t\t\tlength += 8;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_ARRAY:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_quad);\n\t\t\t\t\t\tblr.WriteByte(0);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 4);\n\t\t\t\t\t\tlength += 8;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_LONG:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_long);\n\t\t\t\t\t\tblr.WriteByte((byte)_fields[i].NumericScale);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 4);\n\t\t\t\t\t\tlength += 4;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_SHORT:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_short);\n\t\t\t\t\t\tblr.WriteByte((byte)_fields[i].NumericScale);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 2);\n\t\t\t\t\t\tlength += 2;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_INT64:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_int64);\n\t\t\t\t\t\tblr.WriteByte((byte)_fields[i].NumericScale);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 8);\n\t\t\t\t\t\tlength += 8;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_QUAD:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_quad);\n\t\t\t\t\t\tblr.WriteByte((byte)_fields[i].NumericScale);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 4);\n\t\t\t\t\t\tlength += 8;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_BOOLEAN:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_bool);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 1);\n\t\t\t\t\t\tlength += 1;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_TIMESTAMP_TZ_EX:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_ex_timestamp_tz);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 4);\n\t\t\t\t\t\tlength += 12;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_TIMESTAMP_TZ:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_timestamp_tz);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 4);\n\t\t\t\t\t\tlength += 10;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_TIME_TZ:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_sql_time_tz);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 4);\n\t\t\t\t\t\tlength += 6;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_TIME_TZ_EX:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_ex_time_tz);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 4);\n\t\t\t\t\t\tlength += 8;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_DEC16:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_dec64);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 8);\n\t\t\t\t\t\tlength += 8;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_DEC34:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_dec128);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 8);\n\t\t\t\t\t\tlength += 16;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_INT128:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_int128);\n\t\t\t\t\t\tblr.WriteByte((byte)_fields[i].NumericScale);\n\t\t\t\t\t\tlength = TypeHelper.BlrAlign(length, 8);\n\t\t\t\t\t\tlength += 16;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase IscCodes.SQL_NULL:\n\t\t\t\t\t\tblr.WriteByte(IscCodes.blr_text);\n\t\t\t\t\t\tblr.WriteByte((byte)(len & 255));\n\t\t\t\t\t\tblr.WriteByte((byte)(len >> 8));\n\t\t\t\t\t\t// no align\n\t\t\t\t\t\tlength += len;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tblr.WriteByte(IscCodes.blr_short);\n\t\t\t\tblr.WriteByte(0);\n\n\t\t\t\tlength = TypeHelper.BlrAlign(length, 2);\n\t\t\t\tlength += 2;\n\t\t\t}\n\n\t\t\tblr.WriteByte(IscCodes.blr_end);\n\t\t\tblr.WriteByte(IscCodes.blr_eoc);\n\n\t\t\treturn new BlrData(blr.ToArray(), length);\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/EmptyDescriptorFiller.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal sealed class EmptyDescriptorFiller : IDescriptorFiller\n{\n\tpublic static readonly EmptyDescriptorFiller Instance = new EmptyDescriptorFiller();\n\n\tprivate EmptyDescriptorFiller()\n\t{ }\n\n\tpublic void Fill(Descriptor descriptor, int index)\n\t{ }\n\n\tpublic ValueTask FillAsync(Descriptor descriptor, int index, CancellationToken cancellationToken = default)\n\t{\n\t\treturn ValueTask.CompletedTask;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/EventParameterBuffer.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System.Text;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal sealed class EventParameterBuffer : ParameterBuffer\n{\n\tpublic EventParameterBuffer(Encoding encoding)\n\t{\n\t\tEncoding = encoding;\n\t}\n\n\tpublic void Append(byte[] content, int actualCount)\n\t{\n\t\tWriteByte(content.Length);\n\t\tWrite(content);\n\t\tWrite(actualCount);\n\t}\n\n\tpublic void Append(string content, int actualCount)\n\t{\n\t\tAppend(Encoding.GetBytes(content), actualCount);\n\t}\n\n\tpublic Encoding Encoding { get; }\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/ExplicitCancellation.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\nusing System.Threading;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class ExplicitCancellation\n{\n\tpublic static ExplicitCancel Enter(CancellationToken cancellationToken, Action explicitCancel)\n\t{\n\t\tif (cancellationToken.IsCancellationRequested)\n\t\t{\n\t\t\texplicitCancel();\n\t\t\tthrow new OperationCanceledException(cancellationToken);\n\t\t}\n\t\tvar ctr = cancellationToken.Register(explicitCancel);\n\t\treturn new ExplicitCancel(ctr);\n\t}\n\n\t[MethodImpl(MethodImplOptions.AggressiveInlining)]\n\tstatic void ExitExplicitCancel(CancellationTokenRegistration cancellationTokenRegistration)\n\t{\n\t\tcancellationTokenRegistration.Dispose();\n\t}\n\n\t[StructLayout(LayoutKind.Auto)]\n\tinternal readonly struct ExplicitCancel : IDisposable\n\t{\n\t\treadonly CancellationTokenRegistration _cancellationTokenRegistration;\n\n\t\tpublic ExplicitCancel(CancellationTokenRegistration cancellationTokenRegistration)\n\t\t{\n\t\t\t_cancellationTokenRegistration = cancellationTokenRegistration;\n\t\t}\n\n\t\tpublic void Dispose()\n\t\t{\n\t\t\tExitExplicitCancel(_cancellationTokenRegistration);\n\t\t}\n\n\t\tpublic readonly CancellationToken CancellationToken => CancellationToken.None;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/Extensions.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class Extensions\n{\n\textension(IntPtr ptr)\n\t{\n\t\tpublic int AsInt()\n\t\t{\n\t\t\treturn (int)ptr.ToInt64();\n\t\t}\n\t}\n\n\textension(BinaryReader binaryReader)\n\t{\n\t\tpublic IntPtr ReadIntPtr()\n\t\t{\n\t\t\tif (IntPtr.Size == sizeof(int))\n\t\t\t{\n\t\t\t\treturn new IntPtr(binaryReader.ReadInt32());\n\t\t\t}\n\t\t\telse if (IntPtr.Size == sizeof(long))\n\t\t\t{\n\t\t\t\treturn new IntPtr(binaryReader.ReadInt64());\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthrow new NotSupportedException();\n\t\t\t}\n\t\t}\n\t}\n\n\textension(byte[] b)\n\t{\n\t\tpublic string ToHexString()\n\t\t{\n\t\t\treturn Convert.ToHexString(b);\n\t\t}\n\t}\n\n\textension<T>(T[] array)\n\t{\n\t\tpublic IEnumerable<IEnumerable<T>> Split(int size)\n\t\t{\n\t\t\tfor (var i = 0; i < (float)array.Length / size; i++)\n\t\t\t{\n\t\t\t\tyield return array.Skip(i * size).Take(size);\n\t\t\t}\n\t\t}\n\t}\n\n\textension(string s)\n\t{\n\t\tpublic IEnumerable<char[]> EnumerateRunesToChars()\n\t\t{\n\t\t\tif (s == null)\n\t\t\t\tthrow new ArgumentNullException(nameof(s));\n\n\t\t\treturn s.EnumerateRunes().Select(r =>\n\t\t\t{\n\t\t\t\tvar result = new char[r.Utf16SequenceLength];\n\t\t\t\tr.EncodeToUtf16(result);\n\t\t\t\treturn result;\n\t\t\t});\n\t\t}\n\t}\n\n\textension(Encoding)\n\t{\n\t\tpublic static Encoding GetANSIEncoding()\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\treturn Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.ANSICodePage);\n\t\t\t}\n\t\t\tcatch (Exception)\n\t\t\t{\n\t\t\t\treturn Encoding.Default;\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/IDescriptorFiller.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal interface IDescriptorFiller\n{\n\tvoid Fill(Descriptor descriptor, int index);\n\tValueTask FillAsync(Descriptor descriptor, int index, CancellationToken cancellationToken = default);\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/InfoValuesConverter.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class InfoValuesHelper\n{\n\tpublic static T ConvertValue<T>(object value) => value is IConvertible ? (T)Convert.ChangeType(value, typeof(T)) : (T)value;\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/Int128Helper.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Diagnostics;\nusing System.Numerics;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class Int128Helper\n{\n\tpublic static BigInteger GetInt128(byte[] value)\n\t{\n\t\tDebug.Assert(value.Length == 16);\n\t\tif (!BitConverter.IsLittleEndian)\n\t\t{\n\t\t\tArray.Reverse(value);\n\t\t}\n\t\treturn new BigInteger(value);\n\t}\n\n\tpublic static byte[] GetBytes(BigInteger value)\n\t{\n\t\tvar result = value.ToByteArray();\n\t\tif (result.Length > 16)\n\t\t{\n\t\t\tthrow new ArgumentOutOfRangeException(\"Value too big for Int128.\");\n\t\t}\n\t\tif (result.Length < 16)\n\t\t{\n\t\t\tvar padding = value.Sign == -1 ? (byte)255 : (byte)0;\n\t\t\tvar tmp = new byte[16] { padding, padding, padding, padding, padding, padding, padding, padding, padding, padding, padding, padding, padding, padding, padding, padding };\n\t\t\tBuffer.BlockCopy(result, 0, tmp, 0, result.Length);\n\t\t\tresult = tmp;\n\t\t}\n\t\tif (!BitConverter.IsLittleEndian)\n\t\t{\n\t\t\tArray.Reverse(result);\n\t\t}\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/IscCodes.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\n// This file was originally ported from Jaybird\n\nusing System;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class IscCodes\n{\n\t#region General\n\n\tpublic const int SQLDA_VERSION1 = 1;\n\tpublic const int SQL_DIALECT_V5 = 1;\n\tpublic const int SQL_DIALECT_V6_TRANSITION = 2;\n\tpublic const int SQL_DIALECT_V6 = 3;\n\tpublic const int SQL_DIALECT_CURRENT = SQL_DIALECT_V6;\n\tpublic const int DSQL_close = 1;\n\tpublic const int DSQL_drop = 2;\n\tpublic const int ARRAY_DESC_COLUMN_MAJOR = 1;   /* Set for FORTRAN */\n\tpublic const int ISC_STATUS_LENGTH = 20;\n\tpublic const ushort INVALID_OBJECT = 0xFFFF;\n\n\t#endregion\n\n\t#region Buffer sizes\n\n\tpublic const int BUFFER_SIZE_128 = 128;\n\tpublic const int BUFFER_SIZE_256 = 256;\n\tpublic const int BUFFER_SIZE_32K = 32768;\n\tpublic const int DEFAULT_MAX_BUFFER_SIZE = 8192;\n\tpublic const int ROWS_AFFECTED_BUFFER_SIZE = 34;\n\tpublic const int STATEMENT_TYPE_BUFFER_SIZE = 8;\n\tpublic const int PREPARE_INFO_BUFFER_SIZE = 32768;\n\n\t#endregion\n\n\t#region Protocol Codes\n\n\tpublic const int GenericAchitectureClient = 1;\n\n\tpublic const int CONNECT_VERSION2 = 2;\n\tpublic const int CONNECT_VERSION3 = 3;\n\tpublic const int PROTOCOL_VERSION3 = 3;\n\tpublic const int PROTOCOL_VERSION4 = 4;\n\tpublic const int PROTOCOL_VERSION5 = 5;\n\tpublic const int PROTOCOL_VERSION6 = 6;\n\tpublic const int PROTOCOL_VERSION7 = 7;\n\tpublic const int PROTOCOL_VERSION8 = 8;\n\tpublic const int PROTOCOL_VERSION9 = 9;\n\tpublic const int PROTOCOL_VERSION10 = 10;\n\n\tpublic const int FB_PROTOCOL_FLAG = 0x8000;\n\tpublic const int FB_PROTOCOL_MASK = ~FB_PROTOCOL_FLAG;\n\n\tpublic const int PROTOCOL_VERSION11 = FB_PROTOCOL_FLAG | 11;\n\tpublic const int PROTOCOL_VERSION12 = FB_PROTOCOL_FLAG | 12;\n\tpublic const int PROTOCOL_VERSION13 = FB_PROTOCOL_FLAG | 13;\n\tpublic const int PROTOCOL_VERSION15 = FB_PROTOCOL_FLAG | 15;\n\tpublic const int PROTOCOL_VERSION16 = FB_PROTOCOL_FLAG | 16;\n\n\tpublic const int p_cnct_min_type = 0;\n\n\tpublic const int ptype_rpc = 2;\n\tpublic const int ptype_batch_send = 3;\n\tpublic const int ptype_out_of_band = 4;\n\tpublic const int ptype_lazy_send = 5;\n\n\tpublic const int pflag_compress = 0x100;\n\n\tpublic const int WIRE_CRYPT_DISABLED = 0;\n\tpublic const int WIRE_CRYPT_ENABLED = 1;\n\tpublic const int WIRE_CRYPT_REQUIRED = 2;\n\n\t#endregion\n\n\t#region Statement Flags\n\n\tpublic const int STMT_DEFER_EXECUTE = 4;\n\n\t#endregion\n\n\t#region Server Class\n\n\tpublic const int isc_info_db_class_classic_access = 13;\n\tpublic const int isc_info_db_class_server_access = 14;\n\n\t#endregion\n\n\t#region Operation Codes\n\n\t// Operation (packet) types\n\tpublic const int op_void = 0;   // Packet has been voided\n\tpublic const int op_connect = 1;    // Connect to remote server\n\tpublic const int op_exit = 2;   // Remote end has exitted\n\tpublic const int op_accept = 3; // Server accepts connection\n\tpublic const int op_reject = 4; // Server rejects connection\n\tpublic const int op_protocol = 5;   // Protocol\tselection\n\tpublic const int op_disconnect = 6; // Connect is going\taway\n\tpublic const int op_credit = 7; // Grant (buffer) credits\n\tpublic const int op_continuation = 8;   // Continuation\tpacket\n\tpublic const int op_response = 9;   // Generic response\tblock\n\n\t// Page\tserver operations\n\tpublic const int op_open_file = 10; // Open\tfile for page service\n\tpublic const int op_create_file = 11;   // Create file for page\tservice\n\tpublic const int op_close_file = 12;    // Close file for page service\n\tpublic const int op_read_page = 13; // optionally lock and read\tpage\n\tpublic const int op_write_page = 14;    // write page and optionally release lock\n\tpublic const int op_lock = 15;  // sieze lock\n\tpublic const int op_convert_lock = 16;  // convert existing\tlock\n\tpublic const int op_release_lock = 17;  // release existing\tlock\n\tpublic const int op_blocking = 18;  // blocking\tlock message\n\n\t// Full\tcontext\tserver operations\n\tpublic const int op_attach = 19;    // Attach database\n\tpublic const int op_create = 20;    // Create database\n\tpublic const int op_detach = 21;    // Detach database\n\tpublic const int op_compile = 22;   // Request based operations\n\tpublic const int op_start = 23;\n\tpublic const int op_start_and_send = 24;\n\tpublic const int op_send = 25;\n\tpublic const int op_receive = 26;\n\tpublic const int op_unwind = 27;\n\tpublic const int op_release = 28;\n\n\tpublic const int op_transaction = 29;   // Transaction operations\n\tpublic const int op_commit = 30;\n\tpublic const int op_rollback = 31;\n\tpublic const int op_prepare = 32;\n\tpublic const int op_reconnect = 33;\n\n\tpublic const int op_create_blob = 34;   // Blob\toperations //\n\tpublic const int op_open_blob = 35;\n\tpublic const int op_get_segment = 36;\n\tpublic const int op_put_segment = 37;\n\tpublic const int op_cancel_blob = 38;\n\tpublic const int op_close_blob = 39;\n\n\tpublic const int op_info_database = 40; // Information services\n\tpublic const int op_info_request = 41;\n\tpublic const int op_info_transaction = 42;\n\tpublic const int op_info_blob = 43;\n\n\tpublic const int op_batch_segments = 44;    // Put a bunch of blob segments\n\n\tpublic const int op_mgr_set_affinity = 45;  // Establish server\taffinity\n\tpublic const int op_mgr_clear_affinity = 46;    // Break server\taffinity\n\tpublic const int op_mgr_report = 47;    // Report on server\n\n\tpublic const int op_que_events = 48;    // Que event notification request\n\tpublic const int op_cancel_events = 49; // Cancel event\tnotification request\n\tpublic const int op_commit_retaining = 50;  // Commit retaining\t(what else)\n\tpublic const int op_prepare2 = 51;  // Message form\tof prepare\n\tpublic const int op_event = 52; // Completed event request (asynchronous)\n\tpublic const int op_connect_request = 53;   // Request to establish\tconnection\n\tpublic const int op_aux_connect = 54;   // Establish auxiliary connection\n\tpublic const int op_ddl = 55;   // DDL call\n\tpublic const int op_open_blob2 = 56;\n\tpublic const int op_create_blob2 = 57;\n\tpublic const int op_get_slice = 58;\n\tpublic const int op_put_slice = 59;\n\tpublic const int op_slice = 60; // Successful response to public const int op_get_slice\n\tpublic const int op_seek_blob = 61; // Blob\tseek operation\n\n\t// DSQL\toperations //\n\tpublic const int op_allocate_statement = 62;    // allocate\ta statment handle\n\tpublic const int op_execute = 63;   // execute a prepared statement\n\tpublic const int op_exec_immediate = 64;    // execute a statement\n\tpublic const int op_fetch = 65; // fetch a record\n\tpublic const int op_fetch_response = 66;    // response\tfor\trecord fetch\n\tpublic const int op_free_statement = 67;    // free\ta statement\n\tpublic const int op_prepare_statement = 68; // prepare a statement\n\tpublic const int op_set_cursor = 69;    // set a cursor\tname\n\tpublic const int op_info_sql = 70;\n\tpublic const int op_dummy = 71; // dummy packet\tto detect loss of client\n\tpublic const int op_response_piggyback = 72;    // response\tblock for piggybacked messages\n\tpublic const int op_start_and_receive = 73;\n\tpublic const int op_start_send_and_receive = 74;\n\n\tpublic const int op_exec_immediate2 = 75;   // execute an immediate\tstatement with msgs\n\tpublic const int op_execute2 = 76;  // execute a statement with\tmsgs\n\tpublic const int op_insert = 77;\n\tpublic const int op_sql_response = 78;  // response\tfrom execute; exec immed; insert\n\tpublic const int op_transact = 79;\n\tpublic const int op_transact_response = 80;\n\tpublic const int op_drop_database = 81;\n\tpublic const int op_service_attach = 82;\n\tpublic const int op_service_detach = 83;\n\tpublic const int op_service_info = 84;\n\tpublic const int op_service_start = 85;\n\tpublic const int op_rollback_retaining = 86;\n\n\t// Two following opcode are used in vulcan.\n\t// No plans to implement them completely for a while, but to\n\t// support protocol 11, where they are used, have them here.\n\tpublic const int op_update_account_info = 87;\n\tpublic const int op_authenticate_user = 88;\n\n\tpublic const int op_partial = 89;   // packet is not complete - delay processing\n\tpublic const int op_trusted_auth = 90;\n\tpublic const int op_cancel = 91;\n\tpublic const int op_cont_auth = 92;\n\tpublic const int op_ping = 93;\n\tpublic const int op_accept_data = 94;\n\tpublic const int op_abort_aux_connection = 95;\n\tpublic const int op_crypt = 96;\n\tpublic const int op_crypt_key_callback = 97;\n\tpublic const int op_cond_accept = 98;\n\n\tpublic const int op_batch_create = 99;\n\tpublic const int op_batch_msg = 100;\n\tpublic const int op_batch_exec = 101;\n\tpublic const int op_batch_rls = 102;\n\tpublic const int op_batch_cs = 103;\n\tpublic const int op_batch_regblob = 104;\n\tpublic const int op_batch_blob_stream = 105;\n\tpublic const int op_batch_set_bpb = 106;\n\n\tpublic const int op_repl_data = 107;\n\tpublic const int op_repl_req = 108;\n\n\tpublic const int op_batch_cancel = 109;\n\n\t#endregion\n\n\t#region Database Parameter Block\n\n\tpublic const int isc_dpb_version1 = 1;\n\tpublic const int isc_dpb_version2 = 2;\n\n\tpublic const int isc_dpb_cdd_pathname = 1;\n\tpublic const int isc_dpb_allocation = 2;\n\tpublic const int isc_dpb_journal = 3;\n\tpublic const int isc_dpb_page_size = 4;\n\tpublic const int isc_dpb_num_buffers = 5;\n\tpublic const int isc_dpb_buffer_length = 6;\n\tpublic const int isc_dpb_debug = 7;\n\tpublic const int isc_dpb_garbage_collect = 8;\n\tpublic const int isc_dpb_verify = 9;\n\tpublic const int isc_dpb_sweep = 10;\n\tpublic const int isc_dpb_enable_journal = 11;\n\tpublic const int isc_dpb_disable_journal = 12;\n\tpublic const int isc_dpb_dbkey_scope = 13;\n\tpublic const int isc_dpb_number_of_users = 14;\n\tpublic const int isc_dpb_trace = 15;\n\tpublic const int isc_dpb_no_garbage_collect = 16;\n\tpublic const int isc_dpb_damaged = 17;\n\tpublic const int isc_dpb_license = 18;\n\tpublic const int isc_dpb_sys_user_name = 19;\n\tpublic const int isc_dpb_encrypt_key = 20;\n\tpublic const int isc_dpb_activate_shadow = 21;\n\tpublic const int isc_dpb_sweep_interval = 22;\n\tpublic const int isc_dpb_delete_shadow = 23;\n\tpublic const int isc_dpb_force_write = 24;\n\tpublic const int isc_dpb_begin_log = 25;\n\tpublic const int isc_dpb_quit_log = 26;\n\tpublic const int isc_dpb_no_reserve = 27;\n\tpublic const int isc_dpb_user_name = 28;\n\tpublic const int isc_dpb_password = 29;\n\tpublic const int isc_dpb_password_enc = 30;\n\tpublic const int isc_dpb_sys_user_name_enc = 31;\n\tpublic const int isc_dpb_interp = 32;\n\tpublic const int isc_dpb_online_dump = 33;\n\tpublic const int isc_dpb_old_file_size = 34;\n\tpublic const int isc_dpb_old_num_files = 35;\n\tpublic const int isc_dpb_old_file = 36;\n\tpublic const int isc_dpb_old_start_page = 37;\n\tpublic const int isc_dpb_old_start_seqno = 38;\n\tpublic const int isc_dpb_old_start_file = 39;\n\tpublic const int isc_dpb_drop_walfile = 40;\n\tpublic const int isc_dpb_old_dump_id = 41;\n\tpublic const int isc_dpb_wal_backup_dir = 42;\n\tpublic const int isc_dpb_wal_chkptlen = 43;\n\tpublic const int isc_dpb_wal_numbufs = 44;\n\tpublic const int isc_dpb_wal_bufsize = 45;\n\tpublic const int isc_dpb_wal_grp_cmt_wait = 46;\n\tpublic const int isc_dpb_lc_messages = 47;\n\tpublic const int isc_dpb_lc_ctype = 48;\n\tpublic const int isc_dpb_cache_manager = 49;\n\tpublic const int isc_dpb_shutdown = 50;\n\tpublic const int isc_dpb_online = 51;\n\tpublic const int isc_dpb_shutdown_delay = 52;\n\tpublic const int isc_dpb_reserved = 53;\n\tpublic const int isc_dpb_overwrite = 54;\n\tpublic const int isc_dpb_sec_attach = 55;\n\tpublic const int isc_dpb_disable_wal = 56;\n\tpublic const int isc_dpb_connect_timeout = 57;\n\tpublic const int isc_dpb_dummy_packet_interval = 58;\n\tpublic const int isc_dpb_gbak_attach = 59;\n\tpublic const int isc_dpb_sql_role_name = 60;\n\tpublic const int isc_dpb_set_page_buffers = 61;\n\tpublic const int isc_dpb_working_directory = 62;\n\tpublic const int isc_dpb_sql_dialect = 63;\n\tpublic const int isc_dpb_set_db_readonly = 64;\n\tpublic const int isc_dpb_set_db_sql_dialect = 65;\n\tpublic const int isc_dpb_gfix_attach = 66;\n\tpublic const int isc_dpb_gstat_attach = 67;\n\tpublic const int isc_dpb_set_db_charset = 68;\n\tpublic const int isc_dpb_gsec_attach = 69;\n\tpublic const int isc_dpb_address_path = 70;\n\tpublic const int isc_dpb_process_id = 71;\n\tpublic const int isc_dpb_no_db_triggers = 72;\n\tpublic const int isc_dpb_trusted_auth = 73;\n\tpublic const int isc_dpb_process_name = 74;\n\tpublic const int isc_dpb_trusted_role = 75;\n\tpublic const int isc_dpb_org_filename = 76;\n\tpublic const int isc_dpb_utf8_filename = 77;\n\tpublic const int isc_dpb_ext_call_depth = 78;\n\tpublic const int isc_dpb_auth_block = 79;\n\tpublic const int isc_dpb_client_version = 80;\n\tpublic const int isc_dpb_remote_protocol = 81;\n\tpublic const int isc_dpb_host_name = 82;\n\tpublic const int isc_dpb_os_user = 83;\n\tpublic const int isc_dpb_specific_auth_data = 84;\n\tpublic const int isc_dpb_auth_plugin_list = 85;\n\tpublic const int isc_dpb_auth_plugin_name = 86;\n\tpublic const int isc_dpb_config = 87;\n\tpublic const int isc_dpb_nolinger = 88;\n\tpublic const int isc_dpb_reset_icu = 89;\n\tpublic const int isc_dpb_map_attach = 90;\n\tpublic const int isc_dpb_session_time_zone = 91;\n\tpublic const int isc_dpb_set_db_replica = 92;\n\tpublic const int isc_dpb_set_bind = 93;\n\tpublic const int isc_dpb_decfloat_round = 94;\n\tpublic const int isc_dpb_decfloat_traps = 95;\n\tpublic const int isc_dpb_clear_map = 96;\n\tpublic const int isc_dpb_parallel_workers = 100;\n\tpublic const int isc_dpb_worker_attach = 101;\n\n\t#endregion\n\n\t#region Transaction Parameter Block\n\n\tpublic const int isc_tpb_version1 = 1;\n\tpublic const int isc_tpb_version3 = 3;\n\tpublic const int isc_tpb_consistency = 1;\n\tpublic const int isc_tpb_concurrency = 2;\n\tpublic const int isc_tpb_shared = 3;\n\tpublic const int isc_tpb_protected = 4;\n\tpublic const int isc_tpb_exclusive = 5;\n\tpublic const int isc_tpb_wait = 6;\n\tpublic const int isc_tpb_nowait = 7;\n\tpublic const int isc_tpb_read = 8;\n\tpublic const int isc_tpb_write = 9;\n\tpublic const int isc_tpb_lock_read = 10;\n\tpublic const int isc_tpb_lock_write = 11;\n\tpublic const int isc_tpb_verb_time = 12;\n\tpublic const int isc_tpb_commit_time = 13;\n\tpublic const int isc_tpb_ignore_limbo = 14;\n\tpublic const int isc_tpb_read_committed = 15;\n\tpublic const int isc_tpb_autocommit = 16;\n\tpublic const int isc_tpb_rec_version = 17;\n\tpublic const int isc_tpb_no_rec_version = 18;\n\tpublic const int isc_tpb_restart_requests = 19;\n\tpublic const int isc_tpb_no_auto_undo = 20;\n\tpublic const int isc_tpb_lock_timeout = 21;\n\tpublic const int isc_tpb_read_consistency = 22;\n\tpublic const int isc_tpb_at_snapshot_number = 23;\n\n\t#endregion\n\n\t#region Services Parameter Block\n\n\tpublic const int isc_spb_version1 = 1;\n\tpublic const int isc_spb_current_version = 2;\n\tpublic const int isc_spb_version = isc_spb_current_version;\n\tpublic const int isc_spb_version3 = 3;\n\tpublic const int isc_spb_user_name = isc_dpb_user_name;\n\tpublic const int isc_spb_sys_user_name = isc_dpb_sys_user_name;\n\tpublic const int isc_spb_sys_user_name_enc = isc_dpb_sys_user_name_enc;\n\tpublic const int isc_spb_password = isc_dpb_password;\n\tpublic const int isc_spb_password_enc = isc_dpb_password_enc;\n\tpublic const int isc_spb_command_line = 105;\n\tpublic const int isc_spb_dbname = 106;\n\tpublic const int isc_spb_verbose = 107;\n\tpublic const int isc_spb_options = 108;\n\tpublic const int isc_spb_address_path = 109;\n\tpublic const int isc_spb_process_id = 110;\n\tpublic const int isc_spb_trusted_auth = 111;\n\tpublic const int isc_spb_process_name = 112;\n\tpublic const int isc_spb_trusted_role = 113;\n\tpublic const int isc_spb_verbint = 114;\n\tpublic const int isc_spb_auth_block = 115;\n\tpublic const int isc_spb_auth_plugin_name = 116;\n\tpublic const int isc_spb_auth_plugin_list = 117;\n\tpublic const int isc_spb_utf8_filename = 118;\n\tpublic const int isc_spb_client_version = 119;\n\tpublic const int isc_spb_remote_protocol = 120;\n\tpublic const int isc_spb_host_name = 121;\n\tpublic const int isc_spb_os_user = 122;\n\tpublic const int isc_spb_config = 123;\n\tpublic const int isc_spb_expected_db = 124;\n\n\tpublic const int isc_spb_connect_timeout = isc_dpb_connect_timeout;\n\tpublic const int isc_spb_dummy_packet_interval = isc_dpb_dummy_packet_interval;\n\tpublic const int isc_spb_sql_role_name = isc_dpb_sql_role_name;\n\n\tpublic const int isc_spb_specific_auth_data = isc_spb_trusted_auth;\n\n\tpublic const int isc_spb_num_att = 5;\n\tpublic const int isc_spb_num_db = 6;\n\n\t#endregion\n\n\t#region Services Actions\n\n\tpublic const int isc_action_svc_backup = 1; /* Starts database backup process on the server */\n\tpublic const int isc_action_svc_restore = 2; /* Starts database restore process on the server */\n\tpublic const int isc_action_svc_repair = 3; /* Starts database repair process on the server */\n\tpublic const int isc_action_svc_add_user = 4; /* Adds a new user to the security database */\n\tpublic const int isc_action_svc_delete_user = 5; /* Deletes a user record from the security database */\n\tpublic const int isc_action_svc_modify_user = 6; /* Modifies a user record in the security database */\n\tpublic const int isc_action_svc_display_user = 7; /* Displays a user record from the security database */\n\tpublic const int isc_action_svc_properties = 8; /* Sets database properties */\n\tpublic const int isc_action_svc_add_license = 9; /* Adds a license to the license file */\n\tpublic const int isc_action_svc_remove_license = 10; /* Removes a license from the license file */\n\tpublic const int isc_action_svc_db_stats = 11; /* Retrieves database statistics */\n\tpublic const int isc_action_svc_get_ib_log = 12; /* Retrieves the InterBase log file from the server */\n\tpublic const int isc_action_svc_get_fb_log = 12; /* Retrieves the Firebird log file from the server */\n\tpublic const int isc_action_svc_nbak = 20; /* Incremental nbackup */\n\tpublic const int isc_action_svc_nrest = 21; /* Incremental database restore */\n\tpublic const int isc_action_svc_trace_start = 22; // Start trace session\n\tpublic const int isc_action_svc_trace_stop = 23; // Stop trace session\n\tpublic const int isc_action_svc_trace_suspend = 24; // Suspend trace session\n\tpublic const int isc_action_svc_trace_resume = 25; // Resume trace session\n\tpublic const int isc_action_svc_trace_list = 26; // List existing sessions\n\tpublic const int isc_action_svc_set_mapping = 27; // Set auto admins mapping in security database\n\tpublic const int isc_action_svc_drop_mapping = 28; // Drop auto admins mapping in security database\n\tpublic const int isc_action_svc_display_user_adm = 29; // Displays user(s) from security database with admin info\n\tpublic const int isc_action_svc_validate = 30; // Starts database online validation\n\tpublic const int isc_action_svc_nfix = 31; // Fixup database after file system copy\n\n\t#endregion\n\n\t#region Services Information\n\n\tpublic const int isc_info_svc_svr_db_info = 50; /* Retrieves the number\tof attachments and databases */\n\tpublic const int isc_info_svc_get_license = 51; /* Retrieves all license keys and IDs from the license file\t*/\n\tpublic const int isc_info_svc_get_license_mask = 52;    /* Retrieves a bitmask representing\tlicensed options on\tthe\tserver */\n\tpublic const int isc_info_svc_get_config = 53;  /* Retrieves the parameters\tand\tvalues for IB_CONFIG */\n\tpublic const int isc_info_svc_version = 54; /* Retrieves the version of\tthe\tservices manager */\n\tpublic const int isc_info_svc_server_version = 55;  /* Retrieves the version of\tthe\tInterBase server */\n\tpublic const int isc_info_svc_implementation = 56;  /* Retrieves the implementation\tof the InterBase server\t*/\n\tpublic const int isc_info_svc_capabilities = 57;    /* Retrieves a bitmask representing\tthe\tserver's capabilities */\n\tpublic const int isc_info_svc_user_dbpath = 58; /* Retrieves the path to the security database in use by the server\t*/\n\tpublic const int isc_info_svc_get_env = 59; /* Retrieves the setting of\t$INTERBASE */\n\tpublic const int isc_info_svc_get_env_lock = 60;    /* Retrieves the setting of\t$INTERBASE_LCK */\n\tpublic const int isc_info_svc_get_env_msg = 61; /* Retrieves the setting of\t$INTERBASE_MSG */\n\tpublic const int isc_info_svc_line = 62;    /* Retrieves 1 line\tof service output per call */\n\tpublic const int isc_info_svc_to_eof = 63;  /* Retrieves as much of\tthe\tserver output as will fit in the supplied buffer */\n\tpublic const int isc_info_svc_timeout = 64; /* Sets\t/ signifies\ta timeout value\tfor\treading\tservice\tinformation\t*/\n\tpublic const int isc_info_svc_get_licensed_users = 65;  /* Retrieves the number\tof users licensed for accessing\tthe\tserver */\n\tpublic const int isc_info_svc_limbo_trans = 66; /* Retrieve\tthe\tlimbo transactions */\n\tpublic const int isc_info_svc_running = 67; /* Checks to see if\ta service is running on\tan attachment */\n\tpublic const int isc_info_svc_get_users = 68;   /* Returns the user\tinformation\tfrom isc_action_svc_display_users */\n\tpublic const int isc_info_svc_stdin = 78;   /* Returns size of data, needed as stdin for service */\n\n\t#endregion\n\n\t#region Services Properties\n\n\tpublic const int isc_spb_prp_page_buffers = 5;\n\tpublic const int isc_spb_prp_sweep_interval = 6;\n\tpublic const int isc_spb_prp_shutdown_db = 7;\n\tpublic const int isc_spb_prp_deny_new_attachments = 9;\n\tpublic const int isc_spb_prp_deny_new_transactions = 10;\n\tpublic const int isc_spb_prp_reserve_space = 11;\n\tpublic const int isc_spb_prp_write_mode = 12;\n\tpublic const int isc_spb_prp_access_mode = 13;\n\tpublic const int isc_spb_prp_set_sql_dialect = 14;\n\n\tpublic const int isc_spb_prp_force_shutdown = 41;\n\tpublic const int isc_spb_prp_attachments_shutdown = 42;\n\tpublic const int isc_spb_prp_transactions_shutdown = 43;\n\tpublic const int isc_spb_prp_shutdown_mode = 44;\n\tpublic const int isc_spb_prp_online_mode = 45;\n\n\tpublic const int isc_spb_prp_sm_normal = 0;\n\tpublic const int isc_spb_prp_sm_multi = 1;\n\tpublic const int isc_spb_prp_sm_single = 2;\n\tpublic const int isc_spb_prp_sm_full = 3;\n\n\t// RESERVE_SPACE_PARAMETERS\n\tpublic const int isc_spb_prp_res_use_full = 35;\n\tpublic const int isc_spb_prp_res = 36;\n\n\t// WRITE_MODE_PARAMETERS\n\tpublic const int isc_spb_prp_wm_async = 37;\n\tpublic const int isc_spb_prp_wm_sync = 38;\n\n\t// ACCESS_MODE_PARAMETERS\n\tpublic const int isc_spb_prp_am_readonly = 39;\n\tpublic const int isc_spb_prp_am_readwrite = 40;\n\n\t// Option Flags\n\tpublic const int isc_spb_prp_activate = 0x0100;\n\tpublic const int isc_spb_prp_db_online = 0x0200;\n\tpublic const int isc_spb_prp_nolinger = 0x0400;\n\n\t#endregion\n\n\t#region Backup Service\n\n\tpublic const int isc_spb_bkp_file = 5;\n\tpublic const int isc_spb_bkp_factor = 6;\n\tpublic const int isc_spb_bkp_length = 7;\n\tpublic const int isc_spb_bkp_skip_data = 8;\n\tpublic const int isc_spb_bkp_stat = 15;\n\tpublic const int isc_spb_bkp_keyholder = 16;\n\tpublic const int isc_spb_bkp_keyname = 17;\n\tpublic const int isc_spb_bkp_crypt = 18;\n\tpublic const int isc_spb_bkp_include_data = 19;\n\tpublic const int isc_spb_bkp_parallel_workers = 21;\n\tpublic const int isc_spb_bkp_ignore_checksums = 0x01;\n\tpublic const int isc_spb_bkp_ignore_limbo = 0x02;\n\tpublic const int isc_spb_bkp_metadata_only = 0x04;\n\tpublic const int isc_spb_bkp_no_garbage_collect = 0x08;\n\tpublic const int isc_spb_bkp_old_descriptions = 0x10;\n\tpublic const int isc_spb_bkp_non_transportable = 0x20;\n\tpublic const int isc_spb_bkp_convert = 0x40;\n\tpublic const int isc_spb_bkp_expand = 0x80;\n\tpublic const int isc_spb_bkp_no_triggers = 0x8000;\n\tpublic const int isc_spb_bkp_zip = 0x010000;\n\tpublic const int isc_spb_bkp_direct_io = 0x020000;\n\n\t#endregion\n\n\t#region Restore Service\n\n\tpublic const int isc_spb_res_skip_data = isc_spb_bkp_skip_data;\n\tpublic const int isc_spb_res_include_data = isc_spb_bkp_include_data;\n\tpublic const int isc_spb_res_buffers = 9;\n\tpublic const int isc_spb_res_page_size = 10;\n\tpublic const int isc_spb_res_length = 11;\n\tpublic const int isc_spb_res_access_mode = 12;\n\tpublic const int isc_spb_res_fix_fss_data = 13;\n\tpublic const int isc_spb_res_fix_fss_metadata = 14;\n\tpublic const int isc_spb_res_keyholder = isc_spb_bkp_keyholder;\n\tpublic const int isc_spb_res_keyname = isc_spb_bkp_keyname;\n\tpublic const int isc_spb_res_crypt = isc_spb_bkp_crypt;\n\tpublic const int isc_spb_res_stat = isc_spb_bkp_stat;\n\tpublic const int isc_spb_res_parallel_workers = isc_spb_bkp_parallel_workers;\n\tpublic const int isc_spb_res_metadata_only = isc_spb_bkp_metadata_only;\n\tpublic const int isc_spb_res_deactivate_idx = 0x0100;\n\tpublic const int isc_spb_res_no_shadow = 0x0200;\n\tpublic const int isc_spb_res_no_validity = 0x0400;\n\tpublic const int isc_spb_res_one_at_a_time = 0x0800;\n\tpublic const int isc_spb_res_replace = 0x1000;\n\tpublic const int isc_spb_res_create = 0x2000;\n\tpublic const int isc_spb_res_use_all_space = 0x4000;\n\tpublic const int isc_spb_res_direct_io = isc_spb_bkp_direct_io;\n\tpublic const int isc_spb_res_replica_mode = 20;\n\n\tpublic const int isc_spb_res_am_readonly = isc_spb_prp_am_readonly;\n\tpublic const int isc_spb_res_am_readwrite = isc_spb_prp_am_readwrite;\n\n\t#endregion\n\n\t#region Validate Service\n\tpublic const int isc_spb_val_tab_incl = 1;  // include filter based on regular expression\n\tpublic const int isc_spb_val_tab_excl = 2;  // exclude filter based on regular expression\n\tpublic const int isc_spb_val_idx_incl = 3;  // regexp of indices to validate\n\tpublic const int isc_spb_val_idx_excl = 4;  // regexp of indices to NOT validate\n\tpublic const int isc_spb_val_lock_timeout = 5;  // how long to wait for table lock\n\t#endregion\n\n\t#region Repair Service\n\n\tpublic const int isc_spb_rpr_commit_trans = 15;\n\tpublic const int isc_spb_rpr_rollback_trans = 34;\n\tpublic const int isc_spb_rpr_recover_two_phase = 17;\n\tpublic const int isc_spb_tra_id = 18;\n\tpublic const int isc_spb_single_tra_id = 19;\n\tpublic const int isc_spb_multi_tra_id = 20;\n\tpublic const int isc_spb_tra_state = 21;\n\tpublic const int isc_spb_tra_state_limbo = 22;\n\tpublic const int isc_spb_tra_state_commit = 23;\n\tpublic const int isc_spb_tra_state_rollback = 24;\n\tpublic const int isc_spb_tra_state_unknown = 25;\n\tpublic const int isc_spb_tra_host_site = 26;\n\tpublic const int isc_spb_tra_remote_site = 27;\n\tpublic const int isc_spb_tra_db_path = 28;\n\tpublic const int isc_spb_tra_advise = 29;\n\tpublic const int isc_spb_tra_advise_commit = 30;\n\tpublic const int isc_spb_tra_advise_rollback = 31;\n\tpublic const int isc_spb_tra_advise_unknown = 33;\n\tpublic const int isc_spb_tra_id_64 = 46;\n\tpublic const int isc_spb_single_tra_id_64 = 47;\n\tpublic const int isc_spb_multi_tra_id_64 = 48;\n\tpublic const int isc_spb_rpr_commit_trans_64 = 49;\n\tpublic const int isc_spb_rpr_rollback_trans_64 = 50;\n\tpublic const int isc_spb_rpr_recover_two_phase_64 = 51;\n\tpublic const int isc_spb_rpr_par_workers = 52;\n\n\tpublic const int isc_spb_rpr_validate_db = 0x01;\n\tpublic const int isc_spb_rpr_sweep_db = 0x02;\n\tpublic const int isc_spb_rpr_mend_db = 0x04;\n\tpublic const int isc_spb_rpr_list_limbo_trans = 0x08;\n\tpublic const int isc_spb_rpr_check_db = 0x10;\n\tpublic const int isc_spb_rpr_ignore_checksum = 0x20;\n\tpublic const int isc_spb_rpr_kill_shadows = 0x40;\n\tpublic const int isc_spb_rpr_full = 0x80;\n\tpublic const int isc_spb_rpr_icu = 0x0800;\n\n\t#endregion\n\n\t#region Security Service\n\n\tpublic const int isc_spb_sec_userid = 5;\n\tpublic const int isc_spb_sec_groupid = 6;\n\tpublic const int isc_spb_sec_username = 7;\n\tpublic const int isc_spb_sec_password = 8;\n\tpublic const int isc_spb_sec_groupname = 9;\n\tpublic const int isc_spb_sec_firstname = 10;\n\tpublic const int isc_spb_sec_middlename = 11;\n\tpublic const int isc_spb_sec_lastname = 12;\n\n\t#endregion\n\n\t#region NBackup Service\n\tpublic const int isc_spb_nbk_level = 5;\n\tpublic const int isc_spb_nbk_file = 6;\n\tpublic const int isc_spb_nbk_direct = 7;\n\tpublic const int isc_spb_nbk_no_triggers = 0x01;\n\t#endregion\n\n\t#region Trace Service\n\n\tpublic const int isc_spb_trc_id = 1;\n\tpublic const int isc_spb_trc_name = 2;\n\tpublic const int isc_spb_trc_cfg = 3;\n\n\t#endregion\n\n\t#region Configuration Keys\n\n\tpublic const int ISCCFG_LOCKMEM_KEY = 0;\n\tpublic const int ISCCFG_LOCKSEM_KEY = 1;\n\tpublic const int ISCCFG_LOCKSIG_KEY = 2;\n\tpublic const int ISCCFG_EVNTMEM_KEY = 3;\n\tpublic const int ISCCFG_DBCACHE_KEY = 4;\n\tpublic const int ISCCFG_PRIORITY_KEY = 5;\n\tpublic const int ISCCFG_IPCMAP_KEY = 6;\n\tpublic const int ISCCFG_MEMMIN_KEY = 7;\n\tpublic const int ISCCFG_MEMMAX_KEY = 8;\n\tpublic const int ISCCFG_LOCKORDER_KEY = 9;\n\tpublic const int ISCCFG_ANYLOCKMEM_KEY = 10;\n\tpublic const int ISCCFG_ANYLOCKSEM_KEY = 11;\n\tpublic const int ISCCFG_ANYLOCKSIG_KEY = 12;\n\tpublic const int ISCCFG_ANYEVNTMEM_KEY = 13;\n\tpublic const int ISCCFG_LOCKHASH_KEY = 14;\n\tpublic const int ISCCFG_DEADLOCK_KEY = 15;\n\tpublic const int ISCCFG_LOCKSPIN_KEY = 16;\n\tpublic const int ISCCFG_CONN_TIMEOUT_KEY = 17;\n\tpublic const int ISCCFG_DUMMY_INTRVL_KEY = 18;\n\tpublic const int ISCCFG_TRACE_POOLS_KEY = 19; /* Internal Use only\t*/\n\tpublic const int ISCCFG_REMOTE_BUFFER_KEY = 20;\n\n\t#endregion\n\n\t#region Common Structural Codes\n\n\tpublic const int isc_info_end = 1;\n\tpublic const int isc_info_truncated = 2;\n\tpublic const int isc_info_error = 3;\n\tpublic const int isc_info_data_not_ready = 4;\n\tpublic const int isc_info_flag_end = 127;\n\n\t#endregion\n\n\t#region SQL Information\n\n\tpublic const int isc_info_sql_select = 4;\n\tpublic const int isc_info_sql_bind = 5;\n\tpublic const int isc_info_sql_num_variables = 6;\n\tpublic const int isc_info_sql_describe_vars = 7;\n\tpublic const int isc_info_sql_describe_end = 8;\n\tpublic const int isc_info_sql_sqlda_seq = 9;\n\tpublic const int isc_info_sql_message_seq = 10;\n\tpublic const int isc_info_sql_type = 11;\n\tpublic const int isc_info_sql_sub_type = 12;\n\tpublic const int isc_info_sql_scale = 13;\n\tpublic const int isc_info_sql_length = 14;\n\tpublic const int isc_info_sql_null_ind = 15;\n\tpublic const int isc_info_sql_field = 16;\n\tpublic const int isc_info_sql_relation = 17;\n\tpublic const int isc_info_sql_owner = 18;\n\tpublic const int isc_info_sql_alias = 19;\n\tpublic const int isc_info_sql_sqlda_start = 20;\n\tpublic const int isc_info_sql_stmt_type = 21;\n\tpublic const int isc_info_sql_get_plan = 22;\n\tpublic const int isc_info_sql_records = 23;\n\tpublic const int isc_info_sql_batch_fetch = 24;\n\tpublic const int isc_info_sql_relation_alias = 25;\n\tpublic const int isc_info_sql_explain_plan = 26;\n\tpublic const int isc_info_sql_stmt_flags = 27;\n\n\t#endregion\n\n\t#region SQL Information Return Values\n\n\tpublic const int isc_info_sql_stmt_select = 1;\n\tpublic const int isc_info_sql_stmt_insert = 2;\n\tpublic const int isc_info_sql_stmt_update = 3;\n\tpublic const int isc_info_sql_stmt_delete = 4;\n\tpublic const int isc_info_sql_stmt_ddl = 5;\n\tpublic const int isc_info_sql_stmt_get_segment = 6;\n\tpublic const int isc_info_sql_stmt_put_segment = 7;\n\tpublic const int isc_info_sql_stmt_exec_procedure = 8;\n\tpublic const int isc_info_sql_stmt_start_trans = 9;\n\tpublic const int isc_info_sql_stmt_commit = 10;\n\tpublic const int isc_info_sql_stmt_rollback = 11;\n\tpublic const int isc_info_sql_stmt_select_for_upd = 12;\n\tpublic const int isc_info_sql_stmt_set_generator = 13;\n\tpublic const int isc_info_sql_stmt_savepoint = 14;\n\n\t#endregion\n\n\t#region Database Information\n\n\tpublic const int isc_info_db_id = 4;\n\tpublic const int isc_info_reads = 5;\n\tpublic const int isc_info_writes = 6;\n\tpublic const int isc_info_fetches = 7;\n\tpublic const int isc_info_marks = 8;\n\n\tpublic const int isc_info_implementation = 11;\n\tpublic const int isc_info_isc_version = 12;\n\tpublic const int isc_info_base_level = 13;\n\tpublic const int isc_info_page_size = 14;\n\tpublic const int isc_info_num_buffers = 15;\n\tpublic const int isc_info_limbo = 16;\n\tpublic const int isc_info_current_memory = 17;\n\tpublic const int isc_info_max_memory = 18;\n\tpublic const int isc_info_window_turns = 19;\n\tpublic const int isc_info_license = 20;\n\n\tpublic const int isc_info_allocation = 21;\n\tpublic const int isc_info_attachment_id = 22;\n\tpublic const int isc_info_read_seq_count = 23;\n\tpublic const int isc_info_read_idx_count = 24;\n\tpublic const int isc_info_insert_count = 25;\n\tpublic const int isc_info_update_count = 26;\n\tpublic const int isc_info_delete_count = 27;\n\tpublic const int isc_info_backout_count = 28;\n\tpublic const int isc_info_purge_count = 29;\n\tpublic const int isc_info_expunge_count = 30;\n\n\tpublic const int isc_info_sweep_interval = 31;\n\tpublic const int isc_info_ods_version = 32;\n\tpublic const int isc_info_ods_minor_version = 33;\n\tpublic const int isc_info_no_reserve = 34;\n\tpublic const int isc_info_logfile = 35;\n\tpublic const int isc_info_cur_logfile_name = 36;\n\tpublic const int isc_info_cur_log_part_offset = 37;\n\tpublic const int isc_info_num_wal_buffers = 38;\n\tpublic const int isc_info_wal_buffer_size = 39;\n\tpublic const int isc_info_wal_ckpt_length = 40;\n\n\tpublic const int isc_info_wal_cur_ckpt_interval = 41;\n\tpublic const int isc_info_wal_prv_ckpt_fname = 42;\n\tpublic const int isc_info_wal_prv_ckpt_poffset = 43;\n\tpublic const int isc_info_wal_recv_ckpt_fname = 44;\n\tpublic const int isc_info_wal_recv_ckpt_poffset = 45;\n\tpublic const int isc_info_wal_grpc_wait_usecs = 47;\n\tpublic const int isc_info_wal_num_io = 48;\n\tpublic const int isc_info_wal_avg_io_size = 49;\n\tpublic const int isc_info_wal_num_commits = 50;\n\n\tpublic const int isc_info_wal_avg_grpc_size = 51;\n\tpublic const int isc_info_forced_writes = 52;\n\tpublic const int isc_info_user_names = 53;\n\tpublic const int isc_info_page_errors = 54;\n\tpublic const int isc_info_record_errors = 55;\n\tpublic const int isc_info_bpage_errors = 56;\n\tpublic const int isc_info_dpage_errors = 57;\n\tpublic const int isc_info_ipage_errors = 58;\n\tpublic const int isc_info_ppage_errors = 59;\n\tpublic const int isc_info_tpage_errors = 60;\n\n\tpublic const int isc_info_set_page_buffers = 61;\n\tpublic const int isc_info_db_sql_dialect = 62;\n\tpublic const int isc_info_db_read_only = 63;\n\tpublic const int isc_info_db_size_in_pages = 64;\n\n\tpublic const int frb_info_att_charset = 101;\n\tpublic const int isc_info_db_class = 102;\n\tpublic const int isc_info_firebird_version = 103;\n\tpublic const int isc_info_oldest_transaction = 104;\n\tpublic const int isc_info_oldest_active = 105;\n\tpublic const int isc_info_oldest_snapshot = 106;\n\tpublic const int isc_info_next_transaction = 107;\n\tpublic const int isc_info_db_provider = 108;\n\tpublic const int isc_info_active_transactions = 109;\n\n\tpublic const int isc_info_active_tran_count = 110;\n\tpublic const int isc_info_creation_date = 111;\n\tpublic const int isc_info_db_file_size = 112;\n\tpublic const int fb_info_page_contents = 113;\n\n\tpublic const int fb_info_implementation = 114;\n\n\tpublic const int fb_info_page_warns = 115;\n\tpublic const int fb_info_record_warns = 116;\n\tpublic const int fb_info_bpage_warns = 117;\n\tpublic const int fb_info_dpage_warns = 118;\n\tpublic const int fb_info_ipage_warns = 119;\n\tpublic const int fb_info_ppage_warns = 120;\n\tpublic const int fb_info_tpage_warns = 121;\n\tpublic const int fb_info_pip_errors = 122;\n\tpublic const int fb_info_pip_warns = 123;\n\n\tpublic const int fb_info_pages_used = 124;\n\tpublic const int fb_info_pages_free = 125;\n\n\tpublic const int fb_info_ses_idle_timeout_db = 129;\n\tpublic const int fb_info_ses_idle_timeout_att = 130;\n\tpublic const int fb_info_ses_idle_timeout_run = 131;\n\n\tpublic const int fb_info_conn_flags = 132;\n\n\tpublic const int fb_info_crypt_key = 133;\n\tpublic const int fb_info_crypt_state = 134;\n\n\tpublic const int fb_info_statement_timeout_db = 135;\n\tpublic const int fb_info_statement_timeout_att = 136;\n\n\tpublic const int fb_info_protocol_version = 137;\n\tpublic const int fb_info_crypt_plugin = 138;\n\n\tpublic const int fb_info_creation_timestamp_tz = 139;\n\n\tpublic const int fb_info_wire_crypt = 140;\n\n\tpublic const int fb_info_features = 141;\n\n\tpublic const int fb_info_next_attachment = 142;\n\tpublic const int fb_info_next_statement = 143;\n\n\tpublic const int fb_info_db_guid = 144;\n\tpublic const int fb_info_db_file_id = 145;\n\n\tpublic const int fb_info_replica_mode = 146;\n\n\tpublic const int fb_info_username = 147;\n\tpublic const int fb_info_sqlrole = 148;\n\n\t#endregion\n\n\t#region Information Request\n\n\tpublic const int isc_info_number_messages = 4;\n\tpublic const int isc_info_max_message = 5;\n\tpublic const int isc_info_max_send = 6;\n\tpublic const int isc_info_max_receive = 7;\n\tpublic const int isc_info_state = 8;\n\tpublic const int isc_info_message_number = 9;\n\tpublic const int isc_info_message_size = 10;\n\tpublic const int isc_info_request_cost = 11;\n\tpublic const int isc_info_access_path = 12;\n\tpublic const int isc_info_req_select_count = 13;\n\tpublic const int isc_info_req_insert_count = 14;\n\tpublic const int isc_info_req_update_count = 15;\n\tpublic const int isc_info_req_delete_count = 16;\n\n\t#endregion\n\n\t#region Array Slice Description Language\n\n\tpublic const int isc_sdl_version1 = 1;\n\tpublic const int isc_sdl_eoc = 255;\n\tpublic const int isc_sdl_relation = 2;\n\tpublic const int isc_sdl_rid = 3;\n\tpublic const int isc_sdl_field = 4;\n\tpublic const int isc_sdl_fid = 5;\n\tpublic const int isc_sdl_struct = 6;\n\tpublic const int isc_sdl_variable = 7;\n\tpublic const int isc_sdl_scalar = 8;\n\tpublic const int isc_sdl_tiny_integer = 9;\n\tpublic const int isc_sdl_short_integer = 10;\n\tpublic const int isc_sdl_long_integer = 11;\n\tpublic const int isc_sdl_literal = 12;\n\tpublic const int isc_sdl_add = 13;\n\tpublic const int isc_sdl_subtract = 14;\n\tpublic const int isc_sdl_multiply = 15;\n\tpublic const int isc_sdl_divide = 16;\n\tpublic const int isc_sdl_negate = 17;\n\tpublic const int isc_sdl_eql = 18;\n\tpublic const int isc_sdl_neq = 19;\n\tpublic const int isc_sdl_gtr = 20;\n\tpublic const int isc_sdl_geq = 21;\n\tpublic const int isc_sdl_lss = 22;\n\tpublic const int isc_sdl_leq = 23;\n\tpublic const int isc_sdl_and = 24;\n\tpublic const int isc_sdl_or = 25;\n\tpublic const int isc_sdl_not = 26;\n\tpublic const int isc_sdl_while = 27;\n\tpublic const int isc_sdl_assignment = 28;\n\tpublic const int isc_sdl_label = 29;\n\tpublic const int isc_sdl_leave = 30;\n\tpublic const int isc_sdl_begin = 31;\n\tpublic const int isc_sdl_end = 32;\n\tpublic const int isc_sdl_do3 = 33;\n\tpublic const int isc_sdl_do2 = 34;\n\tpublic const int isc_sdl_do1 = 35;\n\tpublic const int isc_sdl_element = 36;\n\n\t#endregion\n\n\t#region Blob Parameter Block\n\n\tpublic const int isc_bpb_version1 = 1;\n\tpublic const int isc_bpb_source_type = 1;\n\tpublic const int isc_bpb_target_type = 2;\n\tpublic const int isc_bpb_type = 3;\n\tpublic const int isc_bpb_source_interp = 4;\n\tpublic const int isc_bpb_target_interp = 5;\n\tpublic const int isc_bpb_filter_parameter = 6;\n\n\tpublic const int isc_bpb_type_segmented = 0;\n\tpublic const int isc_bpb_type_stream = 1;\n\n\tpublic const int RBL_eof = 1;\n\tpublic const int RBL_segment = 2;\n\tpublic const int RBL_eof_pending = 4;\n\tpublic const int RBL_create = 8;\n\n\tpublic const int isc_blb_seek_from_head = 0;\n\tpublic const int isc_blb_seek_relative =  1;\n\tpublic const int isc_blb_seek_from_tail = 2;\n\n\t#endregion\n\n\t#region Blob Information\n\n\tpublic const int isc_info_blob_num_segments = 4;\n\tpublic const int isc_info_blob_max_segment = 5;\n\tpublic const int isc_info_blob_total_length = 6;\n\tpublic const int isc_info_blob_type = 7;\n\n\t#endregion\n\n\t#region Event Codes\n\n\tpublic const int P_REQ_async = 1;   // Auxiliary asynchronous port\n\tpublic const int EPB_version1 = 1;\n\n\t#endregion\n\n\t#region ISC Error codes\n\n\tpublic const int isc_facility = 20;\n\tpublic const int isc_err_base = 335544320;\n\tpublic const int isc_err_factor = 1;\n\tpublic const int isc_arg_end = 0;    // end of argument list\n\tpublic const int isc_arg_gds = 1;    // generic DSRI\tstatus value\n\tpublic const int isc_arg_string = 2;    // string argument\n\tpublic const int isc_arg_cstring = 3;   // count & string argument\n\tpublic const int isc_arg_number = 4;    // numeric argument\t(long)\n\tpublic const int isc_arg_interpreted = 5;   // interpreted status code (string)\n\tpublic const int isc_arg_vms = 6;   // VAX/VMS status code (long)\n\tpublic const int isc_arg_unix = 7;  // UNIX\terror code\n\tpublic const int isc_arg_domain = 8;    // Apollo/Domain error code\n\tpublic const int isc_arg_dos = 9;   // MSDOS/OS2 error code\n\tpublic const int isc_arg_mpexl = 10;    // HP MPE/XL error code\n\tpublic const int isc_arg_mpexl_ipc = 11;    // HP MPE/XL IPC error code\n\tpublic const int isc_arg_next_mach = 15;    // NeXT/Mach error code\n\tpublic const int isc_arg_netware = 16;  // NetWare error code\n\tpublic const int isc_arg_win32 = 17;    // Win32 error code\n\tpublic const int isc_arg_warning = 18;  // warning argument\n\tpublic const int isc_arg_sql_state = 19;    // SQLSTATE\n\n\tpublic const int isc_open_trans = 335544357;\n\tpublic const int isc_segment = 335544366;\n\tpublic const int isc_segstr_eof = 335544367;\n\tpublic const int isc_connect_reject = 335544421;\n\tpublic const int isc_invalid_dimension = 335544458;\n\tpublic const int isc_tra_state = 335544468;\n\tpublic const int isc_except = 335544517;\n\tpublic const int isc_dsql_sqlda_err = 335544583;\n\tpublic const int isc_network_error = 335544721;\n\tpublic const int isc_net_read_err = 335544726;\n\tpublic const int isc_net_write_err = 335544727;\n\tpublic const int isc_stack_trace = 335544842;\n\tpublic const int isc_except2 = 335544848;\n\tpublic const int isc_arith_except = 335544321;\n\tpublic const int isc_string_truncation = 335544914;\n\tpublic const int isc_formatted_exception = 335545016;\n\tpublic const int isc_wirecrypt_incompatible = 335545064;\n\tpublic const int isc_cancelled = 335544794;\n\tpublic const int isc_nothing_to_cancel = 335544933;\n\n\t#endregion\n\n\t#region BLR Codes\n\n\tpublic const int blr_version5 = 5;\n\tpublic const int blr_begin = 2;\n\tpublic const int blr_message = 4;\n\tpublic const int blr_eoc = 76;\n\tpublic const int blr_end = 255;\n\n\tpublic const int blr_text = 14;\n\tpublic const int blr_text2 = 15;\n\tpublic const int blr_short = 7;\n\tpublic const int blr_long = 8;\n\tpublic const int blr_quad = 9;\n\tpublic const int blr_int64 = 16;\n\tpublic const int blr_float = 10;\n\tpublic const int blr_double = 27;\n\tpublic const int blr_d_float = 11;\n\tpublic const int blr_timestamp = 35;\n\tpublic const int blr_varying = 37;\n\tpublic const int blr_varying2 = 38;\n\tpublic const int blr_blob = 261;\n\tpublic const int blr_cstring = 40;\n\tpublic const int blr_cstring2 = 41;\n\tpublic const int blr_blob_id = 45;\n\tpublic const int blr_sql_date = 12;\n\tpublic const int blr_sql_time = 13;\n\tpublic const int blr_bool = 23;\n\tpublic const int blr_dec64 = 24;\n\tpublic const int blr_dec128 = 25;\n\tpublic const int blr_int128 = 26;\n\tpublic const int blr_sql_time_tz = 28;\n\tpublic const int blr_timestamp_tz = 29;\n\tpublic const int blr_ex_time_tz = 30;\n\tpublic const int blr_ex_timestamp_tz = 31;\n\n\tpublic const int blr_null = 45;\n\n\t#endregion\n\n\t#region DataType Definitions\n\n\tpublic const int SQL_TEXT = 452;\n\tpublic const int SQL_VARYING = 448;\n\tpublic const int SQL_SHORT = 500;\n\tpublic const int SQL_LONG = 496;\n\tpublic const int SQL_FLOAT = 482;\n\tpublic const int SQL_DOUBLE = 480;\n\tpublic const int SQL_D_FLOAT = 530;\n\tpublic const int SQL_TIMESTAMP = 510;\n\tpublic const int SQL_BLOB = 520;\n\tpublic const int SQL_ARRAY = 540;\n\tpublic const int SQL_QUAD = 550;\n\tpublic const int SQL_TYPE_TIME = 560;\n\tpublic const int SQL_TYPE_DATE = 570;\n\tpublic const int SQL_INT64 = 580;\n\tpublic const int SQL_TIMESTAMP_TZ_EX = 32748;\n\tpublic const int SQL_TIME_TZ_EX = 32750;\n\tpublic const int SQL_INT128 = 32752;\n\tpublic const int SQL_TIMESTAMP_TZ = 32754;\n\tpublic const int SQL_TIME_TZ = 32756;\n\tpublic const int SQL_DEC16 = 32760;\n\tpublic const int SQL_DEC34 = 32762;\n\tpublic const int SQL_BOOLEAN = 32764;\n\tpublic const int SQL_NULL = 32766;\n\n\t// Historical alias\tfor\tpre\tV6 applications\n\tpublic const int SQL_DATE = SQL_TIMESTAMP;\n\n\t#endregion\n\n\t#region Cancel types\n\n\tpublic const int fb_cancel_disable = 1;\n\tpublic const int fb_cancel_enable = 2;\n\tpublic const int fb_cancel_raise = 3;\n\tpublic const int fb_cancel_abort = 4;\n\n\t#endregion\n\n\t#region User identification data\n\n\tpublic const int CNCT_user = 1;\n\tpublic const int CNCT_passwd = 2;\n\tpublic const int CNCT_host = 4;\n\tpublic const int CNCT_group = 5;\n\tpublic const int CNCT_user_verification = 6;\n\tpublic const int CNCT_specific_data = 7;\n\tpublic const int CNCT_plugin_name = 8;\n\tpublic const int CNCT_login = 9;\n\tpublic const int CNCT_plugin_list = 10;\n\tpublic const int CNCT_client_crypt = 11;\n\n\t#endregion\n\n\t#region Transaction information items\n\n\tpublic const int isc_info_tra_id = 4;\n\tpublic const int isc_info_tra_oldest_interesting = 5;\n\tpublic const int isc_info_tra_oldest_snapshot = 6;\n\tpublic const int isc_info_tra_oldest_active = 7;\n\tpublic const int isc_info_tra_isolation = 8;\n\tpublic const int isc_info_tra_access = 9;\n\tpublic const int isc_info_tra_lock_timeout = 10;\n\tpublic const int fb_info_tra_dbpath = 11;\n\tpublic const int fb_info_tra_snapshot_number = 12;\n\n\t// isc_info_tra_isolation responses\n\tpublic const int isc_info_tra_consistency = 1;\n\tpublic const int isc_info_tra_concurrency = 2;\n\tpublic const int isc_info_tra_read_committed = 3;\n\n\t// isc_info_tra_read_committed options\n\tpublic const int isc_info_tra_no_rec_version = 0;\n\tpublic const int isc_info_tra_rec_version = 1;\n\tpublic const int isc_info_tra_read_consistency = 2;\n\n\t// isc_info_tra_access responses\n\tpublic const int isc_info_tra_readonly = 0;\n\tpublic const int isc_info_tra_readwrite = 1;\n\n\t#endregion\n\n\tpublic static class Batch\n\t{\n\t\tpublic const int VERSION1 = 1;\n\n\t\tpublic const int TAG_MULTIERROR = 1;\n\t\tpublic const int TAG_RECORD_COUNTS = 2;\n\t\tpublic const int TAG_BUFFER_BYTES_SIZE = 3;\n\t\tpublic const int TAG_BLOB_POLICY = 4;\n\t\tpublic const int TAG_DETAILED_ERRORS = 5;\n\n\t\tpublic const int BLOB_NONE = 0;\n\t\tpublic const int BLOB_ID_ENGINE = 1;\n\t\tpublic const int BLOB_ID_USER = 2;\n\t\tpublic const int BLOB_STREAM = 3;\n\n\t\tpublic const int BLOB_SEGHDR_ALIGN = 2;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/IscError.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Globalization;\n\nnamespace FirebirdSql.Data.Common;\n\n[Serializable]\ninternal sealed class IscError\n{\n\tprivate string _strParam;\n\n\tpublic string Message { get; set; }\n\tpublic int ErrorCode { get; }\n\tpublic int Type { get; }\n\n\tpublic string StrParam\n\t{\n\t\tget\n\t\t{\n\t\t\tswitch (Type)\n\t\t\t{\n\t\t\t\tcase IscCodes.isc_arg_interpreted:\n\t\t\t\tcase IscCodes.isc_arg_string:\n\t\t\t\tcase IscCodes.isc_arg_cstring:\n\t\t\t\tcase IscCodes.isc_arg_sql_state:\n\t\t\t\t\treturn _strParam;\n\n\t\t\t\tcase IscCodes.isc_arg_number:\n\t\t\t\t\treturn ErrorCode.ToString(CultureInfo.InvariantCulture);\n\n\t\t\t\tdefault:\n\t\t\t\t\treturn string.Empty;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic bool IsArgument\n\t{\n\t\tget\n\t\t{\n\t\t\tswitch (Type)\n\t\t\t{\n\t\t\t\tcase IscCodes.isc_arg_interpreted:\n\t\t\t\tcase IscCodes.isc_arg_string:\n\t\t\t\tcase IscCodes.isc_arg_cstring:\n\t\t\t\tcase IscCodes.isc_arg_number:\n\t\t\t\t\treturn true;\n\n\t\t\t\tdefault:\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic bool IsWarning\n\t{\n\t\tget { return Type == IscCodes.isc_arg_warning; }\n\t}\n\n\tinternal IscError(int errorCode)\n\t{\n\t\tErrorCode = errorCode;\n\t}\n\n\tinternal IscError(int type, string strParam)\n\t{\n\t\tType = type;\n\t\t_strParam = strParam;\n\t}\n\n\tinternal IscError(int type, int errorCode)\n\t{\n\t\tType = type;\n\t\tErrorCode = errorCode;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/IscErrorMessages.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class IscErrorMessages\n{\n\tstatic Dictionary<int, string> _messages = new Dictionary<int, string>()\n\t\t{\n\t{335544320, \"\"},\n\t{335544321, \"arithmetic exception, numeric overflow, or string truncation\"},\t\t/* arith_except */\n\t{335544322, \"invalid database key\"},\t\t/* bad_dbkey */\n\t{335544323, \"file {0} is not a valid database\"},\t\t/* bad_db_format */\n\t{335544324, \"invalid database handle (no active connection)\"},\t\t/* bad_db_handle */\n\t{335544325, \"bad parameters on attach or create database\"},\t\t/* bad_dpb_content */\n\t{335544326, \"unrecognized database parameter block\"},\t\t/* bad_dpb_form */\n\t{335544327, \"invalid request handle\"},\t\t/* bad_req_handle */\n\t{335544328, \"invalid BLOB handle\"},\t\t/* bad_segstr_handle */\n\t{335544329, \"invalid BLOB ID\"},\t\t/* bad_segstr_id */\n\t{335544330, \"invalid parameter in transaction parameter block\"},\t\t/* bad_tpb_content */\n\t{335544331, \"invalid format for transaction parameter block\"},\t\t/* bad_tpb_form */\n\t{335544332, \"invalid transaction handle (expecting explicit transaction start)\"},\t\t/* bad_trans_handle */\n\t{335544333, \"internal Firebird consistency check ({0})\"},\t\t/* bug_check */\n\t{335544334, \"conversion error from string \\\"{0}\\\"\"},\t\t/* convert_error */\n\t{335544335, \"database file appears corrupt ({0})\"},\t\t/* db_corrupt */\n\t{335544336, \"deadlock\"},\t\t/* deadlock */\n\t{335544337, \"attempt to start more than {0} transactions\"},\t\t/* excess_trans */\n\t{335544338, \"no match for first value expression\"},\t\t/* from_no_match */\n\t{335544339, \"information type inappropriate for object specified\"},\t\t/* infinap */\n\t{335544340, \"no information of this type available for object specified\"},\t\t/* infona */\n\t{335544341, \"unknown information item\"},\t\t/* infunk */\n\t{335544342, \"action cancelled by trigger ({0}) to preserve data integrity\"},\t\t/* integ_fail */\n\t{335544343, \"invalid request BLR at offset {0}\"},\t\t/* invalid_blr */\n\t{335544344, \"I/O error during \\\"{0}\\\" operation for file \\\"{1}\\\"\"},\t\t/* io_error */\n\t{335544345, \"lock conflict on no wait transaction\"},\t\t/* lock_conflict */\n\t{335544346, \"corrupt system table\"},\t\t/* metadata_corrupt */\n\t{335544347, \"validation error for column {0}, value \\\"{1}\\\"\"},\t\t/* not_valid */\n\t{335544348, \"no current record for fetch operation\"},\t\t/* no_cur_rec */\n\t{335544349, \"attempt to store duplicate value (visible to active transactions) in unique index \\\"{0}\\\"\"},\t\t/* no_dup */\n\t{335544350, \"program attempted to exit without finishing database\"},\t\t/* no_finish */\n\t{335544351, \"unsuccessful metadata update\"},\t\t/* no_meta_update */\n\t{335544352, \"no permission for {0} access to {1} {2}\"},\t\t/* no_priv */\n\t{335544353, \"transaction is not in limbo\"},\t\t/* no_recon */\n\t{335544354, \"invalid database key\"},\t\t/* no_record */\n\t{335544355, \"BLOB was not closed\"},\t\t/* no_segstr_close */\n\t{335544356, \"metadata is obsolete\"},\t\t/* obsolete_metadata */\n\t{335544357, \"cannot disconnect database with open transactions ({0} active)\"},\t\t/* open_trans */\n\t{335544358, \"message length error (encountered {0}, expected {1})\"},\t\t/* port_len */\n\t{335544359, \"attempted update of read-only column {0}\"},\t\t/* read_only_field */\n\t{335544360, \"attempted update of read-only table\"},\t\t/* read_only_rel */\n\t{335544361, \"attempted update during read-only transaction\"},\t\t/* read_only_trans */\n\t{335544362, \"cannot update read-only view {0}\"},\t\t/* read_only_view */\n\t{335544363, \"no transaction for request\"},\t\t/* req_no_trans */\n\t{335544364, \"request synchronization error\"},\t\t/* req_sync */\n\t{335544365, \"request referenced an unavailable database\"},\t\t/* req_wrong_db */\n\t{335544366, \"segment buffer length shorter than expected\"},\t\t/* segment */\n\t{335544367, \"attempted retrieval of more segments than exist\"},\t\t/* segstr_eof */\n\t{335544368, \"attempted invalid operation on a BLOB\"},\t\t/* segstr_no_op */\n\t{335544369, \"attempted read of a new, open BLOB\"},\t\t/* segstr_no_read */\n\t{335544370, \"attempted action on BLOB outside transaction\"},\t\t/* segstr_no_trans */\n\t{335544371, \"attempted write to read-only BLOB\"},\t\t/* segstr_no_write */\n\t{335544372, \"attempted reference to BLOB in unavailable database\"},\t\t/* segstr_wrong_db */\n\t{335544373, \"operating system directive {0} failed\"},\t\t/* sys_request */\n\t{335544374, \"attempt to fetch past the last record in a record stream\"},\t\t/* stream_eof */\n\t{335544375, \"unavailable database\"},\t\t/* unavailable */\n\t{335544376, \"table {0} was omitted from the transaction reserving list\"},\t\t/* unres_rel */\n\t{335544377, \"request includes a DSRI extension not supported in this implementation\"},\t\t/* uns_ext */\n\t{335544378, \"feature is not supported\"},\t\t/* wish_list */\n\t{335544379, \"unsupported on-disk structure for file {0}; found {1}.{2}, support {3}.{4}\"},\t\t/* wrong_ods */\n\t{335544380, \"wrong number of arguments on call\"},\t\t/* wronumarg */\n\t{335544381, \"Implementation limit exceeded\"},\t\t/* imp_exc */\n\t{335544382, \"{0}\"},\t\t/* random */\n\t{335544383, \"unrecoverable conflict with limbo transaction {0}\"},\t\t/* fatal_conflict */\n\t{335544384, \"internal error\"},\t\t/* badblk */\n\t{335544385, \"internal error\"},\t\t/* invpoolcl */\n\t{335544386, \"too many requests\"},\t\t/* nopoolids */\n\t{335544387, \"internal error\"},\t\t/* relbadblk */\n\t{335544388, \"block size exceeds implementation restriction\"},\t\t/* blktoobig */\n\t{335544389, \"buffer exhausted\"},\t\t/* bufexh */\n\t{335544390, \"BLR syntax error: expected {0} at offset {1}, encountered {2}\"},\t\t/* syntaxerr */\n\t{335544391, \"buffer in use\"},\t\t/* bufinuse */\n\t{335544392, \"internal error\"},\t\t/* bdbincon */\n\t{335544393, \"request in use\"},\t\t/* reqinuse */\n\t{335544394, \"incompatible version of on-disk structure\"},\t\t/* badodsver */\n\t{335544395, \"table {0} is not defined\"},\t\t/* relnotdef */\n\t{335544396, \"column {0} is not defined in table {1}\"},\t\t/* fldnotdef */\n\t{335544397, \"internal error\"},\t\t/* dirtypage */\n\t{335544398, \"internal error\"},\t\t/* waifortra */\n\t{335544399, \"internal error\"},\t\t/* doubleloc */\n\t{335544400, \"internal error\"},\t\t/* nodnotfnd */\n\t{335544401, \"internal error\"},\t\t/* dupnodfnd */\n\t{335544402, \"internal error\"},\t\t/* locnotmar */\n\t{335544403, \"page {0} is of wrong type (expected {1}, found {2})\"},\t\t/* badpagtyp */\n\t{335544404, \"database corrupted\"},\t\t/* corrupt */\n\t{335544405, \"checksum error on database page {0}\"},\t\t/* badpage */\n\t{335544406, \"index is broken\"},\t\t/* badindex */\n\t{335544407, \"database handle not zero\"},\t\t/* dbbnotzer */\n\t{335544408, \"transaction handle not zero\"},\t\t/* tranotzer */\n\t{335544409, \"transaction--request mismatch (synchronization error)\"},\t\t/* trareqmis */\n\t{335544410, \"bad handle count\"},\t\t/* badhndcnt */\n\t{335544411, \"wrong version of transaction parameter block\"},\t\t/* wrotpbver */\n\t{335544412, \"unsupported BLR version (expected {0}, encountered {1})\"},\t\t/* wroblrver */\n\t{335544413, \"wrong version of database parameter block\"},\t\t/* wrodpbver */\n\t{335544414, \"BLOB and array data types are not supported for {0} operation\"},\t\t/* blobnotsup */\n\t{335544415, \"database corrupted\"},\t\t/* badrelation */\n\t{335544416, \"internal error\"},\t\t/* nodetach */\n\t{335544417, \"internal error\"},\t\t/* notremote */\n\t{335544418, \"transaction in limbo\"},\t\t/* trainlim */\n\t{335544419, \"transaction not in limbo\"},\t\t/* notinlim */\n\t{335544420, \"transaction outstanding\"},\t\t/* traoutsta */\n\t{335544421, \"connection rejected by remote interface\"},\t\t/* connect_reject */\n\t{335544422, \"internal error\"},\t\t/* dbfile */\n\t{335544423, \"internal error\"},\t\t/* orphan */\n\t{335544424, \"no lock manager available\"},\t\t/* no_lock_mgr */\n\t{335544425, \"context already in use (BLR error)\"},\t\t/* ctxinuse */\n\t{335544426, \"context not defined (BLR error)\"},\t\t/* ctxnotdef */\n\t{335544427, \"data operation not supported\"},\t\t/* datnotsup */\n\t{335544428, \"undefined message number\"},\t\t/* badmsgnum */\n\t{335544429, \"undefined parameter number\"},\t\t/* badparnum */\n\t{335544430, \"unable to allocate memory from operating system\"},\t\t/* virmemexh */\n\t{335544431, \"blocking signal has been received\"},\t\t/* blocking_signal */\n\t{335544432, \"lock manager error\"},\t\t/* lockmanerr */\n\t{335544433, \"communication error with journal \\\"{0}\\\"\"},\t\t/* journerr */\n\t{335544434, \"key size exceeds implementation restriction for index \\\"{0}\\\"\"},\t\t/* keytoobig */\n\t{335544435, \"null segment of UNIQUE KEY\"},\t\t/* nullsegkey */\n\t{335544436, \"SQL error code = {0}\"},\t\t/* sqlerr */\n\t{335544437, \"wrong DYN version\"},\t\t/* wrodynver */\n\t{335544438, \"function {0} is not defined\"},\t\t/* funnotdef */\n\t{335544439, \"function {0} could not be matched\"},\t\t/* funmismat */\n\t{335544440, \"\"},\t\t/* bad_msg_vec */\n\t{335544441, \"database detach completed with errors\"},\t\t/* bad_detach */\n\t{335544442, \"database system cannot read argument {0}\"},\t\t/* noargacc_read */\n\t{335544443, \"database system cannot write argument {0}\"},\t\t/* noargacc_write */\n\t{335544444, \"operation not supported\"},\t\t/* read_only */\n\t{335544445, \"{0} extension error\"},\t\t/* ext_err */\n\t{335544446, \"not updatable\"},\t\t/* non_updatable */\n\t{335544447, \"no rollback performed\"},\t\t/* no_rollback */\n\t{335544448, \"\"},\t\t/* bad_sec_info */\n\t{335544449, \"\"},\t\t/* invalid_sec_info */\n\t{335544450, \"{0}\"},\t\t/* misc_interpreted */\n\t{335544451, \"update conflicts with concurrent update\"},\t\t/* update_conflict */\n\t{335544452, \"product {0} is not licensed\"},\t\t/* unlicensed */\n\t{335544453, \"object {0} is in use\"},\t\t/* obj_in_use */\n\t{335544454, \"filter not found to convert type {0} to type {1}\"},\t\t/* nofilter */\n\t{335544455, \"cannot attach active shadow file\"},\t\t/* shadow_accessed */\n\t{335544456, \"invalid slice description language at offset {0}\"},\t\t/* invalid_sdl */\n\t{335544457, \"subscript out of bounds\"},\t\t/* out_of_bounds */\n\t{335544458, \"column not array or invalid dimensions (expected {0}, encountered {1})\"},\t\t/* invalid_dimension */\n\t{335544459, \"record from transaction {0} is stuck in limbo\"},\t\t/* rec_in_limbo */\n\t{335544460, \"a file in manual shadow {0} is unavailable\"},\t\t/* shadow_missing */\n\t{335544461, \"secondary server attachments cannot validate databases\"},\t\t/* cant_validate */\n\t{335544462, \"secondary server attachments cannot start journaling\"},\t\t/* cant_start_journal */\n\t{335544463, \"generator {0} is not defined\"},\t\t/* gennotdef */\n\t{335544464, \"secondary server attachments cannot start logging\"},\t\t/* cant_start_logging */\n\t{335544465, \"invalid BLOB type for operation\"},\t\t/* bad_segstr_type */\n\t{335544466, \"violation of FOREIGN KEY constraint \\\"{0}\\\" on table \\\"{1}\\\"\"},\t\t/* foreign_key */\n\t{335544467, \"minor version too high found {0} expected {1}\"},\t\t/* high_minor */\n\t{335544468, \"transaction {0} is {1}\"},\t\t/* tra_state */\n\t{335544469, \"transaction marked invalid and cannot be committed\"},\t\t/* trans_invalid */\n\t{335544470, \"cache buffer for page {0} invalid\"},\t\t/* buf_invalid */\n\t{335544471, \"there is no index in table {0} with id {1}\"},\t\t/* indexnotdefined */\n\t{335544472, \"Your user name and password are not defined. Ask your database administrator to set up a Firebird login.\"},\t\t/* login */\n\t{335544473, \"invalid bookmark handle\"},\t\t/* invalid_bookmark */\n\t{335544474, \"invalid lock level {0}\"},\t\t/* bad_lock_level */\n\t{335544475, \"lock on table {0} conflicts with existing lock\"},\t\t/* relation_lock */\n\t{335544476, \"requested record lock conflicts with existing lock\"},\t\t/* record_lock */\n\t{335544477, \"maximum indexes per table ({0}) exceeded\"},\t\t/* max_idx */\n\t{335544478, \"enable journal for database before starting online dump\"},\t\t/* jrn_enable */\n\t{335544479, \"online dump failure. Retry dump\"},\t\t/* old_failure */\n\t{335544480, \"an online dump is already in progress\"},\t\t/* old_in_progress */\n\t{335544481, \"no more disk/tape space.  Cannot continue online dump\"},\t\t/* old_no_space */\n\t{335544482, \"journaling allowed only if database has Write-ahead Log\"},\t\t/* no_wal_no_jrn */\n\t{335544483, \"maximum number of online dump files that can be specified is 16\"},\t\t/* num_old_files */\n\t{335544484, \"error in opening Write-ahead Log file during recovery\"},\t\t/* wal_file_open */\n\t{335544485, \"invalid statement handle\"},\t\t/* bad_stmt_handle */\n\t{335544486, \"Write-ahead log subsystem failure\"},\t\t/* wal_failure */\n\t{335544487, \"WAL Writer error\"},\t\t/* walw_err */\n\t{335544488, \"Log file header of {0} too small\"},\t\t/* logh_small */\n\t{335544489, \"Invalid version of log file {0}\"},\t\t/* logh_inv_version */\n\t{335544490, \"Log file {0} not latest in the chain but open flag still set\"},\t\t/* logh_open_flag */\n\t{335544491, \"Log file {0} not closed properly; database recovery may be required\"},\t\t/* logh_open_flag2 */\n\t{335544492, \"Database name in the log file {0} is different\"},\t\t/* logh_diff_dbname */\n\t{335544493, \"Unexpected end of log file {0} at offset {1}\"},\t\t/* logf_unexpected_eof */\n\t{335544494, \"Incomplete log record at offset {0} in log file {1}\"},\t\t/* logr_incomplete */\n\t{335544495, \"Log record header too small at offset {0} in log file {1}\"},\t\t/* logr_header_small */\n\t{335544496, \"Log block too small at offset {0} in log file {1}\"},\t\t/* logb_small */\n\t{335544497, \"Illegal attempt to attach to an uninitialized WAL segment for {0}\"},\t\t/* wal_illegal_attach */\n\t{335544498, \"Invalid WAL parameter block option {0}\"},\t\t/* wal_invalid_wpb */\n\t{335544499, \"Cannot roll over to the next log file {0}\"},\t\t/* wal_err_rollover */\n\t{335544500, \"database does not use Write-ahead Log\"},\t\t/* no_wal */\n\t{335544501, \"cannot drop log file when journaling is enabled\"},\t\t/* drop_wal */\n\t{335544502, \"reference to invalid stream number\"},\t\t/* stream_not_defined */\n\t{335544503, \"WAL subsystem encountered error\"},\t\t/* wal_subsys_error */\n\t{335544504, \"WAL subsystem corrupted\"},\t\t/* wal_subsys_corrupt */\n\t{335544505, \"must specify archive file when enabling long term journal for databases with round-robin log files\"},\t\t/* no_archive */\n\t{335544506, \"database {0} shutdown in progress\"},\t\t/* shutinprog */\n\t{335544507, \"refresh range number {0} already in use\"},\t\t/* range_in_use */\n\t{335544508, \"refresh range number {0} not found\"},\t\t/* range_not_found */\n\t{335544509, \"CHARACTER SET {0} is not defined\"},\t\t/* charset_not_found */\n\t{335544510, \"lock time-out on wait transaction\"},\t\t/* lock_timeout */\n\t{335544511, \"procedure {0} is not defined\"},\t\t/* prcnotdef */\n\t{335544512, \"Input parameter mismatch for procedure {0}\"},\t\t/* prcmismat */\n\t{335544513, \"Database {0}: WAL subsystem bug for pid {1}\\n{2}\"},\t\t/* wal_bugcheck */\n\t{335544514, \"Could not expand the WAL segment for database {0}\"},\t\t/* wal_cant_expand */\n\t{335544515, \"status code {0} unknown\"},\t\t/* codnotdef */\n\t{335544516, \"exception {0} not defined\"},\t\t/* xcpnotdef */\n\t{335544517, \"exception {0}\"},\t\t/* except */\n\t{335544518, \"restart shared cache manager\"},\t\t/* cache_restart */\n\t{335544519, \"invalid lock handle\"},\t\t/* bad_lock_handle */\n\t{335544520, \"long-term journaling already enabled\"},\t\t/* jrn_present */\n\t{335544521, \"Unable to roll over please see Firebird log.\"},\t\t/* wal_err_rollover2 */\n\t{335544522, \"WAL I/O error.  Please see Firebird log.\"},\t\t/* wal_err_logwrite */\n\t{335544523, \"WAL writer - Journal server communication error.  Please see Firebird log.\"},\t\t/* wal_err_jrn_comm */\n\t{335544524, \"WAL buffers cannot be increased.  Please see Firebird log.\"},\t\t/* wal_err_expansion */\n\t{335544525, \"WAL setup error.  Please see Firebird log.\"},\t\t/* wal_err_setup */\n\t{335544526, \"obsolete\"},\t\t/* wal_err_ww_sync */\n\t{335544527, \"Cannot start WAL writer for the database {0}\"},\t\t/* wal_err_ww_start */\n\t{335544528, \"database {0} shutdown\"},\t\t/* shutdown */\n\t{335544529, \"cannot modify an existing user privilege\"},\t\t/* existing_priv_mod */\n\t{335544530, \"Cannot delete PRIMARY KEY being used in FOREIGN KEY definition.\"},\t\t/* primary_key_ref */\n\t{335544531, \"Column used in a PRIMARY constraint must be NOT NULL.\"},\t\t/* primary_key_notnull */\n\t{335544532, \"Name of Referential Constraint not defined in constraints table.\"},\t\t/* ref_cnstrnt_notfound */\n\t{335544533, \"Non-existent PRIMARY or UNIQUE KEY specified for FOREIGN KEY.\"},\t\t/* foreign_key_notfound */\n\t{335544534, \"Cannot update constraints (RDB$REF_CONSTRAINTS).\"},\t\t/* ref_cnstrnt_update */\n\t{335544535, \"Cannot update constraints (RDB$CHECK_CONSTRAINTS).\"},\t\t/* check_cnstrnt_update */\n\t{335544536, \"Cannot delete CHECK constraint entry (RDB$CHECK_CONSTRAINTS)\"},\t\t/* check_cnstrnt_del */\n\t{335544537, \"Cannot delete index segment used by an Integrity Constraint\"},\t\t/* integ_index_seg_del */\n\t{335544538, \"Cannot update index segment used by an Integrity Constraint\"},\t\t/* integ_index_seg_mod */\n\t{335544539, \"Cannot delete index used by an Integrity Constraint\"},\t\t/* integ_index_del */\n\t{335544540, \"Cannot modify index used by an Integrity Constraint\"},\t\t/* integ_index_mod */\n\t{335544541, \"Cannot delete trigger used by a CHECK Constraint\"},\t\t/* check_trig_del */\n\t{335544542, \"Cannot update trigger used by a CHECK Constraint\"},\t\t/* check_trig_update */\n\t{335544543, \"Cannot delete column being used in an Integrity Constraint.\"},\t\t/* cnstrnt_fld_del */\n\t{335544544, \"Cannot rename column being used in an Integrity Constraint.\"},\t\t/* cnstrnt_fld_rename */\n\t{335544545, \"Cannot update constraints (RDB$RELATION_CONSTRAINTS).\"},\t\t/* rel_cnstrnt_update */\n\t{335544546, \"Cannot define constraints on views\"},\t\t/* constaint_on_view */\n\t{335544547, \"internal Firebird consistency check (invalid RDB$CONSTRAINT_TYPE)\"},\t\t/* invld_cnstrnt_type */\n\t{335544548, \"Attempt to define a second PRIMARY KEY for the same table\"},\t\t/* primary_key_exists */\n\t{335544549, \"cannot modify or erase a system trigger\"},\t\t/* systrig_update */\n\t{335544550, \"only the owner of a table may reassign ownership\"},\t\t/* not_rel_owner */\n\t{335544551, \"could not find object for GRANT\"},\t\t/* grant_obj_notfound */\n\t{335544552, \"could not find column for GRANT\"},\t\t/* grant_fld_notfound */\n\t{335544553, \"user does not have GRANT privileges for operation\"},\t\t/* grant_nopriv */\n\t{335544554, \"object has non-SQL security class defined\"},\t\t/* nonsql_security_rel */\n\t{335544555, \"column has non-SQL security class defined\"},\t\t/* nonsql_security_fld */\n\t{335544556, \"Write-ahead Log without shared cache configuration not allowed\"},\t\t/* wal_cache_err */\n\t{335544557, \"database shutdown unsuccessful\"},\t\t/* shutfail */\n\t{335544558, \"Operation violates CHECK constraint {0} on view or table {1}\"},\t\t/* check_constraint */\n\t{335544559, \"invalid service handle\"},\t\t/* bad_svc_handle */\n\t{335544560, \"database {0} shutdown in {1} seconds\"},\t\t/* shutwarn */\n\t{335544561, \"wrong version of service parameter block\"},\t\t/* wrospbver */\n\t{335544562, \"unrecognized service parameter block\"},\t\t/* bad_spb_form */\n\t{335544563, \"service {0} is not defined\"},\t\t/* svcnotdef */\n\t{335544564, \"long-term journaling not enabled\"},\t\t/* no_jrn */\n\t{335544565, \"Cannot transliterate character between character sets\"},\t\t/* transliteration_failed */\n\t{335544566, \"WAL defined; Cache Manager must be started first\"},\t\t/* start_cm_for_wal */\n\t{335544567, \"Overflow log specification required for round-robin log\"},\t\t/* wal_ovflow_log_required */\n\t{335544568, \"Implementation of text subtype {0} not located.\"},\t\t/* text_subtype */\n\t{335544569, \"Dynamic SQL Error\"},\t\t/* dsql_error */\n\t{335544570, \"Invalid command\"},\t\t/* dsql_command_err */\n\t{335544571, \"Data type for constant unknown\"},\t\t/* dsql_constant_err */\n\t{335544572, \"Invalid cursor reference\"},\t\t/* dsql_cursor_err */\n\t{335544573, \"Data type unknown\"},\t\t/* dsql_datatype_err */\n\t{335544574, \"Invalid cursor declaration\"},\t\t/* dsql_decl_err */\n\t{335544575, \"Cursor {0} is not updatable\"},\t\t/* dsql_cursor_update_err */\n\t{335544576, \"Attempt to reopen an open cursor\"},\t\t/* dsql_cursor_open_err */\n\t{335544577, \"Attempt to reclose a closed cursor\"},\t\t/* dsql_cursor_close_err */\n\t{335544578, \"Column unknown\"},\t\t/* dsql_field_err */\n\t{335544579, \"Internal error\"},\t\t/* dsql_internal_err */\n\t{335544580, \"Table unknown\"},\t\t/* dsql_relation_err */\n\t{335544581, \"Procedure unknown\"},\t\t/* dsql_procedure_err */\n\t{335544582, \"Request unknown\"},\t\t/* dsql_request_err */\n\t{335544583, \"SQLDA error\"},\t\t/* dsql_sqlda_err */\n\t{335544584, \"Count of read-write columns does not equal count of values\"},\t\t/* dsql_var_count_err */\n\t{335544585, \"Invalid statement handle\"},\t\t/* dsql_stmt_handle */\n\t{335544586, \"Function unknown\"},\t\t/* dsql_function_err */\n\t{335544587, \"Column is not a BLOB\"},\t\t/* dsql_blob_err */\n\t{335544588, \"COLLATION {0} for CHARACTER SET {1} is not defined\"},\t\t/* collation_not_found */\n\t{335544589, \"COLLATION {0} is not valid for specified CHARACTER SET\"},\t\t/* collation_not_for_charset */\n\t{335544590, \"Option specified more than once\"},\t\t/* dsql_dup_option */\n\t{335544591, \"Unknown transaction option\"},\t\t/* dsql_tran_err */\n\t{335544592, \"Invalid array reference\"},\t\t/* dsql_invalid_array */\n\t{335544593, \"Array declared with too many dimensions\"},\t\t/* dsql_max_arr_dim_exceeded */\n\t{335544594, \"Illegal array dimension range\"},\t\t/* dsql_arr_range_error */\n\t{335544595, \"Trigger unknown\"},\t\t/* dsql_trigger_err */\n\t{335544596, \"Subselect illegal in this context\"},\t\t/* dsql_subselect_err */\n\t{335544597, \"Cannot prepare a CREATE DATABASE/SCHEMA statement\"},\t\t/* dsql_crdb_prepare_err */\n\t{335544598, \"must specify column name for view select expression\"},\t\t/* specify_field_err */\n\t{335544599, \"number of columns does not match select list\"},\t\t/* num_field_err */\n\t{335544600, \"Only simple column names permitted for VIEW WITH CHECK OPTION\"},\t\t/* col_name_err */\n\t{335544601, \"No WHERE clause for VIEW WITH CHECK OPTION\"},\t\t/* where_err */\n\t{335544602, \"Only one table allowed for VIEW WITH CHECK OPTION\"},\t\t/* table_view_err */\n\t{335544603, \"DISTINCT, GROUP or HAVING not permitted for VIEW WITH CHECK OPTION\"},\t\t/* distinct_err */\n\t{335544604, \"FOREIGN KEY column count does not match PRIMARY KEY\"},\t\t/* key_field_count_err */\n\t{335544605, \"No subqueries permitted for VIEW WITH CHECK OPTION\"},\t\t/* subquery_err */\n\t{335544606, \"expression evaluation not supported\"},\t\t/* expression_eval_err */\n\t{335544607, \"gen.c: node not supported\"},\t\t/* node_err */\n\t{335544608, \"Unexpected end of command\"},\t\t/* command_end_err */\n\t{335544609, \"INDEX {0}\"},\t\t/* index_name */\n\t{335544610, \"EXCEPTION {0}\"},\t\t/* exception_name */\n\t{335544611, \"COLUMN {0}\"},\t\t/* field_name */\n\t{335544612, \"Token unknown\"},\t\t/* token_err */\n\t{335544613, \"union not supported\"},\t\t/* union_err */\n\t{335544614, \"Unsupported DSQL construct\"},\t\t/* dsql_construct_err */\n\t{335544615, \"column used with aggregate\"},\t\t/* field_aggregate_err */\n\t{335544616, \"invalid column reference\"},\t\t/* field_ref_err */\n\t{335544617, \"invalid ORDER BY clause\"},\t\t/* order_by_err */\n\t{335544618, \"Return mode by value not allowed for this data type\"},\t\t/* return_mode_err */\n\t{335544619, \"External functions cannot have more than 10 parameters\"},\t\t/* extern_func_err */\n\t{335544620, \"alias {0} conflicts with an alias in the same statement\"},\t\t/* alias_conflict_err */\n\t{335544621, \"alias {0} conflicts with a procedure in the same statement\"},\t\t/* procedure_conflict_error */\n\t{335544622, \"alias {0} conflicts with a table in the same statement\"},\t\t/* relation_conflict_err */\n\t{335544623, \"Illegal use of keyword VALUE\"},\t\t/* dsql_domain_err */\n\t{335544624, \"segment count of 0 defined for index {0}\"},\t\t/* idx_seg_err */\n\t{335544625, \"A node name is not permitted in a secondary, shadow, cache or log file name\"},\t\t/* node_name_err */\n\t{335544626, \"TABLE {0}\"},\t\t/* table_name */\n\t{335544627, \"PROCEDURE {0}\"},\t\t/* proc_name */\n\t{335544628, \"cannot create index {0}\"},\t\t/* idx_create_err */\n\t{335544629, \"Write-ahead Log with shadowing configuration not allowed\"},\t\t/* wal_shadow_err */\n\t{335544630, \"there are {0} dependencies\"},\t\t/* dependency */\n\t{335544631, \"too many keys defined for index {0}\"},\t\t/* idx_key_err */\n\t{335544632, \"Preceding file did not specify length, so {0} must include starting page number\"},\t\t/* dsql_file_length_err */\n\t{335544633, \"Shadow number must be a positive integer\"},\t\t/* dsql_shadow_number_err */\n\t{335544634, \"Token unknown - line {0}, column {1}\"},\t\t/* dsql_token_unk_err */\n\t{335544635, \"there is no alias or table named {0} at this scope level\"},\t\t/* dsql_no_relation_alias */\n\t{335544636, \"there is no index {0} for table {1}\"},\t\t/* indexname */\n\t{335544637, \"table or procedure {0} is not referenced in plan\"},\t\t/* no_stream_plan */\n\t{335544638, \"table or procedure {0} is referenced more than once in plan; use aliases to distinguish\"},\t\t/* stream_twice */\n\t{335544639, \"table or procedure {0} is referenced in the plan but not the from list\"},\t\t/* stream_not_found */\n\t{335544640, \"Invalid use of CHARACTER SET or COLLATE\"},\t\t/* collation_requires_text */\n\t{335544641, \"Specified domain or source column {0} does not exist\"},\t\t/* dsql_domain_not_found */\n\t{335544642, \"index {0} cannot be used in the specified plan\"},\t\t/* index_unused */\n\t{335544643, \"the table {0} is referenced twice; use aliases to differentiate\"},\t\t/* dsql_self_join */\n\t{335544644, \"attempt to fetch before the first record in a record stream\"},\t\t/* stream_bof */\n\t{335544645, \"the current position is on a crack\"},\t\t/* stream_crack */\n\t{335544646, \"database or file exists\"},\t\t/* db_or_file_exists */\n\t{335544647, \"invalid comparison operator for find operation\"},\t\t/* invalid_operator */\n\t{335544648, \"Connection lost to pipe server\"},\t\t/* conn_lost */\n\t{335544649, \"bad checksum\"},\t\t/* bad_checksum */\n\t{335544650, \"wrong page type\"},\t\t/* page_type_err */\n\t{335544651, \"Cannot insert because the file is readonly or is on a read only medium.\"},\t\t/* ext_readonly_err */\n\t{335544652, \"multiple rows in singleton select\"},\t\t/* sing_select_err */\n\t{335544653, \"cannot attach to password database\"},\t\t/* psw_attach */\n\t{335544654, \"cannot start transaction for password database\"},\t\t/* psw_start_trans */\n\t{335544655, \"invalid direction for find operation\"},\t\t/* invalid_direction */\n\t{335544656, \"variable {0} conflicts with parameter in same procedure\"},\t\t/* dsql_var_conflict */\n\t{335544657, \"Array/BLOB/DATE data types not allowed in arithmetic\"},\t\t/* dsql_no_blob_array */\n\t{335544658, \"{0} is not a valid base table of the specified view\"},\t\t/* dsql_base_table */\n\t{335544659, \"table or procedure {0} is referenced twice in view; use an alias to distinguish\"},\t\t/* duplicate_base_table */\n\t{335544660, \"view {0} has more than one base table; use aliases to distinguish\"},\t\t/* view_alias */\n\t{335544661, \"cannot add index, index root page is full.\"},\t\t/* index_root_page_full */\n\t{335544662, \"BLOB SUB_TYPE {0} is not defined\"},\t\t/* dsql_blob_type_unknown */\n\t{335544663, \"Too many concurrent executions of the same request\"},\t\t/* req_max_clones_exceeded */\n\t{335544664, \"duplicate specification of {0} - not supported\"},\t\t/* dsql_duplicate_spec */\n\t{335544665, \"violation of PRIMARY or UNIQUE KEY constraint \\\"{0}\\\" on table \\\"{1}\\\"\"},\t\t/* unique_key_violation */\n\t{335544666, \"server version too old to support all CREATE DATABASE options\"},\t\t/* srvr_version_too_old */\n\t{335544667, \"drop database completed with errors\"},\t\t/* drdb_completed_with_errs */\n\t{335544668, \"procedure {0} does not return any values\"},\t\t/* dsql_procedure_use_err */\n\t{335544669, \"count of column list and variable list do not match\"},\t\t/* dsql_count_mismatch */\n\t{335544670, \"attempt to index BLOB column in index {0}\"},\t\t/* blob_idx_err */\n\t{335544671, \"attempt to index array column in index {0}\"},\t\t/* array_idx_err */\n\t{335544672, \"too few key columns found for index {0} (incorrect column name?)\"},\t\t/* key_field_err */\n\t{335544673, \"cannot delete\"},\t\t/* no_delete */\n\t{335544674, \"last column in a table cannot be deleted\"},\t\t/* del_last_field */\n\t{335544675, \"sort error\"},\t\t/* sort_err */\n\t{335544676, \"sort error: not enough memory\"},\t\t/* sort_mem_err */\n\t{335544677, \"too many versions\"},\t\t/* version_err */\n\t{335544678, \"invalid key position\"},\t\t/* inval_key_posn */\n\t{335544679, \"segments not allowed in expression index {0}\"},\t\t/* no_segments_err */\n\t{335544680, \"sort error: corruption in data structure\"},\t\t/* crrp_data_err */\n\t{335544681, \"new record size of {0} bytes is too big\"},\t\t/* rec_size_err */\n\t{335544682, \"Inappropriate self-reference of column\"},\t\t/* dsql_field_ref */\n\t{335544683, \"request depth exceeded. (Recursive definition?)\"},\t\t/* req_depth_exceeded */\n\t{335544684, \"cannot access column {0} in view {1}\"},\t\t/* no_field_access */\n\t{335544685, \"dbkey not available for multi-table views\"},\t\t/* no_dbkey */\n\t{335544686, \"journal file wrong format\"},\t\t/* jrn_format_err */\n\t{335544687, \"intermediate journal file full\"},\t\t/* jrn_file_full */\n\t{335544688, \"The prepare statement identifies a prepare statement with an open cursor\"},\t\t/* dsql_open_cursor_request */\n\t{335544689, \"Firebird error\"},\t\t/* ib_error */\n\t{335544690, \"Cache redefined\"},\t\t/* cache_redef */\n\t{335544691, \"Insufficient memory to allocate page buffer cache\"},\t\t/* cache_too_small */\n\t{335544692, \"Log redefined\"},\t\t/* log_redef */\n\t{335544693, \"Log size too small\"},\t\t/* log_too_small */\n\t{335544694, \"Log partition size too small\"},\t\t/* partition_too_small */\n\t{335544695, \"Partitions not supported in series of log file specification\"},\t\t/* partition_not_supp */\n\t{335544696, \"Total length of a partitioned log must be specified\"},\t\t/* log_length_spec */\n\t{335544697, \"Precision must be from 1 to 18\"},\t\t/* precision_err */\n\t{335544698, \"Scale must be between zero and precision\"},\t\t/* scale_nogt */\n\t{335544699, \"Short integer expected\"},\t\t/* expec_short */\n\t{335544700, \"Long integer expected\"},\t\t/* expec_long */\n\t{335544701, \"Unsigned short integer expected\"},\t\t/* expec_ushort */\n\t{335544702, \"Invalid ESCAPE sequence\"},\t\t/* escape_invalid */\n\t{335544703, \"service {0} does not have an associated executable\"},\t\t/* svcnoexe */\n\t{335544704, \"Failed to locate host machine.\"},\t\t/* net_lookup_err */\n\t{335544705, \"Undefined service {0}/{1}.\"},\t\t/* service_unknown */\n\t{335544706, \"The specified name was not found in the hosts file or Domain Name Services.\"},\t\t/* host_unknown */\n\t{335544707, \"user does not have GRANT privileges on base table/view for operation\"},\t\t/* grant_nopriv_on_base */\n\t{335544708, \"Ambiguous column reference.\"},\t\t/* dyn_fld_ambiguous */\n\t{335544709, \"Invalid aggregate reference\"},\t\t/* dsql_agg_ref_err */\n\t{335544710, \"navigational stream {0} references a view with more than one base table\"},\t\t/* complex_view */\n\t{335544711, \"Attempt to execute an unprepared dynamic SQL statement.\"},\t\t/* unprepared_stmt */\n\t{335544712, \"Positive value expected\"},\t\t/* expec_positive */\n\t{335544713, \"Incorrect values within SQLDA structure\"},\t\t/* dsql_sqlda_value_err */\n\t{335544714, \"invalid blob id\"},\t\t/* invalid_array_id */\n\t{335544715, \"Operation not supported for EXTERNAL FILE table {0}\"},\t\t/* extfile_uns_op */\n\t{335544716, \"Service is currently busy: {0}\"},\t\t/* svc_in_use */\n\t{335544717, \"stack size insufficent to execute current request\"},\t\t/* err_stack_limit */\n\t{335544718, \"Invalid key for find operation\"},\t\t/* invalid_key */\n\t{335544719, \"Error initializing the network software.\"},\t\t/* net_init_error */\n\t{335544720, \"Unable to load required library {0}.\"},\t\t/* loadlib_failure */\n\t{335544721, \"Unable to complete network request to host \\\"{0}\\\".\"},\t\t/* network_error */\n\t{335544722, \"Failed to establish a connection.\"},\t\t/* net_connect_err */\n\t{335544723, \"Error while listening for an incoming connection.\"},\t\t/* net_connect_listen_err */\n\t{335544724, \"Failed to establish a secondary connection for event processing.\"},\t\t/* net_event_connect_err */\n\t{335544725, \"Error while listening for an incoming event connection request.\"},\t\t/* net_event_listen_err */\n\t{335544726, \"Error reading data from the connection.\"},\t\t/* net_read_err */\n\t{335544727, \"Error writing data to the connection.\"},\t\t/* net_write_err */\n\t{335544728, \"Cannot deactivate index used by an integrity constraint\"},\t\t/* integ_index_deactivate */\n\t{335544729, \"Cannot deactivate index used by a PRIMARY/UNIQUE constraint\"},\t\t/* integ_deactivate_primary */\n\t{335544730, \"Client/Server Express not supported in this release\"},\t\t/* cse_not_supported */\n\t{335544731, \"\"},\t\t/* tra_must_sweep */\n\t{335544732, \"Access to databases on file servers is not supported.\"},\t\t/* unsupported_network_drive */\n\t{335544733, \"Error while trying to create file\"},\t\t/* io_create_err */\n\t{335544734, \"Error while trying to open file\"},\t\t/* io_open_err */\n\t{335544735, \"Error while trying to close file\"},\t\t/* io_close_err */\n\t{335544736, \"Error while trying to read from file\"},\t\t/* io_read_err */\n\t{335544737, \"Error while trying to write to file\"},\t\t/* io_write_err */\n\t{335544738, \"Error while trying to delete file\"},\t\t/* io_delete_err */\n\t{335544739, \"Error while trying to access file\"},\t\t/* io_access_err */\n\t{335544740, \"A fatal exception occurred during the execution of a user defined function.\"},\t\t/* udf_exception */\n\t{335544741, \"connection lost to database\"},\t\t/* lost_db_connection */\n\t{335544742, \"User cannot write to RDB$USER_PRIVILEGES\"},\t\t/* no_write_user_priv */\n\t{335544743, \"token size exceeds limit\"},\t\t/* token_too_long */\n\t{335544744, \"Maximum user count exceeded.  Contact your database administrator.\"},\t\t/* max_att_exceeded */\n\t{335544745, \"Your login {0} is same as one of the SQL role name. Ask your database administrator to set up a valid Firebird login.\"},\t\t/* login_same_as_role_name */\n\t{335544746, \"\\\"REFERENCES table\\\" without \\\"(column)\\\" requires PRIMARY KEY on referenced table\"},\t\t/* reftable_requires_pk */\n\t{335544747, \"The username entered is too long.  Maximum length is 31 bytes.\"},\t\t/* usrname_too_long */\n\t{335544748, \"The password specified is too long.  Maximum length is 8 bytes.\"},\t\t/* password_too_long */\n\t{335544749, \"A username is required for this operation.\"},\t\t/* usrname_required */\n\t{335544750, \"A password is required for this operation\"},\t\t/* password_required */\n\t{335544751, \"The network protocol specified is invalid\"},\t\t/* bad_protocol */\n\t{335544752, \"A duplicate user name was found in the security database\"},\t\t/* dup_usrname_found */\n\t{335544753, \"The user name specified was not found in the security database\"},\t\t/* usrname_not_found */\n\t{335544754, \"An error occurred while attempting to add the user.\"},\t\t/* error_adding_sec_record */\n\t{335544755, \"An error occurred while attempting to modify the user record.\"},\t\t/* error_modifying_sec_record */\n\t{335544756, \"An error occurred while attempting to delete the user record.\"},\t\t/* error_deleting_sec_record */\n\t{335544757, \"An error occurred while updating the security database.\"},\t\t/* error_updating_sec_db */\n\t{335544758, \"sort record size of {0} bytes is too big\"},\t\t/* sort_rec_size_err */\n\t{335544759, \"can not define a not null column with NULL as default value\"},\t\t/* bad_default_value */\n\t{335544760, \"invalid clause --- '{0}'\"},\t\t/* invalid_clause */\n\t{335544761, \"too many open handles to database\"},\t\t/* too_many_handles */\n\t{335544762, \"size of optimizer block exceeded\"},\t\t/* optimizer_blk_exc */\n\t{335544763, \"a string constant is delimited by double quotes\"},\t\t/* invalid_string_constant */\n\t{335544764, \"DATE must be changed to TIMESTAMP\"},\t\t/* transitional_date */\n\t{335544765, \"attempted update on read-only database\"},\t\t/* read_only_database */\n\t{335544766, \"SQL dialect {0} is not supported in this database\"},\t\t/* must_be_dialect_2_and_up */\n\t{335544767, \"A fatal exception occurred during the execution of a blob filter.\"},\t\t/* blob_filter_exception */\n\t{335544768, \"Access violation.  The code attempted to access a virtual address without privilege to do so.\"},\t\t/* exception_access_violation */\n\t{335544769, \"Datatype misalignment.  The attempted to read or write a value that was not stored on a memory boundary.\"},\t\t/* exception_datatype_missalignment */\n\t{335544770, \"Array bounds exceeded.  The code attempted to access an array element that is out of bounds.\"},\t\t/* exception_array_bounds_exceeded */\n\t{335544771, \"Float denormal operand.  One of the floating-point operands is too small to represent a standard float value.\"},\t\t/* exception_float_denormal_operand */\n\t{335544772, \"Floating-point divide by zero.  The code attempted to divide a floating-point value by zero.\"},\t\t/* exception_float_divide_by_zero */\n\t{335544773, \"Floating-point inexact result.  The result of a floating-point operation cannot be represented as a decimal fraction.\"},\t\t/* exception_float_inexact_result */\n\t{335544774, \"Floating-point invalid operand.  An indeterminant error occurred during a floating-point operation.\"},\t\t/* exception_float_invalid_operand */\n\t{335544775, \"Floating-point overflow.  The exponent of a floating-point operation is greater than the magnitude allowed.\"},\t\t/* exception_float_overflow */\n\t{335544776, \"Floating-point stack check.  The stack overflowed or underflowed as the result of a floating-point operation.\"},\t\t/* exception_float_stack_check */\n\t{335544777, \"Floating-point underflow.  The exponent of a floating-point operation is less than the magnitude allowed.\"},\t\t/* exception_float_underflow */\n\t{335544778, \"Integer divide by zero.  The code attempted to divide an integer value by an integer divisor of zero.\"},\t\t/* exception_integer_divide_by_zero */\n\t{335544779, \"Integer overflow.  The result of an integer operation caused the most significant bit of the result to carry.\"},\t\t/* exception_integer_overflow */\n\t{335544780, \"An exception occurred that does not have a description.  Exception number {0}.\"},\t\t/* exception_unknown */\n\t{335544781, \"Stack overflow.  The resource requirements of the runtime stack have exceeded the memory available to it.\"},\t\t/* exception_stack_overflow */\n\t{335544782, \"Segmentation Fault. The code attempted to access memory without privileges.\"},\t\t/* exception_sigsegv */\n\t{335544783, \"Illegal Instruction. The Code attempted to perform an illegal operation.\"},\t\t/* exception_sigill */\n\t{335544784, \"Bus Error. The Code caused a system bus error.\"},\t\t/* exception_sigbus */\n\t{335544785, \"Floating Point Error. The Code caused an Arithmetic Exception or a floating point exception.\"},\t\t/* exception_sigfpe */\n\t{335544786, \"Cannot delete rows from external files.\"},\t\t/* ext_file_delete */\n\t{335544787, \"Cannot update rows in external files.\"},\t\t/* ext_file_modify */\n\t{335544788, \"Unable to perform operation\"},\t\t/* adm_task_denied */\n\t{335544789, \"Specified EXTRACT part does not exist in input datatype\"},\t\t/* extract_input_mismatch */\n\t{335544790, \"Service {0} requires SYSDBA permissions.  Reattach to the Service Manager using the SYSDBA account.\"},\t\t/* insufficient_svc_privileges */\n\t{335544791, \"The file {0} is currently in use by another process.  Try again later.\"},\t\t/* file_in_use */\n\t{335544792, \"Cannot attach to services manager\"},\t\t/* service_att_err */\n\t{335544793, \"Metadata update statement is not allowed by the current database SQL dialect {0}\"},\t\t/* ddl_not_allowed_by_db_sql_dial */\n\t{335544794, \"operation was cancelled\"},\t\t/* cancelled */\n\t{335544795, \"unexpected item in service parameter block, expected {0}\"},\t\t/* unexp_spb_form */\n\t{335544796, \"Client SQL dialect {0} does not support reference to {1} datatype\"},\t\t/* sql_dialect_datatype_unsupport */\n\t{335544797, \"user name and password are required while attaching to the services manager\"},\t\t/* svcnouser */\n\t{335544798, \"You created an indirect dependency on uncommitted metadata. You must roll back the current transaction.\"},\t\t/* depend_on_uncommitted_rel */\n\t{335544799, \"The service name was not specified.\"},\t\t/* svc_name_missing */\n\t{335544800, \"Too many Contexts of Relation/Procedure/Views. Maximum allowed is 256\"},\t\t/* too_many_contexts */\n\t{335544801, \"data type not supported for arithmetic\"},\t\t/* datype_notsup */\n\t{335544802, \"Database dialect being changed from 3 to 1\"},\t\t/* dialect_reset_warning */\n\t{335544803, \"Database dialect not changed.\"},\t\t/* dialect_not_changed */\n\t{335544804, \"Unable to create database {0}\"},\t\t/* database_create_failed */\n\t{335544805, \"Database dialect {0} is not a valid dialect.\"},\t\t/* inv_dialect_specified */\n\t{335544806, \"Valid database dialects are {0}.\"},\t\t/* valid_db_dialects */\n\t{335544807, \"SQL warning code = {0}\"},\t\t/* sqlwarn */\n\t{335544808, \"DATE data type is now called TIMESTAMP\"},\t\t/* dtype_renamed */\n\t{335544809, \"Function {0} is in {1}, which is not in a permitted directory for external functions.\"},\t\t/* extern_func_dir_error */\n\t{335544810, \"value exceeds the range for valid dates\"},\t\t/* date_range_exceeded */\n\t{335544811, \"passed client dialect {0} is not a valid dialect.\"},\t\t/* inv_client_dialect_specified */\n\t{335544812, \"Valid client dialects are {0}.\"},\t\t/* valid_client_dialects */\n\t{335544813, \"Unsupported field type specified in BETWEEN predicate.\"},\t\t/* optimizer_between_err */\n\t{335544814, \"Services functionality will be supported in a later version  of the product\"},\t\t/* service_not_supported */\n\t{335544815, \"GENERATOR {0}\"},\t\t/* generator_name */\n\t{335544816, \"Function {0}\"},\t\t/* udf_name */\n\t{335544817, \"Invalid parameter to FETCH or FIRST. Only integers >= 0 are allowed.\"},\t\t/* bad_limit_param */\n\t{335544818, \"Invalid parameter to OFFSET or SKIP. Only integers >= 0 are allowed.\"},\t\t/* bad_skip_param */\n\t{335544819, \"File exceeded maximum size of 2GB.  Add another database file or use a 64 bit I/O version of Firebird.\"},\t\t/* io_32bit_exceeded_err */\n\t{335544820, \"Unable to find savepoint with name {0} in transaction context\"},\t\t/* invalid_savepoint */\n\t{335544821, \"Invalid column position used in the {0} clause\"},\t\t/* dsql_column_pos_err */\n\t{335544822, \"Cannot use an aggregate or window function in a WHERE clause, use HAVING (for aggregate only) instead\"},\t\t/* dsql_agg_where_err */\n\t{335544823, \"Cannot use an aggregate or window function in a GROUP BY clause\"},\t\t/* dsql_agg_group_err */\n\t{335544824, \"Invalid expression in the {0} (not contained in either an aggregate function or the GROUP BY clause)\"},\t\t/* dsql_agg_column_err */\n\t{335544825, \"Invalid expression in the {0} (neither an aggregate function nor a part of the GROUP BY clause)\"},\t\t/* dsql_agg_having_err */\n\t{335544826, \"Nested aggregate and window functions are not allowed\"},\t\t/* dsql_agg_nested_err */\n\t{335544827, \"Invalid argument in EXECUTE STATEMENT - cannot convert to string\"},\t\t/* exec_sql_invalid_arg */\n\t{335544828, \"Wrong request type in EXECUTE STATEMENT '{0}'\"},\t\t/* exec_sql_invalid_req */\n\t{335544829, \"Variable type (position {0}) in EXECUTE STATEMENT '{1}' INTO does not match returned column type\"},\t\t/* exec_sql_invalid_var */\n\t{335544830, \"Too many recursion levels of EXECUTE STATEMENT\"},\t\t/* exec_sql_max_call_exceeded */\n\t{335544831, \"Use of {0} at location {1} is not allowed by server configuration\"},\t\t/* conf_access_denied */\n\t{335544832, \"Cannot change difference file name while database is in backup mode\"},\t\t/* wrong_backup_state */\n\t{335544833, \"Physical backup is not allowed while Write-Ahead Log is in use\"},\t\t/* wal_backup_err */\n\t{335544834, \"Cursor is not open\"},\t\t/* cursor_not_open */\n\t{335544835, \"Target shutdown mode is invalid for database \\\"{0}\\\"\"},\t\t/* bad_shutdown_mode */\n\t{335544836, \"Concatenation overflow. Resulting string cannot exceed 32765 bytes in length.\"},\t\t/* concat_overflow */\n\t{335544837, \"Invalid offset parameter {0} to SUBSTRING. Only positive integers are allowed.\"},\t\t/* bad_substring_offset */\n\t{335544838, \"Foreign key reference target does not exist\"},\t\t/* foreign_key_target_doesnt_exist */\n\t{335544839, \"Foreign key references are present for the record\"},\t\t/* foreign_key_references_present */\n\t{335544840, \"cannot update\"},\t\t/* no_update */\n\t{335544841, \"Cursor is already open\"},\t\t/* cursor_already_open */\n\t{335544842, \"{0}\"},\t\t/* stack_trace */\n\t{335544843, \"Context variable '{0}' is not found in namespace '{1}'\"},\t\t/* ctx_var_not_found */\n\t{335544844, \"Invalid namespace name '{0}' passed to {1}\"},\t\t/* ctx_namespace_invalid */\n\t{335544845, \"Too many context variables\"},\t\t/* ctx_too_big */\n\t{335544846, \"Invalid argument passed to {0}\"},\t\t/* ctx_bad_argument */\n\t{335544847, \"BLR syntax error. Identifier {0}... is too long\"},\t\t/* identifier_too_long */\n\t{335544848, \"exception {0}\"},\t\t/* except2 */\n\t{335544849, \"Malformed string\"},\t\t/* malformed_string */\n\t{335544850, \"Output parameter mismatch for procedure {0}\"},\t\t/* prc_out_param_mismatch */\n\t{335544851, \"Unexpected end of command - line {0}, column {1}\"},\t\t/* command_end_err2 */\n\t{335544852, \"partner index segment no {0} has incompatible data type\"},\t\t/* partner_idx_incompat_type */\n\t{335544853, \"Invalid length parameter {0} to SUBSTRING. Negative integers are not allowed.\"},\t\t/* bad_substring_length */\n\t{335544854, \"CHARACTER SET {0} is not installed\"},\t\t/* charset_not_installed */\n\t{335544855, \"COLLATION {0} for CHARACTER SET {1} is not installed\"},\t\t/* collation_not_installed */\n\t{335544856, \"connection shutdown\"},\t\t/* att_shutdown */\n\t{335544857, \"Maximum BLOB size exceeded\"},\t\t/* blobtoobig */\n\t{335544858, \"Can't have relation with only computed fields or constraints\"},\t\t/* must_have_phys_field */\n\t{335544859, \"Time precision exceeds allowed range (0-{0})\"},\t\t/* invalid_time_precision */\n\t{335544860, \"Unsupported conversion to target type BLOB (subtype {0})\"},\t\t/* blob_convert_error */\n\t{335544861, \"Unsupported conversion to target type ARRAY\"},\t\t/* array_convert_error */\n\t{335544862, \"Stream does not support record locking\"},\t\t/* record_lock_not_supp */\n\t{335544863, \"Cannot create foreign key constraint {0}. Partner index does not exist or is inactive.\"},\t\t/* partner_idx_not_found */\n\t{335544864, \"Transactions count exceeded. Perform backup and restore to make database operable again\"},\t\t/* tra_num_exc */\n\t{335544865, \"Column has been unexpectedly deleted\"},\t\t/* field_disappeared */\n\t{335544866, \"{0} cannot depend on {1}\"},\t\t/* met_wrong_gtt_scope */\n\t{335544867, \"Blob sub_types bigger than 1 (text) are for internal use only\"},\t\t/* subtype_for_internal_use */\n\t{335544868, \"Procedure {0} is not selectable (it does not contain a SUSPEND statement)\"},\t\t/* illegal_prc_type */\n\t{335544869, \"Datatype {0} is not supported for sorting operation\"},\t\t/* invalid_sort_datatype */\n\t{335544870, \"COLLATION {0}\"},\t\t/* collation_name */\n\t{335544871, \"DOMAIN {0}\"},\t\t/* domain_name */\n\t{335544872, \"domain {0} is not defined\"},\t\t/* domnotdef */\n\t{335544873, \"Array data type can use up to {0} dimensions\"},\t\t/* array_max_dimensions */\n\t{335544874, \"A multi database transaction cannot span more than {0} databases\"},\t\t/* max_db_per_trans_allowed */\n\t{335544875, \"Bad debug info format\"},\t\t/* bad_debug_format */\n\t{335544876, \"Error while parsing procedure {0}'s BLR\"},\t\t/* bad_proc_BLR */\n\t{335544877, \"index key too big\"},\t\t/* key_too_big */\n\t{335544878, \"concurrent transaction number is {0}\"},\t\t/* concurrent_transaction */\n\t{335544879, \"validation error for variable {0}, value \\\"{1}\\\"\"},\t\t/* not_valid_for_var */\n\t{335544880, \"validation error for {0}, value \\\"{1}\\\"\"},\t\t/* not_valid_for */\n\t{335544881, \"Difference file name should be set explicitly for database on raw device\"},\t\t/* need_difference */\n\t{335544882, \"Login name too long ({0} characters, maximum allowed {1})\"},\t\t/* long_login */\n\t{335544883, \"column {0} is not defined in procedure {1}\"},\t\t/* fldnotdef2 */\n\t{335544884, \"Invalid SIMILAR TO pattern\"},\t\t/* invalid_similar_pattern */\n\t{335544885, \"Invalid TEB format\"},\t\t/* bad_teb_form */\n\t{335544886, \"Found more than one transaction isolation in TPB\"},\t\t/* tpb_multiple_txn_isolation */\n\t{335544887, \"Table reservation lock type {0} requires table name before in TPB\"},\t\t/* tpb_reserv_before_table */\n\t{335544888, \"Found more than one {0} specification in TPB\"},\t\t/* tpb_multiple_spec */\n\t{335544889, \"Option {0} requires READ COMMITTED isolation in TPB\"},\t\t/* tpb_option_without_rc */\n\t{335544890, \"Option {0} is not valid if {1} was used previously in TPB\"},\t\t/* tpb_conflicting_options */\n\t{335544891, \"Table name length missing after table reservation {0} in TPB\"},\t\t/* tpb_reserv_missing_tlen */\n\t{335544892, \"Table name length {0} is too long after table reservation {1} in TPB\"},\t\t/* tpb_reserv_long_tlen */\n\t{335544893, \"Table name length {0} without table name after table reservation {1} in TPB\"},\t\t/* tpb_reserv_missing_tname */\n\t{335544894, \"Table name length {0} goes beyond the remaining TPB size after table reservation {1}\"},\t\t/* tpb_reserv_corrup_tlen */\n\t{335544895, \"Table name length is zero after table reservation {0} in TPB\"},\t\t/* tpb_reserv_null_tlen */\n\t{335544896, \"Table or view {0} not defined in system tables after table reservation {1} in TPB\"},\t\t/* tpb_reserv_relnotfound */\n\t{335544897, \"Base table or view {0} for view {1} not defined in system tables after table reservation {2} in TPB\"},\t\t/* tpb_reserv_baserelnotfound */\n\t{335544898, \"Option length missing after option {0} in TPB\"},\t\t/* tpb_missing_len */\n\t{335544899, \"Option length {0} without value after option {1} in TPB\"},\t\t/* tpb_missing_value */\n\t{335544900, \"Option length {0} goes beyond the remaining TPB size after option {1}\"},\t\t/* tpb_corrupt_len */\n\t{335544901, \"Option length is zero after table reservation {0} in TPB\"},\t\t/* tpb_null_len */\n\t{335544902, \"Option length {0} exceeds the range for option {1} in TPB\"},\t\t/* tpb_overflow_len */\n\t{335544903, \"Option value {0} is invalid for the option {1} in TPB\"},\t\t/* tpb_invalid_value */\n\t{335544904, \"Preserving previous table reservation {0} for table {1}, stronger than new {2} in TPB\"},\t\t/* tpb_reserv_stronger_wng */\n\t{335544905, \"Table reservation {0} for table {1} already specified and is stronger than new {2} in TPB\"},\t\t/* tpb_reserv_stronger */\n\t{335544906, \"Table reservation reached maximum recursion of {0} when expanding views in TPB\"},\t\t/* tpb_reserv_max_recursion */\n\t{335544907, \"Table reservation in TPB cannot be applied to {0} because it's a virtual table\"},\t\t/* tpb_reserv_virtualtbl */\n\t{335544908, \"Table reservation in TPB cannot be applied to {0} because it's a system table\"},\t\t/* tpb_reserv_systbl */\n\t{335544909, \"Table reservation {0} or {1} in TPB cannot be applied to {2} because it's a temporary table\"},\t\t/* tpb_reserv_temptbl */\n\t{335544910, \"Cannot set the transaction in read only mode after a table reservation isc_tpb_lock_write in TPB\"},\t\t/* tpb_readtxn_after_writelock */\n\t{335544911, \"Cannot take a table reservation isc_tpb_lock_write in TPB because the transaction is in read only mode\"},\t\t/* tpb_writelock_after_readtxn */\n\t{335544912, \"value exceeds the range for a valid time\"},\t\t/* time_range_exceeded */\n\t{335544913, \"value exceeds the range for valid timestamps\"},\t\t/* datetime_range_exceeded */\n\t{335544914, \"string right truncation\"},\t\t/* string_truncation */\n\t{335544915, \"blob truncation when converting to a string: length limit exceeded\"},\t\t/* blob_truncation */\n\t{335544916, \"numeric value is out of range\"},\t\t/* numeric_out_of_range */\n\t{335544917, \"Firebird shutdown is still in progress after the specified timeout\"},\t\t/* shutdown_timeout */\n\t{335544918, \"Attachment handle is busy\"},\t\t/* att_handle_busy */\n\t{335544919, \"Bad written UDF detected: pointer returned in FREE_IT function was not allocated by ib_util_malloc\"},\t\t/* bad_udf_freeit */\n\t{335544920, \"External Data Source provider '{0}' not found\"},\t\t/* eds_provider_not_found */\n\t{335544921, \"Execute statement error at {0} :\\n{1}Data source : {2}\"},\t\t/* eds_connection */\n\t{335544922, \"Execute statement preprocess SQL error\"},\t\t/* eds_preprocess */\n\t{335544923, \"Statement expected\"},\t\t/* eds_stmt_expected */\n\t{335544924, \"Parameter name expected\"},\t\t/* eds_prm_name_expected */\n\t{335544925, \"Unclosed comment found near '{0}'\"},\t\t/* eds_unclosed_comment */\n\t{335544926, \"Execute statement error at {0} :\\n{1}Statement : {2}\\nData source : {3}\"},\t\t/* eds_statement */\n\t{335544927, \"Input parameters mismatch\"},\t\t/* eds_input_prm_mismatch */\n\t{335544928, \"Output parameters mismatch\"},\t\t/* eds_output_prm_mismatch */\n\t{335544929, \"Input parameter '{0}' have no value set\"},\t\t/* eds_input_prm_not_set */\n\t{335544930, \"BLR stream length {0} exceeds implementation limit {1}\"},\t\t/* too_big_blr */\n\t{335544931, \"Monitoring table space exhausted\"},\t\t/* montabexh */\n\t{335544932, \"module name or entrypoint could not be found\"},\t\t/* modnotfound */\n\t{335544933, \"nothing to cancel\"},\t\t/* nothing_to_cancel */\n\t{335544934, \"ib_util library has not been loaded to deallocate memory returned by FREE_IT function\"},\t\t/* ibutil_not_loaded */\n\t{335544935, \"Cannot have circular dependencies with computed fields\"},\t\t/* circular_computed */\n\t{335544936, \"Security database error\"},\t\t/* psw_db_error */\n\t{335544937, \"Invalid data type in DATE/TIME/TIMESTAMP addition or subtraction in add_datettime()\"},\t\t/* invalid_type_datetime_op */\n\t{335544938, \"Only a TIME value can be added to a DATE value\"},\t\t/* onlycan_add_timetodate */\n\t{335544939, \"Only a DATE value can be added to a TIME value\"},\t\t/* onlycan_add_datetotime */\n\t{335544940, \"TIMESTAMP values can be subtracted only from another TIMESTAMP value\"},\t\t/* onlycansub_tstampfromtstamp */\n\t{335544941, \"Only one operand can be of type TIMESTAMP\"},\t\t/* onlyoneop_mustbe_tstamp */\n\t{335544942, \"Only HOUR, MINUTE, SECOND and MILLISECOND can be extracted from TIME values\"},\t\t/* invalid_extractpart_time */\n\t{335544943, \"HOUR, MINUTE, SECOND and MILLISECOND cannot be extracted from DATE values\"},\t\t/* invalid_extractpart_date */\n\t{335544944, \"Invalid argument for EXTRACT() not being of DATE/TIME/TIMESTAMP type\"},\t\t/* invalidarg_extract */\n\t{335544945, \"Arguments for {0} must be integral types or NUMERIC/DECIMAL without scale\"},\t\t/* sysf_argmustbe_exact */\n\t{335544946, \"First argument for {0} must be integral type or floating point type\"},\t\t/* sysf_argmustbe_exact_or_fp */\n\t{335544947, \"Human readable UUID argument for {0} must be of string type\"},\t\t/* sysf_argviolates_uuidtype */\n\t{335544948, \"Human readable UUID argument for {1} must be of exact length {0}\"},\t\t/* sysf_argviolates_uuidlen */\n\t{335544949, \"Human readable UUID argument for {2} must have \\\"-\\\" at position {1} instead of \\\"{0}\\\"\"},\t\t/* sysf_argviolates_uuidfmt */\n\t{335544950, \"Human readable UUID argument for {2} must have hex digit at position {1} instead of \\\"{0}\\\"\"},\t\t/* sysf_argviolates_guidigits */\n\t{335544951, \"Only HOUR, MINUTE, SECOND and MILLISECOND can be added to TIME values in {0}\"},\t\t/* sysf_invalid_addpart_time */\n\t{335544952, \"Invalid data type in addition of part to DATE/TIME/TIMESTAMP in {0}\"},\t\t/* sysf_invalid_add_datetime */\n\t{335544953, \"Invalid part {0} to be added to a DATE/TIME/TIMESTAMP value in {1}\"},\t\t/* sysf_invalid_addpart_dtime */\n\t{335544954, \"Expected DATE/TIME/TIMESTAMP type in evlDateAdd() result\"},\t\t/* sysf_invalid_add_dtime_rc */\n\t{335544955, \"Expected DATE/TIME/TIMESTAMP type as first and second argument to {0}\"},\t\t/* sysf_invalid_diff_dtime */\n\t{335544956, \"The result of TIME-<value> in {0} cannot be expressed in YEAR, MONTH, DAY or WEEK\"},\t\t/* sysf_invalid_timediff */\n\t{335544957, \"The result of TIME-TIMESTAMP or TIMESTAMP-TIME in {0} cannot be expressed in HOUR, MINUTE, SECOND or MILLISECOND\"},\t\t/* sysf_invalid_tstamptimediff */\n\t{335544958, \"The result of DATE-TIME or TIME-DATE in {0} cannot be expressed in HOUR, MINUTE, SECOND and MILLISECOND\"},\t\t/* sysf_invalid_datetimediff */\n\t{335544959, \"Invalid part {0} to express the difference between two DATE/TIME/TIMESTAMP values in {1}\"},\t\t/* sysf_invalid_diffpart */\n\t{335544960, \"Argument for {0} must be positive\"},\t\t/* sysf_argmustbe_positive */\n\t{335544961, \"Base for {0} must be positive\"},\t\t/* sysf_basemustbe_positive */\n\t{335544962, \"Argument #{0} for {1} must be zero or positive\"},\t\t/* sysf_argnmustbe_nonneg */\n\t{335544963, \"Argument #{0} for {1} must be positive\"},\t\t/* sysf_argnmustbe_positive */\n\t{335544964, \"Base for {0} cannot be zero if exponent is negative\"},\t\t/* sysf_invalid_zeropowneg */\n\t{335544965, \"Base for {0} cannot be negative if exponent is not an integral value\"},\t\t/* sysf_invalid_negpowfp */\n\t{335544966, \"The numeric scale must be between -128 and 127 in {0}\"},\t\t/* sysf_invalid_scale */\n\t{335544967, \"Argument for {0} must be zero or positive\"},\t\t/* sysf_argmustbe_nonneg */\n\t{335544968, \"Binary UUID argument for {0} must be of string type\"},\t\t/* sysf_binuuid_mustbe_str */\n\t{335544969, \"Binary UUID argument for {1} must use {0} bytes\"},\t\t/* sysf_binuuid_wrongsize */\n\t{335544970, \"Missing required item {0} in service parameter block\"},\t\t/* missing_required_spb */\n\t{335544971, \"{0} server is shutdown\"},\t\t/* net_server_shutdown */\n\t{335544972, \"Invalid connection string\"},\t\t/* bad_conn_str */\n\t{335544973, \"Unrecognized events block\"},\t\t/* bad_epb_form */\n\t{335544974, \"Could not start first worker thread - shutdown server\"},\t\t/* no_threads */\n\t{335544975, \"Timeout occurred while waiting for a secondary connection for event processing\"},\t\t/* net_event_connect_timeout */\n\t{335544976, \"Argument for {0} must be different than zero\"},\t\t/* sysf_argmustbe_nonzero */\n\t{335544977, \"Argument for {0} must be in the range [-1, 1]\"},\t\t/* sysf_argmustbe_range_inc1_1 */\n\t{335544978, \"Argument for {0} must be greater or equal than one\"},\t\t/* sysf_argmustbe_gteq_one */\n\t{335544979, \"Argument for {0} must be in the range ]-1, 1[\"},\t\t/* sysf_argmustbe_range_exc1_1 */\n\t{335544980, \"Incorrect parameters provided to internal function {0}\"},\t\t/* internal_rejected_params */\n\t{335544981, \"Floating point overflow in built-in function {0}\"},\t\t/* sysf_fp_overflow */\n\t{335544982, \"Floating point overflow in result from UDF {0}\"},\t\t/* udf_fp_overflow */\n\t{335544983, \"Invalid floating point value returned by UDF {0}\"},\t\t/* udf_fp_nan */\n\t{335544984, \"Shared memory area is probably already created by another engine instance in another Windows session\"},\t\t/* instance_conflict */\n\t{335544985, \"No free space found in temporary directories\"},\t\t/* out_of_temp_space */\n\t{335544986, \"Explicit transaction control is not allowed\"},\t\t/* eds_expl_tran_ctrl */\n\t{335544987, \"Use of TRUSTED switches in spb_command_line is prohibited\"},\t\t/* no_trusted_spb */\n\t{335544988, \"PACKAGE {0}\"},\t\t/* package_name */\n\t{335544989, \"Cannot make field {0} of table {1} NOT NULL because there are NULLs present\"},\t\t/* cannot_make_not_null */\n\t{335544990, \"Feature {0} is not supported anymore\"},\t\t/* feature_removed */\n\t{335544991, \"VIEW {0}\"},\t\t/* view_name */\n\t{335544992, \"Can not access lock files directory {0}\"},\t\t/* lock_dir_access */\n\t{335544993, \"Fetch option {0} is invalid for a non-scrollable cursor\"},\t\t/* invalid_fetch_option */\n\t{335544994, \"Error while parsing function {0}'s BLR\"},\t\t/* bad_fun_BLR */\n\t{335544995, \"Cannot execute function {0} of the unimplemented package {1}\"},\t\t/* func_pack_not_implemented */\n\t{335544996, \"Cannot execute procedure {0} of the unimplemented package {1}\"},\t\t/* proc_pack_not_implemented */\n\t{335544997, \"External function {0} not returned by the external engine plugin {1}\"},\t\t/* eem_func_not_returned */\n\t{335544998, \"External procedure {0} not returned by the external engine plugin {1}\"},\t\t/* eem_proc_not_returned */\n\t{335544999, \"External trigger {0} not returned by the external engine plugin {1}\"},\t\t/* eem_trig_not_returned */\n\t{335545000, \"Incompatible plugin version {0} for external engine {1}\"},\t\t/* eem_bad_plugin_ver */\n\t{335545001, \"External engine {0} not found\"},\t\t/* eem_engine_notfound */\n\t{335545002, \"Attachment is in use\"},\t\t/* attachment_in_use */\n\t{335545003, \"Transaction is in use\"},\t\t/* transaction_in_use */\n\t{335545004, \"Error loading plugin {0}\"},\t\t/* pman_cannot_load_plugin */\n\t{335545005, \"Loadable module {0} not found\"},\t\t/* pman_module_notfound */\n\t{335545006, \"Standard plugin entrypoint does not exist in module {0}\"},\t\t/* pman_entrypoint_notfound */\n\t{335545007, \"Module {0} exists but can not be loaded\"},\t\t/* pman_module_bad */\n\t{335545008, \"Module {0} does not contain plugin {1} type {2}\"},\t\t/* pman_plugin_notfound */\n\t{335545009, \"Invalid usage of context namespace DDL_TRIGGER\"},\t\t/* sysf_invalid_trig_namespace */\n\t{335545010, \"Value is NULL but isNull parameter was not informed\"},\t\t/* unexpected_null */\n\t{335545011, \"Type {0} is incompatible with BLOB\"},\t\t/* type_notcompat_blob */\n\t{335545012, \"Invalid date\"},\t\t/* invalid_date_val */\n\t{335545013, \"Invalid time\"},\t\t/* invalid_time_val */\n\t{335545014, \"Invalid timestamp\"},\t\t/* invalid_timestamp_val */\n\t{335545015, \"Invalid index {0} in function {1}\"},\t\t/* invalid_index_val */\n\t{335545016, \"{0}\"},\t\t/* formatted_exception */\n\t{335545017, \"Asynchronous call is already running for this attachment\"},\t\t/* async_active */\n\t{335545018, \"Function {0} is private to package {1}\"},\t\t/* private_function */\n\t{335545019, \"Procedure {0} is private to package {1}\"},\t\t/* private_procedure */\n\t{335545020, \"Request can't access new records in relation {0} and should be recompiled\"},\t\t/* request_outdated */\n\t{335545021, \"invalid events id (handle)\"},\t\t/* bad_events_handle */\n\t{335545022, \"Cannot copy statement {0}\"},\t\t/* cannot_copy_stmt */\n\t{335545023, \"Invalid usage of boolean expression\"},\t\t/* invalid_boolean_usage */\n\t{335545024, \"Arguments for {0} cannot both be zero\"},\t\t/* sysf_argscant_both_be_zero */\n\t{335545025, \"missing service ID in spb\"},\t\t/* spb_no_id */\n\t{335545026, \"External BLR message mismatch: invalid null descriptor at field {0}\"},\t\t/* ee_blr_mismatch_null */\n\t{335545027, \"External BLR message mismatch: length = {0}, expected {1}\"},\t\t/* ee_blr_mismatch_length */\n\t{335545028, \"Subscript {0} out of bounds [{1}, {2}]\"},\t\t/* ss_out_of_bounds */\n\t{335545029, \"Install incomplete. To complete security database initialization please CREATE USER. For details read doc/README.security_database.txt.\"},\t\t/* missing_data_structures */\n\t{335545030, \"{0} operation is not allowed for system table {1}\"},\t\t/* protect_sys_tab */\n\t{335545031, \"Libtommath error code {0} in function {1}\"},\t\t/* libtommath_generic */\n\t{335545032, \"unsupported BLR version (expected between {0} and {1}, encountered {2})\"},\t\t/* wroblrver2 */\n\t{335545033, \"expected length {0}, actual {1}\"},\t\t/* trunc_limits */\n\t{335545034, \"Wrong info requested in isc_svc_query() for anonymous service\"},\t\t/* info_access */\n\t{335545035, \"No isc_info_svc_stdin in user request, but service thread requested stdin data\"},\t\t/* svc_no_stdin */\n\t{335545036, \"Start request for anonymous service is impossible\"},\t\t/* svc_start_failed */\n\t{335545037, \"All services except for getting server log require switches\"},\t\t/* svc_no_switches */\n\t{335545038, \"Size of stdin data is more than was requested from client\"},\t\t/* svc_bad_size */\n\t{335545039, \"Crypt plugin {0} failed to load\"},\t\t/* no_crypt_plugin */\n\t{335545040, \"Length of crypt plugin name should not exceed {0} bytes\"},\t\t/* cp_name_too_long */\n\t{335545041, \"Crypt failed - already crypting database\"},\t\t/* cp_process_active */\n\t{335545042, \"Crypt failed - database is already in requested state\"},\t\t/* cp_already_crypted */\n\t{335545043, \"Missing crypt plugin, but page appears encrypted\"},\t\t/* decrypt_error */\n\t{335545044, \"No providers loaded\"},\t\t/* no_providers */\n\t{335545045, \"NULL data with non-zero SPB length\"},\t\t/* null_spb */\n\t{335545046, \"Maximum ({0}) number of arguments exceeded for function {1}\"},\t\t/* max_args_exceeded */\n\t{335545047, \"External BLR message mismatch: names count = {0}, blr count = {1}\"},\t\t/* ee_blr_mismatch_names_count */\n\t{335545048, \"External BLR message mismatch: name {0} not found\"},\t\t/* ee_blr_mismatch_name_not_found */\n\t{335545049, \"Invalid resultset interface\"},\t\t/* bad_result_set */\n\t{335545050, \"Message length passed from user application does not match set of columns\"},\t\t/* wrong_message_length */\n\t{335545051, \"Resultset is missing output format information\"},\t\t/* no_output_format */\n\t{335545052, \"Message metadata not ready - item {0} is not finished\"},\t\t/* item_finish */\n\t{335545053, \"Missing configuration file: {0}\"},\t\t/* miss_config */\n\t{335545054, \"{0}: illegal line <{1}>\"},\t\t/* conf_line */\n\t{335545055, \"Invalid include operator in {0} for <{1}>\"},\t\t/* conf_include */\n\t{335545056, \"Include depth too big\"},\t\t/* include_depth */\n\t{335545057, \"File to include not found\"},\t\t/* include_miss */\n\t{335545058, \"Only the owner can change the ownership\"},\t\t/* protect_ownership */\n\t{335545059, \"undefined variable number\"},\t\t/* badvarnum */\n\t{335545060, \"Missing security context for {0}\"},\t\t/* sec_context */\n\t{335545061, \"Missing segment {0} in multisegment connect block parameter\"},\t\t/* multi_segment */\n\t{335545062, \"Different logins in connect and attach packets - client library error\"},\t\t/* login_changed */\n\t{335545063, \"Exceeded exchange limit during authentication handshake\"},\t\t/* auth_handshake_limit */\n\t{335545064, \"Incompatible wire encryption levels requested on client and server\"},\t\t/* wirecrypt_incompatible */\n\t{335545065, \"Client attempted to attach unencrypted but wire encryption is required\"},\t\t/* miss_wirecrypt */\n\t{335545066, \"Client attempted to start wire encryption using unknown key {0}\"},\t\t/* wirecrypt_key */\n\t{335545067, \"Client attempted to start wire encryption using unsupported plugin {0}\"},\t\t/* wirecrypt_plugin */\n\t{335545068, \"Error getting security database name from configuration file\"},\t\t/* secdb_name */\n\t{335545069, \"Client authentication plugin is missing required data from server\"},\t\t/* auth_data */\n\t{335545070, \"Client authentication plugin expected {1} bytes of {2} from server, got {0}\"},\t\t/* auth_datalength */\n\t{335545071, \"Attempt to get information about an unprepared dynamic SQL statement.\"},\t\t/* info_unprepared_stmt */\n\t{335545072, \"Problematic key value is {0}\"},\t\t/* idx_key_value */\n\t{335545073, \"Cannot select virtual table {0} for update WITH LOCK\"},\t\t/* forupdate_virtualtbl */\n\t{335545074, \"Cannot select system table {0} for update WITH LOCK\"},\t\t/* forupdate_systbl */\n\t{335545075, \"Cannot select temporary table {0} for update WITH LOCK\"},\t\t/* forupdate_temptbl */\n\t{335545076, \"System {0} {1} cannot be modified\"},\t\t/* cant_modify_sysobj */\n\t{335545077, \"Server misconfigured - contact administrator please\"},\t\t/* server_misconfigured */\n\t{335545078, \"Deprecated backward compatibility ALTER ROLE ... SET/DROP AUTO ADMIN mapping may be used only for RDB$ADMIN role\"},\t\t/* alter_role */\n\t{335545079, \"Mapping {0} already exists\"},\t\t/* map_already_exists */\n\t{335545080, \"Mapping {0} does not exist\"},\t\t/* map_not_exists */\n\t{335545081, \"{0} failed when loading mapping cache\"},\t\t/* map_load */\n\t{335545082, \"Invalid name <*> in authentication block\"},\t\t/* map_aster */\n\t{335545083, \"Multiple maps found for {0}\"},\t\t/* map_multi */\n\t{335545084, \"Undefined mapping result - more than one different results found\"},\t\t/* map_undefined */\n\t{335545085, \"Incompatible mode of attachment to damaged database\"},\t\t/* baddpb_damaged_mode */\n\t{335545086, \"Attempt to set in database number of buffers which is out of acceptable range [{0}:{1}]\"},\t\t/* baddpb_buffers_range */\n\t{335545087, \"Attempt to temporarily set number of buffers less than {0}\"},\t\t/* baddpb_temp_buffers */\n\t{335545088, \"Global mapping is not available when database {0} is not present\"},\t\t/* map_nodb */\n\t{335545089, \"Global mapping is not available when table RDB$MAP is not present in database {0}\"},\t\t/* map_notable */\n\t{335545090, \"Your attachment has no trusted role\"},\t\t/* miss_trusted_role */\n\t{335545091, \"Role {0} is invalid or unavailable\"},\t\t/* set_invalid_role */\n\t{335545092, \"Cursor {0} is not positioned in a valid record\"},\t\t/* cursor_not_positioned */\n\t{335545093, \"Duplicated user attribute {0}\"},\t\t/* dup_attribute */\n\t{335545094, \"There is no privilege for this operation\"},\t\t/* dyn_no_priv */\n\t{335545095, \"Using GRANT OPTION on {0} not allowed\"},\t\t/* dsql_cant_grant_option */\n\t{335545096, \"read conflicts with concurrent update\"},\t\t/* read_conflict */\n\t{335545097, \"{0} failed when working with CREATE DATABASE grants\"},\t\t/* crdb_load */\n\t{335545098, \"CREATE DATABASE grants check is not possible when database {0} is not present\"},\t\t/* crdb_nodb */\n\t{335545099, \"CREATE DATABASE grants check is not possible when table RDB$DB_CREATORS is not present in database {0}\"},\t\t/* crdb_notable */\n\t{335545100, \"Interface {2} version too old: expected {0}, found {1}\"},\t\t/* interface_version_too_old */\n\t{335545101, \"Input parameter mismatch for function {0}\"},\t\t/* fun_param_mismatch */\n\t{335545102, \"Error during savepoint backout - transaction invalidated\"},\t\t/* savepoint_backout_err */\n\t{335545103, \"Domain used in the PRIMARY KEY constraint of table {0} must be NOT NULL\"},\t\t/* domain_primary_key_notnull */\n\t{335545104, \"CHARACTER SET {0} cannot be used as a attachment character set\"},\t\t/* invalid_attachment_charset */\n\t{335545105, \"Some database(s) were shutdown when trying to read mapping data\"},\t\t/* map_down */\n\t{335545106, \"Error occurred during login, please check server firebird.log for details\"},\t\t/* login_error */\n\t{335545107, \"Database already opened with engine instance, incompatible with current\"},\t\t/* already_opened */\n\t{335545108, \"Invalid crypt key {0}\"},\t\t/* bad_crypt_key */\n\t{335545109, \"Page requires encryption but crypt plugin is missing\"},\t\t/* encrypt_error */\n\t{335545110, \"Maximum index depth ({0} levels) is reached\"},\t\t/* max_idx_depth */\n\t{335545111, \"System privilege {0} does not exist\"},\t\t/* wrong_prvlg */\n\t{335545112, \"System privilege {0} is missing\"},\t\t/* miss_prvlg */\n\t{335545113, \"Invalid or missing checksum of encrypted database\"},\t\t/* crypt_checksum */\n\t{335545114, \"You must have SYSDBA rights at this server\"},\t\t/* not_dba */\n\t{335545115, \"Cannot open cursor for non-SELECT statement\"},\t\t/* no_cursor */\n\t{335545116, \"If <window frame bound 1> specifies {0}, then <window frame bound 2> shall not specify {1}\"},\t\t/* dsql_window_incompat_frames */\n\t{335545117, \"RANGE based window with <expr> {PRECEDING | FOLLOWING} cannot have ORDER BY with more than one value\"},\t\t/* dsql_window_range_multi_key */\n\t{335545118, \"RANGE based window with <offset> PRECEDING/FOLLOWING must have a single ORDER BY key of numerical, date, time or timestamp types\"},\t\t/* dsql_window_range_inv_key_type */\n\t{335545119, \"Window RANGE/ROWS PRECEDING/FOLLOWING value must be of a numerical type\"},\t\t/* dsql_window_frame_value_inv_type */\n\t{335545120, \"Invalid PRECEDING or FOLLOWING offset in window function: cannot be negative\"},\t\t/* window_frame_value_invalid */\n\t{335545121, \"Window {0} not found\"},\t\t/* dsql_window_not_found */\n\t{335545122, \"Cannot use PARTITION BY clause while overriding the window {0}\"},\t\t/* dsql_window_cant_overr_part */\n\t{335545123, \"Cannot use ORDER BY clause while overriding the window {0} which already has an ORDER BY clause\"},\t\t/* dsql_window_cant_overr_order */\n\t{335545124, \"Cannot override the window {0} because it has a frame clause. Tip: it can be used without parenthesis in OVER\"},\t\t/* dsql_window_cant_overr_frame */\n\t{335545125, \"Duplicate window definition for {0}\"},\t\t/* dsql_window_duplicate */\n\t{335545126, \"SQL statement is too long. Maximum size is {0} bytes.\"},\t\t/* sql_too_long */\n\t{335545127, \"Config level timeout expired.\"},\t\t/* cfg_stmt_timeout */\n\t{335545128, \"Attachment level timeout expired.\"},\t\t/* att_stmt_timeout */\n\t{335545129, \"Statement level timeout expired.\"},\t\t/* req_stmt_timeout */\n\t{335545130, \"Killed by database administrator.\"},\t\t/* att_shut_killed */\n\t{335545131, \"Idle timeout expired.\"},\t\t/* att_shut_idle */\n\t{335545132, \"Database is shutdown.\"},\t\t/* att_shut_db_down */\n\t{335545133, \"Engine is shutdown.\"},\t\t/* att_shut_engine */\n\t{335545134, \"OVERRIDING clause can be used only when an identity column is present in the INSERT's field list for table/view {0}\"},\t\t/* overriding_without_identity */\n\t{335545135, \"OVERRIDING SYSTEM VALUE can be used only for identity column defined as 'GENERATED ALWAYS' in INSERT for table/view {0}\"},\t\t/* overriding_system_invalid */\n\t{335545136, \"OVERRIDING USER VALUE can be used only for identity column defined as 'GENERATED BY DEFAULT' in INSERT for table/view {0}\"},\t\t/* overriding_user_invalid */\n\t{335545137, \"OVERRIDING clause should be used when an identity column defined as 'GENERATED ALWAYS' is present in the INSERT's field list for table table/view {0}\"},\t\t/* overriding_missing */\n\t{335545138, \"DecFloat precision must be 16 or 34\"},\t\t/* decprecision_err */\n\t{335545139, \"Decimal float divide by zero.  The code attempted to divide a DECFLOAT value by zero.\"},\t\t/* decfloat_divide_by_zero */\n\t{335545140, \"Decimal float inexact result.  The result of an operation cannot be represented as a decimal fraction.\"},\t\t/* decfloat_inexact_result */\n\t{335545141, \"Decimal float invalid operation.  An indeterminant error occurred during an operation.\"},\t\t/* decfloat_invalid_operation */\n\t{335545142, \"Decimal float overflow.  The exponent of a result is greater than the magnitude allowed.\"},\t\t/* decfloat_overflow */\n\t{335545143, \"Decimal float underflow.  The exponent of a result is less than the magnitude allowed.\"},\t\t/* decfloat_underflow */\n\t{335545144, \"Sub-function {0} has not been defined\"},\t\t/* subfunc_notdef */\n\t{335545145, \"Sub-procedure {0} has not been defined\"},\t\t/* subproc_notdef */\n\t{335545146, \"Sub-function {0} has a signature mismatch with its forward declaration\"},\t\t/* subfunc_signat */\n\t{335545147, \"Sub-procedure {0} has a signature mismatch with its forward declaration\"},\t\t/* subproc_signat */\n\t{335545148, \"Default values for parameters are not allowed in definition of the previously declared sub-function {0}\"},\t\t/* subfunc_defvaldecl */\n\t{335545149, \"Default values for parameters are not allowed in definition of the previously declared sub-procedure {0}\"},\t\t/* subproc_defvaldecl */\n\t{335545150, \"Sub-function {0} was declared but not implemented\"},\t\t/* subfunc_not_impl */\n\t{335545151, \"Sub-procedure {0} was declared but not implemented\"},\t\t/* subproc_not_impl */\n\t{335545152, \"Invalid HASH algorithm {0}\"},\t\t/* sysf_invalid_hash_algorithm */\n\t{335545153, \"Expression evaluation error for index \\\"{0}\\\" on table \\\"{1}\\\"\"},\t\t/* expression_eval_index */\n\t{335545154, \"Invalid decfloat trap state {0}\"},\t\t/* invalid_decfloat_trap */\n\t{335545155, \"Invalid decfloat rounding mode {0}\"},\t\t/* invalid_decfloat_round */\n\t{335545156, \"Invalid part {0} to calculate the {0} of a DATE/TIMESTAMP\"},\t\t/* sysf_invalid_first_last_part */\n\t{335545157, \"Expected DATE/TIMESTAMP value in {0}\"},\t\t/* sysf_invalid_date_timestamp */\n\t{335545158, \"Precision must be from {0} to {1}\"},\t\t/* precision_err2 */\n\t{335545159, \"invalid batch handle\"},\t\t/* bad_batch_handle */\n\t{335545160, \"Bad international character in tag {0}\"},\t\t/* intl_char */\n\t{335545161, \"Null data in parameters block with non-zero length\"},\t\t/* null_block */\n\t{335545162, \"Items working with running service and getting generic server information should not be mixed in single info block\"},\t\t/* mixed_info */\n\t{335545163, \"Unknown information item, code {0}\"},\t\t/* unknown_info */\n\t{335545164, \"Wrong version of blob parameters block {0}, should be {1}\"},\t\t/* bpb_version */\n\t{335545165, \"User management plugin is missing or failed to load\"},\t\t/* user_manager */\n\t{335545166, \"Missing entrypoint {0} in ICU library\"},\t\t/* icu_entrypoint */\n\t{335545167, \"Could not find acceptable ICU library\"},\t\t/* icu_library */\n\t{335545168, \"Name {0} not found in system MetadataBuilder\"},\t\t/* metadata_name */\n\t{335545169, \"Parse to tokens error\"},\t\t/* tokens_parse */\n\t{335545170, \"Error opening international conversion descriptor from {0} to {1}\"},\t\t/* iconv_open */\n\t{335545171, \"Message {0} is out of range, only {1} messages in batch\"},\t\t/* batch_compl_range */\n\t{335545172, \"Detailed error info for message {0} is missing in batch\"},\t\t/* batch_compl_detail */\n\t{335545173, \"Compression stream init error {0}\"},\t\t/* deflate_init */\n\t{335545174, \"Decompression stream init error {0}\"},\t\t/* inflate_init */\n\t{335545175, \"Segment size ({0}) should not exceed 65535 (64K - 1) when using segmented blob\"},\t\t/* big_segment */\n\t{335545176, \"Invalid blob policy in the batch for {0}() call\"},\t\t/* batch_policy */\n\t{335545177, \"Can't change default BPB after adding any data to batch\"},\t\t/* batch_defbpb */\n\t{335545178, \"Unexpected info buffer structure querying for server batch parameters\"},\t\t/* batch_align */\n\t{335545179, \"Duplicated segment {0} in multisegment connect block parameter\"},\t\t/* multi_segment_dup */\n\t{335545180, \"Plugin not supported by network protocol\"},\t\t/* non_plugin_protocol */\n\t{335545181, \"Error parsing message format\"},\t\t/* message_format */\n\t{335545182, \"Wrong version of batch parameters block {0}, should be {1}\"},\t\t/* batch_param_version */\n\t{335545183, \"Message size ({0}) in batch exceeds internal buffer size ({1})\"},\t\t/* batch_msg_long */\n\t{335545184, \"Batch already opened for this statement\"},\t\t/* batch_open */\n\t{335545185, \"Invalid type of statement used in batch\"},\t\t/* batch_type */\n\t{335545186, \"Statement used in batch must have parameters\"},\t\t/* batch_param */\n\t{335545187, \"There are no blobs in associated with batch statement\"},\t\t/* batch_blobs */\n\t{335545188, \"appendBlobData() is used to append data to last blob but no such blob was added to the batch\"},\t\t/* batch_blob_append */\n\t{335545189, \"Portions of data, passed as blob stream, should have size multiple to the alignment required for blobs\"},\t\t/* batch_stream_align */\n\t{335545190, \"Repeated blob id {0} in registerBlob()\"},\t\t/* batch_rpt_blob */\n\t{335545191, \"Blob buffer format error\"},\t\t/* batch_blob_buf */\n\t{335545192, \"Unusable (too small) data remained in {0} buffer\"},\t\t/* batch_small_data */\n\t{335545193, \"Blob continuation should not contain BPB\"},\t\t/* batch_cont_bpb */\n\t{335545194, \"Size of BPB ({0}) greater than remaining data ({1})\"},\t\t/* batch_big_bpb */\n\t{335545195, \"Size of segment ({0}) greater than current BLOB data ({1})\"},\t\t/* batch_big_segment */\n\t{335545196, \"Size of segment ({0}) greater than available data ({1})\"},\t\t/* batch_big_seg2 */\n\t{335545197, \"Unknown blob ID {0} in the batch message\"},\t\t/* batch_blob_id */\n\t{335545198, \"Internal buffer overflow - batch too big\"},\t\t/* batch_too_big */\n\t{335545199, \"Numeric literal too long\"},\t\t/* num_literal */\n\t{335545200, \"Error using events in mapping shared memory: {0}\"},\t\t/* map_event */\n\t{335545201, \"Global mapping memory overflow\"},\t\t/* map_overflow */\n\t{335545202, \"Header page overflow - too many clumplets on it\"},\t\t/* hdr_overflow */\n\t{335545203, \"No matching client/server authentication plugins configured for execute statement in embedded datasource\"},\t\t/* vld_plugins */\n\t{335545204, \"Missing database encryption key for your attachment\"},\t\t/* db_crypt_key */\n\t{335545205, \"Key holder plugin {0} failed to load\"},\t\t/* no_keyholder_plugin */\n\t{335545206, \"Cannot reset user session\"},\t\t/* ses_reset_err */\n\t{335545207, \"There are open transactions ({0} active)\"},\t\t/* ses_reset_open_trans */\n\t{335545208, \"Session was reset with warning(s)\"},\t\t/* ses_reset_warn */\n\t{335545209, \"Transaction is rolled back due to session reset, all changes are lost\"},\t\t/* ses_reset_tran_rollback */\n\t{335545210, \"Plugin {0}:\"},\t\t/* plugin_name */\n\t{335545211, \"PARAMETER {0}\"},\t\t/* parameter_name */\n\t{335545212, \"Starting page number for file {0} must be {1} or greater\"},\t\t/* file_starting_page_err */\n\t{335545213, \"Invalid time zone offset: {0} - must use format +/-hours:minutes and be between -14:00 and +14:00\"},\t\t/* invalid_timezone_offset */\n\t{335545214, \"Invalid time zone region: {0}\"},\t\t/* invalid_timezone_region */\n\t{335545215, \"Invalid time zone ID: {0}\"},\t\t/* invalid_timezone_id */\n\t{335545216, \"Wrong base64 text length {0}, should be multiple of 4\"},\t\t/* tom_decode64len */\n\t{335545217, \"Invalid first parameter datatype - need string or blob\"},\t\t/* tom_strblob */\n\t{335545218, \"Error registering {0} - probably bad tomcrypt library\"},\t\t/* tom_reg */\n\t{335545219, \"Unknown crypt algorithm {0} in USING clause\"},\t\t/* tom_algorithm */\n\t{335545220, \"Should specify mode parameter for symmetric cipher\"},\t\t/* tom_mode_miss */\n\t{335545221, \"Unknown symmetric crypt mode specified\"},\t\t/* tom_mode_bad */\n\t{335545222, \"Mode parameter makes no sense for chosen cipher\"},\t\t/* tom_no_mode */\n\t{335545223, \"Should specify initialization vector (IV) for chosen cipher and/or mode\"},\t\t/* tom_iv_miss */\n\t{335545224, \"Initialization vector (IV) makes no sense for chosen cipher and/or mode\"},\t\t/* tom_no_iv */\n\t{335545225, \"Invalid counter endianess {0}\"},\t\t/* tom_ctrtype_bad */\n\t{335545226, \"Counter endianess parameter is not used in mode {0}\"},\t\t/* tom_no_ctrtype */\n\t{335545227, \"Too big counter value {0}, maximum {1} can be used\"},\t\t/* tom_ctr_big */\n\t{335545228, \"Counter length/value parameter is not used with {0} {1}\"},\t\t/* tom_no_ctr */\n\t{335545229, \"Invalid initialization vector (IV) length {0}, need {1}\"},\t\t/* tom_iv_length */\n\t{335545230, \"TomCrypt library error: {0}\"},\t\t/* tom_error */\n\t{335545231, \"Starting PRNG yarrow\"},\t\t/* tom_yarrow_start */\n\t{335545232, \"Setting up PRNG yarrow\"},\t\t/* tom_yarrow_setup */\n\t{335545233, \"Initializing {0} mode\"},\t\t/* tom_init_mode */\n\t{335545234, \"Encrypting in {0} mode\"},\t\t/* tom_crypt_mode */\n\t{335545235, \"Decrypting in {0} mode\"},\t\t/* tom_decrypt_mode */\n\t{335545236, \"Initializing cipher {0}\"},\t\t/* tom_init_cip */\n\t{335545237, \"Encrypting using cipher {0}\"},\t\t/* tom_crypt_cip */\n\t{335545238, \"Decrypting using cipher {0}\"},\t\t/* tom_decrypt_cip */\n\t{335545239, \"Setting initialization vector (IV) for {0}\"},\t\t/* tom_setup_cip */\n\t{335545240, \"Invalid initialization vector (IV) length {0}, need  8 or 12\"},\t\t/* tom_setup_chacha */\n\t{335545241, \"Encoding {0}\"},\t\t/* tom_encode */\n\t{335545242, \"Decoding {0}\"},\t\t/* tom_decode */\n\t{335545243, \"Importing RSA key\"},\t\t/* tom_rsa_import */\n\t{335545244, \"Invalid OAEP packet\"},\t\t/* tom_oaep */\n\t{335545245, \"Unknown hash algorithm {0}\"},\t\t/* tom_hash_bad */\n\t{335545246, \"Making RSA key\"},\t\t/* tom_rsa_make */\n\t{335545247, \"Exporting {0} RSA key\"},\t\t/* tom_rsa_export */\n\t{335545248, \"RSA-signing data\"},\t\t/* tom_rsa_sign */\n\t{335545249, \"Verifying RSA-signed data\"},\t\t/* tom_rsa_verify */\n\t{335545250, \"Invalid key length {0}, need 16 or 32\"},\t\t/* tom_chacha_key */\n\t{335545251, \"invalid replicator handle\"},\t\t/* bad_repl_handle */\n\t{335545252, \"Transaction's base snapshot number does not exist\"},\t\t/* tra_snapshot_does_not_exist */\n\t{335545253, \"Input parameter '{0}' is not used in SQL query text\"},\t\t/* eds_input_prm_not_used */\n\t{335545254, \"Effective user is {0}\"},\t\t/* effective_user */\n\t{335545255, \"Invalid time zone bind mode {0}\"},\t\t/* invalid_time_zone_bind */\n\t{335545256, \"Invalid decfloat bind mode {0}\"},\t\t/* invalid_decfloat_bind */\n\t{335545257, \"Invalid hex text length {0}, should be multiple of 2\"},\t\t/* odd_hex_len */\n\t{335545258, \"Invalid hex digit {0} at position {1}\"},\t\t/* invalid_hex_digit */\n\t{335545259, \"Error processing isc_dpb_set_bind clumplet \\\"{0}\\\"\"},\t\t/* bind_err */\n\t{335545260, \"The following statement failed: {0}\"},\t\t/* bind_statement */\n\t{335545261, \"Can not convert {0} to {1}\"},\t\t/* bind_convert */\n\t{335545262, \"cannot update old BLOB\"},\t\t/* cannot_update_old_blob */\n\t{335545263, \"cannot read from new BLOB\"},\t\t/* cannot_read_new_blob */\n\t{335545264, \"No permission for CREATE {0} operation\"},\t\t/* dyn_no_create_priv */\n\t{335545265, \"SUSPEND could not be used without RETURNS clause in PROCEDURE or EXECUTE BLOCK\"},\t\t/* suspend_without_returns */\n\t{335545266, \"String truncated warning due to the following reason\"},\t\t/* truncate_warn */\n\t{335545267, \"Monitoring data does not fit into the field\"},\t\t/* truncate_monitor */\n\t{335545268, \"Engine data does not fit into return value of system function\"},\t\t/* truncate_context */\n\t{335545269, \"Multiple source records cannot match the same target during MERGE\"},\t\t/* merge_dup_update */\n\t{335545270, \"RDB$PAGES written by non-system transaction, DB appears to be damaged\"},\t\t/* wrong_page */\n\t{335545271, \"Replication error\"},\t\t/* repl_error */\n\t{335545272, \"Reset of user session failed. Connection is shut down.\"},\t\t/* ses_reset_failed */\n\t{335545273, \"File size is less than expected\"},\t\t/* block_size */\n\t{335545274, \"Invalid key length {0}, need >{1}\"},\t\t/* tom_key_length */\n\t{335545275, \"Invalid information arguments\"},\t\t/* inf_invalid_args */\n\t{335545276, \"Empty or NULL parameter {0} is not accepted\"},\t\t/* sysf_invalid_null_empty */\n\t{335545277, \"Undefined local table number {0}\"},\t\t/* bad_loctab_num */\n\t{335545278, \"Invalid text <{0}> after quoted string\"},\t\t/* quoted_str_bad */\n\t{335545279, \"Missing terminating quote <{0}> in the end of quoted string\"},\t\t/* quoted_str_miss */\n\t{335545280, \"{0}: inconsistent shared memory type/version; found {1}, expected {2}\"},\t\t/* wrong_shmem_ver */\n\t{335545281, \"{0}-bit engine can't open database already opened by {1}-bit engine\"},\t\t/* wrong_shmem_bitness */\n\t{335545282, \"Procedures cannot specify access type other than NATURAL in the plan\"},\t\t/* wrong_proc_plan */\n\t{335545283, \"Invalid RDB$BLOB_UTIL handle\"},\t\t/* invalid_blob_util_handle */\n\t{335545284, \"Invalid temporary BLOB ID\"},\t\t/* bad_temp_blob_id */\n\t{335545285, \"ODS upgrade failed while adding new system {0}\"},\t\t/* ods_upgrade_err */\n\t{335545286, \"Wrong parallel workers value {0}, valid range are from 1 to {1}\"},\t\t/* bad_par_workers */\n\t{335545287, \"Definition of index expression is not found for index {0}\"},\t\t/* idx_expr_not_found */\n\t{335545288, \"Definition of index condition is not found for index {0}\"},\t\t/* idx_cond_not_found */\n\t{335740929, \"data base file name ({0}) already given\"},\t\t/* gfix_db_name */\n\t{335740930, \"invalid switch {0}\"},\t\t/* gfix_invalid_sw */\n\t{335740931, \"gfix version {0}\"},\t\t/* gfix_version */\n\t{335740932, \"incompatible switch combination\"},\t\t/* gfix_incmp_sw */\n\t{335740933, \"replay log pathname required\"},\t\t/* gfix_replay_req */\n\t{335740934, \"number of page buffers for cache required\"},\t\t/* gfix_pgbuf_req */\n\t{335740935, \"numeric value required\"},\t\t/* gfix_val_req */\n\t{335740936, \"positive numeric value required\"},\t\t/* gfix_pval_req */\n\t{335740937, \"number of transactions per sweep required\"},\t\t/* gfix_trn_req */\n\t{335740938, \"transaction number or \\\"all\\\" required\"},\t\t/* gfix_trn_all_req */\n\t{335740939, \"\\\"sync\\\" or \\\"async\\\" required\"},\t\t/* gfix_sync_req */\n\t{335740940, \"\\\"full\\\" or \\\"reserve\\\" required\"},\t\t/* gfix_full_req */\n\t{335740941, \"user name required\"},\t\t/* gfix_usrname_req */\n\t{335740942, \"password required\"},\t\t/* gfix_pass_req */\n\t{335740943, \"subsystem name\"},\t\t/* gfix_subs_name */\n\t{335740944, \"\\\"wal\\\" required\"},\t\t/* gfix_wal_req */\n\t{335740945, \"number of seconds required\"},\t\t/* gfix_sec_req */\n\t{335740946, \"numeric value between 0 and 32767 inclusive required\"},\t\t/* gfix_nval_req */\n\t{335740947, \"must specify type of shutdown\"},\t\t/* gfix_type_shut */\n\t{335740948, \"please retry, specifying an option\"},\t\t/* gfix_retry */\n\t{335740949, \"plausible options are:\"},\t\t/* gfix_opt */\n\t{335740950, \"\\\\n    Options can be abbreviated to the unparenthesized characters\"},\t\t/* gfix_qualifiers */\n\t{335740951, \"please retry, giving a database name\"},\t\t/* gfix_retry_db */\n\t{335740952, \"Summary of validation errors\"},\t\t/* gfix_summary */\n\t{335740953, \"   -ac(tivate_shadow)   activate shadow file for database usage\"},\t\t/* gfix_opt_active */\n\t{335740954, \"   -at(tach)            shutdown new database attachments\"},\t\t/* gfix_opt_attach */\n\t{335740955, \"\\t-begin_log\\tbegin logging for replay utility\"},\t\t/* gfix_opt_begin_log */\n\t{335740956, \"   -b(uffers)           set page buffers <n>\"},\t\t/* gfix_opt_buffers */\n\t{335740957, \"   -co(mmit)            commit transaction <tr / all>\"},\t\t/* gfix_opt_commit */\n\t{335740958, \"   -ca(che)             shutdown cache manager\"},\t\t/* gfix_opt_cache */\n\t{335740959, \"\\t-disable\\tdisable WAL\"},\t\t/* gfix_opt_disable */\n\t{335740960, \"   -fu(ll)              validate record fragments (-v)\"},\t\t/* gfix_opt_full */\n\t{335740961, \"   -fo(rce_shutdown)    force database shutdown\"},\t\t/* gfix_opt_force */\n\t{335740962, \"   -h(ousekeeping)      set sweep interval <n>\"},\t\t/* gfix_opt_housekeep */\n\t{335740963, \"   -i(gnore)            ignore checksum errors\"},\t\t/* gfix_opt_ignore */\n\t{335740964, \"   -k(ill_shadow)       kill all unavailable shadow files\"},\t\t/* gfix_opt_kill */\n\t{335740965, \"   -l(ist)              show limbo transactions\"},\t\t/* gfix_opt_list */\n\t{335740966, \"   -me(nd)              prepare corrupt database for backup\"},\t\t/* gfix_opt_mend */\n\t{335740967, \"   -n(o_update)         read-only validation (-v)\"},\t\t/* gfix_opt_no_update */\n\t{335740968, \"   -o(nline)            database online <single / multi / normal>\"},\t\t/* gfix_opt_online */\n\t{335740969, \"   -pr(ompt)            prompt for commit/rollback (-l)\"},\t\t/* gfix_opt_prompt */\n\t{335740970, \"   -pa(ssword)          default password\"},\t\t/* gfix_opt_password */\n\t{335740971, \"\\t-quit_log\\tquit logging for replay utility\"},\t\t/* gfix_opt_quit_log */\n\t{335740972, \"   -r(ollback)          rollback transaction <tr / all>\"},\t\t/* gfix_opt_rollback */\n\t{335740973, \"   -sw(eep)             force garbage collection\"},\t\t/* gfix_opt_sweep */\n\t{335740974, \"   -sh(utdown)          shutdown <full / single / multi>\"},\t\t/* gfix_opt_shut */\n\t{335740975, \"   -tw(o_phase)         perform automated two-phase recovery\"},\t\t/* gfix_opt_two_phase */\n\t{335740976, \"   -tra(nsaction)       shutdown transaction startup\"},\t\t/* gfix_opt_tran */\n\t{335740977, \"   -u(se)               use full or reserve space for versions\"},\t\t/* gfix_opt_use */\n\t{335740978, \"   -user                default user name\"},\t\t/* gfix_opt_user */\n\t{335740979, \"   -v(alidate)          validate database structure\"},\t\t/* gfix_opt_validate */\n\t{335740980, \"   -w(rite)             write synchronously or asynchronously\"},\t\t/* gfix_opt_write */\n\t{335740981, \"   -x                   set debug on\"},\t\t/* gfix_opt_x */\n\t{335740982, \"   -z                   print software version number\"},\t\t/* gfix_opt_z */\n\t{335740983, \"\\\\n\\tNumber of record level errors\\t: {0}\"},\t\t/* gfix_rec_err */\n\t{335740984, \"\\tNumber of Blob page errors\\t: {0}\"},\t\t/* gfix_blob_err */\n\t{335740985, \"\\tNumber of data page errors\\t: {0}\"},\t\t/* gfix_data_err */\n\t{335740986, \"\\tNumber of index page errors\\t: {0}\"},\t\t/* gfix_index_err */\n\t{335740987, \"\\tNumber of pointer page errors\\t: {0}\"},\t\t/* gfix_pointer_err */\n\t{335740988, \"\\tNumber of transaction page errors\\t: {0}\"},\t\t/* gfix_trn_err */\n\t{335740989, \"\\tNumber of database page errors\\t: {0}\"},\t\t/* gfix_db_err */\n\t{335740990, \"bad block type\"},\t\t/* gfix_bad_block */\n\t{335740991, \"internal block exceeds maximum size\"},\t\t/* gfix_exceed_max */\n\t{335740992, \"corrupt pool\"},\t\t/* gfix_corrupt_pool */\n\t{335740993, \"virtual memory exhausted\"},\t\t/* gfix_mem_exhausted */\n\t{335740994, \"bad pool id\"},\t\t/* gfix_bad_pool */\n\t{335740995, \"Transaction state {0} not in valid range.\"},\t\t/* gfix_trn_not_valid */\n\t{335740996, \"ATTACH_DATABASE: attempted attach of {0},\"},\t\t/* gfix_dbg_attach */\n\t{335740997, \" failed\"},\t\t/* gfix_dbg_failed */\n\t{335740998, \" succeeded\"},\t\t/* gfix_dbg_success */\n\t{335740999, \"Transaction {0} is in limbo.\"},\t\t/* gfix_trn_limbo */\n\t{335741000, \"More limbo transactions than fit.  Try again\"},\t\t/* gfix_try_again */\n\t{335741001, \"Unrecognized info item {0}\"},\t\t/* gfix_unrec_item */\n\t{335741002, \"A commit of transaction {0} will violate two-phase commit.\"},\t\t/* gfix_commit_violate */\n\t{335741003, \"A rollback of transaction {0} is needed to preserve two-phase commit.\"},\t\t/* gfix_preserve */\n\t{335741004, \"Transaction {0} has already been partially committed.\"},\t\t/* gfix_part_commit */\n\t{335741005, \"A rollback of this transaction will violate two-phase commit.\"},\t\t/* gfix_rback_violate */\n\t{335741006, \"Transaction {0} has been partially committed.\"},\t\t/* gfix_part_commit2 */\n\t{335741007, \"A commit is necessary to preserve the two-phase commit.\"},\t\t/* gfix_commit_pres */\n\t{335741008, \"Insufficient information is available to determine\"},\t\t/* gfix_insuff_info */\n\t{335741009, \"a proper action for transaction {0}.\"},\t\t/* gfix_action */\n\t{335741010, \"Transaction {0}: All subtransactions have been prepared.\"},\t\t/* gfix_all_prep */\n\t{335741011, \"Either commit or rollback is possible.\"},\t\t/* gfix_comm_rback */\n\t{335741012, \"unexpected end of input\"},\t\t/* gfix_unexp_eoi */\n\t{335741013, \"Commit, rollback, or neither (c, r, or n)?\"},\t\t/* gfix_ask */\n\t{335741014, \"Could not reattach to database for transaction {0}.\"},\t\t/* gfix_reattach_failed */\n\t{335741015, \"Original path: {0}\"},\t\t/* gfix_org_path */\n\t{335741016, \"Enter a valid path:\"},\t\t/* gfix_enter_path */\n\t{335741017, \"Attach unsuccessful.\"},\t\t/* gfix_att_unsucc */\n\t{335741018, \"failed to reconnect to a transaction in database {0}\"},\t\t/* gfix_recon_fail */\n\t{335741019, \"Transaction {0}:\"},\t\t/* gfix_trn2 */\n\t{335741020, \"  Multidatabase transaction:\"},\t\t/* gfix_mdb_trn */\n\t{335741021, \"    Host Site: {0}\"},\t\t/* gfix_host_site */\n\t{335741022, \"    Transaction {0}\"},\t\t/* gfix_trn */\n\t{335741023, \"has been prepared.\"},\t\t/* gfix_prepared */\n\t{335741024, \"has been committed.\"},\t\t/* gfix_committed */\n\t{335741025, \"has been rolled back.\"},\t\t/* gfix_rolled_back */\n\t{335741026, \"is not available.\"},\t\t/* gfix_not_available */\n\t{335741027, \"is not found, assumed not prepared.\"},\t\t/* gfix_not_prepared */\n\t{335741028, \"is not found, assumed to be committed.\"},\t\t/* gfix_be_committed */\n\t{335741029, \"        Remote Site: {0}\"},\t\t/* gfix_rmt_site */\n\t{335741030, \"        Database Path: {0}\"},\t\t/* gfix_db_path */\n\t{335741031, \"  Automated recovery would commit this transaction.\"},\t\t/* gfix_auto_comm */\n\t{335741032, \"  Automated recovery would rollback this transaction.\"},\t\t/* gfix_auto_rback */\n\t{335741033, \"Warning: Multidatabase transaction is in inconsistent state for recovery.\"},\t\t/* gfix_warning */\n\t{335741034, \"Transaction {0} was committed, but prior ones were rolled back.\"},\t\t/* gfix_trn_was_comm */\n\t{335741035, \"Transaction {0} was rolled back, but prior ones were committed.\"},\t\t/* gfix_trn_was_rback */\n\t{335741036, \"Transaction description item unknown\"},\t\t/* gfix_trn_unknown */\n\t{335741037, \"   -mo(de)              read_only or read_write database\"},\t\t/* gfix_opt_mode */\n\t{335741038, \"\\\"read_only\\\" or \\\"read_write\\\" required\"},\t\t/* gfix_mode_req */\n\t{335741039, \"   -sq(l_dialect)       set database dialect n\"},\t\t/* gfix_opt_SQL_dialect */\n\t{335741040, \"database SQL dialect must be one of '{0}'\"},\t\t/* gfix_SQL_dialect */\n\t{335741041, \"dialect number required\"},\t\t/* gfix_dialect_req */\n\t{335741042, \"positive or zero numeric value required\"},\t\t/* gfix_pzval_req */\n\t{335741043, \"   -tru(sted)           use trusted authentication\"},\t\t/* gfix_opt_trusted */\n\t{335741044, \"could not open password file {0}, errno {1}\"},\n\t{335741045, \"could not read password file {0}, errno {1}\"},\n\t{335741046, \"empty password file {0}\"},\n\t{335741047, \"   -fe(tch_password)    fetch password from file\"},\n\t{335741048, \"usage: gfix [options] <database>\"},\n\t{335741049, \"   -nol(inger)          close database ignoring linger setting for it\"},\t\t/* gfix_opt_nolinger */\n\t{335741050, \"\\tNumber of inventory page errors\\t: {0}\"},\t\t/* gfix_pip_err */\n\t{335741051, \"\\tNumber of record level warnings\\t: {0}\"},\t\t/* gfix_rec_warn */\n\t{335741052, \"\\tNumber of blob page warnings\\t: {0}\"},\t\t/* gfix_blob_warn */\n\t{335741053, \"\\tNumber of data page warnings\\t: {0}\"},\t\t/* gfix_data_warn */\n\t{335741054, \"\\tNumber of index page warnings\\t: {0}\"},\t\t/* gfix_index_warn */\n\t{335741055, \"\\tNumber of pointer page warnings\\t: {0}\"},\t\t/* gfix_pointer_warn */\n\t{335741056, \"\\tNumber of transaction page warnings\\t: {0}\"},\t\t/* gfix_trn_warn */\n\t{335741057, \"\\tNumber of database page warnings\\t: {0}\"},\t\t/* gfix_db_warn */\n\t{335741058, \"\\tNumber of inventory page warnings\\t: {0}\"},\t\t/* gfix_pip_warn */\n\t{335741059, \"   -icu                 fix database to be usable with present ICU version\"},\t\t/* gfix_opt_icu */\n\t{335741060, \"   -role                set SQL role name\"},\t\t/* gfix_opt_role */\n\t{335741061, \"SQL role name required\"},\t\t/* gfix_role_req */\n\t{335741062, \"   -repl(ica)           replica mode <none / read_only / read_write>\"},\t\t/* gfix_opt_repl */\n\t{335741063, \"replica mode (none / read_only / read_write) required\"},\t\t/* gfix_repl_mode_req */\n\t{335741064, \"   -par(allel)          parallel workers <n> (-sweep, -icu)\"},\t\t/* gfix_opt_parallel */\n\t{335741065, \"   -up(grade)           upgrade database ODS\"},\t\t/* gfix_opt_upgrade */\n\t{336003074, \"Cannot SELECT RDB$DB_KEY from a stored procedure.\"},\t\t/* dsql_dbkey_from_non_table */\n\t{336003075, \"Precision 10 to 18 changed from DOUBLE PRECISION in SQL dialect 1 to 64-bit scaled integer in SQL dialect 3\"},\t\t/* dsql_transitional_numeric */\n\t{336003076, \"Use of {0} expression that returns different results in dialect 1 and dialect 3\"},\t\t/* dsql_dialect_warning_expr */\n\t{336003077, \"Database SQL dialect {0} does not support reference to {1} datatype\"},\t\t/* sql_db_dialect_dtype_unsupport */\n\t{336003078, \"\"},\n\t{336003079, \"DB dialect {0} and client dialect {1} conflict with respect to numeric precision {2}.\"},\t\t/* sql_dialect_conflict_num */\n\t{336003080, \"WARNING: Numeric literal {0} is interpreted as a floating-point\"},\t\t/* dsql_warning_number_ambiguous */\n\t{336003081, \"value in SQL dialect 1, but as an exact numeric value in SQL dialect 3.\"},\t\t/* dsql_warning_number_ambiguous1 */\n\t{336003082, \"WARNING: NUMERIC and DECIMAL fields with precision 10 or greater are stored\"},\t\t/* dsql_warn_precision_ambiguous */\n\t{336003083, \"as approximate floating-point values in SQL dialect 1, but as 64-bit\"},\t\t/* dsql_warn_precision_ambiguous1 */\n\t{336003084, \"integers in SQL dialect 3.\"},\t\t/* dsql_warn_precision_ambiguous2 */\n\t{336003085, \"Ambiguous field name between {0} and {1}\"},\t\t/* dsql_ambiguous_field_name */\n\t{336003086, \"External function should have return position between 1 and {0}\"},\t\t/* dsql_udf_return_pos_err */\n\t{336003087, \"Label {0} {1} in the current scope\"},\t\t/* dsql_invalid_label */\n\t{336003088, \"Datatypes {0}are not comparable in expression {1}\"},\t\t/* dsql_datatypes_not_comparable */\n\t{336003089, \"Empty cursor name is not allowed\"},\t\t/* dsql_cursor_invalid */\n\t{336003090, \"Statement already has a cursor {0} assigned\"},\t\t/* dsql_cursor_redefined */\n\t{336003091, \"Cursor {0} is not found in the current context\"},\t\t/* dsql_cursor_not_found */\n\t{336003092, \"Cursor {0} already exists in the current context\"},\t\t/* dsql_cursor_exists */\n\t{336003093, \"Relation {0} is ambiguous in cursor {1}\"},\t\t/* dsql_cursor_rel_ambiguous */\n\t{336003094, \"Relation {0} is not found in cursor {1}\"},\t\t/* dsql_cursor_rel_not_found */\n\t{336003095, \"Cursor is not open\"},\t\t/* dsql_cursor_not_open */\n\t{336003096, \"Data type {0} is not supported for EXTERNAL TABLES. Relation '{1}', field '{2}'\"},\t\t/* dsql_type_not_supp_ext_tab */\n\t{336003097, \"Feature not supported on ODS version older than {0}.{1}\"},\t\t/* dsql_feature_not_supported_ods */\n\t{336003098, \"Primary key required on table {0}\"},\t\t/* primary_key_required */\n\t{336003099, \"UPDATE OR INSERT field list does not match primary key of table {0}\"},\t\t/* upd_ins_doesnt_match_pk */\n\t{336003100, \"UPDATE OR INSERT field list does not match MATCHING clause\"},\t\t/* upd_ins_doesnt_match_matching */\n\t{336003101, \"UPDATE OR INSERT without MATCHING could not be used with views based on more than one table\"},\t\t/* upd_ins_with_complex_view */\n\t{336003102, \"Incompatible trigger type\"},\t\t/* dsql_incompatible_trigger_type */\n\t{336003103, \"Database trigger type can't be changed\"},\t\t/* dsql_db_trigger_type_cant_change */\n\t{336003104, \"To be used with RDB$RECORD_VERSION, {0} must be a table or a view of single table\"},\t\t/* dsql_record_version_table */\n\t{336003105, \"SQLDA version expected between {0} and {1}, found {2}\"},\t\t/* dsql_invalid_sqlda_version */\n\t{336003106, \"at SQLVAR index {0}\"},\t\t/* dsql_sqlvar_index */\n\t{336003107, \"empty pointer to NULL indicator variable\"},\t\t/* dsql_no_sqlind */\n\t{336003108, \"empty pointer to data\"},\t\t/* dsql_no_sqldata */\n\t{336003109, \"No SQLDA for input values provided\"},\t\t/* dsql_no_input_sqlda */\n\t{336003110, \"No SQLDA for output values provided\"},\t\t/* dsql_no_output_sqlda */\n\t{336003111, \"Wrong number of parameters (expected {0}, got {1})\"},\t\t/* dsql_wrong_param_num */\n\t{336003112, \"Invalid DROP SQL SECURITY clause\"},\t\t/* dsql_invalid_drop_ss_clause */\n\t{336003113, \"UPDATE OR INSERT value for field {0}, part of the implicit or explicit MATCHING clause, cannot be DEFAULT\"},\t\t/* upd_ins_cannot_default */\n\t{336068609, \"ODS version not supported by DYN\"},\n\t{336068610, \"unsupported DYN verb\"},\n\t{336068611, \"STORE RDB$FIELD_DIMENSIONS failed\"},\n\t{336068612, \"unsupported DYN verb\"},\n\t{336068613, \"{0}\"},\n\t{336068614, \"unsupported DYN verb\"},\n\t{336068615, \"DEFINE BLOB FILTER failed\"},\n\t{336068616, \"DEFINE GENERATOR failed\"},\n\t{336068617, \"DEFINE GENERATOR unexpected DYN verb\"},\n\t{336068618, \"DEFINE FUNCTION failed\"},\n\t{336068619, \"unsupported DYN verb\"},\n\t{336068620, \"DEFINE FUNCTION ARGUMENT failed\"},\n\t{336068621, \"STORE RDB$FIELDS failed\"},\n\t{336068622, \"No table specified for index\"},\n\t{336068623, \"STORE RDB$INDEX_SEGMENTS failed\"},\n\t{336068624, \"unsupported DYN verb\"},\n\t{336068625, \"PRIMARY KEY column lookup failed\"},\n\t{336068626, \"could not find UNIQUE or PRIMARY KEY constraint in table {0} with specified columns\"},\n\t{336068627, \"PRIMARY KEY lookup failed\"},\n\t{336068628, \"could not find PRIMARY KEY index in specified table {0}\"},\n\t{336068629, \"STORE RDB$INDICES failed\"},\n\t{336068630, \"STORE RDB$FIELDS failed\"},\n\t{336068631, \"STORE RDB$RELATION_FIELDS failed\"},\n\t{336068632, \"STORE RDB$RELATIONS failed\"},\n\t{336068633, \"STORE RDB$USER_PRIVILEGES failed defining a table\"},\n\t{336068634, \"unsupported DYN verb\"},\n\t{336068635, \"STORE RDB$RELATIONS failed\"},\n\t{336068636, \"STORE RDB$FIELDS failed\"},\n\t{336068637, \"STORE RDB$RELATION_FIELDS failed\"},\n\t{336068638, \"unsupported DYN verb\"},\n\t{336068639, \"DEFINE TRIGGER failed\"},\n\t{336068640, \"unsupported DYN verb\"},\n\t{336068641, \"DEFINE TRIGGER MESSAGE failed\"},\n\t{336068642, \"STORE RDB$VIEW_RELATIONS failed\"},\n\t{336068643, \"ERASE RDB$FIELDS failed\"},\n\t{336068644, \"ERASE BLOB FILTER failed\"},\n\t{336068645, \"BLOB Filter {0} not found\"},\t\t/* dyn_filter_not_found */\n\t{336068646, \"unsupported DYN verb\"},\n\t{336068647, \"ERASE RDB$FUNCTION_ARGUMENTS failed\"},\n\t{336068648, \"ERASE RDB$FUNCTIONS failed\"},\n\t{336068649, \"Function {0} not found\"},\t\t/* dyn_func_not_found */\n\t{336068650, \"unsupported DYN verb\"},\n\t{336068651, \"Domain {0} is used in table {1} (local name {2}) and cannot be dropped\"},\n\t{336068652, \"ERASE RDB$FIELDS failed\"},\n\t{336068653, \"ERASE RDB$FIELDS failed\"},\n\t{336068654, \"Column not found\"},\n\t{336068655, \"ERASE RDB$INDICES failed\"},\n\t{336068656, \"Index not found\"},\t\t/* dyn_index_not_found */\n\t{336068657, \"ERASE RDB$INDEX_SEGMENTS failed\"},\n\t{336068658, \"No segments found for index\"},\n\t{336068659, \"No table specified in ERASE RFR\"},\n\t{336068660, \"Column {0} from table {1} is referenced in view {2}\"},\n\t{336068661, \"ERASE RDB$RELATION_FIELDS failed\"},\n\t{336068662, \"View {0} not found\"},\t\t/* dyn_view_not_found */\n\t{336068663, \"Column not found for table\"},\n\t{336068664, \"ERASE RDB$INDEX_SEGMENTS failed\"},\n\t{336068665, \"ERASE RDB$INDICES failed\"},\n\t{336068666, \"ERASE RDB$RELATION_FIELDS failed\"},\n\t{336068667, \"ERASE RDB$VIEW_RELATIONS failed\"},\n\t{336068668, \"ERASE RDB$RELATIONS failed\"},\n\t{336068669, \"Table not found\"},\n\t{336068670, \"ERASE RDB$USER_PRIVILEGES failed\"},\n\t{336068671, \"ERASE RDB$FILES failed\"},\n\t{336068672, \"unsupported DYN verb\"},\n\t{336068673, \"ERASE RDB$TRIGGER_MESSAGES failed\"},\n\t{336068674, \"ERASE RDB$TRIGGERS failed\"},\n\t{336068675, \"Trigger not found\"},\n\t{336068676, \"MODIFY RDB$VIEW_RELATIONS failed\"},\n\t{336068677, \"unsupported DYN verb\"},\n\t{336068678, \"TRIGGER NAME expected\"},\n\t{336068679, \"ERASE TRIGGER MESSAGE failed\"},\n\t{336068680, \"Trigger Message not found\"},\n\t{336068681, \"unsupported DYN verb\"},\n\t{336068682, \"ERASE RDB$SECURITY_CLASSES failed\"},\n\t{336068683, \"Security class not found\"},\n\t{336068684, \"unsupported DYN verb\"},\n\t{336068685, \"SELECT RDB$USER_PRIVILEGES failed in grant\"},\n\t{336068686, \"SELECT RDB$USER_PRIVILEGES failed in grant\"},\n\t{336068687, \"STORE RDB$USER_PRIVILEGES failed in grant\"},\n\t{336068688, \"Specified domain or source column does not exist\"},\n\t{336068689, \"Generation of column name failed\"},\n\t{336068690, \"Generation of index name failed\"},\n\t{336068691, \"Generation of trigger name failed\"},\n\t{336068692, \"MODIFY DATABASE failed\"},\n\t{336068693, \"MODIFY RDB$CHARACTER_SETS failed\"},\n\t{336068694, \"MODIFY RDB$COLLATIONS failed\"},\n\t{336068695, \"MODIFY RDB$FIELDS failed\"},\n\t{336068696, \"MODIFY RDB$BLOB_FILTERS failed\"},\n\t{336068697, \"Domain not found\"},\t\t/* dyn_domain_not_found */\n\t{336068698, \"unsupported DYN verb\"},\n\t{336068699, \"MODIFY RDB$INDICES failed\"},\n\t{336068700, \"MODIFY RDB$FUNCTIONS failed\"},\n\t{336068701, \"Index column not found\"},\n\t{336068702, \"MODIFY RDB$GENERATORS failed\"},\n\t{336068703, \"MODIFY RDB$RELATION_FIELDS failed\"},\n\t{336068704, \"Local column {0} not found\"},\n\t{336068705, \"add EXTERNAL FILE not allowed\"},\n\t{336068706, \"drop EXTERNAL FILE not allowed\"},\n\t{336068707, \"MODIFY RDB$RELATIONS failed\"},\n\t{336068708, \"MODIFY RDB$PROCEDURE_PARAMETERS failed\"},\n\t{336068709, \"Table column not found\"},\n\t{336068710, \"MODIFY TRIGGER failed\"},\n\t{336068711, \"TRIGGER NAME expected\"},\n\t{336068712, \"unsupported DYN verb\"},\n\t{336068713, \"MODIFY TRIGGER MESSAGE failed\"},\n\t{336068714, \"Create metadata BLOB failed\"},\n\t{336068715, \"Write metadata BLOB failed\"},\n\t{336068716, \"Close metadata BLOB failed\"},\n\t{336068717, \"Triggers created automatically cannot be modified\"},\t\t/* dyn_cant_modify_auto_trig */\n\t{336068718, \"unsupported DYN verb\"},\n\t{336068719, \"ERASE RDB$USER_PRIVILEGES failed in revoke(1)\"},\n\t{336068720, \"Access to RDB$USER_PRIVILEGES failed in revoke(2)\"},\n\t{336068721, \"ERASE RDB$USER_PRIVILEGES failed in revoke (3)\"},\n\t{336068722, \"Access to RDB$USER_PRIVILEGES failed in revoke (4)\"},\n\t{336068723, \"CREATE VIEW failed\"},\n\t{336068724, \" attempt to index BLOB column in INDEX {0}\"},\n\t{336068725, \" attempt to index array column in index {0}\"},\n\t{336068726, \"key size too big for index {0}\"},\n\t{336068727, \"no keys for index {0}\"},\n\t{336068728, \"Unknown columns in index {0}\"},\n\t{336068729, \"STORE RDB$RELATION_CONSTRAINTS failed\"},\n\t{336068730, \"STORE RDB$CHECK_CONSTRAINTS failed\"},\n\t{336068731, \"Column: {0} not defined as NOT NULL - cannot be used in PRIMARY KEY constraint definition\"},\n\t{336068732, \"A column name is repeated in the definition of constraint: {0}\"},\n\t{336068733, \"Integrity Constraint lookup failed\"},\n\t{336068734, \"Same set of columns cannot be used in more than one PRIMARY KEY and/or UNIQUE constraint definition\"},\n\t{336068735, \"STORE RDB$REF_CONSTRAINTS failed\"},\n\t{336068736, \"No table specified in delete_constraint\"},\n\t{336068737, \"ERASE RDB$RELATION_CONSTRAINTS failed\"},\n\t{336068738, \"CONSTRAINT {0} does not exist.\"},\n\t{336068739, \"Generation of constraint name failed\"},\n\t{336068740, \"Table {0} already exists\"},\t\t/* dyn_dup_table */\n\t{336068741, \"Number of referencing columns do not equal number of referenced columns\"},\n\t{336068742, \"STORE RDB$PROCEDURES failed\"},\n\t{336068743, \"Procedure {0} already exists\"},\t\t/* dyn_dup_procedure */\n\t{336068744, \"STORE RDB$PROCEDURE_PARAMETERS failed\"},\n\t{336068745, \"Store into system table {0} failed\"},\n\t{336068746, \"ERASE RDB$PROCEDURE_PARAMETERS failed\"},\n\t{336068747, \"ERASE RDB$PROCEDURES failed\"},\n\t{336068748, \"Procedure {0} not found\"},\t\t/* dyn_proc_not_found */\n\t{336068749, \"MODIFY RDB$PROCEDURES failed\"},\n\t{336068750, \"DEFINE EXCEPTION failed\"},\n\t{336068751, \"ERASE EXCEPTION failed\"},\n\t{336068752, \"Exception not found\"},\t\t/* dyn_exception_not_found */\n\t{336068753, \"MODIFY EXCEPTION failed\"},\n\t{336068754, \"Parameter {0} in procedure {1} not found\"},\t\t/* dyn_proc_param_not_found */\n\t{336068755, \"Trigger {0} not found\"},\t\t/* dyn_trig_not_found */\n\t{336068756, \"Only one data type change to the domain {0} allowed at a time\"},\n\t{336068757, \"Only one data type change to the field {0} allowed at a time\"},\n\t{336068758, \"STORE RDB$FILES failed\"},\n\t{336068759, \"Character set {0} not found\"},\t\t/* dyn_charset_not_found */\n\t{336068760, \"Collation {0} not found\"},\t\t/* dyn_collation_not_found */\n\t{336068761, \"ERASE RDB$LOG_FILES failed\"},\n\t{336068762, \"STORE RDB$LOG_FILES failed\"},\n\t{336068763, \"Role {0} not found\"},\t\t/* dyn_role_not_found */\n\t{336068764, \"Difference file lookup failed\"},\n\t{336068765, \"DEFINE SHADOW failed\"},\n\t{336068766, \"MODIFY RDB$ROLES failed\"},\n\t{336068767, \"Name longer than database column size\"},\t\t/* dyn_name_longer */\n\t{336068768, \"\\\"Only one constraint allowed for a domain\\\"\"},\n\t{336068770, \"Looking up column position failed\"},\n\t{336068771, \"A node name is not permitted in a table with external file definition\"},\n\t{336068772, \"Shadow lookup failed\"},\n\t{336068773, \"Shadow {0} already exists\"},\n\t{336068774, \"Cannot add file with the same name as the database or added files\"},\n\t{336068775, \"no grant option for privilege {0} on column {1} of table/view {2}\"},\n\t{336068776, \"no grant option for privilege {0} on column {1} of base table/view {2}\"},\n\t{336068777, \"no grant option for privilege {0} on table/view {1} (for column {2})\"},\n\t{336068778, \"no grant option for privilege {0} on base table/view {1} (for column {2})\"},\n\t{336068779, \"no {0} privilege with grant option on table/view {1} (for column {2})\"},\n\t{336068780, \"no {0} privilege with grant option on base table/view {1} (for column {2})\"},\n\t{336068781, \"no grant option for privilege {0} on table/view {1}\"},\n\t{336068782, \"no {0} privilege with grant option on table/view {1}\"},\n\t{336068783, \"table/view {0} does not exist\"},\n\t{336068784, \"column {0} does not exist in table/view {1}\"},\t\t/* dyn_column_does_not_exist */\n\t{336068785, \"Can not alter a view\"},\n\t{336068786, \"EXTERNAL FILE table not supported in this context\"},\n\t{336068787, \"attempt to index COMPUTED BY column in INDEX {0}\"},\n\t{336068788, \"Table Name lookup failed\"},\n\t{336068789, \"attempt to index a view\"},\n\t{336068790, \"SELECT RDB$RELATIONS failed in grant\"},\n\t{336068791, \"SELECT RDB$RELATION_FIELDS failed in grant\"},\n\t{336068792, \"SELECT RDB$RELATIONS/RDB$OWNER_NAME failed in grant\"},\n\t{336068793, \"SELECT RDB$USER_PRIVILEGES failed in grant\"},\n\t{336068794, \"SELECT RDB$VIEW_RELATIONS/RDB$RELATION_FIELDS/... failed in grant\"},\n\t{336068795, \"column {0} from table {1} is referenced in index {2}\"},\n\t{336068796, \"SQL role {0} does not exist\"},\t\t/* dyn_role_does_not_exist */\n\t{336068797, \"user {0} has no grant admin option on SQL role {1}\"},\t\t/* dyn_no_grant_admin_opt */\n\t{336068798, \"user {0} is not a member of SQL role {1}\"},\t\t/* dyn_user_not_role_member */\n\t{336068799, \"{0} is not the owner of SQL role {1}\"},\t\t/* dyn_delete_role_failed */\n\t{336068800, \"{0} is a SQL role and not a user\"},\t\t/* dyn_grant_role_to_user */\n\t{336068801, \"user name {0} could not be used for SQL role\"},\t\t/* dyn_inv_sql_role_name */\n\t{336068802, \"SQL role {0} already exists\"},\t\t/* dyn_dup_sql_role */\n\t{336068803, \"keyword {0} can not be used as a SQL role name\"},\t\t/* dyn_kywd_spec_for_role */\n\t{336068804, \"SQL roles are not supported in on older versions of the database.  A backup and restore of the database is required.\"},\t\t/* dyn_roles_not_supported */\n\t{336068812, \"Cannot rename domain {0} to {1}.  A domain with that name already exists.\"},\t\t/* dyn_domain_name_exists */\n\t{336068813, \"Cannot rename column {0} to {1}.  A column with that name already exists in table {2}.\"},\t\t/* dyn_field_name_exists */\n\t{336068814, \"Column {0} from table {1} is referenced in {2}\"},\t\t/* dyn_dependency_exists */\n\t{336068815, \"Cannot change datatype for column {0}.  Changing datatype is not supported for BLOB or ARRAY columns.\"},\t\t/* dyn_dtype_invalid */\n\t{336068816, \"New size specified for column {0} must be at least {1} characters.\"},\t\t/* dyn_char_fld_too_small */\n\t{336068817, \"Cannot change datatype for {0}.  Conversion from base type {1} to {2} is not supported.\"},\t\t/* dyn_invalid_dtype_conversion */\n\t{336068818, \"Cannot change datatype for column {0} from a character type to a non-character type.\"},\t\t/* dyn_dtype_conv_invalid */\n\t{336068819, \"unable to allocate memory from the operating system\"},\t\t/* dyn_virmemexh */\n\t{336068820, \"Zero length identifiers are not allowed\"},\t\t/* dyn_zero_len_id */\n\t{336068821, \"ERASE RDB$GENERATORS failed\"},\t\t/* del_gen_fail */\n\t{336068822, \"Sequence {0} not found\"},\t\t/* dyn_gen_not_found */\n\t{336068823, \"Difference file is not defined\"},\n\t{336068824, \"Difference file is already defined\"},\n\t{336068825, \"Database is already in the physical backup mode\"},\n\t{336068826, \"Database is not in the physical backup mode\"},\n\t{336068827, \"DEFINE COLLATION failed\"},\n\t{336068828, \"CREATE COLLATION statement is not supported in older versions of the database.  A backup and restore is required.\"},\n\t{336068829, \"Maximum number of collations per character set exceeded\"},\t\t/* max_coll_per_charset */\n\t{336068830, \"Invalid collation attributes\"},\t\t/* invalid_coll_attr */\n\t{336068831, \"Collation {0} not installed for character set {1}\"},\n\t{336068832, \"Cannot use the internal domain {0} as new type for field {1}\"},\n\t{336068833, \"Default value is not allowed for array type in field {0}\"},\n\t{336068834, \"Default value is not allowed for array type in domain {0}\"},\n\t{336068835, \"DYN_UTIL_is_array failed for domain {0}\"},\n\t{336068836, \"DYN_UTIL_copy_domain failed for domain {0}\"},\n\t{336068837, \"Local column {0} doesn't have a default\"},\n\t{336068838, \"Local column {0} default belongs to domain {1}\"},\n\t{336068839, \"File name is invalid\"},\n\t{336068840, \"{0} cannot reference {1}\"},\t\t/* dyn_wrong_gtt_scope */\n\t{336068841, \"Local column {0} is computed, cannot set a default value\"},\n\t{336068842, \"ERASE RDB$COLLATIONS failed\"},\t\t/* del_coll_fail */\n\t{336068843, \"Collation {0} is used in table {1} (field name {2}) and cannot be dropped\"},\t\t/* dyn_coll_used_table */\n\t{336068844, \"Collation {0} is used in domain {1} and cannot be dropped\"},\t\t/* dyn_coll_used_domain */\n\t{336068845, \"Cannot delete system collation\"},\t\t/* dyn_cannot_del_syscoll */\n\t{336068846, \"Cannot delete default collation of CHARACTER SET {0}\"},\t\t/* dyn_cannot_del_def_coll */\n\t{336068847, \"Domain {0} is used in procedure {1} (parameter name {2}) and cannot be dropped\"},\n\t{336068848, \"Field {0} cannot be used twice in index {1}\"},\n\t{336068849, \"Table {0} not found\"},\t\t/* dyn_table_not_found */\n\t{336068850, \"attempt to reference a view ({0}) in a foreign key\"},\n\t{336068851, \"Collation {0} is used in procedure {1} (parameter name {2}) and cannot be dropped\"},\t\t/* dyn_coll_used_procedure */\n\t{336068852, \"New scale specified for column {0} must be at most {1}.\"},\t\t/* dyn_scale_too_big */\n\t{336068853, \"New precision specified for column {0} must be at least {1}.\"},\t\t/* dyn_precision_too_small */\n\t{336068854, \"{0} is not grantor of {1} on {2} to {3}.\"},\n\t{336068855, \"Warning: {0} on {1} is not granted to {2}.\"},\t\t/* dyn_miss_priv_warning */\n\t{336068856, \"Feature '{0}' is not supported in ODS {1}.{2}\"},\t\t/* dyn_ods_not_supp_feature */\n\t{336068857, \"Cannot add or remove COMPUTED from column {0}\"},\t\t/* dyn_cannot_addrem_computed */\n\t{336068858, \"Password should not be empty string\"},\t\t/* dyn_no_empty_pw */\n\t{336068859, \"Index {0} already exists\"},\t\t/* dyn_dup_index */\n\t{336068860, \"Only {0} or user with privilege USE_GRANTED_BY_CLAUSE can use GRANTED BY clause\"},\t\t/* dyn_locksmith_use_granted */\n\t{336068861, \"Exception {0} already exists\"},\t\t/* dyn_dup_exception */\n\t{336068862, \"Sequence {0} already exists\"},\t\t/* dyn_dup_generator */\n\t{336068863, \"ERASE RDB$USER_PRIVILEGES failed in REVOKE ALL ON ALL\"},\n\t{336068864, \"Package {0} not found\"},\t\t/* dyn_package_not_found */\n\t{336068865, \"Schema {0} not found\"},\t\t/* dyn_schema_not_found */\n\t{336068866, \"Cannot ALTER or DROP system procedure {0}\"},\t\t/* dyn_cannot_mod_sysproc */\n\t{336068867, \"Cannot ALTER or DROP system trigger {0}\"},\t\t/* dyn_cannot_mod_systrig */\n\t{336068868, \"Cannot ALTER or DROP system function {0}\"},\t\t/* dyn_cannot_mod_sysfunc */\n\t{336068869, \"Invalid DDL statement for procedure {0}\"},\t\t/* dyn_invalid_ddl_proc */\n\t{336068870, \"Invalid DDL statement for trigger {0}\"},\t\t/* dyn_invalid_ddl_trig */\n\t{336068871, \"Function {0} has not been defined on the package body {1}\"},\t\t/* dyn_funcnotdef_package */\n\t{336068872, \"Procedure {0} has not been defined on the package body {1}\"},\t\t/* dyn_procnotdef_package */\n\t{336068873, \"Function {0} has a signature mismatch on package body {1}\"},\t\t/* dyn_funcsignat_package */\n\t{336068874, \"Procedure {0} has a signature mismatch on package body {1}\"},\t\t/* dyn_procsignat_package */\n\t{336068875, \"Default values for parameters are not allowed in the definition of a previously declared packaged procedure {0}.{1}\"},\t\t/* dyn_defvaldecl_package_proc */\n\t{336068876, \"Function {0} already exists\"},\t\t/* dyn_dup_function */\n\t{336068877, \"Package body {0} already exists\"},\t\t/* dyn_package_body_exists */\n\t{336068878, \"Invalid DDL statement for function {0}\"},\t\t/* dyn_invalid_ddl_func */\n\t{336068879, \"Cannot alter new style function {0} with ALTER EXTERNAL FUNCTION. Use ALTER FUNCTION instead.\"},\t\t/* dyn_newfc_oldsyntax */\n\t{336068880, \"Cannot delete system generator {0}\"},\n\t{336068881, \"Identity column {0} of table {1} must be of exact number type with zero scale\"},\n\t{336068882, \"Identity column {0} of table {1} cannot be changed to NULLable\"},\n\t{336068883, \"Identity column {0} of table {1} cannot have default value\"},\n\t{336068884, \"Domain {0} must be of exact number type with zero scale because it's used in an identity column\"},\n\t{336068885, \"Generation of generator name failed\"},\n\t{336068886, \"Parameter {0} in function {1} not found\"},\t\t/* dyn_func_param_not_found */\n\t{336068887, \"Parameter {0} of routine {1} not found\"},\t\t/* dyn_routine_param_not_found */\n\t{336068888, \"Parameter {0} of routine {1} is ambiguous (found in both procedures and functions). Use a specifier keyword.\"},\t\t/* dyn_routine_param_ambiguous */\n\t{336068889, \"Collation {0} is used in function {1} (parameter name {2}) and cannot be dropped\"},\t\t/* dyn_coll_used_function */\n\t{336068890, \"Domain {0} is used in function {1} (parameter name {2}) and cannot be dropped\"},\t\t/* dyn_domain_used_function */\n\t{336068891, \"ALTER USER requires at least one clause to be specified\"},\t\t/* dyn_alter_user_no_clause */\n\t{336068892, \"Cannot delete system SQL role {0}\"},\n\t{336068893, \"Column {0} is not an identity column\"},\n\t{336068894, \"Duplicate {0} {1}\"},\t\t/* dyn_duplicate_package_item */\n\t{336068895, \"System {0} {1} cannot be modified\"},\t\t/* dyn_cant_modify_sysobj */\n\t{336068896, \"INCREMENT BY 0 is an illegal option for sequence {0}\"},\t\t/* dyn_cant_use_zero_increment */\n\t{336068897, \"Can't use {0} in FOREIGN KEY constraint\"},\t\t/* dyn_cant_use_in_foreignkey */\n\t{336068898, \"Default values for parameters are not allowed in the definition of a previously declared packaged function {0}.{1}\"},\t\t/* dyn_defvaldecl_package_func */\n\t{336068899, \"Password must be specified when creating user\"},\t\t/* dyn_create_user_no_password */\n\t{336068900, \"role {0} can not be granted to role {1}\"},\t\t/* dyn_cyclic_role */\n\t{336068901, \"DROP SYSTEM PRIVILEGES should not be used in CREATE ROLE operator\"},\n\t{336068902, \"Access to SYSTEM PRIVILEGES in ROLES denied to {0}\"},\n\t{336068903, \"Only {0}, DB owner {1} or user with privilege USE_GRANTED_BY_CLAUSE can use GRANTED BY clause\"},\n\t{336068904, \"INCREMENT BY 0 is an illegal option for identity column {0} of table {1}\"},\t\t/* dyn_cant_use_zero_inc_ident */\n\t{336068905, \"Concurrent ALTER DATABASE is not supported\"},\t\t/* dyn_concur_alter_database */\n\t{336068906, \"Incompatible ALTER DATABASE clauses: '{0}' and '{1}'\"},\t\t/* dyn_incompat_alter_database */\n\t{336068907, \"no {0} privilege with grant option on DDL {1}\"},\t\t/* dyn_no_ddl_grant_opt_priv */\n\t{336068908, \"no {0} privilege with grant option on object {1}\"},\t\t/* dyn_no_grant_opt_priv */\n\t{336068909, \"Function {0} does not exist\"},\t\t/* dyn_func_not_exist */\n\t{336068910, \"Procedure {0} does not exist\"},\t\t/* dyn_proc_not_exist */\n\t{336068911, \"Package {0} does not exist\"},\t\t/* dyn_pack_not_exist */\n\t{336068912, \"Trigger {0} does not exist\"},\t\t/* dyn_trig_not_exist */\n\t{336068913, \"View {0} does not exist\"},\t\t/* dyn_view_not_exist */\n\t{336068914, \"Table {0} does not exist\"},\t\t/* dyn_rel_not_exist */\n\t{336068915, \"Exception {0} does not exist\"},\t\t/* dyn_exc_not_exist */\n\t{336068916, \"Generator/Sequence {0} does not exist\"},\t\t/* dyn_gen_not_exist */\n\t{336068917, \"Field {0} of table {1} does not exist\"},\t\t/* dyn_fld_not_exist */\n\t{336330752, \"could not locate appropriate error message\"},\n\t{336330753, \"found unknown switch\"},\t\t/* gbak_unknown_switch */\n\t{336330754, \"page size parameter missing\"},\t\t/* gbak_page_size_missing */\n\t{336330755, \"Page size specified ({0}) greater than limit (32768 bytes)\"},\t\t/* gbak_page_size_toobig */\n\t{336330756, \"redirect location for output is not specified\"},\t\t/* gbak_redir_ouput_missing */\n\t{336330757, \"conflicting switches for backup/restore\"},\t\t/* gbak_switches_conflict */\n\t{336330758, \"device type {0} not known\"},\t\t/* gbak_unknown_device */\n\t{336330759, \"protection is not there yet\"},\t\t/* gbak_no_protection */\n\t{336330760, \"page size is allowed only on restore or create\"},\t\t/* gbak_page_size_not_allowed */\n\t{336330761, \"multiple sources or destinations specified\"},\t\t/* gbak_multi_source_dest */\n\t{336330762, \"requires both input and output filenames\"},\t\t/* gbak_filename_missing */\n\t{336330763, \"input and output have the same name.  Disallowed.\"},\t\t/* gbak_dup_inout_names */\n\t{336330764, \"expected page size, encountered \\\"{0}\\\"\"},\t\t/* gbak_inv_page_size */\n\t{336330765, \"REPLACE specified, but the first file {0} is a database\"},\t\t/* gbak_db_specified */\n\t{336330766, \"database {0} already exists.  To replace it, use the -REP switch\"},\t\t/* gbak_db_exists */\n\t{336330767, \"device type not specified\"},\t\t/* gbak_unk_device */\n\t{336330768, \"cannot create APOLLO tape descriptor file {0}\"},\n\t{336330769, \"cannot set APOLLO tape descriptor attribute for {0}\"},\n\t{336330770, \"cannot create APOLLO cartridge descriptor file {0}\"},\n\t{336330771, \"cannot close APOLLO tape descriptor file {0}\"},\n\t{336330772, \"gds_$blob_info failed\"},\t\t/* gbak_blob_info_failed */\n\t{336330773, \"do not understand BLOB INFO item {0}\"},\t\t/* gbak_unk_blob_item */\n\t{336330774, \"gds_$get_segment failed\"},\t\t/* gbak_get_seg_failed */\n\t{336330775, \"gds_$close_blob failed\"},\t\t/* gbak_close_blob_failed */\n\t{336330776, \"gds_$open_blob failed\"},\t\t/* gbak_open_blob_failed */\n\t{336330777, \"Failed in put_blr_gen_id\"},\t\t/* gbak_put_blr_gen_id_failed */\n\t{336330778, \"data type {0} not understood\"},\t\t/* gbak_unk_type */\n\t{336330779, \"gds_$compile_request failed\"},\t\t/* gbak_comp_req_failed */\n\t{336330780, \"gds_$start_request failed\"},\t\t/* gbak_start_req_failed */\n\t{336330781, \"gds_$receive failed\"},\t\t/* gbak_rec_failed */\n\t{336330782, \"gds_$release_request failed\"},\t\t/* gbak_rel_req_failed */\n\t{336330783, \"gds_$database_info failed\"},\t\t/* gbak_db_info_failed */\n\t{336330784, \"Expected database description record\"},\t\t/* gbak_no_db_desc */\n\t{336330785, \"failed to create database {0}\"},\t\t/* gbak_db_create_failed */\n\t{336330786, \"RESTORE: decompression length error\"},\t\t/* gbak_decomp_len_error */\n\t{336330787, \"cannot find table {0}\"},\t\t/* gbak_tbl_missing */\n\t{336330788, \"Cannot find column for BLOB\"},\t\t/* gbak_blob_col_missing */\n\t{336330789, \"gds_$create_blob failed\"},\t\t/* gbak_create_blob_failed */\n\t{336330790, \"gds_$put_segment failed\"},\t\t/* gbak_put_seg_failed */\n\t{336330791, \"expected record length\"},\t\t/* gbak_rec_len_exp */\n\t{336330792, \"wrong length record, expected {0} encountered {1}\"},\t\t/* gbak_inv_rec_len */\n\t{336330793, \"expected data attribute\"},\t\t/* gbak_exp_data_type */\n\t{336330794, \"Failed in store_blr_gen_id\"},\t\t/* gbak_gen_id_failed */\n\t{336330795, \"do not recognize record type {0}\"},\t\t/* gbak_unk_rec_type */\n\t{336330796, \"Expected backup version 1..10.  Found {0}\"},\t\t/* gbak_inv_bkup_ver */\n\t{336330797, \"expected backup description record\"},\t\t/* gbak_missing_bkup_desc */\n\t{336330798, \"string truncated\"},\t\t/* gbak_string_trunc */\n\t{336330799, \"warning -- record could not be restored\"},\t\t/* gbak_cant_rest_record */\n\t{336330800, \"gds_$send failed\"},\t\t/* gbak_send_failed */\n\t{336330801, \"no table name for data\"},\t\t/* gbak_no_tbl_name */\n\t{336330802, \"unexpected end of file on backup file\"},\t\t/* gbak_unexp_eof */\n\t{336330803, \"database format {0} is too old to restore to\"},\t\t/* gbak_db_format_too_old */\n\t{336330804, \"array dimension for column {0} is invalid\"},\t\t/* gbak_inv_array_dim */\n\t{336330805, \"expected array version number {0} but instead found {1}\"},\n\t{336330806, \"expected array dimension {0} but instead found {1}\"},\n\t{336330807, \"Expected XDR record length\"},\t\t/* gbak_xdr_len_expected */\n\t{336330808, \"Unexpected I/O error while {0} backup file\"},\n\t{336330809, \"adding file {0}, starting at page {1}\"},\n\t{336330810, \"array\"},\n\t{336330811, \"backup\"},\n\t{336330812, \"    {0}B(ACKUP_DATABASE)    backup database to file\"},\n\t{336330813, \"\\t\\tbackup file is compressed\"},\n\t{336330814, \"    {0}D(EVICE)             backup file device type on APOLLO (CT or MT)\"},\n\t{336330815, \"    {0}M(ETA_DATA)          backup or restore metadata only\"},\n\t{336330816, \"blob\"},\n\t{336330817, \"cannot open backup file {0}\"},\t\t/* gbak_open_bkup_error */\n\t{336330818, \"cannot open status and error output file {0}\"},\t\t/* gbak_open_error */\n\t{336330819, \"closing file, committing, and finishing\"},\n\t{336330820, \"committing metadata\"},\n\t{336330821, \"commit failed on table {0}\"},\n\t{336330822, \"committing secondary files\"},\n\t{336330823, \"creating index {0}\"},\n\t{336330824, \"committing data for table {0}\"},\n\t{336330825, \"    {0}C(REATE_DATABASE)    create database from backup file (restore)\"},\n\t{336330826, \"created database {0}, page_size {1} bytes\"},\n\t{336330827, \"creating file {0}\"},\n\t{336330828, \"creating indexes\"},\n\t{336330829, \"database {0} has a page size of {1} bytes.\"},\n\t{336330830, \"    {0}I(NACTIVE)           deactivate indexes during restore\"},\n\t{336330831, \"do not understand BLOB INFO item {0}\"},\n\t{336330832, \"do not recognize {0} attribute {1} -- continuing\"},\n\t{336330833, \"error accessing BLOB column {0} -- continuing\"},\n\t{336330834, \"Exiting before completion due to errors\"},\n\t{336330835, \"Exiting before completion due to errors\"},\n\t{336330836, \"column\"},\n\t{336330837, \"file\"},\n\t{336330838, \"file length\"},\n\t{336330839, \"filter\"},\n\t{336330840, \"finishing, closing, and going home\"},\n\t{336330841, \"function\"},\n\t{336330842, \"function argument\"},\n\t{336330843, \"gbak version {0}\"},\n\t{336330844, \"domain\"},\n\t{336330845, \"index\"},\n\t{336330846, \"trigger {0} is invalid\"},\n\t{336330847, \"legal switches are:\"},\n\t{336330848, \"length given for initial file ({0}) is less than minimum ({1})\"},\n\t{336330849, \"    {0}E(XPAND)             no data compression\"},\n\t{336330850, \"    {0}L(IMBO)              ignore transactions in limbo\"},\n\t{336330851, \"    {0}O(NE_AT_A_TIME)      restore one table at a time\"},\n\t{336330852, \"opened file {0}\"},\n\t{336330853, \"    {0}P(AGE_SIZE)          override default page size\"},\n\t{336330854, \"page size\"},\n\t{336330855, \"page size specified ({0} bytes) rounded up to {1} bytes\"},\n\t{336330856, \"    {0}Z                    print version number\"},\n\t{336330857, \"privilege\"},\n\t{336330858, \"     {0} records ignored\"},\n\t{336330859, \"   {0} records restored\"},\n\t{336330860, \"{0} records written\"},\n\t{336330861, \"    {0}Y  <path>            redirect/suppress status message output\"},\n\t{336330862, \"Reducing the database page size from {0} bytes to {1} bytes\"},\n\t{336330863, \"table\"},\n\t{336330864, \"    {0}REP(LACE_DATABASE)   replace database from backup file (restore)\"},\n\t{336330865, \"    {0}V(ERIFY)             report each action taken\"},\n\t{336330866, \"restore failed for record in table {0}\"},\n\t{336330867, \"    restoring column {0}\"},\n\t{336330868, \"    restoring file {0}\"},\n\t{336330869, \"    restoring filter {0}\"},\n\t{336330870, \"restoring function {0}\"},\n\t{336330871, \"    restoring argument for function {0}\"},\n\t{336330872, \"     restoring gen id value of: {0}\"},\n\t{336330873, \"restoring domain {0}\"},\n\t{336330874, \"    restoring index {0}\"},\n\t{336330875, \"    restoring privilege for user {0}\"},\n\t{336330876, \"restoring data for table {0}\"},\n\t{336330877, \"restoring security class {0}\"},\n\t{336330878, \"    restoring trigger {0}\"},\n\t{336330879, \"    restoring trigger message for {0}\"},\n\t{336330880, \"    restoring type {0} for column {1}\"},\n\t{336330881, \"started transaction\"},\n\t{336330882, \"starting transaction\"},\n\t{336330883, \"security class\"},\n\t{336330884, \"switches can be abbreviated to the unparenthesized characters\"},\n\t{336330885, \"transportable backup -- data in XDR format\"},\n\t{336330886, \"trigger\"},\n\t{336330887, \"trigger message\"},\n\t{336330888, \"trigger type\"},\n\t{336330889, \"unknown switch \\\"{0}\\\"\"},\n\t{336330890, \"validation error on column in table {0}\"},\n\t{336330891, \"    Version(s) for database \\\"{0}\\\"\"},\n\t{336330892, \"view\"},\n\t{336330893, \"    writing argument for function {0}\"},\n\t{336330894, \"    writing data for table {0}\"},\n\t{336330895, \"     writing gen id of: {0}\"},\n\t{336330896, \"         writing column {0}\"},\n\t{336330897, \"    writing filter {0}\"},\n\t{336330898, \"writing filters\"},\n\t{336330899, \"    writing function {0}\"},\n\t{336330900, \"writing functions\"},\n\t{336330901, \"    writing domain {0}\"},\n\t{336330902, \"writing domains\"},\n\t{336330903, \"    writing index {0}\"},\n\t{336330904, \"    writing privilege for user {0}\"},\n\t{336330905, \"    writing table {0}\"},\n\t{336330906, \"writing tables\"},\n\t{336330907, \"    writing security class {0}\"},\n\t{336330908, \"    writing trigger {0}\"},\n\t{336330909, \"    writing trigger message for {0}\"},\n\t{336330910, \"writing trigger messages\"},\n\t{336330911, \"writing triggers\"},\n\t{336330912, \"    writing type {0} for column {1}\"},\n\t{336330913, \"writing types\"},\n\t{336330914, \"writing shadow files\"},\n\t{336330915, \"    writing shadow file {0}\"},\n\t{336330916, \"writing id generators\"},\n\t{336330917, \"    writing generator {0} value {1}\"},\n\t{336330918, \"readied database {0} for backup\"},\n\t{336330919, \"restoring table {0}\"},\n\t{336330920, \"type\"},\n\t{336330921, \"gbak:\"},\n\t{336330922, \"committing metadata for table {0}\"},\n\t{336330923, \"error committing metadata for table {0}\"},\n\t{336330924, \"    {0}K(ILL)               restore without creating shadows\"},\n\t{336330925, \"cannot commit index {0}\"},\n\t{336330926, \"cannot commit files\"},\n\t{336330927, \"    {0}T(RANSPORTABLE)      transportable backup -- data in XDR format\"},\n\t{336330928, \"closing file, committing, and finishing. {0} bytes written\"},\n\t{336330929, \"    {0}G(ARBAGE_COLLECT)    inhibit garbage collection\"},\n\t{336330930, \"    {0}IG(NORE)             ignore bad checksums\"},\n\t{336330931, \"\\tcolumn {0} used in index {1} seems to have vanished\"},\n\t{336330932, \"index {0} omitted because {1} of the expected {2} keys were found\"},\n\t{336330933, \"    {0}FA(CTOR)             blocking factor\"},\n\t{336330934, \"blocking factor parameter missing\"},\t\t/* gbak_missing_block_fac */\n\t{336330935, \"expected blocking factor, encountered \\\"{0}\\\"\"},\t\t/* gbak_inv_block_fac */\n\t{336330936, \"a blocking factor may not be used in conjunction with device CT\"},\t\t/* gbak_block_fac_specified */\n\t{336330937, \"restoring generator {0} value: {1}\"},\n\t{336330938, \"    {0}OL(D_DESCRIPTIONS)   save old style metadata descriptions\"},\n\t{336330939, \"    {0}N(O_VALIDITY)        do not restore database validity conditions\"},\n\t{336330940, \"user name parameter missing\"},\t\t/* gbak_missing_username */\n\t{336330941, \"password parameter missing\"},\t\t/* gbak_missing_password */\n\t{336330942, \"    {0}PAS(SWORD)           Firebird password\"},\n\t{336330943, \"    {0}USER                 Firebird user name\"},\n\t{336330944, \"writing stored procedures\"},\n\t{336330945, \"writing stored procedure {0}\"},\n\t{336330946, \"writing parameter {0} for stored procedure\"},\n\t{336330947, \"restoring stored procedure {0}\"},\n\t{336330948, \"    restoring parameter {0} for stored procedure\"},\n\t{336330949, \"writing exceptions\"},\n\t{336330950, \"writing exception {0}\"},\n\t{336330951, \"restoring exception {0}\"},\n\t{336330952, \" missing parameter for the number of bytes to be skipped\"},\t\t/* gbak_missing_skipped_bytes */\n\t{336330953, \"expected number of bytes to be skipped, encountered \\\"{0}\\\"\"},\t\t/* gbak_inv_skipped_bytes */\n\t{336330954, \"adjusting an invalid decompression length from {0} to {1}\"},\n\t{336330955, \"skipped {0} bytes after reading a bad attribute {1}\"},\n\t{336330956, \"    {0}S(KIP_BAD_DATA)      skip number of bytes after reading bad data\"},\n\t{336330957, \"skipped {0} bytes looking for next valid attribute, encountered attribute {1}\"},\n\t{336330958, \"writing table constraints\"},\n\t{336330959, \"writing constraint {0}\"},\n\t{336330960, \"table constraint\"},\n\t{336330961, \"writing referential constraints\"},\n\t{336330962, \"writing check constraints\"},\n\t{336330963, \"writing character sets\"},\t\t/* msgVerbose_write_charsets */\n\t{336330964, \"writing collations\"},\t\t/* msgVerbose_write_collations */\n\t{336330965, \"character set\"},\t\t/* gbak_err_restore_charset */\n\t{336330966, \"writing character set {0}\"},\t\t/* msgVerbose_restore_charset */\n\t{336330967, \"collation\"},\t\t/* gbak_err_restore_collation */\n\t{336330968, \"writing collation {0}\"},\t\t/* msgVerbose_restore_collation */\n\t{336330972, \"Unexpected I/O error while reading from backup file\"},\t\t/* gbak_read_error */\n\t{336330973, \"Unexpected I/O error while writing to backup file\"},\t\t/* gbak_write_error */\n\t{336330974, \"\\n\\nCould not open file name \\\"{0}\\\"\"},\n\t{336330975, \"\\n\\nCould not write to file \\\"{0}\\\"\"},\n\t{336330976, \"\\n\\nCould not read from file \\\"{0}\\\"\"},\n\t{336330977, \"Done with volume #{0}, \\\"{1}\\\"\"},\n\t{336330978, \"\\tPress return to reopen that file, or type a new\\n\\tname followed by return to open a different file.\"},\n\t{336330979, \"Type a file name to open and hit return\"},\n\t{336330980, \"  Name: \"},\n\t{336330981, \"\\n\\nERROR: Backup incomplete\"},\n\t{336330982, \"Expected backup start time {0}, found {1}\"},\n\t{336330983, \"Expected backup database {0}, found {1}\"},\n\t{336330984, \"Expected volume number {0}, found volume {1}\"},\n\t{336330985, \"could not drop database {0} (no privilege or database might be in use)\"},\t\t/* gbak_db_in_use */\n\t{336330986, \"Skipped bad security class entry: {0}\"},\n\t{336330987, \"Unknown V3 SUB_TYPE: {0} in FIELD: {1}.\"},\n\t{336330988, \"Converted V3 sub_type: {0} to character_set_id: {1} and collate_id: {2}.\"},\n\t{336330989, \"Converted V3 scale: {0} to character_set_id: {1} and callate_id: {2}.\"},\n\t{336330990, \"System memory exhausted\"},\t\t/* gbak_sysmemex */\n\t{336330991, \"    {0}NT                   Non-Transportable backup file format\"},\n\t{336330992, \"Index \\\"{0}\\\" failed to activate because:\"},\n\t{336330993, \"  The unique index has duplicate values or NULLs.\"},\n\t{336330994, \"  Delete or Update duplicate values or NULLs, and activate index with\"},\n\t{336330995, \"  ALTER INDEX \\\"{0}\\\" ACTIVE;\"},\n\t{336330996, \"  Not enough disk space to create the sort file for an index.\"},\n\t{336330997, \"  Set the TMP environment variable to a directory on a filesystem that does have enough space, and activate index with\"},\n\t{336330998, \"Database is not online due to failure to activate one or more indices.\"},\n\t{336330999, \"Run gfix -online to bring database online without active indices.\"},\n\t{336331000, \"writing SQL roles\"},\t\t/* write_role_1 */\n\t{336331001, \"    writing SQL role: {0}\"},\t\t/* write_role_2 */\n\t{336331002, \"SQL role\"},\t\t/* gbak_restore_role_failed */\n\t{336331003, \"    restoring SQL role: {0}\"},\t\t/* restore_role */\n\t{336331004, \"    {0}RO(LE)               Firebird SQL role\"},\t\t/* gbak_role_op */\n\t{336331005, \"SQL role parameter missing\"},\t\t/* gbak_role_op_missing */\n\t{336331006, \"    {0}CO(NVERT)            backup external files as tables\"},\t\t/* gbak_convert_ext_tables */\n\t{336331007, \"gbak: WARNING:\"},\t\t/* gbak_warning */\n\t{336331008, \"gbak: ERROR:\"},\t\t/* gbak_error */\n\t{336331009, \"    {0}BU(FFERS)            override page buffers default\"},\t\t/* gbak_page_buffers */\n\t{336331010, \"page buffers parameter missing\"},\t\t/* gbak_page_buffers_missing */\n\t{336331011, \"expected page buffers, encountered \\\"{0}\\\"\"},\t\t/* gbak_page_buffers_wrong_param */\n\t{336331012, \"page buffers is allowed only on restore or create\"},\t\t/* gbak_page_buffers_restore */\n\t{336331013, \"Starting with volume #{0}, \\\"{1}\\\"\"},\n\t{336331014, \"size specification either missing or incorrect for file {0}\"},\t\t/* gbak_inv_size */\n\t{336331015, \"file {0} out of sequence\"},\t\t/* gbak_file_outof_sequence */\n\t{336331016, \"can't join -- one of the files missing\"},\t\t/* gbak_join_file_missing */\n\t{336331017, \" standard input is not supported when using join operation\"},\t\t/* gbak_stdin_not_supptd */\n\t{336331018, \"standard output is not supported when using split operation or in verbose mode\"},\t\t/* gbak_stdout_not_supptd */\n\t{336331019, \"backup file {0} might be corrupt\"},\t\t/* gbak_bkup_corrupt */\n\t{336331020, \"database file specification missing\"},\t\t/* gbak_unk_db_file_spec */\n\t{336331021, \"can't write a header record to file {0}\"},\t\t/* gbak_hdr_write_failed */\n\t{336331022, \"free disk space exhausted\"},\t\t/* gbak_disk_space_ex */\n\t{336331023, \"file size given ({0}) is less than minimum allowed ({1})\"},\t\t/* gbak_size_lt_min */\n\t{336331024, \"Warning -- free disk space exhausted for file {0}, the rest of the bytes ({1}) will be written to file {2}\"},\n\t{336331025, \"service name parameter missing\"},\t\t/* gbak_svc_name_missing */\n\t{336331026, \"Cannot restore over current database, must be SYSDBA or owner of the existing database.\"},\t\t/* gbak_not_ownr */\n\t{336331027, \"\"},\n\t{336331028, \"    {0}USE_(ALL_SPACE)      do not reserve space for record versions\"},\n\t{336331029, \"    {0}SE(RVICE)            use services manager\"},\n\t{336331030, \"    {0}MO(DE) <access>      \\\"read_only\\\" or \\\"read_write\\\" access\"},\t\t/* gbak_opt_mode */\n\t{336331031, \"\\\"read_only\\\" or \\\"read_write\\\" required\"},\t\t/* gbak_mode_req */\n\t{336331032, \"setting database to read-only access\"},\n\t{336331033, \"just data ignore all constraints etc.\"},\t\t/* gbak_just_data */\n\t{336331034, \"restoring data only ignoring foreign key, unique, not null & other constraints\"},\t\t/* gbak_data_only */\n\t{336331035, \"closing file, committing, and finishing. {0} bytes written\"},\n\t{336331036, \"    {0}R(ECREATE_DATABASE) [O(VERWRITE)] create (or replace if OVERWRITE used)\\\\n\\t\\t\\t\\tdatabase from backup file (restore)\"},\n\t{336331037, \"    activating and creating deferred index {0}\"},\t\t/* gbak_activating_idx */\n\t{336331038, \"check constraint\"},\n\t{336331039, \"exception\"},\n\t{336331040, \"array dimensions\"},\n\t{336331041, \"generator\"},\n\t{336331042, \"procedure\"},\n\t{336331043, \"procedure parameter\"},\n\t{336331044, \"referential constraint\"},\n\t{336331045, \"type (in RDB$TYPES)\"},\n\t{336331046, \"    {0}NOD(BTRIGGERS)       do not run database triggers\"},\n\t{336331047, \"    {0}TRU(STED)            use trusted authentication\"},\n\t{336331048, \"writing names mapping\"},\t\t/* write_map_1 */\n\t{336331049, \"    writing map for {0}\"},\t\t/* write_map_2 */\n\t{336331050, \"    restoring map for {0}\"},\t\t/* get_map_1 */\n\t{336331051, \"name mapping\"},\t\t/* get_map_2 */\n\t{336331052, \"cannot restore arbitrary mapping\"},\t\t/* get_map_3 */\n\t{336331053, \"restoring names mapping\"},\t\t/* get_map_4 */\n\t{336331054, \"    {0}FIX_FSS_D(ATA)       fix malformed UNICODE_FSS data\"},\n\t{336331055, \"    {0}FIX_FSS_M(ETADATA)   fix malformed UNICODE_FSS metadata\"},\n\t{336331056, \"Character set parameter missing\"},\n\t{336331057, \"Character set {0} not found\"},\n\t{336331058, \"    {0}FE(TCH_PASSWORD)     fetch password from file\"},\n\t{336331059, \"too many passwords provided\"},\n\t{336331060, \"could not open password file {0}, errno {1}\"},\n\t{336331061, \"could not read password file {0}, errno {1}\"},\n\t{336331062, \"empty password file {0}\"},\n\t{336331063, \"Attribute {0} was already processed for exception {1}\"},\n\t{336331064, \"Skipping attribute {0} because the message already exists for exception {1}\"},\n\t{336331065, \"Trying to recover from unexpected attribute {0} due to wrong message length for exception {1}\"},\n\t{336331066, \"Attribute not specified for storing text bigger than 255 bytes\"},\n\t{336331067, \"Unable to store text bigger than 65536 bytes\"},\n\t{336331068, \"Failed while adjusting the security class name\"},\n\t{336331069, \"Usage:\"},\n\t{336331070, \"     gbak -b <db set> <backup set> [backup options] [general options]\"},\n\t{336331071, \"     gbak -c <backup set> <db set> [restore options] [general options]\"},\n\t{336331072, \"     <db set> = <database> | <db1 size1>...<dbN> (size in db pages)\"},\n\t{336331073, \"     <backup set> = <backup> | <bk1 size1>...<bkN> (size in bytes = n[K|M|G])\"},\n\t{336331074, \"     -recreate overwrite and -replace can be used instead of -c\"},\n\t{336331075, \"backup options are:\"},\n\t{336331076, \"restore options are:\"},\n\t{336331077, \"general options are:\"},\n\t{336331078, \"verbose interval value parameter missing\"},\t\t/* gbak_missing_interval */\n\t{336331079, \"verbose interval value cannot be smaller than {0}\"},\t\t/* gbak_wrong_interval */\n\t{336331080, \"    {0}VERBI(NT) <n>        verbose information with explicit interval\"},\n\t{336331081, \"verify (verbose) and verbint options are mutually exclusive\"},\t\t/* gbak_verify_verbint */\n\t{336331082, \"option -{0} is allowed only on restore or create\"},\t\t/* gbak_option_only_restore */\n\t{336331083, \"option -{0} is allowed only on backup\"},\t\t/* gbak_option_only_backup */\n\t{336331084, \"options -{0} and -{1} are mutually exclusive\"},\t\t/* gbak_option_conflict */\n\t{336331085, \"parameter for option -{0} was already specified with value \\\"{1}\\\"\"},\t\t/* gbak_param_conflict */\n\t{336331086, \"option -{0} was already specified\"},\t\t/* gbak_option_repeated */\n\t{336331087, \"writing package {0}\"},\n\t{336331088, \"writing packages\"},\n\t{336331089, \"restoring package {0}\"},\n\t{336331090, \"package\"},\n\t{336331091, \"dependency depth greater than {0} for view {1}\"},\t\t/* gbak_max_dbkey_recursion */\n\t{336331092, \"value greater than {0} when calculating length of rdb$db_key for view {1}\"},\t\t/* gbak_max_dbkey_length */\n\t{336331093, \"Invalid metadata detected. Use -FIX_FSS_METADATA option.\"},\t\t/* gbak_invalid_metadata */\n\t{336331094, \"Invalid data detected. Use -FIX_FSS_DATA option.\"},\t\t/* gbak_invalid_data */\n\t{336331095, \"text for attribute {0} is too large in {1}, truncating to {2} bytes\"},\n\t{336331096, \"Expected backup version {1}..{2}.  Found {0}\"},\t\t/* gbak_inv_bkup_ver2 */\n\t{336331097, \"    writing view {0}\"},\n\t{336331098, \"    table {0} is a view\"},\n\t{336331099, \"writing security classes\"},\n\t{336331100, \"database format {0} is too old to backup\"},\t\t/* gbak_db_format_too_old2 */\n\t{336331101, \"backup version is {0}\"},\n\t{336331102, \"adjusting system generators\"},\n\t{336331103, \"Error closing database, but backup file is OK\"},\n\t{336331104, \"database\"},\n\t{336331105, \"required mapping attributes are missing in backup file\"},\n\t{336331106, \"missing regular expression to skip tables\"},\n\t{336331107, \"    {0}SKIP_D(ATA)          skip data for table\"},\n\t{336331108, \"regular expression to skip tables was already set\"},\n\t{336331109, \"adjusting views dbkey length\"},\n\t{336331110, \"updating ownership of packages, procedures and tables\"},\n\t{336331111, \"adding missing privileges\"},\n\t{336331112, \"adjusting the ONLINE and FORCED WRITES flags\"},\n\t{336331113, \"    {0}ST(ATISTICS) TDRW    show statistics:\"},\n\t{336331114, \"        T                 time from start\"},\n\t{336331115, \"        D                 delta time\"},\n\t{336331116, \"        R                 page reads\"},\n\t{336331117, \"        W                 page writes\"},\n\t{336331118, \"statistics parameter missing\"},\t\t/* gbak_missing_perf */\n\t{336331119, \"wrong char \\\"{0}\\\" at statistics parameter\"},\t\t/* gbak_wrong_perf */\n\t{336331120, \"too many chars at statistics parameter\"},\t\t/* gbak_too_long_perf */\n\t{336331121, \"total statistics\"},\n\t{336331122, \"could not append BLOB data to batch\"},\n\t{336331123, \"could not start batch when restoring table {0}, trying old way\"},\n\t{336331124, \"    {0}KEYNAME              name of a key to be used for encryption\"},\n\t{336331125, \"    {0}CRYPT                crypt plugin name\"},\n\t{336331126, \"    {0}ZIP                  backup file is in zip compressed format\"},\n\t{336331127, \"Keyname parameter missing\"},\n\t{336331128, \"Key holder parameter missing but backup file is encrypted\"},\n\t{336331129, \"CryptPlugin parameter missing\"},\n\t{336331130, \"Unknown crypt plugin name - use -CRYPT switch\"},\n\t{336331131, \"Inflate error {0}\"},\n\t{336331132, \"Deflate error {0}\"},\n\t{336331133, \"Key holder parameter missing\"},\n\t{336331134, \"    {0}KEYHOLDER            name of a key holder plugin\"},\n\t{336331135, \"Decompression stream init error {0}\"},\n\t{336331136, \"Compression stream init error {0}\"},\n\t{336331137, \"Invalid reply from getInfo() when waiting for DB encryption\"},\n\t{336331138, \"Problems with just created database encryption\"},\n\t{336331139, \"Skipped trigger {0} on system table {1}\"},\n\t{336331140, \"    {0}INCLUDE(_DATA)       backup data of table(s)\"},\n\t{336331141, \"missing regular expression to include tables\"},\n\t{336331142, \"regular expression to include tables was already set\"},\n\t{336331143, \"writing database create grants\"},\n\t{336331144, \"    database create grant for {0}\"},\n\t{336331145, \"    restoring database create grant for {0}\"},\n\t{336331146, \"restoring database create grants\"},\n\t{336331147, \"database create grant\"},\n\t{336331148, \"writing publications\"},\n\t{336331149, \"    writing publication {0}\"},\n\t{336331150, \"    writing publication for table {0}\"},\n\t{336331151, \"restoring publication {0}\"},\n\t{336331152, \"publication\"},\n\t{336331153, \"restoring publication for table {0}\"},\n\t{336331154, \"publication for table\"},\n\t{336331155, \"    {0}REPLICA <mode>      \\\"none\\\", \\\"read_only\\\" or \\\"read_write\\\" replica mode\"},\t\t/* gbak_opt_replica */\n\t{336331156, \"\\\"none\\\", \\\"read_only\\\" or \\\"read_write\\\" required\"},\t\t/* gbak_replica_req */\n\t{336331157, \"could not access batch parameters\"},\n\t{336331158, \"    {0}PAR(ALLEL)           parallel workers\"},\n\t{336331159, \"parallel workers parameter missing\"},\t\t/* gbak_missing_prl_wrks */\n\t{336331160, \"expected parallel workers, encountered \\\"{0}\\\"\"},\t\t/* gbak_inv_prl_wrks */\n\t{336331161, \"    {0}D(IRECT_IO)          direct IO for backup file(s)\"},\n\t{336331162, \"use up to {0} parallel workers\"},\n\t{336396289, \"Firebird error\"},\n\t{336396362, \"Rollback not performed\"},\n\t{336396364, \"Connection error\"},\n\t{336396365, \"Connection not established\"},\n\t{336396366, \"Connection authorization failure.\"},\n\t{336396375, \"deadlock\"},\n\t{336396376, \"Unsuccessful execution caused by deadlock.\"},\n\t{336396377, \"record from transaction {0} is stuck in limbo\"},\n\t{336396379, \"operation completed with errors\"},\n\t{336396382, \"the SQL statement cannot be executed\"},\n\t{336396384, \"Unsuccessful execution caused by an unavailable resource.\"},\n\t{336396386, \"Unsuccessful execution caused by a system error that precludes successful execution of subsequent statements\"},\n\t{336396387, \"Unsuccessful execution caused by system error that does not preclude successful execution of subsequent statements\"},\n\t{336396446, \"Wrong numeric type\"},\n\t{336396447, \"too many versions\"},\n\t{336396448, \"intermediate journal file full\"},\n\t{336396449, \"journal file wrong format\"},\n\t{336396450, \"database {0} shutdown in {1} seconds\"},\n\t{336396451, \"restart shared cache manager\"},\n\t{336396452, \"exception {0}\"},\n\t{336396453, \"bad checksum\"},\n\t{336396454, \"refresh range number {0} not found\"},\n\t{336396455, \"expression evaluation not supported\"},\n\t{336396456, \"FOREIGN KEY column count does not match PRIMARY KEY\"},\n\t{336396457, \"Attempt to define a second PRIMARY KEY for the same table\"},\n\t{336396458, \"column used with aggregate\"},\n\t{336396459, \"invalid column reference\"},\n\t{336396460, \"invalid key position\"},\n\t{336396461, \"invalid direction for find operation\"},\n\t{336396462, \"Invalid statement handle\"},\n\t{336396463, \"invalid lock handle\"},\n\t{336396464, \"invalid lock level {0}\"},\n\t{336396465, \"invalid bookmark handle\"},\n\t{336396468, \"wrong or obsolete version\"},\n\t{336396471, \"The INSERT, UPDATE, DELETE, DDL or authorization statement cannot be executed because the transaction is inquiry only\"},\n\t{336396472, \"external file could not be opened for output\"},\n\t{336396477, \"multiple rows in singleton select\"},\n\t{336396478, \"No subqueries permitted for VIEW WITH CHECK OPTION\"},\n\t{336396479, \"DISTINCT, GROUP or HAVING not permitted for VIEW WITH CHECK OPTION\"},\n\t{336396480, \"Only one table allowed for VIEW WITH CHECK OPTION\"},\n\t{336396481, \"No WHERE clause for VIEW WITH CHECK OPTION\"},\n\t{336396482, \"Only simple column names permitted for VIEW WITH CHECK OPTION\"},\n\t{336396484, \"An error was found in the application program input parameters for the SQL statement.\"},\n\t{336396485, \"Invalid insert or update value(s): object columns are constrained - no 2 table rows can have duplicate column values\"},\n\t{336396486, \"Arithmetic overflow or division by zero has occurred.\"},\n\t{336396594, \"cannot access column {0} in view {1}\"},\n\t{336396595, \"Too many concurrent executions of the same request\"},\n\t{336396596, \"maximum indexes per table ({0}) exceeded\"},\n\t{336396597, \"new record size of {0} bytes is too big\"},\n\t{336396598, \"segments not allowed in expression index {0}\"},\n\t{336396599, \"wrong page type\"},\n\t{336396603, \"invalid ARRAY or BLOB operation\"},\n\t{336396611, \"{0} extension error\"},\n\t{336396624, \"key size exceeds implementation restriction for index \\\"{0}\\\"\"},\n\t{336396625, \"definition error for index {0}\"},\n\t{336396628, \"cannot create index\"},\n\t{336396651, \"duplicate specification of {0} - not supported\"},\n\t{336396663, \"The insert failed because a column definition includes validation constraints.\"},\n\t{336396670, \"Cannot delete object referenced by another object\"},\n\t{336396671, \"Cannot modify object referenced by another object\"},\n\t{336396672, \"Object is referenced by another object\"},\n\t{336396673, \"lock on conflicts with existing lock\"},\n\t{336396681, \"This operation is not defined for system tables.\"},\n\t{336396683, \"Inappropriate self-reference of column\"},\n\t{336396684, \"Illegal array dimension range\"},\n\t{336396687, \"database or file exists\"},\n\t{336396688, \"sort error: corruption in data structure\"},\n\t{336396689, \"node not supported\"},\n\t{336396690, \"Shadow number must be a positive integer\"},\n\t{336396691, \"Preceding file did not specify length, so {0} must include starting page number\"},\n\t{336396692, \"illegal operation when at beginning of stream\"},\n\t{336396693, \"the current position is on a crack\"},\n\t{336396735, \"cannot modify an existing user privilege\"},\n\t{336396736, \"user does not have the privilege to perform operation\"},\n\t{336396737, \"This user does not have privilege to perform this operation on this object.\"},\n\t{336396756, \"transaction marked invalid by I/O error\"},\n\t{336396757, \"Cannot prepare a CREATE DATABASE/SCHEMA statement\"},\n\t{336396758, \"violation of FOREIGN KEY constraint \\\"{0}\\\"\"},\n\t{336396769, \"The prepare statement identifies a prepare statement with an open cursor\"},\n\t{336396770, \"Unknown statement or request\"},\n\t{336396778, \"Attempt to update non-updatable cursor\"},\n\t{336396780, \"The cursor identified in the UPDATE or DELETE statement is not positioned on a row.\"},\n\t{336396784, \"Unknown cursor\"},\n\t{336396786, \"The cursor identified in an OPEN statement is already open.\"},\n\t{336396787, \"The cursor identified in a FETCH or CLOSE statement is not open.\"},\n\t{336396875, \"Overflow occurred during data type conversion.\"},\n\t{336396881, \"null segment of UNIQUE KEY\"},\n\t{336396882, \"subscript out of bounds\"},\n\t{336396886, \"data operation not supported\"},\n\t{336396887, \"invalid comparison operator for find operation\"},\n\t{336396974, \"Cannot transliterate character between character sets\"},\n\t{336396975, \"count of column list and variable list do not match\"},\n\t{336396985, \"Incompatible column/host variable data type\"},\n\t{336396991, \"Operation violates CHECK constraint {0} on view or table\"},\n\t{336396992, \"internal Firebird consistency check (invalid RDB$CONSTRAINT_TYPE)\"},\n\t{336396993, \"Cannot update constraints (RDB$RELATION_CONSTRAINTS).\"},\n\t{336396994, \"Cannot delete CHECK constraint entry (RDB$CHECK_CONSTRAINTS)\"},\n\t{336396995, \"Cannot update constraints (RDB$CHECK_CONSTRAINTS).\"},\n\t{336396996, \"Cannot update constraints (RDB$REF_CONSTRAINTS).\"},\n\t{336396997, \"Column used in a PRIMARY constraint must be NOT NULL.\"},\n\t{336397004, \"index {0} cannot be used in the specified plan\"},\n\t{336397005, \"table {0} is referenced in the plan but not the from list\"},\n\t{336397006, \"the table {0} is referenced twice; use aliases to differentiate\"},\n\t{336397007, \"table {0} is not referenced in plan\"},\n\t{336397027, \"Log file specification partition error\"},\n\t{336397028, \"Cache or Log redefined\"},\n\t{336397029, \"Write-ahead Log with shadowing configuration not allowed\"},\n\t{336397030, \"Overflow log specification required for round-robin log\"},\n\t{336397031, \"WAL defined; Cache Manager must be started first\"},\n\t{336397033, \"Write-ahead Log without shared cache configuration not allowed\"},\n\t{336397034, \"Cannot start WAL writer for the database {0}\"},\n\t{336397035, \"WAL writer synchronization error for the database {0}\"},\n\t{336397036, \"WAL setup error.  Please see Firebird log.\"},\n\t{336397037, \"WAL buffers cannot be increased.  Please see Firebird log.\"},\n\t{336397038, \"WAL writer - Journal server communication error.  Please see Firebird log.\"},\n\t{336397039, \"WAL I/O error.  Please see Firebird log.\"},\n\t{336397040, \"Unable to roll over; please see Firebird log.\"},\n\t{336397041, \"obsolete\"},\n\t{336397042, \"obsolete\"},\n\t{336397043, \"obsolete\"},\n\t{336397044, \"obsolete\"},\n\t{336397045, \"database does not use Write-ahead Log\"},\n\t{336397046, \"Cannot roll over to the next log file {0}\"},\n\t{336397047, \"obsolete\"},\n\t{336397048, \"obsolete\"},\n\t{336397049, \"Cache or Log size too small\"},\n\t{336397050, \"Log record header too small at offset {0} in log file {1}\"},\n\t{336397051, \"Incomplete log record at offset {0} in log file {1}\"},\n\t{336397052, \"Unexpected end of log file {0} at offset {1}\"},\n\t{336397053, \"Database name in the log file {0} is different\"},\n\t{336397054, \"Log file {0} not closed properly; database recovery may be required\"},\n\t{336397055, \"Log file {0} not latest in the chain but open flag still set\"},\n\t{336397056, \"Invalid version of log file {0}\"},\n\t{336397057, \"Log file header of {0} too small\"},\n\t{336397058, \"obsolete\"},\n\t{336397069, \"table {0} is not defined\"},\n\t{336397080, \"invalid ORDER BY clause\"},\n\t{336397082, \"Column does not belong to referenced table\"},\n\t{336397083, \"column {0} is not defined in table {1}\"},\n\t{336397084, \"Undefined name\"},\n\t{336397085, \"Ambiguous column reference.\"},\n\t{336397116, \"function {0} is not defined\"},\n\t{336397117, \"Invalid data type, length, or value\"},\n\t{336397118, \"Invalid number of arguments\"},\n\t{336397126, \"dbkey not available for multi-table views\"},\n\t{336397130, \"number of columns does not match select list\"},\n\t{336397131, \"must specify column name for view select expression\"},\n\t{336397133, \"{0} is not a valid base table of the specified view\"},\n\t{336397137, \"This column cannot be updated because it is derived from an SQL function or expression.\"},\n\t{336397138, \"The object of the INSERT, DELETE or UPDATE statement is a view for which the requested operation is not permitted.\"},\n\t{336397183, \"Invalid String\"},\n\t{336397184, \"Invalid token\"},\n\t{336397185, \"Invalid numeric literal\"},\n\t{336397203, \"An error occurred while trying to update the security database\"},\n\t{336397204, \"non-SQL security class defined\"},\n\t{336397205, \"ODS versions before ODS{0} are not supported\"},\t\t/* dsql_too_old_ods */\n\t{336397206, \"Table {0} does not exist\"},\t\t/* dsql_table_not_found */\n\t{336397207, \"View {0} does not exist\"},\t\t/* dsql_view_not_found */\n\t{336397208, \"At line {0}, column {1}\"},\t\t/* dsql_line_col_error */\n\t{336397209, \"At unknown line and column\"},\t\t/* dsql_unknown_pos */\n\t{336397210, \"Column {0} cannot be repeated in {1} statement\"},\t\t/* dsql_no_dup_name */\n\t{336397211, \"Too many values (more than {0}) in member list to match against\"},\t\t/* dsql_too_many_values */\n\t{336397212, \"Array and BLOB data types not allowed in computed field\"},\t\t/* dsql_no_array_computed */\n\t{336397213, \"Implicit domain name {0} not allowed in user created domain\"},\t\t/* dsql_implicit_domain_name */\n\t{336397214, \"scalar operator used on field {0} which is not an array\"},\t\t/* dsql_only_can_subscript_array */\n\t{336397215, \"cannot sort on more than 255 items\"},\t\t/* dsql_max_sort_items */\n\t{336397216, \"cannot group on more than 255 items\"},\t\t/* dsql_max_group_items */\n\t{336397217, \"Cannot include the same field ({0}.{1}) twice in the ORDER BY clause with conflicting sorting options\"},\t\t/* dsql_conflicting_sort_field */\n\t{336397218, \"column list from derived table {0} has more columns than the number of items in its SELECT statement\"},\t\t/* dsql_derived_table_more_columns */\n\t{336397219, \"column list from derived table {0} has less columns than the number of items in its SELECT statement\"},\t\t/* dsql_derived_table_less_columns */\n\t{336397220, \"no column name specified for column number {0} in derived table {1}\"},\t\t/* dsql_derived_field_unnamed */\n\t{336397221, \"column {0} was specified multiple times for derived table {1}\"},\t\t/* dsql_derived_field_dup_name */\n\t{336397222, \"Internal dsql error: alias type expected by pass1_expand_select_node\"},\t\t/* dsql_derived_alias_select */\n\t{336397223, \"Internal dsql error: alias type expected by pass1_field\"},\t\t/* dsql_derived_alias_field */\n\t{336397224, \"Internal dsql error: column position out of range in pass1_union_auto_cast\"},\t\t/* dsql_auto_field_bad_pos */\n\t{336397225, \"Recursive CTE member ({0}) can refer itself only in FROM clause\"},\t\t/* dsql_cte_wrong_reference */\n\t{336397226, \"CTE '{0}' has cyclic dependencies\"},\t\t/* dsql_cte_cycle */\n\t{336397227, \"Recursive member of CTE can't be member of an outer join\"},\t\t/* dsql_cte_outer_join */\n\t{336397228, \"Recursive member of CTE can't reference itself more than once\"},\t\t/* dsql_cte_mult_references */\n\t{336397229, \"Recursive CTE ({0}) must be an UNION\"},\t\t/* dsql_cte_not_a_union */\n\t{336397230, \"CTE '{0}' defined non-recursive member after recursive\"},\t\t/* dsql_cte_nonrecurs_after_recurs */\n\t{336397231, \"Recursive member of CTE '{0}' has {1} clause\"},\t\t/* dsql_cte_wrong_clause */\n\t{336397232, \"Recursive members of CTE ({0}) must be linked with another members via UNION ALL\"},\t\t/* dsql_cte_union_all */\n\t{336397233, \"Non-recursive member is missing in CTE '{0}'\"},\t\t/* dsql_cte_miss_nonrecursive */\n\t{336397234, \"WITH clause can't be nested\"},\t\t/* dsql_cte_nested_with */\n\t{336397235, \"column {0} appears more than once in USING clause\"},\t\t/* dsql_col_more_than_once_using */\n\t{336397236, \"feature is not supported in dialect {0}\"},\t\t/* dsql_unsupp_feature_dialect */\n\t{336397237, \"CTE \\\"{0}\\\" is not used in query\"},\t\t/* dsql_cte_not_used */\n\t{336397238, \"column {0} appears more than once in ALTER VIEW\"},\t\t/* dsql_col_more_than_once_view */\n\t{336397239, \"{0} is not supported inside IN AUTONOMOUS TRANSACTION block\"},\t\t/* dsql_unsupported_in_auto_trans */\n\t{336397240, \"Unknown node type {0} in dsql/GEN_expr\"},\t\t/* dsql_eval_unknode */\n\t{336397241, \"Argument for {0} in dialect 1 must be string or numeric\"},\t\t/* dsql_agg_wrongarg */\n\t{336397242, \"Argument for {0} in dialect 3 must be numeric\"},\t\t/* dsql_agg2_wrongarg */\n\t{336397243, \"Strings cannot be added to or subtracted from DATE or TIME types\"},\t\t/* dsql_nodateortime_pm_string */\n\t{336397244, \"Invalid data type for subtraction involving DATE, TIME or TIMESTAMP types\"},\t\t/* dsql_invalid_datetime_subtract */\n\t{336397245, \"Adding two DATE values or two TIME values is not allowed\"},\t\t/* dsql_invalid_dateortime_add */\n\t{336397246, \"DATE value cannot be subtracted from the provided data type\"},\t\t/* dsql_invalid_type_minus_date */\n\t{336397247, \"Strings cannot be added or subtracted in dialect 3\"},\t\t/* dsql_nostring_addsub_dial3 */\n\t{336397248, \"Invalid data type for addition or subtraction in dialect 3\"},\t\t/* dsql_invalid_type_addsub_dial3 */\n\t{336397249, \"Invalid data type for multiplication in dialect 1\"},\t\t/* dsql_invalid_type_multip_dial1 */\n\t{336397250, \"Strings cannot be multiplied in dialect 3\"},\t\t/* dsql_nostring_multip_dial3 */\n\t{336397251, \"Invalid data type for multiplication in dialect 3\"},\t\t/* dsql_invalid_type_multip_dial3 */\n\t{336397252, \"Division in dialect 1 must be between numeric data types\"},\t\t/* dsql_mustuse_numeric_div_dial1 */\n\t{336397253, \"Strings cannot be divided in dialect 3\"},\t\t/* dsql_nostring_div_dial3 */\n\t{336397254, \"Invalid data type for division in dialect 3\"},\t\t/* dsql_invalid_type_div_dial3 */\n\t{336397255, \"Strings cannot be negated (applied the minus operator) in dialect 3\"},\t\t/* dsql_nostring_neg_dial3 */\n\t{336397256, \"Invalid data type for negation (minus operator)\"},\t\t/* dsql_invalid_type_neg */\n\t{336397257, \"Cannot have more than 255 items in DISTINCT / UNION DISTINCT list\"},\t\t/* dsql_max_distinct_items */\n\t{336397258, \"ALTER CHARACTER SET {0} failed\"},\t\t/* dsql_alter_charset_failed */\n\t{336397259, \"COMMENT ON {0} failed\"},\t\t/* dsql_comment_on_failed */\n\t{336397260, \"CREATE FUNCTION {0} failed\"},\t\t/* dsql_create_func_failed */\n\t{336397261, \"ALTER FUNCTION {0} failed\"},\t\t/* dsql_alter_func_failed */\n\t{336397262, \"CREATE OR ALTER FUNCTION {0} failed\"},\t\t/* dsql_create_alter_func_failed */\n\t{336397263, \"DROP FUNCTION {0} failed\"},\t\t/* dsql_drop_func_failed */\n\t{336397264, \"RECREATE FUNCTION {0} failed\"},\t\t/* dsql_recreate_func_failed */\n\t{336397265, \"CREATE PROCEDURE {0} failed\"},\t\t/* dsql_create_proc_failed */\n\t{336397266, \"ALTER PROCEDURE {0} failed\"},\t\t/* dsql_alter_proc_failed */\n\t{336397267, \"CREATE OR ALTER PROCEDURE {0} failed\"},\t\t/* dsql_create_alter_proc_failed */\n\t{336397268, \"DROP PROCEDURE {0} failed\"},\t\t/* dsql_drop_proc_failed */\n\t{336397269, \"RECREATE PROCEDURE {0} failed\"},\t\t/* dsql_recreate_proc_failed */\n\t{336397270, \"CREATE TRIGGER {0} failed\"},\t\t/* dsql_create_trigger_failed */\n\t{336397271, \"ALTER TRIGGER {0} failed\"},\t\t/* dsql_alter_trigger_failed */\n\t{336397272, \"CREATE OR ALTER TRIGGER {0} failed\"},\t\t/* dsql_create_alter_trigger_failed */\n\t{336397273, \"DROP TRIGGER {0} failed\"},\t\t/* dsql_drop_trigger_failed */\n\t{336397274, \"RECREATE TRIGGER {0} failed\"},\t\t/* dsql_recreate_trigger_failed */\n\t{336397275, \"CREATE COLLATION {0} failed\"},\t\t/* dsql_create_collation_failed */\n\t{336397276, \"DROP COLLATION {0} failed\"},\t\t/* dsql_drop_collation_failed */\n\t{336397277, \"CREATE DOMAIN {0} failed\"},\t\t/* dsql_create_domain_failed */\n\t{336397278, \"ALTER DOMAIN {0} failed\"},\t\t/* dsql_alter_domain_failed */\n\t{336397279, \"DROP DOMAIN {0} failed\"},\t\t/* dsql_drop_domain_failed */\n\t{336397280, \"CREATE EXCEPTION {0} failed\"},\t\t/* dsql_create_except_failed */\n\t{336397281, \"ALTER EXCEPTION {0} failed\"},\t\t/* dsql_alter_except_failed */\n\t{336397282, \"CREATE OR ALTER EXCEPTION {0} failed\"},\t\t/* dsql_create_alter_except_failed */\n\t{336397283, \"RECREATE EXCEPTION {0} failed\"},\t\t/* dsql_recreate_except_failed */\n\t{336397284, \"DROP EXCEPTION {0} failed\"},\t\t/* dsql_drop_except_failed */\n\t{336397285, \"CREATE SEQUENCE {0} failed\"},\t\t/* dsql_create_sequence_failed */\n\t{336397286, \"CREATE TABLE {0} failed\"},\t\t/* dsql_create_table_failed */\n\t{336397287, \"ALTER TABLE {0} failed\"},\t\t/* dsql_alter_table_failed */\n\t{336397288, \"DROP TABLE {0} failed\"},\t\t/* dsql_drop_table_failed */\n\t{336397289, \"RECREATE TABLE {0} failed\"},\t\t/* dsql_recreate_table_failed */\n\t{336397290, \"CREATE PACKAGE {0} failed\"},\t\t/* dsql_create_pack_failed */\n\t{336397291, \"ALTER PACKAGE {0} failed\"},\t\t/* dsql_alter_pack_failed */\n\t{336397292, \"CREATE OR ALTER PACKAGE {0} failed\"},\t\t/* dsql_create_alter_pack_failed */\n\t{336397293, \"DROP PACKAGE {0} failed\"},\t\t/* dsql_drop_pack_failed */\n\t{336397294, \"RECREATE PACKAGE {0} failed\"},\t\t/* dsql_recreate_pack_failed */\n\t{336397295, \"CREATE PACKAGE BODY {0} failed\"},\t\t/* dsql_create_pack_body_failed */\n\t{336397296, \"DROP PACKAGE BODY {0} failed\"},\t\t/* dsql_drop_pack_body_failed */\n\t{336397297, \"RECREATE PACKAGE BODY {0} failed\"},\t\t/* dsql_recreate_pack_body_failed */\n\t{336397298, \"CREATE VIEW {0} failed\"},\t\t/* dsql_create_view_failed */\n\t{336397299, \"ALTER VIEW {0} failed\"},\t\t/* dsql_alter_view_failed */\n\t{336397300, \"CREATE OR ALTER VIEW {0} failed\"},\t\t/* dsql_create_alter_view_failed */\n\t{336397301, \"RECREATE VIEW {0} failed\"},\t\t/* dsql_recreate_view_failed */\n\t{336397302, \"DROP VIEW {0} failed\"},\t\t/* dsql_drop_view_failed */\n\t{336397303, \"DROP SEQUENCE {0} failed\"},\t\t/* dsql_drop_sequence_failed */\n\t{336397304, \"RECREATE SEQUENCE {0} failed\"},\t\t/* dsql_recreate_sequence_failed */\n\t{336397305, \"DROP INDEX {0} failed\"},\t\t/* dsql_drop_index_failed */\n\t{336397306, \"DROP FILTER {0} failed\"},\t\t/* dsql_drop_filter_failed */\n\t{336397307, \"DROP SHADOW {0} failed\"},\t\t/* dsql_drop_shadow_failed */\n\t{336397308, \"DROP ROLE {0} failed\"},\t\t/* dsql_drop_role_failed */\n\t{336397309, \"DROP USER {0} failed\"},\t\t/* dsql_drop_user_failed */\n\t{336397310, \"CREATE ROLE {0} failed\"},\t\t/* dsql_create_role_failed */\n\t{336397311, \"ALTER ROLE {0} failed\"},\t\t/* dsql_alter_role_failed */\n\t{336397312, \"ALTER INDEX {0} failed\"},\t\t/* dsql_alter_index_failed */\n\t{336397313, \"ALTER DATABASE failed\"},\t\t/* dsql_alter_database_failed */\n\t{336397314, \"CREATE SHADOW {0} failed\"},\t\t/* dsql_create_shadow_failed */\n\t{336397315, \"DECLARE FILTER {0} failed\"},\t\t/* dsql_create_filter_failed */\n\t{336397316, \"CREATE INDEX {0} failed\"},\t\t/* dsql_create_index_failed */\n\t{336397317, \"CREATE USER {0} failed\"},\t\t/* dsql_create_user_failed */\n\t{336397318, \"ALTER USER {0} failed\"},\t\t/* dsql_alter_user_failed */\n\t{336397319, \"GRANT failed\"},\t\t/* dsql_grant_failed */\n\t{336397320, \"REVOKE failed\"},\t\t/* dsql_revoke_failed */\n\t{336397321, \"Recursive member of CTE cannot use aggregate or window function\"},\t\t/* dsql_cte_recursive_aggregate */\n\t{336397322, \"{1} MAPPING {0} failed\"},\t\t/* dsql_mapping_failed */\n\t{336397323, \"ALTER SEQUENCE {0} failed\"},\t\t/* dsql_alter_sequence_failed */\n\t{336397324, \"CREATE GENERATOR {0} failed\"},\t\t/* dsql_create_generator_failed */\n\t{336397325, \"SET GENERATOR {0} failed\"},\t\t/* dsql_set_generator_failed */\n\t{336397326, \"WITH LOCK can be used only with a single physical table\"},\t\t/* dsql_wlock_simple */\n\t{336397327, \"FIRST/SKIP cannot be used with OFFSET/FETCH or ROWS\"},\t\t/* dsql_firstskip_rows */\n\t{336397328, \"WITH LOCK cannot be used with aggregates\"},\t\t/* dsql_wlock_aggregates */\n\t{336397329, \"WITH LOCK cannot be used with {0}\"},\t\t/* dsql_wlock_conflict */\n\t{336397330, \"Number of arguments ({0}) exceeds the maximum ({1}) number of EXCEPTION USING arguments\"},\t\t/* dsql_max_exception_arguments */\n\t{336397331, \"String literal with {0} bytes exceeds the maximum length of {1} bytes\"},\t\t/* dsql_string_byte_length */\n\t{336397332, \"String literal with {0} characters exceeds the maximum length of {1} characters for the {2} character set\"},\t\t/* dsql_string_char_length */\n\t{336397333, \"Too many BEGIN...END nesting. Maximum level is {0}\"},\t\t/* dsql_max_nesting */\n\t{336397334, \"RECREATE USER {0} failed\"},\t\t/* dsql_recreate_user_failed */\n\t{336461924, \"Row not found for fetch, update or delete, or the result of a query is an empty table.\"},\n\t{336461925, \"segment buffer length shorter than expected\"},\n\t{336462125, \"Datatype needs modification\"},\n\t{336462436, \"Duplicate column or domain name found.\"},\n\t{336527507, \"invalid block type encountered\"},\n\t{336527508, \"wrong packet type\"},\n\t{336527509, \"cannot map page\"},\n\t{336527510, \"request to allocate invalid block type\"},\n\t{336527511, \"request to allocate block type larger than maximum size\"},\n\t{336527512, \"memory pool free list is invalid\"},\n\t{336527513, \"invalid pool id encountered\"},\n\t{336527514, \"attempt to release free block\"},\n\t{336527515, \"attempt to release block overlapping following free block\"},\n\t{336527516, \"attempt to release block overlapping prior free block\"},\n\t{336527517, \"cannot sort on a field that does not exist\"},\n\t{336527518, \"database file not available\"},\n\t{336527519, \"cannot assert logical lock\"},\n\t{336527520, \"wrong ACL version\"},\n\t{336527521, \"shadow block not found\"},\n\t{336527522, \"shadow lock not synchronized properly\"},\n\t{336527523, \"root file name not listed for shadow\"},\n\t{336527524, \"failed to remove symbol from hash table\"},\n\t{336527525, \"cannot find tip page\"},\n\t{336527526, \"invalid rsb type\"},\n\t{336527527, \"invalid SEND request\"},\n\t{336527528, \"looper: action not yet implemented\"},\n\t{336527529, \"return data type not supported\"},\n\t{336527530, \"unexpected reply from journal server\"},\n\t{336527531, \"journal server is incompatible version\"},\n\t{336527532, \"journal server refused connection\"},\n\t{336527533, \"referenced index description not found\"},\n\t{336527534, \"index key too big\"},\n\t{336527535, \"partner index description not found\"},\n\t{336527536, \"bad difference record\"},\n\t{336527537, \"applied differences will not fit in record\"},\n\t{336527538, \"record length inconsistent\"},\n\t{336527539, \"decompression overran buffer\"},\n\t{336527540, \"cannot reposition for update after sort for RMS\"},\n\t{336527541, \"external access type not implemented\"},\n\t{336527542, \"differences record too long\"},\n\t{336527543, \"wrong record length\"},\n\t{336527544, \"limbo impossible\"},\n\t{336527545, \"wrong record version\"},\n\t{336527546, \"record disappeared\"},\n\t{336527547, \"cannot delete system tables\"},\n\t{336527548, \"cannot update erased record\"},\n\t{336527549, \"comparison not supported for specified data types\"},\n\t{336527550, \"conversion not supported for specified data types\"},\n\t{336527551, \"conversion error\"},\n\t{336527552, \"overflow during conversion\"},\n\t{336527553, \"null or invalid array\"},\n\t{336527554, \"BLOB not found\"},\n\t{336527555, \"cannot update old BLOB\"},\n\t{336527556, \"relation for array not known\"},\n\t{336527557, \"field for array not known\"},\n\t{336527558, \"array subscript computation error\"},\n\t{336527559, \"expected field node\"},\n\t{336527560, \"invalid BLOB ID\"},\n\t{336527561, \"cannot find BLOB page\"},\n\t{336527562, \"unknown data type\"},\n\t{336527563, \"shadow block not found for extend file\"},\n\t{336527564, \"index inconsistent\"},\n\t{336527565, \"index bucket overfilled\"},\n\t{336527566, \"exceeded index level\"},\n\t{336527567, \"page already in use\"},\n\t{336527568, \"page not accessed for write\"},\n\t{336527569, \"attempt to release page not acquired\"},\n\t{336527570, \"page in use during flush\"},\n\t{336527571, \"attempt to remove page from dirty page list when not there\"},\n\t{336527572, \"CCH_precedence: block marked\"},\n\t{336527573, \"insufficient cache size\"},\n\t{336527574, \"no cache buffers available for reuse\"},\n\t{336527575, \"page {0}, page type {1} lock conversion denied\"},\n\t{336527576, \"page {0}, page type {1} lock denied\"},\n\t{336527577, \"buffer marked for update\"},\n\t{336527578, \"CCH: {0}, status = {1} (218)\"},\n\t{336527579, \"request of unknown resource\"},\n\t{336527580, \"release of unknown resource\"},\n\t{336527581, \"(CMP) copy: cannot remap\"},\n\t{336527582, \"bad BLR -- invalid stream\"},\n\t{336527583, \"argument of scalar operation must be an array\"},\n\t{336527584, \"quad word arithmetic not supported\"},\n\t{336527585, \"data type not supported for arithmetic\"},\n\t{336527586, \"request size limit exceeded\"},\n\t{336527587, \"cannot access field {0} in view {1}\"},\n\t{336527588, \"cannot access field in view {0}\"},\n\t{336527589, \"EVL_assign_to: invalid operation\"},\n\t{336527590, \"EVL_bitmap: invalid operation\"},\n\t{336527591, \"EVL_boolean: invalid operation\"},\n\t{336527592, \"EVL_expr: invalid operation\"},\n\t{336527593, \"eval_statistical: invalid operation\"},\n\t{336527594, \"Unimplemented conversion, FAO directive O,Z,S\"},\n\t{336527595, \"Unimplemented conversion, FAO directive X,U\"},\n\t{336527596, \"Error parsing RDB FAO msg string\"},\n\t{336527597, \"Error parsing RDB FAO msg str\"},\n\t{336527598, \"unknown parameter in RdB status vector\"},\n\t{336527599, \"Firebird status vector inconsistent\"},\n\t{336527600, \"Firebird/RdB message parameter inconsistency\"},\n\t{336527601, \"error parsing RDB FAO message string\"},\n\t{336527602, \"unimplemented FAO directive\"},\n\t{336527603, \"missing pointer page in DPM_data_pages\"},\n\t{336527604, \"Fragment does not exist\"},\n\t{336527605, \"pointer page disappeared in DPM_delete\"},\n\t{336527606, \"pointer page lost from DPM_delete_relation\"},\n\t{336527607, \"missing pointer page in DPM_dump\"},\n\t{336527608, \"cannot find record fragment\"},\n\t{336527609, \"pointer page vanished from DPM_next\"},\n\t{336527610, \"temporary page buffer too small\"},\n\t{336527611, \"damaged data page\"},\n\t{336527612, \"header fragment length changed\"},\n\t{336527613, \"pointer page vanished from extend_relation\"},\n\t{336527614, \"pointer page vanished from relation list in locate_space\"},\n\t{336527615, \"cannot find free space\"},\n\t{336527616, \"pointer page vanished from mark_full\"},\n\t{336527617, \"bad record in RDB$PAGES\"},\n\t{336527618, \"page slot not empty\"},\n\t{336527619, \"bad pointer page\"},\n\t{336527620, \"index unexpectedly deleted\"},\n\t{336527621, \"scalar operator used on field which is not an array\"},\n\t{336527622, \"active\"},\n\t{336527623, \"committed\"},\n\t{336527624, \"rolled back\"},\n\t{336527625, \"in an ill-defined state\"},\n\t{336527626, \"next transaction older than oldest active transaction\"},\n\t{336527627, \"next transaction older than oldest transaction\"},\n\t{336527628, \"buffer marked during cache unwind\"},\n\t{336527629, \"error in recovery! database corrupted\"},\n\t{336527630, \"error in recovery! wrong data page record\"},\n\t{336527631, \"error in recovery! no space on data page\"},\n\t{336527632, \"error in recovery! wrong header page record\"},\n\t{336527633, \"error in recovery! wrong generator page record\"},\n\t{336527634, \"error in recovery! wrong b-tree page record\"},\n\t{336527635, \"error in recovery! wrong page inventory page record\"},\n\t{336527636, \"error in recovery! wrong pointer page record\"},\n\t{336527637, \"error in recovery! wrong index root page record\"},\n\t{336527638, \"error in recovery! wrong transaction page record\"},\n\t{336527639, \"error in recovery! out of sequence log record encountered\"},\n\t{336527640, \"error in recovery! unknown page type\"},\n\t{336527641, \"error in recovery! unknown record type\"},\n\t{336527642, \"journal server cannot archive to specified archive directory\"},\n\t{336527643, \"checksum error in log record when reading from log file\"},\n\t{336527644, \"cannot restore singleton select data\"},\n\t{336527645, \"lock not found in internal lock manager\"},\n\t{336527646, \"size of opt block exceeded\"},\n\t{336527647, \"Too many savepoints\"},\n\t{336527648, \"garbage collect record disappeared\"},\n\t{336527649, \"Unknown BLOB FILTER ACTION_\"},\n\t{336527650, \"error during savepoint backout\"},\t\t/* savepoint_error */\n\t{336527651, \"cannot find record back version\"},\n\t{336527652, \"Illegal user_type.\"},\n\t{336527653, \"bad ACL\"},\n\t{336527654, \"inconsistent LATCH_mark release\"},\n\t{336527655, \"inconsistent LATCH_mark call\"},\n\t{336527656, \"inconsistent latch downgrade call\"},\n\t{336527657, \"bdb is unexpectedly marked\"},\n\t{336527658, \"missing exclusive latch\"},\n\t{336527659, \"exceeded maximum number of shared latches on a bdb\"},\n\t{336527660, \"can't find shared latch\"},\n\t{336527661, \"Non-zero use_count of a buffer in the empty que\"},\t\t/* cache_non_zero_use_count */\n\t{336527662, \"Unexpected page change from latching\"},\t\t/* unexpected_page_change */\n\t{336527663, \"Invalid expression for evaluation\"},\n\t{336527664, \"RDB$FLAGS for trigger {0} in RDB$TRIGGERS is corrupted\"},\t\t/* rdb$triggers_rdb$flags_corrupt */\n\t{336527665, \"Blobs accounting is inconsistent\"},\n\t{336527666, \"Found array data type with more than 16 dimensions\"},\n\t{336658432, \"Statement failed, SQLSTATE = {0}\"},\t\t/* GEN_ERR */\n\t{336658433, \"usage:    isql [options] [<database>]\"},\t\t/* USAGE */\n\t{336658434, \"Unknown switch: {0}\"},\t\t/* SWITCH */\n\t{336658435, \"Use CONNECT or CREATE DATABASE to specify a database\"},\t\t/* NO_DB */\n\t{336658436, \"Unable to open {0}\"},\t\t/* FILE_OPEN_ERR */\n\t{336658437, \"Commit current transaction (y/n)?\"},\t\t/* COMMIT_PROMPT */\n\t{336658438, \"Committing.\"},\t\t/* COMMIT_MSG */\n\t{336658439, \"Rolling back work.\"},\t\t/* ROLLBACK_MSG */\n\t{336658440, \"Command error: {0}\"},\t\t/* CMD_ERR */\n\t{336658441, \"Enter data or NULL for each column.  RETURN to end.\"},\t\t/* ADD_PROMPT */\n\t{336658442, \"ISQL Version: {0}\"},\t\t/* VERSION */\n\t{336658443, \"\\t-a(ll)                  extract metadata incl. legacy non-SQL tables\"},\t\t/* USAGE_ALL */\n\t{336658444, \"Number of DB pages allocated = {0}\"},\t\t/* NUMBER_PAGES */\n\t{336658445, \"Sweep interval = {0}\"},\t\t/* SWEEP_INTERV */\n\t{336658446, \"Number of wal buffers = {0}\"},\t\t/* NUM_WAL_BUFF */\n\t{336658447, \"Wal buffer size = {0}\"},\t\t/* WAL_BUFF_SIZE */\n\t{336658448, \"Check point length = {0}\"},\t\t/* CKPT_LENGTH */\n\t{336658449, \"Check point interval = {0}\"},\t\t/* CKPT_INTERV */\n\t{336658450, \"Wal group commit wait = {0}\"},\t\t/* WAL_GRPC_WAIT */\n\t{336658451, \"Base level = {0}\"},\t\t/* BASE_LEVEL */\n\t{336658452, \"Transaction in limbo = {0}\"},\t\t/* LIMBO */\n\t{336658453, \"Frontend commands:\"},\t\t/* HLP_FRONTEND */\n\t{336658454, \"BLOBVIEW <blobid>          -- view BLOB in text editor\"},\t\t/* HLP_BLOBED */\n\t{336658455, \"BLOBDUMP <blobid> <file>   -- dump BLOB to a file\"},\t\t/* HLP_BLOBDMP */\n\t{336658456, \"EDIT     [<filename>]      -- edit SQL script file and execute\"},\t\t/* HLP_EDIT */\n\t{336658457, \"INput    <filename>        -- take input from the named SQL file\"},\t\t/* HLP_INPUT */\n\t{336658458, \"OUTput   [<filename>]      -- write output to named file\"},\t\t/* HLP_OUTPUT */\n\t{336658459, \"SHELL    <command>         -- execute Operating System command in sub-shell\"},\t\t/* HLP_SHELL */\n\t{336658460, \"HELP                       -- display this menu\"},\t\t/* HLP_HELP */\n\t{336658461, \"Set commands:\"},\t\t/* HLP_SETCOM */\n\t{336658462, \"    SET                    -- display current SET options\"},\t\t/* HLP_SET */\n\t{336658463, \"    SET AUTOddl            -- toggle autocommit of DDL statements\"},\t\t/* HLP_SETAUTO */\n\t{336658464, \"    SET BLOB [ALL|<n>]     -- display BLOBS of subtype <n> or ALL\"},\t\t/* HLP_SETBLOB */\n\t{336658465, \"    SET COUNT              -- toggle count of selected rows on/off\"},\t\t/* HLP_SETCOUNT */\n\t{336658466, \"    SET ECHO               -- toggle command echo on/off\"},\t\t/* HLP_SETECHO */\n\t{336658467, \"    SET STATs              -- toggle display of performance statistics\"},\t\t/* HLP_SETSTAT */\n\t{336658468, \"    SET TERM <string>      -- change statement terminator string\"},\t\t/* HLP_SETTERM */\n\t{336658469, \"SHOW     <object> [<name>] -- display system information\"},\t\t/* HLP_SHOW */\n\t{336658470, \"    <object> = CHECK, COLLATION, DATABASE, DOMAIN, EXCEPTION, FILTER, FUNCTION,\"},\t\t/* HLP_OBJTYPE */\n\t{336658471, \"EXIT                       -- exit and commit changes\"},\t\t/* HLP_EXIT */\n\t{336658472, \"QUIT                       -- exit and roll back changes\"},\t\t/* HLP_QUIT */\n\t{336658473, \"All commands may be abbreviated to letters in CAPitals\"},\t\t/* HLP_ALL */\n\t{336658474, \"\\tSET SCHema/DB <db name> -- changes current database\"},\t\t/* HLP_SETSCHEMA */\n\t{336658475, \"Yes\"},\t\t/* YES_ANS */\n\t{336658476, \"Current memory = !c\\nDelta memory = !d\\nMax memory = !x\\nElapsed time = !e sec\\n\"},\t\t/* REPORT1 */\n\t{336658477, \"Cpu = !u sec\\nBuffers = !b\\nReads = !r\\nWrites = !w\\nFetches = !f\"},\t\t/* REPORT2 */\n\t{336658478, \"BLOB display set to subtype {0}. This BLOB: subtype = {1}\"},\t\t/* BLOB_SUBTYPE */\n\t{336658479, \"BLOB: {0}, type 'edit' or filename to load>\"},\t\t/* BLOB_PROMPT */\n\t{336658480, \"Enter {0} as Y/M/D>\"},\t\t/* DATE_PROMPT */\n\t{336658481, \"Enter {0}>\"},\t\t/* NAME_PROMPT */\n\t{336658482, \"Bad date {0}\"},\t\t/* DATE_ERR */\n\t{336658483, \"CON> \"},\t\t/* CON_PROMPT */\n\t{336658484, \"    SET LIST               -- toggle column or table display format\"},\t\t/* HLP_SETLIST */\n\t{336658485, \"{0} not found\"},\t\t/* NOT_FOUND */\n\t{336658486, \"Errors occurred (possibly duplicate domains) in creating {0} in {1}\"},\t\t/* COPY_ERR */\n\t{336658487, \"Server version too old to support the isql command\"},\t\t/* SERVER_TOO_OLD */\n\t{336658488, \"Records affected: {0}\"},\t\t/* REC_COUNT */\n\t{336658489, \"Unlicensed for database \\\"{0}\\\"\"},\t\t/* UNLICENSED */\n\t{336658490, \"    SET WIDTH <col> [<n>]  -- set/unset print width to <n> for column <col>\"},\t\t/* HLP_SETWIDTH */\n\t{336658491, \"    SET PLAN               -- toggle display of query access plan\"},\t\t/* HLP_SETPLAN */\n\t{336658492, \"    SET TIME               -- toggle display of timestamp with DATE values\"},\t\t/* HLP_SETTIME */\n\t{336658493, \"EDIT                       -- edit current command buffer and execute\"},\t\t/* HLP_EDIT2 */\n\t{336658494, \"OUTput                     -- return output to stdout\"},\t\t/* HLP_OUTPUT2 */\n\t{336658495, \"    SET NAMES <csname>     -- set name of runtime character set\"},\t\t/* HLP_SETNAMES */\n\t{336658496, \"               GENERATOR, GRANT, INDEX, PACKAGE, PROCEDURE, ROLE, SQL DIALECT,\"},\t\t/* HLP_OBJTYPE2 */\n\t{336658497, \"    SET BLOB               -- turn off BLOB display\"},\t\t/* HLP_SETBLOB2 */\n\t{336658498, \"SET      <option>          -- (Use HELP SET for complete list)\"},\t\t/* HLP_SET_ROOT */\n\t{336658499, \"There are no tables in this database\"},\t\t/* NO_TABLES */\n\t{336658500, \"There is no table {0} in this database\"},\t\t/* NO_TABLE */\n\t{336658501, \"There are no views in this database\"},\t\t/* NO_VIEWS */\n\t{336658502, \"There is no view {0} in this database\"},\t\t/* NO_VIEW */\n\t{336658503, \"There are no indices on table {0} in this database\"},\t\t/* NO_INDICES_ON_REL */\n\t{336658504, \"There is no table or index {0} in this database\"},\t\t/* NO_REL_OR_INDEX */\n\t{336658505, \"There are no indices in this database\"},\t\t/* NO_INDICES */\n\t{336658506, \"There is no domain {0} in this database\"},\t\t/* NO_DOMAIN */\n\t{336658507, \"There are no domains in this database\"},\t\t/* NO_DOMAINS */\n\t{336658508, \"There is no exception {0} in this database\"},\t\t/* NO_EXCEPTION */\n\t{336658509, \"There are no exceptions in this database\"},\t\t/* NO_EXCEPTIONS */\n\t{336658510, \"There is no filter {0} in this database\"},\t\t/* NO_FILTER */\n\t{336658511, \"There are no filters in this database\"},\t\t/* NO_FILTERS */\n\t{336658512, \"There is no user-defined function {0} in this database\"},\t\t/* NO_FUNCTION */\n\t{336658513, \"There are no user-defined functions in this database\"},\t\t/* NO_FUNCTIONS */\n\t{336658514, \"There is no generator {0} in this database\"},\t\t/* NO_GEN */\n\t{336658515, \"There are no generators in this database\"},\t\t/* NO_GENS */\n\t{336658516, \"There is no privilege granted on table {0} in this database\"},\t\t/* NO_GRANT_ON_REL */\n\t{336658517, \"There is no privilege granted on stored procedure {0} in this database\"},\t\t/* NO_GRANT_ON_PROC */\n\t{336658518, \"There is no table or stored procedure {0} in this database\"},\t\t/* NO_REL_OR_PROC */\n\t{336658519, \"There is no stored procedure {0} in this database\"},\t\t/* NO_PROC */\n\t{336658520, \"There are no stored procedures in this database\"},\t\t/* NO_PROCS */\n\t{336658521, \"There are no triggers on table {0} in this database\"},\t\t/* NO_TRIGGERS_ON_REL */\n\t{336658522, \"There is no table or trigger {0} in this database\"},\t\t/* NO_REL_OR_TRIGGER */\n\t{336658523, \"There are no triggers in this database\"},\t\t/* NO_TRIGGERS */\n\t{336658524, \"There are no check constraints on table {0} in this database\"},\t\t/* NO_CHECKS_ON_REL */\n\t{336658525, \"Buffers = !b\\nReads = !r\\nWrites !w\\nFetches = !f\"},\t\t/* REPORT2_WINDOWS_ONLY */\n\t{336658526, \"Single isql command exceeded maximum buffer size\"},\t\t/* BUFFER_OVERFLOW */\n\t{336658527, \"There are no roles in this database\"},\t\t/* NO_ROLES */\n\t{336658528, \"There is no metadata object {0} in this database\"},\t\t/* NO_OBJECT */\n\t{336658529, \"There is no membership privilege granted on {0} in this database\"},\t\t/* NO_GRANT_ON_ROL */\n\t{336658530, \"Expected end of statement, encountered EOF\"},\t\t/* UNEXPECTED_EOF */\n\t{336658533, \"Bad TIME: {0}\"},\t\t/* TIME_ERR */\n\t{336658534, \"               SYSTEM, TABLE, TRIGGER, VERSION, USERS, VIEW, WIRE_STATISTICS\"},\t\t/* HLP_OBJTYPE3 */\n\t{336658535, \"There is no role {0} in this database\"},\t\t/* NO_ROLE */\n\t{336658536, \"\\t-b(ail)                 bail on errors (set bail on)\"},\t\t/* USAGE_BAIL */\n\t{336658537, \"Incomplete string in {0}\"},\n\t{336658538, \"    SET SQL DIALECT <n>    -- set sql dialect to <n>\"},\t\t/* HLP_SETSQLDIALECT */\n\t{336658539, \"There is no privilege granted in this database\"},\t\t/* NO_GRANT_ON_ANY */\n\t{336658540, \"    SET PLANONLY           -- toggle display of query plan without executing\"},\t\t/* HLP_SETPLANONLY */\n\t{336658541, \"    SET HEADING            -- toggle display of query column titles\"},\t\t/* HLP_SETHEADING */\n\t{336658542, \"    SET BAIL               -- toggle bailing out on errors in non-interactive mode\"},\t\t/* HLP_SETBAIL */\n\t{336658543, \"\\t-c(ache) <num>          number of cache buffers\"},\t\t/* USAGE_CACHE */\n\t{336658544, \"Enter {0} as H:M:S>\"},\t\t/* TIME_PROMPT */\n\t{336658545, \"Enter {0} as Y/MON/D H:MIN:S[.MSEC]>\"},\t\t/* TIMESTAMP_PROMPT */\n\t{336658546, \"Bad TIMESTAMP: {0}\"},\t\t/* TIMESTAMP_ERR */\n\t{336658547, \"There are no comments for objects in this database\"},\t\t/* NO_COMMENTS */\n\t{336658548, \"Printing only the first {0} blobs.\"},\t\t/* ONLY_FIRST_BLOBS */\n\t{336658549, \"Tables:\"},\t\t/* MSG_TABLES */\n\t{336658550, \"Functions:\"},\t\t/* MSG_FUNCTIONS */\n\t{336658551, \"At line {0} in file {1}\"},\t\t/* EXACTLINE */\n\t{336658552, \"After line {0} in file {1}\"},\t\t/* AFTERLINE */\n\t{336658553, \"There is no trigger {0} in this database\"},\t\t/* NO_TRIGGER */\n\t{336658554, \"\\t-ch(arset) <charset>    connection charset (set names)\"},\t\t/* USAGE_CHARSET */\n\t{336658555, \"\\t-d(atabase) <database>  database name to put in script creation\"},\t\t/* USAGE_DATABASE */\n\t{336658556, \"\\t-e(cho)                 echo commands (set echo on)\"},\t\t/* USAGE_ECHO */\n\t{336658557, \"\\t-ex(tract)              extract metadata\"},\t\t/* USAGE_EXTRACT */\n\t{336658558, \"\\t-i(nput) <file>         input file (set input)\"},\t\t/* USAGE_INPUT */\n\t{336658559, \"\\t-m(erge)                merge standard error\"},\t\t/* USAGE_MERGE */\n\t{336658560, \"\\t-m2                     merge diagnostic\"},\t\t/* USAGE_MERGE2 */\n\t{336658561, \"\\t-n(oautocommit)         no autocommit DDL (set autoddl off)\"},\t\t/* USAGE_NOAUTOCOMMIT */\n\t{336658562, \"\\t-now(arnings)           do not show warnings\"},\t\t/* USAGE_NOWARN */\n\t{336658563, \"\\t-o(utput) <file>        output file (set output)\"},\t\t/* USAGE_OUTPUT */\n\t{336658564, \"\\t-pag(elength) <size>    page length\"},\t\t/* USAGE_PAGE */\n\t{336658565, \"\\t-p(assword) <password>  connection password\"},\t\t/* USAGE_PASSWORD */\n\t{336658566, \"\\t-q(uiet)                do not show the message \\\"Use CONNECT...\\\"\"},\t\t/* USAGE_QUIET */\n\t{336658567, \"\\t-r(ole) <role>          role name\"},\t\t/* USAGE_ROLE */\n\t{336658568, \"\\t-r2 <role>              role (uses quoted identifier)\"},\t\t/* USAGE_ROLE2 */\n\t{336658569, \"\\t-s(qldialect) <dialect> SQL dialect (set sql dialect)\"},\t\t/* USAGE_SQLDIALECT */\n\t{336658570, \"\\t-t(erminator) <term>    command terminator (set term)\"},\t\t/* USAGE_TERM */\n\t{336658571, \"\\t-u(ser) <user>          user name\"},\t\t/* USAGE_USER */\n\t{336658572, \"\\t-x                      extract metadata\"},\t\t/* USAGE_XTRACT */\n\t{336658573, \"\\t-z                      show program and server version\"},\t\t/* USAGE_VERSION */\n\t{336658574, \"missing argument for switch \\\"{0}\\\"\"},\t\t/* USAGE_NOARG */\n\t{336658575, \"argument \\\"{0}\\\" for switch \\\"{1}\\\" is not an integer\"},\t\t/* USAGE_NOTINT */\n\t{336658576, \"value \\\"{0}\\\" for switch \\\"{1}\\\" is out of range\"},\t\t/* USAGE_RANGE */\n\t{336658577, \"switch \\\"{0}\\\" or its equivalent used more than once\"},\t\t/* USAGE_DUPSW */\n\t{336658578, \"more than one database name: \\\"{0}\\\", \\\"{1}\\\"\"},\t\t/* USAGE_DUPDB */\n\t{336658579, \"No dependencies for {0} were found\"},\t\t/* NO_DEPENDENCIES */\n\t{336658580, \"There is no collation {0} in this database\"},\t\t/* NO_COLLATION */\n\t{336658581, \"There are no user-defined collations in this database\"},\t\t/* NO_COLLATIONS */\n\t{336658582, \"Collations:\"},\t\t/* MSG_COLLATIONS */\n\t{336658583, \"There are no security classes for {0}\"},\t\t/* NO_SECCLASS */\n\t{336658584, \"There is no database-wide security class\"},\t\t/* NO_DB_WIDE_SECCLASS */\n\t{336658585, \"Cannot get server version without database connection\"},\t\t/* CANNOT_GET_SRV_VER */\n\t{336658586, \"\\t-nod(btriggers)         do not run database triggers\"},\t\t/* USAGE_NODBTRIGGERS */\n\t{336658587, \"\\t-tr(usted)              use trusted authentication\"},\t\t/* USAGE_TRUSTED */\n\t{336658588, \"BULK> \"},\t\t/* BULK_PROMPT */\n\t{336658589, \"There are no connected users\"},\t\t/* NO_CONNECTED_USERS */\n\t{336658590, \"Users in the database\"},\t\t/* USERS_IN_DB */\n\t{336658591, \"Output was truncated\"},\t\t/* OUTPUT_TRUNCATED */\n\t{336658592, \"Valid options are:\"},\t\t/* VALID_OPTIONS */\n\t{336658593, \"\\t-f(etch_password)       fetch password from file\"},\t\t/* USAGE_FETCH */\n\t{336658594, \"could not open password file {0}, errno {1}\"},\t\t/* PASS_FILE_OPEN */\n\t{336658595, \"could not read password file {0}, errno {1}\"},\t\t/* PASS_FILE_READ */\n\t{336658596, \"empty password file {0}\"},\t\t/* EMPTY_PASS */\n\t{336658597, \"    SET MAXROWS [<n>]      -- limit select stmt to <n> rows, zero is no limit\"},\t\t/* HLP_SETMAXROWS */\n\t{336658598, \"There is no package {0} in this database\"},\t\t/* NO_PACKAGE */\n\t{336658599, \"There are no packages in this database\"},\t\t/* NO_PACKAGES */\n\t{336658600, \"There is no schema {0} in this database\"},\t\t/* NO_SCHEMA */\n\t{336658601, \"There are no schemas in this database\"},\t\t/* NO_SCHEMAS */\n\t{336658602, \"Unable to convert {0} to a number for MAXROWS option\"},\t\t/* MAXROWS_INVALID */\n\t{336658603, \"Value {0} for MAXROWS is out of range. Max value is {1}\"},\t\t/* MAXROWS_OUTOF_RANGE */\n\t{336658604, \"The value ({0}) for MAXROWS must be zero or greater\"},\t\t/* MAXROWS_NEGATIVE */\n\t{336658605, \"    SET EXPLAIN            -- toggle display of query access plan in the explained form\"},\t\t/* HLP_SETEXPLAIN */\n\t{336658606, \"There is no privilege granted on generator {0} in this database\"},\t\t/* NO_GRANT_ON_GEN */\n\t{336658607, \"There is no privilege granted on exception {0} in this database\"},\t\t/* NO_GRANT_ON_XCP */\n\t{336658608, \"There is no privilege granted on domain {0} in this database\"},\t\t/* NO_GRANT_ON_FLD */\n\t{336658609, \"There is no privilege granted on character set {0} in this database\"},\t\t/* NO_GRANT_ON_CS */\n\t{336658610, \"There is no privilege granted on collation {0} in this database\"},\t\t/* NO_GRANT_ON_COLL */\n\t{336658611, \"There is no privilege granted on package {0} in this database\"},\t\t/* NO_GRANT_ON_PKG */\n\t{336658612, \"There is no privilege granted on function {0} in this database\"},\t\t/* NO_GRANT_ON_FUN */\n\t{336658613, \"Current memory = !\\nDelta memory = !\\nMax memory = !\\nElapsed time = ~ sec\\n\"},\t\t/* REPORT_NEW1 */\n\t{336658614, \"Cpu = ~ sec\\n\"},\t\t/* REPORT_NEW2 */\n\t{336658615, \"Buffers = !\\nReads = !\\nWrites = !\\nFetches = !\"},\t\t/* REPORT_NEW3 */\n\t{336658616, \"There is no mapping {0} in this database\"},\t\t/* NO_MAP */\n\t{336658617, \"There are no mappings in this database\"},\t\t/* NO_MAPS */\n\t{336658618, \"Invalid characters for SET TERMINATOR are {0}\"},\t\t/* INVALID_TERM_CHARS */\n\t{336658619, \"Records displayed: {0}\"},\t\t/* REC_DISPLAYCOUNT */\n\t{336658620, \"Full NULL columns hidden due to RecordBuff: {0}\"},\t\t/* COLUMNS_HIDDEN */\n\t{336658621, \"    SET RECORDBuf          -- toggle limited buffering and trimming of columns\"},\t\t/* HLP_SETRECORDBUF */\n\t{336658622, \"Number of DB pages used = {0}\"},\t\t/* NUMBER_USED_PAGES */\n\t{336658623, \"Number of DB pages free = {0}\"},\t\t/* NUMBER_FREE_PAGES */\n\t{336658624, \"Database encrypted\"},\t\t/* DATABASE_CRYPTED */\n\t{336658625, \"Database not encrypted\"},\t\t/* DATABASE_NOT_CRYPTED */\n\t{336658626, \"crypt thread not complete\"},\t\t/* DATABASE_CRYPT_PROCESS */\n\t{336658627, \"Roles:\"},\t\t/* MSG_ROLES */\n\t{336658628, \"Timeouts are not supported by server\"},\t\t/* NO_TIMEOUTS */\n\t{336658629, \"    SET KEEP_TRAN_params   -- toggle to keep or not to keep text of following successful SET TRANSACTION statement\"},\t\t/* HLP_SETKEEPTRAN */\n\t{336658630, \"    SET PER_TABle_stats    -- toggle display of detailed per-table statistics\"},\t\t/* HLP_SETPERTAB */\n\t{336658631, \"Statement type is not recognized\"},\t\t/* BAD_STMT_TYPE */\n\t{336658632, \"Packages:\"},\t\t/* MSG_PACKAGES */\n\t{336658633, \"There is no publication {0} in this database\"},\t\t/* NO_PUBLICATION */\n\t{336658634, \"There is no publications in this database\"},\t\t/* NO_PUBLICATIONS */\n\t{336658635, \"Publications:\"},\t\t/* MSG_PUBLICATIONS */\n\t{336658636, \"Procedures:\"},\t\t/* MSG_PROCEDURES */\n\t{336658641, \"    SET WIRE_stats         -- toggle display of wire (network) statistics\"},\t\t/* HLP_SETWIRESTATS */\n\t{336723969, \"GSEC>\"},\t\t/* GsecMsg1 */\n\t{336723970, \"gsec\"},\t\t/* GsecMsg2 */\n\t{336723971, \"ADD            add user\"},\t\t/* GsecMsg3 */\n\t{336723972, \"DELETE         delete user\"},\t\t/* GsecMsg4 */\n\t{336723973, \"DISPLAY        display user(s)\"},\t\t/* GsecMsg5 */\n\t{336723974, \"MODIFY         modify user\"},\t\t/* GsecMsg6 */\n\t{336723975, \"PW             user's password\"},\t\t/* GsecMsg7 */\n\t{336723976, \"UID            user's ID\"},\t\t/* GsecMsg8 */\n\t{336723977, \"GID            user's group ID\"},\t\t/* GsecMsg9 */\n\t{336723978, \"PROJ           user's project name\"},\t\t/* GsecMsg10 */\n\t{336723979, \"ORG            user's organization name\"},\t\t/* GsecMsg11 */\n\t{336723980, \"FNAME          user's first name\"},\t\t/* GsecMsg12 */\n\t{336723981, \"MNAME          user's middle name/initial\"},\t\t/* GsecMsg13 */\n\t{336723982, \"LNAME          user's last name\"},\t\t/* GsecMsg14 */\n\t{336723983, \"unable to open database\"},\t\t/* gsec_cant_open_db */\n\t{336723984, \"error in switch specifications\"},\t\t/* gsec_switches_error */\n\t{336723985, \"no operation specified\"},\t\t/* gsec_no_op_spec */\n\t{336723986, \"no user name specified\"},\t\t/* gsec_no_usr_name */\n\t{336723987, \"add record error\"},\t\t/* gsec_err_add */\n\t{336723988, \"modify record error\"},\t\t/* gsec_err_modify */\n\t{336723989, \"find/modify record error\"},\t\t/* gsec_err_find_mod */\n\t{336723990, \"record not found for user: {0}\"},\t\t/* gsec_err_rec_not_found */\n\t{336723991, \"delete record error\"},\t\t/* gsec_err_delete */\n\t{336723992, \"find/delete record error\"},\t\t/* gsec_err_find_del */\n\t{336723993, \"users defined for node\"},\t\t/* GsecMsg25 */\n\t{336723994, \"     user name                    uid   gid admin     full name\"},\t\t/* GsecMsg26 */\n\t{336723995, \"------------------------------------------------------------------------------------------------\"},\t\t/* GsecMsg27 */\n\t{336723996, \"find/display record error\"},\t\t/* gsec_err_find_disp */\n\t{336723997, \"invalid parameter, no switch defined\"},\t\t/* gsec_inv_param */\n\t{336723998, \"operation already specified\"},\t\t/* gsec_op_specified */\n\t{336723999, \"password already specified\"},\t\t/* gsec_pw_specified */\n\t{336724000, \"uid already specified\"},\t\t/* gsec_uid_specified */\n\t{336724001, \"gid already specified\"},\t\t/* gsec_gid_specified */\n\t{336724002, \"project already specified\"},\t\t/* gsec_proj_specified */\n\t{336724003, \"organization already specified\"},\t\t/* gsec_org_specified */\n\t{336724004, \"first name already specified\"},\t\t/* gsec_fname_specified */\n\t{336724005, \"middle name already specified\"},\t\t/* gsec_mname_specified */\n\t{336724006, \"last name already specified\"},\t\t/* gsec_lname_specified */\n\t{336724007, \"gsec version\"},\t\t/* GsecMsg39 */\n\t{336724008, \"invalid switch specified\"},\t\t/* gsec_inv_switch */\n\t{336724009, \"ambiguous switch specified\"},\t\t/* gsec_amb_switch */\n\t{336724010, \"no operation specified for parameters\"},\t\t/* gsec_no_op_specified */\n\t{336724011, \"no parameters allowed for this operation\"},\t\t/* gsec_params_not_allowed */\n\t{336724012, \"incompatible switches specified\"},\t\t/* gsec_incompat_switch */\n\t{336724013, \"gsec utility - maintains user password database\"},\t\t/* GsecMsg45 */\n\t{336724014, \"command line usage:\"},\t\t/* GsecMsg46 */\n\t{336724015, \"<command> [ <parameter> ... ]\"},\t\t/* GsecMsg47 */\n\t{336724016, \"interactive usage:\"},\t\t/* GsecMsg48 */\n\t{336724017, \"available commands:\"},\t\t/* GsecMsg49 */\n\t{336724018, \"adding a new user:\"},\t\t/* GsecMsgs50 */\n\t{336724019, \"add <name> [ <parameter> ... ]\"},\t\t/* GsecMsg51 */\n\t{336724020, \"deleting a current user:\"},\t\t/* GsecMsg52 */\n\t{336724021, \"delete <name>\"},\t\t/* GsecMsg53 */\n\t{336724022, \"displaying all users:\"},\t\t/* GsecMsg54 */\n\t{336724023, \"display\"},\t\t/* GsecMsg55 */\n\t{336724024, \"displaying one user:\"},\t\t/* GsecMsg56 */\n\t{336724025, \"display <name>\"},\t\t/* GsecMsg57 */\n\t{336724026, \"modifying a user's parameters:\"},\t\t/* GsecMsg58 */\n\t{336724027, \"modify <name> <parameter> [ <parameter> ... ]\"},\t\t/* GsecMsg59 */\n\t{336724028, \"help:\"},\t\t/* GsecMsg60 */\n\t{336724029, \"? (interactive only)\"},\t\t/* GsecMsg61 */\n\t{336724030, \"help\"},\t\t/* GsecMsg62 */\n\t{336724031, \"quit interactive session:\"},\t\t/* GsecMsg63 */\n\t{336724032, \"quit (interactive only)\"},\t\t/* GsecMsg64 */\n\t{336724033, \"available parameters:\"},\t\t/* GsecMsg65 */\n\t{336724034, \"-pw <password>\"},\t\t/* GsecMsg66 */\n\t{336724035, \"-uid <uid>\"},\t\t/* GsecMsg67 */\n\t{336724036, \"-gid <uid>\"},\t\t/* GsecMsg68 */\n\t{336724037, \"-proj <projectname>\"},\t\t/* GsecMsg69 */\n\t{336724038, \"-org <organizationname>\"},\t\t/* GsecMsg70 */\n\t{336724039, \"-fname <firstname>\"},\t\t/* GsecMsg71 */\n\t{336724040, \"-mname <middlename>\"},\t\t/* GsecMsg72 */\n\t{336724041, \"-lname <lastname>\"},\t\t/* GsecMsg73 */\n\t{336724042, \"gsec - memory allocation error\"},\n\t{336724043, \"gsec error\"},\n\t{336724044, \"Invalid user name (maximum 31 bytes allowed)\"},\t\t/* gsec_inv_username */\n\t{336724045, \"Warning - maximum 8 significant bytes of password used\"},\t\t/* gsec_inv_pw_length */\n\t{336724046, \"database already specified\"},\t\t/* gsec_db_specified */\n\t{336724047, \"database administrator name already specified\"},\t\t/* gsec_db_admin_specified */\n\t{336724048, \"database administrator password already specified\"},\t\t/* gsec_db_admin_pw_specified */\n\t{336724049, \"SQL role name already specified\"},\t\t/* gsec_sql_role_specified */\n\t{336724050, \"[ <options> ... ]\"},\t\t/* GsecMsg82 */\n\t{336724051, \"available options:\"},\t\t/* GsecMsg83 */\n\t{336724052, \"-user <database administrator name>\"},\t\t/* GsecMsg84 */\n\t{336724053, \"-password <database administrator password>\"},\t\t/* GsecMsg85 */\n\t{336724054, \"-role <database administrator SQL role name>\"},\t\t/* GsecMsg86 */\n\t{336724055, \"-database <database to manage>\"},\t\t/* GsecMsg87 */\n\t{336724056, \"-z\"},\t\t/* GsecMsg88 */\n\t{336724057, \"displaying version number:\"},\t\t/* GsecMsg89 */\n\t{336724058, \"z (interactive only)\"},\t\t/* GsecMsg90 */\n\t{336724059, \"-trusted (use trusted authentication)\"},\t\t/* GsecMsg91 */\n\t{336724060, \"invalid switch specified in interactive mode\"},\t\t/* GsecMsg92 */\n\t{336724061, \"error closing security database\"},\t\t/* GsecMsg93 */\n\t{336724062, \"error releasing request in security database\"},\t\t/* GsecMsg94 */\n\t{336724063, \"-fetch_password <file to fetch password from>\"},\t\t/* GsecMsg95 */\n\t{336724064, \"error fetching password from file\"},\t\t/* GsecMsg96 */\n\t{336724065, \"error changing AUTO ADMINS MAPPING in security database\"},\t\t/* GsecMsg97 */\n\t{336724066, \"changing admins mapping to RDB$ADMIN role in security database:\"},\t\t/* GsecMsg98 */\n\t{336724067, \"invalid parameter for -MAPPING, only SET or DROP is accepted\"},\t\t/* GsecMsg99 */\n\t{336724068, \"mapping {set|drop}\"},\t\t/* GsecMsg100 */\n\t{336724069, \"use gsec -? to get help\"},\t\t/* GsecMsg101 */\n\t{336724070, \"-admin {yes|no}\"},\t\t/* GsecMsg102 */\n\t{336724071, \"invalid parameter for -ADMIN, only YES or NO is accepted\"},\t\t/* GsecMsg103 */\n\t{336724072, \"not enough privileges to complete operation\"},\t\t/* GsecMsg104 */\n\t{336920577, \"found unknown switch\"},\t\t/* gstat_unknown_switch */\n\t{336920578, \"please retry, giving a database name\"},\t\t/* gstat_retry */\n\t{336920579, \"Wrong ODS version, expected {0}, encountered {1}\"},\t\t/* gstat_wrong_ods */\n\t{336920580, \"Unexpected end of database file.\"},\t\t/* gstat_unexpected_eof */\n\t{336920581, \"gstat version {0}\"},\n\t{336920582, \"\\nDatabase \\\"{0}\\\"\"},\n\t{336920583, \"\\n\\nDatabase file sequence:\"},\n\t{336920584, \"File {0} continues as file {1}\"},\n\t{336920585, \"File {0} is the {1} file\"},\n\t{336920586, \"\\nAnalyzing database pages ...\"},\n\t{336920587, \"    Primary pointer page: {0}, Index root page: {1}\"},\n\t{336920588, \"    Data pages: {0}, data page slots: {1}, average fill: {2}\"},\n\t{336920589, \"    Fill distribution:\"},\n\t{336920590, \"    Index {0} ({1})\"},\n\t{336920591, \"\\tDepth: {0}, leaf buckets: {1}, nodes: {2}\"},\n\t{336920592, \"\\tAverage data length: {0}, total dup: {1}, max dup: {2}\"},\n\t{336920593, \"\\tFill distribution:\"},\n\t{336920594, \"    Expected data on page {0}\"},\n\t{336920595, \"    Expected b-tree bucket on page {0} from {1}\"},\n\t{336920596, \"unknown switch \\\"{0}\\\"\"},\n\t{336920597, \"Available switches:\"},\n\t{336920598, \"    -a      analyze data and index pages\"},\n\t{336920599, \"    -d      analyze data pages\"},\n\t{336920600, \"    -h      analyze header page ONLY\"},\n\t{336920601, \"    -i      analyze index leaf pages\"},\n\t{336920602, \"    -l      analyze log page\"},\n\t{336920603, \"    -s      analyze system relations in addition to user tables\"},\n\t{336920604, \"    -z      display version number\"},\n\t{336920605, \"Can't open database file {0}\"},\t\t/* gstat_open_err */\n\t{336920606, \"Can't read a database page\"},\t\t/* gstat_read_err */\n\t{336920607, \"System memory exhausted\"},\t\t/* gstat_sysmemex */\n\t{336920608, \"    -u      username\"},\t\t/* gstat_username */\n\t{336920609, \"    -p      password\"},\t\t/* gstat_password */\n\t{336920610, \"    -r      analyze average record and version length\"},\n\t{336920611, \"    -t      tablename <tablename2...> (case sensitive)\"},\n\t{336920612, \"    -tr     use trusted authentication\"},\n\t{336920613, \"    -fetch  fetch password from file\"},\n\t{336920614, \"option -h is incompatible with options -a, -d, -i, -r, -s and -t\"},\n\t{336920615, \"usage:   gstat [options] <database> or gstat <database> [options]\"},\n\t{336920616, \"database name was already specified\"},\n\t{336920617, \"option -t needs a table name\"},\n\t{336920618, \"option -t got a too long table name {0}\"},\n\t{336920619, \"option -t accepts several table names only if used after <database>\"},\n\t{336920620, \"table \\\"{0}\\\" not found\"},\n\t{336920621, \"use gstat -? to get help\"},\n\t{336920622, \"    Primary pages: {0}, secondary pages: {1}, swept pages: {2}\"},\n\t{336920623, \"    Big record pages: {0}\"},\n\t{336920624, \"    Blobs: {0}, total length: {1}, blob pages: {2}\"},\n\t{336920625, \"        Level 0: {0}, Level 1: {1}, Level 2: {2}\"},\n\t{336920626, \"option -e is incompatible with options -a, -d, -h, -i, -r, -s and -t\"},\n\t{336920627, \"    -e      analyze database encryption\"},\n\t{336920628, \"Data pages: total {0}, encrypted {1}, non-crypted {2}\"},\n\t{336920629, \"Index pages: total {0}, encrypted {1}, non-crypted {2}\"},\n\t{336920630, \"Blob pages: total {0}, encrypted {1}, non-crypted {2}\"},\n\t{336920631, \"no encrypted database support, only -e and -h can be used\"},\n\t{336920632, \"    Empty pages: {0}, full pages: {1}\"},\n\t{336920633, \"    -role   SQL role name\"},\n\t{336920634, \"Other pages: total {0}, ENCRYPTED {1} (DB problem!), non-crypted {2}\"},\n\t{336920635, \"Gstat execution time {0}\"},\n\t{336920636, \"Gstat completion time {0}\"},\n\t{336920637, \"    Expected page inventory page {0}\"},\n\t{336920638, \"Generator pages: total {0}, encrypted {1}, non-crypted {2}\"},\n\t{336920639, \"    Table size: {0} bytes\"},\n\t{336920640, \"        Level {0}: {1}, total length: {2}, blob pages: {3}\"},\n\t{336986113, \"Wrong value for access mode\"},\t\t/* fbsvcmgr_bad_am */\n\t{336986114, \"Wrong value for write mode\"},\t\t/* fbsvcmgr_bad_wm */\n\t{336986115, \"Wrong value for reserve space\"},\t\t/* fbsvcmgr_bad_rs */\n\t{336986116, \"Unknown tag ({0}) in info_svr_db_info block after isc_svc_query()\"},\t\t/* fbsvcmgr_info_err */\n\t{336986117, \"Unknown tag ({0}) in isc_svc_query() results\"},\t\t/* fbsvcmgr_query_err */\n\t{336986118, \"Unknown switch \\\"{0}\\\"\"},\t\t/* fbsvcmgr_switch_unknown */\n\t{336986119, \"Service Manager Version\"},\n\t{336986120, \"Server version\"},\n\t{336986121, \"Server implementation\"},\n\t{336986122, \"Path to firebird.msg\"},\n\t{336986123, \"Server root\"},\n\t{336986124, \"Path to lock files\"},\n\t{336986125, \"Security database\"},\n\t{336986126, \"Databases\"},\n\t{336986127, \"   Database in use\"},\n\t{336986128, \"   Number of attachments\"},\n\t{336986129, \"   Number of databases\"},\n\t{336986130, \"Information truncated\"},\n\t{336986131, \"Usage: fbsvcmgr manager-name switches...\"},\n\t{336986132, \"Manager-name should be service_mgr, may be prefixed with host name\"},\n\t{336986133, \"according to common rules (host:service_mgr, \\\\\\\\host\\\\service_mgr).\"},\n\t{336986134, \"Switches exactly match SPB tags, used in abbreviated form.\"},\n\t{336986135, \"Remove isc_, spb_ and svc_ parts of tag and you will get the switch.\"},\n\t{336986136, \"For example: isc_action_svc_backup is specified as action_backup,\"},\n\t{336986137, \"             isc_spb_dbname => dbname,\"},\n\t{336986138, \"             isc_info_svc_implementation => info_implementation,\"},\n\t{336986139, \"             isc_spb_prp_db_online => prp_db_online and so on.\"},\n\t{336986140, \"You may specify single action or multiple info items when calling fbsvcmgr once.\"},\n\t{336986141, \"Full command line samples:\"},\n\t{336986142, \"fbsvcmgr service_mgr user sysdba password masterkey action_db_stats dbname employee sts_hdr_pages\"},\n\t{336986143, \"  (will list header info in database employee on local machine)\"},\n\t{336986144, \"fbsvcmgr yourserver:service_mgr user sysdba password masterkey info_server_version info_svr_db_info\"},\n\t{336986145, \"  (will show firebird version and databases usage on yourserver)\"},\n\t{336986146, \"Transaction in limbo\"},\n\t{336986147, \"Multidatabase transaction in limbo\"},\n\t{336986148, \"Host Site\"},\n\t{336986149, \"Transaction\"},\n\t{336986150, \"has been prepared\"},\n\t{336986151, \"has been committed\"},\n\t{336986152, \"has been rolled back\"},\n\t{336986153, \"is not available\"},\n\t{336986154, \"Remote Site\"},\n\t{336986155, \"Database Path\"},\n\t{336986156, \"Automated recovery would commit this transaction\"},\n\t{336986157, \"Automated recovery would rollback this transaction\"},\n\t{336986158, \"No idea should it be commited or rolled back\"},\n\t{336986159, \"Wrong value for shutdown mode\"},\t\t/* fbsvcmgr_bad_sm */\n\t{336986160, \"could not open file {0}\"},\t\t/* fbsvcmgr_fp_open */\n\t{336986161, \"could not read file {0}\"},\t\t/* fbsvcmgr_fp_read */\n\t{336986162, \"empty file {0}\"},\t\t/* fbsvcmgr_fp_empty */\n\t{336986163, \"Firebird Services Manager version {0}\"},\n\t{336986164, \"Invalid or missing parameter for switch {0}\"},\t\t/* fbsvcmgr_bad_arg */\n\t{336986165, \"To get full list of known services run with -? switch\"},\n\t{336986166, \"Attaching to services manager:\"},\n\t{336986167, \"Information requests:\"},\n\t{336986168, \"Actions:\"},\n\t{336986169, \"Server capabilities:\"},\n\t{336986170, \"Unknown tag ({0}) in isc_info_svc_limbo_trans block after isc_svc_query()\"},\t\t/* fbsvcmgr_info_limbo */\n\t{336986171, \"Unknown tag ({0}) in isc_spb_tra_state block after isc_svc_query()\"},\t\t/* fbsvcmgr_limbo_state */\n\t{336986172, \"Unknown tag ({0}) in isc_spb_tra_advise block after isc_svc_query()\"},\t\t/* fbsvcmgr_limbo_advise */\n\t{336986173, \"Wrong value for replica mode\"},\t\t/* fbsvcmgr_bad_rm */\n\t{337051649, \"Switches trusted_user and trusted_role are not supported from command line\"},\t\t/* utl_trusted_switch */\n\t{337117185, \"ERROR: \"},\n\t{337117186, \"Physical Backup Manager    Copyright (C) 2004 Firebird development team\"},\n\t{337117187, \"  Original idea is of Sean Leyne <sean@broadviewsoftware.com>\"},\n\t{337117188, \"  Designed and implemented by Nickolay Samofatov <skidder@bssys.com>\"},\n\t{337117189, \"  This work was funded through a grant from BroadView Software, Inc.\\\\n\"},\n\t{337117190, \"Usage: nbackup <options>\"},\n\t{337117191, \"exclusive options are:\"},\n\t{337117192, \"  -L(OCK) <database>                     Lock database for filesystem copy\"},\n\t{337117193, \"  -UN(LOCK) <database>                   Unlock previously locked database\"},\n\t{337117194, \"  -F(IXUP) <database>                    Fixup database after filesystem copy\"},\n\t{337117195, \"  -B(ACKUP) <level>|<GUID> <db> [<file>] Create incremental backup\"},\n\t{337117196, \"  -R(ESTORE) <db> [<file0> [<file1>...]] Restore incremental backup\"},\n\t{337117197, \"  -U(SER) <user>                         User name\"},\n\t{337117198, \"  -P(ASSWORD) <password>                 Password\"},\n\t{337117199, \"  -FETCH_PASSWORD <file>                 Fetch password from file\"},\n\t{337117200, \"  -NOD(BTRIGGERS)                        Do not run database triggers\"},\n\t{337117201, \"  -S(IZE)                                Print database size in pages after lock\"},\n\t{337117202, \"  -Z                                     Print program version\"},\n\t{337117203, \"Notes:\"},\n\t{337117204, \"  <database> may specify database alias.\"},\n\t{337117205, \"  Incremental backups of multi-file databases are not supported yet.\"},\n\t{337117206, \"  \\\"stdout\\\" may be used as a value of <filename> for -B option.\"},\n\t{337117207, \"PROBLEM ON \\\"{0}\\\".\"},\n\t{337117208, \"general options are:\"},\n\t{337117209, \"switches can be abbreviated to the unparenthesized characters\"},\n\t{337117210, \"  Option -S(IZE) only is valid together with -L(OCK).\"},\n\t{337117211, \"  For historical reasons, -N is equivalent to -UN(LOCK)\"},\n\t{337117212, \"  and -T is equivalent to -NOD(BTRIGGERS).\"},\n\t{337117213, \"Missing parameter for switch {0}\"},\t\t/* nbackup_missing_param */\n\t{337117214, \"Only one of -LOCK, -UNLOCK, -FIXUP, -BACKUP or -RESTORE should be specified\"},\t\t/* nbackup_allowed_switches */\n\t{337117215, \"Unrecognized parameter {0}\"},\t\t/* nbackup_unknown_param */\n\t{337117216, \"Unknown switch {0}\"},\t\t/* nbackup_unknown_switch */\n\t{337117217, \"Fetch password can't be used in service mode\"},\t\t/* nbackup_nofetchpw_svc */\n\t{337117218, \"Error working with password file \\\"{0}\\\"\"},\t\t/* nbackup_pwfile_error */\n\t{337117219, \"Switch -SIZE can be used only with -LOCK\"},\t\t/* nbackup_size_with_lock */\n\t{337117220, \"None of -LOCK, -UNLOCK, -FIXUP, -BACKUP or -RESTORE specified\"},\t\t/* nbackup_no_switch */\n\t{337117221, \"Failure: \"},\n\t{337117222, \"Enter name of the backup file of level {0} (\\\".\\\" - do not restore further):\"},\n\t{337117223, \"IO error reading file: {0}\"},\t\t/* nbackup_err_read */\n\t{337117224, \"IO error writing file: {0}\"},\t\t/* nbackup_err_write */\n\t{337117225, \"IO error seeking file: {0}\"},\t\t/* nbackup_err_seek */\n\t{337117226, \"Error opening database file: {0}\"},\t\t/* nbackup_err_opendb */\n\t{337117227, \"Error in posix_fadvise({0}) for database {1}\"},\t\t/* nbackup_err_fadvice */\n\t{337117228, \"Error creating database file: {0}\"},\t\t/* nbackup_err_createdb */\n\t{337117229, \"Error opening backup file: {0}\"},\t\t/* nbackup_err_openbk */\n\t{337117230, \"Error creating backup file: {0}\"},\t\t/* nbackup_err_createbk */\n\t{337117231, \"Unexpected end of database file {0}\"},\t\t/* nbackup_err_eofdb */\n\t{337117232, \"Database {0} is not in state ({1}) to be safely fixed up\"},\t\t/* nbackup_fixup_wrongstate */\n\t{337117233, \"Database error\"},\t\t/* nbackup_err_db */\n\t{337117234, \"Username or password is too long\"},\t\t/* nbackup_userpw_toolong */\n\t{337117235, \"Cannot find record for database \\\"{0}\\\" backup level {1} in the backup history\"},\t\t/* nbackup_lostrec_db */\n\t{337117236, \"Internal error. History query returned null SCN or GUID\"},\t\t/* nbackup_lostguid_db */\n\t{337117237, \"Unexpected end of file when reading header of database file \\\"{0}\\\" (stage {1})\"},\t\t/* nbackup_err_eofhdrdb */\n\t{337117238, \"Internal error. Database file is not locked. Flags are {0}\"},\t\t/* nbackup_db_notlock */\n\t{337117239, \"Internal error. Cannot get backup guid clumplet\"},\t\t/* nbackup_lostguid_bk */\n\t{337117240, \"Internal error. Database page {0} had been changed during backup (page SCN={1}, backup SCN={2})\"},\t\t/* nbackup_page_changed */\n\t{337117241, \"Database file size is not a multiple of page size\"},\t\t/* nbackup_dbsize_inconsistent */\n\t{337117242, \"Level 0 backup is not restored\"},\t\t/* nbackup_failed_lzbk */\n\t{337117243, \"Unexpected end of file when reading header of backup file: {0}\"},\t\t/* nbackup_err_eofhdrbk */\n\t{337117244, \"Invalid incremental backup file: {0}\"},\t\t/* nbackup_invalid_incbk */\n\t{337117245, \"Unsupported version {0} of incremental backup file: {1}\"},\t\t/* nbackup_unsupvers_incbk */\n\t{337117246, \"Invalid level {0} of incremental backup file: {1}, expected {2}\"},\t\t/* nbackup_invlevel_incbk */\n\t{337117247, \"Wrong order of backup files or invalid incremental backup file detected, file: {0}\"},\t\t/* nbackup_wrong_orderbk */\n\t{337117248, \"Unexpected end of backup file: {0}\"},\t\t/* nbackup_err_eofbk */\n\t{337117249, \"Error creating database file: {0} via copying from: {1}\"},\t\t/* nbackup_err_copy */\n\t{337117250, \"Unexpected end of file when reading header of restored database file (stage {0})\"},\t\t/* nbackup_err_eofhdr_restdb */\n\t{337117251, \"Cannot get backup guid clumplet from L0 backup\"},\t\t/* nbackup_lostguid_l0bk */\n\t{337117252, \"Physical Backup Manager version {0}\"},\n\t{337117253, \"Enter name of the backup file of level {0} (\\\".\\\" - do not restore further):\"},\n\t{337117254, \"  -D(IRECT) <ON | OFF>                   Use or not direct I/O when backing up database\"},\n\t{337117255, \"Wrong parameter {0} for switch -D, need ON or OFF\"},\t\t/* nbackup_switchd_parameter */\n\t{337117256, \"special options are:\"},\n\t{337117257, \"Terminated due to user request\"},\t\t/* nbackup_user_stop */\n\t{337117258, \"  -DE(COMPRESS) <command>                Command to extract archives during restore\"},\n\t{337117259, \"Too complex decompress command (> {0} arguments)\"},\t\t/* nbackup_deco_parse */\n\t{337117260, \"  -RO(LE) <role>                         SQL role name\"},\n\t{337117261, \"Cannot find record for database \\\"{0}\\\" backup GUID {1} in the backup history\"},\t\t/* nbackup_lostrec_guid_db */\n\t{337117262, \"  -I(NPLACE)                             Restore incremental backup(s) to existing database\"},\n\t{337117263, \"  -INPLACE option could corrupt the database that has changed since previous restore.\"},\n\t{337117264, \"  -SEQ(UENCE)                            Preserve original replication sequence\"},\n\t{337117265, \"Switch -SEQ(UENCE) can be used only with -FIXUP or -RESTORE\"},\t\t/* nbackup_seq_misuse */\n\t{337117266, \"  -CLEAN_HIST(ORY)                       Clean old records from backup history\"},\n\t{337117267, \"  -K(EEP) <N> <(R)OWS | (D)AYS>          How many recent rows (or days back from today) should be kept in the history\"},\n\t{337117268, \"Wrong parameter value for switch {0}\"},\t\t/* nbackup_wrong_param */\n\t{337117269, \"Switch -CLEAN_HISTORY can be used only with -BACKUP\"},\t\t/* nbackup_clean_hist_misuse */\n\t{337117270, \"-KEEP can be used only with -CLEAN_HISTORY\"},\t\t/* nbackup_clean_hist_missed */\n\t{337117271, \"-KEEP is required with -CLEAN_HISTORY\"},\t\t/* nbackup_keep_hist_missed */\n\t{337117272, \"-KEEP can be used one time only\"},\t\t/* nbackup_second_keep_switch */\n\t{337182721, \"Firebird Trace Manager version {0}\"},\n\t{337182722, \"ERROR: \"},\n\t{337182723, \"Firebird Trace Manager.\"},\n\t{337182724, \"Usage: fbtracemgr <action> [<parameters>]\"},\n\t{337182725, \"Actions:\"},\n\t{337182726, \"  -STA[RT]                              Start trace session\"},\n\t{337182727, \"  -STO[P]                               Stop trace session\"},\n\t{337182728, \"  -SU[SPEND]                            Suspend trace session\"},\n\t{337182729, \"  -R[ESUME]                             Resume trace session\"},\n\t{337182730, \"  -L[IST]                               List existing trace sessions\"},\n\t{337182731, \"  -Z                                    Show program version\"},\n\t{337182732, \"Action parameters:\"},\n\t{337182733, \"  -N[AME]    <string>                   Session name\"},\n\t{337182734, \"  -I[D]      <number>                   Session ID\"},\n\t{337182735, \"  -C[ONFIG]  <string>                   Trace configuration file name\"},\n\t{337182736, \"Connection parameters:\"},\n\t{337182737, \"  -SE[RVICE]  <string>                  Service name\"},\n\t{337182738, \"  -U[SER]     <string>                  User name\"},\n\t{337182739, \"  -P[ASSWORD] <string>                  Password\"},\n\t{337182740, \"  -FE[TCH]    <string>                  Fetch password from file\"},\n\t{337182741, \"  -T[RUSTED]  <string>                  Force trusted authentication\"},\n\t{337182742, \"Examples:\"},\n\t{337182743, \"  fbtracemgr -SE remote_host:service_mgr -USER SYSDBA -PASS masterkey -LIST\"},\n\t{337182744, \"  fbtracemgr -SE service_mgr -START -NAME my_trace -CONFIG my_cfg.txt\"},\n\t{337182745, \"  fbtracemgr -SE service_mgr -SUSPEND -ID 2\"},\n\t{337182746, \"  fbtracemgr -SE service_mgr -RESUME -ID 2\"},\n\t{337182747, \"  fbtracemgr -SE service_mgr -STOP -ID 4\"},\n\t{337182748, \"Notes:\"},\n\t{337182749, \"  Press CTRL+C to stop interactive trace session\"},\n\t{337182750, \"conflicting actions \\\"{0}\\\" and \\\"{1}\\\" found\"},\t\t/* trace_conflict_acts */\n\t{337182751, \"action switch not found\"},\t\t/* trace_act_notfound */\n\t{337182752, \"switch \\\"{0}\\\" must be set only once\"},\t\t/* trace_switch_once */\n\t{337182753, \"value for switch \\\"{0}\\\" is missing\"},\t\t/* trace_param_val_miss */\n\t{337182754, \"invalid value (\\\"{0}\\\") for switch \\\"{1}\\\"\"},\t\t/* trace_param_invalid */\n\t{337182755, \"unknown switch \\\"{0}\\\" encountered\"},\t\t/* trace_switch_unknown */\n\t{337182756, \"switch \\\"{0}\\\" can be used by service only\"},\t\t/* trace_switch_svc_only */\n\t{337182757, \"switch \\\"{0}\\\" can be used by interactive user only\"},\t\t/* trace_switch_user_only */\n\t{337182758, \"mandatory parameter \\\"{0}\\\" for switch \\\"{1}\\\" is missing\"},\t\t/* trace_switch_param_miss */\n\t{337182759, \"parameter \\\"{0}\\\" is incompatible with action \\\"{1}\\\"\"},\t\t/* trace_param_act_notcompat */\n\t{337182760, \"mandatory switch \\\"{0}\\\" is missing\"},\t\t/* trace_mandatory_switch_miss */\n\t\t};\n\n\tpublic static bool TryGet(int key, out string value) => _messages.TryGetValue(key, out value);\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/IscException.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Text;\nusing System.Reflection;\nusing System.Resources;\nusing System.Linq;\nusing System.Runtime.Serialization;\nusing System.IO;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal sealed class IscException : Exception\n{\n\tprivate string _message;\n\n\tpublic List<IscError> Errors { get; private set; }\n\tpublic int ErrorCode { get; private set; }\n\tpublic string SQLSTATE { get; private set; }\n\tpublic override string Message => _message;\n\tpublic bool IsWarning => Errors.FirstOrDefault()?.IsWarning ?? false;\n\n\tprivate IscException(Exception innerException = null)\n\t\t: base(innerException?.Message, innerException)\n\t{\n\t\tErrors = new List<IscError>();\n\t}\n\n\tpublic static IscException ForBuilding()\n\t{\n\t\treturn new IscException();\n\t}\n\n\tpublic static IscException ForErrorCode(int errorCode, Exception innerException = null)\n\t{\n\t\tvar result = new IscException(innerException);\n\t\tresult.Errors.Add(new IscError(IscCodes.isc_arg_gds, errorCode));\n\t\tresult.BuildExceptionData();\n\t\treturn result;\n\t}\n\n\tpublic static IscException ForErrorCodes(IEnumerable<int> errorCodes, Exception innerException = null)\n\t{\n\t\tvar result = new IscException(innerException);\n\t\tforeach (var errorCode in errorCodes)\n\t\t{\n\t\t\tresult.Errors.Add(new IscError(IscCodes.isc_arg_gds, errorCode));\n\t\t}\n\t\tresult.BuildExceptionData();\n\t\treturn result;\n\t}\n\n\tpublic static IscException ForSQLSTATE(string sqlState, Exception innerException = null)\n\t{\n\t\tvar result = new IscException(innerException);\n\t\tresult.Errors.Add(new IscError(IscCodes.isc_arg_sql_state, sqlState));\n\t\tresult.BuildExceptionData();\n\t\treturn result;\n\t}\n\n\tpublic static IscException ForStrParam(string strParam, Exception innerException = null)\n\t{\n\t\tvar result = new IscException(innerException);\n\t\tresult.Errors.Add(new IscError(IscCodes.isc_arg_string, strParam));\n\t\tresult.BuildExceptionData();\n\t\treturn result;\n\t}\n\n\tpublic static IscException ForErrorCodeIntParam(int errorCode, int intParam, Exception innerException = null)\n\t{\n\t\tvar result = new IscException(innerException);\n\t\tresult.Errors.Add(new IscError(IscCodes.isc_arg_gds, errorCode));\n\t\tresult.Errors.Add(new IscError(IscCodes.isc_arg_number, intParam));\n\t\tresult.BuildExceptionData();\n\t\treturn result;\n\t}\n\n\tpublic static IscException ForTypeErrorCodeStrParam(int type, int errorCode, string strParam, Exception innerException = null)\n\t{\n\t\tvar result = new IscException(innerException);\n\t\tresult.Errors.Add(new IscError(type, errorCode));\n\t\tresult.Errors.Add(new IscError(IscCodes.isc_arg_string, strParam));\n\t\tresult.BuildExceptionData();\n\t\treturn result;\n\t}\n\n\tpublic static IscException ForTypeErrorCodeIntParamStrParam(int type, int errorCode, int intParam, string strParam, Exception innerException = null)\n\t{\n\t\tvar result = new IscException(innerException);\n\t\tresult.Errors.Add(new IscError(type, errorCode));\n\t\tresult.Errors.Add(new IscError(IscCodes.isc_arg_number, intParam));\n\t\tresult.Errors.Add(new IscError(IscCodes.isc_arg_string, strParam));\n\t\tresult.BuildExceptionData();\n\t\treturn result;\n\t}\n\n\tpublic static IscException ForIOException(IOException exception)\n\t{\n\t\treturn ForErrorCodes(new[] { IscCodes.isc_net_write_err, IscCodes.isc_net_read_err }, exception);\n\t}\n\n\tpublic void BuildExceptionData()\n\t{\n\t\tBuildErrorCode();\n\t\tBuildSqlState();\n\t\tBuildExceptionMessage();\n\t}\n\n\tprivate void BuildErrorCode()\n\t{\n\t\tErrorCode = Errors.Count != 0 ? Errors[0].ErrorCode : 0;\n\t}\n\n\tprivate void BuildSqlState()\n\t{\n\t\tvar error = Errors.Find(e => e.Type == IscCodes.isc_arg_sql_state);\n\t\t// step #1, maybe we already have a SQLSTATE stuffed in the status vector\n\t\tif (error != null)\n\t\t{\n\t\t\tSQLSTATE = error.StrParam;\n\t\t}\n\t\t// step #2, see if we can find a mapping.\n\t\telse\n\t\t{\n\t\t\tSQLSTATE = SqlStateMapping.TryGet(ErrorCode, out var value)\n\t\t\t\t? value\n\t\t\t\t: string.Empty;\n\t\t}\n\t}\n\n\tprivate void BuildExceptionMessage()\n\t{\n\t\tvar builder = new StringBuilder();\n\n\t\tfor (var i = 0; i < Errors.Count; i++)\n\t\t{\n\t\t\tif (Errors[i].Type == IscCodes.isc_arg_gds || Errors[i].Type == IscCodes.isc_arg_warning)\n\t\t\t{\n\t\t\t\tvar code = Errors[i].ErrorCode;\n\t\t\t\tvar message = IscErrorMessages.TryGet(code, out var value)\n\t\t\t\t\t? value\n\t\t\t\t\t: BuildDefaultErrorMessage(code);\n\n\t\t\t\tvar args = new List<string>();\n\t\t\t\tvar index = i + 1;\n\t\t\t\twhile (index < Errors.Count && Errors[index].IsArgument)\n\t\t\t\t{\n\t\t\t\t\targs.Add(Errors[index++].StrParam);\n\t\t\t\t\ti++;\n\t\t\t\t}\n\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tswitch (code)\n\t\t\t\t\t{\n\t\t\t\t\t\tcase IscCodes.isc_except:\n\t\t\t\t\t\t\t// Custom exception\tadd\tthe\tfirst argument as error\tcode\n\t\t\t\t\t\t\tErrorCode = Convert.ToInt32(args[0], CultureInfo.InvariantCulture);\n\t\t\t\t\t\t\t// ignoring the message - historical reason\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase IscCodes.isc_except2:\n\t\t\t\t\t\t\t// Custom exception. Next Error should be the exception name.\n\t\t\t\t\t\t\t// And the next one the Exception message\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase IscCodes.isc_stack_trace:\n\t\t\t\t\t\t\t// The next error contains the PSQL Stack Trace\n\t\t\t\t\t\t\tAppendMessage(builder, message, args);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tAppendMessage(builder, message, args);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch\n\t\t\t\t{\n\t\t\t\t\tmessage = BuildDefaultErrorMessage(code);\n\t\t\t\t\tAppendMessage(builder, message, args);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Update error\tcollection only\twith the main error\n\t\tvar mainError = new IscError(ErrorCode);\n\t\tmainError.Message = builder.ToString();\n\n\t\tErrors.Add(mainError);\n\n\t\t// Update exception\tmessage\n\t\t_message = builder.ToString();\n\t}\n\n\tprivate string BuildDefaultErrorMessage(int code)\n\t{\n\t\treturn string.Format(CultureInfo.CurrentCulture, \"No message for error code {0} found.\", code);\n\t}\n\n\tprivate static void AppendMessage(StringBuilder builder, string message, List<string> args)\n\t{\n\t\tif (builder.Length > 0)\n\t\t{\n\t\t\tbuilder.Append(Environment.NewLine);\n\t\t}\n\t\tbuilder.AppendFormat(CultureInfo.CurrentCulture, message, args.ToArray());\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/IscHelper.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class IscHelper\n{\n\tpublic static List<object> ParseDatabaseInfo(byte[] buffer, Charset charset)\n\t{\n\t\tvar info = new List<object>();\n\n\t\tvar pos = 0;\n\t\tvar length = 0;\n\t\tvar type = 0;\n\n\t\twhile ((type = buffer[pos++]) != IscCodes.isc_info_end)\n\t\t{\n\t\t\tlength = (int)VaxInteger(buffer, pos, 2);\n\t\t\tpos += 2;\n\n\t\t\tswitch (type)\n\t\t\t{\n\t\t\t\tcase IscCodes.isc_info_error:\n\t\t\t\t\tthrow FbException.Create(\"Received error response.\");\n\n\t\t\t\tcase IscCodes.isc_info_allocation:\n\t\t\t\tcase IscCodes.isc_info_ods_version:\n\t\t\t\tcase IscCodes.isc_info_ods_minor_version:\n\t\t\t\tcase IscCodes.isc_info_page_size:\n\t\t\t\tcase IscCodes.isc_info_current_memory:\n\t\t\t\tcase IscCodes.isc_info_max_memory:\n\t\t\t\tcase IscCodes.isc_info_num_buffers:\n\t\t\t\tcase IscCodes.isc_info_sweep_interval:\n\t\t\t\tcase IscCodes.isc_info_fetches:\n\t\t\t\tcase IscCodes.isc_info_marks:\n\t\t\t\tcase IscCodes.isc_info_reads:\n\t\t\t\tcase IscCodes.isc_info_writes:\n\t\t\t\tcase IscCodes.isc_info_backout_count:\n\t\t\t\tcase IscCodes.isc_info_delete_count:\n\t\t\t\tcase IscCodes.isc_info_expunge_count:\n\t\t\t\tcase IscCodes.isc_info_insert_count:\n\t\t\t\tcase IscCodes.isc_info_purge_count:\n\t\t\t\tcase IscCodes.isc_info_read_idx_count:\n\t\t\t\tcase IscCodes.isc_info_read_seq_count:\n\t\t\t\tcase IscCodes.isc_info_update_count:\n\t\t\t\tcase IscCodes.isc_info_db_size_in_pages:\n\t\t\t\tcase IscCodes.isc_info_oldest_transaction:\n\t\t\t\tcase IscCodes.isc_info_oldest_active:\n\t\t\t\tcase IscCodes.isc_info_oldest_snapshot:\n\t\t\t\tcase IscCodes.isc_info_next_transaction:\n\t\t\t\tcase IscCodes.isc_info_active_transactions:\n\t\t\t\tcase IscCodes.isc_info_active_tran_count:\n\t\t\t\tcase IscCodes.fb_info_next_attachment:\n\t\t\t\tcase IscCodes.fb_info_next_statement:\n\t\t\t\tcase IscCodes.fb_info_protocol_version:\n\t\t\t\tcase IscCodes.fb_info_statement_timeout_db:\n\t\t\t\tcase IscCodes.fb_info_statement_timeout_att:\n\t\t\t\t\tinfo.Add(VaxInteger(buffer, pos, length));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_info_no_reserve:\n\t\t\t\tcase IscCodes.isc_info_forced_writes:\n\t\t\t\tcase IscCodes.isc_info_db_read_only:\n\t\t\t\t\tinfo.Add(buffer[pos] == 1);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_info_user_names:\n\t\t\t\t\tinfo.Add(charset.GetString(buffer, pos + 1, buffer[pos]));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.fb_info_wire_crypt:\n\t\t\t\tcase IscCodes.fb_info_crypt_plugin:\n\t\t\t\tcase IscCodes.fb_info_db_file_id:\n\t\t\t\t\tinfo.Add(charset.GetString(buffer, pos, length));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.fb_info_db_guid:\n\t\t\t\t\tinfo.Add(Guid.ParseExact(charset.GetString(buffer, pos, length), \"B\"));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_info_base_level:\n\t\t\t\t\tinfo.Add(string.Format(CultureInfo.CurrentCulture, \"{0}.{1}\", buffer[pos], buffer[pos + 1]));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_info_db_id:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar dbFile = charset.GetString(buffer, pos + 2, buffer[pos + 1]);\n\t\t\t\t\t\tvar sitePos = pos + 2 + buffer[pos + 1];\n\t\t\t\t\t\tint siteLength = buffer[sitePos];\n\t\t\t\t\t\tvar siteName = charset.GetString(buffer, sitePos + 1, siteLength);\n\n\t\t\t\t\t\tsitePos += siteLength + 1;\n\t\t\t\t\t\tsiteLength = buffer[sitePos];\n\t\t\t\t\t\tsiteName += \".\" + charset.GetString(buffer, sitePos + 1, siteLength);\n\n\t\t\t\t\t\tinfo.Add(siteName + \":\" + dbFile);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_info_implementation:\n\t\t\t\t\tinfo.Add(string.Format(CultureInfo.CurrentCulture, \"{0}.{1}.{2}\", buffer[pos], buffer[pos + 1], buffer[pos + 2]));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_info_isc_version:\n\t\t\t\tcase IscCodes.isc_info_firebird_version:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar messagePosition = pos;\n\t\t\t\t\t\tvar count = buffer[messagePosition];\n\t\t\t\t\t\tfor (var i = 0; i < count; i++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvar messageLength = buffer[messagePosition + 1];\n\t\t\t\t\t\t\tinfo.Add(charset.GetString(buffer, messagePosition + 2, messageLength));\n\t\t\t\t\t\t\tmessagePosition += 1 + messageLength;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_info_db_class:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar serverClass = VaxInteger(buffer, pos, length);\n\t\t\t\t\t\tinfo.Add(serverClass switch\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tIscCodes.isc_info_db_class_classic_access => \"CLASSIC SERVER\",\n\t\t\t\t\t\t\tIscCodes.isc_info_db_class_server_access => \"SUPER SERVER\",\n\t\t\t\t\t\t\t_ => throw new ArgumentOutOfRangeException(nameof(serverClass), $\"{nameof(serverClass)}={serverClass}\"),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_info_creation_date:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar date = TypeDecoder.DecodeDate((int)VaxInteger(buffer, pos, 4));\n\t\t\t\t\t\tvar time = TypeDecoder.DecodeTime((int)VaxInteger(buffer, pos + 4, 4));\n\t\t\t\t\t\tinfo.Add(date.Add(time));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.fb_info_replica_mode:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar mode = VaxInteger(buffer, pos, length);\n\t\t\t\t\t\tinfo.Add(mode switch\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t0 => \"NONE\",\n\t\t\t\t\t\t\t1 => \"READ ONLY\",\n\t\t\t\t\t\t\t2 => \"READ WRITE\",\n\t\t\t\t\t\t\t_ => throw new ArgumentOutOfRangeException(nameof(mode), $\"{nameof(mode)}={mode}\"),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.fb_info_creation_timestamp_tz:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar date = TypeDecoder.DecodeDate((int)VaxInteger(buffer, pos, 4));\n\t\t\t\t\t\tvar time = TypeDecoder.DecodeTime((int)VaxInteger(buffer, pos + 4, 4));\n\t\t\t\t\t\tvar tzId = (ushort)VaxInteger(buffer, pos + 4 + 4, 4);\n\t\t\t\t\t\tvar dt = date.Add(time);\n\t\t\t\t\t\tdt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);\n\t\t\t\t\t\tinfo.Add(TypeHelper.CreateZonedDateTime(dt, tzId, null));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new ArgumentOutOfRangeException(nameof(type), $\"{nameof(type)}={type}\");\n\t\t\t}\n\n\t\t\tpos += length;\n\t\t}\n\n\t\treturn info;\n\t}\n\n\tpublic static List<object> ParseTransactionInfo(byte[] buffer, Charset charset)\n\t{\n\t\tvar info = new List<object>();\n\n\t\tvar pos = 0;\n\t\tvar length = 0;\n\t\tvar type = 0;\n\n\t\twhile ((type = buffer[pos++]) != IscCodes.isc_info_end)\n\t\t{\n\t\t\tlength = (int)VaxInteger(buffer, pos, 2);\n\t\t\tpos += 2;\n\n\t\t\tswitch (type)\n\t\t\t{\n\t\t\t\tcase IscCodes.isc_info_error:\n\t\t\t\t\tthrow FbException.Create(\"Received error response.\");\n\n\t\t\t\tcase IscCodes.fb_info_tra_snapshot_number:\n\t\t\t\t\tinfo.Add(VaxInteger(buffer, pos, length));\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new ArgumentOutOfRangeException(nameof(type), $\"{nameof(type)}={type}\");\n\t\t\t}\n\n\t\t\tpos += length;\n\t\t}\n\n\t\treturn info;\n\t}\n\n\tpublic static long VaxInteger(byte[] buffer, int index, int length)\n\t{\n\t\tvar value = 0L;\n\t\tvar shift = 0;\n\t\tvar i = index;\n\t\twhile (--length >= 0)\n\t\t{\n\t\t\tvalue += (buffer[i++] & 0xffL) << shift;\n\t\t\tshift += 8;\n\t\t}\n\t\treturn value;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/NamedParametersParser.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class NamedParametersParser\n{\n\tpublic static (string sql, IReadOnlyList<string> parameters) Parse(string sql)\n\t{\n\t\tvar sqlBuilder = new StringBuilder(sql.Length);\n\t\tvar paramBuilder = new StringBuilder();\n\n\t\tif (sql.IndexOf('@') == -1)\n\t\t{\n\t\t\treturn (sql, Array.Empty<string>());\n\t\t}\n\n\t\tvar namedParameters = new List<string>();\n\t\tvar inSingleQuotes = false;\n\t\tvar inDoubleQuotes = false;\n\t\tvar inParam = false;\n\t\tfor (var i = 0; i < sql.Length; i++)\n\t\t{\n\t\t\tvar sym = sql[i];\n\n\t\t\tif (inParam)\n\t\t\t{\n\t\t\t\tif (char.IsLetterOrDigit(sym) || sym == '_' || sym == '$')\n\t\t\t\t{\n\t\t\t\t\tparamBuilder.Append(sym);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tnamedParameters.Add(paramBuilder.ToString());\n\t\t\t\t\tparamBuilder.Length = 0;\n\t\t\t\t\tsqlBuilder.Append('?');\n\t\t\t\t\tsqlBuilder.Append(sym);\n\t\t\t\t\tinParam = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (sym == '\\'' && !inDoubleQuotes)\n\t\t\t\t{\n\t\t\t\t\tinSingleQuotes = !inSingleQuotes;\n\t\t\t\t}\n\t\t\t\telse if (sym == '\\\"' && !inSingleQuotes)\n\t\t\t\t{\n\t\t\t\t\tinDoubleQuotes = !inDoubleQuotes;\n\t\t\t\t}\n\t\t\t\telse if (!(inSingleQuotes || inDoubleQuotes) && sym == '@')\n\t\t\t\t{\n\t\t\t\t\tinParam = true;\n\t\t\t\t\tparamBuilder.Append(sym);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tsqlBuilder.Append(sym);\n\t\t\t}\n\t\t}\n\n\t\tif (inParam)\n\t\t{\n\t\t\tnamedParameters.Add(paramBuilder.ToString());\n\t\t\tsqlBuilder.Append('?');\n\t\t}\n\n\t\treturn (sqlBuilder.ToString(), namedParameters);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/NativeHelpers.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Concurrent;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class NativeHelpers\n{\n\tprivate static readonly ConcurrentDictionary<string, bool> _cache = new ConcurrentDictionary<string, bool>(StringComparer.Ordinal);\n\n\tpublic static void CallIfExists(string actionId, Action action)\n\t{\n\t\tif (!_cache.TryGetValue(actionId, out var executionAllowed))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\taction();\n\t\t\t\t_cache.TryAdd(actionId, true);\n\t\t\t}\n\t\t\tcatch (EntryPointNotFoundException)\n\t\t\t{\n\t\t\t\t_cache.TryAdd(actionId, false);\n\t\t\t}\n\t\t}\n\t\telse if (executionAllowed)\n\t\t{\n\t\t\taction();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/ParameterBuffer.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Net;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal abstract class ParameterBuffer\n{\n\tprivate readonly List<byte> _data;\n\n\tpublic short Length => (short)_data.Count;\n\n\tprotected ParameterBuffer()\n\t{\n\t\t_data = new List<byte>();\n\t}\n\n\tpublic byte[] ToArray()\n\t{\n\t\treturn _data.ToArray();\n\t}\n\n\tpublic void Append(int type)\n\t{\n\t\tWriteByte(type);\n\t}\n\n\tprotected void WriteByte(int value)\n\t{\n\t\tWriteByte((byte)value);\n\t}\n\n\tprotected void WriteByte(byte value)\n\t{\n\t\t_data.Add(value);\n\t}\n\n\tprotected void Write(byte value)\n\t{\n\t\tWriteByte(value);\n\t}\n\n\tprotected void Write(short value)\n\t{\n\t\tif (!BitConverter.IsLittleEndian)\n\t\t{\n\t\t\tvalue = IPAddress.NetworkToHostOrder(value);\n\t\t}\n\t\tvar buffer = BitConverter.GetBytes(value);\n\t\tWrite(buffer);\n\t}\n\n\tprotected void Write(int value)\n\t{\n\t\tif (!BitConverter.IsLittleEndian)\n\t\t{\n\t\t\tvalue = IPAddress.NetworkToHostOrder(value);\n\t\t}\n\t\tvar buffer = BitConverter.GetBytes(value);\n\t\tWrite(buffer);\n\t}\n\n\tprotected void Write(long value)\n\t{\n\t\tif (!BitConverter.IsLittleEndian)\n\t\t{\n\t\t\tvalue = IPAddress.NetworkToHostOrder(value);\n\t\t}\n\t\tvar buffer = BitConverter.GetBytes(value);\n\t\tWrite(buffer);\n\t}\n\n\tprotected void Write(byte[] buffer)\n\t{\n\t\tWrite(buffer, 0, buffer.Length);\n\t}\n\n\tprotected void Write(byte[] buffer, int offset, int count)\n\t{\n\t\t_data.AddRange(new ArraySegment<byte>(buffer, offset, count));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/RemoteEvent.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal class RemoteEvent\n{\n\tconst int MaxEventNameLength = 255;\n\tconst int MaxEpbLength = 65535;\n\n\tList<string> _events;\n\tDatabaseBase _database;\n\tint[] _previousCounts;\n\tint[] _currentCounts;\n\tint _running;\n\n\tpublic int LocalId { get; set; }\n\tpublic int RemoteId { get; set; }\n\tpublic Action<string, int> EventCountsCallback { get; set; }\n\tpublic Action<Exception> EventErrorCallback { get; set; }\n\n\tpublic List<string> Events\n\t{\n\t\tget { return _events; }\n\t}\n\n\tpublic DatabaseBase Database\n\t{\n\t\tget { return _database; }\n\t}\n\n\tpublic RemoteEvent(DatabaseBase database)\n\t{\n\t\tLocalId = 0;\n\t\tRemoteId = 0;\n\t\t_events = new List<string>();\n\t\t_database = database;\n\t}\n\n\tpublic void QueueEvents(ICollection<string> events)\n\t{\n\t\tEnsureNotRunning();\n\t\tEnsureEventsCollection(events);\n\t\t_events.AddRange(events);\n\t\t_database.QueueEvents(this);\n\t}\n\tpublic ValueTask QueueEventsAsync(ICollection<string> events, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureNotRunning();\n\t\tEnsureEventsCollection(events);\n\t\t_events.AddRange(events);\n\t\treturn _database.QueueEventsAsync(this, cancellationToken);\n\t}\n\n\tpublic void CancelEvents()\n\t{\n\t\t_database.CancelEvents(this);\n\t\t_currentCounts = null;\n\t\t_previousCounts = null;\n\t\t_events.Clear();\n\t\tVolatile.Write(ref _running, 0);\n\t}\n\tpublic async ValueTask CancelEventsAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tawait _database.CancelEventsAsync(this, cancellationToken).ConfigureAwait(false);\n\t\t_currentCounts = null;\n\t\t_previousCounts = null;\n\t\t_events.Clear();\n\t\tVolatile.Write(ref _running, 0);\n\t}\n\n\tinternal void EventCounts(byte[] buffer)\n\t{\n\t\tif (Volatile.Read(ref _running) == 0)\n\t\t\treturn;\n\n\t\t_previousCounts = _currentCounts;\n\t\t_currentCounts = new int[_events.Count];\n\n\t\tvar pos = 1;\n\t\twhile (pos < buffer.Length)\n\t\t{\n\t\t\tvar length = buffer[pos++];\n\t\t\tvar eventName = _database.Charset.GetString(buffer, pos, length);\n\n\t\t\tpos += length;\n\n\t\t\tvar index = _events.IndexOf(eventName);\n\t\t\tDebug.Assert(index != -1);\n\t\t\t_currentCounts[index] = BitConverter.ToInt32(buffer, pos) - 1;\n\n\t\t\tpos += 4;\n\t\t}\n\n\t\tfor (var i = 0; i < _events.Count; i++)\n\t\t{\n\t\t\tvar count = _currentCounts[i] - _previousCounts[i];\n\t\t\tif (count == 0)\n\t\t\t\tcontinue;\n\t\t\tEventCountsCallback(_events[i], count);\n\t\t}\n\t}\n\n\tinternal void EventError(Exception error)\n\t{\n\t\tEventErrorCallback(error);\n\t}\n\n\tinternal EventParameterBuffer BuildEpb()\n\t{\n\t\t_currentCounts ??= new int[_events.Count];\n\t\treturn BuildEpb(_events, i => _currentCounts[i] + 1);\n\t}\n\n\tvoid EnsureNotRunning()\n\t{\n\t\tif (Interlocked.Exchange(ref _running, 1) == 1)\n\t\t\tthrow new InvalidOperationException(\"Events are already running.\");\n\t}\n\n\tEventParameterBuffer BuildEpb(IList<string> events, Func<int, int> countFactory)\n\t{\n\t\tvar epb = Database.CreateEventParameterBuffer();\n\t\tepb.Append(IscCodes.EPB_version1);\n\t\tfor (var i = 0; i < events.Count; i++)\n\t\t{\n\t\t\tepb.Append(events[i], countFactory(i));\n\t\t}\n\t\treturn epb;\n\t}\n\n\tvoid EnsureEventsCollection(ICollection<string> events)\n\t{\n\t\tif (events == null)\n\t\t\tthrow new ArgumentNullException(nameof(events));\n\t\tif (events.Count == 0)\n\t\t\tthrow new ArgumentOutOfRangeException(nameof(events), \"Need to provide at least one event.\");\n\t\tif (events.Any(x => x.Length > MaxEventNameLength))\n\t\t\tthrow new ArgumentOutOfRangeException(nameof(events), $\"Some events are longer than {MaxEventNameLength}.\");\n\t\tif (BuildEpb(events.ToList(), _ => default).ToArray().Length > MaxEpbLength)\n\t\t\tthrow new ArgumentOutOfRangeException(nameof(events), $\"Whole events buffer is bigger than {MaxEpbLength}.\");\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/ServiceManagerBase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal abstract class ServiceManagerBase\n{\n\tpublic Action<IscException> WarningMessage { get; set; }\n\n\tpublic abstract bool UseUtf8ParameterBuffer { get; }\n\tpublic Encoding ParameterBufferEncoding => UseUtf8ParameterBuffer ? Encoding.UTF8 : Encoding.GetANSIEncoding();\n\n\tpublic int Handle { get; protected set; }\n\tpublic Charset Charset { get; }\n\n\tpublic ServiceManagerBase(Charset charset)\n\t{\n\t\tCharset = charset;\n\t}\n\n\tpublic abstract void Attach(ServiceParameterBufferBase spb, string dataSource, int port, string service, byte[] cryptKey);\n\tpublic abstract ValueTask AttachAsync(ServiceParameterBufferBase spb, string dataSource, int port, string service, byte[] cryptKey, CancellationToken cancellationToken = default);\n\n\tpublic abstract void Detach();\n\tpublic abstract ValueTask DetachAsync(CancellationToken cancellationToken = default);\n\n\tpublic abstract void Start(ServiceParameterBufferBase spb);\n\tpublic abstract ValueTask StartAsync(ServiceParameterBufferBase spb, CancellationToken cancellationToken = default);\n\n\tpublic abstract void Query(ServiceParameterBufferBase spb, int requestLength, byte[] requestBuffer, int bufferLength, byte[] buffer);\n\tpublic abstract ValueTask QueryAsync(ServiceParameterBufferBase spb, int requestLength, byte[] requestBuffer, int bufferLength, byte[] buffer, CancellationToken cancellationToken = default);\n\n\tpublic abstract ServiceParameterBufferBase CreateServiceParameterBuffer();\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/ServiceParameterBuffer2.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Text;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal sealed class ServiceParameterBuffer2 : ServiceParameterBufferBase\n{\n\tpublic ServiceParameterBuffer2(Encoding encoding)\n\t\t: base(encoding)\n\t{ }\n\n\tpublic override void AppendPreamble()\n\t{\n\t\tAppend(IscCodes.isc_spb_version);\n\t\tAppend(IscCodes.isc_spb_current_version);\n\t}\n\n\tpublic override void Append1(int type, byte[] value)\n\t{\n\t\tWriteByte(type);\n\t\tWriteByte((byte)value.Length);\n\t\tWrite(value);\n\t}\n\n\tpublic override void Append2(int type, byte[] value)\n\t{\n\t\tWriteByte(type);\n\t\tWrite((short)value.Length);\n\t\tWrite(value);\n\t}\n\n\tpublic override void Append(int type, byte value)\n\t{\n\t\tWriteByte(type);\n\t\tWriteByte(value);\n\t}\n\n\tpublic override void Append(int type, int value)\n\t{\n\t\tWriteByte(type);\n\t\tWrite(value);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/ServiceParameterBuffer3.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Text;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal sealed class ServiceParameterBuffer3 : ServiceParameterBufferBase\n{\n\tpublic ServiceParameterBuffer3(Encoding encoding)\n\t\t: base(encoding)\n\t{ }\n\n\tpublic override void AppendPreamble()\n\t{\n\t\tAppend(IscCodes.isc_spb_version3);\n\t}\n\n\tpublic override void Append1(int type, byte[] value)\n\t{\n\t\tWriteByte(type);\n\t\tWrite(value.Length);\n\t\tWrite(value);\n\t}\n\n\tpublic override void Append2(int type, byte[] value)\n\t{\n\t\tWriteByte(type);\n\t\tWrite(value.Length);\n\t\tWrite(value);\n\t}\n\n\tpublic override void Append(int type, byte value)\n\t{\n\t\tWriteByte(type);\n\t\tWriteByte(value);\n\t}\n\n\tpublic override void Append(int type, int value)\n\t{\n\t\tWriteByte(type);\n\t\tWrite(value);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/ServiceParameterBufferBase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal abstract class ServiceParameterBufferBase : ParameterBuffer\n{\n\tpublic ServiceParameterBufferBase(Encoding encoding)\n\t{\n\t\tEncoding = encoding;\n\t}\n\n\tpublic abstract void AppendPreamble();\n\n\tpublic abstract void Append1(int type, byte[] value);\n\tpublic abstract void Append2(int type, byte[] value);\n\tpublic abstract void Append(int type, byte value);\n\tpublic abstract void Append(int type, int value);\n\n\tpublic void Append1(int type, string value) => Append1(type, Encoding.GetBytes(value));\n\n\tpublic void Append2(int type, string value) => Append2(type, Encoding.GetBytes(value));\n\n\tpublic Encoding Encoding { get; }\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/ShutdownHelper.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Concurrent;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class ShutdownHelper\n{\n\tstatic ConcurrentBag<Action> _pools;\n\tstatic ConcurrentBag<Action> _fbClients;\n\n\tstatic ShutdownHelper()\n\t{\n\t\t_pools = new ConcurrentBag<Action>();\n\t\t_fbClients = new ConcurrentBag<Action>();\n\t\tAppDomain.CurrentDomain.DomainUnload += (sender, e) => HandleDomainUnload();\n\t\tAppDomain.CurrentDomain.ProcessExit += (sender, e) => HandleProcessShutdown();\n\t}\n\n\tinternal static void RegisterPoolCleanup(Action item)\n\t{\n\t\t_pools.Add(item);\n\t}\n\n\tinternal static void RegisterFbClientShutdown(Action item)\n\t{\n\t\t_fbClients.Add(item);\n\t}\n\n\tstatic void HandleDomainUnload()\n\t{\n\t\twhile (_pools.TryTake(out var item))\n\t\t\titem();\n\t}\n\n\tstatic void HandleProcessShutdown()\n\t{\n\t\tHandleDomainUnload();\n\t\twhile (_fbClients.TryTake(out var item))\n\t\t\titem();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/SizeHelper.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class SizeHelper\n{\n\tpublic static bool IsValidPageSize(int value)\n\t{\n\t\treturn value == 1024\n\t\t\t|| value == 2048\n\t\t\t|| value == 4096\n\t\t\t|| value == 8192\n\t\t\t|| value == 16384\n\t\t\t|| value == 32768;\n\t}\n\n\tpublic static bool IsValidBatchBufferSize(int value)\n\t{\n\t\treturn value >= 0 && value <= 256 * 1024 * 1024;\n\t}\n\n\tpublic static Exception InvalidSizeException(string what)\n\t{\n\t\treturn new InvalidOperationException($\"Invalid {what} size.\");\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/SqlStateMapping.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class SqlStateMapping\n{\n\tstatic Dictionary<int, string> _mapping = new Dictionary<int, string>()\n\t\t{\n\t{335544321, \"22000\"}, //   1 arith_except\n\t{335544322, \"HY000\"}, //   2 bad_dbkey\n\t{335544323, \"HY000\"}, //   3 bad_db_format\n\t{335544324, \"08003\"}, //   4 bad_db_handle\n\t{335544325, \"HY000\"}, //   5 bad_dpb_content\n\t{335544326, \"HY000\"}, //   6 bad_dpb_form\n\t{335544327, \"42000\"}, //   7 bad_req_handle\n\t{335544328, \"42000\"}, //   8 bad_segstr_handle\n\t{335544329, \"42000\"}, //   9 bad_segstr_id\n\t{335544330, \"HY000\"}, //  10 bad_tpb_content\n\t{335544331, \"HY000\"}, //  11 bad_tpb_form\n\t{335544332, \"08003\"}, //  12 bad_trans_handle\n\t{335544333, \"XX000\"}, //  13 bug_check\n\t{335544334, \"22018\"}, //  14 convert_error\n\t{335544335, \"XX001\"}, //  15 db_corrupt\n\t{335544336, \"40001\"}, //  16 deadlock\n\t{335544337, \"HY000\"}, //  17 excess_trans\n\t{335544338, \"01000\"}, //  18 from_no_match\n\t{335544339, \"HY000\"}, //  19 infinap\n\t{335544340, \"HY000\"}, //  20 infona\n\t{335544341, \"HY000\"}, //  21 infunk\n\t{335544342, \"27000\"}, //  22 integ_fail\n\t{335544343, \"HY000\"}, //  23 invalid_blr\n\t{335544344, \"08001\"}, //  24 io_error\n\t{335544345, \"40001\"}, //  25 lock_conflict\n\t{335544346, \"XX001\"}, //  26 metadata_corrupt\n\t{335544347, \"23000\"}, //  27 not_valid\n\t{335544348, \"22000\"}, //  28 no_cur_rec\n\t{335544349, \"23000\"}, //  29 no_dup\n\t{335544350, \"HY000\"}, //  30 no_finish\n\t{335544351, \"42000\"}, //  31 no_meta_update\n\t{335544352, \"28000\"}, //  32 no_priv\n\t{335544353, \"HY000\"}, //  33 no_recon\n\t{335544354, \"01000\"}, //  34 no_record\n\t{335544355, \"HY000\"}, //  35 no_segstr_close\n\t{335544356, \"HY000\"}, //  36 obsolete_metadata\n\t{335544357, \"01002\"}, //  37 open_trans\n\t{335544358, \"HY000\"}, //  38 port_len\n\t{335544359, \"42000\"}, //  39 read_only_field\n\t{335544360, \"42000\"}, //  40 read_only_rel\n\t{335544361, \"42000\"}, //  41 read_only_trans\n\t{335544362, \"42000\"}, //  42 read_only_view\n\t{335544363, \"25000\"}, //  43 req_no_trans\n\t{335544364, \"HY000\"}, //  44 req_sync\n\t{335544365, \"HY000\"}, //  45 req_wrong_db\n\t{335544366, \"01000\"}, //  46 segment\n\t{335544367, \"01000\"}, //  47 segstr_eof\n\t{335544368, \"HY000\"}, //  48 segstr_no_op\n\t{335544369, \"HY000\"}, //  49 segstr_no_read\n\t{335544370, \"HY000\"}, //  50 segstr_no_trans\n\t{335544371, \"HY000\"}, //  51 segstr_no_write\n\t{335544372, \"HY000\"}, //  52 segstr_wrong_db\n\t{335544373, \"HY000\"}, //  53 sys_request\n\t{335544374, \"HY109\"}, //  54 stream_eof\n\t{335544375, \"08001\"}, //  55 unavailable\n\t{335544376, \"HY000\"}, //  56 unres_rel\n\t{335544377, \"HY000\"}, //  57 uns_ext\n\t{335544378, \"0A000\"}, //  58 wish_list\n\t{335544379, \"HY000\"}, //  59 wrong_ods\n\t{335544380, \"07002\"}, //  60 wronumarg\n\t{335544381, \"54000\"}, //  61 imp_exc\n\t{335544382, \"HY000\"}, //  62 random\n\t{335544383, \"HY000\"}, //  63 fatal_conflict\n\t{335544384, \"XX000\"}, //  64 badblk\n\t{335544385, \"XX000\"}, //  65 invpoolcl\n\t{335544386, \"HY000\"}, //  66 nopoolids\n\t{335544387, \"XX000\"}, //  67 relbadblk\n\t{335544388, \"54000\"}, //  68 blktoobig\n\t{335544389, \"HY001\"}, //  69 bufexh\n\t{335544390, \"HY000\"}, //  70 syntaxerr\n\t{335544391, \"HY000\"}, //  71 bufinuse\n\t{335544392, \"XX000\"}, //  72 bdbincon\n\t{335544393, \"HY000\"}, //  73 reqinuse\n\t{335544394, \"HY000\"}, //  74 badodsver\n\t{335544395, \"42S02\"}, //  75 relnotdef\n\t{335544396, \"42S22\"}, //  76 fldnotdef\n\t{335544397, \"XX000\"}, //  77 dirtypage\n\t{335544398, \"XX000\"}, //  78 waifortra\n\t{335544399, \"XX000\"}, //  79 doubleloc\n\t{335544400, \"XX000\"}, //  80 nodnotfnd\n\t{335544401, \"XX000\"}, //  81 dupnodfnd\n\t{335544402, \"XX000\"}, //  82 locnotmar\n\t{335544403, \"42000\"}, //  83 badpagtyp\n\t{335544404, \"XX000\"}, //  84 corrupt\n\t{335544405, \"42000\"}, //  85 badpage\n\t{335544406, \"XX002\"}, //  86 badindex\n\t{335544407, \"HY000\"}, //  87 dbbnotzer\n\t{335544408, \"25000\"}, //  88 tranotzer\n\t{335544409, \"25000\"}, //  89 trareqmis\n\t{335544410, \"HY000\"}, //  90 badhndcnt\n\t{335544411, \"HY000\"}, //  91 wrotpbver\n\t{335544412, \"HY000\"}, //  92 wroblrver\n\t{335544413, \"HY000\"}, //  93 wrodpbver\n\t{335544414, \"42000\"}, //  94 blobnotsup\n\t{335544415, \"XX001\"}, //  95 badrelation\n\t{335544416, \"XX000\"}, //  96 nodetach\n\t{335544417, \"XX000\"}, //  97 notremote\n\t{335544418, \"25000\"}, //  98 trainlim\n\t{335544419, \"25000\"}, //  99 notinlim\n\t{335544420, \"25000\"}, // 100 traoutsta\n\t{335544421, \"08004\"}, // 101 connect_reject\n\t{335544422, \"XX000\"}, // 102 dbfile\n\t{335544423, \"XX000\"}, // 103 orphan\n\t{335544424, \"HY000\"}, // 104 no_lock_mgr\n\t{335544425, \"HY000\"}, // 105 ctxinuse\n\t{335544426, \"HY000\"}, // 106 ctxnotdef\n\t{335544427, \"42000\"}, // 107 datnotsup\n\t{335544428, \"HY000\"}, // 108 badmsgnum\n\t{335544429, \"HY000\"}, // 109 badparnum\n\t{335544430, \"HY001\"}, // 110 virmemexh\n\t{335544431, \"HY000\"}, // 111 blocking_signal\n\t{335544432, \"40001\"}, // 112 lockmanerr\n\t{335544433, \"HY000\"}, // 113 journerr\n\t{335544434, \"42000\"}, // 114 keytoobig\n\t{335544435, \"HY000\"}, // 115 nullsegkey\n\t{335544436, \"00000\"}, // 116 sqlerr\n\t{335544437, \"HY000\"}, // 117 wrodynver\n\t{335544438, \"39000\"}, // 118 funnotdef\n\t{335544439, \"39000\"}, // 119 funmismat\n\t{335544440, \"22001\"}, // 120 bad_msg_vec\n\t{335544441, \"08007\"}, // 121 bad_detach\n\t{335544442, \"HY000\"}, // 122 noargacc_read\n\t{335544443, \"HY000\"}, // 123 noargacc_write\n\t{335544444, \"42000\"}, // 124 read_only\n\t{335544445, \"42000\"}, // 125 ext_err\n\t{335544446, \"42000\"}, // 126 non_updatable\n\t{335544447, \"25S02\"}, // 127 no_rollback\n\t{335544448, \"HY000\"}, // 128 bad_sec_info\n\t{335544449, \"28000\"}, // 129 invalid_sec_info\n\t{335544450, \"HY000\"}, // 130 misc_interpreted\n\t{335544451, \"40001\"}, // 131 update_conflict\n\t{335544452, \"HY000\"}, // 132 unlicensed\n\t{335544453, \"42000\"}, // 133 obj_in_use\n\t{335544454, \"HY000\"}, // 134 nofilter\n\t{335544455, \"00000\"}, // 135 shadow_accessed\n\t{335544456, \"HY000\"}, // 136 invalid_sdl\n\t{335544457, \"42000\"}, // 137 out_of_bounds\n\t{335544458, \"42000\"}, // 138 invalid_dimension\n\t{335544459, \"HY000\"}, // 139 rec_in_limbo\n\t{335544460, \"HY000\"}, // 140 shadow_missing\n\t{335544461, \"HY000\"}, // 141 cant_validate\n\t{335544462, \"HY000\"}, // 142 cant_start_journal\n\t{335544463, \"42000\"}, // 143 gennotdef\n\t{335544464, \"HY000\"}, // 144 cant_start_logging\n\t{335544465, \"42000\"}, // 145 bad_segstr_type\n\t{335544466, \"23000\"}, // 146 foreign_key\n\t{335544467, \"HY000\"}, // 147 high_minor\n\t{335544468, \"00000\"}, // 148 tra_state\n\t{335544469, \"25000\"}, // 149 trans_invalid\n\t{335544470, \"HY000\"}, // 150 buf_invalid\n\t{335544471, \"42S12\"}, // 151 indexnotdefined\n\t{335544472, \"28000\"}, // 152 login\n\t{335544473, \"HY111\"}, // 153 invalid_bookmark\n\t{335544474, \"HY000\"}, // 154 bad_lock_level\n\t{335544475, \"40001\"}, // 155 relation_lock\n\t{335544476, \"40001\"}, // 156 record_lock\n\t{335544477, \"54000\"}, // 157 max_idx\n\t{335544478, \"HY000\"}, // 158 jrn_enable\n\t{335544479, \"HY000\"}, // 159 old_failure\n\t{335544480, \"HY000\"}, // 160 old_in_progress\n\t{335544481, \"HY000\"}, // 161 old_no_space\n\t{335544482, \"HY000\"}, // 162 no_wal_no_jrn\n\t{335544483, \"HY000\"}, // 163 num_old_files\n\t{335544484, \"HY000\"}, // 164 wal_file_open\n\t{335544485, \"26000\"}, // 165 bad_stmt_handle\n\t{335544486, \"HY000\"}, // 166 wal_failure\n\t{335544487, \"HY000\"}, // 167 walw_err\n\t{335544488, \"HY000\"}, // 168 logh_small\n\t{335544489, \"HY000\"}, // 169 logh_inv_version\n\t{335544490, \"HY000\"}, // 170 logh_open_flag\n\t{335544491, \"HY000\"}, // 171 logh_open_flag2\n\t{335544492, \"HY000\"}, // 172 logh_diff_dbname\n\t{335544493, \"HY000\"}, // 173 logf_unexpected_eof\n\t{335544494, \"HY000\"}, // 174 logr_incomplete\n\t{335544495, \"HY000\"}, // 175 logr_header_small\n\t{335544496, \"HY000\"}, // 176 logb_small\n\t{335544497, \"HY000\"}, // 177 wal_illegal_attach\n\t{335544498, \"HY000\"}, // 178 wal_invalid_wpb\n\t{335544499, \"HY000\"}, // 179 wal_err_rollover\n\t{335544500, \"HY000\"}, // 180 no_wal\n\t{335544501, \"HY000\"}, // 181 drop_wal\n\t{335544502, \"HY000\"}, // 182 stream_not_defined\n\t{335544503, \"HY000\"}, // 183 wal_subsys_error\n\t{335544504, \"XX000\"}, // 184 wal_subsys_corrupt\n\t{335544505, \"HY000\"}, // 185 no_archive\n\t{335544506, \"HY000\"}, // 186 shutinprog\n\t{335544507, \"42000\"}, // 187 range_in_use\n\t{335544508, \"42000\"}, // 188 range_not_found\n\t{335544509, \"2C000\"}, // 189 charset_not_found\n\t{335544510, \"40001\"}, // 190 lock_timeout\n\t{335544511, \"42000\"}, // 191 prcnotdef\n\t{335544512, \"07001\"}, // 192 prcmismat\n\t{335544513, \"XX000\"}, // 193 wal_bugcheck\n\t{335544514, \"HY000\"}, // 194 wal_cant_expand\n\t{335544515, \"HY000\"}, // 195 codnotdef\n\t{335544516, \"HY000\"}, // 196 xcpnotdef\n\t{335544517, \"HY000\"}, // 197 except\n\t{335544518, \"HY013\"}, // 198 cache_restart\n\t{335544519, \"HY000\"}, // 199 bad_lock_handle\n\t{335544520, \"HY000\"}, // 200 jrn_present\n\t{335544521, \"HY000\"}, // 201 wal_err_rollover2\n\t{335544522, \"HY000\"}, // 202 wal_err_logwrite\n\t{335544523, \"HY000\"}, // 203 wal_err_jrn_comm\n\t{335544524, \"HY000\"}, // 204 wal_err_expansion\n\t{335544525, \"HY000\"}, // 205 wal_err_setup\n\t{335544526, \"HY000\"}, // 206 wal_err_ww_sync\n\t{335544527, \"HY000\"}, // 207 wal_err_ww_start\n\t{335544528, \"HY000\"}, // 208 shutdown\n\t{335544529, \"28000\"}, // 209 existing_priv_mod\n\t{335544530, \"42000\"}, // 210 primary_key_ref\n\t{335544531, \"42000\"}, // 211 primary_key_notnull\n\t{335544532, \"42000\"}, // 212 ref_cnstrnt_notfound\n\t{335544533, \"42000\"}, // 213 foreign_key_notfound\n\t{335544534, \"42000\"}, // 214 ref_cnstrnt_update\n\t{335544535, \"44000\"}, // 215 check_cnstrnt_update\n\t{335544536, \"44000\"}, // 216 check_cnstrnt_del\n\t{335544537, \"42000\"}, // 217 integ_index_seg_del\n\t{335544538, \"42000\"}, // 218 integ_index_seg_mod\n\t{335544539, \"42000\"}, // 219 integ_index_del\n\t{335544540, \"42000\"}, // 220 integ_index_mod\n\t{335544541, \"44000\"}, // 221 check_trig_del\n\t{335544542, \"44000\"}, // 222 check_trig_update\n\t{335544543, \"23000\"}, // 223 cnstrnt_fld_del\n\t{335544544, \"23000\"}, // 224 cnstrnt_fld_rename\n\t{335544545, \"42000\"}, // 225 rel_cnstrnt_update\n\t{335544546, \"42000\"}, // 226 constaint_on_view\n\t{335544547, \"42000\"}, // 227 invld_cnstrnt_type\n\t{335544548, \"42S11\"}, // 228 primary_key_exists\n\t{335544549, \"HY000\"}, // 229 systrig_update\n\t{335544550, \"28000\"}, // 230 not_rel_owner\n\t{335544551, \"01007\"}, // 231 grant_obj_notfound\n\t{335544552, \"01007\"}, // 232 grant_fld_notfound\n\t{335544553, \"01007\"}, // 233 grant_nopriv\n\t{335544554, \"28000\"}, // 234 nonsql_security_rel\n\t{335544555, \"28000\"}, // 235 nonsql_security_fld\n\t{335544556, \"HY000\"}, // 236 wal_cache_err\n\t{335544557, \"HY000\"}, // 237 shutfail\n\t{335544558, \"23000\"}, // 238 check_constraint\n\t{335544559, \"HY000\"}, // 239 bad_svc_handle\n\t{335544560, \"HY000\"}, // 240 shutwarn\n\t{335544561, \"HY000\"}, // 241 wrospbver\n\t{335544562, \"42000\"}, // 242 bad_spb_form\n\t{335544563, \"HY000\"}, // 243 svcnotdef\n\t{335544564, \"HY000\"}, // 244 no_jrn\n\t{335544565, \"22018\"}, // 245 transliteration_failed\n\t{335544566, \"HY000\"}, // 246 start_cm_for_wal\n\t{335544567, \"HY000\"}, // 247 wal_ovflow_log_required\n\t{335544568, \"42000\"}, // 248 text_subtype\n\t{335544569, \"42000\"}, // 249 dsql_error\n\t{335544570, \"42000\"}, // 250 dsql_command_err\n\t{335544571, \"HY004\"}, // 251 dsql_constant_err\n\t{335544572, \"HY015\"}, // 252 dsql_cursor_err\n\t{335544573, \"HY004\"}, // 253 dsql_datatype_err\n\t{335544574, \"34000\"}, // 254 dsql_decl_err\n\t{335544575, \"24000\"}, // 255 dsql_cursor_update_err\n\t{335544576, \"24000\"}, // 256 dsql_cursor_open_err\n\t{335544577, \"24000\"}, // 257 dsql_cursor_close_err\n\t{335544578, \"42S22\"}, // 258 dsql_field_err\n\t{335544579, \"XX000\"}, // 259 dsql_internal_err\n\t{335544580, \"42S02\"}, // 260 dsql_relation_err\n\t{335544581, \"42000\"}, // 261 dsql_procedure_err\n\t{335544582, \"42000\"}, // 262 dsql_request_err\n\t{335544583, \"07002\"}, // 263 dsql_sqlda_err\n\t{335544584, \"21S01\"}, // 264 dsql_var_count_err\n\t{335544585, \"HY000\"}, // 265 dsql_stmt_handle\n\t{335544586, \"39000\"}, // 266 dsql_function_err\n\t{335544587, \"42000\"}, // 267 dsql_blob_err\n\t{335544588, \"22021\"}, // 268 collation_not_found\n\t{335544589, \"22021\"}, // 269 collation_not_for_charset\n\t{335544590, \"42000\"}, // 270 dsql_dup_option\n\t{335544591, \"25000\"}, // 271 dsql_tran_err\n\t{335544592, \"HY000\"}, // 272 dsql_invalid_array\n\t{335544593, \"54000\"}, // 273 dsql_max_arr_dim_exceeded\n\t{335544594, \"42000\"}, // 274 dsql_arr_range_error\n\t{335544595, \"HY000\"}, // 275 dsql_trigger_err\n\t{335544596, \"42000\"}, // 276 dsql_subselect_err\n\t{335544597, \"42000\"}, // 277 dsql_crdb_prepare_err\n\t{335544598, \"42000\"}, // 278 specify_field_err\n\t{335544599, \"07002\"}, // 279 num_field_err\n\t{335544600, \"42000\"}, // 280 col_name_err\n\t{335544601, \"42000\"}, // 281 where_err\n\t{335544602, \"42000\"}, // 282 table_view_err\n\t{335544603, \"42000\"}, // 283 distinct_err\n\t{335544604, \"42000\"}, // 284 key_field_count_err\n\t{335544605, \"42000\"}, // 285 subquery_err\n\t{335544606, \"42000\"}, // 286 expression_eval_err\n\t{335544607, \"HY000\"}, // 287 node_err\n\t{335544608, \"42000\"}, // 288 command_end_err\n\t{335544609, \"42000\"}, // 289 index_name\n\t{335544610, \"22000\"}, // 290 exception_name\n\t{335544611, \"42000\"}, // 291 field_name\n\t{335544612, \"42000\"}, // 292 token_err\n\t{335544613, \"42000\"}, // 293 union_err\n\t{335544614, \"42000\"}, // 294 dsql_construct_err\n\t{335544615, \"42000\"}, // 295 field_aggregate_err\n\t{335544616, \"42S22\"}, // 296 field_ref_err\n\t{335544617, \"42000\"}, // 297 order_by_err\n\t{335544618, \"HY000\"}, // 298 return_mode_err\n\t{335544619, \"38000\"}, // 299 extern_func_err\n\t{335544620, \"08001\"}, // 300 alias_conflict_err\n\t{335544621, \"42000\"}, // 301 procedure_conflict_error\n\t{335544622, \"42000\"}, // 302 relation_conflict_err\n\t{335544623, \"42000\"}, // 303 dsql_domain_err\n\t{335544624, \"42000\"}, // 304 idx_seg_err\n\t{335544625, \"HY000\"}, // 305 node_name_err\n\t{335544626, \"00000\"}, // 306 table_name\n\t{335544627, \"42000\"}, // 307 proc_name\n\t{335544628, \"42000\"}, // 308 idx_create_err\n\t{335544629, \"HY000\"}, // 309 wal_shadow_err\n\t{335544630, \"42000\"}, // 310 dependency\n\t{335544631, \"54011\"}, // 311 idx_key_err\n\t{335544632, \"42000\"}, // 312 dsql_file_length_err\n\t{335544633, \"HY000\"}, // 313 dsql_shadow_number_err\n\t{335544634, \"42000\"}, // 314 dsql_token_unk_err\n\t{335544635, \"42S02\"}, // 315 dsql_no_relation_alias\n\t{335544636, \"42000\"}, // 316 indexname\n\t{335544637, \"HY000\"}, // 317 no_stream_plan\n\t{335544638, \"HY000\"}, // 318 stream_twice\n\t{335544639, \"HY000\"}, // 319 stream_not_found\n\t{335544640, \"22021\"}, // 320 collation_requires_text\n\t{335544641, \"42000\"}, // 321 dsql_domain_not_found\n\t{335544642, \"42000\"}, // 322 index_unused\n\t{335544643, \"42000\"}, // 323 dsql_self_join\n\t{335544644, \"HY109\"}, // 324 stream_bof\n\t{335544645, \"HY000\"}, // 325 stream_crack\n\t{335544646, \"HY000\"}, // 326 db_or_file_exists\n\t{335544647, \"42000\"}, // 327 invalid_operator\n\t{335544648, \"HY000\"}, // 328 conn_lost\n\t{335544649, \"42000\"}, // 329 bad_checksum\n\t{335544650, \"HY000\"}, // 330 page_type_err\n\t{335544651, \"42000\"}, // 331 ext_readonly_err\n\t{335544652, \"21000\"}, // 332 sing_select_err\n\t{335544653, \"28000\"}, // 333 psw_attach\n\t{335544654, \"28000\"}, // 334 psw_start_trans\n\t{335544655, \"42000\"}, // 335 invalid_direction\n\t{335544656, \"HY000\"}, // 336 dsql_var_conflict\n\t{335544657, \"HY000\"}, // 337 dsql_no_blob_array\n\t{335544658, \"42000\"}, // 338 dsql_base_table\n\t{335544659, \"42000\"}, // 339 duplicate_base_table\n\t{335544660, \"42000\"}, // 340 view_alias\n\t{335544661, \"54000\"}, // 341 index_root_page_full\n\t{335544662, \"42000\"}, // 342 dsql_blob_type_unknown\n\t{335544663, \"54001\"}, // 343 req_max_clones_exceeded\n\t{335544664, \"42000\"}, // 344 dsql_duplicate_spec\n\t{335544665, \"23000\"}, // 345 unique_key_violation\n\t{335544666, \"HY000\"}, // 346 srvr_version_too_old\n\t{335544667, \"HY000\"}, // 347 drdb_completed_with_errs\n\t{335544668, \"42000\"}, // 348 dsql_procedure_use_err\n\t{335544669, \"07002\"}, // 349 dsql_count_mismatch\n\t{335544670, \"42000\"}, // 350 blob_idx_err\n\t{335544671, \"42000\"}, // 351 array_idx_err\n\t{335544672, \"42000\"}, // 352 key_field_err\n\t{335544673, \"HY000\"}, // 353 no_delete\n\t{335544674, \"42000\"}, // 354 del_last_field\n\t{335544675, \"HY000\"}, // 355 sort_err\n\t{335544676, \"HY001\"}, // 356 sort_mem_err\n\t{335544677, \"54000\"}, // 357 version_err\n\t{335544678, \"HY000\"}, // 358 inval_key_posn\n\t{335544679, \"HY000\"}, // 359 no_segments_err\n\t{335544680, \"XX000\"}, // 360 crrp_data_err\n\t{335544681, \"54000\"}, // 361 rec_size_err\n\t{335544682, \"42000\"}, // 362 dsql_field_ref\n\t{335544683, \"54001\"}, // 363 req_depth_exceeded\n\t{335544684, \"42S22\"}, // 364 no_field_access\n\t{335544685, \"HY000\"}, // 365 no_dbkey\n\t{335544686, \"HY000\"}, // 366 jrn_format_err\n\t{335544687, \"HY000\"}, // 367 jrn_file_full\n\t{335544688, \"24000\"}, // 368 dsql_open_cursor_request\n\t{335544689, \"HY000\"}, // 369 ib_error\n\t{335544690, \"HY013\"}, // 370 cache_redef\n\t{335544691, \"HY013\"}, // 371 cache_too_small\n\t{335544692, \"HY000\"}, // 372 log_redef\n\t{335544693, \"HY000\"}, // 373 log_too_small\n\t{335544694, \"HY000\"}, // 374 partition_too_small\n\t{335544695, \"HY000\"}, // 375 partition_not_supp\n\t{335544696, \"HY000\"}, // 376 log_length_spec\n\t{335544697, \"HY104\"}, // 377 precision_err\n\t{335544698, \"HY104\"}, // 378 scale_nogt\n\t{335544699, \"22003\"}, // 379 expec_short\n\t{335544700, \"22003\"}, // 380 expec_long\n\t{335544701, \"22003\"}, // 381 expec_ushort\n\t{335544702, \"22025\"}, // 382 escape_invalid\n\t{335544703, \"HY000\"}, // 383 svcnoexe\n\t{335544704, \"08006\"}, // 384 net_lookup_err\n\t{335544705, \"HY000\"}, // 385 service_unknown\n\t{335544706, \"08001\"}, // 386 host_unknown\n\t{335544707, \"01007\"}, // 387 grant_nopriv_on_base\n\t{335544708, \"42702\"}, // 388 dyn_fld_ambiguous\n\t{335544709, \"42000\"}, // 389 dsql_agg_ref_err\n\t{335544710, \"HY000\"}, // 390 complex_view\n\t{335544711, \"HY007\"}, // 391 unprepared_stmt\n\t{335544712, \"42000\"}, // 392 expec_positive\n\t{335544713, \"HY000\"}, // 393 dsql_sqlda_value_err\n\t{335544714, \"HY000\"}, // 394 invalid_array_id\n\t{335544715, \"42000\"}, // 395 extfile_uns_op\n\t{335544716, \"HY000\"}, // 396 svc_in_use\n\t{335544717, \"HY013\"}, // 397 err_stack_limit\n\t{335544718, \"42000\"}, // 398 invalid_key\n\t{335544719, \"08006\"}, // 399 net_init_error\n\t{335544720, \"HY000\"}, // 400 loadlib_failure\n\t{335544721, \"08006\"}, // 401 network_error\n\t{335544722, \"08006\"}, // 402 net_connect_err\n\t{335544723, \"08006\"}, // 403 net_connect_listen_err\n\t{335544724, \"08006\"}, // 404 net_event_connect_err\n\t{335544725, \"08006\"}, // 405 net_event_listen_err\n\t{335544726, \"08006\"}, // 406 net_read_err\n\t{335544727, \"08006\"}, // 407 net_write_err\n\t{335544728, \"42000\"}, // 408 integ_index_deactivate\n\t{335544729, \"42000\"}, // 409 integ_deactivate_primary\n\t{335544730, \"HY000\"}, // 410 cse_not_supported\n\t{335544731, \"HY000\"}, // 411 tra_must_sweep\n\t{335544732, \"HY000\"}, // 412 unsupported_network_drive\n\t{335544733, \"08001\"}, // 413 io_create_err\n\t{335544734, \"08001\"}, // 414 io_open_err\n\t{335544735, \"HY000\"}, // 415 io_close_err\n\t{335544736, \"HY000\"}, // 416 io_read_err\n\t{335544737, \"HY000\"}, // 417 io_write_err\n\t{335544738, \"HY000\"}, // 418 io_delete_err\n\t{335544739, \"HY000\"}, // 419 io_access_err\n\t{335544740, \"38000\"}, // 420 udf_exception\n\t{335544741, \"08006\"}, // 421 lost_db_connection\n\t{335544742, \"28000\"}, // 422 no_write_user_priv\n\t{335544743, \"42000\"}, // 423 token_too_long\n\t{335544744, \"08001\"}, // 424 max_att_exceeded\n\t{335544745, \"28000\"}, // 425 login_same_as_role_name\n\t{335544746, \"42000\"}, // 426 reftable_requires_pk\n\t{335544747, \"28000\"}, // 427 usrname_too_long\n\t{335544748, \"28000\"}, // 428 password_too_long\n\t{335544749, \"28000\"}, // 429 usrname_required\n\t{335544750, \"28000\"}, // 430 password_required\n\t{335544751, \"42000\"}, // 431 bad_protocol\n\t{335544752, \"28000\"}, // 432 dup_usrname_found\n\t{335544753, \"28000\"}, // 433 usrname_not_found\n\t{335544754, \"28000\"}, // 434 error_adding_sec_record\n\t{335544755, \"28000\"}, // 435 error_modifying_sec_record\n\t{335544756, \"28000\"}, // 436 error_deleting_sec_record\n\t{335544757, \"28000\"}, // 437 error_updating_sec_db\n\t{335544758, \"HY000\"}, // 438 sort_rec_size_err\n\t{335544759, \"42000\"}, // 439 bad_default_value\n\t{335544760, \"42000\"}, // 440 invalid_clause\n\t{335544761, \"HY000\"}, // 441 too_many_handles\n\t{335544762, \"HY000\"}, // 442 optimizer_blk_exc\n\t{335544763, \"42000\"}, // 443 invalid_string_constant\n\t{335544764, \"HY000\"}, // 444 transitional_date\n\t{335544765, \"42000\"}, // 445 read_only_database\n\t{335544766, \"HY000\"}, // 446 must_be_dialect_2_and_up\n\t{335544767, \"HY000\"}, // 447 blob_filter_exception\n\t{335544768, \"HY000\"}, // 448 exception_access_violation\n\t{335544769, \"22000\"}, // 449 exception_datatype_missalignment\n\t{335544770, \"22000\"}, // 450 exception_array_bounds_exceeded\n\t{335544771, \"22000\"}, // 451 exception_float_denormal_operand\n\t{335544772, \"22012\"}, // 452 exception_float_divide_by_zero\n\t{335544773, \"22000\"}, // 453 exception_float_inexact_result\n\t{335544774, \"22000\"}, // 454 exception_float_invalid_operand\n\t{335544775, \"22003\"}, // 455 exception_float_overflow\n\t{335544776, \"22000\"}, // 456 exception_float_stack_check\n\t{335544777, \"22003\"}, // 457 exception_float_underflow\n\t{335544778, \"22012\"}, // 458 exception_integer_divide_by_zero\n\t{335544779, \"22003\"}, // 459 exception_integer_overflow\n\t{335544780, \"HY000\"}, // 460 exception_unknown\n\t{335544781, \"HY001\"}, // 461 exception_stack_overflow\n\t{335544782, \"HY000\"}, // 462 exception_sigsegv\n\t{335544783, \"HY000\"}, // 463 exception_sigill\n\t{335544784, \"HY000\"}, // 464 exception_sigbus\n\t{335544785, \"HY000\"}, // 465 exception_sigfpe\n\t{335544786, \"42000\"}, // 466 ext_file_delete\n\t{335544787, \"42000\"}, // 467 ext_file_modify\n\t{335544788, \"28000\"}, // 468 adm_task_denied\n\t{335544789, \"42000\"}, // 469 extract_input_mismatch\n\t{335544790, \"28000\"}, // 470 insufficient_svc_privileges\n\t{335544791, \"HY000\"}, // 471 file_in_use\n\t{335544792, \"HY000\"}, // 472 service_att_err\n\t{335544793, \"42000\"}, // 473 ddl_not_allowed_by_db_sql_dial\n\t{335544794, \"HY008\"}, // 474 cancelled\n\t{335544795, \"HY000\"}, // 475 unexp_spb_form\n\t{335544796, \"HY000\"}, // 476 sql_dialect_datatype_unsupport\n\t{335544797, \"HY000\"}, // 477 svcnouser\n\t{335544798, \"42000\"}, // 478 depend_on_uncommitted_rel\n\t{335544799, \"HY000\"}, // 479 svc_name_missing\n\t{335544800, \"54001\"}, // 480 too_many_contexts\n\t{335544801, \"22008\"}, // 481 datype_notsup\n\t{335544802, \"01000\"}, // 482 dialect_reset_warning\n\t{335544803, \"HY000\"}, // 483 dialect_not_changed\n\t{335544804, \"HY000\"}, // 484 database_create_failed\n\t{335544805, \"42000\"}, // 485 inv_dialect_specified\n\t{335544806, \"00000\"}, // 486 valid_db_dialects\n\t{335544807, \"00000\"}, // 487 sqlwarn\n\t{335544808, \"HY000\"}, // 488 dtype_renamed\n\t{335544809, \"38000\"}, // 489 extern_func_dir_error\n\t{335544810, \"22008\"}, // 490 date_range_exceeded\n\t{335544811, \"42000\"}, // 491 inv_client_dialect_specified\n\t{335544812, \"00000\"}, // 492 valid_client_dialects\n\t{335544813, \"HY004\"}, // 493 optimizer_between_err\n\t{335544814, \"HY000\"}, // 494 service_not_supported\n\t{335544815, \"00000\"}, // 495 generator_name\n\t{335544816, \"38000\"}, // 496 udf_name\n\t{335544817, \"HY000\"}, // 497 bad_limit_param\n\t{335544818, \"42000\"}, // 498 bad_skip_param\n\t{335544819, \"54000\"}, // 499 io_32bit_exceeded_err\n\t{335544820, \"3B000\"}, // 500 invalid_savepoint\n\t{335544821, \"42000\"}, // 501 dsql_column_pos_err\n\t{335544822, \"42000\"}, // 502 dsql_agg_where_err\n\t{335544823, \"42000\"}, // 503 dsql_agg_group_err\n\t{335544824, \"42000\"}, // 504 dsql_agg_column_err\n\t{335544825, \"42000\"}, // 505 dsql_agg_having_err\n\t{335544826, \"42000\"}, // 506 dsql_agg_nested_err\n\t{335544827, \"42000\"}, // 507 exec_sql_invalid_arg\n\t{335544828, \"42000\"}, // 508 exec_sql_invalid_req\n\t{335544829, \"42000\"}, // 509 exec_sql_invalid_var\n\t{335544830, \"42000\"}, // 510 exec_sql_max_call_exceeded\n\t{335544831, \"28000\"}, // 511 conf_access_denied\n\t{335544832, \"HY000\"}, // 512 wrong_backup_state\n\t{335544833, \"HY000\"}, // 513 wal_backup_err\n\t{335544834, \"24000\"}, // 514 cursor_not_open\n\t{335544835, \"08007\"}, // 515 bad_shutdown_mode\n\t{335544836, \"HY000\"}, // 516 concat_overflow\n\t{335544837, \"22011\"}, // 517 bad_substring_offset\n\t{335544838, \"42000\"}, // 518 foreign_key_target_doesnt_exist\n\t{335544839, \"42000\"}, // 519 foreign_key_references_present\n\t{335544840, \"HY000\"}, // 520 no_update\n\t{335544841, \"24000\"}, // 521 cursor_already_open\n\t{335544842, \"00000\"}, // 522 stack_trace\n\t{335544843, \"HY000\"}, // 523 ctx_var_not_found\n\t{335544844, \"HY000\"}, // 524 ctx_namespace_invalid\n\t{335544845, \"54000\"}, // 525 ctx_too_big\n\t{335544846, \"HY000\"}, // 526 ctx_bad_argument\n\t{335544847, \"42000\"}, // 527 identifier_too_long\n\t{335544848, \"HY000\"}, // 528 except2\n\t{335544849, \"22000\"}, // 529 malformed_string\n\t{335544850, \"07002\"}, // 530 prc_out_param_mismatch\n\t{335544851, \"42000\"}, // 531 command_end_err2\n\t{335544852, \"42000\"}, // 532 partner_idx_incompat_type\n\t{335544853, \"22011\"}, // 533 bad_substring_length\n\t{335544854, \"2C000\"}, // 534 charset_not_installed\n\t{335544855, \"22021\"}, // 535 collation_not_installed\n\t{335544856, \"08003\"}, // 536 att_shutdown\n\t{335544857, \"54000\"}, // 537 blobtoobig\n\t{335544858, \"42000\"}, // 538 must_have_phys_field\n\t{335544859, \"22007\"}, // 539 invalid_time_precision\n\t{335544860, \"HY000\"}, // 540 blob_convert_error\n\t{335544861, \"22000\"}, // 541 array_convert_error\n\t{335544862, \"40001\"}, // 542 record_lock_not_supp\n\t{335544863, \"42000\"}, // 543 partner_idx_not_found\n\t{335544864, \"54000\"}, // 544 tra_num_exc\n\t{335544865, \"42000\"}, // 545 field_disappeared\n\t{335544866, \"HY000\"}, // 546 met_wrong_gtt_scope\n\t{335544867, \"HY000\"}, // 547 subtype_for_internal_use\n\t{335544868, \"42000\"}, // 548 illegal_prc_type\n\t{335544869, \"42000\"}, // 549 invalid_sort_datatype\n\t{335544870, \"00000\"}, // 550 collation_name\n\t{335544871, \"00000\"}, // 551 domain_name\n\t{335544872, \"42000\"}, // 552 domnotdef\n\t{335544873, \"54000\"}, // 553 array_max_dimensions\n\t{335544874, \"54000\"}, // 554 max_db_per_trans_allowed\n\t{335544875, \"00000\"}, // 555 bad_debug_format\n\t{335544876, \"2F000\"}, // 556 bad_proc_BLR\n\t{335544877, \"54000\"}, // 557 key_too_big\n\t{335544878, \"HY000\"}, // 558 concurrent_transaction\n\t{335544879, \"42000\"}, // 559 not_valid_for_var\n\t{335544880, \"42000\"}, // 560 not_valid_for\n\t{335544881, \"HY000\"}, // 561 need_difference\n\t{335544882, \"HY000\"}, // 562 long_login\n\t{335544883, \"42S22\"}, // 563 fldnotdef2\n\t{335544884, \"42000\"}, // 564 invalid_similar_pattern\n\t{335544885, \"HY000\"}, // 565 bad_teb_form\n\t{335544886, \"HY000\"}, // 566 tpb_multiple_txn_isolation\n\t{335544887, \"HY000\"}, // 567 tpb_reserv_before_table\n\t{335544888, \"HY000\"}, // 568 tpb_multiple_spec\n\t{335544889, \"HY000\"}, // 569 tpb_option_without_rc\n\t{335544890, \"HY000\"}, // 570 tpb_conflicting_options\n\t{335544891, \"HY000\"}, // 571 tpb_reserv_missing_tlen\n\t{335544892, \"HY000\"}, // 572 tpb_reserv_long_tlen\n\t{335544893, \"HY000\"}, // 573 tpb_reserv_missing_tname\n\t{335544894, \"HY000\"}, // 574 tpb_reserv_corrup_tlen\n\t{335544895, \"HY000\"}, // 575 tpb_reserv_null_tlen\n\t{335544896, \"HY000\"}, // 576 tpb_reserv_relnotfound\n\t{335544897, \"HY000\"}, // 577 tpb_reserv_baserelnotfound\n\t{335544898, \"HY000\"}, // 578 tpb_missing_len\n\t{335544899, \"HY000\"}, // 579 tpb_missing_value\n\t{335544900, \"HY000\"}, // 580 tpb_corrupt_len\n\t{335544901, \"HY000\"}, // 581 tpb_null_len\n\t{335544902, \"HY000\"}, // 582 tpb_overflow_len\n\t{335544903, \"HY000\"}, // 583 tpb_invalid_value\n\t{335544904, \"HY000\"}, // 584 tpb_reserv_stronger_wng\n\t{335544905, \"HY000\"}, // 585 tpb_reserv_stronger\n\t{335544906, \"HY000\"}, // 586 tpb_reserv_max_recursion\n\t{335544907, \"HY000\"}, // 587 tpb_reserv_virtualtbl\n\t{335544908, \"HY000\"}, // 588 tpb_reserv_systbl\n\t{335544909, \"HY000\"}, // 589 tpb_reserv_temptbl\n\t{335544910, \"HY000\"}, // 590 tpb_readtxn_after_writelock\n\t{335544911, \"HY000\"}, // 591 tpb_writelock_after_readtxn\n\t{335544912, \"22008\"}, // 592 time_range_exceeded\n\t{335544913, \"22008\"}, // 593 datetime_range_exceeded\n\t{335544914, \"22001\"}, // 594 string_truncation\n\t{335544915, \"22001\"}, // 595 blob_truncation\n\t{335544916, \"22003\"}, // 596 numeric_out_of_range\n\t{335544917, \"HYT00\"}, // 597 shutdown_timeout\n\t{335544918, \"HY010\"}, // 598 att_handle_busy\n\t{335544919, \"39000\"}, // 599 bad_udf_freeit\n\t{335544920, \"42000\"}, // 600 eds_provider_not_found\n\t{335544921, \"42000\"}, // 601 eds_connection\n\t{335544922, \"42000\"}, // 602 eds_preprocess\n\t{335544923, \"42000\"}, // 603 eds_stmt_expected\n\t{335544924, \"42000\"}, // 604 eds_prm_name_expected\n\t{335544925, \"42000\"}, // 605 eds_unclosed_comment\n\t{335544926, \"42000\"}, // 606 eds_statement\n\t{335544927, \"42000\"}, // 607 eds_input_prm_mismatch\n\t{335544928, \"42000\"}, // 608 eds_output_prm_mismatch\n\t{335544929, \"42000\"}, // 609 eds_input_prm_not_set\n\t{335544930, \"HY000\"}, // 610 too_big_blr\n\t{335544931, \"HY001\"}, // 611 montabexh\n\t{335544932, \"39000\"}, // 612 modnotfound\n\t{335544933, \"HY018\"}, // 613 nothing_to_cancel\n\t{335544934, \"39000\"}, // 614 ibutil_not_loaded\n\t{335544935, \"42000\"}, // 615 circular_computed\n\t{335544936, \"28000\"}, // 616 psw_db_error\n\t{335544937, \"42000\"}, // 617 invalid_type_datetime_op\n\t{335544938, \"42000\"}, // 618 onlycan_add_timetodate\n\t{335544939, \"42000\"}, // 619 onlycan_add_datetotime\n\t{335544940, \"42000\"}, // 620 onlycansub_tstampfromtstamp\n\t{335544941, \"42000\"}, // 621 onlyoneop_mustbe_tstamp\n\t{335544942, \"42000\"}, // 622 invalid_extractpart_time\n\t{335544943, \"42000\"}, // 623 invalid_extractpart_date\n\t{335544944, \"42000\"}, // 624 invalidarg_extract\n\t{335544945, \"42000\"}, // 625 sysf_argmustbe_exact\n\t{335544946, \"42000\"}, // 626 sysf_argmustbe_exact_or_fp\n\t{335544947, \"42000\"}, // 627 sysf_argviolates_uuidtype\n\t{335544948, \"42000\"}, // 628 sysf_argviolates_uuidlen\n\t{335544949, \"42000\"}, // 629 sysf_argviolates_uuidfmt\n\t{335544950, \"42000\"}, // 630 sysf_argviolates_guidigits\n\t{335544951, \"42000\"}, // 631 sysf_invalid_addpart_time\n\t{335544952, \"42000\"}, // 632 sysf_invalid_add_datetime\n\t{335544953, \"42000\"}, // 633 sysf_invalid_addpart_dtime\n\t{335544954, \"42000\"}, // 634 sysf_invalid_add_dtime_rc\n\t{335544955, \"42000\"}, // 635 sysf_invalid_diff_dtime\n\t{335544956, \"42000\"}, // 636 sysf_invalid_timediff\n\t{335544957, \"42000\"}, // 637 sysf_invalid_tstamptimediff\n\t{335544958, \"42000\"}, // 638 sysf_invalid_datetimediff\n\t{335544959, \"42000\"}, // 639 sysf_invalid_diffpart\n\t{335544960, \"42000\"}, // 640 sysf_argmustbe_positive\n\t{335544961, \"42000\"}, // 641 sysf_basemustbe_positive\n\t{335544962, \"42000\"}, // 642 sysf_argnmustbe_nonneg\n\t{335544963, \"42000\"}, // 643 sysf_argnmustbe_positive\n\t{335544964, \"42000\"}, // 644 sysf_invalid_zeropowneg\n\t{335544965, \"42000\"}, // 645 sysf_invalid_negpowfp\n\t{335544966, \"42000\"}, // 646 sysf_invalid_scale\n\t{335544967, \"42000\"}, // 647 sysf_argmustbe_nonneg\n\t{335544968, \"42000\"}, // 648 sysf_binuuid_mustbe_str\n\t{335544969, \"42000\"}, // 649 sysf_binuuid_wrongsize\n\t{335544970, \"HY000\"}, // 650 missing_required_spb\n\t{335544971, \"08006\"}, // 651 net_server_shutdown\n\t{335544972, \"08001\"}, // 652 bad_conn_str\n\t{335544973, \"HY000\"}, // 653 bad_epb_form\n\t{335544974, \"08004\"}, // 654 no_threads\n\t{335544975, \"08006\"}, // 655 net_event_connect_timeout\n\t{335544976, \"42000\"}, // 656 sysf_argmustbe_nonzero\n\t{335544977, \"42000\"}, // 657 sysf_argmustbe_range_inc1_1\n\t{335544978, \"42000\"}, // 658 sysf_argmustbe_gteq_one\n\t{335544979, \"42000\"}, // 659 sysf_argmustbe_range_exc1_1\n\t{335544980, \"HY000\"}, // 660 internal_rejected_params\n\t{335544981, \"42000\"}, // 661 sysf_fp_overflow\n\t{335544982, \"39000\"}, // 662 udf_fp_overflow\n\t{335544983, \"39000\"}, // 663 udf_fp_nan\n\t{335544984, \"42000\"}, // 664 instance_conflict\n\t{335544985, \"HY000\"}, // 665 out_of_temp_space\n\t{335544986, \"42000\"}, // 666 eds_expl_tran_ctrl\n\t{335544987, \"28000\"}, // 667 no_trusted_spb\n\t{335544988, \"42000\"}, // 668 package_name\n\t{335544989, \"22006\"}, // 669 cannot_make_not_null\n\t{335544990, \"0A000\"}, // 670 feature_removed\n\t{335544991, \"00000\"}, // 671 view_name\n\t{335544992, \"08006\"}, // 672 lock_dir_access\n\t{335544993, \"HY106\"}, // 673 invalid_fetch_option\n\t{335544994, \"2F000\"}, // 674 bad_fun_BLR\n\t{335544995, \"2F000\"}, // 675 func_pack_not_implemented\n\t{335544996, \"2F000\"}, // 676 proc_pack_not_implemented\n\t{335544997, \"39000\"}, // 677 eem_func_not_returned\n\t{335544998, \"39000\"}, // 678 eem_proc_not_returned\n\t{335544999, \"39000\"}, // 679 eem_trig_not_returned\n\t{335545000, \"39000\"}, // 680 eem_bad_plugin_ver\n\t{335545001, \"39000\"}, // 681 eem_engine_notfound\n\t{335545002, \"08002\"}, // 682 attachment_in_use\n\t{335545003, \"25S02\"}, // 683 transaction_in_use\n\t{335545004, \"39000\"}, // 684 pman_cannot_load_plugin\n\t{335545005, \"00000\"}, // 685 pman_module_notfound\n\t{335545006, \"00000\"}, // 686 pman_entrypoint_notfound\n\t{335545007, \"00000\"}, // 687 pman_module_bad\n\t{335545008, \"00000\"}, // 688 pman_plugin_notfound\n\t{335545009, \"42000\"}, // 689 sysf_invalid_trig_namespace\n\t{335545010, \"22002\"}, // 690 unexpected_null\n\t{335545011, \"2200G\"}, // 691 type_notcompat_blob\n\t{335545012, \"22003\"}, // 692 invalid_date_val\n\t{335545013, \"22003\"}, // 693 invalid_time_val\n\t{335545014, \"22003\"}, // 694 invalid_timestamp_val\n\t{335545015, \"22003\"}, // 695 invalid_index_val\n\t{335545016, \"00000\"}, // 696 formatted_exception\n\t{335545017, \"HY018\"}, // 697 async_active\n\t{335545018, \"42000\"}, // 698 private_function\n\t{335545019, \"42000\"}, // 699 private_procedure\n\t{335545020, \"24000\"}, // 700 request_outdated\n\t{335545021, \"08003\"}, // 701 bad_events_handle\n\t{335545022, \"XX000\"}, // 702 cannot_copy_stmt\n\t{335545023, \"22000\"}, // 703 invalid_boolean_usage\n\t{335545024, \"42000\"}, // 704 sysf_argscant_both_be_zero\n\t{335545025, \"HY000\"}, // 705 spb_no_id\n\t{335545026, \"42000\"}, // 706 ee_blr_mismatch_null\n\t{335545027, \"42000\"}, // 707 ee_blr_mismatch_length\n\t{335545028, \"42000\"}, // 708 ss_out_of_bounds\n\t{335545029, \"28000\"}, // 709 missing_data_structures\n\t{335545030, \"42000\"}, // 710 protect_sys_tab\n\t{335545031, \"2F000\"}, // 711 libtommath_generic\n\t{335545032, \"HY000\"}, // 712 wroblrver2\n\t{335545033, \"28000\"}, // 713 trunc_limits\n\t{335545034, \"28000\"}, // 714 info_access\n\t{335545035, \"HY024\"}, // 715 svc_no_stdin\n\t{335545036, \"28000\"}, // 716 svc_start_failed\n\t{335545037, \"HY024\"}, // 717 svc_no_switches\n\t{335545038, \"HY109\"}, // 718 svc_bad_size\n\t{335545039, \"HY024\"}, // 719 no_crypt_plugin\n\t{335545040, \"22001\"}, // 720 cp_name_too_long\n\t{335545041, \"42818\"}, // 721 cp_process_active\n\t{335545042, \"42818\"}, // 722 cp_already_crypted\n\t{335545043, \"XX000\"}, // 723 decrypt_error\n\t{335545044, \"39000\"}, // 724 no_providers\n\t{335545045, \"42818\"}, // 725 null_spb\n\t{335545046, \"42000\"}, // 726 max_args_exceeded\n\t{335545047, \"42000\"}, // 727 ee_blr_mismatch_names_count\n\t{335545048, \"42000\"}, // 728 ee_blr_mismatch_name_not_found\n\t{335545049, \"26000\"}, // 729 bad_result_set\n\t{335545050, \"07000\"}, // 730 wrong_message_length\n\t{335545051, \"07000\"}, // 731 no_output_format\n\t{335545052, \"HY021\"}, // 732 item_finish\n\t{335545053, \"XX000\"}, // 733 miss_config\n\t{335545054, \"XX000\"}, // 734 conf_line\n\t{335545055, \"XX000\"}, // 735 conf_include\n\t{335545056, \"XX000\"}, // 736 include_depth\n\t{335545057, \"XX000\"}, // 737 include_miss\n\t{335545058, \"28000\"}, // 738 protect_ownership\n\t{335545059, \"HY000\"}, // 739 badvarnum\n\t{335545060, \"28000\"}, // 740 sec_context\n\t{335545061, \"28000\"}, // 741 multi_segment\n\t{335545062, \"28000\"}, // 742 login_changed\n\t{335545063, \"28000\"}, // 743 auth_handshake_limit\n\t{335545064, \"28000\"}, // 744 wirecrypt_incompatible\n\t{335545065, \"28000\"}, // 745 miss_wirecrypt\n\t{335545066, \"28000\"}, // 746 wirecrypt_key\n\t{335545067, \"28000\"}, // 747 wirecrypt_plugin\n\t{335545068, \"28000\"}, // 748 secdb_name\n\t{335545069, \"28000\"}, // 749 auth_data\n\t{335545070, \"28000\"}, // 750 auth_datalength\n\t{335545071, \"HY007\"}, // 751 info_unprepared_stmt\n\t{335545072, \"HY007\"}, // 752 idx_key_value\n\t{335545073, \"HY000\"}, // 753 forupdate_virtualtbl\n\t{335545074, \"HY000\"}, // 754 forupdate_systbl\n\t{335545075, \"HY000\"}, // 755 forupdate_temptbl\n\t{335545076, \"42000\"}, // 756 cant_modify_sysobj\n\t{335545077, \"08004\"}, // 757 server_misconfigured\n\t{335545078, \"0A000\"}, // 758 alter_role\n\t{335545079, \"42S01\"}, // 759 map_already_exists\n\t{335545080, \"42S02\"}, // 760 map_not_exists\n\t{335545081, \"08004\"}, // 761 map_load\n\t{335545082, \"08004\"}, // 762 map_aster\n\t{335545083, \"08004\"}, // 763 map_multi\n\t{335545084, \"08004\"}, // 764 map_undefined\n\t{335545085, \"HY000\"}, // 765 baddpb_damaged_mode\n\t{335545086, \"HY000\"}, // 766 baddpb_buffers_range\n\t{335545087, \"HY000\"}, // 767 baddpb_temp_buffers\n\t{335545088, \"0A000\"}, // 768 map_nodb\n\t{335545089, \"0A000\"}, // 769 map_notable\n\t{335545090, \"0P000\"}, // 770 miss_trusted_role\n\t{335545091, \"0P000\"}, // 771 set_invalid_role\n\t{335545092, \"HY109\"}, // 772 cursor_not_positioned\n\t{335545093, \"42702\"}, // 773 dup_attribute\n\t{335545094, \"42000\"}, // 774 dyn_no_priv\n\t{335545095, \"42000\"}, // 775 dsql_cant_grant_option\n\t{335545096, \"40001\"}, // 776 read_conflict\n\t{335545097, \"08004\"}, // 777 crdb_load\n\t{335545098, \"0A000\"}, // 778 crdb_nodb\n\t{335545099, \"0A000\"}, // 779 crdb_notable\n\t{335545100, \"HY000\"}, // 780 interface_version_too_old\n\t{335545101, \"07001\"}, // 781 fun_param_mismatch\n\t{335545102, \"HY000\"}, // 782 savepoint_backout_err\n\t{335545103, \"42000\"}, // 783 domain_primary_key_notnull\n\t{335545104, \"2C000\"}, // 784 invalid_attachment_charset\n\t{335545105, \"08004\"}, // 785 map_down\n\t{335545106, \"08006\"}, // 786 login_error\n\t{335545107, \"08006\"}, // 787 already_opened\n\t{335545108, \"08006\"}, // 788 bad_crypt_key\n\t{335545109, \"XX000\"}, // 789 encrypt_error\n\t{335545110, \"54000\"}, // 790 max_idx_depth\n\t{335545111, \"0A000\"}, // 791 wrong_prvlg\n\t{335545112, \"28000\"}, // 792 miss_prvlg\n\t{335545113, \"XX000\"}, // 793 crypt_checksum\n\t{335545114, \"28000\"}, // 794 not_dba\n\t{335545115, \"07005\"}, // 795 no_cursor\n\t{335545116, \"42000\"}, // 796 dsql_window_incompat_frames\n\t{335545117, \"42000\"}, // 797 dsql_window_range_multi_key\n\t{335545118, \"42000\"}, // 798 dsql_window_range_inv_key_type\n\t{335545119, \"42000\"}, // 799 dsql_window_frame_value_inv_type\n\t{335545120, \"42000\"}, // 800 window_frame_value_invalid\n\t{335545121, \"42000\"}, // 801 dsql_window_not_found\n\t{335545122, \"42000\"}, // 802 dsql_window_cant_overr_part\n\t{335545123, \"42000\"}, // 803 dsql_window_cant_overr_order\n\t{335545124, \"42000\"}, // 804 dsql_window_cant_overr_frame\n\t{335545125, \"42000\"}, // 805 dsql_window_duplicate\n\t{335545126, \"54001\"}, // 806 sql_too_long\n\t{335545127, \"HY008\"}, // 807 cfg_stmt_timeout\n\t{335545128, \"HY008\"}, // 808 att_stmt_timeout\n\t{335545129, \"HY008\"}, // 809 req_stmt_timeout\n\t{335545130, \"08003\"}, // 810 att_shut_killed\n\t{335545131, \"08003\"}, // 811 att_shut_idle\n\t{335545132, \"08003\"}, // 812 att_shut_db_down\n\t{335545133, \"08003\"}, // 813 att_shut_engine\n\t{335545134, \"42000\"}, // 814 overriding_without_identity\n\t{335545135, \"42000\"}, // 815 overriding_system_invalid\n\t{335545136, \"42000\"}, // 816 overriding_user_invalid\n\t{335545137, \"42000\"}, // 817 overriding_system_missing\n\t{335545138, \"HY104\"}, // 818 decprecision_err\n\t{335545139, \"22012\"}, // 819 decfloat_divide_by_zero\n\t{335545140, \"22000\"}, // 820 decfloat_inexact_result\n\t{335545141, \"22000\"}, // 821 decfloat_invalid_operation\n\t{335545142, \"22003\"}, // 822 decfloat_overflow\n\t{335545143, \"22003\"}, // 823 decfloat_underflow\n\t{335545144, \"42000\"}, // 824 subfunc_notdef\n\t{335545145, \"42000\"}, // 825 subproc_notdef\n\t{335545146, \"42000\"}, // 826 subfunc_signat\n\t{335545147, \"42000\"}, // 827 subproc_signat\n\t{335545148, \"42000\"}, // 828 subfunc_defvaldecl\n\t{335545149, \"42000\"}, // 829 subproc_defvaldecl\n\t{335545150, \"42000\"}, // 830 subfunc_not_impl\n\t{335545151, \"42000\"}, // 831 subproc_not_impl\n\t{335545152, \"42000\"}, // 832 sysf_invalid_hash_algorithm\n\t{335545153, \"42000\"}, // 833 expression_eval_index\n\t{335545154, \"42000\"}, // 834 invalid_decfloat_trap\n\t{335545155, \"42000\"}, // 835 invalid_decfloat_round\n\t{335545156, \"42000\"}, // 836 sysf_invalid_first_last_part\n\t{335545157, \"42000\"}, // 837 sysf_invalid_date_timestamp\n\t{335545158, \"HY104\"}, // 838 precision_err2\n\t{335545159, \"08003\"}, // 839 bad_batch_handle\n\t{335545160, \"22021\"}, // 840 intl_char\n\t{335545161, \"22000\"}, // 841 null_block\n\t{335545162, \"22000\"}, // 842 mixed_info\n\t{335545163, \"22000\"}, // 843 unknown_info\n\t{335545164, \"22000\"}, // 844 bpb_version\n\t{335545165, \"28000\"}, // 845 user_manager\n\t{335545166, \"XX000\"}, // 846 icu_entrypoint\n\t{335545167, \"XX000\"}, // 847 icu_library\n\t{335545168, \"02000\"}, // 848 metadata_name\n\t{335545169, \"42000\"}, // 849 tokens_parse\n\t{335545170, \"08006\"}, // 850 iconv_open\n\t{335545171, \"07002\"}, // 851 batch_compl_range\n\t{335545172, \"07002\"}, // 852 batch_compl_detail\n\t{335545173, \"08006\"}, // 853 deflate_init\n\t{335545174, \"08006\"}, // 854 inflate_init\n\t{335545175, \"22026\"}, // 855 big_segment\n\t{335545176, \"22000\"}, // 856 batch_policy\n\t{335545177, \"22000\"}, // 857 batch_defbpb\n\t{335545178, \"22000\"}, // 858 batch_align\n\t{335545179, \"22000\"}, // 859 multi_segment_dup\n\t{335545180, \"08004\"}, // 860 non_plugin_protocol\n\t{335545181, \"22000\"}, // 861 message_format\n\t{335545182, \"22000\"}, // 862 batch_param_version\n\t{335545183, \"54000\"}, // 863 batch_msg_long\n\t{335545184, \"08002\"}, // 864 batch_open\n\t{335545185, \"07003\"}, // 865 batch_type\n\t{335545186, \"07001\"}, // 866 batch_param\n\t{335545187, \"07001\"}, // 867 batch_blobs\n\t{335545188, \"22000\"}, // 868 batch_blob_append\n\t{335545189, \"22000\"}, // 869 batch_stream_align\n\t{335545190, \"22000\"}, // 870 batch_rpt_blob\n\t{335545191, \"22000\"}, // 871 batch_blob_buf\n\t{335545192, \"22000\"}, // 872 batch_small_data\n\t{335545193, \"22000\"}, // 873 batch_cont_bpb\n\t{335545194, \"22000\"}, // 874 batch_big_bpb\n\t{335545195, \"22000\"}, // 875 batch_big_segment\n\t{335545196, \"22000\"}, // 876 batch_big_seg2\n\t{335545197, \"22000\"}, // 877 batch_blob_id\n\t{335545198, \"54000\"}, // 878 batch_too_big\n\t{335545199, \"54000\"}, // 879 num_literal\n\t{335545200, \"XX000\"}, // 880 map_event\n\t{335545201, \"54000\"}, // 881 map_overflow\n\t{335545202, \"54000\"}, // 882 hdr_overflow\n\t{335545203, \"28000\"}, // 883 vld_plugins\n\t{335545204, \"08004\"}, // 884 db_crypt_key\n\t{335545205, \"HY024\"}, // 885 no_keyholder_plugin\n\t{335545206, \"01002\"}, // 886 ses_reset_err\n\t{335545207, \"25S02\"}, // 887 ses_reset_open_trans\n\t{335545208, \"01000\"}, // 888 ses_reset_warn\n\t{335545209, \"01102\"}, // 889 ses_reset_tran_rollback\n\t{335545210, \"00000\"}, // 890 plugin_name\n\t{335545211, \"42000\"}, // 891 parameter_name\n\t{335545212, \"HY000\"}, // 892 file_starting_page_err\n\t{335545213, \"22009\"}, // 893 invalid_timezone_offset\n\t{335545214, \"22009\"}, // 894 invalid_timezone_region\n\t{335545215, \"22009\"}, // 895 invalid_timezone_id\n\t{335545216, \"22023\"}, // 896 tom_decode64len\n\t{335545217, \"22023\"}, // 897 tom_strblob\n\t{335545218, \"22023\"}, // 898 tom_reg\n\t{335545219, \"22023\"}, // 899 tom_algorithm\n\t{335545220, \"22023\"}, // 900 tom_mode_miss\n\t{335545221, \"22023\"}, // 901 tom_mode_bad\n\t{335545222, \"22023\"}, // 902 tom_no_mode\n\t{335545223, \"22023\"}, // 903 tom_iv_miss\n\t{335545224, \"22023\"}, // 904 tom_no_iv\n\t{335545225, \"22023\"}, // 905 tom_ctrtype_bad\n\t{335545226, \"22023\"}, // 906 tom_no_ctrtype\n\t{335545227, \"22023\"}, // 907 tom_ctr_big\n\t{335545228, \"22023\"}, // 908 tom_no_ctr\n\t{335545229, \"22023\"}, // 909 tom_iv_length\n\t{335545230, \"22000\"}, // 910 tom_error\n\t{335545231, \"22023\"}, // 911 tom_yarrow_start\n\t{335545232, \"22023\"}, // 912 tom_yarrow_setup\n\t{335545233, \"22023\"}, // 913 tom_init_mode\n\t{335545234, \"22023\"}, // 914 tom_crypt_mode\n\t{335545235, \"22023\"}, // 915 tom_decrypt_mode\n\t{335545236, \"22023\"}, // 916 tom_init_cip\n\t{335545237, \"22023\"}, // 917 tom_crypt_cip\n\t{335545238, \"22023\"}, // 918 tom_decrypt_cip\n\t{335545239, \"22023\"}, // 919 tom_setup_cip\n\t{335545240, \"22023\"}, // 920 tom_setup_chacha\n\t{335545241, \"22023\"}, // 921 tom_encode\n\t{335545242, \"22023\"}, // 922 tom_decode\n\t{335545243, \"22023\"}, // 923 tom_rsa_import\n\t{335545244, \"22023\"}, // 924 tom_oaep\n\t{335545245, \"22023\"}, // 925 tom_hash_bad\n\t{335545246, \"22023\"}, // 926 tom_rsa_make\n\t{335545247, \"22023\"}, // 927 tom_rsa_export\n\t{335545248, \"22023\"}, // 928 tom_rsa_sign\n\t{335545249, \"22023\"}, // 929 tom_rsa_verify\n\t{335545250, \"22023\"}, // 930 tom_chacha_key\n\t{335545251, \"08003\"}, // 931 bad_repl_handle\n\t{335545252, \"0B000\"}, // 932 tra_snapshot_does_not_exist\n\t{335545253, \"42000\"}, // 933 eds_input_prm_not_used\n\t{335545254, \"28000\"}, // 934 effective_user\n\t{335545255, \"42000\"}, // 935 invalid_time_zone_bind\n\t{335545256, \"42000\"}, // 936 invalid_decfloat_bind\n\t{335545257, \"22023\"}, // 937 odd_hex_len\n\t{335545258, \"22023\"}, // 938 invalid_hex_digit\n\t{335545259, \"08004\"}, // 939 bind_err\n\t{335545260, \"08004\"}, // 940 bind_statement\n\t{335545261, \"22000\"}, // 941 bind_convert\n\t{335545262, \"42000\"}, // 942 cannot_update_old_blob\n\t{335545263, \"42000\"}, // 943 cannot_read_new_blob\n\t{335545264, \"42000\"}, // 944 dyn_no_create_priv\n\t{335545265, \"42000\"}, // 945 suspend_without_returns\n\t{335545266, \"01004\"}, // 946 truncate_warn\n\t{335545267, \"01004\"}, // 947 truncate_monitor\n\t{335545268, \"01004\"}, // 948 truncate_context\n\t{335545269, \"21000\"}, // 949 merge_dup_update\n\t{335545270, \"XX000\"}, // 950 wrong_page\n\t{335545271, \"HY000\"}, // 951 repl_error\n\t{335545272, \"08003\"}, // 952 ses_reset_failed\n\t{335740929, \"00000\"}, //   1 gfix_db_name\n\t{335740930, \"00000\"}, //   2 gfix_invalid_sw\n\t{335740932, \"00000\"}, //   4 gfix_incmp_sw\n\t{335740933, \"00000\"}, //   5 gfix_replay_req\n\t{335740934, \"00000\"}, //   6 gfix_pgbuf_req\n\t{335740935, \"00000\"}, //   7 gfix_val_req\n\t{335740936, \"00000\"}, //   8 gfix_pval_req\n\t{335740937, \"00000\"}, //   9 gfix_trn_req\n\t{335740940, \"00000\"}, //  12 gfix_full_req\n\t{335740941, \"00000\"}, //  13 gfix_usrname_req\n\t{335740942, \"00000\"}, //  14 gfix_pass_req\n\t{335740943, \"00000\"}, //  15 gfix_subs_name\n\t{335740944, \"00000\"}, //  16 gfix_wal_req\n\t{335740945, \"00000\"}, //  17 gfix_sec_req\n\t{335740946, \"00000\"}, //  18 gfix_nval_req\n\t{335740947, \"00000\"}, //  19 gfix_type_shut\n\t{335740948, \"00000\"}, //  20 gfix_retry\n\t{335740951, \"00000\"}, //  23 gfix_retry_db\n\t{335740991, \"00000\"}, //  63 gfix_exceed_max\n\t{335740992, \"00000\"}, //  64 gfix_corrupt_pool\n\t{335740993, \"00000\"}, //  65 gfix_mem_exhausted\n\t{335740994, \"00000\"}, //  66 gfix_bad_pool\n\t{335740995, \"00000\"}, //  67 gfix_trn_not_valid\n\t{335741012, \"00000\"}, //  84 gfix_unexp_eoi\n\t{335741018, \"00000\"}, //  90 gfix_recon_fail\n\t{335741036, \"00000\"}, // 108 gfix_trn_unknown\n\t{335741038, \"00000\"}, // 110 gfix_mode_req\n\t{335741042, \"00000\"}, // 114 gfix_pzval_req\n\t{336003074, \"HY000\"}, //   2 dsql_dbkey_from_non_table\n\t{336003075, \"HY000\"}, //   3 dsql_transitional_numeric\n\t{336003076, \"01000\"}, //   4 dsql_dialect_warning_expr\n\t{336003077, \"HY000\"}, //   5 sql_db_dialect_dtype_unsupport\n\t{336003079, \"HY000\"}, //   7 sql_dialect_conflict_num\n\t{336003080, \"HY104\"}, //   8 dsql_warning_number_ambiguous\n\t{336003081, \"HY104\"}, //   9 dsql_warning_number_ambiguous1\n\t{336003082, \"HY104\"}, //  10 dsql_warn_precision_ambiguous\n\t{336003083, \"HY104\"}, //  11 dsql_warn_precision_ambiguous1\n\t{336003084, \"HY104\"}, //  12 dsql_warn_precision_ambiguous2\n\t{336003085, \"42702\"}, //  13 dsql_ambiguous_field_name\n\t{336003086, \"38000\"}, //  14 dsql_udf_return_pos_err\n\t{336003087, \"HY000\"}, //  15 dsql_invalid_label\n\t{336003088, \"HY004\"}, //  16 dsql_datatypes_not_comparable\n\t{336003089, \"24000\"}, //  17 dsql_cursor_invalid\n\t{336003090, \"24000\"}, //  18 dsql_cursor_redefined\n\t{336003091, \"34000\"}, //  19 dsql_cursor_not_found\n\t{336003092, \"24000\"}, //  20 dsql_cursor_exists\n\t{336003093, \"34000\"}, //  21 dsql_cursor_rel_ambiguous\n\t{336003094, \"34000\"}, //  22 dsql_cursor_rel_not_found\n\t{336003095, \"24000\"}, //  23 dsql_cursor_not_open\n\t{336003096, \"HY004\"}, //  24 dsql_type_not_supp_ext_tab\n\t{336003097, \"0A000\"}, //  25 dsql_feature_not_supported_ods\n\t{336003098, \"22000\"}, //  26 primary_key_required\n\t{336003099, \"42000\"}, //  27 upd_ins_doesnt_match_pk\n\t{336003100, \"42000\"}, //  28 upd_ins_doesnt_match_matching\n\t{336003101, \"54001\"}, //  29 upd_ins_with_complex_view\n\t{336003102, \"42000\"}, //  30 dsql_incompatible_trigger_type\n\t{336003103, \"42000\"}, //  31 dsql_db_trigger_type_cant_change\n\t{336003104, \"HY000\"}, //  32 dsql_record_version_table\n\t{336003105, \"07002\"}, //  33 dsql_invalid_sqlda_version\n\t{336003106, \"07002\"}, //  34 dsql_sqlvar_index\n\t{336003107, \"07002\"}, //  35 dsql_no_sqlind\n\t{336003108, \"07002\"}, //  36 dsql_no_sqldata\n\t{336003109, \"07002\"}, //  37 dsql_no_input_sqlda\n\t{336003110, \"07002\"}, //  38 dsql_no_output_sqlda\n\t{336003111, \"07001\"}, //  39 dsql_wrong_param_num\n\t{336003112, \"42000\"}, //  40 dsql_invalid_drop_ss_clause\n\t{336003113, \"42000\"}, //  41 upd_ins_cannot_default\n\t{336068645, \"42000\"}, //  37 dyn_filter_not_found\n\t{336068649, \"42000\"}, //  41 dyn_func_not_found\n\t{336068656, \"42000\"}, //  48 dyn_index_not_found\n\t{336068662, \"42000\"}, //  54 dyn_view_not_found\n\t{336068697, \"42000\"}, //  89 dyn_domain_not_found\n\t{336068717, \"42000\"}, // 109 dyn_cant_modify_auto_trig\n\t{336068740, \"42S01\"}, // 132 dyn_dup_table\n\t{336068748, \"42000\"}, // 140 dyn_proc_not_found\n\t{336068752, \"42000\"}, // 144 dyn_exception_not_found\n\t{336068754, \"42000\"}, // 146 dyn_proc_param_not_found\n\t{336068755, \"42000\"}, // 147 dyn_trig_not_found\n\t{336068759, \"42000\"}, // 151 dyn_charset_not_found\n\t{336068760, \"42000\"}, // 152 dyn_collation_not_found\n\t{336068763, \"42000\"}, // 155 dyn_role_not_found\n\t{336068767, \"42000\"}, // 159 dyn_name_longer\n\t{336068784, \"42S22\"}, // 176 dyn_column_does_not_exist\n\t{336068796, \"28000\"}, // 188 dyn_role_does_not_exist\n\t{336068797, \"28000\"}, // 189 dyn_no_grant_admin_opt\n\t{336068798, \"28000\"}, // 190 dyn_user_not_role_member\n\t{336068799, \"28000\"}, // 191 dyn_delete_role_failed\n\t{336068800, \"28000\"}, // 192 dyn_grant_role_to_user\n\t{336068801, \"28000\"}, // 193 dyn_inv_sql_role_name\n\t{336068802, \"42000\"}, // 194 dyn_dup_sql_role\n\t{336068803, \"28000\"}, // 195 dyn_kywd_spec_for_role\n\t{336068804, \"28000\"}, // 196 dyn_roles_not_supported\n\t{336068812, \"42000\"}, // 204 dyn_domain_name_exists\n\t{336068813, \"42S21\"}, // 205 dyn_field_name_exists\n\t{336068814, \"42000\"}, // 206 dyn_dependency_exists\n\t{336068815, \"42000\"}, // 207 dyn_dtype_invalid\n\t{336068816, \"42000\"}, // 208 dyn_char_fld_too_small\n\t{336068817, \"42000\"}, // 209 dyn_invalid_dtype_conversion\n\t{336068818, \"42000\"}, // 210 dyn_dtype_conv_invalid\n\t{336068820, \"42000\"}, // 212 dyn_zero_len_id\n\t{336068822, \"42000\"}, // 214 dyn_gen_not_found\n\t{336068829, \"2C000\"}, // 221 max_coll_per_charset\n\t{336068830, \"HY000\"}, // 222 invalid_coll_attr\n\t{336068840, \"HY000\"}, // 232 dyn_wrong_gtt_scope\n\t{336068843, \"HY000\"}, // 235 dyn_coll_used_table\n\t{336068844, \"HY000\"}, // 236 dyn_coll_used_domain\n\t{336068845, \"HY000\"}, // 237 dyn_cannot_del_syscoll\n\t{336068846, \"HY000\"}, // 238 dyn_cannot_del_def_coll\n\t{336068849, \"42000\"}, // 241 dyn_table_not_found\n\t{336068851, \"HY000\"}, // 243 dyn_coll_used_procedure\n\t{336068852, \"42000\"}, // 244 dyn_scale_too_big\n\t{336068853, \"42000\"}, // 245 dyn_precision_too_small\n\t{336068855, \"42000\"}, // 247 dyn_miss_priv_warning\n\t{336068856, \"0A000\"}, // 248 dyn_ods_not_supp_feature\n\t{336068857, \"42000\"}, // 249 dyn_cannot_addrem_computed\n\t{336068858, \"42000\"}, // 250 dyn_no_empty_pw\n\t{336068859, \"42S11\"}, // 251 dyn_dup_index\n\t{336068864, \"42000\"}, // 256 dyn_package_not_found\n\t{336068865, \"42000\"}, // 257 dyn_schema_not_found\n\t{336068866, \"HY000\"}, // 258 dyn_cannot_mod_sysproc\n\t{336068867, \"HY000\"}, // 259 dyn_cannot_mod_systrig\n\t{336068868, \"HY000\"}, // 260 dyn_cannot_mod_sysfunc\n\t{336068869, \"HY000\"}, // 261 dyn_invalid_ddl_proc\n\t{336068870, \"HY000\"}, // 262 dyn_invalid_ddl_trig\n\t{336068871, \"42000\"}, // 263 dyn_funcnotdef_package\n\t{336068872, \"42000\"}, // 264 dyn_procnotdef_package\n\t{336068873, \"42000\"}, // 265 dyn_funcsignat_package\n\t{336068874, \"42000\"}, // 266 dyn_procsignat_package\n\t{336068875, \"42000\"}, // 267 dyn_defvaldecl_package_proc\n\t{336068877, \"42000\"}, // 269 dyn_package_body_exists\n\t{336068878, \"HY000\"}, // 270 dyn_invalid_ddl_func\n\t{336068879, \"42000\"}, // 271 dyn_newfc_oldsyntax\n\t{336068886, \"42000\"}, // 278 dyn_func_param_not_found\n\t{336068887, \"42000\"}, // 279 dyn_routine_param_not_found\n\t{336068888, \"42000\"}, // 280 dyn_routine_param_ambiguous\n\t{336068889, \"HY000\"}, // 281 dyn_coll_used_function\n\t{336068890, \"HY000\"}, // 282 dyn_domain_used_function\n\t{336068891, \"42000\"}, // 283 dyn_alter_user_no_clause\n\t{336068894, \"42000\"}, // 286 dyn_duplicate_package_item\n\t{336068895, \"42000\"}, // 287 dyn_cant_modify_sysobj\n\t{336068896, \"42000\"}, // 288 dyn_cant_use_zero_increment\n\t{336068897, \"42000\"}, // 289 dyn_cant_use_in_foreignkey\n\t{336068898, \"42000\"}, // 290 dyn_defvaldecl_package_func\n\t{336068900, \"42000\"}, // 292 dyn_cyclic_role\n\t{336068904, \"42000\"}, // 296 dyn_cant_use_zero_inc_ident\n\t{336068907, \"42000\"}, // 299 dyn_no_ddl_grant_opt_priv\n\t{336068908, \"42000\"}, // 300 dyn_no_grant_opt_priv\n\t{336068909, \"42000\"}, // 301 dyn_func_not_exist\n\t{336068910, \"42000\"}, // 302 dyn_proc_not_exist\n\t{336068911, \"42000\"}, // 303 dyn_pack_not_exist\n\t{336068912, \"42000\"}, // 304 dyn_trig_not_exist\n\t{336068913, \"42000\"}, // 305 dyn_view_not_exist\n\t{336068914, \"42000\"}, // 306 dyn_rel_not_exist\n\t{336068915, \"42000\"}, // 307 dyn_exc_not_exist\n\t{336068916, \"42000\"}, // 308 dyn_gen_not_exist\n\t{336068917, \"42000\"}, // 309 dyn_fld_not_exist\n\t{336330753, \"00000\"}, //   1 gbak_unknown_switch\n\t{336330754, \"00000\"}, //   2 gbak_page_size_missing\n\t{336330755, \"00000\"}, //   3 gbak_page_size_toobig\n\t{336330756, \"00000\"}, //   4 gbak_redir_ouput_missing\n\t{336330757, \"00000\"}, //   5 gbak_switches_conflict\n\t{336330758, \"00000\"}, //   6 gbak_unknown_device\n\t{336330759, \"00000\"}, //   7 gbak_no_protection\n\t{336330760, \"00000\"}, //   8 gbak_page_size_not_allowed\n\t{336330761, \"00000\"}, //   9 gbak_multi_source_dest\n\t{336330762, \"00000\"}, //  10 gbak_filename_missing\n\t{336330763, \"00000\"}, //  11 gbak_dup_inout_names\n\t{336330764, \"00000\"}, //  12 gbak_inv_page_size\n\t{336330765, \"00000\"}, //  13 gbak_db_specified\n\t{336330766, \"00000\"}, //  14 gbak_db_exists\n\t{336330767, \"00000\"}, //  15 gbak_unk_device\n\t{336330772, \"00000\"}, //  20 gbak_blob_info_failed\n\t{336330773, \"00000\"}, //  21 gbak_unk_blob_item\n\t{336330774, \"00000\"}, //  22 gbak_get_seg_failed\n\t{336330775, \"00000\"}, //  23 gbak_close_blob_failed\n\t{336330776, \"00000\"}, //  24 gbak_open_blob_failed\n\t{336330777, \"00000\"}, //  25 gbak_put_blr_gen_id_failed\n\t{336330778, \"00000\"}, //  26 gbak_unk_type\n\t{336330779, \"00000\"}, //  27 gbak_comp_req_failed\n\t{336330780, \"00000\"}, //  28 gbak_start_req_failed\n\t{336330781, \"00000\"}, //  29 gbak_rec_failed\n\t{336330782, \"00000\"}, //  30 gbak_rel_req_failed\n\t{336330783, \"00000\"}, //  31 gbak_db_info_failed\n\t{336330784, \"00000\"}, //  32 gbak_no_db_desc\n\t{336330785, \"00000\"}, //  33 gbak_db_create_failed\n\t{336330786, \"00000\"}, //  34 gbak_decomp_len_error\n\t{336330787, \"00000\"}, //  35 gbak_tbl_missing\n\t{336330788, \"00000\"}, //  36 gbak_blob_col_missing\n\t{336330789, \"00000\"}, //  37 gbak_create_blob_failed\n\t{336330790, \"00000\"}, //  38 gbak_put_seg_failed\n\t{336330791, \"00000\"}, //  39 gbak_rec_len_exp\n\t{336330792, \"00000\"}, //  40 gbak_inv_rec_len\n\t{336330793, \"00000\"}, //  41 gbak_exp_data_type\n\t{336330794, \"00000\"}, //  42 gbak_gen_id_failed\n\t{336330795, \"00000\"}, //  43 gbak_unk_rec_type\n\t{336330796, \"00000\"}, //  44 gbak_inv_bkup_ver\n\t{336330797, \"00000\"}, //  45 gbak_missing_bkup_desc\n\t{336330798, \"00000\"}, //  46 gbak_string_trunc\n\t{336330799, \"00000\"}, //  47 gbak_cant_rest_record\n\t{336330800, \"00000\"}, //  48 gbak_send_failed\n\t{336330801, \"00000\"}, //  49 gbak_no_tbl_name\n\t{336330802, \"00000\"}, //  50 gbak_unexp_eof\n\t{336330803, \"00000\"}, //  51 gbak_db_format_too_old\n\t{336330804, \"00000\"}, //  52 gbak_inv_array_dim\n\t{336330807, \"00000\"}, //  55 gbak_xdr_len_expected\n\t{336330817, \"00000\"}, //  65 gbak_open_bkup_error\n\t{336330818, \"00000\"}, //  66 gbak_open_error\n\t{336330934, \"00000\"}, // 182 gbak_missing_block_fac\n\t{336330935, \"00000\"}, // 183 gbak_inv_block_fac\n\t{336330936, \"00000\"}, // 184 gbak_block_fac_specified\n\t{336330940, \"00000\"}, // 188 gbak_missing_username\n\t{336330941, \"00000\"}, // 189 gbak_missing_password\n\t{336330952, \"00000\"}, // 200 gbak_missing_skipped_bytes\n\t{336330953, \"00000\"}, // 201 gbak_inv_skipped_bytes\n\t{336330965, \"00000\"}, // 213 gbak_err_restore_charset\n\t{336330967, \"00000\"}, // 215 gbak_err_restore_collation\n\t{336330972, \"00000\"}, // 220 gbak_read_error\n\t{336330973, \"00000\"}, // 221 gbak_write_error\n\t{336330985, \"00000\"}, // 233 gbak_db_in_use\n\t{336330990, \"00000\"}, // 238 gbak_sysmemex\n\t{336331002, \"00000\"}, // 250 gbak_restore_role_failed\n\t{336331005, \"00000\"}, // 253 gbak_role_op_missing\n\t{336331010, \"00000\"}, // 258 gbak_page_buffers_missing\n\t{336331011, \"00000\"}, // 259 gbak_page_buffers_wrong_param\n\t{336331012, \"00000\"}, // 260 gbak_page_buffers_restore\n\t{336331014, \"00000\"}, // 262 gbak_inv_size\n\t{336331015, \"00000\"}, // 263 gbak_file_outof_sequence\n\t{336331016, \"00000\"}, // 264 gbak_join_file_missing\n\t{336331017, \"00000\"}, // 265 gbak_stdin_not_supptd\n\t{336331018, \"00000\"}, // 266 gbak_stdout_not_supptd\n\t{336331019, \"00000\"}, // 267 gbak_bkup_corrupt\n\t{336331020, \"00000\"}, // 268 gbak_unk_db_file_spec\n\t{336331021, \"00000\"}, // 269 gbak_hdr_write_failed\n\t{336331022, \"00000\"}, // 270 gbak_disk_space_ex\n\t{336331023, \"00000\"}, // 271 gbak_size_lt_min\n\t{336331025, \"00000\"}, // 273 gbak_svc_name_missing\n\t{336331026, \"00000\"}, // 274 gbak_not_ownr\n\t{336331031, \"00000\"}, // 279 gbak_mode_req\n\t{336331033, \"00000\"}, // 281 gbak_just_data\n\t{336331034, \"00000\"}, // 282 gbak_data_only\n\t{336331078, \"00000\"}, // 326 gbak_missing_interval\n\t{336331079, \"00000\"}, // 327 gbak_wrong_interval\n\t{336331081, \"00000\"}, // 329 gbak_verify_verbint\n\t{336331082, \"00000\"}, // 330 gbak_option_only_restore\n\t{336331083, \"00000\"}, // 331 gbak_option_only_backup\n\t{336331084, \"00000\"}, // 332 gbak_option_conflict\n\t{336331085, \"00000\"}, // 333 gbak_param_conflict\n\t{336331086, \"00000\"}, // 334 gbak_option_repeated\n\t{336331091, \"00000\"}, // 339 gbak_max_dbkey_recursion\n\t{336331092, \"00000\"}, // 340 gbak_max_dbkey_length\n\t{336331093, \"00000\"}, // 341 gbak_invalid_metadata\n\t{336331094, \"00000\"}, // 342 gbak_invalid_data\n\t{336331096, \"00000\"}, // 344 gbak_inv_bkup_ver2\n\t{336331100, \"00000\"}, // 348 gbak_db_format_too_old2\n\t{336397205, \"HY000\"}, // 917 dsql_too_old_ods\n\t{336397206, \"42S02\"}, // 918 dsql_table_not_found\n\t{336397207, \"42S02\"}, // 919 dsql_view_not_found\n\t{336397208, \"42000\"}, // 920 dsql_line_col_error\n\t{336397209, \"42000\"}, // 921 dsql_unknown_pos\n\t{336397210, \"HY000\"}, // 922 dsql_no_dup_name\n\t{336397211, \"07002\"}, // 923 dsql_too_many_values\n\t{336397212, \"HY000\"}, // 924 dsql_no_array_computed\n\t{336397213, \"00000\"}, // 925 dsql_implicit_domain_name\n\t{336397214, \"42000\"}, // 926 dsql_only_can_subscript_array\n\t{336397215, \"54011\"}, // 927 dsql_max_sort_items\n\t{336397216, \"54011\"}, // 928 dsql_max_group_items\n\t{336397217, \"42000\"}, // 929 dsql_conflicting_sort_field\n\t{336397218, \"54001\"}, // 930 dsql_derived_table_more_columns\n\t{336397219, \"54001\"}, // 931 dsql_derived_table_less_columns\n\t{336397220, \"42000\"}, // 932 dsql_derived_field_unnamed\n\t{336397221, \"42000\"}, // 933 dsql_derived_field_dup_name\n\t{336397222, \"42000\"}, // 934 dsql_derived_alias_select\n\t{336397223, \"42000\"}, // 935 dsql_derived_alias_field\n\t{336397224, \"42000\"}, // 936 dsql_auto_field_bad_pos\n\t{336397225, \"42000\"}, // 937 dsql_cte_wrong_reference\n\t{336397226, \"42000\"}, // 938 dsql_cte_cycle\n\t{336397227, \"42000\"}, // 939 dsql_cte_outer_join\n\t{336397228, \"42000\"}, // 940 dsql_cte_mult_references\n\t{336397229, \"42000\"}, // 941 dsql_cte_not_a_union\n\t{336397230, \"42000\"}, // 942 dsql_cte_nonrecurs_after_recurs\n\t{336397231, \"42000\"}, // 943 dsql_cte_wrong_clause\n\t{336397232, \"42000\"}, // 944 dsql_cte_union_all\n\t{336397233, \"42000\"}, // 945 dsql_cte_miss_nonrecursive\n\t{336397234, \"42000\"}, // 946 dsql_cte_nested_with\n\t{336397235, \"42000\"}, // 947 dsql_col_more_than_once_using\n\t{336397236, \"HY000\"}, // 948 dsql_unsupp_feature_dialect\n\t{336397237, \"42000\"}, // 949 dsql_cte_not_used\n\t{336397238, \"42000\"}, // 950 dsql_col_more_than_once_view\n\t{336397239, \"HY000\"}, // 951 dsql_unsupported_in_auto_trans\n\t{336397240, \"42000\"}, // 952 dsql_eval_unknode\n\t{336397241, \"42000\"}, // 953 dsql_agg_wrongarg\n\t{336397242, \"42000\"}, // 954 dsql_agg2_wrongarg\n\t{336397243, \"42000\"}, // 955 dsql_nodateortime_pm_string\n\t{336397244, \"42000\"}, // 956 dsql_invalid_datetime_subtract\n\t{336397245, \"42000\"}, // 957 dsql_invalid_dateortime_add\n\t{336397246, \"42000\"}, // 958 dsql_invalid_type_minus_date\n\t{336397247, \"42000\"}, // 959 dsql_nostring_addsub_dial3\n\t{336397248, \"42000\"}, // 960 dsql_invalid_type_addsub_dial3\n\t{336397249, \"42000\"}, // 961 dsql_invalid_type_multip_dial1\n\t{336397250, \"42000\"}, // 962 dsql_nostring_multip_dial3\n\t{336397251, \"42000\"}, // 963 dsql_invalid_type_multip_dial3\n\t{336397252, \"42000\"}, // 964 dsql_mustuse_numeric_div_dial1\n\t{336397253, \"42000\"}, // 965 dsql_nostring_div_dial3\n\t{336397254, \"42000\"}, // 966 dsql_invalid_type_div_dial3\n\t{336397255, \"42000\"}, // 967 dsql_nostring_neg_dial3\n\t{336397256, \"42000\"}, // 968 dsql_invalid_type_neg\n\t{336397257, \"54011\"}, // 969 dsql_max_distinct_items\n\t{336397258, \"42000\"}, // 970 dsql_alter_charset_failed\n\t{336397259, \"42000\"}, // 971 dsql_comment_on_failed\n\t{336397260, \"42000\"}, // 972 dsql_create_func_failed\n\t{336397261, \"42000\"}, // 973 dsql_alter_func_failed\n\t{336397262, \"42000\"}, // 974 dsql_create_alter_func_failed\n\t{336397263, \"42000\"}, // 975 dsql_drop_func_failed\n\t{336397264, \"42000\"}, // 976 dsql_recreate_func_failed\n\t{336397265, \"42000\"}, // 977 dsql_create_proc_failed\n\t{336397266, \"42000\"}, // 978 dsql_alter_proc_failed\n\t{336397267, \"42000\"}, // 979 dsql_create_alter_proc_failed\n\t{336397268, \"42000\"}, // 980 dsql_drop_proc_failed\n\t{336397269, \"42000\"}, // 981 dsql_recreate_proc_failed\n\t{336397270, \"42000\"}, // 982 dsql_create_trigger_failed\n\t{336397271, \"42000\"}, // 983 dsql_alter_trigger_failed\n\t{336397272, \"42000\"}, // 984 dsql_create_alter_trigger_failed\n\t{336397273, \"42000\"}, // 985 dsql_drop_trigger_failed\n\t{336397274, \"42000\"}, // 986 dsql_recreate_trigger_failed\n\t{336397275, \"42000\"}, // 987 dsql_create_collation_failed\n\t{336397276, \"42000\"}, // 988 dsql_drop_collation_failed\n\t{336397277, \"42000\"}, // 989 dsql_create_domain_failed\n\t{336397278, \"42000\"}, // 990 dsql_alter_domain_failed\n\t{336397279, \"42000\"}, // 991 dsql_drop_domain_failed\n\t{336397280, \"42000\"}, // 992 dsql_create_except_failed\n\t{336397281, \"42000\"}, // 993 dsql_alter_except_failed\n\t{336397282, \"42000\"}, // 994 dsql_create_alter_except_failed\n\t{336397283, \"42000\"}, // 995 dsql_recreate_except_failed\n\t{336397284, \"42000\"}, // 996 dsql_drop_except_failed\n\t{336397285, \"42000\"}, // 997 dsql_create_sequence_failed\n\t{336397286, \"42000\"}, // 998 dsql_create_table_failed\n\t{336397287, \"42000\"}, // 999 dsql_alter_table_failed\n\t{336397288, \"42000\"}, // 1000 dsql_drop_table_failed\n\t{336397289, \"42000\"}, // 1001 dsql_recreate_table_failed\n\t{336397290, \"42000\"}, // 1002 dsql_create_pack_failed\n\t{336397291, \"42000\"}, // 1003 dsql_alter_pack_failed\n\t{336397292, \"42000\"}, // 1004 dsql_create_alter_pack_failed\n\t{336397293, \"42000\"}, // 1005 dsql_drop_pack_failed\n\t{336397294, \"42000\"}, // 1006 dsql_recreate_pack_failed\n\t{336397295, \"42000\"}, // 1007 dsql_create_pack_body_failed\n\t{336397296, \"42000\"}, // 1008 dsql_drop_pack_body_failed\n\t{336397297, \"42000\"}, // 1009 dsql_recreate_pack_body_failed\n\t{336397298, \"42000\"}, // 1010 dsql_create_view_failed\n\t{336397299, \"42000\"}, // 1011 dsql_alter_view_failed\n\t{336397300, \"42000\"}, // 1012 dsql_create_alter_view_failed\n\t{336397301, \"42000\"}, // 1013 dsql_recreate_view_failed\n\t{336397302, \"42000\"}, // 1014 dsql_drop_view_failed\n\t{336397303, \"42000\"}, // 1015 dsql_drop_sequence_failed\n\t{336397304, \"42000\"}, // 1016 dsql_recreate_sequence_failed\n\t{336397305, \"42000\"}, // 1017 dsql_drop_index_failed\n\t{336397306, \"42000\"}, // 1018 dsql_drop_filter_failed\n\t{336397307, \"42000\"}, // 1019 dsql_drop_shadow_failed\n\t{336397308, \"42000\"}, // 1020 dsql_drop_role_failed\n\t{336397309, \"42000\"}, // 1021 dsql_drop_user_failed\n\t{336397310, \"42000\"}, // 1022 dsql_create_role_failed\n\t{336397311, \"42000\"}, // 1023 dsql_alter_role_failed\n\t{336397312, \"42000\"}, // 1024 dsql_alter_index_failed\n\t{336397313, \"42000\"}, // 1025 dsql_alter_database_failed\n\t{336397314, \"42000\"}, // 1026 dsql_create_shadow_failed\n\t{336397315, \"42000\"}, // 1027 dsql_create_filter_failed\n\t{336397316, \"42000\"}, // 1028 dsql_create_index_failed\n\t{336397317, \"42000\"}, // 1029 dsql_create_user_failed\n\t{336397318, \"42000\"}, // 1030 dsql_alter_user_failed\n\t{336397319, \"42000\"}, // 1031 dsql_grant_failed\n\t{336397320, \"42000\"}, // 1032 dsql_revoke_failed\n\t{336397321, \"42000\"}, // 1033 dsql_cte_recursive_aggregate\n\t{336397322, \"42000\"}, // 1034 dsql_mapping_failed\n\t{336397323, \"42000\"}, // 1035 dsql_alter_sequence_failed\n\t{336397324, \"42000\"}, // 1036 dsql_create_generator_failed\n\t{336397325, \"42000\"}, // 1037 dsql_set_generator_failed\n\t{336397326, \"42000\"}, // 1038 dsql_wlock_simple\n\t{336397327, \"42000\"}, // 1039 dsql_firstskip_rows\n\t{336397328, \"42000\"}, // 1040 dsql_wlock_aggregates\n\t{336397329, \"42000\"}, // 1041 dsql_wlock_conflict\n\t{336397330, \"07002\"}, // 1042 dsql_max_exception_arguments\n\t{336397331, \"42000\"}, // 1043 dsql_string_byte_length\n\t{336397332, \"42000\"}, // 1044 dsql_string_char_length\n\t{336397333, \"07002\"}, // 1045 dsql_max_nesting\n\t{336397334, \"42000\"}, // 1046 dsql_recreate_user_failed\n\t{336723983, \"00000\"}, //  15 gsec_cant_open_db\n\t{336723984, \"00000\"}, //  16 gsec_switches_error\n\t{336723985, \"00000\"}, //  17 gsec_no_op_spec\n\t{336723986, \"00000\"}, //  18 gsec_no_usr_name\n\t{336723987, \"00000\"}, //  19 gsec_err_add\n\t{336723988, \"00000\"}, //  20 gsec_err_modify\n\t{336723989, \"00000\"}, //  21 gsec_err_find_mod\n\t{336723990, \"00000\"}, //  22 gsec_err_rec_not_found\n\t{336723991, \"00000\"}, //  23 gsec_err_delete\n\t{336723992, \"00000\"}, //  24 gsec_err_find_del\n\t{336723996, \"00000\"}, //  28 gsec_err_find_disp\n\t{336723997, \"00000\"}, //  29 gsec_inv_param\n\t{336723998, \"00000\"}, //  30 gsec_op_specified\n\t{336723999, \"00000\"}, //  31 gsec_pw_specified\n\t{336724000, \"00000\"}, //  32 gsec_uid_specified\n\t{336724001, \"00000\"}, //  33 gsec_gid_specified\n\t{336724002, \"00000\"}, //  34 gsec_proj_specified\n\t{336724003, \"00000\"}, //  35 gsec_org_specified\n\t{336724004, \"00000\"}, //  36 gsec_fname_specified\n\t{336724005, \"00000\"}, //  37 gsec_mname_specified\n\t{336724006, \"00000\"}, //  38 gsec_lname_specified\n\t{336724008, \"00000\"}, //  40 gsec_inv_switch\n\t{336724009, \"00000\"}, //  41 gsec_amb_switch\n\t{336724010, \"00000\"}, //  42 gsec_no_op_specified\n\t{336724011, \"00000\"}, //  43 gsec_params_not_allowed\n\t{336724012, \"00000\"}, //  44 gsec_incompat_switch\n\t{336724044, \"00000\"}, //  76 gsec_inv_username\n\t{336724045, \"00000\"}, //  77 gsec_inv_pw_length\n\t{336724046, \"00000\"}, //  78 gsec_db_specified\n\t{336724047, \"00000\"}, //  79 gsec_db_admin_specified\n\t{336724048, \"00000\"}, //  80 gsec_db_admin_pw_specified\n\t{336724049, \"00000\"}, //  81 gsec_sql_role_specified\n\t{336920577, \"00000\"}, //   1 gstat_unknown_switch\n\t{336920578, \"00000\"}, //   2 gstat_retry\n\t{336920579, \"00000\"}, //   3 gstat_wrong_ods\n\t{336920580, \"00000\"}, //   4 gstat_unexpected_eof\n\t{336920605, \"00000\"}, //  29 gstat_open_err\n\t{336920606, \"00000\"}, //  30 gstat_read_err\n\t{336920607, \"00000\"}, //  31 gstat_sysmemex\n\t{336986113, \"00000\"}, //   1 fbsvcmgr_bad_am\n\t{336986114, \"00000\"}, //   2 fbsvcmgr_bad_wm\n\t{336986115, \"00000\"}, //   3 fbsvcmgr_bad_rs\n\t{336986116, \"00000\"}, //   4 fbsvcmgr_info_err\n\t{336986117, \"00000\"}, //   5 fbsvcmgr_query_err\n\t{336986118, \"00000\"}, //   6 fbsvcmgr_switch_unknown\n\t{336986159, \"00000\"}, //  47 fbsvcmgr_bad_sm\n\t{336986160, \"00000\"}, //  48 fbsvcmgr_fp_open\n\t{336986161, \"00000\"}, //  49 fbsvcmgr_fp_read\n\t{336986162, \"00000\"}, //  50 fbsvcmgr_fp_empty\n\t{336986164, \"00000\"}, //  52 fbsvcmgr_bad_arg\n\t{336986170, \"00000\"}, //  58 fbsvcmgr_info_limbo\n\t{336986171, \"00000\"}, //  59 fbsvcmgr_limbo_state\n\t{336986172, \"00000\"}, //  60 fbsvcmgr_limbo_advise\n\t{337051649, \"00000\"}, //   1 utl_trusted_switch\n\t{337117213, \"00000\"}, //  29 nbackup_missing_param\n\t{337117214, \"00000\"}, //  30 nbackup_allowed_switches\n\t{337117215, \"00000\"}, //  31 nbackup_unknown_param\n\t{337117216, \"00000\"}, //  32 nbackup_unknown_switch\n\t{337117217, \"00000\"}, //  33 nbackup_nofetchpw_svc\n\t{337117218, \"00000\"}, //  34 nbackup_pwfile_error\n\t{337117219, \"00000\"}, //  35 nbackup_size_with_lock\n\t{337117220, \"00000\"}, //  36 nbackup_no_switch\n\t{337117223, \"00000\"}, //  39 nbackup_err_read\n\t{337117224, \"00000\"}, //  40 nbackup_err_write\n\t{337117225, \"00000\"}, //  41 nbackup_err_seek\n\t{337117226, \"00000\"}, //  42 nbackup_err_opendb\n\t{337117227, \"00000\"}, //  43 nbackup_err_fadvice\n\t{337117228, \"00000\"}, //  44 nbackup_err_createdb\n\t{337117229, \"00000\"}, //  45 nbackup_err_openbk\n\t{337117230, \"00000\"}, //  46 nbackup_err_createbk\n\t{337117231, \"00000\"}, //  47 nbackup_err_eofdb\n\t{337117232, \"00000\"}, //  48 nbackup_fixup_wrongstate\n\t{337117233, \"00000\"}, //  49 nbackup_err_db\n\t{337117234, \"00000\"}, //  50 nbackup_userpw_toolong\n\t{337117235, \"00000\"}, //  51 nbackup_lostrec_db\n\t{337117236, \"00000\"}, //  52 nbackup_lostguid_db\n\t{337117237, \"00000\"}, //  53 nbackup_err_eofhdrdb\n\t{337117238, \"00000\"}, //  54 nbackup_db_notlock\n\t{337117239, \"00000\"}, //  55 nbackup_lostguid_bk\n\t{337117240, \"00000\"}, //  56 nbackup_page_changed\n\t{337117241, \"00000\"}, //  57 nbackup_dbsize_inconsistent\n\t{337117242, \"00000\"}, //  58 nbackup_failed_lzbk\n\t{337117243, \"00000\"}, //  59 nbackup_err_eofhdrbk\n\t{337117244, \"00000\"}, //  60 nbackup_invalid_incbk\n\t{337117245, \"00000\"}, //  61 nbackup_unsupvers_incbk\n\t{337117246, \"00000\"}, //  62 nbackup_invlevel_incbk\n\t{337117247, \"00000\"}, //  63 nbackup_wrong_orderbk\n\t{337117248, \"00000\"}, //  64 nbackup_err_eofbk\n\t{337117249, \"00000\"}, //  65 nbackup_err_copy\n\t{337117250, \"00000\"}, //  66 nbackup_err_eofhdr_restdb\n\t{337117251, \"00000\"}, //  67 nbackup_lostguid_l0bk\n\t{337117255, \"00000\"}, //  71 nbackup_switchd_parameter\n\t{337117257, \"08006\"}, //  73 nbackup_user_stop\n\t{337117259, \"54023\"}, //  75 nbackup_deco_parse\n\t{337117261, \"00000\"}, //  77 nbackup_lostrec_guid_db\n\t{337117265, \"00000\"}, //  81 nbackup_seq_misuse\n\t{337182750, \"00000\"}, //  30 trace_conflict_acts\n\t{337182751, \"00000\"}, //  31 trace_act_notfound\n\t{337182752, \"00000\"}, //  32 trace_switch_once\n\t{337182753, \"00000\"}, //  33 trace_param_val_miss\n\t{337182754, \"00000\"}, //  34 trace_param_invalid\n\t{337182755, \"00000\"}, //  35 trace_switch_unknown\n\t{337182756, \"00000\"}, //  36 trace_switch_svc_only\n\t{337182757, \"00000\"}, //  37 trace_switch_user_only\n\t{337182758, \"00000\"}, //  38 trace_switch_param_miss\n\t{337182759, \"00000\"}, //  39 trace_param_act_notcompat\n\t{337182760, \"00000\"}, //  40 trace_mandatory_switch_miss\n\t\t};\n\n\tpublic static bool TryGet(int key, out string value) => _mapping.TryGetValue(key, out value);\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/StatementBase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal abstract class StatementBase\n{\n\t#region Protected Static Fields\n\n\tprotected static readonly byte[] DescribePlanInfoItems = new byte[]\n\t{\n\t\t\tIscCodes.isc_info_sql_get_plan,\n\t};\n\n\tprotected static readonly byte[] DescribeExplaindPlanInfoItems = new byte[]\n\t{\n\t\t\tIscCodes.isc_info_sql_explain_plan,\n\t};\n\n\tprotected static readonly byte[] RowsAffectedInfoItems = new byte[]\n\t{\n\t\t\tIscCodes.isc_info_sql_records,\n\t};\n\n\tprotected static readonly byte[] DescribeInfoAndBindInfoItems = new byte[]\n\t{\n\t\t\tIscCodes.isc_info_sql_select,\n\t\t\tIscCodes.isc_info_sql_describe_vars,\n\t\t\tIscCodes.isc_info_sql_sqlda_seq,\n\t\t\tIscCodes.isc_info_sql_type,\n\t\t\tIscCodes.isc_info_sql_sub_type,\n\t\t\tIscCodes.isc_info_sql_length,\n\t\t\tIscCodes.isc_info_sql_scale,\n\t\t\tIscCodes.isc_info_sql_field,\n\t\t\tIscCodes.isc_info_sql_relation,\n\t\t\t// IscCodes.isc_info_sql_owner,\n\t\t\tIscCodes.isc_info_sql_alias,\n\t\t\tIscCodes.isc_info_sql_describe_end,\n\n\t\t\tIscCodes.isc_info_sql_bind,\n\t\t\tIscCodes.isc_info_sql_describe_vars,\n\t\t\tIscCodes.isc_info_sql_sqlda_seq,\n\t\t\tIscCodes.isc_info_sql_type,\n\t\t\tIscCodes.isc_info_sql_sub_type,\n\t\t\tIscCodes.isc_info_sql_length,\n\t\t\tIscCodes.isc_info_sql_scale,\n\t\t\tIscCodes.isc_info_sql_field,\n\t\t\tIscCodes.isc_info_sql_relation,\n\t\t\t// IscCodes.isc_info_sql_owner,\n\t\t\tIscCodes.isc_info_sql_alias,\n\t\t\tIscCodes.isc_info_sql_describe_end,\n\t};\n\n\tprotected static readonly byte[] StatementTypeInfoItems = new byte[]\n\t{\n\t\t\tIscCodes.isc_info_sql_stmt_type,\n\t};\n\n\t#endregion\n\n\t#region Protected Fields\n\n\tprotected EventHandler TransactionUpdate;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic abstract DatabaseBase Database { get; }\n\tpublic abstract TransactionBase Transaction { get; set; }\n\tpublic abstract Descriptor Parameters { get; set; }\n\tpublic abstract Descriptor Fields { get; }\n\tpublic abstract int FetchSize { get; set; }\n\n\tprotected Queue<DbValue[]> OutputParameters { get; set; }\n\n\tpublic DbStatementType StatementType { get; protected set; } = DbStatementType.None;\n\tpublic StatementState State { get; protected set; } = StatementState.Deallocated;\n\tpublic int RecordsAffected { get; protected set; } = -1;\n\n\tpublic bool ReturnRecordsAffected { get; set; }\n\n\tpublic bool IsPrepared => !(State == StatementState.Deallocated || State == StatementState.Error);\n\tpublic bool DoRecordsAffected => ReturnRecordsAffected\n\t\t&& (StatementType == DbStatementType.Insert\n\t\t\t|| StatementType == DbStatementType.Delete\n\t\t\t|| StatementType == DbStatementType.Update\n\t\t\t|| StatementType == DbStatementType.StoredProcedure\n\t\t\t|| StatementType == DbStatementType.Select);\n\n\t#endregion\n\n\t#region Dispose2\n\n\tpublic virtual void Dispose2()\n\t{ }\n\tpublic virtual ValueTask Dispose2Async(CancellationToken cancellationToken = default)\n\t{\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic string GetExecutionPlan()\n\t{\n\t\treturn GetPlanInfo(DescribePlanInfoItems);\n\t}\n\tpublic ValueTask<string> GetExecutionPlanAsync(CancellationToken cancellationToken)\n\t{\n\t\treturn GetPlanInfoAsync(DescribePlanInfoItems, cancellationToken);\n\t}\n\n\tpublic string GetExecutionExplainedPlan()\n\t{\n\t\treturn GetPlanInfo(DescribeExplaindPlanInfoItems);\n\t}\n\tpublic ValueTask<string> GetExecutionExplainedPlanAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetPlanInfoAsync(DescribeExplaindPlanInfoItems, cancellationToken);\n\t}\n\n\tpublic virtual void Close()\n\t{\n\t\tif (State == StatementState.Executed ||\n\t\t\tState == StatementState.Error)\n\t\t{\n\t\t\tif (StatementType == DbStatementType.Select ||\n\t\t\t\tStatementType == DbStatementType.SelectForUpdate ||\n\t\t\t\tStatementType == DbStatementType.StoredProcedure)\n\t\t\t{\n\t\t\t\tif (State == StatementState.Allocated ||\n\t\t\t\t\tState == StatementState.Prepared ||\n\t\t\t\t\tState == StatementState.Executed)\n\t\t\t\t{\n\t\t\t\t\ttry\n\t\t\t\t\t{\n\t\t\t\t\t\tFree(IscCodes.DSQL_close);\n\t\t\t\t\t}\n\t\t\t\t\tcatch\n\t\t\t\t\t{ }\n\t\t\t\t}\n\t\t\t\tClearArrayHandles();\n\t\t\t\tState = StatementState.Closed;\n\t\t\t}\n\t\t}\n\t}\n\tpublic virtual async ValueTask CloseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (State == StatementState.Executed ||\n\t\t\tState == StatementState.Error)\n\t\t{\n\t\t\tif (StatementType == DbStatementType.Select ||\n\t\t\t\tStatementType == DbStatementType.SelectForUpdate ||\n\t\t\t\tStatementType == DbStatementType.StoredProcedure)\n\t\t\t{\n\t\t\t\tif (State == StatementState.Allocated ||\n\t\t\t\t\tState == StatementState.Prepared ||\n\t\t\t\t\tState == StatementState.Executed)\n\t\t\t\t{\n\t\t\t\t\ttry\n\t\t\t\t\t{\n\t\t\t\t\t\tawait FreeAsync(IscCodes.DSQL_close, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t}\n\t\t\t\t\tcatch\n\t\t\t\t\t{ }\n\t\t\t\t}\n\t\t\t\tClearArrayHandles();\n\t\t\t\tState = StatementState.Closed;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic virtual void Release()\n\t{\n\t\tif (Transaction != null && TransactionUpdate != null)\n\t\t{\n\t\t\tTransaction.Update -= TransactionUpdate;\n\t\t\tTransactionUpdate = null;\n\t\t}\n\n\t\tFree(IscCodes.DSQL_drop);\n\n\t\tClearArrayHandles();\n\t\tState = StatementState.Deallocated;\n\t\tStatementType = DbStatementType.None;\n\t}\n\tpublic virtual async ValueTask ReleaseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (Transaction != null && TransactionUpdate != null)\n\t\t{\n\t\t\tTransaction.Update -= TransactionUpdate;\n\t\t\tTransactionUpdate = null;\n\t\t}\n\n\t\tawait FreeAsync(IscCodes.DSQL_drop, cancellationToken).ConfigureAwait(false);\n\n\t\tClearArrayHandles();\n\t\tState = StatementState.Deallocated;\n\t\tStatementType = DbStatementType.None;\n\t}\n\n\t#endregion\n\n\t#region Abstract Methods\n\n\tpublic abstract void Prepare(string commandText);\n\tpublic abstract ValueTask PrepareAsync(string commandText, CancellationToken cancellationToken = default);\n\n\tpublic abstract void Execute(int timeout, IDescriptorFiller descriptorFiller);\n\tpublic abstract ValueTask ExecuteAsync(int timeout, IDescriptorFiller descriptorFiller, CancellationToken cancellationToken = default);\n\n\tpublic abstract DbValue[] Fetch();\n\tpublic abstract ValueTask<DbValue[]> FetchAsync(CancellationToken cancellationToken = default);\n\n\tpublic abstract BlobBase CreateBlob();\n\tpublic abstract BlobBase CreateBlob(long handle);\n\n\tpublic abstract ArrayBase CreateArray(ArrayDesc descriptor);\n\tpublic abstract ValueTask<ArrayBase> CreateArrayAsync(ArrayDesc descriptor, CancellationToken cancellationToken = default);\n\n\tpublic abstract ArrayBase CreateArray(string tableName, string fieldName);\n\tpublic abstract ValueTask<ArrayBase> CreateArrayAsync(string tableName, string fieldName, CancellationToken cancellationToken = default);\n\n\tpublic abstract ArrayBase CreateArray(long handle, string tableName, string fieldName);\n\tpublic abstract ValueTask<ArrayBase> CreateArrayAsync(long handle, string tableName, string fieldName, CancellationToken cancellationToken = default);\n\n\tpublic abstract BatchBase CreateBatch();\n\tpublic abstract BatchParameterBuffer CreateBatchParameterBuffer();\n\n\t#endregion\n\n\t#region Protected Abstract Methods\n\n\tprotected abstract void TransactionUpdated(object sender, EventArgs e);\n\n\tprotected abstract byte[] GetSqlInfo(byte[] items, int bufferLength);\n\tprotected abstract ValueTask<byte[]> GetSqlInfoAsync(byte[] items, int bufferLength, CancellationToken cancellationToken = default);\n\n\tprotected abstract void Free(int option);\n\tprotected abstract ValueTask FreeAsync(int option, CancellationToken cancellationToken = default);\n\n\t#endregion\n\n\t#region Protected Methods\n\n\tpublic DbValue[] GetOutputParameters()\n\t{\n\t\tif (OutputParameters != null && OutputParameters.Count > 0)\n\t\t{\n\t\t\treturn OutputParameters.Dequeue();\n\t\t}\n\t\treturn null;\n\t}\n\n\tprotected byte[] GetSqlInfo(byte[] items)\n\t{\n\t\treturn GetSqlInfo(items, IscCodes.DEFAULT_MAX_BUFFER_SIZE);\n\t}\n\tprotected ValueTask<byte[]> GetSqlInfoAsync(byte[] items, CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetSqlInfoAsync(items, IscCodes.DEFAULT_MAX_BUFFER_SIZE, cancellationToken);\n\t}\n\n\tprotected int GetRecordsAffected()\n\t{\n\t\tvar buffer = GetSqlInfo(RowsAffectedInfoItems, IscCodes.ROWS_AFFECTED_BUFFER_SIZE);\n\t\treturn ProcessRecordsAffectedBuffer(buffer);\n\t}\n\tprotected async ValueTask<int> GetRecordsAffectedAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar buffer = await GetSqlInfoAsync(RowsAffectedInfoItems, IscCodes.ROWS_AFFECTED_BUFFER_SIZE, cancellationToken).ConfigureAwait(false);\n\t\treturn ProcessRecordsAffectedBuffer(buffer);\n\t}\n\n\tprotected int ProcessRecordsAffectedBuffer(byte[] buffer)\n\t{\n\t\tvar insertCount = 0;\n\t\tvar updateCount = 0;\n\t\tvar deleteCount = 0;\n\t\tvar selectCount = 0;\n\t\tvar pos = 0;\n\n\t\tint type;\n\t\twhile ((type = buffer[pos++]) != IscCodes.isc_info_end)\n\t\t{\n\t\t\tvar length = (int)IscHelper.VaxInteger(buffer, pos, 2);\n\t\t\tpos += 2;\n\t\t\tswitch (type)\n\t\t\t{\n\t\t\t\tcase IscCodes.isc_info_sql_records:\n\t\t\t\t\tint t;\n\t\t\t\t\twhile ((t = buffer[pos++]) != IscCodes.isc_info_end)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar l = (int)IscHelper.VaxInteger(buffer, pos, 2);\n\t\t\t\t\t\tpos += 2;\n\t\t\t\t\t\tswitch (t)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcase IscCodes.isc_info_req_insert_count:\n\t\t\t\t\t\t\t\tinsertCount = (int)IscHelper.VaxInteger(buffer, pos, l);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase IscCodes.isc_info_req_update_count:\n\t\t\t\t\t\t\t\tupdateCount = (int)IscHelper.VaxInteger(buffer, pos, l);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase IscCodes.isc_info_req_delete_count:\n\t\t\t\t\t\t\t\tdeleteCount = (int)IscHelper.VaxInteger(buffer, pos, l);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase IscCodes.isc_info_req_select_count:\n\t\t\t\t\t\t\t\tselectCount = (int)IscHelper.VaxInteger(buffer, pos, l);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpos += l;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tpos += length;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn insertCount + updateCount + deleteCount;\n\t}\n\n\tprotected DbStatementType GetStatementType()\n\t{\n\t\tvar buffer = GetSqlInfo(StatementTypeInfoItems, IscCodes.STATEMENT_TYPE_BUFFER_SIZE);\n\t\treturn ProcessStatementTypeInfoBuffer(buffer);\n\t}\n\tprotected async ValueTask<DbStatementType> GetStatementTypeAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar buffer = await GetSqlInfoAsync(StatementTypeInfoItems, IscCodes.STATEMENT_TYPE_BUFFER_SIZE, cancellationToken).ConfigureAwait(false);\n\t\treturn ProcessStatementTypeInfoBuffer(buffer);\n\t}\n\n\tprotected DbStatementType ProcessStatementTypeInfoBuffer(byte[] buffer)\n\t{\n\t\tvar stmtType = DbStatementType.None;\n\t\tvar pos = 0;\n\t\tvar length = 0;\n\t\tvar type = 0;\n\n\t\twhile ((type = buffer[pos++]) != IscCodes.isc_info_end)\n\t\t{\n\t\t\tlength = (int)IscHelper.VaxInteger(buffer, pos, 2);\n\t\t\tpos += 2;\n\t\t\tswitch (type)\n\t\t\t{\n\t\t\t\tcase IscCodes.isc_info_sql_stmt_type:\n\t\t\t\t\tstmtType = (DbStatementType)IscHelper.VaxInteger(buffer, pos, length);\n\t\t\t\t\tpos += length;\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tpos += length;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn stmtType;\n\t}\n\n\tprotected void ClearArrayHandles()\n\t{\n\t\tif (Fields != null && Fields.Count > 0)\n\t\t{\n\t\t\tfor (var i = 0; i < Fields.Count; i++)\n\t\t\t{\n\t\t\t\tif (Fields[i].IsArray())\n\t\t\t\t{\n\t\t\t\t\tFields[i].ArrayHandle = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected string GetPlanInfo(byte[] planInfoItems)\n\t{\n\t\tvar count = 0;\n\t\tvar bufferSize = IscCodes.DEFAULT_MAX_BUFFER_SIZE;\n\t\tvar buffer = GetSqlInfo(planInfoItems, bufferSize);\n\n\t\tif (buffer[0] == IscCodes.isc_info_end)\n\t\t{\n\t\t\treturn string.Empty;\n\t\t}\n\n\t\twhile (buffer[0] == IscCodes.isc_info_truncated && count < 4)\n\t\t{\n\t\t\tbufferSize *= 2;\n\t\t\tbuffer = GetSqlInfo(planInfoItems, bufferSize);\n\t\t\tcount++;\n\t\t}\n\t\tif (count > 3)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\n\t\tint len = buffer[1];\n\t\tlen += buffer[2] << 8;\n\t\tif (len > 0)\n\t\t{\n\t\t\treturn Database.Charset.GetString(buffer, 4, --len);\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn string.Empty;\n\t\t}\n\t}\n\tprotected async ValueTask<string> GetPlanInfoAsync(byte[] planInfoItems, CancellationToken cancellationToken = default)\n\t{\n\t\tvar count = 0;\n\t\tvar bufferSize = IscCodes.DEFAULT_MAX_BUFFER_SIZE;\n\t\tvar buffer = await GetSqlInfoAsync(planInfoItems, bufferSize, cancellationToken).ConfigureAwait(false);\n\n\t\tif (buffer[0] == IscCodes.isc_info_end)\n\t\t{\n\t\t\treturn string.Empty;\n\t\t}\n\n\t\twhile (buffer[0] == IscCodes.isc_info_truncated && count < 4)\n\t\t{\n\t\t\tbufferSize *= 2;\n\t\t\tbuffer = await GetSqlInfoAsync(planInfoItems, bufferSize, cancellationToken).ConfigureAwait(false);\n\t\t\tcount++;\n\t\t}\n\t\tif (count > 3)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\n\t\tint len = buffer[1];\n\t\tlen += buffer[2] << 8;\n\t\tif (len > 0)\n\t\t{\n\t\t\treturn Database.Charset.GetString(buffer, 4, --len);\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn string.Empty;\n\t\t}\n\t}\n\n\tprotected void EnsureNotDeallocated()\n\t{\n\t\tif (State == StatementState.Deallocated)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Statement is not correctly created.\");\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/StatementState.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez\n\nusing System;\n\nnamespace FirebirdSql.Data.Common;\n\n[Serializable]\ninternal enum StatementState\n{\n\tDeallocated,\n\tAllocated,\n\tPrepared,\n\tExecuted,\n\tClosed,\n\tError\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/TimeZoneMapping.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal class TimeZoneMapping\n{\n\t// select '{ ' || rdb$time_zone_id || ', \"' || trim(rdb$time_zone_name) || '\" },' from rdb$time_zones order by rdb$time_zone_id desc;\n\tstatic Dictionary<ushort, string> _idToName = new Dictionary<ushort, string>()\n\t\t{\n{ 65535, \"GMT\" },\n{ 65534, \"ACT\" },\n{ 65533, \"AET\" },\n{ 65532, \"AGT\" },\n{ 65531, \"ART\" },\n{ 65530, \"AST\" },\n{ 65529, \"Africa/Abidjan\" },\n{ 65528, \"Africa/Accra\" },\n{ 65527, \"Africa/Addis_Ababa\" },\n{ 65526, \"Africa/Algiers\" },\n{ 65525, \"Africa/Asmara\" },\n{ 65524, \"Africa/Asmera\" },\n{ 65523, \"Africa/Bamako\" },\n{ 65522, \"Africa/Bangui\" },\n{ 65521, \"Africa/Banjul\" },\n{ 65520, \"Africa/Bissau\" },\n{ 65519, \"Africa/Blantyre\" },\n{ 65518, \"Africa/Brazzaville\" },\n{ 65517, \"Africa/Bujumbura\" },\n{ 65516, \"Africa/Cairo\" },\n{ 65515, \"Africa/Casablanca\" },\n{ 65514, \"Africa/Ceuta\" },\n{ 65513, \"Africa/Conakry\" },\n{ 65512, \"Africa/Dakar\" },\n{ 65511, \"Africa/Dar_es_Salaam\" },\n{ 65510, \"Africa/Djibouti\" },\n{ 65509, \"Africa/Douala\" },\n{ 65508, \"Africa/El_Aaiun\" },\n{ 65507, \"Africa/Freetown\" },\n{ 65506, \"Africa/Gaborone\" },\n{ 65505, \"Africa/Harare\" },\n{ 65504, \"Africa/Johannesburg\" },\n{ 65503, \"Africa/Juba\" },\n{ 65502, \"Africa/Kampala\" },\n{ 65501, \"Africa/Khartoum\" },\n{ 65500, \"Africa/Kigali\" },\n{ 65499, \"Africa/Kinshasa\" },\n{ 65498, \"Africa/Lagos\" },\n{ 65497, \"Africa/Libreville\" },\n{ 65496, \"Africa/Lome\" },\n{ 65495, \"Africa/Luanda\" },\n{ 65494, \"Africa/Lubumbashi\" },\n{ 65493, \"Africa/Lusaka\" },\n{ 65492, \"Africa/Malabo\" },\n{ 65491, \"Africa/Maputo\" },\n{ 65490, \"Africa/Maseru\" },\n{ 65489, \"Africa/Mbabane\" },\n{ 65488, \"Africa/Mogadishu\" },\n{ 65487, \"Africa/Monrovia\" },\n{ 65486, \"Africa/Nairobi\" },\n{ 65485, \"Africa/Ndjamena\" },\n{ 65484, \"Africa/Niamey\" },\n{ 65483, \"Africa/Nouakchott\" },\n{ 65482, \"Africa/Ouagadougou\" },\n{ 65481, \"Africa/Porto-Novo\" },\n{ 65480, \"Africa/Sao_Tome\" },\n{ 65479, \"Africa/Timbuktu\" },\n{ 65478, \"Africa/Tripoli\" },\n{ 65477, \"Africa/Tunis\" },\n{ 65476, \"Africa/Windhoek\" },\n{ 65475, \"America/Adak\" },\n{ 65474, \"America/Anchorage\" },\n{ 65473, \"America/Anguilla\" },\n{ 65472, \"America/Antigua\" },\n{ 65471, \"America/Araguaina\" },\n{ 65470, \"America/Argentina/Buenos_Aires\" },\n{ 65469, \"America/Argentina/Catamarca\" },\n{ 65468, \"America/Argentina/ComodRivadavia\" },\n{ 65467, \"America/Argentina/Cordoba\" },\n{ 65466, \"America/Argentina/Jujuy\" },\n{ 65465, \"America/Argentina/La_Rioja\" },\n{ 65464, \"America/Argentina/Mendoza\" },\n{ 65463, \"America/Argentina/Rio_Gallegos\" },\n{ 65462, \"America/Argentina/Salta\" },\n{ 65461, \"America/Argentina/San_Juan\" },\n{ 65460, \"America/Argentina/San_Luis\" },\n{ 65459, \"America/Argentina/Tucuman\" },\n{ 65458, \"America/Argentina/Ushuaia\" },\n{ 65457, \"America/Aruba\" },\n{ 65456, \"America/Asuncion\" },\n{ 65455, \"America/Atikokan\" },\n{ 65454, \"America/Atka\" },\n{ 65453, \"America/Bahia\" },\n{ 65452, \"America/Bahia_Banderas\" },\n{ 65451, \"America/Barbados\" },\n{ 65450, \"America/Belem\" },\n{ 65449, \"America/Belize\" },\n{ 65448, \"America/Blanc-Sablon\" },\n{ 65447, \"America/Boa_Vista\" },\n{ 65446, \"America/Bogota\" },\n{ 65445, \"America/Boise\" },\n{ 65444, \"America/Buenos_Aires\" },\n{ 65443, \"America/Cambridge_Bay\" },\n{ 65442, \"America/Campo_Grande\" },\n{ 65441, \"America/Cancun\" },\n{ 65440, \"America/Caracas\" },\n{ 65439, \"America/Catamarca\" },\n{ 65438, \"America/Cayenne\" },\n{ 65437, \"America/Cayman\" },\n{ 65436, \"America/Chicago\" },\n{ 65435, \"America/Chihuahua\" },\n{ 65434, \"America/Coral_Harbour\" },\n{ 65433, \"America/Cordoba\" },\n{ 65432, \"America/Costa_Rica\" },\n{ 65431, \"America/Creston\" },\n{ 65430, \"America/Cuiaba\" },\n{ 65429, \"America/Curacao\" },\n{ 65428, \"America/Danmarkshavn\" },\n{ 65427, \"America/Dawson\" },\n{ 65426, \"America/Dawson_Creek\" },\n{ 65425, \"America/Denver\" },\n{ 65424, \"America/Detroit\" },\n{ 65423, \"America/Dominica\" },\n{ 65422, \"America/Edmonton\" },\n{ 65421, \"America/Eirunepe\" },\n{ 65420, \"America/El_Salvador\" },\n{ 65419, \"America/Ensenada\" },\n{ 65418, \"America/Fort_Nelson\" },\n{ 65417, \"America/Fort_Wayne\" },\n{ 65416, \"America/Fortaleza\" },\n{ 65415, \"America/Glace_Bay\" },\n{ 65414, \"America/Godthab\" },\n{ 65413, \"America/Goose_Bay\" },\n{ 65412, \"America/Grand_Turk\" },\n{ 65411, \"America/Grenada\" },\n{ 65410, \"America/Guadeloupe\" },\n{ 65409, \"America/Guatemala\" },\n{ 65408, \"America/Guayaquil\" },\n{ 65407, \"America/Guyana\" },\n{ 65406, \"America/Halifax\" },\n{ 65405, \"America/Havana\" },\n{ 65404, \"America/Hermosillo\" },\n{ 65403, \"America/Indiana/Indianapolis\" },\n{ 65402, \"America/Indiana/Knox\" },\n{ 65401, \"America/Indiana/Marengo\" },\n{ 65400, \"America/Indiana/Petersburg\" },\n{ 65399, \"America/Indiana/Tell_City\" },\n{ 65398, \"America/Indiana/Vevay\" },\n{ 65397, \"America/Indiana/Vincennes\" },\n{ 65396, \"America/Indiana/Winamac\" },\n{ 65395, \"America/Indianapolis\" },\n{ 65394, \"America/Inuvik\" },\n{ 65393, \"America/Iqaluit\" },\n{ 65392, \"America/Jamaica\" },\n{ 65391, \"America/Jujuy\" },\n{ 65390, \"America/Juneau\" },\n{ 65389, \"America/Kentucky/Louisville\" },\n{ 65388, \"America/Kentucky/Monticello\" },\n{ 65387, \"America/Knox_IN\" },\n{ 65386, \"America/Kralendijk\" },\n{ 65385, \"America/La_Paz\" },\n{ 65384, \"America/Lima\" },\n{ 65383, \"America/Los_Angeles\" },\n{ 65382, \"America/Louisville\" },\n{ 65381, \"America/Lower_Princes\" },\n{ 65380, \"America/Maceio\" },\n{ 65379, \"America/Managua\" },\n{ 65378, \"America/Manaus\" },\n{ 65377, \"America/Marigot\" },\n{ 65376, \"America/Martinique\" },\n{ 65375, \"America/Matamoros\" },\n{ 65374, \"America/Mazatlan\" },\n{ 65373, \"America/Mendoza\" },\n{ 65372, \"America/Menominee\" },\n{ 65371, \"America/Merida\" },\n{ 65370, \"America/Metlakatla\" },\n{ 65369, \"America/Mexico_City\" },\n{ 65368, \"America/Miquelon\" },\n{ 65367, \"America/Moncton\" },\n{ 65366, \"America/Monterrey\" },\n{ 65365, \"America/Montevideo\" },\n{ 65364, \"America/Montreal\" },\n{ 65363, \"America/Montserrat\" },\n{ 65362, \"America/Nassau\" },\n{ 65361, \"America/New_York\" },\n{ 65360, \"America/Nipigon\" },\n{ 65359, \"America/Nome\" },\n{ 65358, \"America/Noronha\" },\n{ 65357, \"America/North_Dakota/Beulah\" },\n{ 65356, \"America/North_Dakota/Center\" },\n{ 65355, \"America/North_Dakota/New_Salem\" },\n{ 65354, \"America/Ojinaga\" },\n{ 65353, \"America/Panama\" },\n{ 65352, \"America/Pangnirtung\" },\n{ 65351, \"America/Paramaribo\" },\n{ 65350, \"America/Phoenix\" },\n{ 65349, \"America/Port-au-Prince\" },\n{ 65348, \"America/Port_of_Spain\" },\n{ 65347, \"America/Porto_Acre\" },\n{ 65346, \"America/Porto_Velho\" },\n{ 65345, \"America/Puerto_Rico\" },\n{ 65344, \"America/Punta_Arenas\" },\n{ 65343, \"America/Rainy_River\" },\n{ 65342, \"America/Rankin_Inlet\" },\n{ 65341, \"America/Recife\" },\n{ 65340, \"America/Regina\" },\n{ 65339, \"America/Resolute\" },\n{ 65338, \"America/Rio_Branco\" },\n{ 65337, \"America/Rosario\" },\n{ 65336, \"America/Santa_Isabel\" },\n{ 65335, \"America/Santarem\" },\n{ 65334, \"America/Santiago\" },\n{ 65333, \"America/Santo_Domingo\" },\n{ 65332, \"America/Sao_Paulo\" },\n{ 65331, \"America/Scoresbysund\" },\n{ 65330, \"America/Shiprock\" },\n{ 65329, \"America/Sitka\" },\n{ 65328, \"America/St_Barthelemy\" },\n{ 65327, \"America/St_Johns\" },\n{ 65326, \"America/St_Kitts\" },\n{ 65325, \"America/St_Lucia\" },\n{ 65324, \"America/St_Thomas\" },\n{ 65323, \"America/St_Vincent\" },\n{ 65322, \"America/Swift_Current\" },\n{ 65321, \"America/Tegucigalpa\" },\n{ 65320, \"America/Thule\" },\n{ 65319, \"America/Thunder_Bay\" },\n{ 65318, \"America/Tijuana\" },\n{ 65317, \"America/Toronto\" },\n{ 65316, \"America/Tortola\" },\n{ 65315, \"America/Vancouver\" },\n{ 65314, \"America/Virgin\" },\n{ 65313, \"America/Whitehorse\" },\n{ 65312, \"America/Winnipeg\" },\n{ 65311, \"America/Yakutat\" },\n{ 65310, \"America/Yellowknife\" },\n{ 65309, \"Antarctica/Casey\" },\n{ 65308, \"Antarctica/Davis\" },\n{ 65307, \"Antarctica/DumontDUrville\" },\n{ 65306, \"Antarctica/Macquarie\" },\n{ 65305, \"Antarctica/Mawson\" },\n{ 65304, \"Antarctica/McMurdo\" },\n{ 65303, \"Antarctica/Palmer\" },\n{ 65302, \"Antarctica/Rothera\" },\n{ 65301, \"Antarctica/South_Pole\" },\n{ 65300, \"Antarctica/Syowa\" },\n{ 65299, \"Antarctica/Troll\" },\n{ 65298, \"Antarctica/Vostok\" },\n{ 65297, \"Arctic/Longyearbyen\" },\n{ 65296, \"Asia/Aden\" },\n{ 65295, \"Asia/Almaty\" },\n{ 65294, \"Asia/Amman\" },\n{ 65293, \"Asia/Anadyr\" },\n{ 65292, \"Asia/Aqtau\" },\n{ 65291, \"Asia/Aqtobe\" },\n{ 65290, \"Asia/Ashgabat\" },\n{ 65289, \"Asia/Ashkhabad\" },\n{ 65288, \"Asia/Atyrau\" },\n{ 65287, \"Asia/Baghdad\" },\n{ 65286, \"Asia/Bahrain\" },\n{ 65285, \"Asia/Baku\" },\n{ 65284, \"Asia/Bangkok\" },\n{ 65283, \"Asia/Barnaul\" },\n{ 65282, \"Asia/Beirut\" },\n{ 65281, \"Asia/Bishkek\" },\n{ 65280, \"Asia/Brunei\" },\n{ 65279, \"Asia/Calcutta\" },\n{ 65278, \"Asia/Chita\" },\n{ 65277, \"Asia/Choibalsan\" },\n{ 65276, \"Asia/Chongqing\" },\n{ 65275, \"Asia/Chungking\" },\n{ 65274, \"Asia/Colombo\" },\n{ 65273, \"Asia/Dacca\" },\n{ 65272, \"Asia/Damascus\" },\n{ 65271, \"Asia/Dhaka\" },\n{ 65270, \"Asia/Dili\" },\n{ 65269, \"Asia/Dubai\" },\n{ 65268, \"Asia/Dushanbe\" },\n{ 65267, \"Asia/Famagusta\" },\n{ 65266, \"Asia/Gaza\" },\n{ 65265, \"Asia/Harbin\" },\n{ 65264, \"Asia/Hebron\" },\n{ 65263, \"Asia/Ho_Chi_Minh\" },\n{ 65262, \"Asia/Hong_Kong\" },\n{ 65261, \"Asia/Hovd\" },\n{ 65260, \"Asia/Irkutsk\" },\n{ 65259, \"Asia/Istanbul\" },\n{ 65258, \"Asia/Jakarta\" },\n{ 65257, \"Asia/Jayapura\" },\n{ 65256, \"Asia/Jerusalem\" },\n{ 65255, \"Asia/Kabul\" },\n{ 65254, \"Asia/Kamchatka\" },\n{ 65253, \"Asia/Karachi\" },\n{ 65252, \"Asia/Kashgar\" },\n{ 65251, \"Asia/Kathmandu\" },\n{ 65250, \"Asia/Katmandu\" },\n{ 65249, \"Asia/Khandyga\" },\n{ 65248, \"Asia/Kolkata\" },\n{ 65247, \"Asia/Krasnoyarsk\" },\n{ 65246, \"Asia/Kuala_Lumpur\" },\n{ 65245, \"Asia/Kuching\" },\n{ 65244, \"Asia/Kuwait\" },\n{ 65243, \"Asia/Macao\" },\n{ 65242, \"Asia/Macau\" },\n{ 65241, \"Asia/Magadan\" },\n{ 65240, \"Asia/Makassar\" },\n{ 65239, \"Asia/Manila\" },\n{ 65238, \"Asia/Muscat\" },\n{ 65237, \"Asia/Nicosia\" },\n{ 65236, \"Asia/Novokuznetsk\" },\n{ 65235, \"Asia/Novosibirsk\" },\n{ 65234, \"Asia/Omsk\" },\n{ 65233, \"Asia/Oral\" },\n{ 65232, \"Asia/Phnom_Penh\" },\n{ 65231, \"Asia/Pontianak\" },\n{ 65230, \"Asia/Pyongyang\" },\n{ 65229, \"Asia/Qatar\" },\n{ 65228, \"Asia/Qyzylorda\" },\n{ 65227, \"Asia/Rangoon\" },\n{ 65226, \"Asia/Riyadh\" },\n{ 65225, \"Asia/Saigon\" },\n{ 65224, \"Asia/Sakhalin\" },\n{ 65223, \"Asia/Samarkand\" },\n{ 65222, \"Asia/Seoul\" },\n{ 65221, \"Asia/Shanghai\" },\n{ 65220, \"Asia/Singapore\" },\n{ 65219, \"Asia/Srednekolymsk\" },\n{ 65218, \"Asia/Taipei\" },\n{ 65217, \"Asia/Tashkent\" },\n{ 65216, \"Asia/Tbilisi\" },\n{ 65215, \"Asia/Tehran\" },\n{ 65214, \"Asia/Tel_Aviv\" },\n{ 65213, \"Asia/Thimbu\" },\n{ 65212, \"Asia/Thimphu\" },\n{ 65211, \"Asia/Tokyo\" },\n{ 65210, \"Asia/Tomsk\" },\n{ 65209, \"Asia/Ujung_Pandang\" },\n{ 65208, \"Asia/Ulaanbaatar\" },\n{ 65207, \"Asia/Ulan_Bator\" },\n{ 65206, \"Asia/Urumqi\" },\n{ 65205, \"Asia/Ust-Nera\" },\n{ 65204, \"Asia/Vientiane\" },\n{ 65203, \"Asia/Vladivostok\" },\n{ 65202, \"Asia/Yakutsk\" },\n{ 65201, \"Asia/Yangon\" },\n{ 65200, \"Asia/Yekaterinburg\" },\n{ 65199, \"Asia/Yerevan\" },\n{ 65198, \"Atlantic/Azores\" },\n{ 65197, \"Atlantic/Bermuda\" },\n{ 65196, \"Atlantic/Canary\" },\n{ 65195, \"Atlantic/Cape_Verde\" },\n{ 65194, \"Atlantic/Faeroe\" },\n{ 65193, \"Atlantic/Faroe\" },\n{ 65192, \"Atlantic/Jan_Mayen\" },\n{ 65191, \"Atlantic/Madeira\" },\n{ 65190, \"Atlantic/Reykjavik\" },\n{ 65189, \"Atlantic/South_Georgia\" },\n{ 65188, \"Atlantic/St_Helena\" },\n{ 65187, \"Atlantic/Stanley\" },\n{ 65186, \"Australia/ACT\" },\n{ 65185, \"Australia/Adelaide\" },\n{ 65184, \"Australia/Brisbane\" },\n{ 65183, \"Australia/Broken_Hill\" },\n{ 65182, \"Australia/Canberra\" },\n{ 65181, \"Australia/Currie\" },\n{ 65180, \"Australia/Darwin\" },\n{ 65179, \"Australia/Eucla\" },\n{ 65178, \"Australia/Hobart\" },\n{ 65177, \"Australia/LHI\" },\n{ 65176, \"Australia/Lindeman\" },\n{ 65175, \"Australia/Lord_Howe\" },\n{ 65174, \"Australia/Melbourne\" },\n{ 65173, \"Australia/NSW\" },\n{ 65172, \"Australia/North\" },\n{ 65171, \"Australia/Perth\" },\n{ 65170, \"Australia/Queensland\" },\n{ 65169, \"Australia/South\" },\n{ 65168, \"Australia/Sydney\" },\n{ 65167, \"Australia/Tasmania\" },\n{ 65166, \"Australia/Victoria\" },\n{ 65165, \"Australia/West\" },\n{ 65164, \"Australia/Yancowinna\" },\n{ 65163, \"BET\" },\n{ 65162, \"BST\" },\n{ 65161, \"Brazil/Acre\" },\n{ 65160, \"Brazil/DeNoronha\" },\n{ 65159, \"Brazil/East\" },\n{ 65158, \"Brazil/West\" },\n{ 65157, \"CAT\" },\n{ 65156, \"CET\" },\n{ 65155, \"CNT\" },\n{ 65154, \"CST\" },\n{ 65153, \"CST6CDT\" },\n{ 65152, \"CTT\" },\n{ 65151, \"Canada/Atlantic\" },\n{ 65150, \"Canada/Central\" },\n{ 65149, \"Canada/East-Saskatchewan\" },\n{ 65148, \"Canada/Eastern\" },\n{ 65147, \"Canada/Mountain\" },\n{ 65146, \"Canada/Newfoundland\" },\n{ 65145, \"Canada/Pacific\" },\n{ 65144, \"Canada/Saskatchewan\" },\n{ 65143, \"Canada/Yukon\" },\n{ 65142, \"Chile/Continental\" },\n{ 65141, \"Chile/EasterIsland\" },\n{ 65140, \"Cuba\" },\n{ 65139, \"EAT\" },\n{ 65138, \"ECT\" },\n{ 65137, \"EET\" },\n{ 65136, \"EST\" },\n{ 65135, \"EST5EDT\" },\n{ 65134, \"Egypt\" },\n{ 65133, \"Eire\" },\n{ 65132, \"Etc/GMT\" },\n{ 65131, \"Etc/GMT+0\" },\n{ 65130, \"Etc/GMT+1\" },\n{ 65129, \"Etc/GMT+10\" },\n{ 65128, \"Etc/GMT+11\" },\n{ 65127, \"Etc/GMT+12\" },\n{ 65126, \"Etc/GMT+2\" },\n{ 65125, \"Etc/GMT+3\" },\n{ 65124, \"Etc/GMT+4\" },\n{ 65123, \"Etc/GMT+5\" },\n{ 65122, \"Etc/GMT+6\" },\n{ 65121, \"Etc/GMT+7\" },\n{ 65120, \"Etc/GMT+8\" },\n{ 65119, \"Etc/GMT+9\" },\n{ 65118, \"Etc/GMT-0\" },\n{ 65117, \"Etc/GMT-1\" },\n{ 65116, \"Etc/GMT-10\" },\n{ 65115, \"Etc/GMT-11\" },\n{ 65114, \"Etc/GMT-12\" },\n{ 65113, \"Etc/GMT-13\" },\n{ 65112, \"Etc/GMT-14\" },\n{ 65111, \"Etc/GMT-2\" },\n{ 65110, \"Etc/GMT-3\" },\n{ 65109, \"Etc/GMT-4\" },\n{ 65108, \"Etc/GMT-5\" },\n{ 65107, \"Etc/GMT-6\" },\n{ 65106, \"Etc/GMT-7\" },\n{ 65105, \"Etc/GMT-8\" },\n{ 65104, \"Etc/GMT-9\" },\n{ 65103, \"Etc/GMT0\" },\n{ 65102, \"Etc/Greenwich\" },\n{ 65101, \"Etc/UCT\" },\n{ 65100, \"Etc/UTC\" },\n{ 65099, \"Etc/Universal\" },\n{ 65098, \"Etc/Zulu\" },\n{ 65097, \"Europe/Amsterdam\" },\n{ 65096, \"Europe/Andorra\" },\n{ 65095, \"Europe/Astrakhan\" },\n{ 65094, \"Europe/Athens\" },\n{ 65093, \"Europe/Belfast\" },\n{ 65092, \"Europe/Belgrade\" },\n{ 65091, \"Europe/Berlin\" },\n{ 65090, \"Europe/Bratislava\" },\n{ 65089, \"Europe/Brussels\" },\n{ 65088, \"Europe/Bucharest\" },\n{ 65087, \"Europe/Budapest\" },\n{ 65086, \"Europe/Busingen\" },\n{ 65085, \"Europe/Chisinau\" },\n{ 65084, \"Europe/Copenhagen\" },\n{ 65083, \"Europe/Dublin\" },\n{ 65082, \"Europe/Gibraltar\" },\n{ 65081, \"Europe/Guernsey\" },\n{ 65080, \"Europe/Helsinki\" },\n{ 65079, \"Europe/Isle_of_Man\" },\n{ 65078, \"Europe/Istanbul\" },\n{ 65077, \"Europe/Jersey\" },\n{ 65076, \"Europe/Kaliningrad\" },\n{ 65075, \"Europe/Kiev\" },\n{ 65074, \"Europe/Kirov\" },\n{ 65073, \"Europe/Lisbon\" },\n{ 65072, \"Europe/Ljubljana\" },\n{ 65071, \"Europe/London\" },\n{ 65070, \"Europe/Luxembourg\" },\n{ 65069, \"Europe/Madrid\" },\n{ 65068, \"Europe/Malta\" },\n{ 65067, \"Europe/Mariehamn\" },\n{ 65066, \"Europe/Minsk\" },\n{ 65065, \"Europe/Monaco\" },\n{ 65064, \"Europe/Moscow\" },\n{ 65063, \"Europe/Nicosia\" },\n{ 65062, \"Europe/Oslo\" },\n{ 65061, \"Europe/Paris\" },\n{ 65060, \"Europe/Podgorica\" },\n{ 65059, \"Europe/Prague\" },\n{ 65058, \"Europe/Riga\" },\n{ 65057, \"Europe/Rome\" },\n{ 65056, \"Europe/Samara\" },\n{ 65055, \"Europe/San_Marino\" },\n{ 65054, \"Europe/Sarajevo\" },\n{ 65053, \"Europe/Saratov\" },\n{ 65052, \"Europe/Simferopol\" },\n{ 65051, \"Europe/Skopje\" },\n{ 65050, \"Europe/Sofia\" },\n{ 65049, \"Europe/Stockholm\" },\n{ 65048, \"Europe/Tallinn\" },\n{ 65047, \"Europe/Tirane\" },\n{ 65046, \"Europe/Tiraspol\" },\n{ 65045, \"Europe/Ulyanovsk\" },\n{ 65044, \"Europe/Uzhgorod\" },\n{ 65043, \"Europe/Vaduz\" },\n{ 65042, \"Europe/Vatican\" },\n{ 65041, \"Europe/Vienna\" },\n{ 65040, \"Europe/Vilnius\" },\n{ 65039, \"Europe/Volgograd\" },\n{ 65038, \"Europe/Warsaw\" },\n{ 65037, \"Europe/Zagreb\" },\n{ 65036, \"Europe/Zaporozhye\" },\n{ 65035, \"Europe/Zurich\" },\n{ 65034, \"Factory\" },\n{ 65033, \"GB\" },\n{ 65032, \"GB-Eire\" },\n{ 65031, \"GMT+0\" },\n{ 65030, \"GMT-0\" },\n{ 65029, \"GMT0\" },\n{ 65028, \"Greenwich\" },\n{ 65027, \"HST\" },\n{ 65026, \"Hongkong\" },\n{ 65025, \"IET\" },\n{ 65024, \"IST\" },\n{ 65023, \"Iceland\" },\n{ 65022, \"Indian/Antananarivo\" },\n{ 65021, \"Indian/Chagos\" },\n{ 65020, \"Indian/Christmas\" },\n{ 65019, \"Indian/Cocos\" },\n{ 65018, \"Indian/Comoro\" },\n{ 65017, \"Indian/Kerguelen\" },\n{ 65016, \"Indian/Mahe\" },\n{ 65015, \"Indian/Maldives\" },\n{ 65014, \"Indian/Mauritius\" },\n{ 65013, \"Indian/Mayotte\" },\n{ 65012, \"Indian/Reunion\" },\n{ 65011, \"Iran\" },\n{ 65010, \"Israel\" },\n{ 65009, \"JST\" },\n{ 65008, \"Jamaica\" },\n{ 65007, \"Japan\" },\n{ 65006, \"Kwajalein\" },\n{ 65005, \"Libya\" },\n{ 65004, \"MET\" },\n{ 65003, \"MIT\" },\n{ 65002, \"MST\" },\n{ 65001, \"MST7MDT\" },\n{ 65000, \"Mexico/BajaNorte\" },\n{ 64999, \"Mexico/BajaSur\" },\n{ 64998, \"Mexico/General\" },\n{ 64997, \"NET\" },\n{ 64996, \"NST\" },\n{ 64995, \"NZ\" },\n{ 64994, \"NZ-CHAT\" },\n{ 64993, \"Navajo\" },\n{ 64992, \"PLT\" },\n{ 64991, \"PNT\" },\n{ 64990, \"PRC\" },\n{ 64989, \"PRT\" },\n{ 64988, \"PST\" },\n{ 64987, \"PST8PDT\" },\n{ 64986, \"Pacific/Apia\" },\n{ 64985, \"Pacific/Auckland\" },\n{ 64984, \"Pacific/Bougainville\" },\n{ 64983, \"Pacific/Chatham\" },\n{ 64982, \"Pacific/Chuuk\" },\n{ 64981, \"Pacific/Easter\" },\n{ 64980, \"Pacific/Efate\" },\n{ 64979, \"Pacific/Enderbury\" },\n{ 64978, \"Pacific/Fakaofo\" },\n{ 64977, \"Pacific/Fiji\" },\n{ 64976, \"Pacific/Funafuti\" },\n{ 64975, \"Pacific/Galapagos\" },\n{ 64974, \"Pacific/Gambier\" },\n{ 64973, \"Pacific/Guadalcanal\" },\n{ 64972, \"Pacific/Guam\" },\n{ 64971, \"Pacific/Honolulu\" },\n{ 64970, \"Pacific/Johnston\" },\n{ 64969, \"Pacific/Kiritimati\" },\n{ 64968, \"Pacific/Kosrae\" },\n{ 64967, \"Pacific/Kwajalein\" },\n{ 64966, \"Pacific/Majuro\" },\n{ 64965, \"Pacific/Marquesas\" },\n{ 64964, \"Pacific/Midway\" },\n{ 64963, \"Pacific/Nauru\" },\n{ 64962, \"Pacific/Niue\" },\n{ 64961, \"Pacific/Norfolk\" },\n{ 64960, \"Pacific/Noumea\" },\n{ 64959, \"Pacific/Pago_Pago\" },\n{ 64958, \"Pacific/Palau\" },\n{ 64957, \"Pacific/Pitcairn\" },\n{ 64956, \"Pacific/Pohnpei\" },\n{ 64955, \"Pacific/Ponape\" },\n{ 64954, \"Pacific/Port_Moresby\" },\n{ 64953, \"Pacific/Rarotonga\" },\n{ 64952, \"Pacific/Saipan\" },\n{ 64951, \"Pacific/Samoa\" },\n{ 64950, \"Pacific/Tahiti\" },\n{ 64949, \"Pacific/Tarawa\" },\n{ 64948, \"Pacific/Tongatapu\" },\n{ 64947, \"Pacific/Truk\" },\n{ 64946, \"Pacific/Wake\" },\n{ 64945, \"Pacific/Wallis\" },\n{ 64944, \"Pacific/Yap\" },\n{ 64943, \"Poland\" },\n{ 64942, \"Portugal\" },\n{ 64941, \"ROC\" },\n{ 64940, \"ROK\" },\n{ 64939, \"SST\" },\n{ 64938, \"Singapore\" },\n{ 64937, \"SystemV/AST4\" },\n{ 64936, \"SystemV/AST4ADT\" },\n{ 64935, \"SystemV/CST6\" },\n{ 64934, \"SystemV/CST6CDT\" },\n{ 64933, \"SystemV/EST5\" },\n{ 64932, \"SystemV/EST5EDT\" },\n{ 64931, \"SystemV/HST10\" },\n{ 64930, \"SystemV/MST7\" },\n{ 64929, \"SystemV/MST7MDT\" },\n{ 64928, \"SystemV/PST8\" },\n{ 64927, \"SystemV/PST8PDT\" },\n{ 64926, \"SystemV/YST9\" },\n{ 64925, \"SystemV/YST9YDT\" },\n{ 64924, \"Turkey\" },\n{ 64923, \"UCT\" },\n{ 64922, \"US/Alaska\" },\n{ 64921, \"US/Aleutian\" },\n{ 64920, \"US/Arizona\" },\n{ 64919, \"US/Central\" },\n{ 64918, \"US/East-Indiana\" },\n{ 64917, \"US/Eastern\" },\n{ 64916, \"US/Hawaii\" },\n{ 64915, \"US/Indiana-Starke\" },\n{ 64914, \"US/Michigan\" },\n{ 64913, \"US/Mountain\" },\n{ 64912, \"US/Pacific\" },\n{ 64911, \"US/Pacific-New\" },\n{ 64910, \"US/Samoa\" },\n{ 64909, \"UTC\" },\n{ 64908, \"Universal\" },\n{ 64907, \"VST\" },\n{ 64906, \"W-SU\" },\n{ 64905, \"WET\" },\n{ 64904, \"Zulu\" },\n{ 64903, \"America/Nuuk\" },\n{ 64902, \"Asia/Qostanay\" },\n{ 64901, \"Pacific/Kanton\" },\n{ 64900, \"Europe/Kyiv\" },\n{ 64899, \"America/Ciudad_Juarez\" },\n\t\t};\n\n\t// select '{ \"' || trim(rdb$time_zone_name) || '\", ' || rdb$time_zone_id || ' },' from rdb$time_zones order by rdb$time_zone_id desc;\n\tstatic Dictionary<string, ushort> _nameToId = new Dictionary<string, ushort>()\n\t\t{\n{ \"GMT\", 65535 },\n{ \"ACT\", 65534 },\n{ \"AET\", 65533 },\n{ \"AGT\", 65532 },\n{ \"ART\", 65531 },\n{ \"AST\", 65530 },\n{ \"Africa/Abidjan\", 65529 },\n{ \"Africa/Accra\", 65528 },\n{ \"Africa/Addis_Ababa\", 65527 },\n{ \"Africa/Algiers\", 65526 },\n{ \"Africa/Asmara\", 65525 },\n{ \"Africa/Asmera\", 65524 },\n{ \"Africa/Bamako\", 65523 },\n{ \"Africa/Bangui\", 65522 },\n{ \"Africa/Banjul\", 65521 },\n{ \"Africa/Bissau\", 65520 },\n{ \"Africa/Blantyre\", 65519 },\n{ \"Africa/Brazzaville\", 65518 },\n{ \"Africa/Bujumbura\", 65517 },\n{ \"Africa/Cairo\", 65516 },\n{ \"Africa/Casablanca\", 65515 },\n{ \"Africa/Ceuta\", 65514 },\n{ \"Africa/Conakry\", 65513 },\n{ \"Africa/Dakar\", 65512 },\n{ \"Africa/Dar_es_Salaam\", 65511 },\n{ \"Africa/Djibouti\", 65510 },\n{ \"Africa/Douala\", 65509 },\n{ \"Africa/El_Aaiun\", 65508 },\n{ \"Africa/Freetown\", 65507 },\n{ \"Africa/Gaborone\", 65506 },\n{ \"Africa/Harare\", 65505 },\n{ \"Africa/Johannesburg\", 65504 },\n{ \"Africa/Juba\", 65503 },\n{ \"Africa/Kampala\", 65502 },\n{ \"Africa/Khartoum\", 65501 },\n{ \"Africa/Kigali\", 65500 },\n{ \"Africa/Kinshasa\", 65499 },\n{ \"Africa/Lagos\", 65498 },\n{ \"Africa/Libreville\", 65497 },\n{ \"Africa/Lome\", 65496 },\n{ \"Africa/Luanda\", 65495 },\n{ \"Africa/Lubumbashi\", 65494 },\n{ \"Africa/Lusaka\", 65493 },\n{ \"Africa/Malabo\", 65492 },\n{ \"Africa/Maputo\", 65491 },\n{ \"Africa/Maseru\", 65490 },\n{ \"Africa/Mbabane\", 65489 },\n{ \"Africa/Mogadishu\", 65488 },\n{ \"Africa/Monrovia\", 65487 },\n{ \"Africa/Nairobi\", 65486 },\n{ \"Africa/Ndjamena\", 65485 },\n{ \"Africa/Niamey\", 65484 },\n{ \"Africa/Nouakchott\", 65483 },\n{ \"Africa/Ouagadougou\", 65482 },\n{ \"Africa/Porto-Novo\", 65481 },\n{ \"Africa/Sao_Tome\", 65480 },\n{ \"Africa/Timbuktu\", 65479 },\n{ \"Africa/Tripoli\", 65478 },\n{ \"Africa/Tunis\", 65477 },\n{ \"Africa/Windhoek\", 65476 },\n{ \"America/Adak\", 65475 },\n{ \"America/Anchorage\", 65474 },\n{ \"America/Anguilla\", 65473 },\n{ \"America/Antigua\", 65472 },\n{ \"America/Araguaina\", 65471 },\n{ \"America/Argentina/Buenos_Aires\", 65470 },\n{ \"America/Argentina/Catamarca\", 65469 },\n{ \"America/Argentina/ComodRivadavia\", 65468 },\n{ \"America/Argentina/Cordoba\", 65467 },\n{ \"America/Argentina/Jujuy\", 65466 },\n{ \"America/Argentina/La_Rioja\", 65465 },\n{ \"America/Argentina/Mendoza\", 65464 },\n{ \"America/Argentina/Rio_Gallegos\", 65463 },\n{ \"America/Argentina/Salta\", 65462 },\n{ \"America/Argentina/San_Juan\", 65461 },\n{ \"America/Argentina/San_Luis\", 65460 },\n{ \"America/Argentina/Tucuman\", 65459 },\n{ \"America/Argentina/Ushuaia\", 65458 },\n{ \"America/Aruba\", 65457 },\n{ \"America/Asuncion\", 65456 },\n{ \"America/Atikokan\", 65455 },\n{ \"America/Atka\", 65454 },\n{ \"America/Bahia\", 65453 },\n{ \"America/Bahia_Banderas\", 65452 },\n{ \"America/Barbados\", 65451 },\n{ \"America/Belem\", 65450 },\n{ \"America/Belize\", 65449 },\n{ \"America/Blanc-Sablon\", 65448 },\n{ \"America/Boa_Vista\", 65447 },\n{ \"America/Bogota\", 65446 },\n{ \"America/Boise\", 65445 },\n{ \"America/Buenos_Aires\", 65444 },\n{ \"America/Cambridge_Bay\", 65443 },\n{ \"America/Campo_Grande\", 65442 },\n{ \"America/Cancun\", 65441 },\n{ \"America/Caracas\", 65440 },\n{ \"America/Catamarca\", 65439 },\n{ \"America/Cayenne\", 65438 },\n{ \"America/Cayman\", 65437 },\n{ \"America/Chicago\", 65436 },\n{ \"America/Chihuahua\", 65435 },\n{ \"America/Coral_Harbour\", 65434 },\n{ \"America/Cordoba\", 65433 },\n{ \"America/Costa_Rica\", 65432 },\n{ \"America/Creston\", 65431 },\n{ \"America/Cuiaba\", 65430 },\n{ \"America/Curacao\", 65429 },\n{ \"America/Danmarkshavn\", 65428 },\n{ \"America/Dawson\", 65427 },\n{ \"America/Dawson_Creek\", 65426 },\n{ \"America/Denver\", 65425 },\n{ \"America/Detroit\", 65424 },\n{ \"America/Dominica\", 65423 },\n{ \"America/Edmonton\", 65422 },\n{ \"America/Eirunepe\", 65421 },\n{ \"America/El_Salvador\", 65420 },\n{ \"America/Ensenada\", 65419 },\n{ \"America/Fort_Nelson\", 65418 },\n{ \"America/Fort_Wayne\", 65417 },\n{ \"America/Fortaleza\", 65416 },\n{ \"America/Glace_Bay\", 65415 },\n{ \"America/Godthab\", 65414 },\n{ \"America/Goose_Bay\", 65413 },\n{ \"America/Grand_Turk\", 65412 },\n{ \"America/Grenada\", 65411 },\n{ \"America/Guadeloupe\", 65410 },\n{ \"America/Guatemala\", 65409 },\n{ \"America/Guayaquil\", 65408 },\n{ \"America/Guyana\", 65407 },\n{ \"America/Halifax\", 65406 },\n{ \"America/Havana\", 65405 },\n{ \"America/Hermosillo\", 65404 },\n{ \"America/Indiana/Indianapolis\", 65403 },\n{ \"America/Indiana/Knox\", 65402 },\n{ \"America/Indiana/Marengo\", 65401 },\n{ \"America/Indiana/Petersburg\", 65400 },\n{ \"America/Indiana/Tell_City\", 65399 },\n{ \"America/Indiana/Vevay\", 65398 },\n{ \"America/Indiana/Vincennes\", 65397 },\n{ \"America/Indiana/Winamac\", 65396 },\n{ \"America/Indianapolis\", 65395 },\n{ \"America/Inuvik\", 65394 },\n{ \"America/Iqaluit\", 65393 },\n{ \"America/Jamaica\", 65392 },\n{ \"America/Jujuy\", 65391 },\n{ \"America/Juneau\", 65390 },\n{ \"America/Kentucky/Louisville\", 65389 },\n{ \"America/Kentucky/Monticello\", 65388 },\n{ \"America/Knox_IN\", 65387 },\n{ \"America/Kralendijk\", 65386 },\n{ \"America/La_Paz\", 65385 },\n{ \"America/Lima\", 65384 },\n{ \"America/Los_Angeles\", 65383 },\n{ \"America/Louisville\", 65382 },\n{ \"America/Lower_Princes\", 65381 },\n{ \"America/Maceio\", 65380 },\n{ \"America/Managua\", 65379 },\n{ \"America/Manaus\", 65378 },\n{ \"America/Marigot\", 65377 },\n{ \"America/Martinique\", 65376 },\n{ \"America/Matamoros\", 65375 },\n{ \"America/Mazatlan\", 65374 },\n{ \"America/Mendoza\", 65373 },\n{ \"America/Menominee\", 65372 },\n{ \"America/Merida\", 65371 },\n{ \"America/Metlakatla\", 65370 },\n{ \"America/Mexico_City\", 65369 },\n{ \"America/Miquelon\", 65368 },\n{ \"America/Moncton\", 65367 },\n{ \"America/Monterrey\", 65366 },\n{ \"America/Montevideo\", 65365 },\n{ \"America/Montreal\", 65364 },\n{ \"America/Montserrat\", 65363 },\n{ \"America/Nassau\", 65362 },\n{ \"America/New_York\", 65361 },\n{ \"America/Nipigon\", 65360 },\n{ \"America/Nome\", 65359 },\n{ \"America/Noronha\", 65358 },\n{ \"America/North_Dakota/Beulah\", 65357 },\n{ \"America/North_Dakota/Center\", 65356 },\n{ \"America/North_Dakota/New_Salem\", 65355 },\n{ \"America/Ojinaga\", 65354 },\n{ \"America/Panama\", 65353 },\n{ \"America/Pangnirtung\", 65352 },\n{ \"America/Paramaribo\", 65351 },\n{ \"America/Phoenix\", 65350 },\n{ \"America/Port-au-Prince\", 65349 },\n{ \"America/Port_of_Spain\", 65348 },\n{ \"America/Porto_Acre\", 65347 },\n{ \"America/Porto_Velho\", 65346 },\n{ \"America/Puerto_Rico\", 65345 },\n{ \"America/Punta_Arenas\", 65344 },\n{ \"America/Rainy_River\", 65343 },\n{ \"America/Rankin_Inlet\", 65342 },\n{ \"America/Recife\", 65341 },\n{ \"America/Regina\", 65340 },\n{ \"America/Resolute\", 65339 },\n{ \"America/Rio_Branco\", 65338 },\n{ \"America/Rosario\", 65337 },\n{ \"America/Santa_Isabel\", 65336 },\n{ \"America/Santarem\", 65335 },\n{ \"America/Santiago\", 65334 },\n{ \"America/Santo_Domingo\", 65333 },\n{ \"America/Sao_Paulo\", 65332 },\n{ \"America/Scoresbysund\", 65331 },\n{ \"America/Shiprock\", 65330 },\n{ \"America/Sitka\", 65329 },\n{ \"America/St_Barthelemy\", 65328 },\n{ \"America/St_Johns\", 65327 },\n{ \"America/St_Kitts\", 65326 },\n{ \"America/St_Lucia\", 65325 },\n{ \"America/St_Thomas\", 65324 },\n{ \"America/St_Vincent\", 65323 },\n{ \"America/Swift_Current\", 65322 },\n{ \"America/Tegucigalpa\", 65321 },\n{ \"America/Thule\", 65320 },\n{ \"America/Thunder_Bay\", 65319 },\n{ \"America/Tijuana\", 65318 },\n{ \"America/Toronto\", 65317 },\n{ \"America/Tortola\", 65316 },\n{ \"America/Vancouver\", 65315 },\n{ \"America/Virgin\", 65314 },\n{ \"America/Whitehorse\", 65313 },\n{ \"America/Winnipeg\", 65312 },\n{ \"America/Yakutat\", 65311 },\n{ \"America/Yellowknife\", 65310 },\n{ \"Antarctica/Casey\", 65309 },\n{ \"Antarctica/Davis\", 65308 },\n{ \"Antarctica/DumontDUrville\", 65307 },\n{ \"Antarctica/Macquarie\", 65306 },\n{ \"Antarctica/Mawson\", 65305 },\n{ \"Antarctica/McMurdo\", 65304 },\n{ \"Antarctica/Palmer\", 65303 },\n{ \"Antarctica/Rothera\", 65302 },\n{ \"Antarctica/South_Pole\", 65301 },\n{ \"Antarctica/Syowa\", 65300 },\n{ \"Antarctica/Troll\", 65299 },\n{ \"Antarctica/Vostok\", 65298 },\n{ \"Arctic/Longyearbyen\", 65297 },\n{ \"Asia/Aden\", 65296 },\n{ \"Asia/Almaty\", 65295 },\n{ \"Asia/Amman\", 65294 },\n{ \"Asia/Anadyr\", 65293 },\n{ \"Asia/Aqtau\", 65292 },\n{ \"Asia/Aqtobe\", 65291 },\n{ \"Asia/Ashgabat\", 65290 },\n{ \"Asia/Ashkhabad\", 65289 },\n{ \"Asia/Atyrau\", 65288 },\n{ \"Asia/Baghdad\", 65287 },\n{ \"Asia/Bahrain\", 65286 },\n{ \"Asia/Baku\", 65285 },\n{ \"Asia/Bangkok\", 65284 },\n{ \"Asia/Barnaul\", 65283 },\n{ \"Asia/Beirut\", 65282 },\n{ \"Asia/Bishkek\", 65281 },\n{ \"Asia/Brunei\", 65280 },\n{ \"Asia/Calcutta\", 65279 },\n{ \"Asia/Chita\", 65278 },\n{ \"Asia/Choibalsan\", 65277 },\n{ \"Asia/Chongqing\", 65276 },\n{ \"Asia/Chungking\", 65275 },\n{ \"Asia/Colombo\", 65274 },\n{ \"Asia/Dacca\", 65273 },\n{ \"Asia/Damascus\", 65272 },\n{ \"Asia/Dhaka\", 65271 },\n{ \"Asia/Dili\", 65270 },\n{ \"Asia/Dubai\", 65269 },\n{ \"Asia/Dushanbe\", 65268 },\n{ \"Asia/Famagusta\", 65267 },\n{ \"Asia/Gaza\", 65266 },\n{ \"Asia/Harbin\", 65265 },\n{ \"Asia/Hebron\", 65264 },\n{ \"Asia/Ho_Chi_Minh\", 65263 },\n{ \"Asia/Hong_Kong\", 65262 },\n{ \"Asia/Hovd\", 65261 },\n{ \"Asia/Irkutsk\", 65260 },\n{ \"Asia/Istanbul\", 65259 },\n{ \"Asia/Jakarta\", 65258 },\n{ \"Asia/Jayapura\", 65257 },\n{ \"Asia/Jerusalem\", 65256 },\n{ \"Asia/Kabul\", 65255 },\n{ \"Asia/Kamchatka\", 65254 },\n{ \"Asia/Karachi\", 65253 },\n{ \"Asia/Kashgar\", 65252 },\n{ \"Asia/Kathmandu\", 65251 },\n{ \"Asia/Katmandu\", 65250 },\n{ \"Asia/Khandyga\", 65249 },\n{ \"Asia/Kolkata\", 65248 },\n{ \"Asia/Krasnoyarsk\", 65247 },\n{ \"Asia/Kuala_Lumpur\", 65246 },\n{ \"Asia/Kuching\", 65245 },\n{ \"Asia/Kuwait\", 65244 },\n{ \"Asia/Macao\", 65243 },\n{ \"Asia/Macau\", 65242 },\n{ \"Asia/Magadan\", 65241 },\n{ \"Asia/Makassar\", 65240 },\n{ \"Asia/Manila\", 65239 },\n{ \"Asia/Muscat\", 65238 },\n{ \"Asia/Nicosia\", 65237 },\n{ \"Asia/Novokuznetsk\", 65236 },\n{ \"Asia/Novosibirsk\", 65235 },\n{ \"Asia/Omsk\", 65234 },\n{ \"Asia/Oral\", 65233 },\n{ \"Asia/Phnom_Penh\", 65232 },\n{ \"Asia/Pontianak\", 65231 },\n{ \"Asia/Pyongyang\", 65230 },\n{ \"Asia/Qatar\", 65229 },\n{ \"Asia/Qyzylorda\", 65228 },\n{ \"Asia/Rangoon\", 65227 },\n{ \"Asia/Riyadh\", 65226 },\n{ \"Asia/Saigon\", 65225 },\n{ \"Asia/Sakhalin\", 65224 },\n{ \"Asia/Samarkand\", 65223 },\n{ \"Asia/Seoul\", 65222 },\n{ \"Asia/Shanghai\", 65221 },\n{ \"Asia/Singapore\", 65220 },\n{ \"Asia/Srednekolymsk\", 65219 },\n{ \"Asia/Taipei\", 65218 },\n{ \"Asia/Tashkent\", 65217 },\n{ \"Asia/Tbilisi\", 65216 },\n{ \"Asia/Tehran\", 65215 },\n{ \"Asia/Tel_Aviv\", 65214 },\n{ \"Asia/Thimbu\", 65213 },\n{ \"Asia/Thimphu\", 65212 },\n{ \"Asia/Tokyo\", 65211 },\n{ \"Asia/Tomsk\", 65210 },\n{ \"Asia/Ujung_Pandang\", 65209 },\n{ \"Asia/Ulaanbaatar\", 65208 },\n{ \"Asia/Ulan_Bator\", 65207 },\n{ \"Asia/Urumqi\", 65206 },\n{ \"Asia/Ust-Nera\", 65205 },\n{ \"Asia/Vientiane\", 65204 },\n{ \"Asia/Vladivostok\", 65203 },\n{ \"Asia/Yakutsk\", 65202 },\n{ \"Asia/Yangon\", 65201 },\n{ \"Asia/Yekaterinburg\", 65200 },\n{ \"Asia/Yerevan\", 65199 },\n{ \"Atlantic/Azores\", 65198 },\n{ \"Atlantic/Bermuda\", 65197 },\n{ \"Atlantic/Canary\", 65196 },\n{ \"Atlantic/Cape_Verde\", 65195 },\n{ \"Atlantic/Faeroe\", 65194 },\n{ \"Atlantic/Faroe\", 65193 },\n{ \"Atlantic/Jan_Mayen\", 65192 },\n{ \"Atlantic/Madeira\", 65191 },\n{ \"Atlantic/Reykjavik\", 65190 },\n{ \"Atlantic/South_Georgia\", 65189 },\n{ \"Atlantic/St_Helena\", 65188 },\n{ \"Atlantic/Stanley\", 65187 },\n{ \"Australia/ACT\", 65186 },\n{ \"Australia/Adelaide\", 65185 },\n{ \"Australia/Brisbane\", 65184 },\n{ \"Australia/Broken_Hill\", 65183 },\n{ \"Australia/Canberra\", 65182 },\n{ \"Australia/Currie\", 65181 },\n{ \"Australia/Darwin\", 65180 },\n{ \"Australia/Eucla\", 65179 },\n{ \"Australia/Hobart\", 65178 },\n{ \"Australia/LHI\", 65177 },\n{ \"Australia/Lindeman\", 65176 },\n{ \"Australia/Lord_Howe\", 65175 },\n{ \"Australia/Melbourne\", 65174 },\n{ \"Australia/NSW\", 65173 },\n{ \"Australia/North\", 65172 },\n{ \"Australia/Perth\", 65171 },\n{ \"Australia/Queensland\", 65170 },\n{ \"Australia/South\", 65169 },\n{ \"Australia/Sydney\", 65168 },\n{ \"Australia/Tasmania\", 65167 },\n{ \"Australia/Victoria\", 65166 },\n{ \"Australia/West\", 65165 },\n{ \"Australia/Yancowinna\", 65164 },\n{ \"BET\", 65163 },\n{ \"BST\", 65162 },\n{ \"Brazil/Acre\", 65161 },\n{ \"Brazil/DeNoronha\", 65160 },\n{ \"Brazil/East\", 65159 },\n{ \"Brazil/West\", 65158 },\n{ \"CAT\", 65157 },\n{ \"CET\", 65156 },\n{ \"CNT\", 65155 },\n{ \"CST\", 65154 },\n{ \"CST6CDT\", 65153 },\n{ \"CTT\", 65152 },\n{ \"Canada/Atlantic\", 65151 },\n{ \"Canada/Central\", 65150 },\n{ \"Canada/East-Saskatchewan\", 65149 },\n{ \"Canada/Eastern\", 65148 },\n{ \"Canada/Mountain\", 65147 },\n{ \"Canada/Newfoundland\", 65146 },\n{ \"Canada/Pacific\", 65145 },\n{ \"Canada/Saskatchewan\", 65144 },\n{ \"Canada/Yukon\", 65143 },\n{ \"Chile/Continental\", 65142 },\n{ \"Chile/EasterIsland\", 65141 },\n{ \"Cuba\", 65140 },\n{ \"EAT\", 65139 },\n{ \"ECT\", 65138 },\n{ \"EET\", 65137 },\n{ \"EST\", 65136 },\n{ \"EST5EDT\", 65135 },\n{ \"Egypt\", 65134 },\n{ \"Eire\", 65133 },\n{ \"Etc/GMT\", 65132 },\n{ \"Etc/GMT+0\", 65131 },\n{ \"Etc/GMT+1\", 65130 },\n{ \"Etc/GMT+10\", 65129 },\n{ \"Etc/GMT+11\", 65128 },\n{ \"Etc/GMT+12\", 65127 },\n{ \"Etc/GMT+2\", 65126 },\n{ \"Etc/GMT+3\", 65125 },\n{ \"Etc/GMT+4\", 65124 },\n{ \"Etc/GMT+5\", 65123 },\n{ \"Etc/GMT+6\", 65122 },\n{ \"Etc/GMT+7\", 65121 },\n{ \"Etc/GMT+8\", 65120 },\n{ \"Etc/GMT+9\", 65119 },\n{ \"Etc/GMT-0\", 65118 },\n{ \"Etc/GMT-1\", 65117 },\n{ \"Etc/GMT-10\", 65116 },\n{ \"Etc/GMT-11\", 65115 },\n{ \"Etc/GMT-12\", 65114 },\n{ \"Etc/GMT-13\", 65113 },\n{ \"Etc/GMT-14\", 65112 },\n{ \"Etc/GMT-2\", 65111 },\n{ \"Etc/GMT-3\", 65110 },\n{ \"Etc/GMT-4\", 65109 },\n{ \"Etc/GMT-5\", 65108 },\n{ \"Etc/GMT-6\", 65107 },\n{ \"Etc/GMT-7\", 65106 },\n{ \"Etc/GMT-8\", 65105 },\n{ \"Etc/GMT-9\", 65104 },\n{ \"Etc/GMT0\", 65103 },\n{ \"Etc/Greenwich\", 65102 },\n{ \"Etc/UCT\", 65101 },\n{ \"Etc/UTC\", 65100 },\n{ \"Etc/Universal\", 65099 },\n{ \"Etc/Zulu\", 65098 },\n{ \"Europe/Amsterdam\", 65097 },\n{ \"Europe/Andorra\", 65096 },\n{ \"Europe/Astrakhan\", 65095 },\n{ \"Europe/Athens\", 65094 },\n{ \"Europe/Belfast\", 65093 },\n{ \"Europe/Belgrade\", 65092 },\n{ \"Europe/Berlin\", 65091 },\n{ \"Europe/Bratislava\", 65090 },\n{ \"Europe/Brussels\", 65089 },\n{ \"Europe/Bucharest\", 65088 },\n{ \"Europe/Budapest\", 65087 },\n{ \"Europe/Busingen\", 65086 },\n{ \"Europe/Chisinau\", 65085 },\n{ \"Europe/Copenhagen\", 65084 },\n{ \"Europe/Dublin\", 65083 },\n{ \"Europe/Gibraltar\", 65082 },\n{ \"Europe/Guernsey\", 65081 },\n{ \"Europe/Helsinki\", 65080 },\n{ \"Europe/Isle_of_Man\", 65079 },\n{ \"Europe/Istanbul\", 65078 },\n{ \"Europe/Jersey\", 65077 },\n{ \"Europe/Kaliningrad\", 65076 },\n{ \"Europe/Kiev\", 65075 },\n{ \"Europe/Kirov\", 65074 },\n{ \"Europe/Lisbon\", 65073 },\n{ \"Europe/Ljubljana\", 65072 },\n{ \"Europe/London\", 65071 },\n{ \"Europe/Luxembourg\", 65070 },\n{ \"Europe/Madrid\", 65069 },\n{ \"Europe/Malta\", 65068 },\n{ \"Europe/Mariehamn\", 65067 },\n{ \"Europe/Minsk\", 65066 },\n{ \"Europe/Monaco\", 65065 },\n{ \"Europe/Moscow\", 65064 },\n{ \"Europe/Nicosia\", 65063 },\n{ \"Europe/Oslo\", 65062 },\n{ \"Europe/Paris\", 65061 },\n{ \"Europe/Podgorica\", 65060 },\n{ \"Europe/Prague\", 65059 },\n{ \"Europe/Riga\", 65058 },\n{ \"Europe/Rome\", 65057 },\n{ \"Europe/Samara\", 65056 },\n{ \"Europe/San_Marino\", 65055 },\n{ \"Europe/Sarajevo\", 65054 },\n{ \"Europe/Saratov\", 65053 },\n{ \"Europe/Simferopol\", 65052 },\n{ \"Europe/Skopje\", 65051 },\n{ \"Europe/Sofia\", 65050 },\n{ \"Europe/Stockholm\", 65049 },\n{ \"Europe/Tallinn\", 65048 },\n{ \"Europe/Tirane\", 65047 },\n{ \"Europe/Tiraspol\", 65046 },\n{ \"Europe/Ulyanovsk\", 65045 },\n{ \"Europe/Uzhgorod\", 65044 },\n{ \"Europe/Vaduz\", 65043 },\n{ \"Europe/Vatican\", 65042 },\n{ \"Europe/Vienna\", 65041 },\n{ \"Europe/Vilnius\", 65040 },\n{ \"Europe/Volgograd\", 65039 },\n{ \"Europe/Warsaw\", 65038 },\n{ \"Europe/Zagreb\", 65037 },\n{ \"Europe/Zaporozhye\", 65036 },\n{ \"Europe/Zurich\", 65035 },\n{ \"Factory\", 65034 },\n{ \"GB\", 65033 },\n{ \"GB-Eire\", 65032 },\n{ \"GMT+0\", 65031 },\n{ \"GMT-0\", 65030 },\n{ \"GMT0\", 65029 },\n{ \"Greenwich\", 65028 },\n{ \"HST\", 65027 },\n{ \"Hongkong\", 65026 },\n{ \"IET\", 65025 },\n{ \"IST\", 65024 },\n{ \"Iceland\", 65023 },\n{ \"Indian/Antananarivo\", 65022 },\n{ \"Indian/Chagos\", 65021 },\n{ \"Indian/Christmas\", 65020 },\n{ \"Indian/Cocos\", 65019 },\n{ \"Indian/Comoro\", 65018 },\n{ \"Indian/Kerguelen\", 65017 },\n{ \"Indian/Mahe\", 65016 },\n{ \"Indian/Maldives\", 65015 },\n{ \"Indian/Mauritius\", 65014 },\n{ \"Indian/Mayotte\", 65013 },\n{ \"Indian/Reunion\", 65012 },\n{ \"Iran\", 65011 },\n{ \"Israel\", 65010 },\n{ \"JST\", 65009 },\n{ \"Jamaica\", 65008 },\n{ \"Japan\", 65007 },\n{ \"Kwajalein\", 65006 },\n{ \"Libya\", 65005 },\n{ \"MET\", 65004 },\n{ \"MIT\", 65003 },\n{ \"MST\", 65002 },\n{ \"MST7MDT\", 65001 },\n{ \"Mexico/BajaNorte\", 65000 },\n{ \"Mexico/BajaSur\", 64999 },\n{ \"Mexico/General\", 64998 },\n{ \"NET\", 64997 },\n{ \"NST\", 64996 },\n{ \"NZ\", 64995 },\n{ \"NZ-CHAT\", 64994 },\n{ \"Navajo\", 64993 },\n{ \"PLT\", 64992 },\n{ \"PNT\", 64991 },\n{ \"PRC\", 64990 },\n{ \"PRT\", 64989 },\n{ \"PST\", 64988 },\n{ \"PST8PDT\", 64987 },\n{ \"Pacific/Apia\", 64986 },\n{ \"Pacific/Auckland\", 64985 },\n{ \"Pacific/Bougainville\", 64984 },\n{ \"Pacific/Chatham\", 64983 },\n{ \"Pacific/Chuuk\", 64982 },\n{ \"Pacific/Easter\", 64981 },\n{ \"Pacific/Efate\", 64980 },\n{ \"Pacific/Enderbury\", 64979 },\n{ \"Pacific/Fakaofo\", 64978 },\n{ \"Pacific/Fiji\", 64977 },\n{ \"Pacific/Funafuti\", 64976 },\n{ \"Pacific/Galapagos\", 64975 },\n{ \"Pacific/Gambier\", 64974 },\n{ \"Pacific/Guadalcanal\", 64973 },\n{ \"Pacific/Guam\", 64972 },\n{ \"Pacific/Honolulu\", 64971 },\n{ \"Pacific/Johnston\", 64970 },\n{ \"Pacific/Kiritimati\", 64969 },\n{ \"Pacific/Kosrae\", 64968 },\n{ \"Pacific/Kwajalein\", 64967 },\n{ \"Pacific/Majuro\", 64966 },\n{ \"Pacific/Marquesas\", 64965 },\n{ \"Pacific/Midway\", 64964 },\n{ \"Pacific/Nauru\", 64963 },\n{ \"Pacific/Niue\", 64962 },\n{ \"Pacific/Norfolk\", 64961 },\n{ \"Pacific/Noumea\", 64960 },\n{ \"Pacific/Pago_Pago\", 64959 },\n{ \"Pacific/Palau\", 64958 },\n{ \"Pacific/Pitcairn\", 64957 },\n{ \"Pacific/Pohnpei\", 64956 },\n{ \"Pacific/Ponape\", 64955 },\n{ \"Pacific/Port_Moresby\", 64954 },\n{ \"Pacific/Rarotonga\", 64953 },\n{ \"Pacific/Saipan\", 64952 },\n{ \"Pacific/Samoa\", 64951 },\n{ \"Pacific/Tahiti\", 64950 },\n{ \"Pacific/Tarawa\", 64949 },\n{ \"Pacific/Tongatapu\", 64948 },\n{ \"Pacific/Truk\", 64947 },\n{ \"Pacific/Wake\", 64946 },\n{ \"Pacific/Wallis\", 64945 },\n{ \"Pacific/Yap\", 64944 },\n{ \"Poland\", 64943 },\n{ \"Portugal\", 64942 },\n{ \"ROC\", 64941 },\n{ \"ROK\", 64940 },\n{ \"SST\", 64939 },\n{ \"Singapore\", 64938 },\n{ \"SystemV/AST4\", 64937 },\n{ \"SystemV/AST4ADT\", 64936 },\n{ \"SystemV/CST6\", 64935 },\n{ \"SystemV/CST6CDT\", 64934 },\n{ \"SystemV/EST5\", 64933 },\n{ \"SystemV/EST5EDT\", 64932 },\n{ \"SystemV/HST10\", 64931 },\n{ \"SystemV/MST7\", 64930 },\n{ \"SystemV/MST7MDT\", 64929 },\n{ \"SystemV/PST8\", 64928 },\n{ \"SystemV/PST8PDT\", 64927 },\n{ \"SystemV/YST9\", 64926 },\n{ \"SystemV/YST9YDT\", 64925 },\n{ \"Turkey\", 64924 },\n{ \"UCT\", 64923 },\n{ \"US/Alaska\", 64922 },\n{ \"US/Aleutian\", 64921 },\n{ \"US/Arizona\", 64920 },\n{ \"US/Central\", 64919 },\n{ \"US/East-Indiana\", 64918 },\n{ \"US/Eastern\", 64917 },\n{ \"US/Hawaii\", 64916 },\n{ \"US/Indiana-Starke\", 64915 },\n{ \"US/Michigan\", 64914 },\n{ \"US/Mountain\", 64913 },\n{ \"US/Pacific\", 64912 },\n{ \"US/Pacific-New\", 64911 },\n{ \"US/Samoa\", 64910 },\n{ \"UTC\", 64909 },\n{ \"Universal\", 64908 },\n{ \"VST\", 64907 },\n{ \"W-SU\", 64906 },\n{ \"WET\", 64905 },\n{ \"Zulu\", 64904 },\n{ \"America/Nuuk\", 64903 },\n{ \"Asia/Qostanay\", 64902 },\n{ \"Pacific/Kanton\", 64901 },\n{ \"Europe/Kyiv\", 64900 },\n{ \"America/Ciudad_Juarez\", 64899 },\n\t\t};\n\n\tpublic static readonly string DefaultTimeZoneName = \"GMT\";\n\n\tpublic static bool TryGetByName(string name, out ushort id) => _nameToId.TryGetValue(name, out id);\n\n\tpublic static bool TryGetById(ushort id, out string name) => _idToName.TryGetValue(id, out name);\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/TransactionBase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal abstract class TransactionBase\n{\n\tpublic abstract int Handle { get; }\n\n\tpublic TransactionState State { get; protected set; }\n\tpublic event EventHandler Update;\n\n\tpublic abstract void BeginTransaction(TransactionParameterBuffer tpb);\n\tpublic abstract ValueTask BeginTransactionAsync(TransactionParameterBuffer tpb, CancellationToken cancellationToken = default);\n\n\tpublic abstract void Commit();\n\tpublic abstract ValueTask CommitAsync(CancellationToken cancellationToken = default);\n\n\tpublic abstract void CommitRetaining();\n\tpublic abstract ValueTask CommitRetainingAsync(CancellationToken cancellationToken = default);\n\n\tpublic abstract void Rollback();\n\tpublic abstract ValueTask RollbackAsync(CancellationToken cancellationToken = default);\n\n\tpublic abstract void RollbackRetaining();\n\tpublic abstract ValueTask RollbackRetainingAsync(CancellationToken cancellationToken = default);\n\n\tpublic abstract void Prepare();\n\tpublic abstract ValueTask PrepareAsync(CancellationToken cancellationToken = default);\n\n\tpublic abstract void Prepare(byte[] buffer);\n\tpublic abstract ValueTask PrepareAsync(byte[] buffer, CancellationToken cancellationToken = default);\n\n\tpublic abstract List<object> GetTransactionInfo(byte[] items);\n\tpublic abstract ValueTask<List<object>> GetTransactionInfoAsync(byte[] items, CancellationToken cancellationToken = default);\n\n\tpublic abstract List<object> GetTransactionInfo(byte[] items, int bufferLength);\n\tpublic abstract ValueTask<List<object>> GetTransactionInfoAsync(byte[] items, int bufferLength, CancellationToken cancellationToken = default);\n\n\tpublic virtual void Dispose2()\n\t{ }\n\tpublic virtual ValueTask Dispose2Async(CancellationToken cancellationToken = default)\n\t{\n\t\treturn ValueTask.CompletedTask;\n\t}\n\n\tprotected void EnsureActiveTransactionState()\n\t{\n\t\tif (State != TransactionState.Active)\n\t\t\tthrow IscException.ForTypeErrorCodeIntParamStrParam(IscCodes.isc_arg_gds, IscCodes.isc_tra_state, Handle, \"no valid\");\n\t}\n\n\tprotected void OnUpdate(EventArgs e)\n\t{\n\t\tUpdate?.Invoke(this, e);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/TransactionParameterBuffer.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal sealed class TransactionParameterBuffer : ParameterBuffer\n{\n\tpublic TransactionParameterBuffer(Encoding encoding)\n\t{\n\t\tEncoding = encoding;\n\t}\n\n\tpublic void Append(int type, short value)\n\t{\n\t\tWriteByte(type);\n\t\tWriteByte(2);\n\t\tWrite(value);\n\t}\n\n\tpublic void Append(int type, int value)\n\t{\n\t\tWriteByte(type);\n\t\tWriteByte(4);\n\t\tWrite(value);\n\t}\n\n\tpublic void Append(int type, long value)\n\t{\n\t\tWriteByte(type);\n\t\tWriteByte(8);\n\t\tWrite(value);\n\t}\n\n\tpublic void Append(int type, byte[] buffer)\n\t{\n\t\tWriteByte(type);\n\t\tWriteByte(buffer.Length);\n\t\tWrite(buffer);\n\t}\n\n\tpublic void Append(int type, string content) => Append(type, Encoding.GetBytes(content));\n\n\tpublic Encoding Encoding { get; }\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/TransactionState.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez\n\nusing System;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal enum TransactionState\n{\n\tNoTransaction,\n\tActive,\n\tPrepared\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/TypeDecoder.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Net;\nusing System.Numerics;\nusing FirebirdSql.Data.Types;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class TypeDecoder\n{\n\tpublic static decimal DecodeDecimal(object value, int scale, int type)\n\t{\n\t\tvar shift = scale < 0 ? -scale : scale;\n\n\t\tswitch (type & ~1)\n\t\t{\n\t\t\tcase IscCodes.SQL_SHORT:\n\t\t\t\treturn DecimalShiftHelper.ShiftDecimalLeft((decimal)(short)value, shift);\n\n\t\t\tcase IscCodes.SQL_LONG:\n\t\t\t\treturn DecimalShiftHelper.ShiftDecimalLeft((decimal)(int)value, shift);\n\n\t\t\tcase IscCodes.SQL_QUAD:\n\t\t\tcase IscCodes.SQL_INT64:\n\t\t\t\treturn DecimalShiftHelper.ShiftDecimalLeft((decimal)(long)value, shift);\n\n\t\t\tcase IscCodes.SQL_DOUBLE:\n\t\t\tcase IscCodes.SQL_D_FLOAT:\n\t\t\t\treturn (decimal)(double)value;\n\n\t\t\tcase IscCodes.SQL_INT128:\n\t\t\t\treturn DecimalShiftHelper.ShiftDecimalLeft((decimal)(BigInteger)value, shift);\n\n\t\t\tdefault:\n\t\t\t\tthrow new ArgumentOutOfRangeException(nameof(type), $\"{nameof(type)}={type}\");\n\t\t}\n\t}\n\n\tpublic static TimeSpan DecodeTime(int sqlTime)\n\t{\n\t\treturn TimeSpan.FromTicks(sqlTime * 1000L);\n\t}\n\n\tpublic static DateTime DecodeDate(int sqlDate)\n\t{\n\t\tvar (year, month, day) = DecodeDateImpl(sqlDate);\n\t\tvar date = new DateTime(year, month, day);\n\t\treturn date.Date;\n\t}\n\tstatic (int year, int month, int day) DecodeDateImpl(int sqlDate)\n\t{\n\t\tsqlDate -= 1721119 - 2400001;\n\t\tvar century = (4 * sqlDate - 1) / 146097;\n\t\tsqlDate = 4 * sqlDate - 1 - 146097 * century;\n\t\tvar day = sqlDate / 4;\n\n\t\tsqlDate = (4 * day + 3) / 1461;\n\t\tday = 4 * day + 3 - 1461 * sqlDate;\n\t\tday = (day + 4) / 4;\n\n\t\tvar month = (5 * day - 3) / 153;\n\t\tday = 5 * day - 3 - 153 * month;\n\t\tday = (day + 5) / 5;\n\n\t\tvar year = 100 * century + sqlDate;\n\n\t\tif (month < 10)\n\t\t{\n\t\t\tmonth += 3;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tmonth -= 9;\n\t\t\tyear += 1;\n\t\t}\n\n\t\treturn (year, month, day);\n\t}\n\n\tpublic static bool DecodeBoolean(byte[] value)\n\t{\n\t\treturn value[0] != 0;\n\t}\n\n\tpublic static Guid DecodeGuid(byte[] value)\n\t{\n\t\tvar a = IPAddress.HostToNetworkOrder(BitConverter.ToInt32(value, 0));\n\t\tvar b = IPAddress.HostToNetworkOrder(BitConverter.ToInt16(value, 4));\n\t\tvar c = IPAddress.HostToNetworkOrder(BitConverter.ToInt16(value, 6));\n\t\tvar d = new[] { value[8], value[9], value[10], value[11], value[12], value[13], value[14], value[15] };\n\t\treturn new Guid(a, b, c, d);\n\t}\n\n\tpublic static int DecodeInt32(byte[] value)\n\t{\n\t\treturn IPAddress.HostToNetworkOrder(BitConverter.ToInt32(value, 0));\n\t}\n\n\tpublic static long DecodeInt64(byte[] value)\n\t{\n\t\treturn IPAddress.HostToNetworkOrder(BitConverter.ToInt64(value, 0));\n\t}\n\n\tpublic static FbDecFloat DecodeDec16(byte[] value)\n\t{\n\t\tif (BitConverter.IsLittleEndian)\n\t\t{\n\t\t\tArray.Reverse(value);\n\t\t}\n\t\treturn DecimalCodec.DecFloat16.ParseBytes(value);\n\t}\n\n\tpublic static FbDecFloat DecodeDec34(byte[] value)\n\t{\n\t\tif (BitConverter.IsLittleEndian)\n\t\t{\n\t\t\tArray.Reverse(value);\n\t\t}\n\t\treturn DecimalCodec.DecFloat34.ParseBytes(value);\n\t}\n\n\tpublic static BigInteger DecodeInt128(byte[] value)\n\t{\n\t\tif (BitConverter.IsLittleEndian)\n\t\t{\n\t\t\tArray.Reverse(value);\n\t\t}\n\t\treturn Int128Helper.GetInt128(value);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/TypeEncoder.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Globalization;\nusing System.Net;\nusing System.Numerics;\nusing FirebirdSql.Data.Types;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class TypeEncoder\n{\n\tpublic static object EncodeDecimal(decimal d, int scale, int type)\n\t{\n\t\tvar shift = scale < 0 ? -scale : scale;\n\n\t\tswitch (type & ~1)\n\t\t{\n\t\t\tcase IscCodes.SQL_SHORT:\n\t\t\t\treturn (short)DecimalShiftHelper.ShiftDecimalRight(d, shift);\n\n\t\t\tcase IscCodes.SQL_LONG:\n\t\t\t\treturn (int)DecimalShiftHelper.ShiftDecimalRight(d, shift);\n\n\t\t\tcase IscCodes.SQL_QUAD:\n\t\t\tcase IscCodes.SQL_INT64:\n\t\t\t\treturn (long)DecimalShiftHelper.ShiftDecimalRight(d, shift);\n\n\t\t\tcase IscCodes.SQL_DOUBLE:\n\t\t\tcase IscCodes.SQL_D_FLOAT:\n\t\t\t\treturn (double)d;\n\n\t\t\tcase IscCodes.SQL_INT128:\n\t\t\t\treturn (BigInteger)DecimalShiftHelper.ShiftDecimalRight(d, shift);\n\n\t\t\tdefault:\n\t\t\t\tthrow new ArgumentOutOfRangeException(nameof(type), $\"{nameof(type)}={type}\");\n\t\t}\n\t}\n\n\tpublic static int EncodeTime(TimeSpan t)\n\t{\n\t\treturn (int)(t.Ticks / 1000L);\n\t}\n\tpublic static int EncodeTime(TimeOnly t)\n\t{\n\t\treturn (int)(t.Ticks / 1000L);\n\t}\n\n\tpublic static int EncodeDate(DateTime d)\n\t{\n\t\tvar calendar = new GregorianCalendar();\n\t\tvar day = calendar.GetDayOfMonth(d);\n\t\tvar month = calendar.GetMonth(d);\n\t\tvar year = calendar.GetYear(d);\n\t\treturn EncodeDateImpl(year, month, day);\n\t}\n\tpublic static int EncodeDate(DateOnly d)\n\t{\n\t\treturn EncodeDateImpl(d.Year, d.Month, d.Day);\n\t}\n\tstatic int EncodeDateImpl(int year, int month, int day)\n\t{\n\t\tif (month > 2)\n\t\t{\n\t\t\tmonth -= 3;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tmonth += 9;\n\t\t\tyear -= 1;\n\t\t}\n\n\t\tvar c = year / 100;\n\t\tvar ya = year - 100 * c;\n\n\t\treturn ((146097 * c) / 4 + (1461 * ya) / 4 + (153 * month + 2) / 5 + day + 1721119 - 2400001);\n\t}\n\n\tpublic static byte[] EncodeBoolean(bool value)\n\t{\n\t\treturn new[] { (byte)(value ? 1 : 0) };\n\t}\n\n\tpublic static byte[] EncodeGuid(Guid value)\n\t{\n\t\tvar data = value.ToByteArray();\n\t\tvar a = BitConverter.GetBytes(IPAddress.NetworkToHostOrder(BitConverter.ToInt32(data, 0)));\n\t\tvar b = BitConverter.GetBytes(IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, 4)));\n\t\tvar c = BitConverter.GetBytes(IPAddress.NetworkToHostOrder(BitConverter.ToInt16(data, 6)));\n\t\treturn new[]\n\t\t{\n\t\t\ta[0], a[1], a[2], a[3],\n\t\t\tb[0], b[1],\n\t\t\tc[0], c[1],\n\t\t\tdata[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15]\n\t\t};\n\t}\n\n\tpublic static byte[] EncodeInt32(int value)\n\t{\n\t\treturn BitConverter.GetBytes(IPAddress.NetworkToHostOrder(value));\n\t}\n\n\tpublic static byte[] EncodeInt64(long value)\n\t{\n\t\treturn BitConverter.GetBytes(IPAddress.NetworkToHostOrder(value));\n\t}\n\n\tpublic static byte[] EncodeDec16(FbDecFloat value)\n\t{\n\t\tvar result = DecimalCodec.DecFloat16.EncodeDecimal(value);\n\t\tif (BitConverter.IsLittleEndian)\n\t\t{\n\t\t\tArray.Reverse(result);\n\t\t}\n\t\treturn result;\n\t}\n\n\tpublic static byte[] EncodeDec34(FbDecFloat value)\n\t{\n\t\tvar result = DecimalCodec.DecFloat34.EncodeDecimal(value);\n\t\tif (BitConverter.IsLittleEndian)\n\t\t{\n\t\t\tArray.Reverse(result);\n\t\t}\n\t\treturn result;\n\t}\n\n\tpublic static byte[] EncodeInt128(BigInteger value)\n\t{\n\t\tvar result = Int128Helper.GetBytes(value);\n\t\tif (BitConverter.IsLittleEndian)\n\t\t{\n\t\t\tArray.Reverse(result);\n\t\t}\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Common/TypeHelper.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing FirebirdSql.Data.FirebirdClient;\nusing FirebirdSql.Data.Types;\n\nnamespace FirebirdSql.Data.Common;\n\ninternal static class TypeHelper\n{\n\tpublic static bool IsDBNull(object value)\n\t{\n\t\treturn value == null || value == DBNull.Value;\n\t}\n\n\tpublic static short? GetSize(DbDataType type)\n\t{\n\t\tswitch (type)\n\t\t{\n\t\t\tcase DbDataType.Array:\n\t\t\tcase DbDataType.Binary:\n\t\t\tcase DbDataType.Text:\n\t\t\t\treturn 8;\n\n\t\t\tcase DbDataType.SmallInt:\n\t\t\t\treturn 2;\n\n\t\t\tcase DbDataType.Integer:\n\t\t\tcase DbDataType.Float:\n\t\t\tcase DbDataType.Date:\n\t\t\tcase DbDataType.Time:\n\t\t\t\treturn 4;\n\n\t\t\tcase DbDataType.BigInt:\n\t\t\tcase DbDataType.Double:\n\t\t\tcase DbDataType.TimeStamp:\n\t\t\tcase DbDataType.Dec16:\n\t\t\tcase DbDataType.TimeTZ:\n\t\t\t\treturn 8;\n\n\t\t\tcase DbDataType.Guid:\n\t\t\tcase DbDataType.TimeStampTZEx:\n\t\t\tcase DbDataType.Dec34:\n\t\t\tcase DbDataType.Int128:\n\t\t\t\treturn 16;\n\n\t\t\tcase DbDataType.Boolean:\n\t\t\t\treturn 1;\n\n\t\t\tcase DbDataType.TimeStampTZ:\n\t\t\tcase DbDataType.TimeTZEx:\n\t\t\t\treturn 12;\n\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t}\n\t}\n\n\tpublic static int GetSqlTypeFromDbDataType(DbDataType type, bool isNullable)\n\t{\n\t\tvar sqltype = 0;\n\n\t\tswitch (type)\n\t\t{\n\t\t\tcase DbDataType.Array:\n\t\t\t\tsqltype = IscCodes.SQL_ARRAY;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.Binary:\n\t\t\tcase DbDataType.Text:\n\t\t\t\tsqltype = IscCodes.SQL_BLOB;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.Char:\n\t\t\t\tsqltype = IscCodes.SQL_TEXT;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.VarChar:\n\t\t\t\tsqltype = IscCodes.SQL_VARYING;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.SmallInt:\n\t\t\t\tsqltype = IscCodes.SQL_SHORT;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.Integer:\n\t\t\t\tsqltype = IscCodes.SQL_LONG;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.BigInt:\n\t\t\t\tsqltype = IscCodes.SQL_INT64;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.Float:\n\t\t\t\tsqltype = IscCodes.SQL_FLOAT;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.Guid:\n\t\t\t\tsqltype = IscCodes.SQL_TEXT;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.Double:\n\t\t\t\tsqltype = IscCodes.SQL_DOUBLE;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.Date:\n\t\t\t\tsqltype = IscCodes.SQL_TYPE_DATE;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.Time:\n\t\t\t\tsqltype = IscCodes.SQL_TYPE_TIME;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\tsqltype = IscCodes.SQL_TIMESTAMP;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.Boolean:\n\t\t\t\tsqltype = IscCodes.SQL_BOOLEAN;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.TimeStampTZ:\n\t\t\t\tsqltype = IscCodes.SQL_TIMESTAMP_TZ;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.TimeStampTZEx:\n\t\t\t\tsqltype = IscCodes.SQL_TIMESTAMP_TZ_EX;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.TimeTZ:\n\t\t\t\tsqltype = IscCodes.SQL_TIME_TZ;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.TimeTZEx:\n\t\t\t\tsqltype = IscCodes.SQL_TIME_TZ_EX;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.Dec16:\n\t\t\t\tsqltype = IscCodes.SQL_DEC16;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.Dec34:\n\t\t\t\tsqltype = IscCodes.SQL_DEC34;\n\t\t\t\tbreak;\n\n\t\t\tcase DbDataType.Int128:\n\t\t\t\tsqltype = IscCodes.SQL_INT128;\n\t\t\t\tbreak;\n\n\n\t\t\tdefault:\n\t\t\t\tthrow InvalidDataType((int)type);\n\t\t}\n\n\t\tif (isNullable)\n\t\t{\n\t\t\tsqltype++;\n\t\t}\n\n\t\treturn sqltype;\n\t}\n\n\tpublic static int GetSqlTypeFromBlrType(int type)\n\t{\n\t\tswitch (type)\n\t\t{\n\t\t\tcase IscCodes.blr_varying:\n\t\t\tcase IscCodes.blr_varying2:\n\t\t\t\treturn IscCodes.SQL_VARYING;\n\n\t\t\tcase IscCodes.blr_text:\n\t\t\tcase IscCodes.blr_text2:\n\t\t\tcase IscCodes.blr_cstring:\n\t\t\tcase IscCodes.blr_cstring2:\n\t\t\t\treturn IscCodes.SQL_TEXT;\n\n\t\t\tcase IscCodes.blr_short:\n\t\t\t\treturn IscCodes.SQL_SHORT;\n\n\t\t\tcase IscCodes.blr_long:\n\t\t\t\treturn IscCodes.SQL_LONG;\n\n\t\t\tcase IscCodes.blr_quad:\n\t\t\t\treturn IscCodes.SQL_QUAD;\n\n\t\t\tcase IscCodes.blr_int64:\n\t\t\tcase IscCodes.blr_blob_id:\n\t\t\t\treturn IscCodes.SQL_INT64;\n\n\t\t\tcase IscCodes.blr_double:\n\t\t\t\treturn IscCodes.SQL_DOUBLE;\n\n\t\t\tcase IscCodes.blr_d_float:\n\t\t\t\treturn IscCodes.SQL_D_FLOAT;\n\n\t\t\tcase IscCodes.blr_float:\n\t\t\t\treturn IscCodes.SQL_FLOAT;\n\n\t\t\tcase IscCodes.blr_sql_date:\n\t\t\t\treturn IscCodes.SQL_TYPE_DATE;\n\n\t\t\tcase IscCodes.blr_sql_time:\n\t\t\t\treturn IscCodes.SQL_TYPE_TIME;\n\n\t\t\tcase IscCodes.blr_timestamp:\n\t\t\t\treturn IscCodes.SQL_TIMESTAMP;\n\n\t\t\tcase IscCodes.blr_blob:\n\t\t\t\treturn IscCodes.SQL_BLOB;\n\n\t\t\tcase IscCodes.blr_bool:\n\t\t\t\treturn IscCodes.SQL_BOOLEAN;\n\n\t\t\tcase IscCodes.blr_ex_timestamp_tz:\n\t\t\t\treturn IscCodes.SQL_TIMESTAMP_TZ_EX;\n\n\t\t\tcase IscCodes.blr_timestamp_tz:\n\t\t\t\treturn IscCodes.SQL_TIMESTAMP_TZ;\n\n\t\t\tcase IscCodes.blr_sql_time_tz:\n\t\t\t\treturn IscCodes.SQL_TIME_TZ;\n\n\t\t\tcase IscCodes.blr_ex_time_tz:\n\t\t\t\treturn IscCodes.SQL_TIME_TZ_EX;\n\n\t\t\tcase IscCodes.blr_dec64:\n\t\t\t\treturn IscCodes.SQL_DEC16;\n\n\t\t\tcase IscCodes.blr_dec128:\n\t\t\t\treturn IscCodes.SQL_DEC34;\n\n\t\t\tcase IscCodes.blr_int128:\n\t\t\t\treturn IscCodes.SQL_INT128;\n\n\t\t\tdefault:\n\t\t\t\tthrow InvalidDataType(type);\n\t\t}\n\t}\n\n\tpublic static string GetDataTypeName(DbDataType type)\n\t{\n\t\tswitch (type)\n\t\t{\n\t\t\tcase DbDataType.Array:\n\t\t\t\treturn \"ARRAY\";\n\n\t\t\tcase DbDataType.Binary:\n\t\t\t\treturn \"BLOB\";\n\n\t\t\tcase DbDataType.Text:\n\t\t\t\treturn \"BLOB SUB_TYPE 1\";\n\n\t\t\tcase DbDataType.Char:\n\t\t\tcase DbDataType.Guid:\n\t\t\t\treturn \"CHAR\";\n\n\t\t\tcase DbDataType.VarChar:\n\t\t\t\treturn \"VARCHAR\";\n\n\t\t\tcase DbDataType.SmallInt:\n\t\t\t\treturn \"SMALLINT\";\n\n\t\t\tcase DbDataType.Integer:\n\t\t\t\treturn \"INTEGER\";\n\n\t\t\tcase DbDataType.Float:\n\t\t\t\treturn \"FLOAT\";\n\n\t\t\tcase DbDataType.Double:\n\t\t\t\treturn \"DOUBLE PRECISION\";\n\n\t\t\tcase DbDataType.BigInt:\n\t\t\t\treturn \"BIGINT\";\n\n\t\t\tcase DbDataType.Numeric:\n\t\t\t\treturn \"NUMERIC\";\n\n\t\t\tcase DbDataType.Decimal:\n\t\t\t\treturn \"DECIMAL\";\n\n\t\t\tcase DbDataType.Date:\n\t\t\t\treturn \"DATE\";\n\n\t\t\tcase DbDataType.Time:\n\t\t\t\treturn \"TIME\";\n\n\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\treturn \"TIMESTAMP\";\n\n\t\t\tcase DbDataType.Boolean:\n\t\t\t\treturn \"BOOLEAN\";\n\n\t\t\tcase DbDataType.TimeStampTZ:\n\t\t\tcase DbDataType.TimeStampTZEx:\n\t\t\t\treturn \"TIMESTAMP WITH TIME ZONE\";\n\n\t\t\tcase DbDataType.TimeTZ:\n\t\t\tcase DbDataType.TimeTZEx:\n\t\t\t\treturn \"TIME WITH TIME ZONE\";\n\n\t\t\tcase DbDataType.Dec16:\n\t\t\tcase DbDataType.Dec34:\n\t\t\t\treturn \"DECFLOAT\";\n\n\t\t\tcase DbDataType.Int128:\n\t\t\t\treturn \"INT128\";\n\n\t\t\tdefault:\n\t\t\t\tthrow InvalidDataType((int)type);\n\t\t}\n\t}\n\n\tpublic static Type GetTypeFromDbDataType(DbDataType type)\n\t{\n\t\tswitch (type)\n\t\t{\n\t\t\tcase DbDataType.Array:\n\t\t\t\treturn typeof(System.Array);\n\n\t\t\tcase DbDataType.Binary:\n\t\t\t\treturn typeof(System.Byte[]);\n\n\t\t\tcase DbDataType.Text:\n\t\t\tcase DbDataType.Char:\n\t\t\tcase DbDataType.VarChar:\n\t\t\t\treturn typeof(System.String);\n\n\t\t\tcase DbDataType.Guid:\n\t\t\t\treturn typeof(System.Guid);\n\n\t\t\tcase DbDataType.SmallInt:\n\t\t\t\treturn typeof(System.Int16);\n\n\t\t\tcase DbDataType.Integer:\n\t\t\t\treturn typeof(System.Int32);\n\n\t\t\tcase DbDataType.BigInt:\n\t\t\t\treturn typeof(System.Int64);\n\n\t\t\tcase DbDataType.Float:\n\t\t\t\treturn typeof(System.Single);\n\n\t\t\tcase DbDataType.Double:\n\t\t\t\treturn typeof(System.Double);\n\n\t\t\tcase DbDataType.Numeric:\n\t\t\tcase DbDataType.Decimal:\n\t\t\t\treturn typeof(System.Decimal);\n\n\t\t\tcase DbDataType.Date:\n\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\treturn typeof(System.DateTime);\n\n\t\t\tcase DbDataType.Time:\n\t\t\t\treturn typeof(System.TimeSpan);\n\n\t\t\tcase DbDataType.Boolean:\n\t\t\t\treturn typeof(System.Boolean);\n\n\t\t\tcase DbDataType.TimeStampTZ:\n\t\t\tcase DbDataType.TimeStampTZEx:\n\t\t\t\treturn typeof(FbZonedDateTime);\n\n\t\t\tcase DbDataType.TimeTZ:\n\t\t\tcase DbDataType.TimeTZEx:\n\t\t\t\treturn typeof(FbZonedTime);\n\n\t\t\tcase DbDataType.Dec16:\n\t\t\tcase DbDataType.Dec34:\n\t\t\t\treturn typeof(FbDecFloat);\n\n\t\t\tcase DbDataType.Int128:\n\t\t\t\treturn typeof(System.Numerics.BigInteger);\n\n\t\t\tdefault:\n\t\t\t\tthrow InvalidDataType((int)type);\n\t\t}\n\t}\n\n\tpublic static FbDbType GetFbDataTypeFromType(Type type)\n\t{\n\t\tif (type.IsEnum)\n\t\t{\n\t\t\treturn GetFbDataTypeFromType(Enum.GetUnderlyingType(type));\n\t\t}\n\n\t\tif (type == typeof(System.DBNull))\n\t\t{\n\t\t\treturn FbDbType.VarChar;\n\t\t}\n\n\t\tif (type == typeof(System.String))\n\t\t{\n\t\t\treturn FbDbType.VarChar;\n\t\t}\n\t\telse if (type == typeof(System.Char))\n\t\t{\n\t\t\treturn FbDbType.Char;\n\t\t}\n\t\telse if (type == typeof(System.Boolean))\n\t\t{\n\t\t\treturn FbDbType.Boolean;\n\t\t}\n\t\telse if (type == typeof(System.Byte) || type == typeof(System.SByte) || type == typeof(System.Int16) || type == typeof(System.UInt16))\n\t\t{\n\t\t\treturn FbDbType.SmallInt;\n\t\t}\n\t\telse if (type == typeof(System.Int32) || type == typeof(System.UInt32))\n\t\t{\n\t\t\treturn FbDbType.Integer;\n\t\t}\n\t\telse if (type == typeof(System.Int64) || type == typeof(System.UInt64))\n\t\t{\n\t\t\treturn FbDbType.BigInt;\n\t\t}\n\t\telse if (type == typeof(System.Single))\n\t\t{\n\t\t\treturn FbDbType.Float;\n\t\t}\n\t\telse if (type == typeof(System.Double))\n\t\t{\n\t\t\treturn FbDbType.Double;\n\t\t}\n\t\telse if (type == typeof(System.Decimal))\n\t\t{\n\t\t\treturn FbDbType.Decimal;\n\t\t}\n\t\telse if (type == typeof(System.DateTime))\n\t\t{\n\t\t\treturn FbDbType.TimeStamp;\n\t\t}\n\t\telse if (type == typeof(System.TimeSpan))\n\t\t{\n\t\t\treturn FbDbType.Time;\n\t\t}\n\t\telse if (type == typeof(System.Guid))\n\t\t{\n\t\t\treturn FbDbType.Guid;\n\t\t}\n\t\telse if (type == typeof(FbZonedDateTime))\n\t\t{\n\t\t\treturn FbDbType.TimeStampTZ;\n\t\t}\n\t\telse if (type == typeof(FbZonedTime))\n\t\t{\n\t\t\treturn FbDbType.TimeTZ;\n\t\t}\n\t\telse if (type == typeof(FbDecFloat))\n\t\t{\n\t\t\treturn FbDbType.Dec34;\n\t\t}\n\t\telse if (type == typeof(System.Numerics.BigInteger))\n\t\t{\n\t\t\treturn FbDbType.Int128;\n\t\t}\n\t\telse if (type == typeof(System.Byte[]))\n\t\t{\n\t\t\treturn FbDbType.Binary;\n\t\t}\n\t\telse if (type == typeof(System.DateOnly))\n\t\t{\n\t\t\treturn FbDbType.Date;\n\t\t}\n\t\telse if (type == typeof(System.TimeOnly))\n\t\t{\n\t\t\treturn FbDbType.Time;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tthrow new ArgumentException($\"Unknown type: {type}.\");\n\t\t}\n\t}\n\n\tpublic static Type GetTypeFromBlrType(int type, int subType, int scale)\n\t{\n\t\treturn GetTypeFromDbDataType(GetDbDataTypeFromBlrType(type, subType, scale));\n\t}\n\n\tpublic static DbType GetDbTypeFromDbDataType(DbDataType type)\n\t{\n\t\tswitch (type)\n\t\t{\n\t\t\tcase DbDataType.Array:\n\t\t\tcase DbDataType.Binary:\n\t\t\t\treturn DbType.Binary;\n\n\t\t\tcase DbDataType.Text:\n\t\t\tcase DbDataType.VarChar:\n\t\t\tcase DbDataType.Char:\n\t\t\t\treturn DbType.String;\n\n\t\t\tcase DbDataType.SmallInt:\n\t\t\t\treturn DbType.Int16;\n\n\t\t\tcase DbDataType.Integer:\n\t\t\t\treturn DbType.Int32;\n\n\t\t\tcase DbDataType.BigInt:\n\t\t\t\treturn DbType.Int64;\n\n\t\t\tcase DbDataType.Date:\n\t\t\t\treturn DbType.Date;\n\n\t\t\tcase DbDataType.Time:\n\t\t\t\treturn DbType.Time;\n\n\t\t\tcase DbDataType.TimeStamp:\n\t\t\t\treturn DbType.DateTime;\n\n\t\t\tcase DbDataType.Numeric:\n\t\t\tcase DbDataType.Decimal:\n\t\t\t\treturn DbType.Decimal;\n\n\t\t\tcase DbDataType.Float:\n\t\t\t\treturn DbType.Single;\n\n\t\t\tcase DbDataType.Double:\n\t\t\t\treturn DbType.Double;\n\n\t\t\tcase DbDataType.Guid:\n\t\t\t\treturn DbType.Guid;\n\n\t\t\tcase DbDataType.Boolean:\n\t\t\t\treturn DbType.Boolean;\n\n\t\t\tcase DbDataType.TimeStampTZ:\n\t\t\tcase DbDataType.TimeStampTZEx:\n\t\t\tcase DbDataType.TimeTZ:\n\t\t\tcase DbDataType.TimeTZEx:\n\t\t\tcase DbDataType.Dec16:\n\t\t\tcase DbDataType.Dec34:\n\t\t\tcase DbDataType.Int128:\n\t\t\t\t// nothing better at the moment\n\t\t\t\treturn DbType.Object;\n\n\t\t\tdefault:\n\t\t\t\tthrow InvalidDataType((int)type);\n\t\t}\n\t}\n\n\tpublic static DbDataType GetDbDataTypeFromDbType(DbType type)\n\t{\n\t\tswitch (type)\n\t\t{\n\t\t\tcase DbType.String:\n\t\t\tcase DbType.AnsiString:\n\t\t\t\treturn DbDataType.VarChar;\n\n\t\t\tcase DbType.StringFixedLength:\n\t\t\tcase DbType.AnsiStringFixedLength:\n\t\t\t\treturn DbDataType.Char;\n\n\t\t\tcase DbType.Byte:\n\t\t\tcase DbType.SByte:\n\t\t\tcase DbType.Int16:\n\t\t\tcase DbType.UInt16:\n\t\t\t\treturn DbDataType.SmallInt;\n\n\t\t\tcase DbType.Int32:\n\t\t\tcase DbType.UInt32:\n\t\t\t\treturn DbDataType.Integer;\n\n\t\t\tcase DbType.Int64:\n\t\t\tcase DbType.UInt64:\n\t\t\t\treturn DbDataType.BigInt;\n\n\t\t\tcase DbType.Date:\n\t\t\t\treturn DbDataType.Date;\n\n\t\t\tcase DbType.Time:\n\t\t\t\treturn DbDataType.Time;\n\n\t\t\tcase DbType.DateTime:\n\t\t\t\treturn DbDataType.TimeStamp;\n\n\t\t\tcase DbType.Object:\n\t\t\tcase DbType.Binary:\n\t\t\t\treturn DbDataType.Binary;\n\n\t\t\tcase DbType.Decimal:\n\t\t\t\treturn DbDataType.Decimal;\n\n\t\t\tcase DbType.Double:\n\t\t\t\treturn DbDataType.Double;\n\n\t\t\tcase DbType.Single:\n\t\t\t\treturn DbDataType.Float;\n\n\t\t\tcase DbType.Guid:\n\t\t\t\treturn DbDataType.Guid;\n\n\t\t\tcase DbType.Boolean:\n\t\t\t\treturn DbDataType.Boolean;\n\n\t\t\tdefault:\n\t\t\t\tthrow InvalidDataType((int)type);\n\t\t}\n\t}\n\n\tpublic static DbDataType GetDbDataTypeFromBlrType(int type, int subType, int scale)\n\t{\n\t\treturn GetDbDataTypeFromSqlType(GetSqlTypeFromBlrType(type), subType, scale);\n\t}\n\n\tpublic static DbDataType GetDbDataTypeFromSqlType(int type, int subType, int scale, int? length = null, Charset charset = null)\n\t{\n\t\t// Special case for Guid handling\n\t\tif ((type == IscCodes.SQL_TEXT || type == IscCodes.SQL_VARYING) && length == 16 && (charset?.IsOctetsCharset ?? false))\n\t\t{\n\t\t\treturn DbDataType.Guid;\n\t\t}\n\n\t\tswitch (type)\n\t\t{\n\t\t\tcase IscCodes.SQL_TEXT:\n\t\t\t\treturn DbDataType.Char;\n\n\t\t\tcase IscCodes.SQL_VARYING:\n\t\t\t\treturn DbDataType.VarChar;\n\n\t\t\tcase IscCodes.SQL_SHORT:\n\t\t\t\tif (subType == 2)\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Decimal;\n\t\t\t\t}\n\t\t\t\telse if (subType == 1)\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Numeric;\n\t\t\t\t}\n\t\t\t\telse if (scale < 0)\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Decimal;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.SmallInt;\n\t\t\t\t}\n\n\t\t\tcase IscCodes.SQL_LONG:\n\t\t\t\tif (subType == 2)\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Decimal;\n\t\t\t\t}\n\t\t\t\telse if (subType == 1)\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Numeric;\n\t\t\t\t}\n\t\t\t\telse if (scale < 0)\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Decimal;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Integer;\n\t\t\t\t}\n\n\t\t\tcase IscCodes.SQL_QUAD:\n\t\t\tcase IscCodes.SQL_INT64:\n\t\t\t\tif (subType == 2)\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Decimal;\n\t\t\t\t}\n\t\t\t\telse if (subType == 1)\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Numeric;\n\t\t\t\t}\n\t\t\t\telse if (scale < 0)\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Decimal;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.BigInt;\n\t\t\t\t}\n\n\t\t\tcase IscCodes.SQL_FLOAT:\n\t\t\t\treturn DbDataType.Float;\n\n\t\t\tcase IscCodes.SQL_DOUBLE:\n\t\t\tcase IscCodes.SQL_D_FLOAT:\n\t\t\t\tif (subType == 2)\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Decimal;\n\t\t\t\t}\n\t\t\t\telse if (subType == 1)\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Numeric;\n\t\t\t\t}\n\t\t\t\telse if (scale < 0)\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Decimal;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Double;\n\t\t\t\t}\n\n\t\t\tcase IscCodes.SQL_BLOB:\n\t\t\t\tif (subType == 1)\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Text;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Binary;\n\t\t\t\t}\n\n\t\t\tcase IscCodes.SQL_TIMESTAMP:\n\t\t\t\treturn DbDataType.TimeStamp;\n\n\t\t\tcase IscCodes.SQL_TYPE_TIME:\n\t\t\t\treturn DbDataType.Time;\n\n\t\t\tcase IscCodes.SQL_TYPE_DATE:\n\t\t\t\treturn DbDataType.Date;\n\n\t\t\tcase IscCodes.SQL_ARRAY:\n\t\t\t\treturn DbDataType.Array;\n\n\t\t\tcase IscCodes.SQL_NULL:\n\t\t\t\treturn DbDataType.Null;\n\n\t\t\tcase IscCodes.SQL_BOOLEAN:\n\t\t\t\treturn DbDataType.Boolean;\n\n\t\t\tcase IscCodes.SQL_TIMESTAMP_TZ:\n\t\t\t\treturn DbDataType.TimeStampTZ;\n\n\t\t\tcase IscCodes.SQL_TIMESTAMP_TZ_EX:\n\t\t\t\treturn DbDataType.TimeStampTZEx;\n\n\t\t\tcase IscCodes.SQL_TIME_TZ:\n\t\t\t\treturn DbDataType.TimeTZ;\n\n\t\t\tcase IscCodes.SQL_TIME_TZ_EX:\n\t\t\t\treturn DbDataType.TimeTZEx;\n\n\t\t\tcase IscCodes.SQL_DEC16:\n\t\t\t\treturn DbDataType.Dec16;\n\n\t\t\tcase IscCodes.SQL_DEC34:\n\t\t\t\treturn DbDataType.Dec34;\n\n\t\t\tcase IscCodes.SQL_INT128:\n\t\t\t\tif (subType == 2)\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Decimal;\n\t\t\t\t}\n\t\t\t\telse if (subType == 1)\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Numeric;\n\t\t\t\t}\n\t\t\t\telse if (scale < 0)\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Decimal;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn DbDataType.Int128;\n\t\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tthrow InvalidDataType(type);\n\t\t}\n\t}\n\n\tpublic static DbDataType GetDbDataTypeFromFbDbType(FbDbType type)\n\t{\n\t\t// these are aligned for this conversion\n\t\treturn (DbDataType)type;\n\t}\n\n\tpublic static TimeSpan DateTimeTimeToTimeSpan(DateTime d)\n\t{\n\t\treturn TimeSpan.FromTicks(d.Subtract(d.Date).Ticks);\n\t}\n\n\tpublic static FbZonedDateTime CreateZonedDateTime(DateTime dateTime, ushort tzId, short? offset)\n\t{\n\t\tif (!TimeZoneMapping.TryGetById(tzId, out var tz))\n\t\t{\n\t\t\tthrow new ArgumentException(\"Unknown time zone ID.\");\n\t\t}\n\t\treturn new FbZonedDateTime(dateTime, tz, offset != null ? TimeSpan.FromMinutes((short)offset) : (TimeSpan?)null);\n\t}\n\n\tpublic static FbZonedTime CreateZonedTime(TimeSpan time, ushort tzId, short? offset)\n\t{\n\t\tif (!TimeZoneMapping.TryGetById(tzId, out var tz))\n\t\t{\n\t\t\tthrow new ArgumentException(\"Unknown time zone ID.\");\n\t\t}\n\t\treturn new FbZonedTime(time, tz, offset != null ? TimeSpan.FromMinutes((short)offset) : (TimeSpan?)null);\n\t}\n\n\tpublic static Exception InvalidDataType(int type)\n\t{\n\t\treturn new ArgumentException($\"Invalid data type: {type}.\");\n\t}\n\n\tpublic static int BlrAlign(int current, int alignment)\n\t{\n\t\treturn (current + alignment - 1) & ~(alignment - 1);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbBatchCommand.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.Logging;\nusing Microsoft.Extensions.Logging;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic sealed class FbBatchCommand : IFbPreparedCommand, IDescriptorFiller, IDisposable, IAsyncDisposable\n{\n\tstatic readonly ILogger<FbBatchCommand> Log = FbLogManager.CreateLogger<FbBatchCommand>();\n\n\tprivate const int DefaultBatchBufferSize = 16 * 1024 * 1024;\n\n\t#region Fields\n\n\tprivate FbConnection _connection;\n\tprivate FbTransaction _transaction;\n\tprivate FbBatchParameterCollection _batchParameters;\n\tprivate StatementBase _statement;\n\tprivate BatchBase _batch;\n\t//private FbDataReader _activeReader;\n\tprivate IReadOnlyList<string> _namedParameters;\n\tprivate string _commandText;\n\tprivate bool _disposed;\n\tprivate bool _implicitTransaction;\n\t//private int? _commandTimeout;\n\t//private int _fetchSize;\n\tprivate bool _multiError;\n\tprivate int _batchBufferSize;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic string CommandText\n\t{\n\t\tget { return _commandText; }\n\t\tset\n\t\t{\n\t\t\tif (_commandText != value && _statement != null)\n\t\t\t{\n\t\t\t\tRelease();\n\t\t\t}\n\n\t\t\t_commandText = value;\n\t\t}\n\t}\n\n\t//[Category(\"Behavior\")]\n\t//[DefaultValue(ConnectionString.DefaultValueCommandTimeout)]\n\t//public int CommandTimeout\n\t//{\n\t//\tget\n\t//\t{\n\t//\t\tif (_commandTimeout != null)\n\t//\t\t\treturn (int)_commandTimeout;\n\t//\t\tif (_connection?.CommandTimeout >= 0)\n\t//\t\t\treturn (int)_connection?.CommandTimeout;\n\t//\t\treturn ConnectionString.DefaultValueCommandTimeout;\n\t//\t}\n\t//\tset\n\t//\t{\n\t//\t\tif (value < 0)\n\t//\t\t{\n\t//\t\t\tthrow new ArgumentException(\"The property value assigned is less than 0.\");\n\t//\t\t}\n\n\t//\t\t_commandTimeout = value;\n\t//\t}\n\t//}\n\n\tpublic FbConnection Connection\n\t{\n\t\tget { return _connection; }\n\t\tset\n\t\t{\n\t\t\t//if (_activeReader != null)\n\t\t\t//{\n\t\t\t//\tthrow new InvalidOperationException(\"There is already an open DataReader associated with this Command which must be closed first.\");\n\t\t\t//}\n\n\t\t\tif (_transaction != null && _transaction.IsCompleted)\n\t\t\t{\n\t\t\t\t_transaction = null;\n\t\t\t}\n\n\t\t\tif (_connection != null &&\n\t\t\t\t_connection != value &&\n\t\t\t\t_connection.State == ConnectionState.Open)\n\t\t\t{\n\t\t\t\tRelease();\n\t\t\t}\n\n\t\t\t_connection = value;\n\t\t}\n\t}\n\n\tpublic FbBatchParameterCollection BatchParameters\n\t{\n\t\tget\n\t\t{\n\t\t\tif (_batchParameters == null)\n\t\t\t{\n\t\t\t\t_batchParameters = new FbBatchParameterCollection();\n\t\t\t}\n\t\t\treturn _batchParameters;\n\t\t}\n\t}\n\n\tpublic FbTransaction Transaction\n\t{\n\t\tget { return _implicitTransaction ? null : _transaction; }\n\t\tset\n\t\t{\n\t\t\t//if (_activeReader != null)\n\t\t\t//{\n\t\t\t//\tthrow new InvalidOperationException(\"There is already an open DataReader associated with this Command which must be closed first.\");\n\t\t\t//}\n\n\t\t\tRollbackImplicitTransaction();\n\n\t\t\t_transaction = value;\n\n\t\t\tif (_statement != null)\n\t\t\t{\n\t\t\t\tif (_transaction != null)\n\t\t\t\t{\n\t\t\t\t\t_statement.Transaction = _transaction.Transaction;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t_statement.Transaction = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t//public int FetchSize\n\t//{\n\t//\tget { return _fetchSize; }\n\t//\tset\n\t//\t{\n\t//\t\tif (_activeReader != null)\n\t//\t\t{\n\t//\t\t\tthrow new InvalidOperationException(\"There is already an open DataReader associated with this Command which must be closed first.\");\n\t//\t\t}\n\t//\t\t_fetchSize = value;\n\t//\t}\n\t//}\n\n\tpublic bool MultiError\n\t{\n\t\tget { return _multiError; }\n\t\tset { _multiError = value; }\n\t}\n\n\tpublic int BatchBufferSize\n\t{\n\t\tget { return _batchBufferSize; }\n\t\tset\n\t\t{\n\t\t\tif (!SizeHelper.IsValidBatchBufferSize(value))\n\t\t\t\tthrow SizeHelper.InvalidSizeException(\"batch buffer\");\n\n\t\t\t_batchBufferSize = value;\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Gets collection of parameters parsed from the query text during command prepare.\n\t/// </summary>\n\t[Browsable(false)]\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\tpublic IReadOnlyList<string> NamedParameters\n\t{\n\t\tget { return _namedParameters; }\n\t}\n\n\t#endregion\n\n\t#region Internal Properties\n\n\tinternal bool IsDisposed\n\t{\n\t\tget { return _disposed; }\n\t}\n\n\t//internal FbDataReader ActiveReader\n\t//{\n\t//\tget { return _activeReader; }\n\t//\tset { _activeReader = value; }\n\t//}\n\n\tinternal FbTransaction ActiveTransaction\n\t{\n\t\tget { return _transaction; }\n\t}\n\n\tinternal bool HasImplicitTransaction\n\t{\n\t\tget { return _implicitTransaction; }\n\t}\n\n\t//internal bool HasFields\n\t//{\n\t//\tget { return _statement?.Fields?.Count > 0; }\n\t//}\n\n\tinternal bool HasParameters\n\t{\n\t\tget { return _batchParameters != null && _batchParameters.Count > 0 && _batchParameters[0].Count > 0; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FbBatchCommand()\n\t\t: this(null, null, null)\n\t{ }\n\n\tpublic FbBatchCommand(string cmdText)\n\t\t: this(cmdText, null, null)\n\t{ }\n\n\tpublic FbBatchCommand(string cmdText, FbConnection connection)\n\t\t: this(cmdText, connection, null)\n\t{ }\n\n\tpublic FbBatchCommand(string cmdText, FbConnection connection, FbTransaction transaction)\n\t{\n\t\t_namedParameters = Array.Empty<string>();\n\t\t//_commandTimeout = null;\n\t\t//_fetchSize = 200;\n\t\t_multiError = false;\n\t\t_batchBufferSize = DefaultBatchBufferSize;\n\t\t_commandText = string.Empty;\n\n\t\tif (connection != null)\n\t\t{\n\t\t\t//_fetchSize = connection.ConnectionOptions.FetchSize;\n\t\t}\n\n\t\tif (cmdText != null)\n\t\t{\n\t\t\tCommandText = cmdText;\n\t\t}\n\n\t\tConnection = connection;\n\t\t_transaction = transaction;\n\t}\n\n\t#endregion\n\n\t#region IDisposable, IAsyncDisposable methods\n\n\tpublic void Dispose()\n\t{\n\t\tif (!_disposed)\n\t\t{\n\t\t\t_disposed = true;\n\t\t\ttry\n\t\t\t{\n\t\t\t\tRelease();\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t\t_batchBufferSize = DefaultBatchBufferSize;\n\t\t\t_multiError = false;\n\t\t\t//_commandTimeout = null;\n\t\t\t//_fetchSize = 0;\n\t\t\t_implicitTransaction = false;\n\t\t\t_commandText = null;\n\t\t\t_connection = null;\n\t\t\t_transaction = null;\n\t\t\t_batchParameters = null;\n\t\t\t_batch = null;\n\t\t\t_statement = null;\n\t\t\t//_activeReader = null;\n\t\t\t_namedParameters = null;\n\t\t}\n\t}\n\tpublic async ValueTask DisposeAsync()\n\t{\n\t\tif (!_disposed)\n\t\t{\n\t\t\t_disposed = true;\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait ReleaseAsync().ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t\t_batchBufferSize = DefaultBatchBufferSize;\n\t\t\t_multiError = false;\n\t\t\t//_commandTimeout = 0;\n\t\t\t//_fetchSize = 0;\n\t\t\t_implicitTransaction = false;\n\t\t\t_commandText = null;\n\t\t\t_connection = null;\n\t\t\t_transaction = null;\n\t\t\t_batchParameters = null;\n\t\t\t_batch = null;\n\t\t\t_statement = null;\n\t\t\t//_activeReader = null;\n\t\t\t_namedParameters = null;\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic void Cancel()\n\t{\n\t\t_connection.CancelCommand();\n\t}\n\n\tpublic FbParameter CreateParameter()\n\t{\n\t\treturn new FbParameter();\n\t}\n\n\tpublic FbParameterCollection AddBatchParameters()\n\t{\n\t\tvar result = new FbParameterCollection();\n\t\tBatchParameters.Add(result);\n\t\treturn result;\n\t}\n\n\tpublic void Prepare()\n\t{\n\t\tCheckCommand();\n\n\t\tusing (var explicitCancellation = ExplicitCancellation.Enter(CancellationToken.None, Cancel))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tPrepare(false);\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tRollbackImplicitTransaction();\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tRollbackImplicitTransaction();\n\t\t\t\tthrow;\n\t\t\t}\n\t\t}\n\t}\n\tpublic async Task PrepareAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tCheckCommand();\n\n\t\tusing (var explicitCancellation = ExplicitCancellation.Enter(cancellationToken, Cancel))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait PrepareAsync(false, explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tawait RollbackImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tawait RollbackImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\tthrow;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic FbBatchNonQueryResult ExecuteNonQuery()\n\t{\n\t\tCheckCommand();\n\n\t\tFbBatchNonQueryResult result;\n\n\t\tusing (var explicitCancellation = ExplicitCancellation.Enter(CancellationToken.None, Cancel))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tresult = ExecuteCommand(false);\n\n\t\t\t\t//if (_statement.StatementType == DbStatementType.StoredProcedure)\n\t\t\t\t//{\n\t\t\t\t//\tSetOutputParameters();\n\t\t\t\t//}\n\n\t\t\t\tCommitImplicitTransaction();\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tRollbackImplicitTransaction();\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tRollbackImplicitTransaction();\n\t\t\t\tthrow;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\tpublic async Task<FbBatchNonQueryResult> ExecuteNonQueryAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tCheckCommand();\n\n\t\tFbBatchNonQueryResult result;\n\n\t\tusing (var explicitCancellation = ExplicitCancellation.Enter(cancellationToken, Cancel))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tresult = await ExecuteCommandAsync(false, explicitCancellation.CancellationToken).ConfigureAwait(false);\n\n\t\t\t\t//if (_statement.StatementType == DbStatementType.StoredProcedure)\n\t\t\t\t//{\n\t\t\t\t//\tawait SetOutputParametersAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\t//}\n\n\t\t\t\tawait CommitImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tawait RollbackImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tawait RollbackImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\tthrow;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t//public new FbDataReader ExecuteReader() => ExecuteReader(CommandBehavior.Default);\n\t//public new Task<FbDataReader> ExecuteReaderAsync() => ExecuteReaderAsync(CommandBehavior.Default);\n\t//public new Task<FbDataReader> ExecuteReaderAsync(CancellationToken cancellationToken) => ExecuteReaderAsync(CommandBehavior.Default, cancellationToken);\n\n\t//public new FbDataReader ExecuteReader(CommandBehavior behavior)\n\t//{\n\t//\tCheckCommand();\n\n\t//\tusing (var explicitCancellation = ExplicitCancellation.Enter(CancellationToken.None, Cancel))\n\t//\t{\n\t//\t\ttry\n\t//\t\t{\n\t//\t\t\tExecuteCommand(behavior, true);\n\t//\t\t}\n\t//\t\tcatch (IscException ex)\n\t//\t\t{\n\t//\t\t\tRollbackImplicitTransaction();\n\t//\t\t\tthrow FbException.Create(ex);\n\t//\t\t}\n\t//\t\tcatch\n\t//\t\t{\n\t//\t\t\tRollbackImplicitTransaction();\n\t//\t\t\tthrow;\n\t//\t\t}\n\t//\t}\n\n\t//\t_activeReader = new FbDataReader(this, _connection, behavior);\n\t//\treturn _activeReader;\n\t//}\n\t//public new Task<FbDataReader> ExecuteReaderAsync(CommandBehavior behavior) => ExecuteReaderAsync(behavior, CancellationToken.None);\n\t//public new async Task<FbDataReader> ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)\n\t//{\n\t//\tCheckCommand();\n\n\t//\tusing (var explicitCancellation = ExplicitCancellation.Enter(cancellationToken, Cancel))\n\t//\t{\n\t//\t\ttry\n\t//\t\t{\n\t//\t\t\tawait ExecuteCommandAsync(behavior, true, explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t//\t\t}\n\t//\t\tcatch (IscException ex)\n\t//\t\t{\n\t//\t\t\tawait RollbackImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t//\t\t\tthrow FbException.Create(ex);\n\t//\t\t}\n\t//\t\tcatch\n\t//\t\t{\n\t//\t\t\tawait RollbackImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t//\t\t\tthrow;\n\t//\t\t}\n\t//\t}\n\n\t//\t_activeReader = new FbDataReader(this, _connection, behavior);\n\t//\treturn _activeReader;\n\t//}\n\n\tpublic string GetCommandPlan()\n\t{\n\t\tif (_statement == null)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\treturn _statement.GetExecutionPlan();\n\t}\n\tpublic Task<string> GetCommandPlanAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_statement == null)\n\t\t{\n\t\t\treturn Task.FromResult<string>(null);\n\t\t}\n\t\treturn _statement.GetExecutionPlanAsync(cancellationToken).AsTask();\n\t}\n\n\tpublic string GetCommandExplainedPlan()\n\t{\n\t\tif (_statement == null)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\treturn _statement.GetExecutionExplainedPlan();\n\t}\n\tpublic Task<string> GetCommandExplainedPlanAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_statement == null)\n\t\t{\n\t\t\treturn Task.FromResult<string>(null);\n\t\t}\n\t\treturn _statement.GetExecutionExplainedPlanAsync(cancellationToken).AsTask();\n\t}\n\n\tpublic int ComputeCurrentBatchSize()\n\t{\n\t\tif (_batch == null)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Batch must be prepared.\");\n\t\t}\n\t\tif (!HasParameters)\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\treturn _batch.ComputeBatchSize(_batchParameters.Count, this);\n\t}\n\tpublic async Task<int> ComputeCurrentBatchSizeAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_batch == null)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Batch must be prepared.\");\n\t\t}\n\t\tif (!HasParameters)\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\treturn await _batch.ComputeBatchSizeAsync(_batchParameters.Count, this, cancellationToken).ConfigureAwait(false);\n\t}\n\n\t#endregion\n\n\t#region Internal Methods\n\n\t//\t\tinternal void DisposeReader()\n\t//\t\t{\n\t//\t\t\tif (_activeReader != null)\n\t//\t\t\t{\n\t//\t\t\t\t_activeReader.Dispose();\n\t//\t\t\t\t_activeReader = null;\n\t//\t\t\t}\n\t//\t\t}\n\t//\t\tinternal async Task DisposeReaderAsync(CancellationToken cancellationToken = default)\n\t//\t\t{\n\t//\t\t\tif (_activeReader != null)\n\t//\t\t\t{\n\t//\t\t\t\tawait _activeReader.DisposeAsync().ConfigureAwait(false);\n\t//\t\t\t\t_activeReader = null;\n\t//\t\t\t}\n\t//\t\t}\n\n\t//internal DbValue[] Fetch()\n\t//{\n\t//\tif (_statement != null)\n\t//\t{\n\t//\t\ttry\n\t//\t\t{\n\t//\t\t\treturn _statement.Fetch();\n\t//\t\t}\n\t//\t\tcatch (IscException ex)\n\t//\t\t{\n\t//\t\t\tthrow FbException.Create(ex);\n\t//\t\t}\n\t//\t}\n\t//\treturn null;\n\t//}\n\t//internal async Task<DbValue[]> FetchAsync(CancellationToken cancellationToken = default)\n\t//{\n\t//\tif (_statement != null)\n\t//\t{\n\t//\t\ttry\n\t//\t\t{\n\t//\t\t\treturn await _statement.FetchAsync(cancellationToken).ConfigureAwait(false);\n\t//\t\t}\n\t//\t\tcatch (IscException ex)\n\t//\t\t{\n\t//\t\t\tthrow FbException.Create(ex);\n\t//\t\t}\n\t//\t}\n\t//\treturn null;\n\t//}\n\n\t//internal Descriptor GetFieldsDescriptor()\n\t//{\n\t//\tif (_statement != null)\n\t//\t{\n\t//\t\treturn _statement.Fields;\n\t//\t}\n\t//\treturn null;\n\t//}\n\n\t//internal void SetOutputParameters()\n\t//{\n\t//\tSetOutputParameters(null);\n\t//}\n\t//internal Task SetOutputParametersAsync(CancellationToken cancellationToken = default)\n\t//{\n\t//\treturn SetOutputParametersAsync(null, cancellationToken);\n\t//}\n\n\t//internal void SetOutputParameters(DbValue[] outputParameterValues)\n\t//{\n\t//\tif (Parameters.Count > 0 && _statement != null)\n\t//\t{\n\t//\t\tif (_statement != null &&\n\t//\t\t\t_statement.StatementType == DbStatementType.StoredProcedure)\n\t//\t\t{\n\t//\t\t\tvar values = outputParameterValues;\n\t//\t\t\tif (outputParameterValues == null)\n\t//\t\t\t{\n\t//\t\t\t\tvalues = _statement.GetOutputParameters();\n\t//\t\t\t}\n\n\t//\t\t\tif (values != null && values.Length > 0)\n\t//\t\t\t{\n\t//\t\t\t\tvar i = 0;\n\t//\t\t\t\tforeach (FbParameter parameter in Parameters)\n\t//\t\t\t\t{\n\t//\t\t\t\t\tif (parameter.Direction == ParameterDirection.Output ||\n\t//\t\t\t\t\t\tparameter.Direction == ParameterDirection.InputOutput ||\n\t//\t\t\t\t\t\tparameter.Direction == ParameterDirection.ReturnValue)\n\t//\t\t\t\t\t{\n\t//\t\t\t\t\t\tparameter.Value = values[i].GetValue();\n\t//\t\t\t\t\t\ti++;\n\t//\t\t\t\t\t}\n\t//\t\t\t\t}\n\t//\t\t\t}\n\t//\t\t}\n\t//\t}\n\t//}\n\t//internal async Task SetOutputParametersAsync(DbValue[] outputParameterValues, CancellationToken cancellationToken = default)\n\t//{\n\t//\tif (Parameters.Count > 0 && _statement != null)\n\t//\t{\n\t//\t\tif (_statement != null &&\n\t//\t\t\t_statement.StatementType == DbStatementType.StoredProcedure)\n\t//\t\t{\n\t//\t\t\tvar values = outputParameterValues;\n\t//\t\t\tif (outputParameterValues == null)\n\t//\t\t\t{\n\t//\t\t\t\tvalues = _statement.GetOutputParameters();\n\t//\t\t\t}\n\n\t//\t\t\tif (values != null && values.Length > 0)\n\t//\t\t\t{\n\t//\t\t\t\tvar i = 0;\n\t//\t\t\t\tforeach (FbParameter parameter in Parameters)\n\t//\t\t\t\t{\n\t//\t\t\t\t\tif (parameter.Direction == ParameterDirection.Output ||\n\t//\t\t\t\t\t\tparameter.Direction == ParameterDirection.InputOutput ||\n\t//\t\t\t\t\t\tparameter.Direction == ParameterDirection.ReturnValue)\n\t//\t\t\t\t\t{\n\t//\t\t\t\t\t\tparameter.Value = await values[i].GetValueAsync(cancellationToken).ConfigureAwait(false);\n\t//\t\t\t\t\t\ti++;\n\t//\t\t\t\t\t}\n\t//\t\t\t\t}\n\t//\t\t\t}\n\t//\t\t}\n\t//\t}\n\t//}\n\n\tinternal void CommitImplicitTransaction()\n\t{\n\t\tif (HasImplicitTransaction && _transaction != null && _transaction.Transaction != null)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\t_transaction.Commit();\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tRollbackImplicitTransaction();\n\n\t\t\t\tthrow;\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tif (_transaction != null)\n\t\t\t\t{\n\t\t\t\t\t_transaction.Dispose();\n\t\t\t\t\t_transaction = null;\n\t\t\t\t\t_implicitTransaction = false;\n\t\t\t\t}\n\n\t\t\t\tif (_statement != null)\n\t\t\t\t{\n\t\t\t\t\t_statement.Transaction = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tinternal async Task CommitImplicitTransactionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (HasImplicitTransaction && _transaction != null && _transaction.Transaction != null)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait _transaction.CommitAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tawait RollbackImplicitTransactionAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tthrow;\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tif (_transaction != null)\n\t\t\t\t{\n\t\t\t\t\tawait _transaction.DisposeAsync().ConfigureAwait(false);\n\t\t\t\t\t_transaction = null;\n\t\t\t\t\t_implicitTransaction = false;\n\t\t\t\t}\n\n\t\t\t\tif (_statement != null)\n\t\t\t\t{\n\t\t\t\t\t_statement.Transaction = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tinternal void RollbackImplicitTransaction()\n\t{\n\t\tif (HasImplicitTransaction && _transaction != null && _transaction.Transaction != null)\n\t\t{\n\t\t\tvar transactionCount = Connection.InnerConnection.Database.TransactionCount;\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\t_transaction.Rollback();\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tif (Connection.InnerConnection.Database.TransactionCount == transactionCount)\n\t\t\t\t{\n\t\t\t\t\tConnection.InnerConnection.Database.TransactionCount--;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\t_transaction.Dispose();\n\t\t\t\t_transaction = null;\n\t\t\t\t_implicitTransaction = false;\n\n\t\t\t\tif (_statement != null)\n\t\t\t\t{\n\t\t\t\t\t_statement.Transaction = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tinternal async Task RollbackImplicitTransactionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (HasImplicitTransaction && _transaction != null && _transaction.Transaction != null)\n\t\t{\n\t\t\tvar transactionCount = Connection.InnerConnection.Database.TransactionCount;\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait _transaction.RollbackAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tif (Connection.InnerConnection.Database.TransactionCount == transactionCount)\n\t\t\t\t{\n\t\t\t\t\tConnection.InnerConnection.Database.TransactionCount--;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait _transaction.DisposeAsync().ConfigureAwait(false);\n\t\t\t\t_transaction = null;\n\t\t\t\t_implicitTransaction = false;\n\n\t\t\t\tif (_statement != null)\n\t\t\t\t{\n\t\t\t\t\t_statement.Transaction = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tinternal void Close()\n\t{\n\t\tif (_statement != null)\n\t\t{\n\t\t\t_statement.Close();\n\t\t}\n\t}\n\tinternal Task CloseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_statement != null)\n\t\t{\n\t\t\treturn _statement.CloseAsync(cancellationToken).AsTask();\n\t\t}\n\t\treturn Task.CompletedTask;\n\t}\n\n\tvoid IFbPreparedCommand.Release() => Release();\n\tinternal void Release()\n\t{\n\t\tRollbackImplicitTransaction();\n\n\t\t//DisposeReader();\n\n\t\tif (_connection != null && _connection.State == ConnectionState.Open)\n\t\t{\n\t\t\t_connection.InnerConnection.RemovePreparedCommand(this);\n\t\t}\n\n\t\t_batch = null;\n\n\t\tif (_statement != null)\n\t\t{\n\t\t\t_statement.Dispose2();\n\t\t\t_statement = null;\n\t\t}\n\t}\n\tTask IFbPreparedCommand.ReleaseAsync(CancellationToken cancellationToken) => ReleaseAsync(cancellationToken);\n\tinternal async Task ReleaseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tawait RollbackImplicitTransactionAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t//await DisposeReaderAsync(cancellationToken).ConfigureAwait(false);\n\n\t\tif (_connection != null && _connection.State == ConnectionState.Open)\n\t\t{\n\t\t\t_connection.InnerConnection.RemovePreparedCommand(this);\n\t\t}\n\n\t\t_batch = null;\n\n\t\tif (_statement != null)\n\t\t{\n\t\t\tawait _statement.Dispose2Async(cancellationToken).ConfigureAwait(false);\n\t\t\t_statement = null;\n\t\t}\n\t}\n\n\tvoid IFbPreparedCommand.TransactionCompleted() => TransactionCompleted();\n\tinternal void TransactionCompleted()\n\t{\n\t\tif (Transaction != null)\n\t\t{\n\t\t\t//DisposeReader();\n\t\t\tTransaction = null;\n\t\t}\n\t}\n\tTask IFbPreparedCommand.TransactionCompletedAsync(CancellationToken cancellationToken) => TransactionCompletedAsync(cancellationToken);\n\tinternal async Task TransactionCompletedAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (Transaction != null)\n\t\t{\n\t\t\t//await DisposeReaderAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tawait Task.CompletedTask.ConfigureAwait(false);\n\t\t\tTransaction = null;\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region IDescriptorFiller\n\n\tvoid IDescriptorFiller.Fill(Descriptor descriptor, int index) => UpdateParameterValues(descriptor, index);\n\tprivate void UpdateParameterValues(Descriptor descriptor, int batchIndex)\n\t{\n\t\tif (!HasParameters)\n\t\t\treturn;\n\n\t\tfor (var i = 0; i < descriptor.Count; i++)\n\t\t{\n\t\t\tvar parameter = descriptor[i];\n\t\t\tvar index = i;\n\n\t\t\tif (_namedParameters.Count > 0)\n\t\t\t{\n\t\t\t\tindex = _batchParameters[batchIndex].IndexOf(_namedParameters[i], i);\n\t\t\t\tif (index == -1)\n\t\t\t\t{\n\t\t\t\t\tthrow FbException.Create($\"Must declare the variable '{_namedParameters[i]}'.\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (index != -1)\n\t\t\t{\n\t\t\t\tvar commandParameter = _batchParameters[batchIndex][index];\n\t\t\t\tif (commandParameter.InternalValue == DBNull.Value || commandParameter.InternalValue == null)\n\t\t\t\t{\n\t\t\t\t\tparameter.NullFlag = -1;\n\t\t\t\t\tparameter.DbValue.SetValue(DBNull.Value);\n\n\t\t\t\t\tif (!parameter.AllowDBNull())\n\t\t\t\t\t{\n\t\t\t\t\t\tparameter.DataType++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tparameter.NullFlag = 0;\n\n\t\t\t\t\tswitch (parameter.DbDataType)\n\t\t\t\t\t{\n\t\t\t\t\t\tcase DbDataType.Binary:\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvar blob = _statement.CreateBlob();\n\t\t\t\t\t\t\t\tblob.Write((byte[])commandParameter.InternalValue);\n\t\t\t\t\t\t\t\tparameter.DbValue.SetValue(blob.Id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Text:\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvar blob = _statement.CreateBlob();\n\t\t\t\t\t\t\t\tif (commandParameter.InternalValue is byte[])\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tblob.Write((byte[])commandParameter.InternalValue);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tblob.Write((string)commandParameter.InternalValue);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tparameter.DbValue.SetValue(blob.Id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Array:\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (parameter.ArrayHandle == null)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tparameter.ArrayHandle = _statement.CreateArray(parameter.Relation, parameter.Name);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tparameter.ArrayHandle.Database = _statement.Database;\n\t\t\t\t\t\t\t\t\tparameter.ArrayHandle.Transaction = _statement.Transaction;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tparameter.ArrayHandle.Handle = 0;\n\t\t\t\t\t\t\t\tparameter.ArrayHandle.Write((Array)commandParameter.InternalValue);\n\t\t\t\t\t\t\t\tparameter.DbValue.SetValue(parameter.ArrayHandle.Handle);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Guid:\n\t\t\t\t\t\t\tif (!(commandParameter.InternalValue is Guid) && !(commandParameter.InternalValue is byte[]))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tthrow new InvalidOperationException(\"Incorrect Guid value.\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tparameter.DbValue.SetValue(commandParameter.InternalValue);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tparameter.DbValue.SetValue(commandParameter.InternalValue);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tValueTask IDescriptorFiller.FillAsync(Descriptor descriptor, int index, CancellationToken cancellationToken) => UpdateParameterValuesAsync(descriptor, index, cancellationToken);\n\tprivate async ValueTask UpdateParameterValuesAsync(Descriptor descriptor, int batchIndex, CancellationToken cancellationToken = default)\n\t{\n\t\tif (!HasParameters)\n\t\t\treturn;\n\n\t\tfor (var i = 0; i < descriptor.Count; i++)\n\t\t{\n\t\t\tvar batchParameter = descriptor[i];\n\t\t\tvar index = i;\n\n\t\t\tif (_namedParameters.Count > 0)\n\t\t\t{\n\t\t\t\tindex = _batchParameters[batchIndex].IndexOf(_namedParameters[i], i);\n\t\t\t\tif (index == -1)\n\t\t\t\t{\n\t\t\t\t\tthrow FbException.Create($\"Must declare the variable '{_namedParameters[i]}'.\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (index != -1)\n\t\t\t{\n\t\t\t\tvar commandParameter = _batchParameters[batchIndex][index];\n\t\t\t\tif (commandParameter.InternalValue == DBNull.Value || commandParameter.InternalValue == null)\n\t\t\t\t{\n\t\t\t\t\tbatchParameter.NullFlag = -1;\n\t\t\t\t\tbatchParameter.DbValue.SetValue(DBNull.Value);\n\n\t\t\t\t\tif (!batchParameter.AllowDBNull())\n\t\t\t\t\t{\n\t\t\t\t\t\tbatchParameter.DataType++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tbatchParameter.NullFlag = 0;\n\n\t\t\t\t\tswitch (batchParameter.DbDataType)\n\t\t\t\t\t{\n\t\t\t\t\t\tcase DbDataType.Binary:\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvar blob = _statement.CreateBlob();\n\t\t\t\t\t\t\t\tawait blob.WriteAsync((byte[])commandParameter.InternalValue, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\t\tbatchParameter.DbValue.SetValue(blob.Id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Text:\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvar blob = _statement.CreateBlob();\n\t\t\t\t\t\t\t\tif (commandParameter.InternalValue is byte[])\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tawait blob.WriteAsync((byte[])commandParameter.InternalValue, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tawait blob.WriteAsync((string)commandParameter.InternalValue, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbatchParameter.DbValue.SetValue(blob.Id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Array:\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (batchParameter.ArrayHandle == null)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tbatchParameter.ArrayHandle =\n\t\t\t\t\t\t\t\t\tawait _statement.CreateArrayAsync(batchParameter.Relation, batchParameter.Name, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tbatchParameter.ArrayHandle.Database = _statement.Database;\n\t\t\t\t\t\t\t\t\tbatchParameter.ArrayHandle.Transaction = _statement.Transaction;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tbatchParameter.ArrayHandle.Handle = 0;\n\t\t\t\t\t\t\t\tawait batchParameter.ArrayHandle.WriteAsync((Array)commandParameter.InternalValue, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\t\tbatchParameter.DbValue.SetValue(batchParameter.ArrayHandle.Handle);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Guid:\n\t\t\t\t\t\t\tif (!(commandParameter.InternalValue is Guid) && !(commandParameter.InternalValue is byte[]))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tthrow new InvalidOperationException(\"Incorrect Guid value.\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbatchParameter.DbValue.SetValue(commandParameter.InternalValue);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tbatchParameter.DbValue.SetValue(commandParameter.InternalValue);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void Prepare(bool returnsSet)\n\t{\n\t\tvar innerConn = _connection.InnerConnection;\n\n\t\t// Check if\twe have\ta valid\ttransaction\n\t\tif (_transaction == null)\n\t\t{\n\t\t\tif (innerConn.IsEnlisted)\n\t\t\t{\n\t\t\t\t_transaction = innerConn.ActiveTransaction;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_implicitTransaction = true;\n\t\t\t\t_transaction = new FbTransaction(_connection, _connection.ConnectionOptions.IsolationLevel);\n\t\t\t\t_transaction.BeginTransaction();\n\n\t\t\t\t// Update Statement\ttransaction\n\t\t\t\tif (_statement != null)\n\t\t\t\t{\n\t\t\t\t\t_statement.Transaction = _transaction.Transaction;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Check if\twe have\ta valid\tstatement handle\n\t\tif (_statement == null)\n\t\t{\n\t\t\t_statement = innerConn.Database.CreateStatement(_transaction.Transaction);\n\t\t\t_batch = _statement.CreateBatch();\n\t\t}\n\n\t\t// Prepare the statement if\tneeded\n\t\tif (!_statement.IsPrepared)\n\t\t{\n\t\t\t// Close the inner DataReader if needed\n\t\t\t//DisposeReader();\n\n\t\t\t// Reformat the SQL statement if needed\n\t\t\tvar sql = _commandText;\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\t(sql, _namedParameters) = NamedParametersParser.Parse(sql);\n\t\t\t\t// Try to prepare the command\n\t\t\t\t_statement.Prepare(sql);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\t_batch = null;\n\t\t\t\t// Release the statement and rethrow the exception\n\t\t\t\t_statement.Release();\n\t\t\t\t_statement = null;\n\n\t\t\t\tthrow;\n\t\t\t}\n\n\t\t\t// Add this\tcommand\tto the active command list\n\t\t\tinnerConn.AddPreparedCommand(this);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// Close statement for subsequently\texecutions\n\t\t\tClose();\n\t\t}\n\t}\n\tprivate async Task PrepareAsync(bool returnsSet, CancellationToken cancellationToken = default)\n\t{\n\t\tvar innerConn = _connection.InnerConnection;\n\n\t\t// Check if\twe have\ta valid\ttransaction\n\t\tif (_transaction == null)\n\t\t{\n\t\t\tif (innerConn.IsEnlisted)\n\t\t\t{\n\t\t\t\t_transaction = innerConn.ActiveTransaction;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_implicitTransaction = true;\n\t\t\t\t_transaction = new FbTransaction(_connection, _connection.ConnectionOptions.IsolationLevel);\n\t\t\t\tawait _transaction.BeginTransactionAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\t// Update Statement\ttransaction\n\t\t\t\tif (_statement != null)\n\t\t\t\t{\n\t\t\t\t\t_statement.Transaction = _transaction.Transaction;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Check if\twe have\ta valid\tstatement handle\n\t\tif (_statement == null)\n\t\t{\n\t\t\t_statement = innerConn.Database.CreateStatement(_transaction.Transaction);\n\t\t\t_batch = _statement.CreateBatch();\n\t\t}\n\n\t\t// Prepare the statement if\tneeded\n\t\tif (!_statement.IsPrepared)\n\t\t{\n\t\t\t// Close the inner DataReader if needed\n\t\t\t//await DisposeReaderAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t// Reformat the SQL statement if needed\n\t\t\tvar sql = _commandText;\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\t(sql, _namedParameters) = NamedParametersParser.Parse(sql);\n\t\t\t\t// Try to prepare the command\n\t\t\t\tawait _statement.PrepareAsync(sql, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\t_batch = null;\n\t\t\t\t// Release the statement and rethrow the exception\n\t\t\t\tawait _statement.ReleaseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t_statement = null;\n\n\t\t\t\tthrow;\n\t\t\t}\n\n\t\t\t// Add this\tcommand\tto the active command list\n\t\t\tinnerConn.AddPreparedCommand(this);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// Close statement for subsequently\texecutions\n\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\tprivate FbBatchNonQueryResult ExecuteCommand(bool returnsSet)\n\t{\n\t\tLogMessages.CommandExecution(Log, this);\n\n\t\tPrepare(returnsSet);\n\n\t\t// Set the fetch size\n\t\t//_statement.FetchSize = _fetchSize;\n\n\t\t// Set if it's needed the Records Affected information\n\t\t_statement.ReturnRecordsAffected = _connection.ConnectionOptions.ReturnRecordsAffected;\n\n\t\t// Validate input parameter count\n\t\tif (_namedParameters.Count > 0 && !HasParameters)\n\t\t{\n\t\t\tthrow FbException.Create(\"Must declare command parameters.\");\n\t\t}\n\n\t\ttry\n\t\t{\n\t\t\t_batch.MultiError = MultiError;\n\t\t\t_batch.BatchBufferSize = BatchBufferSize;\n\t\t\t// Execute\n\t\t\treturn new FbBatchNonQueryResult(_batch.Execute(_batchParameters.Count, this));\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\t_batch.Release();\n\t\t}\n\t}\n\tprivate async Task<FbBatchNonQueryResult> ExecuteCommandAsync(bool returnsSet, CancellationToken cancellationToken = default)\n\t{\n\t\tLogMessages.CommandExecution(Log, this);\n\n\t\tawait PrepareAsync(returnsSet, cancellationToken).ConfigureAwait(false);\n\n\t\t// Set the fetch size\n\t\t//_statement.FetchSize = _fetchSize;\n\n\t\t// Set if it's needed the Records Affected information\n\t\t_statement.ReturnRecordsAffected = _connection.ConnectionOptions.ReturnRecordsAffected;\n\n\t\t// Validate input parameter count\n\t\tif (_namedParameters.Count > 0 && !HasParameters)\n\t\t{\n\t\t\tthrow FbException.Create(\"Must declare command parameters.\");\n\t\t}\n\n\t\ttry\n\t\t{\n\t\t\t_batch.MultiError = MultiError;\n\t\t\t_batch.BatchBufferSize = BatchBufferSize;\n\t\t\t// Execute\n\t\t\treturn new FbBatchNonQueryResult(await _batch.ExecuteAsync(_batchParameters.Count, this, cancellationToken).ConfigureAwait(false));\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tawait _batch.ReleaseAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\tprivate void CheckCommand()\n\t{\n\t\tif (_transaction != null && _transaction.IsCompleted)\n\t\t{\n\t\t\t_transaction = null;\n\t\t}\n\n\t\tFbConnection.EnsureOpen(_connection);\n\n\t\t//if (_activeReader != null)\n\t\t//{\n\t\t//\tthrow new InvalidOperationException(\"There is already an open DataReader associated with this Command which must be closed first.\");\n\t\t//}\n\n\t\tif (_transaction == null &&\n\t\t\t_connection.InnerConnection.HasActiveTransaction &&\n\t\t\t!_connection.InnerConnection.IsEnlisted)\n\t\t{\n\t\t\tthrow 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.\");\n\t\t}\n\n\t\tif (_transaction != null && !_transaction.IsCompleted &&\n\t\t\t!_connection.Equals(_transaction.Connection))\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Command Connection is not equal to Transaction Connection.\");\n\t\t}\n\n\t\tif (_commandText == null || _commandText.Length == 0)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"The command text for this Command has not been set.\");\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbBatchNonQueryResult.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing static FirebirdSql.Data.Common.BatchBase;\nusing static FirebirdSql.Data.FirebirdClient.FbBatchNonQueryResult;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic sealed class FbBatchNonQueryResult : IEnumerable<FbBatchNonQueryResultItem>\n{\n\tpublic sealed class FbBatchNonQueryResultItem\n\t{\n\t\tpublic int RecordsAffected { get; internal set; }\n\t\tpublic bool IsSuccess { get; internal set; }\n\t\tpublic FbException Exception { get; internal set; }\n\t}\n\n\treadonly List<FbBatchNonQueryResultItem> _items;\n\n\tpublic bool AllSuccess => _items.TrueForAll(x => x.IsSuccess);\n\tpublic int Count => _items.Count;\n\n\tinternal FbBatchNonQueryResult(ExecuteResultItem[] result)\n\t{\n\t\t_items = result.Select(x => new FbBatchNonQueryResultItem()\n\t\t{\n\t\t\tRecordsAffected = x.RecordsAffected,\n\t\t\tIsSuccess = !x.IsError,\n\t\t\tException = x.Exception != null ? (FbException)FbException.Create(x.Exception) : null,\n\t\t}).ToList();\n\t}\n\n\tpublic FbBatchNonQueryResultItem this[int index] => _items[index];\n\n\tpublic void EnsureSuccess()\n\t{\n\t\tvar indexes = _items.Select((e, i) => new { Element = e, Index = i }).Where(x => !x.Element.IsSuccess).Select(x => x.Index).ToList();\n\t\tif (indexes.Count == 0)\n\t\t\treturn;\n\t\tthrow FbException.Create($\"Indexes {string.Join(\", \", indexes)} failed in batch.\");\n\t}\n\n\tpublic IEnumerator<FbBatchNonQueryResultItem> GetEnumerator() => _items.GetEnumerator();\n\n\tIEnumerator IEnumerable.GetEnumerator() => GetEnumerator();\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbBatchParameterCollection.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.ComponentModel;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\n[ListBindable(false)]\npublic sealed class FbBatchParameterCollection : IList<FbParameterCollection>\n{\n\treadonly List<FbParameterCollection> _inner;\n\n\tinternal FbBatchParameterCollection()\n\t{\n\t\t_inner = new List<FbParameterCollection>();\n\t}\n\n\tpublic FbParameterCollection this[int index]\n\t{\n\t\tget => _inner[index];\n\t\tset => _inner[index] = value;\n\t}\n\n\tpublic int Count => _inner.Count;\n\n\tpublic bool IsReadOnly => false;\n\n\tpublic void Add(FbParameterCollection item) => _inner.Add(item);\n\n\tpublic void Clear() => _inner.Clear();\n\n\tpublic bool Contains(FbParameterCollection item) => _inner.Contains(item);\n\n\tpublic void CopyTo(FbParameterCollection[] array, int arrayIndex) => _inner.CopyTo(array, arrayIndex);\n\n\tpublic IEnumerator<FbParameterCollection> GetEnumerator() => _inner.GetEnumerator();\n\n\tpublic int IndexOf(FbParameterCollection item) => _inner.IndexOf(item);\n\n\tpublic void Insert(int index, FbParameterCollection item) => _inner.Insert(index, item);\n\n\tpublic bool Remove(FbParameterCollection item) => _inner.Remove(item);\n\n\tpublic void RemoveAt(int index) => _inner.RemoveAt(index);\n\n\tIEnumerator IEnumerable.GetEnumerator() => GetEnumerator();\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbCharset.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\n[Serializable]\npublic enum FbCharset\n{\n\tDefault = -1,\n\tNone = 0,\n\tOctets = 1,\n\tAscii = 2,\n\tUnicodeFss = 3,\n\tUtf8 = 4,\n\tShiftJis0208 = 5,\n\tEucJapanese0208 = 6,\n\tIso2022Japanese = 7,\n\tDos437 = 10,\n\tDos850 = 11,\n\tDos865 = 12,\n\tDos860 = 13,\n\tDos863 = 14,\n\tIso8859_1 = 21,\n\tIso8859_2 = 22,\n\tKsc5601 = 44,\n\tDos861 = 47,\n\tWindows1250 = 51,\n\tWindows1251 = 52,\n\tWindows1252 = 53,\n\tWindows1253 = 54,\n\tWindows1254 = 55,\n\tBig5 = 56,\n\tGb2312 = 57,\n\tWindows1255 = 58,\n\tWindows1256 = 59,\n\tWindows1257 = 60,\n\t// UTF-16\n\t// Utf16           = 61,\n\t// UTF-32\n\t// Utf32           = 62,\n\t// Russian KOI8R\n\tKoi8R = 63,\n\t// Ukrainian KOI8U\n\tKoi8U = 64,\n\t// TIS-620 Thai character set, single byte (since Firebird 2.1)\n\tTIS620 = 65,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbCommand.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Data.Common;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.Logging;\nusing Microsoft.Extensions.Logging;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic sealed class FbCommand : DbCommand, IFbPreparedCommand, IDescriptorFiller, ICloneable\n{\n\tstatic readonly ILogger<FbCommand> Log = FbLogManager.CreateLogger<FbCommand>();\n\n\t#region Fields\n\n\tprivate CommandType _commandType;\n\tprivate UpdateRowSource _updatedRowSource;\n\tprivate FbConnection _connection;\n\tprivate FbTransaction _transaction;\n\tprivate FbParameterCollection _parameters;\n\tprivate StatementBase _statement;\n\tprivate FbDataReader _activeReader;\n\tprivate IReadOnlyList<string> _namedParameters;\n\tprivate string _commandText;\n\tprivate bool _disposed;\n\tprivate bool _designTimeVisible;\n\tprivate bool _implicitTransaction;\n\tprivate int? _commandTimeout;\n\tprivate int _fetchSize;\n\tprivate Type[] _expectedColumnTypes;\n\n\t#endregion\n\n\t#region Properties\n\n\t[Category(\"Data\")]\n\t[DefaultValue(\"\")]\n\t[RefreshProperties(RefreshProperties.All)]\n\tpublic override string CommandText\n\t{\n\t\tget { return _commandText; }\n\t\tset\n\t\t{\n\t\t\tif (_commandText != value && _statement != null)\n\t\t\t{\n\t\t\t\tRelease();\n\t\t\t}\n\n\t\t\t_commandText = value;\n\t\t}\n\t}\n\n\t[Category(\"Data\")]\n\t[DefaultValue(CommandType.Text)]\n\t[RefreshProperties(RefreshProperties.All)]\n\tpublic override CommandType CommandType\n\t{\n\t\tget { return _commandType; }\n\t\tset { _commandType = value; }\n\t}\n\n\t[Category(\"Behavior\")]\n\t[DefaultValue(ConnectionString.DefaultValueCommandTimeout)]\n\tpublic override int CommandTimeout\n\t{\n\t\tget\n\t\t{\n\t\t\tif (_commandTimeout != null)\n\t\t\t\treturn (int)_commandTimeout;\n\t\t\tif (_connection?.CommandTimeout >= 0)\n\t\t\t\treturn (int)_connection?.CommandTimeout;\n\t\t\treturn ConnectionString.DefaultValueCommandTimeout;\n\t\t}\n\t\tset\n\t\t{\n\t\t\tif (value < 0)\n\t\t\t{\n\t\t\t\tthrow new ArgumentException(\"The property value assigned is less than 0.\");\n\t\t\t}\n\n\t\t\t_commandTimeout = value;\n\t\t}\n\t}\n\n\t[Category(\"Behavior\")]\n\t[DefaultValue(null)]\n\tpublic new FbConnection Connection\n\t{\n\t\tget { return _connection; }\n\t\tset\n\t\t{\n\t\t\tif (_activeReader != null)\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException(\"There is already an open DataReader associated with this Command which must be closed first.\");\n\t\t\t}\n\n\t\t\tif (_transaction != null && _transaction.IsCompleted)\n\t\t\t{\n\t\t\t\t_transaction = null;\n\t\t\t}\n\n\t\t\tif (_connection != null &&\n\t\t\t\t_connection != value &&\n\t\t\t\t_connection.State == ConnectionState.Open)\n\t\t\t{\n\t\t\t\tRelease();\n\t\t\t}\n\n\t\t\t_connection = value;\n\t\t}\n\t}\n\n\t[Category(\"Data\")]\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]\n\tpublic new FbParameterCollection Parameters\n\t{\n\t\tget\n\t\t{\n\t\t\tif (_parameters == null)\n\t\t\t{\n\t\t\t\t_parameters = new FbParameterCollection();\n\t\t\t}\n\t\t\treturn _parameters;\n\t\t}\n\t}\n\n\t[Browsable(false)]\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\tpublic new FbTransaction Transaction\n\t{\n\t\tget { return _implicitTransaction ? null : _transaction; }\n\t\tset\n\t\t{\n\t\t\tif (_activeReader != null)\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException(\"There is already an open DataReader associated with this Command which must be closed first.\");\n\t\t\t}\n\n\t\t\tRollbackImplicitTransaction();\n\n\t\t\t_transaction = value;\n\n\t\t\tif (_statement != null)\n\t\t\t{\n\t\t\t\tif (_transaction != null)\n\t\t\t\t{\n\t\t\t\t\t_statement.Transaction = _transaction.Transaction;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t_statement.Transaction = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Category(\"Behavior\")]\n\t[DefaultValue(UpdateRowSource.Both)]\n\tpublic override UpdateRowSource UpdatedRowSource\n\t{\n\t\tget { return _updatedRowSource; }\n\t\tset { _updatedRowSource = value; }\n\t}\n\n\t[Category(\"Behavior\")]\n\t[DefaultValue(200)]\n\tpublic int FetchSize\n\t{\n\t\tget { return _fetchSize; }\n\t\tset\n\t\t{\n\t\t\tif (_activeReader != null)\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException(\"There is already an open DataReader associated with this Command which must be closed first.\");\n\t\t\t}\n\t\t\t_fetchSize = value;\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Gets collection of parameters parsed from the query text during command prepare.\n\t/// </summary>\n\t[Browsable(false)]\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\tpublic IReadOnlyList<string> NamedParameters\n\t{\n\t\tget { return _namedParameters; }\n\t}\n\n\t#endregion\n\n\t#region Protected DbCommand Properties\n\n\tprotected override DbConnection DbConnection\n\t{\n\t\tget { return Connection; }\n\t\tset { Connection = (FbConnection)value; }\n\t}\n\n\tprotected override DbTransaction DbTransaction\n\t{\n\t\tget { return Transaction; }\n\t\tset { Transaction = (FbTransaction)value; }\n\t}\n\n\tprotected override DbParameterCollection DbParameterCollection\n\t{\n\t\tget { return Parameters; }\n\t}\n\n\t#endregion\n\n\t#region Design-Time properties\n\n\t[Browsable(false)]\n\t[DesignOnly(true)]\n\t[DefaultValue(true)]\n\tpublic override bool DesignTimeVisible\n\t{\n\t\tget { return _designTimeVisible; }\n\t\tset\n\t\t{\n\t\t\t_designTimeVisible = value;\n\t\t\tTypeDescriptor.Refresh(this);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Internal Properties\n\n\tinternal int RecordsAffected\n\t{\n\t\tget\n\t\t{\n\t\t\tif (_statement != null && CommandType != CommandType.StoredProcedure)\n\t\t\t{\n\t\t\t\treturn _statement.RecordsAffected;\n\t\t\t}\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tinternal bool IsDisposed\n\t{\n\t\tget { return _disposed; }\n\t}\n\n\tinternal FbDataReader ActiveReader\n\t{\n\t\tget { return _activeReader; }\n\t\tset { _activeReader = value; }\n\t}\n\n\tinternal FbTransaction ActiveTransaction\n\t{\n\t\tget { return _transaction; }\n\t}\n\n\tinternal bool HasImplicitTransaction\n\t{\n\t\tget { return _implicitTransaction; }\n\t}\n\n\tinternal bool HasFields\n\t{\n\t\tget { return _statement?.Fields?.Count > 0; }\n\t}\n\n\tinternal bool HasParameters\n\t{\n\t\tget { return _parameters != null && _parameters.Count > 0; }\n\t}\n\n\tinternal bool IsDDLCommand\n\t{\n\t\tget { return _statement?.StatementType == DbStatementType.DDL; }\n\t}\n\n\tinternal Type[] ExpectedColumnTypes\n\t{\n\t\tget { return _expectedColumnTypes; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FbCommand()\n\t\t: this(null, null, null)\n\t{ }\n\n\tpublic FbCommand(string cmdText)\n\t\t: this(cmdText, null, null)\n\t{ }\n\n\tpublic FbCommand(string cmdText, FbConnection connection)\n\t\t: this(cmdText, connection, null)\n\t{ }\n\n\tpublic FbCommand(string cmdText, FbConnection connection, FbTransaction transaction)\n\t{\n\t\t_namedParameters = Array.Empty<string>();\n\t\t_updatedRowSource = UpdateRowSource.Both;\n\t\t_commandType = CommandType.Text;\n\t\t_designTimeVisible = true;\n\t\t_commandTimeout = null;\n\t\t_fetchSize = 200;\n\t\t_commandText = string.Empty;\n\n\t\tif (connection != null)\n\t\t{\n\t\t\t_fetchSize = connection.ConnectionOptions.FetchSize;\n\t\t}\n\n\t\tif (cmdText != null)\n\t\t{\n\t\t\tCommandText = cmdText;\n\t\t}\n\n\t\tConnection = connection;\n\t\t_transaction = transaction;\n\t}\n\n\tpublic static FbCommand CreateWithTypeCoercions(Type[] expectedColumnTypes)\n\t{\n\t\tvar result = new FbCommand();\n\t\tresult._expectedColumnTypes = expectedColumnTypes;\n\t\treturn result;\n\t}\n\n\t#endregion\n\n\t#region IDisposable, IAsyncDisposable methods\n\n\tprotected override void Dispose(bool disposing)\n\t{\n\t\tif (disposing)\n\t\t{\n\t\t\tif (!_disposed)\n\t\t\t{\n\t\t\t\t_disposed = true;\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tRelease();\n\t\t\t\t}\n\t\t\t\tcatch (IscException ex)\n\t\t\t\t{\n\t\t\t\t\tthrow FbException.Create(ex);\n\t\t\t\t}\n\t\t\t\t_commandTimeout = null;\n\t\t\t\t_fetchSize = 0;\n\t\t\t\t_implicitTransaction = false;\n\t\t\t\t_commandText = null;\n\t\t\t\t_connection = null;\n\t\t\t\t_transaction = null;\n\t\t\t\t_parameters = null;\n\t\t\t\t_statement = null;\n\t\t\t\t_activeReader = null;\n\t\t\t\t_namedParameters = null;\n\t\t\t}\n\t\t}\n\t\tbase.Dispose(disposing);\n\t}\n\tpublic override async ValueTask DisposeAsync()\n\t{\n\t\tif (!_disposed)\n\t\t{\n\t\t\t_disposed = true;\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait ReleaseAsync().ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t\t_commandTimeout = 0;\n\t\t\t_fetchSize = 0;\n\t\t\t_implicitTransaction = false;\n\t\t\t_commandText = null;\n\t\t\t_connection = null;\n\t\t\t_transaction = null;\n\t\t\t_parameters = null;\n\t\t\t_statement = null;\n\t\t\t_activeReader = null;\n\t\t\t_namedParameters = null;\n\t\t}\n\t\tawait base.DisposeAsync().ConfigureAwait(false);\n\t}\n\n\t#endregion\n\n\t#region ICloneable Methods\n\n\tobject ICloneable.Clone()\n\t{\n\t\tvar command = new FbCommand();\n\n\t\tcommand.CommandText = CommandText;\n\t\tcommand.Connection = Connection;\n\t\tcommand.Transaction = Transaction;\n\t\tcommand.CommandType = CommandType;\n\t\tcommand.UpdatedRowSource = UpdatedRowSource;\n\t\tcommand.CommandTimeout = CommandTimeout;\n\t\tcommand.FetchSize = FetchSize;\n\t\tcommand.UpdatedRowSource = UpdatedRowSource;\n\n\t\tif (_expectedColumnTypes != null)\n\t\t{\n\t\t\tcommand._expectedColumnTypes = (Type[])_expectedColumnTypes.Clone();\n\t\t}\n\n\t\tfor (var i = 0; i < Parameters.Count; i++)\n\t\t{\n\t\t\tcommand.Parameters.Add(((ICloneable)Parameters[i]).Clone());\n\t\t}\n\n\t\treturn command;\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic override void Cancel()\n\t{\n\t\t_connection.CancelCommand();\n\t}\n\n\tpublic new FbParameter CreateParameter()\n\t{\n\t\treturn new FbParameter();\n\t}\n\n\tpublic override void Prepare()\n\t{\n\t\tCheckCommand();\n\n\t\tusing (var explicitCancellation = ExplicitCancellation.Enter(CancellationToken.None, Cancel))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tPrepare(false);\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tRollbackImplicitTransaction();\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tRollbackImplicitTransaction();\n\t\t\t\tthrow;\n\t\t\t}\n\t\t}\n\t}\n\tpublic override async Task PrepareAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tCheckCommand();\n\n\t\tusing (var explicitCancellation = ExplicitCancellation.Enter(cancellationToken, Cancel))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait PrepareAsync(false, explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tawait RollbackImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tawait RollbackImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\tthrow;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override int ExecuteNonQuery()\n\t{\n\t\tCheckCommand();\n\n\t\tusing (var explicitCancellation = ExplicitCancellation.Enter(CancellationToken.None, Cancel))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tExecuteCommand(CommandBehavior.Default, false);\n\n\t\t\t\tif (_statement.StatementType == DbStatementType.StoredProcedure)\n\t\t\t\t{\n\t\t\t\t\tSetOutputParameters();\n\t\t\t\t}\n\n\t\t\t\tCommitImplicitTransaction();\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tRollbackImplicitTransaction();\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tRollbackImplicitTransaction();\n\t\t\t\tthrow;\n\t\t\t}\n\t\t}\n\n\t\treturn _statement.StatementType switch\n\t\t{\n\t\t\tDbStatementType.Insert => RecordsAffected,\n\t\t\tDbStatementType.Update => RecordsAffected,\n\t\t\tDbStatementType.Delete => RecordsAffected,\n\t\t\t_ => -1,\n\t\t};\n\t}\n\tpublic override async Task<int> ExecuteNonQueryAsync(CancellationToken cancellationToken)\n\t{\n\t\tCheckCommand();\n\n\t\tusing (var explicitCancellation = ExplicitCancellation.Enter(cancellationToken, Cancel))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait ExecuteCommandAsync(CommandBehavior.Default, false, explicitCancellation.CancellationToken).ConfigureAwait(false);\n\n\t\t\t\tif (_statement.StatementType == DbStatementType.StoredProcedure)\n\t\t\t\t{\n\t\t\t\t\tawait SetOutputParametersAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\n\t\t\t\tawait CommitImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tawait RollbackImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tawait RollbackImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\tthrow;\n\t\t\t}\n\t\t}\n\n\t\treturn _statement.StatementType switch\n\t\t{\n\t\t\tDbStatementType.Insert => RecordsAffected,\n\t\t\tDbStatementType.Update => RecordsAffected,\n\t\t\tDbStatementType.Delete => RecordsAffected,\n\t\t\t_ => -1,\n\t\t};\n\t}\n\n\tpublic new FbDataReader ExecuteReader() => ExecuteReader(CommandBehavior.Default);\n\tpublic new Task<FbDataReader> ExecuteReaderAsync() => ExecuteReaderAsync(CommandBehavior.Default);\n\tpublic new Task<FbDataReader> ExecuteReaderAsync(CancellationToken cancellationToken) => ExecuteReaderAsync(CommandBehavior.Default, cancellationToken);\n\n\tpublic new FbDataReader ExecuteReader(CommandBehavior behavior)\n\t{\n\t\tCheckCommand();\n\n\t\tusing (var explicitCancellation = ExplicitCancellation.Enter(CancellationToken.None, Cancel))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tExecuteCommand(behavior, true);\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tRollbackImplicitTransaction();\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tRollbackImplicitTransaction();\n\t\t\t\tthrow;\n\t\t\t}\n\t\t}\n\n\t\t_activeReader = new FbDataReader(this, _connection, behavior);\n\t\treturn _activeReader;\n\t}\n\tpublic new Task<FbDataReader> ExecuteReaderAsync(CommandBehavior behavior) => ExecuteReaderAsync(behavior, CancellationToken.None);\n\tpublic new async Task<FbDataReader> ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)\n\t{\n\t\tCheckCommand();\n\n\t\tusing (var explicitCancellation = ExplicitCancellation.Enter(cancellationToken, Cancel))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait ExecuteCommandAsync(behavior, true, explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tawait RollbackImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tawait RollbackImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\tthrow;\n\t\t\t}\n\t\t}\n\n\t\t_activeReader = new FbDataReader(this, _connection, behavior);\n\t\treturn _activeReader;\n\t}\n\n\tpublic override object ExecuteScalar()\n\t{\n\t\tDbValue[] values = null;\n\t\tobject val = null;\n\n\t\tCheckCommand();\n\n\t\tusing (var explicitCancellation = ExplicitCancellation.Enter(CancellationToken.None, Cancel))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tExecuteCommand(CommandBehavior.Default, false);\n\n\t\t\t\t// Gets\tonly the values\tof the first row or\n\t\t\t\t// the output parameters values if command is an Stored Procedure\n\t\t\t\tif (_statement.StatementType == DbStatementType.StoredProcedure)\n\t\t\t\t{\n\t\t\t\t\tvalues = _statement.GetOutputParameters();\n\t\t\t\t\tSetOutputParameters(values);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tvalues = _statement.Fetch();\n\t\t\t\t}\n\n\t\t\t\t// Get the return value\n\t\t\t\tif (values != null && values.Length > 0)\n\t\t\t\t{\n\t\t\t\t\tval = values[0].GetValue();\n\t\t\t\t}\n\n\t\t\t\tCommitImplicitTransaction();\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tRollbackImplicitTransaction();\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tRollbackImplicitTransaction();\n\t\t\t\tthrow;\n\t\t\t}\n\t\t}\n\n\t\treturn val;\n\t}\n\tpublic override async Task<object> ExecuteScalarAsync(CancellationToken cancellationToken)\n\t{\n\t\tDbValue[] values = null;\n\t\tobject val = null;\n\n\t\tCheckCommand();\n\n\t\tusing (var explicitCancellation = ExplicitCancellation.Enter(cancellationToken, Cancel))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait ExecuteCommandAsync(CommandBehavior.Default, false, explicitCancellation.CancellationToken).ConfigureAwait(false);\n\n\t\t\t\t// Gets\tonly the values\tof the first row or\n\t\t\t\t// the output parameters values if command is an Stored Procedure\n\t\t\t\tif (_statement.StatementType == DbStatementType.StoredProcedure)\n\t\t\t\t{\n\t\t\t\t\tvalues = _statement.GetOutputParameters();\n\t\t\t\t\tawait SetOutputParametersAsync(values, explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tvalues = await _statement.FetchAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\n\t\t\t\t// Get the return value\n\t\t\t\tif (values != null && values.Length > 0)\n\t\t\t\t{\n\t\t\t\t\tval = await values[0].GetValueAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\n\t\t\t\tawait CommitImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tawait RollbackImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tawait RollbackImplicitTransactionAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\tthrow;\n\t\t\t}\n\t\t}\n\n\t\treturn val;\n\t}\n\n\tpublic string GetCommandPlan()\n\t{\n\t\tif (_statement == null)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\treturn _statement.GetExecutionPlan();\n\t}\n\tpublic Task<string> GetCommandPlanAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_statement == null)\n\t\t{\n\t\t\treturn Task.FromResult<string>(null);\n\t\t}\n\t\treturn _statement.GetExecutionPlanAsync(cancellationToken).AsTask();\n\t}\n\n\tpublic string GetCommandExplainedPlan()\n\t{\n\t\tif (_statement == null)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\treturn _statement.GetExecutionExplainedPlan();\n\t}\n\tpublic Task<string> GetCommandExplainedPlanAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_statement == null)\n\t\t{\n\t\t\treturn Task.FromResult<string>(null);\n\t\t}\n\t\treturn _statement.GetExecutionExplainedPlanAsync(cancellationToken).AsTask();\n\t}\n\n\t#endregion\n\n\t#region DbCommand Protected Methods\n\n\tprotected override DbParameter CreateDbParameter()\n\t{\n\t\treturn CreateParameter();\n\t}\n\n\tprotected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)\n\t{\n\t\treturn ExecuteReader(behavior);\n\t}\n\tprotected override async Task<DbDataReader> ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)\n\t{\n\t\treturn await ExecuteReaderAsync(behavior, cancellationToken).ConfigureAwait(false);\n\t}\n\n\t#endregion\n\n\t#region Internal Methods\n\n\tinternal void DisposeReader()\n\t{\n\t\tif (_activeReader != null)\n\t\t{\n\t\t\t_activeReader.Dispose();\n\t\t\t_activeReader = null;\n\t\t}\n\t}\n\tinternal async Task DisposeReaderAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_activeReader != null)\n\t\t{\n\t\t\tawait _activeReader.DisposeAsync().ConfigureAwait(false);\n\t\t\t_activeReader = null;\n\t\t}\n\t}\n\n\tinternal DbValue[] Fetch()\n\t{\n\t\tif (_statement != null)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\treturn _statement.Fetch();\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\tinternal async Task<DbValue[]> FetchAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_statement != null)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\treturn await _statement.FetchAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch (IscException ex)\n\t\t\t{\n\t\t\t\tthrow FbException.Create(ex);\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\tinternal Descriptor GetFieldsDescriptor()\n\t{\n\t\tif (_statement != null)\n\t\t{\n\t\t\treturn _statement.Fields;\n\t\t}\n\t\treturn null;\n\t}\n\n\tinternal void SetOutputParameters()\n\t{\n\t\tSetOutputParameters(null);\n\t}\n\tinternal Task SetOutputParametersAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn SetOutputParametersAsync(null, cancellationToken);\n\t}\n\n\tinternal void SetOutputParameters(DbValue[] outputParameterValues)\n\t{\n\t\tif (Parameters.Count > 0 && _statement != null)\n\t\t{\n\t\t\tif (_statement != null &&\n\t\t\t\t_statement.StatementType == DbStatementType.StoredProcedure)\n\t\t\t{\n\t\t\t\tvar values = outputParameterValues;\n\t\t\t\tif (outputParameterValues == null)\n\t\t\t\t{\n\t\t\t\t\tvalues = _statement.GetOutputParameters();\n\t\t\t\t}\n\n\t\t\t\tif (values != null && values.Length > 0)\n\t\t\t\t{\n\t\t\t\t\tvar i = 0;\n\t\t\t\t\tforeach (FbParameter parameter in Parameters)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (parameter.Direction == ParameterDirection.Output ||\n\t\t\t\t\t\t\tparameter.Direction == ParameterDirection.InputOutput ||\n\t\t\t\t\t\t\tparameter.Direction == ParameterDirection.ReturnValue)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tparameter.Value = values[i].GetValue();\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tinternal async Task SetOutputParametersAsync(DbValue[] outputParameterValues, CancellationToken cancellationToken = default)\n\t{\n\t\tif (Parameters.Count > 0 && _statement != null)\n\t\t{\n\t\t\tif (_statement != null &&\n\t\t\t\t_statement.StatementType == DbStatementType.StoredProcedure)\n\t\t\t{\n\t\t\t\tvar values = outputParameterValues;\n\t\t\t\tif (outputParameterValues == null)\n\t\t\t\t{\n\t\t\t\t\tvalues = _statement.GetOutputParameters();\n\t\t\t\t}\n\n\t\t\t\tif (values != null && values.Length > 0)\n\t\t\t\t{\n\t\t\t\t\tvar i = 0;\n\t\t\t\t\tforeach (FbParameter parameter in Parameters)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (parameter.Direction == ParameterDirection.Output ||\n\t\t\t\t\t\t\tparameter.Direction == ParameterDirection.InputOutput ||\n\t\t\t\t\t\t\tparameter.Direction == ParameterDirection.ReturnValue)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tparameter.Value = await values[i].GetValueAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tinternal void CommitImplicitTransaction()\n\t{\n\t\tif (HasImplicitTransaction && _transaction != null && _transaction.Transaction != null)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\t_transaction.Commit();\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tRollbackImplicitTransaction();\n\n\t\t\t\tthrow;\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tif (_transaction != null)\n\t\t\t\t{\n\t\t\t\t\t_transaction.Dispose();\n\t\t\t\t\t_transaction = null;\n\t\t\t\t\t_implicitTransaction = false;\n\t\t\t\t}\n\n\t\t\t\tif (_statement != null)\n\t\t\t\t{\n\t\t\t\t\t_statement.Transaction = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tinternal async Task CommitImplicitTransactionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (HasImplicitTransaction && _transaction != null && _transaction.Transaction != null)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait _transaction.CommitAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tawait RollbackImplicitTransactionAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tthrow;\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tif (_transaction != null)\n\t\t\t\t{\n\t\t\t\t\tawait _transaction.DisposeAsync().ConfigureAwait(false);\n\t\t\t\t\t_transaction = null;\n\t\t\t\t\t_implicitTransaction = false;\n\t\t\t\t}\n\n\t\t\t\tif (_statement != null)\n\t\t\t\t{\n\t\t\t\t\t_statement.Transaction = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tinternal void RollbackImplicitTransaction()\n\t{\n\t\tif (HasImplicitTransaction && _transaction != null && _transaction.Transaction != null)\n\t\t{\n\t\t\tvar transactionCount = Connection.InnerConnection.Database.TransactionCount;\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\t_transaction.Rollback();\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tif (Connection.InnerConnection.Database.TransactionCount == transactionCount)\n\t\t\t\t{\n\t\t\t\t\tConnection.InnerConnection.Database.TransactionCount--;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\t_transaction.Dispose();\n\t\t\t\t_transaction = null;\n\t\t\t\t_implicitTransaction = false;\n\n\t\t\t\tif (_statement != null)\n\t\t\t\t{\n\t\t\t\t\t_statement.Transaction = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tinternal async Task RollbackImplicitTransactionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (HasImplicitTransaction && _transaction != null && _transaction.Transaction != null)\n\t\t{\n\t\t\tvar transactionCount = Connection.InnerConnection.Database.TransactionCount;\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait _transaction.RollbackAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tif (Connection.InnerConnection.Database.TransactionCount == transactionCount)\n\t\t\t\t{\n\t\t\t\t\tConnection.InnerConnection.Database.TransactionCount--;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait _transaction.DisposeAsync().ConfigureAwait(false);\n\t\t\t\t_transaction = null;\n\t\t\t\t_implicitTransaction = false;\n\n\t\t\t\tif (_statement != null)\n\t\t\t\t{\n\t\t\t\t\t_statement.Transaction = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tinternal void Close()\n\t{\n\t\tif (_statement != null)\n\t\t{\n\t\t\t_statement.Close();\n\t\t}\n\t}\n\tinternal Task CloseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_statement != null)\n\t\t{\n\t\t\treturn _statement.CloseAsync(cancellationToken).AsTask();\n\t\t}\n\t\treturn Task.CompletedTask;\n\t}\n\n\tvoid IFbPreparedCommand.Release() => Release();\n\tinternal void Release()\n\t{\n\t\tRollbackImplicitTransaction();\n\n\t\tDisposeReader();\n\n\t\tif (_connection != null && _connection.State == ConnectionState.Open)\n\t\t{\n\t\t\t_connection.InnerConnection.RemovePreparedCommand(this);\n\t\t}\n\n\t\tif (_statement != null)\n\t\t{\n\t\t\t_statement.Dispose2();\n\t\t\t_statement = null;\n\t\t}\n\t}\n\tTask IFbPreparedCommand.ReleaseAsync(CancellationToken cancellationToken) => ReleaseAsync(cancellationToken);\n\tinternal async Task ReleaseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tawait RollbackImplicitTransactionAsync(cancellationToken).ConfigureAwait(false);\n\n\t\tawait DisposeReaderAsync(cancellationToken).ConfigureAwait(false);\n\n\t\tif (_connection != null && _connection.State == ConnectionState.Open)\n\t\t{\n\t\t\t_connection.InnerConnection.RemovePreparedCommand(this);\n\t\t}\n\n\t\tif (_statement != null)\n\t\t{\n\t\t\tawait _statement.Dispose2Async(cancellationToken).ConfigureAwait(false);\n\t\t\t_statement = null;\n\t\t}\n\t}\n\n\tvoid IFbPreparedCommand.TransactionCompleted() => TransactionCompleted();\n\tinternal void TransactionCompleted()\n\t{\n\t\tif (Transaction != null)\n\t\t{\n\t\t\tDisposeReader();\n\t\t\tTransaction = null;\n\t\t}\n\t}\n\tTask IFbPreparedCommand.TransactionCompletedAsync(CancellationToken cancellationToken) => TransactionCompletedAsync(cancellationToken);\n\tinternal async Task TransactionCompletedAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (Transaction != null)\n\t\t{\n\t\t\tawait DisposeReaderAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tTransaction = null;\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region IDescriptorFiller\n\n\tvoid IDescriptorFiller.Fill(Descriptor descriptor, int index) => UpdateParameterValues(descriptor);\n\tprivate void UpdateParameterValues(Descriptor descriptor)\n\t{\n\t\tif (!HasParameters)\n\t\t\treturn;\n\n\t\tfor (var i = 0; i < descriptor.Count; i++)\n\t\t{\n\t\t\tvar parameter = descriptor[i];\n\t\t\tvar index = i;\n\n\t\t\tif (_namedParameters.Count > 0)\n\t\t\t{\n\t\t\t\tindex = _parameters.IndexOf(_namedParameters[i], i);\n\t\t\t\tif (index == -1)\n\t\t\t\t{\n\t\t\t\t\tthrow FbException.Create($\"Must declare the variable '{_namedParameters[i]}'.\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (index != -1)\n\t\t\t{\n\t\t\t\tvar commandParameter = _parameters[index];\n\t\t\t\tif (commandParameter.InternalValue == DBNull.Value || commandParameter.InternalValue == null)\n\t\t\t\t{\n\t\t\t\t\tparameter.NullFlag = -1;\n\t\t\t\t\tparameter.DbValue.SetValue(DBNull.Value);\n\n\t\t\t\t\tif (!parameter.AllowDBNull())\n\t\t\t\t\t{\n\t\t\t\t\t\tparameter.DataType++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tparameter.NullFlag = 0;\n\n\t\t\t\t\tswitch (parameter.DbDataType)\n\t\t\t\t\t{\n\t\t\t\t\t\tcase DbDataType.Binary:\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvar blob = _statement.CreateBlob();\n\t\t\t\t\t\t\t\tblob.Write((byte[])commandParameter.InternalValue);\n\t\t\t\t\t\t\t\tparameter.DbValue.SetValue(blob.Id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Text:\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvar blob = _statement.CreateBlob();\n\t\t\t\t\t\t\t\tif (commandParameter.InternalValue is byte[])\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tblob.Write((byte[])commandParameter.InternalValue);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tblob.Write((string)commandParameter.InternalValue);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tparameter.DbValue.SetValue(blob.Id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Array:\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (parameter.ArrayHandle == null)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tparameter.ArrayHandle = _statement.CreateArray(parameter.Relation, parameter.Name);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tparameter.ArrayHandle.Database = _statement.Database;\n\t\t\t\t\t\t\t\t\tparameter.ArrayHandle.Transaction = _statement.Transaction;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tparameter.ArrayHandle.Handle = 0;\n\t\t\t\t\t\t\t\tparameter.ArrayHandle.Write((Array)commandParameter.InternalValue);\n\t\t\t\t\t\t\t\tparameter.DbValue.SetValue(parameter.ArrayHandle.Handle);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Guid:\n\t\t\t\t\t\t\tif (!(commandParameter.InternalValue is Guid) && !(commandParameter.InternalValue is byte[]))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tthrow new InvalidOperationException(\"Incorrect Guid value.\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tparameter.DbValue.SetValue(commandParameter.InternalValue);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tparameter.DbValue.SetValue(commandParameter.InternalValue);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tValueTask IDescriptorFiller.FillAsync(Descriptor descriptor, int index, CancellationToken cancellationToken) => UpdateParameterValuesAsync(descriptor, cancellationToken);\n\tprivate async ValueTask UpdateParameterValuesAsync(Descriptor descriptor, CancellationToken cancellationToken = default)\n\t{\n\t\tif (!HasParameters)\n\t\t\treturn;\n\n\t\tfor (var i = 0; i < descriptor.Count; i++)\n\t\t{\n\t\t\tvar statementParameter = descriptor[i];\n\t\t\tvar index = i;\n\n\t\t\tif (_namedParameters.Count > 0)\n\t\t\t{\n\t\t\t\tindex = _parameters.IndexOf(_namedParameters[i], i);\n\t\t\t\tif (index == -1)\n\t\t\t\t{\n\t\t\t\t\tthrow FbException.Create($\"Must declare the variable '{_namedParameters[i]}'.\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (index != -1)\n\t\t\t{\n\t\t\t\tvar commandParameter = _parameters[index];\n\t\t\t\tif (commandParameter.InternalValue == DBNull.Value || commandParameter.InternalValue == null)\n\t\t\t\t{\n\t\t\t\t\tstatementParameter.NullFlag = -1;\n\t\t\t\t\tstatementParameter.DbValue.SetValue(DBNull.Value);\n\n\t\t\t\t\tif (!statementParameter.AllowDBNull())\n\t\t\t\t\t{\n\t\t\t\t\t\tstatementParameter.DataType++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tstatementParameter.NullFlag = 0;\n\n\t\t\t\t\tswitch (statementParameter.DbDataType)\n\t\t\t\t\t{\n\t\t\t\t\t\tcase DbDataType.Binary:\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvar blob = _statement.CreateBlob();\n\t\t\t\t\t\t\t\tawait blob.WriteAsync((byte[])commandParameter.InternalValue, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\t\tstatementParameter.DbValue.SetValue(blob.Id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Text:\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvar blob = _statement.CreateBlob();\n\t\t\t\t\t\t\t\tif (commandParameter.InternalValue is byte[])\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tawait blob.WriteAsync((byte[])commandParameter.InternalValue, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tawait blob.WriteAsync((string)commandParameter.InternalValue, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tstatementParameter.DbValue.SetValue(blob.Id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Array:\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (statementParameter.ArrayHandle == null)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tstatementParameter.ArrayHandle = await _statement.CreateArrayAsync(statementParameter.Relation, statementParameter.Name, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tstatementParameter.ArrayHandle.Database = _statement.Database;\n\t\t\t\t\t\t\t\t\tstatementParameter.ArrayHandle.Transaction = _statement.Transaction;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tstatementParameter.ArrayHandle.Handle = 0;\n\t\t\t\t\t\t\t\tawait statementParameter.ArrayHandle.WriteAsync((Array)commandParameter.InternalValue, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t\t\tstatementParameter.DbValue.SetValue(statementParameter.ArrayHandle.Handle);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase DbDataType.Guid:\n\t\t\t\t\t\t\tif (!(commandParameter.InternalValue is Guid) && !(commandParameter.InternalValue is byte[]))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tthrow new InvalidOperationException(\"Incorrect Guid value.\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tstatementParameter.DbValue.SetValue(commandParameter.InternalValue);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tstatementParameter.DbValue.SetValue(commandParameter.InternalValue);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void Prepare(bool returnsSet)\n\t{\n\t\tvar innerConn = _connection.InnerConnection;\n\n\t\t// Check if\twe have\ta valid\ttransaction\n\t\tif (_transaction == null)\n\t\t{\n\t\t\tif (innerConn.IsEnlisted)\n\t\t\t{\n\t\t\t\t_transaction = innerConn.ActiveTransaction;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_implicitTransaction = true;\n\t\t\t\t_transaction = new FbTransaction(_connection, _connection.ConnectionOptions.IsolationLevel);\n\t\t\t\t_transaction.BeginTransaction();\n\n\t\t\t\t// Update Statement\ttransaction\n\t\t\t\tif (_statement != null)\n\t\t\t\t{\n\t\t\t\t\t_statement.Transaction = _transaction.Transaction;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Check if\twe have\ta valid\tstatement handle\n\t\tif (_statement == null)\n\t\t{\n\t\t\t_statement = innerConn.Database.CreateStatement(_transaction.Transaction);\n\t\t}\n\n\t\t// Prepare the statement if\tneeded\n\t\tif (!_statement.IsPrepared)\n\t\t{\n\t\t\t// Close the inner DataReader if needed\n\t\t\tDisposeReader();\n\n\t\t\t// Reformat the SQL statement if needed\n\t\t\tvar sql = _commandText;\n\n\t\t\tif (_commandType == CommandType.StoredProcedure)\n\t\t\t{\n\t\t\t\tsql = BuildStoredProcedureSql(sql, returnsSet);\n\t\t\t}\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\t(sql, _namedParameters) = NamedParametersParser.Parse(sql);\n\t\t\t\t// Try to prepare the command\n\t\t\t\t_statement.Prepare(sql);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\t// Release the statement and rethrow the exception\n\t\t\t\t_statement.Release();\n\t\t\t\t_statement = null;\n\n\t\t\t\tthrow;\n\t\t\t}\n\n\t\t\t// Add this\tcommand\tto the active command list\n\t\t\tinnerConn.AddPreparedCommand(this);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// Close statement for subsequently\texecutions\n\t\t\tClose();\n\t\t}\n\t}\n\tprivate async Task PrepareAsync(bool returnsSet, CancellationToken cancellationToken = default)\n\t{\n\t\tvar innerConn = _connection.InnerConnection;\n\n\t\t// Check if\twe have\ta valid\ttransaction\n\t\tif (_transaction == null)\n\t\t{\n\t\t\tif (innerConn.IsEnlisted)\n\t\t\t{\n\t\t\t\t_transaction = innerConn.ActiveTransaction;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_implicitTransaction = true;\n\t\t\t\t_transaction = new FbTransaction(_connection, _connection.ConnectionOptions.IsolationLevel);\n\t\t\t\tawait _transaction.BeginTransactionAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\t// Update Statement\ttransaction\n\t\t\t\tif (_statement != null)\n\t\t\t\t{\n\t\t\t\t\t_statement.Transaction = _transaction.Transaction;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Check if\twe have\ta valid\tstatement handle\n\t\tif (_statement == null)\n\t\t{\n\t\t\t_statement = innerConn.Database.CreateStatement(_transaction.Transaction);\n\t\t}\n\n\t\t// Prepare the statement if\tneeded\n\t\tif (!_statement.IsPrepared)\n\t\t{\n\t\t\t// Close the inner DataReader if needed\n\t\t\tawait DisposeReaderAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t// Reformat the SQL statement if needed\n\t\t\tvar sql = _commandText;\n\n\t\t\tif (_commandType == CommandType.StoredProcedure)\n\t\t\t{\n\t\t\t\tsql = BuildStoredProcedureSql(sql, returnsSet);\n\t\t\t}\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\t(sql, _namedParameters) = NamedParametersParser.Parse(sql);\n\t\t\t\t// Try to prepare the command\n\t\t\t\tawait _statement.PrepareAsync(sql, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\t// Release the statement and rethrow the exception\n\t\t\t\tawait _statement.ReleaseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t_statement = null;\n\n\t\t\t\tthrow;\n\t\t\t}\n\n\t\t\t// Add this\tcommand\tto the active command list\n\t\t\tinnerConn.AddPreparedCommand(this);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// Close statement for subsequently\texecutions\n\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\tprivate void ExecuteCommand(CommandBehavior behavior, bool returnsSet)\n\t{\n\t\tLogMessages.CommandExecution(Log, this);\n\n\t\tPrepare(returnsSet);\n\n\t\tif ((behavior & CommandBehavior.SequentialAccess) == CommandBehavior.SequentialAccess ||\n\t\t\t(behavior & CommandBehavior.SingleResult) == CommandBehavior.SingleResult ||\n\t\t\t(behavior & CommandBehavior.SingleRow) == CommandBehavior.SingleRow ||\n\t\t\t(behavior & CommandBehavior.CloseConnection) == CommandBehavior.CloseConnection ||\n\t\t\tbehavior == CommandBehavior.Default)\n\t\t{\n\t\t\t// Set the fetch size\n\t\t\t_statement.FetchSize = _fetchSize;\n\n\t\t\t// Set if it's needed the Records Affected information\n\t\t\t_statement.ReturnRecordsAffected = _connection.ConnectionOptions.ReturnRecordsAffected;\n\n\t\t\t// Validate input parameter count\n\t\t\tif (_namedParameters.Count > 0 && !HasParameters)\n\t\t\t{\n\t\t\t\tthrow FbException.Create(\"Must declare command parameters.\");\n\t\t\t}\n\n\t\t\t// Execute\n\t\t\t_statement.Execute(CommandTimeout * 1000, this);\n\t\t}\n\t}\n\tprivate async Task ExecuteCommandAsync(CommandBehavior behavior, bool returnsSet, CancellationToken cancellationToken = default)\n\t{\n\t\tLogMessages.CommandExecution(Log, this);\n\n\t\tawait PrepareAsync(returnsSet, cancellationToken).ConfigureAwait(false);\n\n\t\tif ((behavior & CommandBehavior.SequentialAccess) == CommandBehavior.SequentialAccess ||\n\t\t\t(behavior & CommandBehavior.SingleResult) == CommandBehavior.SingleResult ||\n\t\t\t(behavior & CommandBehavior.SingleRow) == CommandBehavior.SingleRow ||\n\t\t\t(behavior & CommandBehavior.CloseConnection) == CommandBehavior.CloseConnection ||\n\t\t\tbehavior == CommandBehavior.Default)\n\t\t{\n\t\t\t// Set the fetch size\n\t\t\t_statement.FetchSize = _fetchSize;\n\n\t\t\t// Set if it's needed the Records Affected information\n\t\t\t_statement.ReturnRecordsAffected = _connection.ConnectionOptions.ReturnRecordsAffected;\n\n\t\t\t// Validate input parameter count\n\t\t\tif (_namedParameters.Count > 0 && !HasParameters)\n\t\t\t{\n\t\t\t\tthrow FbException.Create(\"Must declare command parameters.\");\n\t\t\t}\n\n\t\t\t// Execute\n\t\t\tawait _statement.ExecuteAsync(CommandTimeout * 1000, this, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\tprivate string BuildStoredProcedureSql(string spName, bool returnsSet)\n\t{\n\t\tvar sql = spName == null ? string.Empty : spName.Trim();\n\n\t\tif (sql.Length > 0 &&\n\t\t\t!sql.StartsWith(\"EXECUTE PROCEDURE \", StringComparison.InvariantCultureIgnoreCase) &&\n\t\t\t!sql.StartsWith(\"SELECT \", StringComparison.InvariantCultureIgnoreCase))\n\t\t{\n\t\t\tvar paramsText = new StringBuilder();\n\n\t\t\t// Append the stored proc parameter\tname\n\t\t\tparamsText.Append(sql);\n\t\t\tif (Parameters.Count > 0)\n\t\t\t{\n\t\t\t\tparamsText.Append(\"(\");\n\t\t\t\tfor (var i = 0; i < Parameters.Count; i++)\n\t\t\t\t{\n\t\t\t\t\tif (Parameters[i].Direction == ParameterDirection.Input ||\n\t\t\t\t\t\tParameters[i].Direction == ParameterDirection.InputOutput)\n\t\t\t\t\t{\n\t\t\t\t\t\t// Append parameter\tname to parameter list\n\t\t\t\t\t\tparamsText.Append(Parameters[i].InternalParameterName);\n\t\t\t\t\t\tif (i != Parameters.Count - 1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tparamsText = paramsText.Append(\",\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tparamsText.Append(\")\");\n\t\t\t\tparamsText.Replace(\",)\", \")\");\n\t\t\t\tparamsText.Replace(\"()\", string.Empty);\n\t\t\t}\n\n\t\t\tif (returnsSet)\n\t\t\t{\n\t\t\t\tsql = \"select * from \" + paramsText.ToString();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tsql = \"execute procedure \" + paramsText.ToString();\n\t\t\t}\n\t\t}\n\n\t\treturn sql;\n\t}\n\n\tprivate void CheckCommand()\n\t{\n\t\tif (_transaction != null && _transaction.IsCompleted)\n\t\t{\n\t\t\t_transaction = null;\n\t\t}\n\n\t\tFbConnection.EnsureOpen(_connection);\n\n\t\tif (_activeReader != null)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"There is already an open DataReader associated with this Command which must be closed first.\");\n\t\t}\n\n\t\tif (_transaction == null &&\n\t\t\t_connection.InnerConnection.HasActiveTransaction &&\n\t\t\t!_connection.InnerConnection.IsEnlisted)\n\t\t{\n\t\t\tthrow 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.\");\n\t\t}\n\n\t\tif (_transaction != null && !_transaction.IsCompleted &&\n\t\t\t!_connection.Equals(_transaction.Connection))\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Command Connection is not equal to Transaction Connection.\");\n\t\t}\n\n\t\tif (_commandText == null || _commandText.Length == 0)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"The command text for this Command has not been set.\");\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbCommandBuilder.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Data.Common;\nusing System.Globalization;\nusing System.Text;\n\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic sealed class FbCommandBuilder : DbCommandBuilder\n{\n\t#region Static Methods\n\n\tpublic static void DeriveParameters(FbCommand command)\n\t{\n\t\tif (command.CommandType != CommandType.StoredProcedure)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"DeriveParameters only supports CommandType.StoredProcedure.\");\n\t\t}\n\n\t\tvar spName = command.CommandText.Trim();\n\t\tvar quotePrefix = \"\\\"\";\n\t\tvar quoteSuffix = \"\\\"\";\n\n\t\tif (spName.StartsWith(quotePrefix) && spName.EndsWith(quoteSuffix))\n\t\t{\n\t\t\tspName = spName.Substring(1, spName.Length - 2);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tspName = spName.ToUpperInvariant();\n\t\t}\n\n\t\tvar paramsText = string.Empty;\n\n\t\tcommand.Parameters.Clear();\n\n\t\tvar dataTypes = command.Connection.GetSchema(\"DataTypes\").DefaultView;\n\n\t\tvar spSchema = command.Connection.GetSchema(\n\t\t\t\"ProcedureParameters\", new string[] { null, null, spName });\n\n\t\t// SP has zero params. or not exist\n\t\t// so check whether exists, else thow exception\n\t\tif (spSchema.Rows.Count == 0)\n\t\t{\n\t\t\tif (command.Connection.GetSchema(\"Procedures\", new string[] { null, null, spName }).Rows.Count == 0)\n\t\t\t\tthrow new InvalidOperationException(\"Stored procedure doesn't exist.\");\n\t\t}\n\n\t\tforeach (DataRow row in spSchema.Rows)\n\t\t{\n\t\t\tdataTypes.RowFilter = string.Format(\n\t\t\t\t\"TypeName = '{0}'\",\n\t\t\t\trow[\"PARAMETER_DATA_TYPE\"]);\n\n\t\t\tvar parameter = command.Parameters.Add(\n\t\t\t\t\"@\" + row[\"PARAMETER_NAME\"].ToString().Trim(),\n\t\t\t\tFbDbType.VarChar);\n\n\t\t\tparameter.FbDbType = (FbDbType)dataTypes[0][\"ProviderDbType\"];\n\n\t\t\tparameter.Direction = (ParameterDirection)row[\"PARAMETER_DIRECTION\"];\n\n\t\t\tparameter.Size = Convert.ToInt32(row[\"PARAMETER_SIZE\"], CultureInfo.InvariantCulture);\n\n\t\t\tif (parameter.FbDbType == FbDbType.Decimal ||\n\t\t\t\tparameter.FbDbType == FbDbType.Numeric)\n\t\t\t{\n\t\t\t\tif (row[\"NUMERIC_PRECISION\"] != DBNull.Value)\n\t\t\t\t{\n\t\t\t\t\tparameter.Precision = Convert.ToByte(row[\"NUMERIC_PRECISION\"], CultureInfo.InvariantCulture);\n\t\t\t\t}\n\t\t\t\tif (row[\"NUMERIC_SCALE\"] != DBNull.Value)\n\t\t\t\t{\n\t\t\t\t\tparameter.Scale = Convert.ToByte(row[\"NUMERIC_SCALE\"], CultureInfo.InvariantCulture);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Fields\n\n\tprivate EventHandler<FbRowUpdatingEventArgs> _rowUpdatingHandler;\n\n\t#endregion\n\n\t#region Properties\n\n\t[Browsable(false)]\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\t[EditorBrowsable(EditorBrowsableState.Never)]\n\tpublic override string QuotePrefix\n\t{\n\t\tget { return base.QuotePrefix; }\n\t\tset\n\t\t{\n\t\t\tif (string.IsNullOrEmpty(value))\n\t\t\t{\n\t\t\t\tbase.QuotePrefix = value;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tbase.QuotePrefix = \"\\\"\";\n\t\t\t}\n\t\t}\n\t}\n\n\t[Browsable(false)]\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\t[EditorBrowsable(EditorBrowsableState.Never)]\n\tpublic override string QuoteSuffix\n\t{\n\t\tget { return base.QuoteSuffix; }\n\t\tset\n\t\t{\n\t\t\tif (string.IsNullOrEmpty(value))\n\t\t\t{\n\t\t\t\tbase.QuoteSuffix = value;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tbase.QuoteSuffix = \"\\\"\";\n\t\t\t}\n\t\t}\n\t}\n\n\t[DefaultValue(null)]\n\tpublic new FbDataAdapter DataAdapter\n\t{\n\t\tget { return (FbDataAdapter)base.DataAdapter; }\n\t\tset { base.DataAdapter = value; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FbCommandBuilder()\n\t\t: this(null)\n\t{\n\t}\n\n\tpublic FbCommandBuilder(FbDataAdapter adapter)\n\t\t: base()\n\t{\n\t\tDataAdapter = adapter;\n\t\tQuotePrefix = \"\\\"\";\n\t\tQuoteSuffix = \"\\\"\";\n\t\tConflictOption = ConflictOption.OverwriteChanges;\n\t}\n\n\t#endregion\n\n\t#region DbCommandBuilder methods\n\n\tpublic new FbCommand GetInsertCommand()\n\t{\n\t\treturn base.GetInsertCommand() as FbCommand;\n\t}\n\n\tpublic new FbCommand GetInsertCommand(bool useColumnsForParameterNames)\n\t{\n\t\treturn base.GetInsertCommand(useColumnsForParameterNames) as FbCommand;\n\t}\n\n\tpublic new FbCommand GetUpdateCommand()\n\t{\n\t\treturn base.GetUpdateCommand() as FbCommand;\n\t}\n\n\tpublic new FbCommand GetUpdateCommand(bool useColumnsForParameterNames)\n\t{\n\t\treturn base.GetUpdateCommand(useColumnsForParameterNames) as FbCommand;\n\t}\n\n\tpublic new FbCommand GetDeleteCommand()\n\t{\n\t\treturn base.GetDeleteCommand() as FbCommand;\n\t}\n\n\tpublic new FbCommand GetDeleteCommand(bool useColumnsForParameterNames)\n\t{\n\t\treturn base.GetDeleteCommand(useColumnsForParameterNames) as FbCommand;\n\t}\n\n\tpublic override string QuoteIdentifier(string unquotedIdentifier)\n\t{\n\t\tif (unquotedIdentifier == null)\n\t\t{\n\t\t\tthrow new ArgumentNullException(\"Unquoted identifier parameter cannot be null\");\n\t\t}\n\n\t\treturn string.Format(\"{0}{1}{2}\", QuotePrefix, unquotedIdentifier, QuoteSuffix);\n\t}\n\n\tpublic override string UnquoteIdentifier(string quotedIdentifier)\n\t{\n\t\tif (quotedIdentifier == null)\n\t\t{\n\t\t\tthrow new ArgumentNullException(\"Quoted identifier parameter cannot be null\");\n\t\t}\n\n\t\tvar unquotedIdentifier = quotedIdentifier.Trim();\n\n\t\tif (unquotedIdentifier.StartsWith(QuotePrefix))\n\t\t{\n\t\t\tunquotedIdentifier = unquotedIdentifier.Remove(0, 1);\n\t\t}\n\t\tif (unquotedIdentifier.EndsWith(QuoteSuffix))\n\t\t{\n\t\t\tunquotedIdentifier = unquotedIdentifier.Remove(unquotedIdentifier.Length - 1, 1);\n\t\t}\n\n\t\treturn unquotedIdentifier;\n\t}\n\n\t#endregion\n\n\t#region Protected DbCommandBuilder methods\n\n\tprotected override void ApplyParameterInfo(DbParameter p, DataRow row, StatementType statementType, bool whereClause)\n\t{\n\t\tvar parameter = (FbParameter)p;\n\n\t\tparameter.Size = int.Parse(row[\"ColumnSize\"].ToString());\n\t\tif (row[\"NumericPrecision\"] != DBNull.Value)\n\t\t{\n\t\t\tparameter.Precision = byte.Parse(row[\"NumericPrecision\"].ToString());\n\t\t}\n\t\tif (row[\"NumericScale\"] != DBNull.Value)\n\t\t{\n\t\t\tparameter.Scale = byte.Parse(row[\"NumericScale\"].ToString());\n\t\t}\n\t\tparameter.FbDbType = (FbDbType)row[\"ProviderType\"];\n\t}\n\n\tprotected override string GetParameterName(int parameterOrdinal)\n\t{\n\t\treturn string.Format(\"@p{0}\", parameterOrdinal);\n\t}\n\n\tprotected override string GetParameterName(string parameterName)\n\t{\n\t\treturn string.Format(\"@{0}\", parameterName);\n\t}\n\n\tprotected override string GetParameterPlaceholder(int parameterOrdinal)\n\t{\n\t\treturn GetParameterName(parameterOrdinal);\n\t}\n\n\tprotected override void SetRowUpdatingHandler(DbDataAdapter adapter)\n\t{\n\t\tif (!(adapter is FbDataAdapter))\n\t\t{\n\t\t\tthrow new ArgumentException($\"Argument needs to be a {nameof(FbDataAdapter)}.\", nameof(adapter));\n\t\t}\n\n\t\t_rowUpdatingHandler = new EventHandler<FbRowUpdatingEventArgs>(RowUpdatingHandler);\n\t\t((FbDataAdapter)adapter).RowUpdating += _rowUpdatingHandler;\n\t}\n\n\t#endregion\n\n\t#region Event Handlers\n\n\tprivate void RowUpdatingHandler(object sender, FbRowUpdatingEventArgs e)\n\t{\n\t\tbase.RowUpdatingHandler(e);\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbConnection.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Data.Common;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.Logging;\nusing Microsoft.Extensions.Logging;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\n[DefaultEvent(\"InfoMessage\")]\npublic sealed class FbConnection : DbConnection, ICloneable\n{\n\tstatic readonly ILogger<FbConnection> Log = FbLogManager.CreateLogger<FbConnection>();\n\n\t#region Static Pool Handling Methods\n\n\tpublic static void ClearAllPools()\n\t{\n\t\tFbConnectionPoolManager.Instance.ClearAllPools();\n\t}\n\n\tpublic static void ClearPool(FbConnection connection)\n\t{\n\t\tif (connection == null)\n\t\t\tthrow new ArgumentNullException(nameof(connection));\n\n\t\tFbConnectionPoolManager.Instance.ClearPool(connection.ConnectionOptions);\n\t}\n\n\tpublic static void ClearPool(string connectionString)\n\t{\n\t\tif (connectionString == null)\n\t\t\tthrow new ArgumentNullException(nameof(connectionString));\n\n\t\tFbConnectionPoolManager.Instance.ClearPool(new ConnectionString(connectionString));\n\t}\n\n\t#endregion\n\n\t#region Static Database Creation/Drop methods\n\n\tpublic static void CreateDatabase(string connectionString, int pageSize = 4096, bool forcedWrites = true, bool overwrite = false)\n\t{\n\t\tvar options = new ConnectionString(connectionString);\n\t\toptions.Validate();\n\n\t\ttry\n\t\t{\n\t\t\tvar db = new FbConnectionInternal(options);\n\t\t\ttry\n\t\t\t{\n\t\t\t\tdb.CreateDatabase(pageSize, forcedWrites, overwrite);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tdb.Disconnect();\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic static async Task CreateDatabaseAsync(string connectionString, int pageSize = 4096, bool forcedWrites = true, bool overwrite = false, CancellationToken cancellationToken = default)\n\t{\n\t\tvar options = new ConnectionString(connectionString);\n\t\toptions.Validate();\n\n\t\ttry\n\t\t{\n\t\t\tvar db = new FbConnectionInternal(options);\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait db.CreateDatabaseAsync(pageSize, forcedWrites, overwrite, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait db.DisconnectAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic static void DropDatabase(string connectionString)\n\t{\n\t\tvar options = new ConnectionString(connectionString);\n\t\toptions.Validate();\n\n\t\ttry\n\t\t{\n\t\t\tvar db = new FbConnectionInternal(options);\n\t\t\ttry\n\t\t\t{\n\t\t\t\tdb.DropDatabase();\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tdb.Disconnect();\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic static async Task DropDatabaseAsync(string connectionString, CancellationToken cancellationToken = default)\n\t{\n\t\tvar options = new ConnectionString(connectionString);\n\t\toptions.Validate();\n\n\t\ttry\n\t\t{\n\t\t\tvar db = new FbConnectionInternal(options);\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait db.DropDatabaseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait db.DisconnectAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Events\n\n\tpublic override event StateChangeEventHandler StateChange;\n\n\tpublic event EventHandler<FbInfoMessageEventArgs> InfoMessage;\n\n\t#endregion\n\n\t#region Fields\n\n\tprivate FbConnectionInternal _innerConnection;\n\tprivate ConnectionState _state;\n\tprivate ConnectionString _options;\n\tprivate bool _disposed;\n\tprivate string _connectionString;\n\n\t#endregion\n\n\t#region Properties\n\n\t[Category(\"Data\")]\n\t[SettingsBindable(true)]\n\t[RefreshProperties(RefreshProperties.All)]\n\t[DefaultValue(\"\")]\n\tpublic override string ConnectionString\n\t{\n\t\tget { return _connectionString; }\n\t\tset\n\t\t{\n\t\t\tif (_state == ConnectionState.Closed)\n\t\t\t{\n\t\t\t\tif (value == null)\n\t\t\t\t{\n\t\t\t\t\tvalue = string.Empty;\n\t\t\t\t}\n\n\t\t\t\t_options = new ConnectionString(value);\n\t\t\t\t_options.Validate();\n\t\t\t\t_connectionString = value;\n\t\t\t}\n\t\t}\n\t}\n\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\tpublic override int ConnectionTimeout\n\t{\n\t\tget { return _options.ConnectionTimeout; }\n\t}\n\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\tpublic override string Database\n\t{\n\t\tget { return _options.Database; }\n\t}\n\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\tpublic override string DataSource\n\t{\n\t\tget { return _options.DataSource; }\n\t}\n\n\t[Browsable(false)]\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\tpublic override string ServerVersion\n\t{\n\t\tget\n\t\t{\n\t\t\tif (_state == ConnectionState.Closed)\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException(\"The connection is closed.\");\n\t\t\t}\n\n\t\t\tif (_innerConnection != null)\n\t\t\t{\n\t\t\t\treturn _innerConnection.Database.ServerVersion;\n\t\t\t}\n\n\t\t\treturn string.Empty;\n\t\t}\n\t}\n\n\t[Browsable(false)]\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\tpublic override ConnectionState State\n\t{\n\t\tget { return _state; }\n\t}\n\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\tpublic int PacketSize\n\t{\n\t\tget { return _options.PacketSize; }\n\t}\n\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\tpublic int CommandTimeout\n\t{\n\t\tget { return _options.CommandTimeout; }\n\t}\n\n\t#endregion\n\n\t#region Internal Properties\n\n\tinternal FbConnectionInternal InnerConnection\n\t{\n\t\tget { return _innerConnection; }\n\t}\n\n\tinternal ConnectionString ConnectionOptions\n\t{\n\t\tget { return _options; }\n\t}\n\n\tinternal bool IsClosed\n\t{\n\t\tget { return _state == ConnectionState.Closed; }\n\t}\n\n\t#endregion\n\n\t#region Protected Properties\n\n\tprotected override DbProviderFactory DbProviderFactory\n\t{\n\t\tget { return FirebirdClientFactory.Instance; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FbConnection()\n\t{\n\t\t_options = new ConnectionString();\n\t\t_state = ConnectionState.Closed;\n\t\t_connectionString = string.Empty;\n\t}\n\n\tpublic FbConnection(string connectionString)\n\t\t: this()\n\t{\n\t\tif (!string.IsNullOrEmpty(connectionString))\n\t\t{\n\t\t\tConnectionString = connectionString;\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region IDisposable, IAsyncDisposable methods\n\n\tprotected override void Dispose(bool disposing)\n\t{\n\t\tif (disposing)\n\t\t{\n\t\t\tif (!_disposed)\n\t\t\t{\n\t\t\t\t_disposed = true;\n\t\t\t\tClose();\n\t\t\t\t_innerConnection = null;\n\t\t\t}\n\t\t}\n\t\tbase.Dispose(disposing);\n\t}\n\tpublic override async ValueTask DisposeAsync()\n\t{\n\t\tif (!_disposed)\n\t\t{\n\t\t\t_disposed = true;\n\t\t\tawait CloseAsync().ConfigureAwait(false);\n\t\t\t_innerConnection = null;\n\t\t}\n\t\tawait base.DisposeAsync().ConfigureAwait(false);\n\t}\n\n\t#endregion\n\n\t#region ICloneable Methods\n\n\tobject ICloneable.Clone()\n\t{\n\t\treturn new FbConnection(ConnectionString);\n\t}\n\n\t#endregion\n\n\t#region Transaction Handling Methods\n\n\tpublic new FbTransaction BeginTransaction() => BeginTransaction(FbTransaction.DefaultIsolationLevel, null);\n\tpublic new Task<FbTransaction> BeginTransactionAsync(CancellationToken cancellationToken = default)\n\t\t\t=> BeginTransactionAsync(FbTransaction.DefaultIsolationLevel, null, cancellationToken);\n\n\tpublic new FbTransaction BeginTransaction(IsolationLevel level) => BeginTransaction(level, null);\n\tpublic new Task<FbTransaction> BeginTransactionAsync(IsolationLevel level, CancellationToken cancellationToken = default)\n\t\t\t=> BeginTransactionAsync(level, null, cancellationToken);\n\n\tpublic FbTransaction BeginTransaction(string transactionName) => BeginTransaction(FbTransaction.DefaultIsolationLevel, transactionName);\n\tpublic Task<FbTransaction> BeginTransactionAsync(string transactionName, CancellationToken cancellationToken = default) => BeginTransactionAsync(FbTransaction.DefaultIsolationLevel, transactionName, cancellationToken);\n\n\tpublic FbTransaction BeginTransaction(IsolationLevel level, string transactionName)\n\t{\n\t\tCheckClosed();\n\n\t\treturn _innerConnection.BeginTransaction(level, transactionName);\n\t}\n\tpublic Task<FbTransaction> BeginTransactionAsync(IsolationLevel level, string transactionName, CancellationToken cancellationToken = default)\n\t{\n\t\tCheckClosed();\n\n\t\treturn _innerConnection.BeginTransactionAsync(level, transactionName, cancellationToken);\n\t}\n\n\tpublic FbTransaction BeginTransaction(FbTransactionOptions options) => BeginTransaction(options, null);\n\tpublic Task<FbTransaction> BeginTransactionAsync(FbTransactionOptions options, CancellationToken cancellationToken = default) => BeginTransactionAsync(options, null, cancellationToken);\n\n\tpublic FbTransaction BeginTransaction(FbTransactionOptions options, string transactionName)\n\t{\n\t\tCheckClosed();\n\n\t\treturn _innerConnection.BeginTransaction(options, transactionName);\n\t}\n\tpublic Task<FbTransaction> BeginTransactionAsync(FbTransactionOptions options, string transactionName, CancellationToken cancellationToken = default)\n\t{\n\t\tCheckClosed();\n\n\t\treturn _innerConnection.BeginTransactionAsync(options, transactionName, cancellationToken);\n\t}\n\n\tprotected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) => BeginTransaction(isolationLevel);\n\tprotected override async ValueTask<DbTransaction> BeginDbTransactionAsync(IsolationLevel isolationLevel, CancellationToken cancellationToken) => await BeginTransactionAsync(isolationLevel, cancellationToken).ConfigureAwait(false);\n\n\t#endregion\n\n\t#region Transaction Enlistement\n\n\tpublic override void EnlistTransaction(System.Transactions.Transaction transaction)\n\t{\n\t\tCheckClosed();\n\n\t\tif (transaction == null)\n\t\t\treturn;\n\n\t\t_innerConnection.EnlistTransaction(transaction);\n\t}\n\n\t#endregion\n\n\t#region Database Schema Methods\n\n\tpublic override DataTable GetSchema()\n\t{\n\t\treturn GetSchema(\"MetaDataCollections\");\n\t}\n\tpublic override Task<DataTable> GetSchemaAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetSchemaAsync(\"MetaDataCollections\", cancellationToken);\n\t}\n\n\tpublic override DataTable GetSchema(string collectionName)\n\t{\n\t\treturn GetSchema(collectionName, null);\n\t}\n\tpublic override Task<DataTable> GetSchemaAsync(string collectionName, CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetSchemaAsync(collectionName, null, cancellationToken);\n\t}\n\tpublic override DataTable GetSchema(string collectionName, string[] restrictions)\n\t{\n\t\tCheckClosed();\n\n\t\treturn _innerConnection.GetSchema(collectionName, restrictions);\n\t}\n\tpublic override Task<DataTable> GetSchemaAsync(string collectionName, string[] restrictions, CancellationToken cancellationToken = default)\n\t{\n\t\tCheckClosed();\n\n\t\treturn _innerConnection.GetSchemaAsync(collectionName, restrictions, cancellationToken);\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic new FbCommand CreateCommand()\n\t{\n\t\treturn (FbCommand)CreateDbCommand();\n\t}\n\n\tprotected override DbCommand CreateDbCommand()\n\t{\n\t\treturn new FbCommand(null, this);\n\t}\n\n\tpublic new DbBatch CreateBatch()\n\t{\n\t\tthrow new NotSupportedException(\"DbBatch is currently not supported. Use FbBatchCommand instead.\");\n\t}\n\n\tprotected override DbBatch CreateDbBatch()\n\t{\n\t\treturn CreateBatch();\n\t}\n\n\tpublic FbBatchCommand CreateBatchCommand()\n\t{\n\t\treturn new FbBatchCommand(null, this);\n\t}\n\n\tpublic override void ChangeDatabase(string databaseName)\n\t{\n\t\tCheckClosed();\n\n\t\tif (string.IsNullOrEmpty(databaseName))\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Database name is not valid.\");\n\t\t}\n\n\t\tvar oldConnectionString = _connectionString;\n\t\ttry\n\t\t{\n\t\t\tvar csb = new FbConnectionStringBuilder(_connectionString);\n\n\t\t\t/* Close current connection\t*/\n\t\t\tClose();\n\n\t\t\t/* Set up the new Database\t*/\n\t\t\tcsb.Database = databaseName;\n\t\t\tConnectionString = csb.ToString();\n\n\t\t\t/* Open\tnew\tconnection\t*/\n\t\t\tOpen();\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tConnectionString = oldConnectionString;\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic override async Task ChangeDatabaseAsync(string databaseName, CancellationToken cancellationToken = default)\n\t{\n\t\tCheckClosed();\n\n\t\tif (string.IsNullOrEmpty(databaseName))\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Database name is not valid.\");\n\t\t}\n\n\t\tvar oldConnectionString = _connectionString;\n\t\ttry\n\t\t{\n\t\t\tvar csb = new FbConnectionStringBuilder(_connectionString);\n\n\t\t\t/* Close current connection\t*/\n\t\t\tawait CloseAsync().ConfigureAwait(false);\n\n\t\t\t/* Set up the new Database\t*/\n\t\t\tcsb.Database = databaseName;\n\t\t\tConnectionString = csb.ToString();\n\n\t\t\t/* Open\tnew\tconnection\t*/\n\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tConnectionString = oldConnectionString;\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic override void Open()\n\t{\n\t\tLogMessages.ConnectionOpening(Log, this);\n\n\t\tif (string.IsNullOrEmpty(_connectionString))\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Connection String is not initialized.\");\n\t\t}\n\t\tif (!IsClosed && _state != ConnectionState.Connecting)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Connection already Open.\");\n\t\t}\n\n\t\ttry\n\t\t{\n\t\t\tOnStateChange(_state, ConnectionState.Connecting);\n\n\t\t\tvar createdNew = default(bool);\n\t\t\tif (_options.Pooling)\n\t\t\t{\n\t\t\t\t_innerConnection = FbConnectionPoolManager.Instance.Get(_options, out createdNew);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_innerConnection = new FbConnectionInternal(_options);\n\t\t\t\tcreatedNew = true;\n\t\t\t}\n\t\t\tif (createdNew)\n\t\t\t{\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\ttry\n\t\t\t\t\t{\n\t\t\t\t\t\t_innerConnection.Connect();\n\t\t\t\t\t}\n\t\t\t\t\tcatch (OperationCanceledException ex)\n\t\t\t\t\t{\n\t\t\t\t\t\t//cancellationToken.ThrowIfCancellationRequested();\n\t\t\t\t\t\tthrow new TimeoutException(\"Timeout while connecting.\", ex);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch\n\t\t\t\t{\n\t\t\t\t\tif (_options.Pooling)\n\t\t\t\t\t{\n\t\t\t\t\t\tFbConnectionPoolManager.Instance.Release(_innerConnection, false);\n\t\t\t\t\t}\n\t\t\t\t\tthrow;\n\t\t\t\t}\n\t\t\t}\n\t\t\t_innerConnection.SetOwningConnection(this);\n\n\t\t\tif (_options.Enlist)\n\t\t\t{\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tEnlistTransaction(System.Transactions.Transaction.Current);\n\t\t\t\t}\n\t\t\t\tcatch\n\t\t\t\t{\n\t\t\t\t\t// if enlistment fails clean up innerConnection\n\t\t\t\t\t_innerConnection.DisposeTransaction();\n\n\t\t\t\t\tif (_options.Pooling)\n\t\t\t\t\t{\n\t\t\t\t\t\tFbConnectionPoolManager.Instance.Release(_innerConnection, true);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t_innerConnection.Disconnect();\n\t\t\t\t\t\t_innerConnection = null;\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Bind\tWarning\tmessages event\n\t\t\t_innerConnection.Database.WarningMessage = OnWarningMessage;\n\n\t\t\t// Update the connection state\n\t\t\tOnStateChange(_state, ConnectionState.Open);\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tOnStateChange(_state, ConnectionState.Closed);\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t\tcatch\n\t\t{\n\t\t\tOnStateChange(_state, ConnectionState.Closed);\n\t\t\tthrow;\n\t\t}\n\n\t\tLogMessages.ConnectionOpened(Log, this);\n\t}\n\tpublic override async Task OpenAsync(CancellationToken cancellationToken)\n\t{\n\t\tLogMessages.ConnectionOpening(Log, this);\n\n\t\tif (string.IsNullOrEmpty(_connectionString))\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Connection String is not initialized.\");\n\t\t}\n\t\tif (!IsClosed && _state != ConnectionState.Connecting)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Connection already Open.\");\n\t\t}\n\n\t\ttry\n\t\t{\n\t\t\tOnStateChange(_state, ConnectionState.Connecting);\n\n\t\t\tvar createdNew = default(bool);\n\t\t\tif (_options.Pooling)\n\t\t\t{\n\t\t\t\t_innerConnection = FbConnectionPoolManager.Instance.Get(_options, out createdNew);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_innerConnection = new FbConnectionInternal(_options);\n\t\t\t\tcreatedNew = true;\n\t\t\t}\n\t\t\tif (createdNew)\n\t\t\t{\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\ttry\n\t\t\t\t\t{\n\t\t\t\t\t\tawait _innerConnection.ConnectAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (OperationCanceledException ex)\n\t\t\t\t\t{\n\t\t\t\t\t\tcancellationToken.ThrowIfCancellationRequested();\n\t\t\t\t\t\tthrow new TimeoutException(\"Timeout while connecting.\", ex);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch\n\t\t\t\t{\n\t\t\t\t\tif (_options.Pooling)\n\t\t\t\t\t{\n\t\t\t\t\t\tFbConnectionPoolManager.Instance.Release(_innerConnection, false);\n\t\t\t\t\t}\n\t\t\t\t\tthrow;\n\t\t\t\t}\n\t\t\t}\n\t\t\t_innerConnection.SetOwningConnection(this);\n\n\t\t\tif (_options.Enlist)\n\t\t\t{\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tEnlistTransaction(System.Transactions.Transaction.Current);\n\t\t\t\t}\n\t\t\t\tcatch\n\t\t\t\t{\n\t\t\t\t\t// if enlistment fails clean up innerConnection\n\t\t\t\t\tawait _innerConnection.DisposeTransactionAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\t\tif (_options.Pooling)\n\t\t\t\t\t{\n\t\t\t\t\t\tFbConnectionPoolManager.Instance.Release(_innerConnection, true);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tawait _innerConnection.DisconnectAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t_innerConnection = null;\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Bind\tWarning\tmessages event\n\t\t\t_innerConnection.Database.WarningMessage = OnWarningMessage;\n\n\t\t\t// Update the connection state\n\t\t\tOnStateChange(_state, ConnectionState.Open);\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tOnStateChange(_state, ConnectionState.Closed);\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t\tcatch\n\t\t{\n\t\t\tOnStateChange(_state, ConnectionState.Closed);\n\t\t\tthrow;\n\t\t}\n\n\t\tLogMessages.ConnectionOpened(Log, this);\n\t}\n\n\tpublic override void Close()\n\t{\n\t\tLogMessages.ConnectionClosing(Log, this);\n\n\t\tif (!IsClosed && _innerConnection != null)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\t_innerConnection.CloseEventManager();\n\n\t\t\t\tif (_innerConnection.Database != null)\n\t\t\t\t{\n\t\t\t\t\t_innerConnection.Database.WarningMessage = null;\n\t\t\t\t}\n\n\t\t\t\t_innerConnection.DisposeTransaction();\n\n\t\t\t\t_innerConnection.ReleasePreparedCommands();\n\n\t\t\t\tif (_options.Pooling)\n\t\t\t\t{\n\t\t\t\t\tif (_innerConnection.CancelDisabled)\n\t\t\t\t\t{\n\t\t\t\t\t\t_innerConnection.EnableCancel();\n\t\t\t\t\t}\n\n\t\t\t\t\tvar broken = _innerConnection.Database.ConnectionBroken;\n\t\t\t\t\tFbConnectionPoolManager.Instance.Release(_innerConnection, !broken);\n\t\t\t\t\tif (broken)\n\t\t\t\t\t{\n\t\t\t\t\t\tDisconnectEnlistedHelper();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tDisconnectEnlistedHelper();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch\n\t\t\t{ }\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tOnStateChange(_state, ConnectionState.Closed);\n\t\t\t}\n\n\t\t\tLogMessages.ConnectionClosed(Log, this);\n\t\t}\n\n\t\tvoid DisconnectEnlistedHelper()\n\t\t{\n\t\t\tif (!_innerConnection.IsEnlisted)\n\t\t\t{\n\t\t\t\t_innerConnection.Disconnect();\n\t\t\t}\n\t\t\t_innerConnection = null;\n\t\t}\n\t}\n\tpublic override async Task CloseAsync()\n\t{\n\t\tLogMessages.ConnectionClosing(Log, this);\n\n\t\tif (!IsClosed && _innerConnection != null)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait _innerConnection.CloseEventManagerAsync(CancellationToken.None).ConfigureAwait(false);\n\n\t\t\t\tif (_innerConnection.Database != null)\n\t\t\t\t{\n\t\t\t\t\t_innerConnection.Database.WarningMessage = null;\n\t\t\t\t}\n\n\t\t\t\tawait _innerConnection.DisposeTransactionAsync(CancellationToken.None).ConfigureAwait(false);\n\n\t\t\t\tawait _innerConnection.ReleasePreparedCommandsAsync(CancellationToken.None).ConfigureAwait(false);\n\n\t\t\t\tif (_options.Pooling)\n\t\t\t\t{\n\t\t\t\t\tif (_innerConnection.CancelDisabled)\n\t\t\t\t\t{\n\t\t\t\t\t\tawait _innerConnection.EnableCancelAsync(CancellationToken.None).ConfigureAwait(false);\n\t\t\t\t\t}\n\n\t\t\t\t\tvar broken = _innerConnection.Database.ConnectionBroken;\n\t\t\t\t\tFbConnectionPoolManager.Instance.Release(_innerConnection, !broken);\n\t\t\t\t\tif (broken)\n\t\t\t\t\t{\n\t\t\t\t\t\tawait DisconnectEnlistedHelper().ConfigureAwait(false);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tawait DisconnectEnlistedHelper().ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch\n\t\t\t{ }\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tOnStateChange(_state, ConnectionState.Closed);\n\t\t\t}\n\n\t\t\tLogMessages.ConnectionClosed(Log, this);\n\t\t}\n\n\t\tasync Task DisconnectEnlistedHelper()\n\t\t{\n\t\t\tif (!_innerConnection.IsEnlisted)\n\t\t\t{\n\t\t\t\tawait _innerConnection.DisconnectAsync(CancellationToken.None).ConfigureAwait(false);\n\t\t\t}\n\t\t\t_innerConnection = null;\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void CheckClosed()\n\t{\n\t\tif (IsClosed)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Operation requires an open and available connection.\");\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Event Handlers\n\n\tprivate void OnWarningMessage(IscException warning)\n\t{\n\t\tInfoMessage?.Invoke(this, new FbInfoMessageEventArgs(warning));\n\t}\n\n\tprivate void OnStateChange(ConnectionState originalState, ConnectionState currentState)\n\t{\n\t\t_state = currentState;\n\t\tStateChange?.Invoke(this, new StateChangeEventArgs(originalState, currentState));\n\t}\n\n\t#endregion\n\n\t#region Cancelation\n\tpublic void EnableCancel()\n\t{\n\t\tCheckClosed();\n\n\t\t_innerConnection.EnableCancel();\n\t}\n\tpublic Task EnableCancelAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tCheckClosed();\n\n\t\treturn _innerConnection.EnableCancelAsync(cancellationToken);\n\t}\n\n\tpublic void DisableCancel()\n\t{\n\t\tCheckClosed();\n\n\t\t_innerConnection.DisableCancel();\n\t}\n\tpublic Task DisableCancelAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tCheckClosed();\n\n\t\treturn _innerConnection.DisableCancelAsync(cancellationToken);\n\t}\n\n\tpublic void CancelCommand()\n\t{\n\t\tCheckClosed();\n\n\t\t_innerConnection.CancelCommand();\n\t}\n\tpublic Task CancelCommandAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tCheckClosed();\n\n\t\treturn _innerConnection.CancelCommandAsync(cancellationToken);\n\t}\n\t#endregion\n\n\t#region Internal Methods\n\n\tinternal static void EnsureOpen(FbConnection connection)\n\t{\n\t\tif (connection == null || connection.State != ConnectionState.Open)\n\t\t\tthrow new InvalidOperationException(\"Connection must be valid and open.\");\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbConnectionInternal.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Data;\nusing System.Diagnostics;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Client;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.Schema;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\ninternal class FbConnectionInternal\n{\n\t#region Fields\n\n\tprivate DatabaseBase _db;\n\tprivate FbTransaction _activeTransaction;\n\tprivate HashSet<IFbPreparedCommand> _preparedCommands;\n\tprivate ConnectionString _connectionStringOptions;\n\tprivate FbConnection _owningConnection;\n\tprivate FbEnlistmentNotification _enlistmentNotification;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic DatabaseBase Database\n\t{\n\t\tget { return _db; }\n\t}\n\n\tpublic bool HasActiveTransaction\n\t{\n\t\tget\n\t\t{\n\t\t\treturn _activeTransaction != null && !_activeTransaction.IsCompleted;\n\t\t}\n\t}\n\n\tpublic FbTransaction ActiveTransaction\n\t{\n\t\tget { return _activeTransaction; }\n\t}\n\n\tpublic FbConnection OwningConnection\n\t{\n\t\tget { return _owningConnection; }\n\t}\n\n\tpublic bool IsEnlisted\n\t{\n\t\tget\n\t\t{\n\t\t\treturn _enlistmentNotification != null && !_enlistmentNotification.IsCompleted;\n\t\t}\n\t}\n\n\tpublic ConnectionString ConnectionStringOptions\n\t{\n\t\tget { return _connectionStringOptions; }\n\t}\n\n\tpublic bool CancelDisabled { get; private set; }\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FbConnectionInternal(ConnectionString options)\n\t{\n\t\t_preparedCommands = new HashSet<IFbPreparedCommand>();\n\n\t\t_connectionStringOptions = options;\n\t}\n\n\t#endregion\n\n\t#region Create and Drop database methods\n\n\tpublic void CreateDatabase(int pageSize, bool forcedWrites, bool overwrite)\n\t{\n\t\tvar db = ClientFactory.CreateDatabase(_connectionStringOptions);\n\n\t\tvar dpb = db.CreateDatabaseParameterBuffer();\n\n\t\tif (db.UseUtf8ParameterBuffer)\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_utf8_filename, 0);\n\t\t}\n\t\tdpb.Append(IscCodes.isc_dpb_dummy_packet_interval, new byte[] { 120, 10, 0, 0 });\n\t\tdpb.Append(IscCodes.isc_dpb_sql_dialect, new byte[] { (byte)_connectionStringOptions.Dialect, 0, 0, 0 });\n\t\tif (!string.IsNullOrEmpty(_connectionStringOptions.UserID))\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_user_name, _connectionStringOptions.UserID);\n\t\t}\n\t\tif (_connectionStringOptions.Charset.Length > 0)\n\t\t{\n\t\t\tif (!Charset.TryGetByName(_connectionStringOptions.Charset, out var charset))\n\t\t\t\tthrow new ArgumentException(\"Invalid character set specified.\");\n\t\t\tdpb.Append(IscCodes.isc_dpb_set_db_charset, charset.Name);\n\t\t}\n\t\tdpb.Append(IscCodes.isc_dpb_force_write, (short)(forcedWrites ? 1 : 0));\n\t\tdpb.Append(IscCodes.isc_dpb_overwrite, (overwrite ? 1 : 0));\n\t\tif (pageSize > 0)\n\t\t{\n\t\t\tif (!SizeHelper.IsValidPageSize(pageSize))\n\t\t\t\tthrow SizeHelper.InvalidSizeException(\"page size\");\n\t\t\tdpb.Append(IscCodes.isc_dpb_page_size, pageSize);\n\t\t}\n\n\t\ttry\n\t\t{\n\t\t\tif (string.IsNullOrEmpty(_connectionStringOptions.UserID) && string.IsNullOrEmpty(_connectionStringOptions.Password))\n\t\t\t{\n\t\t\t\tdb.CreateDatabaseWithTrustedAuth(dpb, _connectionStringOptions.Database, _connectionStringOptions.CryptKey);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tdb.CreateDatabase(dpb, _connectionStringOptions.Database, _connectionStringOptions.CryptKey);\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tdb.Detach();\n\t\t}\n\t}\n\tpublic async Task CreateDatabaseAsync(int pageSize, bool forcedWrites, bool overwrite, CancellationToken cancellationToken = default)\n\t{\n\t\tvar db = await ClientFactory.CreateDatabaseAsync(_connectionStringOptions, cancellationToken).ConfigureAwait(false);\n\n\t\tvar dpb = db.CreateDatabaseParameterBuffer();\n\n\t\tif (db.UseUtf8ParameterBuffer)\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_utf8_filename, 0);\n\t\t}\n\t\tdpb.Append(IscCodes.isc_dpb_dummy_packet_interval, new byte[] { 120, 10, 0, 0 });\n\t\tdpb.Append(IscCodes.isc_dpb_sql_dialect, new byte[] { (byte)_connectionStringOptions.Dialect, 0, 0, 0 });\n\t\tif (!string.IsNullOrEmpty(_connectionStringOptions.UserID))\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_user_name, _connectionStringOptions.UserID);\n\t\t}\n\t\tif (_connectionStringOptions.Charset.Length > 0)\n\t\t{\n\t\t\tif (!Charset.TryGetByName(_connectionStringOptions.Charset, out var charset))\n\t\t\t\tthrow new ArgumentException(\"Invalid character set specified.\");\n\t\t\tdpb.Append(IscCodes.isc_dpb_set_db_charset, charset.Name);\n\t\t}\n\t\tdpb.Append(IscCodes.isc_dpb_force_write, (short)(forcedWrites ? 1 : 0));\n\t\tdpb.Append(IscCodes.isc_dpb_overwrite, (overwrite ? 1 : 0));\n\t\tif (pageSize > 0)\n\t\t{\n\t\t\tif (!SizeHelper.IsValidPageSize(pageSize))\n\t\t\t\tthrow SizeHelper.InvalidSizeException(\"page size\");\n\t\t\tdpb.Append(IscCodes.isc_dpb_page_size, pageSize);\n\t\t}\n\n\t\ttry\n\t\t{\n\t\t\tif (string.IsNullOrEmpty(_connectionStringOptions.UserID) && string.IsNullOrEmpty(_connectionStringOptions.Password))\n\t\t\t{\n\t\t\t\tawait db.CreateDatabaseWithTrustedAuthAsync(dpb, _connectionStringOptions.Database, _connectionStringOptions.CryptKey, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tawait db.CreateDatabaseAsync(dpb, _connectionStringOptions.Database, _connectionStringOptions.CryptKey, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tawait db.DetachAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\tpublic void DropDatabase()\n\t{\n\t\tvar db = ClientFactory.CreateDatabase(_connectionStringOptions);\n\t\ttry\n\t\t{\n\t\t\tif (string.IsNullOrEmpty(_connectionStringOptions.UserID) && string.IsNullOrEmpty(_connectionStringOptions.Password))\n\t\t\t{\n\t\t\t\tdb.AttachWithTrustedAuth(BuildDpb(db, _connectionStringOptions), _connectionStringOptions.Database, _connectionStringOptions.CryptKey);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tdb.Attach(BuildDpb(db, _connectionStringOptions), _connectionStringOptions.Database, _connectionStringOptions.CryptKey);\n\t\t\t}\n\t\t\tdb.DropDatabase();\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tdb.Detach();\n\t\t}\n\t}\n\tpublic async Task DropDatabaseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar db = await ClientFactory.CreateDatabaseAsync(_connectionStringOptions, cancellationToken).ConfigureAwait(false);\n\t\ttry\n\t\t{\n\t\t\tif (string.IsNullOrEmpty(_connectionStringOptions.UserID) && string.IsNullOrEmpty(_connectionStringOptions.Password))\n\t\t\t{\n\t\t\t\tawait db.AttachWithTrustedAuthAsync(BuildDpb(db, _connectionStringOptions), _connectionStringOptions.Database, _connectionStringOptions.CryptKey, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tawait db.AttachAsync(BuildDpb(db, _connectionStringOptions), _connectionStringOptions.Database, _connectionStringOptions.CryptKey, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tawait db.DropDatabaseAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tawait db.DetachAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Connect and Disconnect methods\n\n\tpublic void Connect()\n\t{\n\t\tif (!Charset.TryGetByName(_connectionStringOptions.Charset, out var charset))\n\t\t\tthrow new ArgumentException(\"Invalid character set specified.\");\n\n\t\ttry\n\t\t{\n\t\t\t_db = ClientFactory.CreateDatabase(_connectionStringOptions);\n\t\t\tvar dpb = BuildDpb(_db, _connectionStringOptions);\n\t\t\tif (string.IsNullOrEmpty(_connectionStringOptions.UserID) && string.IsNullOrEmpty(_connectionStringOptions.Password))\n\t\t\t{\n\t\t\t\t_db.AttachWithTrustedAuth(dpb, _connectionStringOptions.Database, _connectionStringOptions.CryptKey);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_db.Attach(dpb, _connectionStringOptions.Database, _connectionStringOptions.CryptKey);\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task ConnectAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (!Charset.TryGetByName(_connectionStringOptions.Charset, out var charset))\n\t\t\tthrow new ArgumentException(\"Invalid character set specified.\");\n\n\t\ttry\n\t\t{\n\t\t\t_db = await ClientFactory.CreateDatabaseAsync(_connectionStringOptions, cancellationToken).ConfigureAwait(false);\n\t\t\tvar dpb = BuildDpb(_db, _connectionStringOptions);\n\t\t\tif (string.IsNullOrEmpty(_connectionStringOptions.UserID) && string.IsNullOrEmpty(_connectionStringOptions.Password))\n\t\t\t{\n\t\t\t\tawait _db.AttachWithTrustedAuthAsync(dpb, _connectionStringOptions.Database, _connectionStringOptions.CryptKey, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tawait _db.AttachAsync(dpb, _connectionStringOptions.Database, _connectionStringOptions.CryptKey, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic void Disconnect()\n\t{\n\t\tif (_db != null)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\t_db.Detach();\n\t\t\t}\n\t\t\tcatch\n\t\t\t{ }\n\t\t\tfinally\n\t\t\t{\n\t\t\t\t_db = null;\n\t\t\t\t_owningConnection = null;\n\t\t\t\t_connectionStringOptions = null;\n\t\t\t}\n\t\t}\n\t}\n\tpublic async Task DisconnectAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_db != null)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait _db.DetachAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch\n\t\t\t{ }\n\t\t\tfinally\n\t\t\t{\n\t\t\t\t_db = null;\n\t\t\t\t_owningConnection = null;\n\t\t\t\t_connectionStringOptions = null;\n\t\t\t}\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Transaction Handling Methods\n\n\tpublic FbTransaction BeginTransaction(IsolationLevel level, string transactionName)\n\t{\n\t\tEnsureNoActiveTransaction();\n\n\t\ttry\n\t\t{\n\t\t\t_activeTransaction = new FbTransaction(_owningConnection, level);\n\t\t\t_activeTransaction.BeginTransaction();\n\n\t\t\tif (transactionName != null)\n\t\t\t{\n\t\t\t\t_activeTransaction.Save(transactionName);\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tDisposeTransaction();\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\treturn _activeTransaction;\n\t}\n\tpublic async Task<FbTransaction> BeginTransactionAsync(IsolationLevel level, string transactionName, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureNoActiveTransaction();\n\n\t\ttry\n\t\t{\n\t\t\t_activeTransaction = new FbTransaction(_owningConnection, level);\n\t\t\tawait _activeTransaction.BeginTransactionAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\tif (transactionName != null)\n\t\t\t{\n\t\t\t\t_activeTransaction.Save(transactionName);\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tawait DisposeTransactionAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\treturn _activeTransaction;\n\t}\n\n\tpublic FbTransaction BeginTransaction(FbTransactionOptions options, string transactionName)\n\t{\n\t\tEnsureNoActiveTransaction();\n\n\t\ttry\n\t\t{\n\t\t\t_activeTransaction = new FbTransaction(_owningConnection, IsolationLevel.Unspecified);\n\t\t\t_activeTransaction.BeginTransaction(options);\n\n\t\t\tif (transactionName != null)\n\t\t\t{\n\t\t\t\t_activeTransaction.Save(transactionName);\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tDisposeTransaction();\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\treturn _activeTransaction;\n\t}\n\tpublic async Task<FbTransaction> BeginTransactionAsync(FbTransactionOptions options, string transactionName, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureNoActiveTransaction();\n\n\t\ttry\n\t\t{\n\t\t\t_activeTransaction = new FbTransaction(_owningConnection, IsolationLevel.Unspecified);\n\t\t\tawait _activeTransaction.BeginTransactionAsync(options, cancellationToken).ConfigureAwait(false);\n\n\t\t\tif (transactionName != null)\n\t\t\t{\n\t\t\t\t_activeTransaction.Save(transactionName);\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tawait DisposeTransactionAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\treturn _activeTransaction;\n\t}\n\n\tpublic void DisposeTransaction()\n\t{\n\t\tif (_activeTransaction != null && !IsEnlisted)\n\t\t{\n\t\t\t_activeTransaction.Dispose();\n\t\t\t_activeTransaction = null;\n\t\t}\n\t}\n\tpublic async Task DisposeTransactionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_activeTransaction != null && !IsEnlisted)\n\t\t{\n\t\t\tawait _activeTransaction.DisposeAsync().ConfigureAwait(false);\n\t\t\t_activeTransaction = null;\n\t\t}\n\t}\n\n\tpublic void TransactionCompleted()\n\t{\n\t\tforeach (var command in _preparedCommands)\n\t\t{\n\t\t\tcommand.TransactionCompleted();\n\t\t}\n\t}\n\tpublic async Task TransactionCompletedAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tforeach (var command in _preparedCommands)\n\t\t{\n\t\t\tawait command.TransactionCompletedAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Transaction Enlistment\n\n\tpublic void EnlistTransaction(System.Transactions.Transaction transaction)\n\t{\n\t\tif (_owningConnection != null)\n\t\t{\n\t\t\tif (_enlistmentNotification != null && _enlistmentNotification.SystemTransaction == transaction)\n\t\t\t\treturn;\n\n\t\t\tif (HasActiveTransaction)\n\t\t\t{\n\t\t\t\tthrow new ArgumentException(\"Unable to enlist in transaction, a local transaction already exists\");\n\t\t\t}\n\t\t\tif (_enlistmentNotification != null)\n\t\t\t{\n\t\t\t\tthrow new ArgumentException(\"Already enlisted in a transaction\");\n\t\t\t}\n\n\t\t\t_enlistmentNotification = new FbEnlistmentNotification(this, transaction);\n\t\t\t_enlistmentNotification.Completed += new EventHandler(EnlistmentCompleted);\n\t\t}\n\t}\n\n\tprivate void EnlistmentCompleted(object sender, EventArgs e)\n\t{\n\t\t_enlistmentNotification = null;\n\t}\n\n\tpublic FbTransaction BeginTransaction(System.Transactions.IsolationLevel isolationLevel)\n\t{\n\t\tvar il = isolationLevel switch\n\t\t{\n\t\t\tSystem.Transactions.IsolationLevel.Chaos => IsolationLevel.Chaos,\n\t\t\tSystem.Transactions.IsolationLevel.ReadUncommitted => IsolationLevel.ReadUncommitted,\n\t\t\tSystem.Transactions.IsolationLevel.RepeatableRead => IsolationLevel.RepeatableRead,\n\t\t\tSystem.Transactions.IsolationLevel.Serializable => IsolationLevel.Serializable,\n\t\t\tSystem.Transactions.IsolationLevel.Snapshot => IsolationLevel.Snapshot,\n\t\t\tSystem.Transactions.IsolationLevel.Unspecified => IsolationLevel.Unspecified,\n\t\t\t_ => IsolationLevel.ReadCommitted,\n\t\t};\n\t\treturn BeginTransaction(il, null);\n\t}\n\tpublic Task<FbTransaction> BeginTransactionAsync(System.Transactions.IsolationLevel isolationLevel, CancellationToken cancellationToken = default)\n\t{\n\t\tvar il = isolationLevel switch\n\t\t{\n\t\t\tSystem.Transactions.IsolationLevel.Chaos => IsolationLevel.Chaos,\n\t\t\tSystem.Transactions.IsolationLevel.ReadUncommitted => IsolationLevel.ReadUncommitted,\n\t\t\tSystem.Transactions.IsolationLevel.RepeatableRead => IsolationLevel.RepeatableRead,\n\t\t\tSystem.Transactions.IsolationLevel.Serializable => IsolationLevel.Serializable,\n\t\t\tSystem.Transactions.IsolationLevel.Snapshot => IsolationLevel.Snapshot,\n\t\t\tSystem.Transactions.IsolationLevel.Unspecified => IsolationLevel.Unspecified,\n\t\t\t_ => IsolationLevel.ReadCommitted,\n\t\t};\n\t\treturn BeginTransactionAsync(il, null, cancellationToken);\n\t}\n\n\t#endregion\n\n\t#region Schema Methods\n\n\tpublic DataTable GetSchema(string collectionName, string[] restrictions)\n\t{\n\t\treturn FbSchemaFactory.GetSchema(_owningConnection, collectionName, restrictions);\n\t}\n\tpublic Task<DataTable> GetSchemaAsync(string collectionName, string[] restrictions, CancellationToken cancellationToken = default)\n\t{\n\t\treturn FbSchemaFactory.GetSchemaAsync(_owningConnection, collectionName, restrictions, cancellationToken);\n\t}\n\n\t#endregion\n\n\t#region Prepared Commands Methods\n\n\tpublic void AddPreparedCommand(IFbPreparedCommand command)\n\t{\n\t\tif (_preparedCommands.Contains(command))\n\t\t\treturn;\n\t\t_preparedCommands.Add(command);\n\t}\n\n\tpublic void RemovePreparedCommand(IFbPreparedCommand command)\n\t{\n\t\t_preparedCommands.Remove(command);\n\t}\n\n\tpublic void ReleasePreparedCommands()\n\t{\n\t\t// copy the data because the collection will be modified via RemovePreparedCommand from Release\n\t\tvar data = _preparedCommands.ToList();\n\t\tforeach (var item in data)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\titem.Release();\n\t\t\t}\n\t\t\tcatch (IOException)\n\t\t\t{\n\t\t\t\t// If an IO error occurs when trying to release the command\n\t\t\t\t// avoid it. (It maybe the connection to the server was down\n\t\t\t\t// for unknown reasons.)\n\t\t\t}\n\t\t\tcatch (IscException ex) when (ex.ErrorCode == IscCodes.isc_network_error\n\t\t\t\t|| ex.ErrorCode == IscCodes.isc_net_read_err\n\t\t\t\t|| ex.ErrorCode == IscCodes.isc_net_write_err)\n\t\t\t{ }\n\t\t}\n\t}\n\tpublic async Task ReleasePreparedCommandsAsync(CancellationToken cancellationToken = default)\n\t{\n\t\t// copy the data because the collection will be modified via RemovePreparedCommand from Release\n\t\tvar data = _preparedCommands.ToList();\n\t\tforeach (var item in data)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait item.ReleaseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tcatch (IOException)\n\t\t\t{\n\t\t\t\t// If an IO error occurs when trying to release the command\n\t\t\t\t// avoid it. (It maybe the connection to the server was down\n\t\t\t\t// for unknown reasons.)\n\t\t\t}\n\t\t\tcatch (IscException ex) when (ex.ErrorCode == IscCodes.isc_network_error\n\t\t\t\t|| ex.ErrorCode == IscCodes.isc_net_read_err\n\t\t\t\t|| ex.ErrorCode == IscCodes.isc_net_write_err)\n\t\t\t{ }\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Firebird Events Methods\n\n\tpublic void CloseEventManager()\n\t{\n\t\tif (_db != null && _db.HasRemoteEventSupport)\n\t\t{\n\t\t\t_db.CloseEventManager();\n\t\t}\n\t}\n\tpublic Task CloseEventManagerAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_db != null && _db.HasRemoteEventSupport)\n\t\t{\n\t\t\treturn _db.CloseEventManagerAsync(cancellationToken).AsTask();\n\t\t}\n\t\treturn Task.CompletedTask;\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void EnsureNoActiveTransaction()\n\t{\n\t\tif (HasActiveTransaction)\n\t\t\tthrow new InvalidOperationException(\"A transaction is currently active. Parallel transactions are not supported.\");\n\t}\n\n\tprivate static DatabaseParameterBufferBase BuildDpb(DatabaseBase db, ConnectionString options)\n\t{\n\t\tvar dpb = db.CreateDatabaseParameterBuffer();\n\n\t\tif (db.UseUtf8ParameterBuffer)\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_utf8_filename, 0);\n\t\t}\n\t\tdpb.Append(IscCodes.isc_dpb_dummy_packet_interval, new byte[] { 120, 10, 0, 0 });\n\t\tdpb.Append(IscCodes.isc_dpb_sql_dialect, new byte[] { (byte)options.Dialect, 0, 0, 0 });\n\t\tdpb.Append(IscCodes.isc_dpb_lc_ctype, options.Charset);\n\t\tif (options.DbCachePages > 0)\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_num_buffers, options.DbCachePages);\n\t\t}\n\t\tif (!string.IsNullOrEmpty(options.UserID))\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_user_name, options.UserID);\n\t\t}\n\t\tif (!string.IsNullOrEmpty(options.Role))\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_sql_role_name, options.Role);\n\t\t}\n\t\tdpb.Append(IscCodes.isc_dpb_connect_timeout, options.ConnectionTimeout);\n\t\tdpb.Append(IscCodes.isc_dpb_process_id, GetProcessId());\n\t\tdpb.Append(IscCodes.isc_dpb_process_name, GetProcessName(options));\n\t\tdpb.Append(IscCodes.isc_dpb_client_version, GetClientVersion());\n\t\tif (options.NoDatabaseTriggers)\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_no_db_triggers, 1);\n\t\t}\n\t\tif (options.NoGarbageCollect)\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_no_garbage_collect, (byte)0);\n\t\t}\n\t\tif (options.ParallelWorkers > 0)\n\t\t{\n\t\t\tdpb.Append(IscCodes.isc_dpb_parallel_workers, options.ParallelWorkers);\n\t\t}\n\n\t\treturn dpb;\n\t}\n\n\tprivate static string GetProcessName(ConnectionString options)\n\t{\n\t\tif (!string.IsNullOrEmpty(options.ApplicationName))\n\t\t{\n\t\t\treturn options.ApplicationName;\n\t\t}\n\t\treturn GetRealProcessName() ?? string.Empty;\n\t}\n\n\tprivate static string GetRealProcessName()\n\t{\n\t\treturn Assembly.GetEntryAssembly()?.Location ?? Environment.ProcessPath;\n\t}\n\n\tprivate static int GetProcessId()\n\t{\n\t\treturn Environment.ProcessId;\n\t}\n\n\tprivate static string GetClientVersion()\n\t{\n\t\treturn typeof(FbConnectionInternal).GetTypeInfo().Assembly.GetName().Version.ToString();\n\t}\n\t#endregion\n\n\t#region Cancelation\n\tpublic void EnableCancel()\n\t{\n\t\t_db.CancelOperation(IscCodes.fb_cancel_enable);\n\t\tCancelDisabled = false;\n\t}\n\tpublic async Task EnableCancelAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tawait _db.CancelOperationAsync(IscCodes.fb_cancel_enable, cancellationToken).ConfigureAwait(false);\n\t\tCancelDisabled = false;\n\t}\n\n\tpublic void DisableCancel()\n\t{\n\t\t_db.CancelOperation(IscCodes.fb_cancel_disable);\n\t\tCancelDisabled = true;\n\t}\n\tpublic async Task DisableCancelAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tawait _db.CancelOperationAsync(IscCodes.fb_cancel_disable, cancellationToken).ConfigureAwait(false);\n\t\tCancelDisabled = true;\n\t}\n\n\tpublic void CancelCommand()\n\t{\n\t\t_db.CancelOperation(IscCodes.fb_cancel_raise);\n\t}\n\tpublic Task CancelCommandAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn _db.CancelOperationAsync(IscCodes.fb_cancel_raise, cancellationToken).AsTask();\n\t}\n\t#endregion\n\n\t#region Infrastructure\n\tpublic FbConnectionInternal SetOwningConnection(FbConnection owningConnection)\n\t{\n\t\t_owningConnection = owningConnection;\n\t\treturn this;\n\t}\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbConnectionPoolManager.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Concurrent;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Runtime.CompilerServices;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\nsealed class FbConnectionPoolManager : IDisposable\n{\n\tinternal static FbConnectionPoolManager Instance { get; private set; }\n\n\tsealed class Item\n\t{\n\t\tpublic long Created { get; private set; }\n\t\tpublic FbConnectionInternal Connection { get; private set; }\n\n\t\tpublic Item(long created, FbConnectionInternal connection)\n\t\t{\n\t\t\tCreated = created;\n\t\t\tConnection = connection;\n\t\t}\n\n\t\tpublic void Release()\n\t\t{\n\t\t\tConnection.Disconnect();\n\t\t}\n\t}\n\n\tsealed class Pool : IDisposable\n\t{\n\t\tbool _disposed;\n\t\tobject _syncRoot;\n\t\tConnectionString _connectionString;\n\t\tStack<Item> _available;\n\t\tList<FbConnectionInternal> _busy;\n\n\t\tpublic Pool(ConnectionString connectionString)\n\t\t{\n\t\t\t_syncRoot = new object();\n\t\t\t_connectionString = connectionString;\n\t\t\t_available = new Stack<Item>();\n\t\t\t_busy = new List<FbConnectionInternal>();\n\t\t}\n\n\t\tpublic void Dispose()\n\t\t{\n\t\t\tlock (_syncRoot)\n\t\t\t{\n\t\t\t\tif (_disposed)\n\t\t\t\t\treturn;\n\t\t\t\t_disposed = true;\n\t\t\t\tCleanConnectionsImpl();\n\t\t\t}\n\t\t}\n\n\t\tpublic FbConnectionInternal GetConnection(out bool createdNew)\n\t\t{\n\t\t\tFbConnectionInternal connection;\n\t\t\tlock (_syncRoot)\n\t\t\t{\n\t\t\t\tCheckDisposedImpl();\n\n\t\t\t\tconnection = GetOrCreateConnectionImpl(out createdNew);\n\t\t\t\t_busy.Add(connection);\n\t\t\t}\n\t\t\treturn connection;\n\t\t}\n\n\t\tpublic void ReleaseConnection(FbConnectionInternal connection, bool returnToAvailable)\n\t\t{\n\t\t\tlock (_syncRoot)\n\t\t\t{\n\t\t\t\tCheckDisposedImpl();\n\n\t\t\t\tvar removed = _busy.Remove(connection);\n\t\t\t\tif (removed && returnToAvailable)\n\t\t\t\t{\n\t\t\t\t\t_available.Push(new Item(GetTicks(), connection));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpublic void PrunePool()\n\t\t{\n\t\t\tlock (_syncRoot)\n\t\t\t{\n\t\t\t\tCheckDisposedImpl();\n\n\t\t\t\tvar now = GetTicks();\n\t\t\t\tvar available = _available.ToList();\n\t\t\t\tif (available.Count <= _connectionString.MinPoolSize)\n\t\t\t\t\treturn;\n\t\t\t\tvar keep = available.Where(x => ConnectionPoolLifetimeHelper.IsAlive(_connectionString.ConnectionLifetime, x.Created, now)).ToList();\n\t\t\t\tvar keepCount = keep.Count;\n\t\t\t\tif (keepCount < _connectionString.MinPoolSize)\n\t\t\t\t{\n\t\t\t\t\tkeep = keep.Concat(available.Except(keep).OrderByDescending(x => x.Created).Take(_connectionString.MinPoolSize - keepCount)).ToList();\n\t\t\t\t}\n\t\t\t\tvar release = available.Except(keep).ToList();\n\t\t\t\tParallel.ForEach(release, x => x.Release());\n\t\t\t\t_available = new Stack<Item>(keep);\n\t\t\t}\n\t\t}\n\n\t\tpublic void ClearPool()\n\t\t{\n\t\t\tlock (_syncRoot)\n\t\t\t{\n\t\t\t\tCheckDisposedImpl();\n\n\t\t\t\tCleanConnectionsImpl();\n\t\t\t\t_available.Clear();\n\t\t\t}\n\t\t}\n\n\t\tvoid CleanConnectionsImpl()\n\t\t{\n\t\t\tParallel.ForEach(_available, x => x.Release());\n\t\t}\n\n\t\t[MethodImpl(MethodImplOptions.AggressiveInlining)]\n\t\tvoid CheckDisposedImpl()\n\t\t{\n\t\t\tif (_disposed)\n\t\t\t\tthrow new ObjectDisposedException(nameof(Pool));\n\t\t}\n\n\t\tFbConnectionInternal GetOrCreateConnectionImpl(out bool createdNew)\n\t\t{\n\t\t\tif (_available.Any())\n\t\t\t{\n\t\t\t\tcreatedNew = false;\n\t\t\t\treturn _available.Pop().Connection;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcreatedNew = true;\n\t\t\t\tif (_busy.Count + 1 > _connectionString.MaxPoolSize)\n\t\t\t\t\tthrow new InvalidOperationException(\"Connection pool is full.\");\n\t\t\t\treturn new FbConnectionInternal(_connectionString);\n\t\t\t}\n\t\t}\n\n\t\tstatic long GetTicks()\n\t\t{\n\t\t\tvar ticks = Environment.TickCount;\n\t\t\treturn ticks + -(long)int.MinValue;\n\t\t}\n\t}\n\n\tint _disposed;\n\tConcurrentDictionary<string, Pool> _pools;\n\tTimer _cleanupTimer;\n\n\tstatic FbConnectionPoolManager()\n\t{\n\t\tInstance = new FbConnectionPoolManager();\n\t\tShutdownHelper.RegisterPoolCleanup(Instance.Dispose);\n\t}\n\n\tFbConnectionPoolManager()\n\t{\n\t\t_disposed = 0;\n\t\t_pools = new ConcurrentDictionary<string, Pool>();\n\t\t_cleanupTimer = new Timer(CleanupCallback, null, TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2));\n\t}\n\n\tinternal FbConnectionInternal Get(ConnectionString connectionString, out bool createdNew)\n\t{\n\t\tCheckDisposed();\n\n\t\treturn _pools.GetOrAdd(connectionString.NormalizedConnectionString, _ => new Pool(connectionString)).GetConnection(out createdNew);\n\t}\n\n\tinternal void Release(FbConnectionInternal connection, bool returnToAvailable)\n\t{\n\t\tCheckDisposed();\n\n\t\tif (_pools.TryGetValue(connection.ConnectionStringOptions.NormalizedConnectionString, out var pool))\n\t\t{\n\t\t\tpool.ReleaseConnection(connection, returnToAvailable);\n\t\t}\n\t}\n\n\tinternal void ClearAllPools()\n\t{\n\t\tCheckDisposed();\n\n\t\tParallel.ForEach(_pools.Values, x => x.ClearPool());\n\t}\n\n\tinternal void ClearPool(ConnectionString connectionString)\n\t{\n\t\tCheckDisposed();\n\n\t\tif (_pools.TryGetValue(connectionString.NormalizedConnectionString, out var pool))\n\t\t{\n\t\t\tpool.ClearPool();\n\t\t}\n\t}\n\n\tpublic void Dispose()\n\t{\n\t\tif (Interlocked.Exchange(ref _disposed, 1) == 1)\n\t\t\treturn;\n\t\tusing (var mre = new ManualResetEvent(false))\n\t\t{\n\t\t\t_cleanupTimer.Dispose(mre);\n\t\t\tmre.WaitOne();\n\t\t}\n\t\tParallel.ForEach(_pools.Values, x => x.Dispose());\n\t}\n\n\tvoid CleanupCallback(object o)\n\t{\n\t\tParallel.ForEach(_pools.Values, x => x.PrunePool());\n\t}\n\n\t[MethodImpl(MethodImplOptions.AggressiveInlining)]\n\tvoid CheckDisposed()\n\t{\n\t\tif (Volatile.Read(ref _disposed) == 1)\n\t\t\tthrow new ObjectDisposedException(nameof(FbConnectionPoolManager));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbConnectionStringBuilder.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Data.Common;\nusing System.Globalization;\nusing System.Text;\nusing System.ComponentModel;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic class FbConnectionStringBuilder : DbConnectionStringBuilder\n{\n\t#region Properties\n\n\t[Category(\"Security\")]\n\t[DisplayName(\"User ID\")]\n\t[Description(\"Indicates the User ID to be used when connecting to the data source.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueUserId)]\n\tpublic string UserID\n\t{\n\t\tget { return Common.ConnectionString.GetString(GetKey(Common.ConnectionString.DefaultKeyUserId), base.TryGetValue, Common.ConnectionString.DefaultValueUserId); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyUserId, value); }\n\t}\n\n\t[Category(\"Security\")]\n\t[DisplayName(\"Password\")]\n\t[Description(\"Indicates the password to be used when connecting to the data source.\")]\n\t[PasswordPropertyText(true)]\n\t[DefaultValue(Common.ConnectionString.DefaultValuePassword)]\n\tpublic string Password\n\t{\n\t\tget { return Common.ConnectionString.GetString(GetKey(Common.ConnectionString.DefaultKeyPassword), base.TryGetValue, Common.ConnectionString.DefaultValuePassword); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyPassword, value); }\n\t}\n\n\t[Category(\"Source\")]\n\t[DisplayName(\"DataSource\")]\n\t[Description(\"The name of the Firebird server to which to connect.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueDataSource)]\n\tpublic string DataSource\n\t{\n\t\tget { return Common.ConnectionString.GetString(GetKey(Common.ConnectionString.DefaultKeyDataSource), base.TryGetValue, Common.ConnectionString.DefaultValueDataSource); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyDataSource, value); }\n\t}\n\n\t[Category(\"Source\")]\n\t[DisplayName(\"Database\")]\n\t[Description(\"The name of the actual database or the database to be used when a connection is open. It is normally the path to an .FDB file or an alias.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueCatalog)]\n\tpublic string Database\n\t{\n\t\tget { return Common.ConnectionString.GetString(GetKey(Common.ConnectionString.DefaultKeyCatalog), base.TryGetValue, Common.ConnectionString.DefaultValueCatalog); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyCatalog, value); }\n\t}\n\n\t[Category(\"Source\")]\n\t[DisplayName(\"Port\")]\n\t[Description(\"Port to use for TCP/IP connections\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValuePortNumber)]\n\tpublic int Port\n\t{\n\t\tget { return Common.ConnectionString.GetInt32(GetKey(Common.ConnectionString.DefaultKeyPortNumber), base.TryGetValue, Common.ConnectionString.DefaultValuePortNumber); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyPortNumber, value); }\n\t}\n\n\t[Category(\"Advanced\")]\n\t[DisplayName(\"PacketSize\")]\n\t[Description(\"The size (in bytes) of network packets. PacketSize may be in the range 512-32767 bytes.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValuePacketSize)]\n\tpublic int PacketSize\n\t{\n\t\tget { return Common.ConnectionString.GetInt32(GetKey(Common.ConnectionString.DefaultKeyPacketSize), base.TryGetValue, Common.ConnectionString.DefaultValuePacketSize); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyPacketSize, value); }\n\t}\n\n\t[Category(\"Security\")]\n\t[DisplayName(\"Role\")]\n\t[Description(\"The user role.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueRoleName)]\n\tpublic string Role\n\t{\n\t\tget { return Common.ConnectionString.GetString(GetKey(Common.ConnectionString.DefaultKeyRoleName), base.TryGetValue, Common.ConnectionString.DefaultValueRoleName); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyRoleName, value); }\n\t}\n\n\t[Category(\"Advanced\")]\n\t[DisplayName(\"Dialect\")]\n\t[Description(\"The database SQL dialect.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueDialect)]\n\tpublic int Dialect\n\t{\n\t\tget { return Common.ConnectionString.GetInt32(GetKey(Common.ConnectionString.DefaultKeyDialect), base.TryGetValue, Common.ConnectionString.DefaultValueDialect); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyDialect, value); }\n\t}\n\n\t[Category(\"Advanced\")]\n\t[DisplayName(\"Character Set\")]\n\t[Description(\"The connection character set encoding.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueCharacterSet)]\n\tpublic string Charset\n\t{\n\t\tget { return Common.ConnectionString.GetString(GetKey(Common.ConnectionString.DefaultKeyCharacterSet), base.TryGetValue, Common.ConnectionString.DefaultValueCharacterSet); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyCharacterSet, value); }\n\t}\n\n\t[Category(\"Connection\")]\n\t[DisplayName(\"Connection Timeout\")]\n\t[Description(\"The time (in seconds) to wait for a connection to open.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueConnectionTimeout)]\n\tpublic int ConnectionTimeout\n\t{\n\t\tget { return Common.ConnectionString.GetInt32(GetKey(Common.ConnectionString.DefaultKeyConnectionTimeout), base.TryGetValue, Common.ConnectionString.DefaultValueConnectionTimeout); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyConnectionTimeout, value); }\n\t}\n\n\t[Category(\"Pooling\")]\n\t[DisplayName(\"Pooling\")]\n\t[Description(\"When true the connection is grabbed from a pool or, if necessary, created and added to the appropriate pool.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValuePooling)]\n\tpublic bool Pooling\n\t{\n\t\tget { return Common.ConnectionString.GetBoolean(GetKey(Common.ConnectionString.DefaultKeyPooling), base.TryGetValue, Common.ConnectionString.DefaultValuePooling); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyPooling, value); }\n\t}\n\n\t[Category(\"Connection\")]\n\t[DisplayName(\"Connection LifeTime\")]\n\t[Description(\"When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by connection lifetime.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueConnectionLifetime)]\n\tpublic int ConnectionLifeTime\n\t{\n\t\tget { return Common.ConnectionString.GetInt32(GetKey(Common.ConnectionString.DefaultKeyConnectionLifetime), base.TryGetValue, Common.ConnectionString.DefaultValueConnectionLifetime); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyConnectionLifetime, value); }\n\t}\n\n\t[Category(\"Pooling\")]\n\t[DisplayName(\"MinPoolSize\")]\n\t[Description(\"The minimun number of connections allowed in the pool.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueMinPoolSize)]\n\tpublic int MinPoolSize\n\t{\n\t\tget { return Common.ConnectionString.GetInt32(GetKey(Common.ConnectionString.DefaultKeyMinPoolSize), base.TryGetValue, Common.ConnectionString.DefaultValueMinPoolSize); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyMinPoolSize, value); }\n\t}\n\n\t[Category(\"Pooling\")]\n\t[DisplayName(\"MaxPoolSize\")]\n\t[Description(\"The maximum number of connections allowed in the pool.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueMaxPoolSize)]\n\tpublic int MaxPoolSize\n\t{\n\t\tget { return Common.ConnectionString.GetInt32(GetKey(Common.ConnectionString.DefaultKeyMaxPoolSize), base.TryGetValue, Common.ConnectionString.DefaultValueMaxPoolSize); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyMaxPoolSize, value); }\n\t}\n\n\t[Category(\"Advanced\")]\n\t[DisplayName(\"FetchSize\")]\n\t[Description(\"The maximum number of rows to be fetched in a single call to read into the internal row buffer.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueFetchSize)]\n\tpublic int FetchSize\n\t{\n\t\tget { return Common.ConnectionString.GetInt32(GetKey(Common.ConnectionString.DefaultKeyFetchSize), base.TryGetValue, Common.ConnectionString.DefaultValueFetchSize); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyFetchSize, value); }\n\t}\n\n\t[Category(\"Source\")]\n\t[DisplayName(\"ServerType\")]\n\t[Description(\"The type of server used.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueServerType)]\n\tpublic FbServerType ServerType\n\t{\n\t\tget { return GetServerType(Common.ConnectionString.DefaultKeyServerType, Common.ConnectionString.DefaultValueServerType); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyServerType, value); }\n\t}\n\n\t[Category(\"Advanced\")]\n\t[DisplayName(\"IsolationLevel\")]\n\t[Description(\"The default Isolation Level for implicit transactions.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueIsolationLevel)]\n\tpublic IsolationLevel IsolationLevel\n\t{\n\t\tget { return GetIsolationLevel(Common.ConnectionString.DefaultKeyIsolationLevel, Common.ConnectionString.DefaultValueIsolationLevel); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyIsolationLevel, value); }\n\t}\n\n\t[Category(\"Advanced\")]\n\t[DisplayName(\"Records Affected\")]\n\t[Description(\"Get the number of rows affected by a command when true.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueRecordsAffected)]\n\tpublic bool ReturnRecordsAffected\n\t{\n\t\tget { return Common.ConnectionString.GetBoolean(GetKey(Common.ConnectionString.DefaultKeyRecordsAffected), base.TryGetValue, Common.ConnectionString.DefaultValueRecordsAffected); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyRecordsAffected, value); }\n\t}\n\n\t[Category(\"Pooling\")]\n\t[DisplayName(\"Enlist\")]\n\t[Description(\"If true, enlists the connections in the current transaction.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValuePooling)]\n\tpublic bool Enlist\n\t{\n\t\tget { return Common.ConnectionString.GetBoolean(GetKey(Common.ConnectionString.DefaultKeyEnlist), base.TryGetValue, Common.ConnectionString.DefaultValueEnlist); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyEnlist, value); }\n\t}\n\n\t[Category(\"Advanced\")]\n\t[DisplayName(\"Client Library\")]\n\t[Description(\"Client library for Firebird Embedded.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueClientLibrary)]\n\tpublic string ClientLibrary\n\t{\n\t\tget { return Common.ConnectionString.GetString(GetKey(Common.ConnectionString.DefaultKeyClientLibrary), base.TryGetValue, Common.ConnectionString.DefaultValueClientLibrary); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyClientLibrary, value); }\n\t}\n\n\t[Category(\"Advanced\")]\n\t[DisplayName(\"DB Cache Pages\")]\n\t[Description(\"How many cache buffers to use for this session.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueDbCachePages)]\n\tpublic int DbCachePages\n\t{\n\t\tget { return Common.ConnectionString.GetInt32(GetKey(Common.ConnectionString.DefaultKeyDbCachePages), base.TryGetValue, Common.ConnectionString.DefaultValueDbCachePages); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyDbCachePages, value); }\n\t}\n\n\t[Category(\"Advanced\")]\n\t[DisplayName(\"No Triggers\")]\n\t[Description(\"Disables database triggers for this connection.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueNoDbTriggers)]\n\tpublic bool NoDatabaseTriggers\n\t{\n\t\tget { return Common.ConnectionString.GetBoolean(GetKey(Common.ConnectionString.DefaultKeyNoDbTriggers), base.TryGetValue, Common.ConnectionString.DefaultValueNoDbTriggers); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyNoDbTriggers, value); }\n\t}\n\n\t[Category(\"Advanced\")]\n\t[DisplayName(\"No Garbage Collect\")]\n\t[Description(\"If true, disables sweeping the database upon attachment.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueNoGarbageCollect)]\n\tpublic bool NoGarbageCollect\n\t{\n\t\tget { return Common.ConnectionString.GetBoolean(GetKey(Common.ConnectionString.DefaultKeyNoGarbageCollect), base.TryGetValue, Common.ConnectionString.DefaultValueNoGarbageCollect); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyNoGarbageCollect, value); }\n\t}\n\n\t[Category(\"Advanced\")]\n\t[DisplayName(\"Compression\")]\n\t[Description(\"Enables or disables wire compression.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueCompression)]\n\tpublic bool Compression\n\t{\n\t\tget { return Common.ConnectionString.GetBoolean(GetKey(Common.ConnectionString.DefaultKeyCompression), base.TryGetValue, Common.ConnectionString.DefaultValueCompression); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyCompression, value); }\n\t}\n\n\t[Category(\"Advanced\")]\n\t[DisplayName(\"Crypt Key\")]\n\t[Description(\"Key used for database decryption.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueCryptKey)]\n\tpublic byte[] CryptKey\n\t{\n\t\tget { return GetBytes(Common.ConnectionString.DefaultKeyCryptKey, Common.ConnectionString.DefaultValueCryptKey); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyCryptKey, value); }\n\t}\n\n\t[Category(\"Advanced\")]\n\t[DisplayName(\"Wire Crypt\")]\n\t[Description(\"Selection for wire encryption.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueWireCrypt)]\n\tpublic FbWireCrypt WireCrypt\n\t{\n\t\tget { return GetWireCrypt(Common.ConnectionString.DefaultKeyWireCrypt, Common.ConnectionString.DefaultValueWireCrypt); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyWireCrypt, value); }\n\t}\n\n\t[Category(\"Advanced\")]\n\t[DisplayName(\"Application Name\")]\n\t[Description(\"The name of the application making the connection.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueApplicationName)]\n\tpublic string ApplicationName\n\t{\n\t\tget { return Common.ConnectionString.GetString(GetKey(Common.ConnectionString.DefaultKeyApplicationName), base.TryGetValue, Common.ConnectionString.DefaultValueApplicationName); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyApplicationName, value); }\n\t}\n\n\t[Category(\"Advanced\")]\n\t[DisplayName(\"Command Timeout\")]\n\t[Description(\"The time (in seconds) for command execution.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueCommandTimeout)]\n\tpublic int CommandTimeout\n\t{\n\t\tget { return Common.ConnectionString.GetInt32(GetKey(Common.ConnectionString.DefaultKeyCommandTimeout), base.TryGetValue, Common.ConnectionString.DefaultValueCommandTimeout); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyCommandTimeout, value); }\n\t}\n\n\t[Category(\"Advanced\")]\n\t[DisplayName(\"Parallel Workers\")]\n\t[Description(\"Number of parallel workers to use for certain operations in Firebird.\")]\n\t[DefaultValue(Common.ConnectionString.DefaultValueParallelWorkers)]\n\tpublic int ParallelWorkers\n\t{\n\t\tget { return Common.ConnectionString.GetInt32(GetKey(Common.ConnectionString.DefaultKeyParallelWorkers), base.TryGetValue, Common.ConnectionString.DefaultValueParallelWorkers); }\n\t\tset { SetValue(Common.ConnectionString.DefaultKeyParallelWorkers, value); }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FbConnectionStringBuilder()\n\t{ }\n\n\tpublic FbConnectionStringBuilder(string connectionString)\n\t\t: this()\n\t{\n\t\tConnectionString = connectionString;\n\t}\n\n\t#endregion\n\n\t#region Private methods\n\n\tprivate FbServerType GetServerType(string keyword, FbServerType defaultValue)\n\t{\n\t\tvar key = GetKey(keyword);\n\t\tif (!TryGetValue(key, out var value))\n\t\t\treturn defaultValue;\n\t\tswitch (value)\n\t\t{\n\t\t\tcase FbServerType fbServerType:\n\t\t\t\treturn fbServerType;\n\t\t\tcase string s when Enum.TryParse<FbServerType>(s, true, out var enumResult):\n\t\t\t\treturn enumResult;\n\t\t\tdefault:\n\t\t\t\treturn Common.ConnectionString.GetServerType(key, base.TryGetValue, defaultValue);\n\t\t}\n\t}\n\n\tprivate IsolationLevel GetIsolationLevel(string keyword, IsolationLevel defaultValue)\n\t{\n\t\tvar key = GetKey(keyword);\n\t\tif (!TryGetValue(key, out var value))\n\t\t\treturn defaultValue;\n\t\tswitch (value)\n\t\t{\n\t\t\tcase IsolationLevel isolationLevel:\n\t\t\t\treturn isolationLevel;\n\t\t\tcase string s when Enum.TryParse<IsolationLevel>(s, true, out var enumResult):\n\t\t\t\treturn enumResult;\n\t\t\tdefault:\n\t\t\t\treturn Common.ConnectionString.GetIsolationLevel(key, base.TryGetValue, defaultValue);\n\t\t}\n\t}\n\n\tprivate FbWireCrypt GetWireCrypt(string keyword, FbWireCrypt defaultValue)\n\t{\n\t\tvar key = GetKey(keyword);\n\t\tif (!TryGetValue(key, out var value))\n\t\t\treturn defaultValue;\n\t\tswitch (value)\n\t\t{\n\t\t\tcase FbWireCrypt fbWireCrypt:\n\t\t\t\treturn fbWireCrypt;\n\t\t\tcase string s when Enum.TryParse<FbWireCrypt>(s, true, out var enumResult):\n\t\t\t\treturn enumResult;\n\t\t\tdefault:\n\t\t\t\treturn Common.ConnectionString.GetWireCrypt(key, base.TryGetValue, defaultValue);\n\t\t}\n\t}\n\n\tprivate byte[] GetBytes(string keyword, byte[] defaultValue)\n\t{\n\t\tvar key = GetKey(keyword);\n\t\tif (!TryGetValue(key, out var value))\n\t\t\treturn defaultValue;\n\t\tswitch (value)\n\t\t{\n\t\t\tcase byte[] bytes:\n\t\t\t\treturn bytes;\n\t\t\tcase string s:\n\t\t\t\treturn Convert.FromBase64String(s);\n\t\t\tdefault:\n\t\t\t\treturn defaultValue;\n\t\t}\n\t}\n\n\tprivate void SetValue<T>(string keyword, T value)\n\t{\n\t\tvar key = GetKey(keyword);\n\t\tif (value is byte[] bytes)\n\t\t{\n\t\t\tthis[key] = Convert.ToBase64String(bytes);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tthis[key] = value;\n\t\t}\n\t}\n\n\tprivate string GetKey(string keyword)\n\t{\n\t\tvar synonymKey = Common.ConnectionString.Synonyms[keyword];\n\t\tforeach (string key in Keys)\n\t\t{\n\t\t\tif (Common.ConnectionString.Synonyms.ContainsKey(key) && Common.ConnectionString.Synonyms[key] == synonymKey)\n\t\t\t{\n\t\t\t\tsynonymKey = key;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn synonymKey;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbDataAdapter.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Data.Common;\nusing System.Collections.Generic;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\n[DefaultEvent(\"RowUpdated\")]\npublic sealed class FbDataAdapter : DbDataAdapter, ICloneable\n{\n\t#region Static Fields\n\n\tprivate static readonly object EventRowUpdated = new object();\n\tprivate static readonly object EventRowUpdating = new object();\n\n\t#endregion\n\n\t#region Events\n\n\tpublic event EventHandler<FbRowUpdatedEventArgs> RowUpdated\n\t{\n\t\tadd\n\t\t{\n\t\t\tbase.Events.AddHandler(EventRowUpdated, value);\n\t\t}\n\n\t\tremove\n\t\t{\n\t\t\tbase.Events.RemoveHandler(EventRowUpdated, value);\n\t\t}\n\t}\n\n\tpublic event EventHandler<FbRowUpdatingEventArgs> RowUpdating\n\t{\n\t\tadd\n\t\t{\n\t\t\tbase.Events.AddHandler(EventRowUpdating, value);\n\t\t}\n\n\t\tremove\n\t\t{\n\t\t\tbase.Events.RemoveHandler(EventRowUpdating, value);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Fields\n\n\tprivate bool _disposed;\n\tprivate bool _shouldDisposeSelectCommand;\n\n\t#endregion\n\n\t#region Properties\n\n\t[Category(\"Fill\")]\n\t[DefaultValue(null)]\n\tpublic new FbCommand SelectCommand\n\t{\n\t\tget { return (FbCommand)base.SelectCommand; }\n\t\tset { base.SelectCommand = value; }\n\t}\n\n\t[Category(\"Update\")]\n\t[DefaultValue(null)]\n\tpublic new FbCommand InsertCommand\n\t{\n\t\tget { return (FbCommand)base.InsertCommand; }\n\t\tset { base.InsertCommand = value; }\n\t}\n\n\t[Category(\"Update\")]\n\t[DefaultValue(null)]\n\tpublic new FbCommand UpdateCommand\n\t{\n\t\tget { return (FbCommand)base.UpdateCommand; }\n\t\tset { base.UpdateCommand = value; }\n\t}\n\n\t[Category(\"Update\")]\n\t[DefaultValue(null)]\n\tpublic new FbCommand DeleteCommand\n\t{\n\t\tget { return (FbCommand)base.DeleteCommand; }\n\t\tset { base.DeleteCommand = value; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FbDataAdapter()\n\t\t: base()\n\t{\n\t}\n\n\tpublic FbDataAdapter(FbCommand selectCommand)\n\t\t: base()\n\t{\n\t\tSelectCommand = selectCommand;\n\t}\n\n\tpublic FbDataAdapter(string selectCommandText, string selectConnectionString)\n\t\t: this(selectCommandText, new FbConnection(selectConnectionString))\n\t{\n\t}\n\n\tpublic FbDataAdapter(string selectCommandText, FbConnection selectConnection)\n\t\t: base()\n\t{\n\t\tSelectCommand = new FbCommand(selectCommandText, selectConnection);\n\t\t_shouldDisposeSelectCommand = true;\n\t}\n\n\t#endregion\n\n\t#region IDisposable\tMethods\n\n\tprotected override void Dispose(bool disposing)\n\t{\n\t\tif (disposing)\n\t\t{\n\t\t\tif (!_disposed)\n\t\t\t{\n\t\t\t\t_disposed = true;\n\t\t\t\tif (_shouldDisposeSelectCommand)\n\t\t\t\t{\n\t\t\t\t\tif (SelectCommand != null)\n\t\t\t\t\t{\n\t\t\t\t\t\tSelectCommand.Dispose();\n\t\t\t\t\t\tSelectCommand = null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbase.Dispose(disposing);\n\t\t\t}\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Protected Methods\n\n\tprotected override RowUpdatingEventArgs CreateRowUpdatingEvent(\n\t\tDataRow dataRow,\n\t\tIDbCommand command,\n\t\tStatementType statementType,\n\t\tDataTableMapping tableMapping)\n\t{\n\t\treturn new FbRowUpdatingEventArgs(dataRow, command, statementType, tableMapping);\n\t}\n\n\tprotected override RowUpdatedEventArgs CreateRowUpdatedEvent(\n\t\tDataRow dataRow,\n\t\tIDbCommand command,\n\t\tStatementType statementType,\n\t\tDataTableMapping tableMapping)\n\t{\n\t\treturn new FbRowUpdatedEventArgs(dataRow, command, statementType, tableMapping);\n\t}\n\n\tprotected override void OnRowUpdating(RowUpdatingEventArgs value)\n\t{\n\t\tEventHandler<FbRowUpdatingEventArgs> handler = null;\n\n\t\thandler = (EventHandler<FbRowUpdatingEventArgs>)base.Events[EventRowUpdating];\n\n\t\tif ((null != handler) &&\n\t\t\t(value is FbRowUpdatingEventArgs) &&\n\t\t\t(value != null))\n\t\t{\n\t\t\thandler(this, (FbRowUpdatingEventArgs)value);\n\t\t}\n\t}\n\n\tprotected override void OnRowUpdated(RowUpdatedEventArgs value)\n\t{\n\t\tEventHandler<FbRowUpdatedEventArgs> handler = null;\n\n\t\thandler = (EventHandler<FbRowUpdatedEventArgs>)base.Events[EventRowUpdated];\n\n\t\tif ((handler != null) &&\n\t\t\t(value is FbRowUpdatedEventArgs) &&\n\t\t\t(value != null))\n\t\t{\n\t\t\thandler(this, (FbRowUpdatedEventArgs)value);\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Update DataRow Collection\n\n\t/// <summary>\n\t/// Review .NET\tFramework documentation.\n\t/// </summary>\n\tprotected override int Update(DataRow[] dataRows, DataTableMapping tableMapping)\n\t{\n\t\tvar updated = 0;\n\t\tIDbCommand command = null;\n\t\tvar statementType = StatementType.Insert;\n\t\tICollection<IDbConnection> connections = new List<IDbConnection>();\n\t\tRowUpdatingEventArgs updatingArgs = null;\n\t\tException updateException = null;\n\n\t\tforeach (var row in dataRows)\n\t\t{\n\t\t\tupdateException = null;\n\n\t\t\tif (row.RowState == DataRowState.Detached ||\n\t\t\t\trow.RowState == DataRowState.Unchanged)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tswitch (row.RowState)\n\t\t\t{\n\t\t\t\tcase DataRowState.Unchanged:\n\t\t\t\tcase DataRowState.Detached:\n\t\t\t\t\tcontinue;\n\n\t\t\t\tcase DataRowState.Added:\n\t\t\t\t\tcommand = InsertCommand;\n\t\t\t\t\tstatementType = StatementType.Insert;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DataRowState.Modified:\n\t\t\t\t\tcommand = UpdateCommand;\n\t\t\t\t\tstatementType = StatementType.Update;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase DataRowState.Deleted:\n\t\t\t\t\tcommand = DeleteCommand;\n\t\t\t\t\tstatementType = StatementType.Delete;\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t/* The order of\texecution can be reviewed in the .NET 1.1 documentation\n\t\t\t *\n\t\t\t * 1. The values in\tthe\tDataRow\tare\tmoved to the parameter values.\n\t\t\t * 2. The OnRowUpdating\tevent is raised.\n\t\t\t * 3. The command executes.\n\t\t\t * 4. If the command is\tset\tto FirstReturnedRecord,\tthen the first returned\tresult is placed in\tthe\tDataRow.\n\t\t\t * 5. If there are output parameters, they are placed in the DataRow.\n\t\t\t * 6. The OnRowUpdated event is\traised.\n\t\t\t * 7 AcceptChanges is called.\n\t\t\t */\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\tupdatingArgs = CreateRowUpdatingEvent(row, command, statementType, tableMapping);\n\n\t\t\t\t/* 1. Update Parameter values (It's\tvery similar to\twhat we\n\t\t\t\t * are doing in\tthe\tFbCommandBuilder class).\n\t\t\t\t *\n\t\t\t\t * Only\tinput parameters should\tbe updated.\n\t\t\t\t */\n\t\t\t\tif (command != null && command.Parameters.Count > 0)\n\t\t\t\t{\n\t\t\t\t\ttry\n\t\t\t\t\t{\n\t\t\t\t\t\tUpdateParameterValues(command, statementType, row, tableMapping);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (Exception ex)\n\t\t\t\t\t{\n\t\t\t\t\t\tupdatingArgs.Errors = ex;\n\t\t\t\t\t\tupdatingArgs.Status = UpdateStatus.ErrorsOccurred;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// 2. Raise\tRowUpdating\tevent\n\t\t\t\tOnRowUpdating(updatingArgs);\n\n\t\t\t\tif (updatingArgs.Status == UpdateStatus.SkipAllRemainingRows)\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse if (updatingArgs.Status == UpdateStatus.ErrorsOccurred)\n\t\t\t\t{\n\t\t\t\t\tif (updatingArgs.Errors == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new InvalidOperationException(\"RowUpdatingEvent: Errors occurred; no additional information is available.\");\n\t\t\t\t\t}\n\t\t\t\t\tthrow updatingArgs.Errors;\n\t\t\t\t}\n\t\t\t\telse if (updatingArgs.Status == UpdateStatus.SkipCurrentRow)\n\t\t\t\t{\n\t\t\t\t\tupdated++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\telse if (updatingArgs.Status == UpdateStatus.Continue)\n\t\t\t\t{\n\t\t\t\t\tif (command != updatingArgs.Command)\n\t\t\t\t\t{\n\t\t\t\t\t\tcommand = updatingArgs.Command;\n\t\t\t\t\t}\n\t\t\t\t\tif (command == null)\n\t\t\t\t\t{\n\t\t\t\t\t\t/* Samples of exceptions thrown\tby DbDataAdapter class\n\t\t\t\t\t\t *\n\t\t\t\t\t\t *\tUpdate requires\ta valid\tInsertCommand when passed DataRow collection with new rows\n\t\t\t\t\t\t *\tUpdate requires\ta valid\tUpdateCommand when passed DataRow collection with modified rows.\n\t\t\t\t\t\t *\tUpdate requires\ta valid\tDeleteCommand when passed DataRow collection with deleted rows.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tthrow new InvalidOperationException(CreateExceptionMessage(statementType));\n\t\t\t\t\t}\n\n\t\t\t\t\t// 3. Execute the command\n\t\t\t\t\tif (command.Connection.State == ConnectionState.Closed)\n\t\t\t\t\t{\n\t\t\t\t\t\tcommand.Connection.Open();\n\t\t\t\t\t\t// Track command connection\n\t\t\t\t\t\tconnections.Add(command.Connection);\n\t\t\t\t\t}\n\n\t\t\t\t\tvar rowsAffected = command.ExecuteNonQuery();\n\t\t\t\t\tif (rowsAffected == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new DBConcurrencyException(new DBConcurrencyException().Message, null, new DataRow[] { row });\n\t\t\t\t\t}\n\n\t\t\t\t\tupdated++;\n\n\t\t\t\t\t// http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=933212&SiteID=1\n\t\t\t\t\tif (statementType == StatementType.Insert)\n\t\t\t\t\t{\n\t\t\t\t\t\trow.AcceptChanges();\n\t\t\t\t\t}\n\n\t\t\t\t\t/* 4. If the command is\tset\tto FirstReturnedRecord,\tthen the\n\t\t\t\t\t * first returned result is\tplaced in the DataRow.\n\t\t\t\t\t *\n\t\t\t\t\t * We have nothing to do in\tthis case as there are no\n\t\t\t\t\t * support for batch commands.\n\t\t\t\t\t */\n\n\t\t\t\t\t/* 5. Check\tif we have output parameters and they should\n\t\t\t\t\t * be updated.\n\t\t\t\t\t *\n\t\t\t\t\t * Only\toutput parameters should be\tupdated\n\t\t\t\t\t */\n\t\t\t\t\tif (command.UpdatedRowSource == UpdateRowSource.OutputParameters ||\n\t\t\t\t\t\tcommand.UpdatedRowSource == UpdateRowSource.Both)\n\t\t\t\t\t{\n\t\t\t\t\t\t// Process output parameters\n\t\t\t\t\t\tforeach (IDataParameter parameter in command.Parameters)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif ((parameter.Direction == ParameterDirection.Output ||\n\t\t\t\t\t\t\t\tparameter.Direction == ParameterDirection.ReturnValue ||\n\t\t\t\t\t\t\t\tparameter.Direction == ParameterDirection.InputOutput) &&\n\t\t\t\t\t\t\t\t!string.IsNullOrEmpty(parameter.SourceColumn))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tDataColumn column = null;\n\n\t\t\t\t\t\t\t\tvar columnMapping = tableMapping.GetColumnMappingBySchemaAction(\n\t\t\t\t\t\t\t\t\tparameter.SourceColumn,\n\t\t\t\t\t\t\t\t\tMissingMappingAction);\n\n\t\t\t\t\t\t\t\tif (columnMapping != null)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcolumn = columnMapping.GetDataColumnBySchemaAction(\n\t\t\t\t\t\t\t\t\t\trow.Table,\n\t\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t\t\tMissingSchemaAction);\n\n\t\t\t\t\t\t\t\t\tif (column != null)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\trow[column] = parameter.Value;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (Exception ex)\n\t\t\t{\n\t\t\t\trow.RowError = ex.Message;\n\t\t\t\tupdateException = ex;\n\t\t\t}\n\n\t\t\tif (updatingArgs != null && updatingArgs.Status == UpdateStatus.Continue)\n\t\t\t{\n\t\t\t\t// 6. Raise\tRowUpdated event\n\t\t\t\tvar updatedArgs = CreateRowUpdatedEvent(row, command, statementType, tableMapping);\n\t\t\t\tOnRowUpdated(updatedArgs);\n\n\t\t\t\tif (updatedArgs.Status == UpdateStatus.SkipAllRemainingRows)\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse if (updatedArgs.Status == UpdateStatus.ErrorsOccurred)\n\t\t\t\t{\n\t\t\t\t\tif (updatingArgs.Errors == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new InvalidOperationException(\"RowUpdatedEvent: Errors occurred; no additional information available.\");\n\t\t\t\t\t}\n\t\t\t\t\tthrow updatedArgs.Errors;\n\t\t\t\t}\n\t\t\t\telse if (updatedArgs.Status == UpdateStatus.SkipCurrentRow)\n\t\t\t\t{\n\t\t\t\t}\n\t\t\t\telse if (updatingArgs.Status == UpdateStatus.Continue)\n\t\t\t\t{\n\t\t\t\t\t// If the update result is an exception throw it\n\t\t\t\t\tif (!ContinueUpdateOnError && updateException != null)\n\t\t\t\t\t{\n\t\t\t\t\t\tCloseConnections(connections);\n\t\t\t\t\t\tthrow updateException;\n\t\t\t\t\t}\n\n\t\t\t\t\t// 7. Call AcceptChanges\n\t\t\t\t\tif (AcceptChangesDuringUpdate && !row.HasErrors)\n\t\t\t\t\t{\n\t\t\t\t\t\trow.AcceptChanges();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// If the update result is an exception throw it\n\t\t\t\tif (!ContinueUpdateOnError && updateException != null)\n\t\t\t\t{\n\t\t\t\t\tCloseConnections(connections);\n\t\t\t\t\tthrow updateException;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tCloseConnections(connections);\n\n\t\treturn updated;\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate string CreateExceptionMessage(StatementType statementType)\n\t{\n\t\tvar sb = new System.Text.StringBuilder();\n\n\t\tsb.Append(\"Update requires a valid \");\n\t\tsb.Append(statementType.ToString());\n\t\tsb.Append(\"Command when passed DataRow collection with \");\n\n\t\tswitch (statementType)\n\t\t{\n\t\t\tcase StatementType.Insert:\n\t\t\t\tsb.Append(\"new\");\n\t\t\t\tbreak;\n\n\t\t\tcase StatementType.Update:\n\t\t\t\tsb.Append(\"modified\");\n\t\t\t\tbreak;\n\n\t\t\tcase StatementType.Delete:\n\t\t\t\tsb.Append(\"deleted\");\n\t\t\t\tbreak;\n\t\t}\n\n\t\tsb.Append(\" rows.\");\n\n\t\treturn sb.ToString();\n\t}\n\n\tprivate void UpdateParameterValues(\n\t\tIDbCommand command,\n\t\tStatementType statementType,\n\t\tDataRow row,\n\t\tDataTableMapping tableMapping)\n\t{\n\t\tforeach (DbParameter parameter in command.Parameters)\n\t\t{\n\t\t\t// Process only input parameters\n\t\t\tif ((parameter.Direction == ParameterDirection.Input || parameter.Direction == ParameterDirection.InputOutput) &&\n\t\t\t\t!string.IsNullOrEmpty(parameter.SourceColumn))\n\t\t\t{\n\t\t\t\tDataColumn column = null;\n\n\t\t\t\t/* Get the DataColumnMapping that matches the given\n\t\t\t\t * column name\n\t\t\t\t */\n\t\t\t\tvar columnMapping = tableMapping.GetColumnMappingBySchemaAction(\n\t\t\t\t\tparameter.SourceColumn,\n\t\t\t\t\tMissingMappingAction);\n\n\t\t\t\tif (columnMapping != null)\n\t\t\t\t{\n\t\t\t\t\tcolumn = columnMapping.GetDataColumnBySchemaAction(row.Table, null, MissingSchemaAction);\n\n\t\t\t\t\tif (column != null)\n\t\t\t\t\t{\n\t\t\t\t\t\tvar dataRowVersion = DataRowVersion.Default;\n\n\t\t\t\t\t\tif (statementType == StatementType.Insert)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdataRowVersion = DataRowVersion.Current;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (statementType == StatementType.Update)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdataRowVersion = parameter.SourceVersion;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (statementType == StatementType.Delete)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdataRowVersion = DataRowVersion.Original;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (parameter.SourceColumnNullMapping)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tparameter.Value = IsNull(row[column, dataRowVersion]) ? 1 : 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tparameter.Value = row[column, dataRowVersion];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void CloseConnections(ICollection<IDbConnection> connections)\n\t{\n\t\tforeach (var c in connections)\n\t\t{\n\t\t\tc.Close();\n\t\t}\n\t\tconnections.Clear();\n\t}\n\n\tprivate bool IsNull(object value)\n\t{\n\t\treturn FirebirdSql.Data.Common.TypeHelper.IsDBNull(value);\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbDataReader.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Data.Common;\nusing System.IO;\nusing System.Linq;\nusing System.Numerics;\nusing System.Runtime.CompilerServices;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.Types;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic sealed class FbDataReader : DbDataReader\n{\n\t#region Constants\n\n\tprivate const int StartPosition = -1;\n\n\t#endregion\n\n\t#region Fields\n\n\tprivate DataTable _schemaTable;\n\tprivate FbCommand _command;\n\tprivate FbConnection _connection;\n\tprivate DbValue[] _row;\n\tprivate Descriptor _fields;\n\tprivate CommandBehavior _commandBehavior;\n\tprivate bool _eof;\n\tprivate bool _isClosed;\n\tprivate int _position;\n\tprivate int _recordsAffected;\n\tprivate Dictionary<string, int> _columnsIndexesOrdinal;\n\tprivate Dictionary<string, int> _columnsIndexesOrdinalCI;\n\n\t#endregion\n\n\t#region DbDataReader Indexers\n\n\tpublic override object this[int i]\n\t{\n\t\tget { return GetValue(i); }\n\t}\n\n\tpublic override object this[string name]\n\t{\n\t\tget { return GetValue(GetOrdinal(name)); }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tinternal FbDataReader()\n\t\t: base()\n\t{ }\n\n\tinternal FbDataReader(FbCommand command, FbConnection connection, CommandBehavior commandBehavior)\n\t{\n\t\t_position = StartPosition;\n\t\t_command = command;\n\t\t_connection = connection;\n\t\t_commandBehavior = commandBehavior;\n\t\t_fields = _command.GetFieldsDescriptor();\n\n\t\tUpdateRecordsAffected();\n\t}\n\n\t#endregion\n\n\t#region DbDataReader overriden Properties\n\n\tpublic override int Depth\n\t{\n\t\tget\n\t\t{\n\t\t\tCheckState();\n\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tpublic override bool HasRows\n\t{\n\t\tget { return _command.HasFields; }\n\t}\n\n\tpublic override bool IsClosed\n\t{\n\t\tget { return _isClosed; }\n\t}\n\n\tpublic override int FieldCount\n\t{\n\t\tget\n\t\t{\n\t\t\tCheckState();\n\n\t\t\treturn _fields.Count;\n\t\t}\n\t}\n\n\tpublic override int RecordsAffected\n\t{\n\t\tget { return _recordsAffected; }\n\t}\n\n\tpublic override int VisibleFieldCount\n\t{\n\t\tget\n\t\t{\n\t\t\tCheckState();\n\n\t\t\treturn _fields.Count;\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region DbDataReader overriden methods\n\n\tpublic override void Close()\n\t{\n\t\tif (!IsClosed)\n\t\t{\n\t\t\t_isClosed = true;\n\t\t\tif (_command != null && !_command.IsDisposed)\n\t\t\t{\n\t\t\t\tif (_command.CommandType == CommandType.StoredProcedure)\n\t\t\t\t{\n\t\t\t\t\t_command.SetOutputParameters();\n\t\t\t\t}\n\t\t\t\tif (_command.HasImplicitTransaction)\n\t\t\t\t{\n\t\t\t\t\t_command.CommitImplicitTransaction();\n\t\t\t\t}\n\t\t\t\t_command.ActiveReader = null;\n\t\t\t}\n\t\t\tif (_connection != null && IsCommandBehavior(CommandBehavior.CloseConnection))\n\t\t\t{\n\t\t\t\t_connection.Close();\n\t\t\t}\n\t\t\t_position = StartPosition;\n\t\t\t_command = null;\n\t\t\t_connection = null;\n\t\t\t_row = null;\n\t\t\t_schemaTable = null;\n\t\t\t_fields = null;\n\t\t}\n\t}\n\tpublic override async Task CloseAsync()\n\t{\n\t\tif (!IsClosed)\n\t\t{\n\t\t\t_isClosed = true;\n\t\t\tif (_command != null && !_command.IsDisposed)\n\t\t\t{\n\t\t\t\tif (_command.CommandType == CommandType.StoredProcedure)\n\t\t\t\t{\n\t\t\t\t\tawait _command.SetOutputParametersAsync(CancellationToken.None).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t\tif (_command.HasImplicitTransaction)\n\t\t\t\t{\n\t\t\t\t\tawait _command.CommitImplicitTransactionAsync(CancellationToken.None).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t\t_command.ActiveReader = null;\n\t\t\t}\n\t\t\tif (_connection != null && IsCommandBehavior(CommandBehavior.CloseConnection))\n\t\t\t{\n\t\t\t\tawait _connection.CloseAsync().ConfigureAwait(false);\n\t\t\t}\n\t\t\t_position = StartPosition;\n\t\t\t_command = null;\n\t\t\t_connection = null;\n\t\t\t_row = null;\n\t\t\t_schemaTable = null;\n\t\t\t_fields = null;\n\t\t}\n\t}\n\n\tprotected override void Dispose(bool disposing)\n\t{\n\t\tif (disposing)\n\t\t{\n\t\t\tClose();\n\t\t}\n\t}\n\tpublic override async ValueTask DisposeAsync()\n\t{\n\t\tawait CloseAsync().ConfigureAwait(false);\n\t\tawait base.DisposeAsync().ConfigureAwait(false);\n\t}\n\n\tpublic override bool Read()\n\t{\n\t\tCheckState();\n\n\t\tif (IsCommandBehavior(CommandBehavior.SchemaOnly))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\telse if (IsCommandBehavior(CommandBehavior.SingleRow) && _position != StartPosition)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tusing (var explicitCancellation = ExplicitCancellation.Enter(CancellationToken.None, _command.Cancel))\n\t\t\t{\n\t\t\t\t_row = _command.Fetch();\n\t\t\t\tif (_row != null)\n\t\t\t\t{\n\t\t\t\t\t_position++;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t_eof = true;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tpublic override async Task<bool> ReadAsync(CancellationToken cancellationToken)\n\t{\n\t\tCheckState();\n\n\t\tif (IsCommandBehavior(CommandBehavior.SchemaOnly))\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\telse if (IsCommandBehavior(CommandBehavior.SingleRow) && _position != StartPosition)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tusing (var explicitCancellation = ExplicitCancellation.Enter(cancellationToken, _command.Cancel))\n\t\t\t{\n\t\t\t\t_row = await _command.FetchAsync(explicitCancellation.CancellationToken).ConfigureAwait(false);\n\t\t\t\tif (_row != null)\n\t\t\t\t{\n\t\t\t\t\t_position++;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t_eof = true;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override DataTable GetSchemaTable()\n\t{\n\t\tCheckState();\n\n\t\tif (_schemaTable != null)\n\t\t{\n\t\t\treturn _schemaTable;\n\t\t}\n\n\t\tDataRow schemaRow = null;\n\t\tvar tableCount = 0;\n\t\tvar currentTable = string.Empty;\n\n\t\t_schemaTable = GetSchemaTableStructure();\n\n\t\t/* Prepare statement for schema fields information\t*/\n\t\tvar schemaCmd = new FbCommand(GetSchemaCommandText(), _command.Connection, _command.Connection.InnerConnection.ActiveTransaction);\n\t\ttry\n\t\t{\n\t\t\tschemaCmd.Parameters.Add(\"@TABLE_NAME\", FbDbType.Char, 31);\n\t\t\tschemaCmd.Parameters.Add(\"@COLUMN_NAME\", FbDbType.Char, 31);\n\t\t\tschemaCmd.Prepare();\n\n\t\t\t_schemaTable.BeginLoadData();\n\n\t\t\tfor (var i = 0; i < _fields.Count; i++)\n\t\t\t{\n\t\t\t\tvar isKeyColumn = false;\n\t\t\t\tvar isUnique = false;\n\t\t\t\tvar isReadOnly = false;\n\t\t\t\tvar precision = 0;\n\t\t\t\tvar isExpression = false;\n\n\t\t\t\t/* Get Schema data for the field\t*/\n\t\t\t\tschemaCmd.Parameters[0].Value = _fields[i].Relation;\n\t\t\t\tschemaCmd.Parameters[1].Value = _fields[i].Name;\n\n\t\t\t\tvar reader = schemaCmd.ExecuteReader(CommandBehavior.Default);\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tif (reader.Read())\n\t\t\t\t\t{\n\t\t\t\t\t\tisReadOnly = (IsReadOnly(reader) || IsExpression(reader)) ? true : false;\n\t\t\t\t\t\tisKeyColumn = (reader.GetInt32(2) == 1) ? true : false;\n\t\t\t\t\t\tisUnique = (reader.GetInt32(3) == 1) ? true : false;\n\t\t\t\t\t\tprecision = reader.IsDBNull(4) ? -1 : reader.GetInt32(4);\n\t\t\t\t\t\tisExpression = IsExpression(reader);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfinally\n\t\t\t\t{\n\t\t\t\t\treader.Dispose();\n\t\t\t\t}\n\n\t\t\t\t/* Create new row for the Schema Table\t*/\n\t\t\t\tschemaRow = _schemaTable.NewRow();\n\n\t\t\t\tschemaRow[\"ColumnName\"] = GetName(i);\n\t\t\t\tschemaRow[\"ColumnOrdinal\"] = i;\n\t\t\t\tschemaRow[\"ColumnSize\"] = _fields[i].GetSize();\n\t\t\t\tif (_fields[i].IsDecimal())\n\t\t\t\t{\n\t\t\t\t\tschemaRow[\"NumericPrecision\"] = schemaRow[\"ColumnSize\"];\n\t\t\t\t\tif (precision > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tschemaRow[\"NumericPrecision\"] = precision;\n\t\t\t\t\t}\n\t\t\t\t\tschemaRow[\"NumericScale\"] = _fields[i].NumericScale * (-1);\n\t\t\t\t}\n\t\t\t\tschemaRow[\"DataType\"] = GetFieldType(i);\n\t\t\t\tschemaRow[\"ProviderType\"] = GetProviderType(i);\n\t\t\t\tschemaRow[\"IsLong\"] = _fields[i].IsLong();\n\t\t\t\tschemaRow[\"AllowDBNull\"] = _fields[i].AllowDBNull();\n\t\t\t\tschemaRow[\"IsRowVersion\"] = false;\n\t\t\t\tschemaRow[\"IsAutoIncrement\"] = false;\n\t\t\t\tschemaRow[\"IsReadOnly\"] = isReadOnly;\n\t\t\t\tschemaRow[\"IsKey\"] = isKeyColumn;\n\t\t\t\tschemaRow[\"IsUnique\"] = isUnique;\n\t\t\t\tschemaRow[\"IsAliased\"] = _fields[i].IsAliased();\n\t\t\t\tschemaRow[\"IsExpression\"] = isExpression;\n\t\t\t\tschemaRow[\"BaseSchemaName\"] = DBNull.Value;\n\t\t\t\tschemaRow[\"BaseCatalogName\"] = DBNull.Value;\n\t\t\t\tschemaRow[\"BaseTableName\"] = _fields[i].Relation;\n\t\t\t\tschemaRow[\"BaseColumnName\"] = _fields[i].Name;\n\n\t\t\t\t_schemaTable.Rows.Add(schemaRow);\n\n\t\t\t\tif (!string.IsNullOrEmpty(_fields[i].Relation) && currentTable != _fields[i].Relation)\n\t\t\t\t{\n\t\t\t\t\ttableCount++;\n\t\t\t\t\tcurrentTable = _fields[i].Relation;\n\t\t\t\t}\n\n\t\t\t\tschemaCmd.Close();\n\t\t\t}\n\n\t\t\tif (tableCount > 1)\n\t\t\t{\n\t\t\t\tforeach (DataRow row in _schemaTable.Rows)\n\t\t\t\t{\n\t\t\t\t\trow[\"IsKey\"] = false;\n\t\t\t\t\trow[\"IsUnique\"] = false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_schemaTable.EndLoadData();\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tschemaCmd.Dispose();\n\t\t}\n\n\t\treturn _schemaTable;\n\t}\n\tpublic override async Task<DataTable> GetSchemaTableAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tCheckState();\n\n\t\tif (_schemaTable != null)\n\t\t{\n\t\t\treturn _schemaTable;\n\t\t}\n\n\t\tDataRow schemaRow = null;\n\t\tvar tableCount = 0;\n\t\tvar currentTable = string.Empty;\n\n\t\t_schemaTable = GetSchemaTableStructure();\n\n\t\t/* Prepare statement for schema fields information\t*/\n\t\tvar schemaCmd = new FbCommand(GetSchemaCommandText(), _command.Connection, _command.Connection.InnerConnection.ActiveTransaction);\n\t\ttry\n\t\t{\n\t\t\tschemaCmd.Parameters.Add(\"@TABLE_NAME\", FbDbType.Char, 31);\n\t\t\tschemaCmd.Parameters.Add(\"@COLUMN_NAME\", FbDbType.Char, 31);\n\t\t\tawait schemaCmd.PrepareAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t_schemaTable.BeginLoadData();\n\n\t\t\tfor (var i = 0; i < _fields.Count; i++)\n\t\t\t{\n\t\t\t\tvar isKeyColumn = false;\n\t\t\t\tvar isUnique = false;\n\t\t\t\tvar isReadOnly = false;\n\t\t\t\tvar precision = 0;\n\t\t\t\tvar isExpression = false;\n\n\t\t\t\t/* Get Schema data for the field\t*/\n\t\t\t\tschemaCmd.Parameters[0].Value = _fields[i].Relation;\n\t\t\t\tschemaCmd.Parameters[1].Value = _fields[i].Name;\n\n\t\t\t\tvar reader = await schemaCmd.ExecuteReaderAsync(CommandBehavior.Default, cancellationToken).ConfigureAwait(false);\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tif (await reader.ReadAsync(cancellationToken).ConfigureAwait(false))\n\t\t\t\t\t{\n\t\t\t\t\t\tisReadOnly = IsReadOnly(reader) || IsExpression(reader);\n\t\t\t\t\t\tisKeyColumn = reader.GetInt32(2) == 1;\n\t\t\t\t\t\tisUnique = reader.GetInt32(3) == 1;\n\t\t\t\t\t\tprecision = reader.IsDBNull(4) ? -1 : reader.GetInt32(4);\n\t\t\t\t\t\tisExpression = IsExpression(reader);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfinally\n\t\t\t\t{\n\t\t\t\t\tawait reader.DisposeAsync().ConfigureAwait(false);\n\t\t\t\t}\n\n\t\t\t\t/* Create new row for the Schema Table\t*/\n\t\t\t\tschemaRow = _schemaTable.NewRow();\n\n\t\t\t\tschemaRow[\"ColumnName\"] = GetName(i);\n\t\t\t\tschemaRow[\"ColumnOrdinal\"] = i;\n\t\t\t\tschemaRow[\"ColumnSize\"] = _fields[i].GetSize();\n\t\t\t\tif (_fields[i].IsDecimal())\n\t\t\t\t{\n\t\t\t\t\tschemaRow[\"NumericPrecision\"] = schemaRow[\"ColumnSize\"];\n\t\t\t\t\tif (precision > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tschemaRow[\"NumericPrecision\"] = precision;\n\t\t\t\t\t}\n\t\t\t\t\tschemaRow[\"NumericScale\"] = _fields[i].NumericScale * (-1);\n\t\t\t\t}\n\t\t\t\tschemaRow[\"DataType\"] = GetFieldType(i);\n\t\t\t\tschemaRow[\"ProviderType\"] = GetProviderType(i);\n\t\t\t\tschemaRow[\"IsLong\"] = _fields[i].IsLong();\n\t\t\t\tschemaRow[\"AllowDBNull\"] = _fields[i].AllowDBNull();\n\t\t\t\tschemaRow[\"IsRowVersion\"] = false;\n\t\t\t\tschemaRow[\"IsAutoIncrement\"] = false;\n\t\t\t\tschemaRow[\"IsReadOnly\"] = isReadOnly;\n\t\t\t\tschemaRow[\"IsKey\"] = isKeyColumn;\n\t\t\t\tschemaRow[\"IsUnique\"] = isUnique;\n\t\t\t\tschemaRow[\"IsAliased\"] = _fields[i].IsAliased();\n\t\t\t\tschemaRow[\"IsExpression\"] = isExpression;\n\t\t\t\tschemaRow[\"BaseSchemaName\"] = DBNull.Value;\n\t\t\t\tschemaRow[\"BaseCatalogName\"] = DBNull.Value;\n\t\t\t\tschemaRow[\"BaseTableName\"] = _fields[i].Relation;\n\t\t\t\tschemaRow[\"BaseColumnName\"] = _fields[i].Name;\n\n\t\t\t\t_schemaTable.Rows.Add(schemaRow);\n\n\t\t\t\tif (!string.IsNullOrEmpty(_fields[i].Relation) && currentTable != _fields[i].Relation)\n\t\t\t\t{\n\t\t\t\t\ttableCount++;\n\t\t\t\t\tcurrentTable = _fields[i].Relation;\n\t\t\t\t}\n\n\t\t\t\tawait schemaCmd.CloseAsync().ConfigureAwait(false);\n\t\t\t}\n\n\t\t\tif (tableCount > 1)\n\t\t\t{\n\t\t\t\tforeach (DataRow row in _schemaTable.Rows)\n\t\t\t\t{\n\t\t\t\t\trow[\"IsKey\"] = false;\n\t\t\t\t\trow[\"IsUnique\"] = false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_schemaTable.EndLoadData();\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tawait schemaCmd.DisposeAsync().ConfigureAwait(false);\n\t\t}\n\n\t\treturn _schemaTable;\n\t}\n\n\tpublic override int GetOrdinal(string name)\n\t{\n\t\tCheckState();\n\n\t\treturn GetColumnIndex(name);\n\t}\n\n\tpublic override string GetName(int i)\n\t{\n\t\tCheckState();\n\t\tCheckIndex(i);\n\n\t\tif (_fields[i].Alias.Length > 0)\n\t\t{\n\t\t\treturn _fields[i].Alias;\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn _fields[i].Name;\n\t\t}\n\t}\n\n\tpublic override string GetDataTypeName(int i)\n\t{\n\t\tCheckState();\n\t\tCheckIndex(i);\n\n\t\treturn TypeHelper.GetDataTypeName(_fields[i].DbDataType);\n\t}\n\n\tpublic override Type GetFieldType(int i)\n\t{\n\t\tCheckState();\n\t\tCheckIndex(i);\n\n\t\treturn _fields[i].GetSystemType();\n\t}\n\n\tpublic override Type GetProviderSpecificFieldType(int i)\n\t{\n\t\treturn GetFieldType(i);\n\t}\n\n\tpublic override object GetProviderSpecificValue(int i)\n\t{\n\t\treturn GetValue(i);\n\t}\n\n\tpublic override int GetProviderSpecificValues(object[] values)\n\t{\n\t\treturn GetValues(values);\n\t}\n\n\tpublic override object GetValue(int i)\n\t{\n\t\t// type coercions for EF\n\t\tif (_command.ExpectedColumnTypes != null)\n\t\t{\n\t\t\tvar type = _command.ExpectedColumnTypes.ElementAtOrDefault(i);\n\t\t\tvar nullableUnderlying = Nullable.GetUnderlyingType(type);\n\t\t\tif (nullableUnderlying != null)\n\t\t\t{\n\t\t\t\tif (IsDBNull(i))\n\t\t\t\t{\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tif (nullableUnderlying == typeof(bool))\n\t\t\t\t{\n\t\t\t\t\treturn GetFieldValue<bool>(i);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (type == typeof(bool))\n\t\t\t{\n\t\t\t\treturn GetFieldValue<bool>(i);\n\t\t\t}\n\t\t}\n\n\t\treturn GetFieldValue<object>(i);\n\t}\n\n\tpublic override int GetValues(object[] values)\n\t{\n\t\tvar count = Math.Min(_fields.Count, values.Length);\n\t\tfor (var i = 0; i < count; i++)\n\t\t{\n\t\t\tvalues[i] = GetValue(i);\n\t\t}\n\t\treturn count;\n\t}\n\n\tpublic override T GetFieldValue<T>(int i)\n\t{\n\t\tCheckState();\n\t\tCheckPosition();\n\t\tCheckIndex(i);\n\n\t\tvar type = typeof(T);\n\t\ttype = Nullable.GetUnderlyingType(type) ?? type;\n\t\ttry\n\t\t{\n\t\t\tif (type == typeof(bool))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetBoolean();\n\t\t\t}\n\t\t\telse if (type == typeof(byte))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetByte();\n\t\t\t}\n\t\t\telse if (type == typeof(char))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetChar();\n\t\t\t}\n\t\t\telse if (type == typeof(Guid))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetGuid();\n\t\t\t}\n\t\t\telse if (type == typeof(short))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetInt16();\n\t\t\t}\n\t\t\telse if (type == typeof(int))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetInt32();\n\t\t\t}\n\t\t\telse if (type == typeof(long))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetInt64();\n\t\t\t}\n\t\t\telse if (type == typeof(float))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetFloat();\n\t\t\t}\n\t\t\telse if (type == typeof(double))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetDouble();\n\t\t\t}\n\t\t\telse if (type == typeof(string))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetString();\n\t\t\t}\n\t\t\telse if (type == typeof(decimal))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetDecimal();\n\t\t\t}\n\t\t\telse if (type == typeof(DateTime))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetDateTime();\n\t\t\t}\n\t\t\telse if (type == typeof(TimeSpan))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetTimeSpan();\n\t\t\t}\n\t\t\telse if (type == typeof(byte[]))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetBinary();\n\t\t\t}\n\t\t\telse if (type == typeof(FbDecFloat))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetDecFloat();\n\t\t\t}\n\t\t\telse if (type == typeof(BigInteger))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetInt128();\n\t\t\t}\n\t\t\telse if (type == typeof(FbZonedDateTime))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetZonedDateTime();\n\t\t\t}\n\t\t\telse if (type == typeof(FbZonedTime))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetZonedTime();\n\t\t\t}\n\t\t\telse if (type == typeof(DateOnly))\n\t\t\t{\n\t\t\t\treturn (T)(object)DateOnly.FromDateTime(_row[i].GetDateTime());\n\t\t\t}\n\t\t\telse if (type == typeof(TimeOnly))\n\t\t\t{\n\t\t\t\treturn (T)(object)TimeOnly.FromTimeSpan(_row[i].GetTimeSpan());\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn (T)_row[i].GetValue();\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic override async Task<T> GetFieldValueAsync<T>(int i, CancellationToken cancellationToken)\n\t{\n\t\tCheckState();\n\t\tCheckPosition();\n\t\tCheckIndex(i);\n\n\t\tvar type = typeof(T);\n\t\ttype = Nullable.GetUnderlyingType(type) ?? type;\n\t\ttry\n\t\t{\n\t\t\tif (type == typeof(bool))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetBoolean();\n\t\t\t}\n\t\t\telse if (type == typeof(byte))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetByte();\n\t\t\t}\n\t\t\telse if (type == typeof(char))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetChar();\n\t\t\t}\n\t\t\telse if (type == typeof(Guid))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetGuid();\n\t\t\t}\n\t\t\telse if (type == typeof(short))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetInt16();\n\t\t\t}\n\t\t\telse if (type == typeof(int))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetInt32();\n\t\t\t}\n\t\t\telse if (type == typeof(long))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetInt64();\n\t\t\t}\n\t\t\telse if (type == typeof(float))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetFloat();\n\t\t\t}\n\t\t\telse if (type == typeof(double))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetDouble();\n\t\t\t}\n\t\t\telse if (type == typeof(string))\n\t\t\t{\n\t\t\t\treturn (T)(object)await _row[i].GetStringAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\telse if (type == typeof(decimal))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetDecimal();\n\t\t\t}\n\t\t\telse if (type == typeof(DateTime))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetDateTime();\n\t\t\t}\n\t\t\telse if (type == typeof(TimeSpan))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetTimeSpan();\n\t\t\t}\n\t\t\telse if (type == typeof(byte[]))\n\t\t\t{\n\t\t\t\treturn (T)(object)await _row[i].GetBinaryAsync().ConfigureAwait(false);\n\t\t\t}\n\t\t\telse if (type == typeof(FbDecFloat))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetDecFloat();\n\t\t\t}\n\t\t\telse if (type == typeof(BigInteger))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetInt128();\n\t\t\t}\n\t\t\telse if (type == typeof(FbZonedDateTime))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetZonedDateTime();\n\t\t\t}\n\t\t\telse if (type == typeof(FbZonedTime))\n\t\t\t{\n\t\t\t\treturn (T)(object)_row[i].GetZonedTime();\n\t\t\t}\n\t\t\telse if (type == typeof(DateOnly))\n\t\t\t{\n\t\t\t\treturn (T)(object)DateOnly.FromDateTime(_row[i].GetDateTime());\n\t\t\t}\n\t\t\telse if (type == typeof(TimeOnly))\n\t\t\t{\n\t\t\t\treturn (T)(object)TimeOnly.FromTimeSpan(_row[i].GetTimeSpan());\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn (T)await _row[i].GetValueAsync().ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic override bool GetBoolean(int i)\n\t{\n\t\treturn GetFieldValue<bool>(i);\n\t}\n\n\tpublic override byte GetByte(int i)\n\t{\n\t\treturn GetFieldValue<byte>(i);\n\t}\n\n\tpublic override long GetBytes(int i, long dataIndex, byte[] buffer, int bufferIndex, int length)\n\t{\n\t\tCheckState();\n\t\tCheckPosition();\n\t\tCheckIndex(i);\n\n\t\tvar bytesRead = 0;\n\t\tvar realLength = length;\n\n\t\tif (buffer == null)\n\t\t{\n\t\t\tif (IsDBNull(i))\n\t\t\t{\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn GetFieldValue<byte[]>(i).Length;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tvar byteArray = GetFieldValue<byte[]>(i);\n\n\t\t\tif (length > (byteArray.Length - dataIndex))\n\t\t\t{\n\t\t\t\trealLength = byteArray.Length - (int)dataIndex;\n\t\t\t}\n\n\t\t\tArray.Copy(byteArray, (int)dataIndex, buffer, bufferIndex, realLength);\n\n\t\t\tif ((byteArray.Length - dataIndex) < length)\n\t\t\t{\n\t\t\t\tbytesRead = byteArray.Length - (int)dataIndex;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tbytesRead = length;\n\t\t\t}\n\n\t\t\treturn bytesRead;\n\t\t}\n\t}\n\n\tpublic override char GetChar(int i)\n\t{\n\t\treturn GetFieldValue<char>(i);\n\t}\n\n\tpublic override long GetChars(int i, long dataIndex, char[] buffer, int bufferIndex, int length)\n\t{\n\t\tCheckState();\n\t\tCheckPosition();\n\t\tCheckIndex(i);\n\n\t\tif (buffer == null)\n\t\t{\n\t\t\tif (IsDBNull(i))\n\t\t\t{\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn GetFieldValue<string>(i).ToCharArray().Length;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\n\t\t\tvar charArray = GetFieldValue<string>(i).ToCharArray();\n\n\t\t\tvar charsRead = 0;\n\t\t\tvar realLength = length;\n\n\t\t\tif (length > (charArray.Length - dataIndex))\n\t\t\t{\n\t\t\t\trealLength = charArray.Length - (int)dataIndex;\n\t\t\t}\n\n\t\t\tArray.Copy(charArray, (int)dataIndex, buffer,\n\t\t\t\tbufferIndex, realLength);\n\n\t\t\tif ((charArray.Length - dataIndex) < length)\n\t\t\t{\n\t\t\t\tcharsRead = charArray.Length - (int)dataIndex;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcharsRead = length;\n\t\t\t}\n\n\t\t\treturn charsRead;\n\t\t}\n\t}\n\n\tpublic override Guid GetGuid(int i)\n\t{\n\t\treturn GetFieldValue<Guid>(i);\n\t}\n\n\tpublic override short GetInt16(int i)\n\t{\n\t\treturn GetFieldValue<short>(i);\n\t}\n\n\tpublic override int GetInt32(int i)\n\t{\n\t\treturn GetFieldValue<int>(i);\n\t}\n\n\tpublic override long GetInt64(int i)\n\t{\n\t\treturn GetFieldValue<long>(i);\n\t}\n\n\tpublic override float GetFloat(int i)\n\t{\n\t\treturn GetFieldValue<float>(i);\n\t}\n\n\tpublic override double GetDouble(int i)\n\t{\n\t\treturn GetFieldValue<double>(i);\n\t}\n\n\tpublic override string GetString(int i)\n\t{\n\t\treturn GetFieldValue<string>(i);\n\t}\n\n\tpublic override decimal GetDecimal(int i)\n\t{\n\t\treturn GetFieldValue<decimal>(i);\n\t}\n\n\tpublic override DateTime GetDateTime(int i)\n\t{\n\t\treturn GetFieldValue<DateTime>(i);\n\t}\n\n\tpublic override Stream GetStream(int i)\n\t{\n\t\tCheckState();\n\t\tCheckPosition();\n\t\tCheckIndex(i);\n\n\t\treturn _row[i].GetBinaryStream();\n\t}\n\n\tpublic override bool IsDBNull(int i)\n\t{\n\t\tCheckState();\n\t\tCheckPosition();\n\t\tCheckIndex(i);\n\n\t\treturn _row[i].IsDBNull();\n\t}\n\tpublic override Task<bool> IsDBNullAsync(int i, CancellationToken cancellationToken)\n\t{\n\t\tCheckState();\n\t\tCheckPosition();\n\t\tCheckIndex(i);\n\n\t\treturn Task.FromResult(_row[i].IsDBNull());\n\t}\n\n\tpublic override IEnumerator GetEnumerator()\n\t{\n\t\treturn new DbEnumerator(this, IsCommandBehavior(CommandBehavior.CloseConnection));\n\t}\n\n\tpublic override bool NextResult()\n\t{\n\t\treturn false;\n\t}\n\tpublic override Task<bool> NextResultAsync(CancellationToken cancellationToken)\n\t{\n\t\treturn Task.FromResult(false);\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void CheckPosition()\n\t{\n\t\tif (_eof || _position == StartPosition)\n\t\t\tthrow new InvalidOperationException(\"There are no data to read.\");\n\t}\n\n\tprivate void CheckState()\n\t{\n\t\tif (IsClosed)\n\t\t\tthrow new InvalidOperationException(\"Invalid attempt of read when the reader is closed.\");\n\t}\n\n\tprivate void CheckIndex(int i)\n\t{\n\t\tif (i < 0 || i >= FieldCount)\n\t\t\tthrow new IndexOutOfRangeException(\"Could not find specified column in results.\");\n\t}\n\n\tprivate FbDbType GetProviderType(int i)\n\t{\n\t\treturn (FbDbType)_fields[i].DbDataType;\n\t}\n\n\tprivate void UpdateRecordsAffected()\n\t{\n\t\tif (_command != null && !_command.IsDisposed)\n\t\t{\n\t\t\tif (_command.RecordsAffected != -1)\n\t\t\t{\n\t\t\t\t_recordsAffected = _recordsAffected == -1 ? 0 : _recordsAffected;\n\t\t\t\t_recordsAffected += _command.RecordsAffected;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate bool IsCommandBehavior(CommandBehavior behavior)\n\t{\n\t\treturn _commandBehavior.HasFlag(behavior);\n\t}\n\n\tprivate void InitializeColumnsIndexes()\n\t{\n\t\t_columnsIndexesOrdinal = new Dictionary<string, int>(_fields.Count, StringComparer.Ordinal);\n\t\t_columnsIndexesOrdinalCI = new Dictionary<string, int>(_fields.Count, StringComparer.OrdinalIgnoreCase);\n\t\tfor (var i = 0; i < _fields.Count; i++)\n\t\t{\n\t\t\tvar fieldName = _fields[i].Alias;\n\t\t\tif (!_columnsIndexesOrdinal.ContainsKey(fieldName))\n\t\t\t\t_columnsIndexesOrdinal.Add(fieldName, i);\n\t\t\tif (!_columnsIndexesOrdinalCI.ContainsKey(fieldName))\n\t\t\t\t_columnsIndexesOrdinalCI.Add(fieldName, i);\n\t\t}\n\t}\n\n\tprivate int GetColumnIndex(string name)\n\t{\n\t\tif (_columnsIndexesOrdinal == null || _columnsIndexesOrdinalCI == null)\n\t\t{\n\t\t\tInitializeColumnsIndexes();\n\t\t}\n\t\tif (!_columnsIndexesOrdinal.TryGetValue(name, out var index))\n\t\t\tif (!_columnsIndexesOrdinalCI.TryGetValue(name, out index))\n\t\t\t\tthrow new IndexOutOfRangeException($\"Could not find specified column '{name}' in results.\");\n\t\treturn index;\n\t}\n\n\t#endregion\n\n\t#region Static Methods\n\n\tprivate static bool IsReadOnly(FbDataReader r)\n\t{\n\t\treturn IsExpression(r);\n\t}\n\n\tpublic static bool IsExpression(FbDataReader r)\n\t{\n\t\t/* [0] = COMPUTED_BLR\n\t\t * [1] = COMPUTED_SOURCE\n\t\t */\n\t\tif (!r.IsDBNull(0) || !r.IsDBNull(1))\n\t\t{\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate static DataTable GetSchemaTableStructure()\n\t{\n\t\tvar schema = new DataTable(\"Schema\");\n\n\t\t// Schema table structure\n\t\tschema.Columns.Add(\"ColumnName\", Type.GetType(\"System.String\"));\n\t\tschema.Columns.Add(\"ColumnOrdinal\", Type.GetType(\"System.Int32\"));\n\t\tschema.Columns.Add(\"ColumnSize\", Type.GetType(\"System.Int32\"));\n\t\tschema.Columns.Add(\"NumericPrecision\", Type.GetType(\"System.Int32\"));\n\t\tschema.Columns.Add(\"NumericScale\", Type.GetType(\"System.Int32\"));\n\t\tschema.Columns.Add(\"DataType\", Type.GetType(\"System.Type\"));\n\t\tschema.Columns.Add(\"ProviderType\", Type.GetType(\"System.Int32\"));\n\t\tschema.Columns.Add(\"IsLong\", Type.GetType(\"System.Boolean\"));\n\t\tschema.Columns.Add(\"AllowDBNull\", Type.GetType(\"System.Boolean\"));\n\t\tschema.Columns.Add(\"IsReadOnly\", Type.GetType(\"System.Boolean\"));\n\t\tschema.Columns.Add(\"IsRowVersion\", Type.GetType(\"System.Boolean\"));\n\t\tschema.Columns.Add(\"IsUnique\", Type.GetType(\"System.Boolean\"));\n\t\tschema.Columns.Add(\"IsKey\", Type.GetType(\"System.Boolean\"));\n\t\tschema.Columns.Add(\"IsAutoIncrement\", Type.GetType(\"System.Boolean\"));\n\t\tschema.Columns.Add(\"IsAliased\", Type.GetType(\"System.Boolean\"));\n\t\tschema.Columns.Add(\"IsExpression\", Type.GetType(\"System.Boolean\"));\n\t\tschema.Columns.Add(\"BaseSchemaName\", Type.GetType(\"System.String\"));\n\t\tschema.Columns.Add(\"BaseCatalogName\", Type.GetType(\"System.String\"));\n\t\tschema.Columns.Add(\"BaseTableName\", Type.GetType(\"System.String\"));\n\t\tschema.Columns.Add(\"BaseColumnName\", Type.GetType(\"System.String\"));\n\n\t\treturn schema;\n\t}\n\n\tprivate static string GetSchemaCommandText()\n\t{\n\t\tconst string sql =\n\t\t\t@\"SELECT\n\t\t\t\t\tfld.rdb$computed_blr AS computed_blr,\n\t\t\t\t\tfld.rdb$computed_source AS computed_source,\n\t\t\t\t\t(SELECT COUNT(*) FROM rdb$relation_constraints rel\n\t\t\t\t\t  INNER JOIN rdb$indices idx ON rel.rdb$index_name = idx.rdb$index_name\n\t\t\t\t\t  INNER JOIN rdb$index_segments seg ON idx.rdb$index_name = seg.rdb$index_name\n\t\t\t\t\tWHERE rel.rdb$constraint_type = 'PRIMARY KEY'\n\t\t\t\t\t  AND rel.rdb$relation_name = rfr.rdb$relation_name\n\t\t\t\t\t  AND seg.rdb$field_name = rfr.rdb$field_name) AS primary_key,\n\t\t\t\t\t(SELECT COUNT(*) FROM rdb$relation_constraints rel\n\t\t\t\t\t  INNER JOIN rdb$indices idx ON rel.rdb$index_name = idx.rdb$index_name\n\t\t\t\t\t  INNER JOIN rdb$index_segments seg ON idx.rdb$index_name = seg.rdb$index_name\n\t\t\t\t\tWHERE rel.rdb$constraint_type = 'UNIQUE'\n\t\t\t\t\t  AND rel.rdb$relation_name = rfr.rdb$relation_name\n\t\t\t\t\t  AND seg.rdb$field_name = rfr.rdb$field_name) AS unique_key,\n\t\t\t\t\tfld.rdb$field_precision AS numeric_precision\n\t\t\t\t  FROM rdb$relation_fields rfr\n\t\t\t\t\tINNER JOIN rdb$fields fld ON rfr.rdb$field_source = fld.rdb$field_name\n\t\t\t\t  WHERE rfr.rdb$relation_name = ?\n\t\t\t\t\tAND rfr.rdb$field_name = ?\n\t\t\t\t  ORDER BY rfr.rdb$relation_name, rfr.rdb$field_position\";\n\n\t\treturn sql;\n\t}\n\n\t[MethodImpl(MethodImplOptions.AggressiveInlining)]\n\tprivate static T CheckedGetValue2<T>(Func<T> getter)\n\t{\n\t\ttry\n\t\t{\n\t\t\treturn getter();\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbDatabaseInfo.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Data;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.Types;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic sealed class FbDatabaseInfo\n{\n\t#region Properties\n\n\tpublic FbConnection Connection { get; set; }\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic string GetIscVersion()\n\t{\n\t\treturn GetValue<string>(IscCodes.isc_info_isc_version);\n\t}\n\tpublic Task<string> GetIscVersionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<string>(IscCodes.isc_info_isc_version, cancellationToken);\n\t}\n\n\tpublic string GetServerVersion()\n\t{\n\t\treturn GetValue<string>(IscCodes.isc_info_firebird_version);\n\t}\n\tpublic Task<string> GetServerVersionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<string>(IscCodes.isc_info_firebird_version, cancellationToken);\n\t}\n\n\tpublic string GetServerClass()\n\t{\n\t\treturn GetValue<string>(IscCodes.isc_info_db_class);\n\t}\n\tpublic Task<string> GetServerClassAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<string>(IscCodes.isc_info_db_class, cancellationToken);\n\t}\n\n\tpublic int GetPageSize()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_page_size);\n\t}\n\tpublic Task<int> GetPageSizeAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_page_size, cancellationToken);\n\t}\n\n\tpublic int GetAllocationPages()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_allocation);\n\t}\n\tpublic Task<int> GetAllocationPagesAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_allocation, cancellationToken);\n\t}\n\n\tpublic string GetBaseLevel()\n\t{\n\t\treturn GetValue<string>(IscCodes.isc_info_base_level);\n\t}\n\tpublic Task<string> GetBaseLevelAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<string>(IscCodes.isc_info_base_level, cancellationToken);\n\t}\n\n\tpublic string GetDbId()\n\t{\n\t\treturn GetValue<string>(IscCodes.isc_info_db_id);\n\t}\n\tpublic Task<string> GetDbIdAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<string>(IscCodes.isc_info_db_id, cancellationToken);\n\t}\n\n\tpublic string GetImplementation()\n\t{\n\t\treturn GetValue<string>(IscCodes.isc_info_implementation);\n\t}\n\tpublic Task<string> GetImplementationAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<string>(IscCodes.isc_info_implementation, cancellationToken);\n\t}\n\n\tpublic bool GetNoReserve()\n\t{\n\t\treturn GetValue<bool>(IscCodes.isc_info_no_reserve);\n\t}\n\tpublic Task<bool> GetNoReserveAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<bool>(IscCodes.isc_info_no_reserve, cancellationToken);\n\t}\n\n\tpublic int GetOdsVersion()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_ods_version);\n\t}\n\tpublic Task<int> GetOdsVersionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_ods_version, cancellationToken);\n\t}\n\n\tpublic int GetOdsMinorVersion()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_ods_minor_version);\n\t}\n\tpublic Task<int> GetOdsMinorVersionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_ods_minor_version, cancellationToken);\n\t}\n\n\tpublic int GetMaxMemory()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_max_memory);\n\t}\n\tpublic Task<int> GetMaxMemoryAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_max_memory, cancellationToken);\n\t}\n\n\tpublic int GetCurrentMemory()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_current_memory);\n\t}\n\tpublic Task<int> GetCurrentMemoryAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_current_memory, cancellationToken);\n\t}\n\n\tpublic bool GetForcedWrites()\n\t{\n\t\treturn GetValue<bool>(IscCodes.isc_info_forced_writes);\n\t}\n\tpublic Task<bool> GetForcedWritesAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<bool>(IscCodes.isc_info_forced_writes, cancellationToken);\n\t}\n\n\tpublic int GetNumBuffers()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_num_buffers);\n\t}\n\tpublic Task<int> GetNumBuffersAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_num_buffers, cancellationToken);\n\t}\n\n\tpublic int GetSweepInterval()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_sweep_interval);\n\t}\n\tpublic Task<int> GetSweepIntervalAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_sweep_interval, cancellationToken);\n\t}\n\n\tpublic bool GetReadOnly()\n\t{\n\t\treturn GetValue<bool>(IscCodes.isc_info_db_read_only);\n\t}\n\tpublic Task<bool> GetReadOnlyAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<bool>(IscCodes.isc_info_db_read_only, cancellationToken);\n\t}\n\n\tpublic int GetFetches()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_fetches);\n\t}\n\tpublic Task<int> GetFetchesAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_fetches, cancellationToken);\n\t}\n\n\tpublic int GetMarks()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_marks);\n\t}\n\tpublic Task<int> GetMarksAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_marks, cancellationToken);\n\t}\n\n\tpublic int GetReads()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_reads);\n\t}\n\tpublic Task<int> GetReadsAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_reads, cancellationToken);\n\t}\n\n\tpublic int GetWrites()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_writes);\n\t}\n\tpublic Task<int> GetWritesAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_writes, cancellationToken);\n\t}\n\n\tpublic int GetBackoutCount()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_backout_count);\n\t}\n\tpublic Task<int> GetBackoutCountAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_backout_count, cancellationToken);\n\t}\n\n\tpublic int GetDeleteCount()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_delete_count);\n\t}\n\tpublic Task<int> GetDeleteCountAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_delete_count, cancellationToken);\n\t}\n\n\tpublic int GetExpungeCount()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_expunge_count);\n\t}\n\tpublic Task<int> GetExpungeCountAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_expunge_count, cancellationToken);\n\t}\n\n\tpublic int GetInsertCount()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_insert_count);\n\t}\n\tpublic Task<int> GetInsertCountAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_insert_count, cancellationToken);\n\t}\n\n\tpublic int GetPurgeCount()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_purge_count);\n\t}\n\tpublic Task<int> GetPurgeCountAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_purge_count, cancellationToken);\n\t}\n\n\tpublic long GetReadIdxCount()\n\t{\n\t\treturn GetValue<long>(IscCodes.isc_info_read_idx_count);\n\t}\n\tpublic Task<long> GetReadIdxCountAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<long>(IscCodes.isc_info_read_idx_count, cancellationToken);\n\t}\n\n\tpublic long GetReadSeqCount()\n\t{\n\t\treturn GetValue<long>(IscCodes.isc_info_read_seq_count);\n\t}\n\tpublic Task<long> GetReadSeqCountAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<long>(IscCodes.isc_info_read_seq_count, cancellationToken);\n\t}\n\n\tpublic long GetUpdateCount()\n\t{\n\t\treturn GetValue<long>(IscCodes.isc_info_update_count);\n\t}\n\tpublic Task<long> GetUpdateCountAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<long>(IscCodes.isc_info_update_count, cancellationToken);\n\t}\n\n\tpublic int GetDatabaseSizeInPages()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_db_size_in_pages);\n\t}\n\tpublic Task<int> GetDatabaseSizeInPagesAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_db_size_in_pages, cancellationToken);\n\t}\n\n\tpublic long GetOldestTransaction()\n\t{\n\t\treturn GetValue<long>(IscCodes.isc_info_oldest_transaction);\n\t}\n\tpublic Task<long> GetOldestTransactionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<long>(IscCodes.isc_info_oldest_transaction, cancellationToken);\n\t}\n\n\tpublic long GetOldestActiveTransaction()\n\t{\n\t\treturn GetValue<long>(IscCodes.isc_info_oldest_active);\n\t}\n\tpublic Task<long> GetOldestActiveTransactionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<long>(IscCodes.isc_info_oldest_active, cancellationToken);\n\t}\n\n\tpublic long GetOldestActiveSnapshot()\n\t{\n\t\treturn GetValue<long>(IscCodes.isc_info_oldest_snapshot);\n\t}\n\tpublic Task<long> GetOldestActiveSnapshotAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<long>(IscCodes.isc_info_oldest_snapshot, cancellationToken);\n\t}\n\n\tpublic long GetNextTransaction()\n\t{\n\t\treturn GetValue<long>(IscCodes.isc_info_next_transaction);\n\t}\n\tpublic Task<long> GetNextTransactionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<long>(IscCodes.isc_info_next_transaction, cancellationToken);\n\t}\n\n\tpublic List<long> GetActiveTransactions()\n\t{\n\t\treturn GetList<long>(IscCodes.isc_info_active_transactions);\n\t}\n\tpublic Task<List<long>> GetActiveTransactionsAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetListAsync<long>(IscCodes.isc_info_active_transactions, cancellationToken);\n\t}\n\n\tpublic int GetActiveTransactionsCount()\n\t{\n\t\treturn GetValue<int>(IscCodes.isc_info_active_tran_count);\n\t}\n\tpublic Task<int> GetActiveTransactionsCountAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.isc_info_active_tran_count, cancellationToken);\n\t}\n\n\tpublic List<string> GetActiveUsers()\n\t{\n\t\treturn GetList<string>(IscCodes.isc_info_user_names);\n\t}\n\tpublic Task<List<string>> GetActiveUsersAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetListAsync<string>(IscCodes.isc_info_user_names, cancellationToken);\n\t}\n\n\tpublic string GetWireCrypt()\n\t{\n\t\treturn GetValue<string>(IscCodes.fb_info_wire_crypt);\n\t}\n\tpublic Task<string> GetWireCryptAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<string>(IscCodes.fb_info_wire_crypt, cancellationToken);\n\t}\n\n\tpublic string GetCryptPlugin()\n\t{\n\t\treturn GetValue<string>(IscCodes.fb_info_crypt_plugin);\n\t}\n\tpublic Task<string> GetCryptPluginAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<string>(IscCodes.fb_info_crypt_plugin, cancellationToken);\n\t}\n\n\tpublic DateTime GetCreationDate()\n\t{\n\t\treturn GetValue<DateTime>(IscCodes.isc_info_creation_date);\n\t}\n\tpublic Task<DateTime> GetCreationDateAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<DateTime>(IscCodes.isc_info_creation_date, cancellationToken);\n\t}\n\n\tpublic long GetNextAttachment()\n\t{\n\t\treturn GetValue<long>(IscCodes.fb_info_next_attachment);\n\t}\n\tpublic Task<long> GetNextAttachmentAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<long>(IscCodes.fb_info_next_attachment, cancellationToken);\n\t}\n\n\tpublic long GetNextStatement()\n\t{\n\t\treturn GetValue<long>(IscCodes.fb_info_next_statement);\n\t}\n\tpublic Task<long> GetNextStatementAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<long>(IscCodes.fb_info_next_statement, cancellationToken);\n\t}\n\n\tpublic string GetReplicaMode()\n\t{\n\t\treturn GetValue<string>(IscCodes.fb_info_replica_mode);\n\t}\n\tpublic Task<string> GetReplicaModeAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<string>(IscCodes.fb_info_replica_mode, cancellationToken);\n\t}\n\n\tpublic string GetDbFileId()\n\t{\n\t\treturn GetValue<string>(IscCodes.fb_info_db_file_id);\n\t}\n\tpublic Task<string> GetDbFileIdAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<string>(IscCodes.fb_info_db_file_id, cancellationToken);\n\t}\n\n\tpublic Guid GetDbGuid()\n\t{\n\t\treturn GetValue<Guid>(IscCodes.fb_info_db_guid);\n\t}\n\tpublic Task<Guid> GetDbGuidAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<Guid>(IscCodes.fb_info_db_guid, cancellationToken);\n\t}\n\n\tpublic FbZonedDateTime GetCreationTimestamp()\n\t{\n\t\treturn GetValue<FbZonedDateTime>(IscCodes.fb_info_creation_timestamp_tz);\n\t}\n\tpublic Task<FbZonedDateTime> GetCreationTimestampAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<FbZonedDateTime>(IscCodes.fb_info_creation_timestamp_tz, cancellationToken);\n\t}\n\n\tpublic int GetProtocolVersion()\n\t{\n\t\treturn GetValue<int>(IscCodes.fb_info_protocol_version);\n\t}\n\tpublic Task<int> GetProtocolVersionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.fb_info_protocol_version, cancellationToken);\n\t}\n\n\tpublic int GetStatementTimeoutDatabase()\n\t{\n\t\treturn GetValue<int>(IscCodes.fb_info_statement_timeout_db);\n\t}\n\tpublic Task<int> GetStatementTimeoutDatabaseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.fb_info_statement_timeout_db, cancellationToken);\n\t}\n\n\tpublic int GetStatementTimeoutAttachment()\n\t{\n\t\treturn GetValue<int>(IscCodes.fb_info_statement_timeout_att);\n\t}\n\tpublic Task<int> GetStatementTimeoutAttachmentAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<int>(IscCodes.fb_info_statement_timeout_att, cancellationToken);\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FbDatabaseInfo(FbConnection connection = null)\n\t{\n\t\tConnection = connection;\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate T GetValue<T>(byte item)\n\t{\n\t\tFbConnection.EnsureOpen(Connection);\n\n\t\tvar items = new byte[]\n\t\t{\n\t\t\titem,\n\t\t\tIscCodes.isc_info_end\n\t\t};\n\t\tvar info = Connection.InnerConnection.Database.GetDatabaseInfo(items);\n\t\treturn info.Any() ? InfoValuesHelper.ConvertValue<T>(info[0]) : default;\n\t}\n\tprivate async Task<T> GetValueAsync<T>(byte item, CancellationToken cancellationToken = default)\n\t{\n\t\tFbConnection.EnsureOpen(Connection);\n\n\t\tvar items = new byte[]\n\t\t{\n\t\t\titem,\n\t\t\tIscCodes.isc_info_end\n\t\t};\n\t\tvar info = await Connection.InnerConnection.Database.GetDatabaseInfoAsync(items, cancellationToken).ConfigureAwait(false);\n\t\treturn info.Any() ? InfoValuesHelper.ConvertValue<T>(info[0]) : default;\n\t}\n\n\tprivate List<T> GetList<T>(byte item)\n\t{\n\t\tFbConnection.EnsureOpen(Connection);\n\n\t\tvar items = new byte[]\n\t\t{\n\t\t\titem,\n\t\t\tIscCodes.isc_info_end\n\t\t};\n\n\t\treturn (Connection.InnerConnection.Database.GetDatabaseInfo(items)).Select(InfoValuesHelper.ConvertValue<T>).ToList();\n\t}\n\tprivate async Task<List<T>> GetListAsync<T>(byte item, CancellationToken cancellationToken = default)\n\t{\n\t\tFbConnection.EnsureOpen(Connection);\n\n\t\tvar items = new byte[]\n\t\t{\n\t\t\titem,\n\t\t\tIscCodes.isc_info_end\n\t\t};\n\n\t\treturn (await Connection.InnerConnection.Database.GetDatabaseInfoAsync(items, cancellationToken).ConfigureAwait(false)).Select(InfoValuesHelper.ConvertValue<T>).ToList();\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbDbType.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\n[Serializable]\npublic enum FbDbType\n{\n\tArray,\n\tBigInt,\n\tBinary,\n\tBoolean,\n\tChar,\n\tDate,\n\tDecimal,\n\tDouble,\n\tFloat,\n\tGuid,\n\tInteger,\n\tNumeric,\n\tSmallInt,\n\tText,\n\tTime,\n\tTimeStamp,\n\tVarChar,\n\tTimeStampTZ,\n\tTimeStampTZEx,\n\tTimeTZ,\n\tTimeTZEx,\n\tDec16,\n\tDec34,\n\tInt128,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbEnlistmentNotification.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading;\nusing System.Transactions;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\ninternal sealed class FbEnlistmentNotification : IEnlistmentNotification\n{\n\t#region Events\n\n\tpublic event EventHandler Completed;\n\n\t#endregion\n\n\t#region Fields\n\n\tprivate FbConnectionInternal _connection;\n\tprivate FbTransaction _transaction;\n\tprivate Transaction _systemTransaction;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic bool IsCompleted\n\t{\n\t\tget { return (_transaction == null); }\n\t}\n\n\tpublic Transaction SystemTransaction\n\t{\n\t\tget { return _systemTransaction; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FbEnlistmentNotification(FbConnectionInternal connection, Transaction systemTransaction)\n\t{\n\t\t_connection = connection;\n\t\t_transaction = connection.BeginTransaction(systemTransaction.IsolationLevel);\n\t\t_systemTransaction = systemTransaction;\n\n\t\t_systemTransaction.EnlistVolatile(this, EnlistmentOptions.None);\n\t}\n\n\t#endregion\n\n\t#region IEnlistmentNotification Members\n\n\tpublic void Commit(Enlistment enlistment)\n\t{\n\t\tif (_transaction != null && !_transaction.IsCompleted)\n\t\t{\n\t\t\t_transaction.Commit();\n\t\t\t_transaction = null;\n\n\t\t\tCompleted?.Invoke(this, new EventArgs());\n\n\t\t\tif (_connection != null)\n\t\t\t{\n\t\t\t\tif (!_connection.ConnectionStringOptions.Pooling && (_connection.OwningConnection == null || _connection.OwningConnection.IsClosed))\n\t\t\t\t{\n\t\t\t\t\t_connection.Disconnect();\n\t\t\t\t}\n\t\t\t}\n\t\t\t_connection = null;\n\t\t\t_systemTransaction = null;\n\n\t\t\t// Declare done on the enlistment\n\t\t\tenlistment.Done();\n\t\t}\n\t}\n\n\tpublic void InDoubt(Enlistment enlistment)\n\t{\n\t\tthrow new NotSupportedException(\"In Doubt transactions are not supported\");\n\t}\n\n\tpublic void Prepare(PreparingEnlistment preparingEnlistment)\n\t{\n\t\tpreparingEnlistment.Prepared();\n\t}\n\n\tpublic void Rollback(Enlistment enlistment)\n\t{\n\t\tif (_transaction != null && !_transaction.IsCompleted)\n\t\t{\n\t\t\t_transaction.Rollback();\n\t\t\t_transaction = null;\n\n\t\t\tCompleted?.Invoke(this, new EventArgs());\n\n\t\t\tif (_connection != null)\n\t\t\t{\n\t\t\t\tif (!_connection.ConnectionStringOptions.Pooling && (_connection.OwningConnection == null || _connection.OwningConnection.IsClosed))\n\t\t\t\t{\n\t\t\t\t\t_connection.Disconnect();\n\t\t\t\t}\n\t\t\t}\n\t\t\t_connection = null;\n\t\t\t_systemTransaction = null;\n\n\t\t\t// Declare done on the enlistment\n\t\t\tenlistment.Done();\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbError.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\n[Serializable]\npublic sealed class FbError\n{\n\t#region Fields\n\n\tprivate byte _classError;\n\tprivate int _lineNumber;\n\tprivate string _message;\n\tprivate int _number;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic byte Class\n\t{\n\t\tget { return _classError; }\n\t}\n\n\tpublic int LineNumber\n\t{\n\t\tget { return _lineNumber; }\n\t}\n\n\tpublic string Message\n\t{\n\t\tget { return _message; }\n\t}\n\n\tpublic int Number\n\t{\n\t\tget { return _number; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tinternal FbError(string message, int number)\n\t\t: this(0, 0, message, number)\n\t{\n\t}\n\n\tinternal FbError(byte classError, string message, int number)\n\t\t: this(classError, 0, message, number)\n\t{\n\t}\n\n\tinternal FbError(byte classError, int line, string message, int number)\n\t{\n\t\t_classError = classError;\n\t\t_lineNumber = line;\n\t\t_number = number;\n\t\t_message = message;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbErrorCollection.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.ComponentModel;\nusing System.Collections.Generic;\n\nusing FirebirdSql.Data.Common;\nusing System.Collections;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\n[Serializable]\n[ListBindable(false)]\npublic sealed class FbErrorCollection : ICollection<FbError>\n{\n\t#region Fields\n\n\tprivate List<FbError> _errors;\n\n\t#endregion\n\n\t#region Constructors\n\n\tinternal FbErrorCollection()\n\t{\n\t\t_errors = new List<FbError>();\n\t}\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic int Count\n\t{\n\t\tget { return _errors.Count; }\n\t}\n\n\tpublic bool IsReadOnly\n\t{\n\t\tget { return true; }\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tinternal int IndexOf(string errorMessage)\n\t{\n\t\treturn _errors.FindIndex(x => string.Equals(x.Message, errorMessage, StringComparison.CurrentCultureIgnoreCase));\n\t}\n\n\tinternal FbError Add(FbError error)\n\t{\n\t\t_errors.Add(error);\n\n\t\treturn error;\n\t}\n\n\tinternal FbError Add(string errorMessage, int number)\n\t{\n\t\treturn Add(new FbError(errorMessage, number));\n\t}\n\n\tvoid ICollection<FbError>.Add(FbError item)\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\n\tvoid ICollection<FbError>.Clear()\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\n\tpublic bool Contains(FbError item)\n\t{\n\t\treturn _errors.Contains(item);\n\t}\n\n\tpublic void CopyTo(FbError[] array, int arrayIndex)\n\t{\n\t\t_errors.CopyTo(array, arrayIndex);\n\t}\n\n\tbool ICollection<FbError>.Remove(FbError item)\n\t{\n\t\tthrow new NotSupportedException();\n\t}\n\n\tpublic IEnumerator<FbError> GetEnumerator()\n\t{\n\t\treturn _errors.GetEnumerator();\n\t}\n\n\tIEnumerator IEnumerable.GetEnumerator()\n\t{\n\t\treturn GetEnumerator();\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbException.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.ComponentModel;\nusing System.Data.Common;\n\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic sealed class FbException : DbException\n{\n\tprivate FbErrorCollection _errors;\n\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]\n\tpublic FbErrorCollection Errors => _errors ??= new FbErrorCollection();\n\n\tpublic override int ErrorCode => (InnerException as IscException)?.ErrorCode ?? 0;\n\n\tpublic string SQLSTATE => (InnerException as IscException)?.SQLSTATE;\n\n\tprivate FbException(string message, Exception innerException)\n\t\t: base(message, innerException)\n\t{ }\n\n\tprivate void ProcessIscExceptionErrors(IscException innerException)\n\t{\n\t\tforeach (var error in innerException.Errors)\n\t\t{\n\t\t\tErrors.Add(error.Message, error.ErrorCode);\n\t\t}\n\t}\n\n\tinternal static Exception Create(string message) => Create(message, null);\n\tinternal static Exception Create(Exception innerException) => Create(null, innerException);\n\tinternal static Exception Create(string message, Exception innerException)\n\t{\n\t\tmessage ??= innerException?.Message;\n\t\tif (innerException is IscException iscException)\n\t\t{\n\t\t\tif (iscException.ErrorCode == IscCodes.isc_cancelled)\n\t\t\t{\n\t\t\t\treturn new OperationCanceledException(message, innerException);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tvar result = new FbException(message, innerException);\n\t\t\t\tresult.ProcessIscExceptionErrors(iscException);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn new FbException(message, innerException);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbInfoMessageEventArgs.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez\n\nusing System;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic sealed class FbInfoMessageEventArgs : EventArgs\n{\n\t#region Fields\n\n\tprivate FbErrorCollection _errors;\n\tprivate string _message;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic FbErrorCollection Errors\n\t{\n\t\tget { return _errors; }\n\t}\n\n\tpublic string Message\n\t{\n\t\tget { return _message; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tinternal FbInfoMessageEventArgs(IscException ex)\n\t{\n\t\t_message = ex.Message;\n\t\t_errors = new FbErrorCollection();\n\t\tforeach (var error in ex.Errors)\n\t\t{\n\t\t\t_errors.Add(error.Message, error.ErrorCode);\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbParameter.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Data.Common;\nusing System.ComponentModel;\n\nusing FirebirdSql.Data.Common;\nusing System.Text;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\n[ParenthesizePropertyName(true)]\npublic sealed class FbParameter : DbParameter, ICloneable\n{\n\t#region Fields\n\n\tprivate FbParameterCollection _parent;\n\tprivate FbDbType _fbDbType;\n\tprivate ParameterDirection _direction;\n\tprivate DataRowVersion _sourceVersion;\n\tprivate FbCharset _charset;\n\tprivate bool _isNullable;\n\tprivate bool _sourceColumnNullMapping;\n\tprivate byte _precision;\n\tprivate byte _scale;\n\tprivate int _size;\n\tprivate object _value;\n\tprivate string _parameterName;\n\tprivate string _sourceColumn;\n\tprivate string _internalParameterName;\n\tprivate bool _isUnicodeParameterName;\n\n\t#endregion\n\n\t#region DbParameter properties\n\n\t[DefaultValue(\"\")]\n\tpublic override string ParameterName\n\t{\n\t\tget { return _parameterName; }\n\t\tset\n\t\t{\n\t\t\t_parameterName = value;\n\t\t\t_internalParameterName = NormalizeParameterName(_parameterName);\n\t\t\t_isUnicodeParameterName = IsNonAsciiParameterName(_parameterName);\n\t\t\t_parent?.ParameterNameChanged();\n\t\t}\n\t}\n\n\t[Category(\"Data\")]\n\t[DefaultValue(0)]\n\tpublic override int Size\n\t{\n\t\tget\n\t\t{\n\t\t\treturn (HasSize ? _size : RealValueSize ?? 0);\n\t\t}\n\t\tset\n\t\t{\n\t\t\tif (value < 0)\n\t\t\t\tthrow new ArgumentOutOfRangeException();\n\n\t\t\t_size = value;\n\n\t\t\t// Hack for Clob parameters\n\t\t\tif (value == 2147483647 &&\n\t\t\t\t(FbDbType == FbDbType.VarChar || FbDbType == FbDbType.Char))\n\t\t\t{\n\t\t\t\tFbDbType = FbDbType.Text;\n\t\t\t}\n\t\t}\n\t}\n\n\t[Category(\"Data\")]\n\t[DefaultValue(ParameterDirection.Input)]\n\tpublic override ParameterDirection Direction\n\t{\n\t\tget { return _direction; }\n\t\tset { _direction = value; }\n\t}\n\n\t[Browsable(false)]\n\t[DesignOnly(true)]\n\t[DefaultValue(false)]\n\t[EditorBrowsable(EditorBrowsableState.Advanced)]\n\tpublic override bool IsNullable\n\t{\n\t\tget { return _isNullable; }\n\t\tset { _isNullable = value; }\n\t}\n\n\t[Category(\"Data\")]\n\t[DefaultValue(\"\")]\n\tpublic override string SourceColumn\n\t{\n\t\tget { return _sourceColumn; }\n\t\tset { _sourceColumn = value; }\n\t}\n\n\t[Category(\"Data\")]\n\t[DefaultValue(DataRowVersion.Current)]\n\tpublic override DataRowVersion SourceVersion\n\t{\n\t\tget { return _sourceVersion; }\n\t\tset { _sourceVersion = value; }\n\t}\n\n\t[Browsable(false)]\n\t[Category(\"Data\")]\n\t[RefreshProperties(RefreshProperties.All)]\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\tpublic override DbType DbType\n\t{\n\t\tget { return TypeHelper.GetDbTypeFromDbDataType((DbDataType)_fbDbType); }\n\t\tset { FbDbType = (FbDbType)TypeHelper.GetDbDataTypeFromDbType(value); }\n\t}\n\n\t[RefreshProperties(RefreshProperties.All)]\n\t[Category(\"Data\")]\n\t[DefaultValue(FbDbType.VarChar)]\n\tpublic FbDbType FbDbType\n\t{\n\t\tget { return _fbDbType; }\n\t\tset\n\t\t{\n\t\t\t_fbDbType = value;\n\t\t\tIsTypeSet = true;\n\t\t}\n\t}\n\n\t[Category(\"Data\")]\n\t[TypeConverter(typeof(StringConverter)), DefaultValue(null)]\n\tpublic override object Value\n\t{\n\t\tget { return _value; }\n\t\tset\n\t\t{\n\t\t\tif (value == null)\n\t\t\t{\n\t\t\t\tvalue = DBNull.Value;\n\t\t\t}\n\n\t\t\tif (FbDbType == FbDbType.Guid && value != null &&\n\t\t\t\tvalue != DBNull.Value && !(value is Guid) && !(value is byte[]))\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException(\"Incorrect Guid value.\");\n\t\t\t}\n\n\t\t\t_value = value;\n\n\t\t\tif (!IsTypeSet)\n\t\t\t{\n\t\t\t\tSetFbDbType(value);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Category(\"Data\")]\n\t[DefaultValue(FbCharset.Default)]\n\tpublic FbCharset Charset\n\t{\n\t\tget { return _charset; }\n\t\tset { _charset = value; }\n\t}\n\n\tpublic override bool SourceColumnNullMapping\n\t{\n\t\tget { return _sourceColumnNullMapping; }\n\t\tset { _sourceColumnNullMapping = value; }\n\t}\n\n\t#endregion\n\n\t#region Properties\n\n\t[Category(\"Data\")]\n\t[DefaultValue((byte)0)]\n\tpublic override byte Precision\n\t{\n\t\tget { return _precision; }\n\t\tset { _precision = value; }\n\t}\n\n\t[Category(\"Data\")]\n\t[DefaultValue((byte)0)]\n\tpublic override byte Scale\n\t{\n\t\tget { return _scale; }\n\t\tset { _scale = value; }\n\t}\n\n\t#endregion\n\n\t#region Internal Properties\n\n\tinternal FbParameterCollection Parent\n\t{\n\t\tget { return _parent; }\n\t\tset\n\t\t{\n\t\t\t_parent?.ParameterNameChanged();\n\t\t\t_parent = value;\n\t\t\t_parent?.ParameterNameChanged();\n\t\t}\n\t}\n\n\tinternal string InternalParameterName\n\t{\n\t\tget\n\t\t{\n\t\t\treturn _internalParameterName;\n\t\t}\n\t}\n\n\tinternal bool IsTypeSet { get; private set; }\n\n\tinternal object InternalValue\n\t{\n\t\tget\n\t\t{\n\t\t\tswitch (_value)\n\t\t\t{\n\t\t\t\tcase string svalue:\n\t\t\t\t\treturn svalue.Substring(0, Math.Min(Size, svalue.Length));\n\t\t\t\tcase byte[] bvalue:\n\t\t\t\t\tvar result = new byte[Math.Min(Size, bvalue.Length)];\n\t\t\t\t\tArray.Copy(bvalue, result, result.Length);\n\t\t\t\t\treturn result;\n\t\t\t\tdefault:\n\t\t\t\t\treturn _value;\n\t\t\t}\n\t\t}\n\t}\n\n\tinternal bool HasSize\n\t{\n\t\tget { return _size != default; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FbParameter()\n\t{\n\t\t_fbDbType = FbDbType.VarChar;\n\t\t_direction = ParameterDirection.Input;\n\t\t_sourceVersion = DataRowVersion.Current;\n\t\t_sourceColumn = string.Empty;\n\t\t_parameterName = string.Empty;\n\t\t_charset = FbCharset.Default;\n\t\t_internalParameterName = string.Empty;\n\t}\n\n\tpublic FbParameter(string parameterName, object value)\n\t\t: this()\n\t{\n\t\tParameterName = parameterName;\n\t\tValue = value;\n\t}\n\n\tpublic FbParameter(string parameterName, FbDbType fbType)\n\t\t: this()\n\t{\n\t\tParameterName = parameterName;\n\t\tFbDbType = fbType;\n\t}\n\n\tpublic FbParameter(string parameterName, FbDbType fbType, int size)\n\t\t: this()\n\t{\n\t\tParameterName = parameterName;\n\t\tFbDbType = fbType;\n\t\tSize = size;\n\t}\n\n\tpublic FbParameter(string parameterName, FbDbType fbType, int size, string sourceColumn)\n\t\t: this()\n\t{\n\t\tParameterName = parameterName;\n\t\tFbDbType = fbType;\n\t\tSize = size;\n\t\t_sourceColumn = sourceColumn;\n\t}\n\n\t[EditorBrowsable(EditorBrowsableState.Advanced)]\n\tpublic FbParameter(\n\t\tstring parameterName,\n\t\tFbDbType dbType,\n\t\tint size,\n\t\tParameterDirection direction,\n\t\tbool isNullable,\n\t\tbyte precision,\n\t\tbyte scale,\n\t\tstring sourceColumn,\n\t\tDataRowVersion sourceVersion,\n\t\tobject value)\n\t{\n\t\tParameterName = parameterName;\n\t\tFbDbType = dbType;\n\t\tSize = size;\n\t\t_direction = direction;\n\t\t_isNullable = isNullable;\n\t\t_precision = precision;\n\t\t_scale = scale;\n\t\t_sourceColumn = sourceColumn;\n\t\t_sourceVersion = sourceVersion;\n\t\tValue = value;\n\t\t_charset = FbCharset.Default;\n\t}\n\n\t#endregion\n\n\t#region ICloneable Methods\n\tobject ICloneable.Clone()\n\t{\n\t\treturn new FbParameter(\n\t\t\t_parameterName,\n\t\t\t_fbDbType,\n\t\t\t_size,\n\t\t\t_direction,\n\t\t\t_isNullable,\n\t\t\t_precision,\n\t\t\t_scale,\n\t\t\t_sourceColumn,\n\t\t\t_sourceVersion,\n\t\t\t_value)\n\t\t{\n\t\t\tCharset = _charset\n\t\t};\n\t}\n\n\t#endregion\n\n\t#region DbParameter methods\n\n\tpublic override string ToString()\n\t{\n\t\treturn _parameterName;\n\t}\n\n\tpublic override void ResetDbType()\n\t{\n\t\tthrow new NotImplementedException();\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void SetFbDbType(object value)\n\t{\n\t\tif (value == null)\n\t\t{\n\t\t\tvalue = DBNull.Value;\n\t\t}\n\t\t_fbDbType = TypeHelper.GetFbDataTypeFromType(value.GetType());\n\t}\n\n\t#endregion\n\n\t#region Private Properties\n\n\tprivate int? RealValueSize\n\t{\n\t\tget\n\t\t{\n\t\t\tvar svalue = (_value as string);\n\t\t\tif (svalue != null)\n\t\t\t{\n\t\t\t\treturn svalue.Length;\n\t\t\t}\n\t\t\tvar bvalue = (_value as byte[]);\n\t\t\tif (bvalue != null)\n\t\t\t{\n\t\t\t\treturn bvalue.Length;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tinternal bool IsUnicodeParameterName\n\t{\n\t\tget\n\t\t{\n\t\t\treturn _isUnicodeParameterName;\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Static Methods\n\n\tinternal static string NormalizeParameterName(string parameterName)\n\t{\n\t\treturn string.IsNullOrEmpty(parameterName) || parameterName[0] == '@'\n\t\t\t? parameterName\n\t\t\t: \"@\" + parameterName;\n\t}\n\n\tinternal static bool IsNonAsciiParameterName(string parameterName)\n\t{\n\t\tvar isAscii = string.IsNullOrWhiteSpace(parameterName)\n\t\t\t|| Encoding.UTF8.GetByteCount(parameterName) == parameterName.Length;\n\t\treturn !isAscii;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbParameterCollection.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Data.Common;\nusing System.Globalization;\nusing System.Linq;\n\nusing FirebirdSql.Data.Common;\nusing System.Text;\nusing System.Collections;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\n[ListBindable(false)]\npublic sealed class FbParameterCollection : DbParameterCollection\n{\n\t#region Fields\n\n\tprivate List<FbParameter> _parameters;\n\tprivate bool? _hasParameterWithNonAsciiName;\n\n\t#endregion\n\n\t#region Indexers\n\n\t[Browsable(false)]\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\tpublic new FbParameter this[string parameterName]\n\t{\n\t\tget { return this[IndexOf(parameterName)]; }\n\t\tset { this[IndexOf(parameterName)] = value; }\n\t}\n\n\t[Browsable(false)]\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\tpublic new FbParameter this[int index]\n\t{\n\t\tget { return _parameters[index]; }\n\t\tset { _parameters[index] = value; }\n\t}\n\n\t#endregion\n\n\t#region DbParameterCollection overriden properties\n\n\t[Browsable(false)]\n\t[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]\n\tpublic override int Count\n\t{\n\t\tget { return _parameters.Count; }\n\t}\n\n\tpublic override bool IsFixedSize\n\t{\n\t\tget { return ((IList)_parameters).IsFixedSize; }\n\t}\n\n\tpublic override bool IsReadOnly\n\t{\n\t\tget { return ((IList)_parameters).IsReadOnly; }\n\t}\n\n\tpublic override bool IsSynchronized\n\t{\n\t\tget { return ((ICollection)_parameters).IsSynchronized; }\n\t}\n\n\tpublic override object SyncRoot\n\t{\n\t\tget { return ((ICollection)_parameters).SyncRoot; }\n\t}\n\n\t#endregion\n\n\t#region Internal properties\n\n\tinternal bool HasParameterWithNonAsciiName\n\t{\n\t\tget\n\t\t{\n\t\t\treturn _hasParameterWithNonAsciiName ?? (bool)(_hasParameterWithNonAsciiName = _parameters.Any(x => x.IsUnicodeParameterName));\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tinternal FbParameterCollection()\n\t{\n\t\t_parameters = new List<FbParameter>();\n\t\t_hasParameterWithNonAsciiName = null;\n\t}\n\n\t#endregion\n\n\t#region DbParameterCollection overriden methods\n\n\tpublic void AddRange(IEnumerable<FbParameter> values)\n\t{\n\t\tforeach (var p in values)\n\t\t{\n\t\t\tAdd(p);\n\t\t}\n\t}\n\n\tpublic override void AddRange(Array values)\n\t{\n\t\tAddRange(values.Cast<object>().Select(x => { EnsureFbParameterType(x); return (FbParameter)x; }));\n\t}\n\n\tpublic FbParameter AddWithValue(string parameterName, object value)\n\t{\n\t\treturn Add(new FbParameter(parameterName, value));\n\t}\n\n\tpublic FbParameter Add(string parameterName, object value)\n\t{\n\t\treturn Add(new FbParameter(parameterName, value));\n\t}\n\n\tpublic FbParameter Add(string parameterName, FbDbType type)\n\t{\n\t\treturn Add(new FbParameter(parameterName, type));\n\t}\n\n\tpublic FbParameter Add(string parameterName, FbDbType fbType, int size)\n\t{\n\t\treturn Add(new FbParameter(parameterName, fbType, size));\n\t}\n\n\tpublic FbParameter Add(string parameterName, FbDbType fbType, int size, string sourceColumn)\n\t{\n\t\treturn Add(new FbParameter(parameterName, fbType, size, sourceColumn));\n\t}\n\n\tpublic FbParameter Add(FbParameter value)\n\t{\n\t\tEnsureFbParameterAddOrInsert(value);\n\n\t\tAttachParameter(value);\n\t\t_parameters.Add(value);\n\t\treturn value;\n\t}\n\n\tpublic override int Add(object value)\n\t{\n\t\tEnsureFbParameterType(value);\n\n\t\treturn IndexOf(Add((FbParameter)value));\n\t}\n\n\tpublic bool Contains(FbParameter value)\n\t{\n\t\treturn _parameters.Contains(value);\n\t}\n\n\tpublic override bool Contains(object value)\n\t{\n\t\tEnsureFbParameterType(value);\n\n\t\treturn Contains((FbParameter)value);\n\t}\n\n\tpublic override bool Contains(string parameterName)\n\t{\n\t\treturn IndexOf(parameterName) != -1;\n\t}\n\n\tpublic int IndexOf(FbParameter value)\n\t{\n\t\treturn _parameters.IndexOf(value);\n\t}\n\n\tpublic override int IndexOf(object value)\n\t{\n\t\tEnsureFbParameterType(value);\n\n\t\treturn IndexOf((FbParameter)value);\n\t}\n\n\tpublic override int IndexOf(string parameterName)\n\t{\n\t\treturn IndexOf(parameterName, -1);\n\t}\n\n\tinternal int IndexOf(string parameterName, int luckyIndex)\n\t{\n\t\tvar isNonAsciiParameterName = FbParameter.IsNonAsciiParameterName(parameterName);\n\t\tvar usedComparison = isNonAsciiParameterName || HasParameterWithNonAsciiName\n\t\t\t? StringComparison.CurrentCultureIgnoreCase\n\t\t\t: StringComparison.OrdinalIgnoreCase;\n\t\tvar normalizedParameterName = FbParameter.NormalizeParameterName(parameterName);\n\t\tif (luckyIndex != -1 && luckyIndex < _parameters.Count)\n\t\t{\n\t\t\tif (_parameters[luckyIndex].InternalParameterName.Equals(normalizedParameterName, usedComparison))\n\t\t\t{\n\t\t\t\treturn luckyIndex;\n\t\t\t}\n\t\t}\n\n\t\treturn _parameters.FindIndex(x => x.InternalParameterName.Equals(normalizedParameterName, usedComparison));\n\t}\n\n\tpublic void Insert(int index, FbParameter value)\n\t{\n\t\tEnsureFbParameterAddOrInsert(value);\n\n\t\tAttachParameter(value);\n\t\t_parameters.Insert(index, value);\n\t}\n\n\tpublic override void Insert(int index, object value)\n\t{\n\t\tEnsureFbParameterType(value);\n\n\t\tInsert(index, (FbParameter)value);\n\t}\n\n\tpublic void Remove(FbParameter value)\n\t{\n\t\tif (!_parameters.Remove(value))\n\t\t{\n\t\t\tthrow new ArgumentException(\"The parameter does not exist in the collection.\");\n\t\t}\n\n\t\tReleaseParameter(value);\n\t}\n\n\tpublic override void Remove(object value)\n\t{\n\t\tEnsureFbParameterType(value);\n\n\t\tRemove((FbParameter)value);\n\t}\n\n\tpublic override void RemoveAt(int index)\n\t{\n\t\tif (index < 0 || index > Count)\n\t\t{\n\t\t\tthrow new IndexOutOfRangeException(\"The specified index does not exist.\");\n\t\t}\n\n\t\tvar parameter = this[index];\n\t\t_parameters.RemoveAt(index);\n\t\tReleaseParameter(parameter);\n\t}\n\n\tpublic override void RemoveAt(string parameterName)\n\t{\n\t\tRemoveAt(IndexOf(parameterName));\n\t}\n\n\tpublic void CopyTo(FbParameter[] array, int index)\n\t{\n\t\t_parameters.CopyTo(array, index);\n\t}\n\n\tpublic override void CopyTo(Array array, int index)\n\t{\n\t\t((IList)_parameters).CopyTo(array, index);\n\t}\n\n\tpublic override void Clear()\n\t{\n\t\tvar parameters = _parameters.ToArray();\n\t\t_parameters.Clear();\n\t\tforeach (var parameter in parameters)\n\t\t{\n\t\t\tReleaseParameter(parameter);\n\t\t}\n\t}\n\n\tpublic override IEnumerator GetEnumerator()\n\t{\n\t\treturn _parameters.GetEnumerator();\n\t}\n\n\t#endregion\n\n\t#region DbParameterCollection overriden protected methods\n\n\tprotected override DbParameter GetParameter(string parameterName)\n\t{\n\t\treturn this[parameterName];\n\t}\n\n\tprotected override DbParameter GetParameter(int index)\n\t{\n\t\treturn this[index];\n\t}\n\n\tprotected override void SetParameter(int index, DbParameter value)\n\t{\n\t\tthis[index] = (FbParameter)value;\n\t}\n\n\tprotected override void SetParameter(string parameterName, DbParameter value)\n\t{\n\t\tthis[parameterName] = (FbParameter)value;\n\t}\n\n\t#endregion\n\n\t#region Internal Methods\n\n\tinternal void ParameterNameChanged()\n\t{\n\t\t_hasParameterWithNonAsciiName = null;\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate string GenerateParameterName()\n\t{\n\t\tvar index = Count + 1;\n\t\twhile (true)\n\t\t{\n\t\t\tvar name = \"Parameter\" + index.ToString(CultureInfo.InvariantCulture);\n\t\t\tif (!Contains(name))\n\t\t\t{\n\t\t\t\treturn name;\n\t\t\t}\n\t\t\tindex++;\n\t\t}\n\t}\n\n\tprivate void EnsureFbParameterType(object value)\n\t{\n\t\tif (!(value is FbParameter))\n\t\t{\n\t\t\tthrow new InvalidCastException($\"The parameter passed was not a {nameof(FbParameter)}.\");\n\t\t}\n\t}\n\n\tprivate void EnsureFbParameterAddOrInsert(FbParameter value)\n\t{\n\t\tif (value == null)\n\t\t{\n\t\t\tthrow new ArgumentNullException();\n\t\t}\n\t\tif (value.Parent != null)\n\t\t{\n\t\t\tthrow new ArgumentException($\"The {nameof(FbParameter)} specified in the value parameter is already added to this or another {nameof(FbParameterCollection)}.\");\n\t\t}\n\t\tif (value.ParameterName == null || value.ParameterName.Length == 0)\n\t\t{\n\t\t\tvalue.ParameterName = GenerateParameterName();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (Contains(value.ParameterName))\n\t\t\t{\n\t\t\t\tthrow new ArgumentException($\"{nameof(FbParameterCollection)} already contains {nameof(FbParameter)} with {nameof(FbParameter.ParameterName)} '{value.ParameterName}'.\");\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate void AttachParameter(FbParameter parameter)\n\t{\n\t\tparameter.Parent = this;\n\t}\n\n\tprivate void ReleaseParameter(FbParameter parameter)\n\t{\n\t\tparameter.Parent = null;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbRemoteEvent.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic sealed class FbRemoteEvent : IDisposable, IAsyncDisposable\n{\n\tprivate FbConnectionInternal _connection;\n\tprivate RemoteEvent _revent;\n\tprivate SynchronizationContext _synchronizationContext;\n\n\tpublic event EventHandler<FbRemoteEventCountsEventArgs> RemoteEventCounts;\n\tpublic event EventHandler<FbRemoteEventErrorEventArgs> RemoteEventError;\n\n\tpublic string this[int index] => _revent != null ? _revent.Events[index] : throw new InvalidOperationException();\n\tpublic int RemoteEventId => _revent != null ? _revent.RemoteId : throw new InvalidOperationException();\n\n\tpublic FbRemoteEvent(string connectionString)\n\t{\n\t\t_connection = new FbConnectionInternal(new ConnectionString(connectionString));\n\t}\n\n\tpublic void Open()\n\t{\n\t\tif (_revent != null)\n\t\t\tthrow new InvalidOperationException($\"{nameof(FbRemoteEvent)} already open.\");\n\n\t\t_connection.Connect();\n\t\t_revent = new RemoteEvent(_connection.Database);\n\t\t_revent.EventCountsCallback = OnRemoteEventCounts;\n\t\t_revent.EventErrorCallback = OnRemoteEventError;\n\t\t_synchronizationContext = SynchronizationContext.Current ?? new SynchronizationContext();\n\t}\n\tpublic async Task OpenAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_revent != null)\n\t\t\tthrow new InvalidOperationException($\"{nameof(FbRemoteEvent)} already open.\");\n\n\t\tawait _connection.ConnectAsync(cancellationToken).ConfigureAwait(false);\n\t\t_revent = new RemoteEvent(_connection.Database);\n\t\t_revent.EventCountsCallback = OnRemoteEventCounts;\n\t\t_revent.EventErrorCallback = OnRemoteEventError;\n\t\t_synchronizationContext = SynchronizationContext.Current ?? new SynchronizationContext();\n\t}\n\n\tpublic void Dispose()\n\t{\n\t\t_connection.Disconnect();\n\t}\n\tpublic ValueTask DisposeAsync()\n\t{\n\t\treturn new ValueTask(_connection.DisconnectAsync(CancellationToken.None));\n\t}\n\n\tpublic void QueueEvents(ICollection<string> events)\n\t{\n\t\tif (_revent == null)\n\t\t\tthrow new InvalidOperationException($\"{nameof(FbRemoteEvent)} must be opened.\");\n\n\t\ttry\n\t\t{\n\t\t\t_revent.QueueEvents(events);\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task QueueEventsAsync(ICollection<string> events, CancellationToken cancellationToken = default)\n\t{\n\t\tif (_revent == null)\n\t\t\tthrow new InvalidOperationException($\"{nameof(FbRemoteEvent)} must be opened.\");\n\n\t\ttry\n\t\t{\n\t\t\tawait _revent.QueueEventsAsync(events, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic void CancelEvents()\n\t{\n\t\ttry\n\t\t{\n\t\t\t_revent.CancelEvents();\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task CancelEventsAsync(CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait _revent.CancelEventsAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tprivate void OnRemoteEventCounts(string name, int count)\n\t{\n\t\tvar args = new FbRemoteEventCountsEventArgs(name, count);\n\t\t_synchronizationContext.Post(_ =>\n\t\t{\n\t\t\tRemoteEventCounts?.Invoke(this, args);\n\t\t}, null);\n\t}\n\n\tprivate void OnRemoteEventError(Exception error)\n\t{\n\t\tvar args = new FbRemoteEventErrorEventArgs(error);\n\t\t_synchronizationContext.Post(_ =>\n\t\t{\n\t\t\tRemoteEventError?.Invoke(this, args);\n\t\t}, null);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbRemoteEventCountsEventArgs.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.ComponentModel;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic sealed class FbRemoteEventCountsEventArgs : EventArgs\n{\n\tpublic string Name { get; }\n\tpublic int Counts { get; }\n\n\tpublic FbRemoteEventCountsEventArgs(string name, int counts)\n\t{\n\t\tName = name;\n\t\tCounts = counts;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbRemoteEventErrorEventArgs.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.ComponentModel;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic sealed class FbRemoteEventErrorEventArgs : EventArgs\n{\n\tpublic Exception Error { get; }\n\n\tpublic FbRemoteEventErrorEventArgs(Exception error)\n\t{\n\t\tError = error;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbRowUpdatedEventArgs.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez\n\nusing System;\nusing System.Data;\nusing System.Data.Common;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic sealed class FbRowUpdatedEventArgs : RowUpdatedEventArgs\n{\n\t#region Properties\n\n\tpublic new FbCommand Command\n\t{\n\t\tget { return (FbCommand)base.Command; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FbRowUpdatedEventArgs(\n\t\tDataRow row,\n\t\tIDbCommand command,\n\t\tStatementType statementType,\n\t\tDataTableMapping tableMapping)\n\t\t: base(row, command, statementType, tableMapping)\n\t{\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbRowUpdatingEventArgs.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez\n\nusing System;\nusing System.Data;\nusing System.Data.Common;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic sealed class FbRowUpdatingEventArgs : RowUpdatingEventArgs\n{\n\t#region Properties\n\n\tpublic new FbCommand Command\n\t{\n\t\tget { return (FbCommand)base.Command; }\n\t\tset { base.Command = value; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FbRowUpdatingEventArgs(\n\t\tDataRow row,\n\t\tIDbCommand command,\n\t\tStatementType statementType,\n\t\tDataTableMapping tableMapping)\n\t\t: base(row, command, statementType, tableMapping)\n\t{\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbServerType.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\n[Serializable]\npublic enum FbServerType\n{\n\tDefault = 0,\n\tEmbedded = 1,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbTransaction.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Data.Common;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.Logging;\nusing Microsoft.Extensions.Logging;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic sealed class FbTransaction : DbTransaction\n{\n\tstatic readonly ILogger<FbTransaction> Log = FbLogManager.CreateLogger<FbTransaction>();\n\n\tinternal const IsolationLevel DefaultIsolationLevel = IsolationLevel.ReadCommitted;\n\n\t#region Fields\n\n\tprivate FbConnection _connection;\n\tprivate TransactionBase _transaction;\n\tprivate bool _disposed;\n\tprivate bool _isCompleted;\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic new FbConnection Connection\n\t{\n\t\tget { return !_isCompleted ? _connection : null; }\n\t}\n\n\tpublic override IsolationLevel IsolationLevel { get; }\n\n\tinternal TransactionBase Transaction\n\t{\n\t\tget { return _transaction; }\n\t}\n\n\tinternal bool IsCompleted\n\t{\n\t\tget { return _isCompleted; }\n\t}\n\n\tprotected override DbConnection DbConnection\n\t{\n\t\tget { return _connection; }\n\t}\n\n\tpublic override bool SupportsSavepoints\n\t{\n\t\tget { return true; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tinternal FbTransaction(FbConnection connection)\n\t\t: this(connection, IsolationLevel.ReadCommitted)\n\t{ }\n\n\tinternal FbTransaction(FbConnection connection, IsolationLevel il)\n\t{\n\t\t_connection = connection;\n\t\tIsolationLevel = il;\n\t}\n\n\t#endregion\n\n\t#region IDisposable, IAsyncDisposable methods\n\n\tprotected override void Dispose(bool disposing)\n\t{\n\t\tif (!_disposed)\n\t\t{\n\t\t\t_disposed = true;\n\t\t\tif (_transaction != null)\n\t\t\t{\n\t\t\t\tif (!_isCompleted)\n\t\t\t\t{\n\t\t\t\t\ttry\n\t\t\t\t\t{\n\t\t\t\t\t\t_transaction.Dispose2();\n\t\t\t\t\t}\n\t\t\t\t\tcatch (IscException ex)\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow FbException.Create(ex);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t_connection = null;\n\t\t\t_transaction = null;\n\t\t\t_isCompleted = true;\n\t\t}\n\t\tbase.Dispose(disposing);\n\t}\n\tpublic override async ValueTask DisposeAsync()\n\t{\n\t\tif (!_disposed)\n\t\t{\n\t\t\t_disposed = true;\n\t\t\tif (_transaction != null)\n\t\t\t{\n\t\t\t\tif (!_isCompleted)\n\t\t\t\t{\n\t\t\t\t\ttry\n\t\t\t\t\t{\n\t\t\t\t\t\tawait _transaction.Dispose2Async(CancellationToken.None).ConfigureAwait(false);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (IscException ex)\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow FbException.Create(ex);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t_connection = null;\n\t\t\t_transaction = null;\n\t\t\t_isCompleted = true;\n\t\t}\n\t\tawait base.DisposeAsync().ConfigureAwait(false);\n\t}\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic override void Commit()\n\t{\n\t\tLogMessages.TransactionCommitting(Log, this);\n\n\t\tEnsureCompleted();\n\t\ttry\n\t\t{\n\t\t\t_transaction.Commit();\n\t\t\tCompleteTransaction();\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\tLogMessages.TransactionCommitted(Log, this);\n\t}\n\tpublic override async Task CommitAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tLogMessages.TransactionCommitting(Log, this);\n\n\t\tEnsureCompleted();\n\t\ttry\n\t\t{\n\t\t\tawait _transaction.CommitAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tawait CompleteTransactionAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\tLogMessages.TransactionCommitted(Log, this);\n\t}\n\n\tpublic override void Rollback()\n\t{\n\t\tLogMessages.TransactionRollingBack(Log, this);\n\n\t\tEnsureCompleted();\n\t\ttry\n\t\t{\n\t\t\t_transaction.Rollback();\n\t\t\tCompleteTransaction();\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\tLogMessages.TransactionRolledBack(Log, this);\n\t}\n\tpublic override async Task RollbackAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tLogMessages.TransactionRollingBack(Log, this);\n\n\t\tEnsureCompleted();\n\t\ttry\n\t\t{\n\t\t\tawait _transaction.RollbackAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tawait CompleteTransactionAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\tLogMessages.TransactionRolledBack(Log, this);\n\t}\n\n\tpublic override void Save(string savePointName)\n\t{\n\t\tLogMessages.TransactionSaving(Log, this);\n\n\t\tEnsureSavePointName(savePointName);\n\t\tEnsureCompleted();\n\t\ttry\n\t\t{\n\t\t\tvar command = new FbCommand($\"SAVEPOINT {savePointName}\", _connection, this);\n\t\t\tusing (command)\n\t\t\t{\n\t\t\t\tcommand.ExecuteNonQuery();\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\tLogMessages.TransactionSaved(Log, this);\n\t}\n\tpublic override async Task SaveAsync(string savePointName, CancellationToken cancellationToken = default)\n\t{\n\t\tLogMessages.TransactionSaving(Log, this);\n\n\t\tEnsureSavePointName(savePointName);\n\t\tEnsureCompleted();\n\t\ttry\n\t\t{\n\t\t\tvar command = new FbCommand($\"SAVEPOINT {savePointName}\", _connection, this);\n\t\t\tawait using (command.ConfigureAwait(false))\n\t\t\t{\n\t\t\t\tawait command.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\tLogMessages.TransactionSaved(Log, this);\n\t}\n\n\tpublic override void Release(string savePointName)\n\t{\n\t\tLogMessages.TransactionReleasingSavepoint(Log, this);\n\n\t\tEnsureSavePointName(savePointName);\n\t\tEnsureCompleted();\n\t\ttry\n\t\t{\n\t\t\tvar command = new FbCommand($\"RELEASE SAVEPOINT {savePointName}\", _connection, this);\n\t\t\tusing (command)\n\t\t\t{\n\t\t\t\tcommand.ExecuteNonQuery();\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\tLogMessages.TransactionReleasedSavepoint(Log, this);\n\t}\n\tpublic override async Task ReleaseAsync(string savePointName, CancellationToken cancellationToken = default)\n\t{\n\t\tLogMessages.TransactionReleasingSavepoint(Log, this);\n\n\t\tEnsureSavePointName(savePointName);\n\t\tEnsureCompleted();\n\t\ttry\n\t\t{\n\t\t\tvar command = new FbCommand($\"RELEASE SAVEPOINT {savePointName}\", _connection, this);\n\t\t\tawait using (command.ConfigureAwait(false))\n\t\t\t{\n\t\t\t\tawait command.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\tLogMessages.TransactionReleasedSavepoint(Log, this);\n\t}\n\n\tpublic override void Rollback(string savePointName)\n\t{\n\t\tLogMessages.TransactionRollingBackSavepoint(Log, this);\n\n\t\tEnsureSavePointName(savePointName);\n\t\tEnsureCompleted();\n\t\ttry\n\t\t{\n\t\t\tvar command = new FbCommand($\"ROLLBACK WORK TO SAVEPOINT {savePointName}\", _connection, this);\n\t\t\tusing (command)\n\t\t\t{\n\t\t\t\tcommand.ExecuteNonQuery();\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\tLogMessages.TransactionRolledBackSavepoint(Log, this);\n\t}\n\tpublic override async Task RollbackAsync(string savePointName, CancellationToken cancellationToken = default)\n\t{\n\t\tLogMessages.TransactionRollingBackSavepoint(Log, this);\n\n\t\tEnsureSavePointName(savePointName);\n\t\tEnsureCompleted();\n\t\ttry\n\t\t{\n\t\t\tvar command = new FbCommand($\"ROLLBACK WORK TO SAVEPOINT {savePointName}\", _connection, this);\n\t\t\tawait using (command.ConfigureAwait(false))\n\t\t\t{\n\t\t\t\tawait command.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\tLogMessages.TransactionRolledBackSavepoint(Log, this);\n\t}\n\n\tpublic void CommitRetaining()\n\t{\n\t\tLogMessages.TransactionCommittingRetaining(Log, this);\n\n\t\tEnsureCompleted();\n\t\ttry\n\t\t{\n\t\t\t_transaction.CommitRetaining();\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\tLogMessages.TransactionCommittedRetaining(Log, this);\n\t}\n\tpublic async Task CommitRetainingAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tLogMessages.TransactionCommittingRetaining(Log, this);\n\n\t\tEnsureCompleted();\n\t\ttry\n\t\t{\n\t\t\tawait _transaction.CommitRetainingAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\tLogMessages.TransactionCommittedRetaining(Log, this);\n\t}\n\n\tpublic void RollbackRetaining()\n\t{\n\t\tLogMessages.TransactionRollingBackRetaining(Log, this);\n\n\t\tEnsureCompleted();\n\t\ttry\n\t\t{\n\t\t\t_transaction.RollbackRetaining();\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\tLogMessages.TransactionRolledBackRetaining(Log, this);\n\t}\n\tpublic async Task RollbackRetainingAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tLogMessages.TransactionRollingBackRetaining(Log, this);\n\n\t\tEnsureCompleted();\n\t\ttry\n\t\t{\n\t\t\tawait _transaction.RollbackRetainingAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tcatch (IscException ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\n\t\tLogMessages.TransactionRolledBackRetaining(Log, this);\n\t}\n\n\t#endregion\n\n\t#region Internal Methods\n\n\tinternal void BeginTransaction()\n\t{\n\t\tLogMessages.TransactionBeginning(Log, this);\n\n\t\t_transaction = _connection.InnerConnection.Database.BeginTransaction(BuildTpb());\n\n\t\tLogMessages.TransactionBegan(Log, this);\n\t}\n\tinternal async Task BeginTransactionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tLogMessages.TransactionBeginning(Log, this);\n\n\t\t_transaction = await _connection.InnerConnection.Database.BeginTransactionAsync(BuildTpb(), cancellationToken).ConfigureAwait(false);\n\n\t\tLogMessages.TransactionBegan(Log, this);\n\t}\n\n\tinternal void BeginTransaction(FbTransactionOptions options)\n\t{\n\t\tLogMessages.TransactionBeginning(Log, this);\n\n\t\t_transaction = _connection.InnerConnection.Database.BeginTransaction(BuildTpb(options));\n\n\t\tLogMessages.TransactionBegan(Log, this);\n\t}\n\tinternal async Task BeginTransactionAsync(FbTransactionOptions options, CancellationToken cancellationToken = default)\n\t{\n\t\tLogMessages.TransactionBeginning(Log, this);\n\n\t\t_transaction = await _connection.InnerConnection.Database.BeginTransactionAsync(BuildTpb(options), cancellationToken).ConfigureAwait(false);\n\n\t\tLogMessages.TransactionBegan(Log, this);\n\t}\n\n\tinternal static void EnsureActive(FbTransaction transaction)\n\t{\n\t\tif (transaction == null || transaction.IsCompleted)\n\t\t\tthrow new InvalidOperationException(\"Transaction must be valid and active.\");\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate void CompleteTransaction()\n\t{\n\t\tvar innerConnection = _connection?.InnerConnection;\n\t\tif (innerConnection != null)\n\t\t{\n\t\t\tinnerConnection.TransactionCompleted();\n\t\t}\n\t\t_connection = null;\n\t\t_transaction.Dispose2();\n\t\t_transaction = null;\n\t\t_isCompleted = true;\n\t}\n\tprivate async Task CompleteTransactionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar innerConnection = _connection?.InnerConnection;\n\t\tif (innerConnection != null)\n\t\t{\n\t\t\tawait innerConnection.TransactionCompletedAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\t_connection = null;\n\t\tawait _transaction.Dispose2Async(cancellationToken).ConfigureAwait(false);\n\t\t_transaction = null;\n\t\t_isCompleted = true;\n\t}\n\n\tprivate TransactionParameterBuffer BuildTpb()\n\t{\n\t\tvar options = new FbTransactionOptions();\n\t\toptions.WaitTimeout = null;\n\t\toptions.TransactionBehavior = FbTransactionBehavior.Write;\n\n\t\toptions.TransactionBehavior |= FbTransactionBehavior.NoWait;\n\n\t\tswitch (IsolationLevel)\n\t\t{\n\t\t\tcase IsolationLevel.Serializable:\n\t\t\t\toptions.TransactionBehavior |= FbTransactionBehavior.Consistency;\n\t\t\t\tbreak;\n\n\t\t\tcase IsolationLevel.RepeatableRead:\n\t\t\tcase IsolationLevel.Snapshot:\n\t\t\t\toptions.TransactionBehavior |= FbTransactionBehavior.Concurrency;\n\t\t\t\tbreak;\n\n\t\t\tcase IsolationLevel.ReadCommitted:\n\t\t\tcase IsolationLevel.ReadUncommitted:\n\t\t\tdefault:\n\t\t\t\toptions.TransactionBehavior |= FbTransactionBehavior.ReadCommitted;\n\t\t\t\toptions.TransactionBehavior |= FbTransactionBehavior.RecVersion;\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn BuildTpb(options);\n\t}\n\n\tprivate void EnsureCompleted()\n\t{\n\t\tif (_isCompleted)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"This transaction has completed and it is no longer usable.\");\n\t\t}\n\t}\n\n\tprivate TransactionParameterBuffer BuildTpb(FbTransactionOptions options)\n\t{\n\t\tvar tpb = Connection.InnerConnection.Database.CreateTransactionParameterBuffer();\n\n\t\ttpb.Append(IscCodes.isc_tpb_version3);\n\n\t\tif (options.TransactionBehavior.HasFlag(FbTransactionBehavior.Consistency))\n\t\t{\n\t\t\ttpb.Append(IscCodes.isc_tpb_consistency);\n\t\t}\n\t\tif (options.TransactionBehavior.HasFlag(FbTransactionBehavior.Concurrency))\n\t\t{\n\t\t\ttpb.Append(IscCodes.isc_tpb_concurrency);\n\t\t}\n\t\tif (options.TransactionBehavior.HasFlag(FbTransactionBehavior.Wait))\n\t\t{\n\t\t\ttpb.Append(IscCodes.isc_tpb_wait);\n\t\t\tif (options.WaitTimeoutTPBValue != null)\n\t\t\t{\n\t\t\t\ttpb.Append(IscCodes.isc_tpb_lock_timeout, (short)options.WaitTimeoutTPBValue);\n\t\t\t}\n\t\t}\n\t\tif (options.TransactionBehavior.HasFlag(FbTransactionBehavior.NoWait))\n\t\t{\n\t\t\ttpb.Append(IscCodes.isc_tpb_nowait);\n\t\t}\n\t\tif (options.TransactionBehavior.HasFlag(FbTransactionBehavior.Read))\n\t\t{\n\t\t\ttpb.Append(IscCodes.isc_tpb_read);\n\t\t}\n\t\tif (options.TransactionBehavior.HasFlag(FbTransactionBehavior.Write))\n\t\t{\n\t\t\ttpb.Append(IscCodes.isc_tpb_write);\n\t\t}\n\t\tforeach (var table in options.LockTables)\n\t\t{\n\t\t\tint lockType;\n\t\t\tif (table.Value.HasFlag(FbTransactionBehavior.LockRead))\n\t\t\t{\n\t\t\t\tlockType = IscCodes.isc_tpb_lock_read;\n\t\t\t}\n\t\t\telse if (table.Value.HasFlag(FbTransactionBehavior.LockWrite))\n\t\t\t{\n\t\t\t\tlockType = IscCodes.isc_tpb_lock_write;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthrow new ArgumentException(\"Must specify either LockRead or LockWrite.\");\n\t\t\t}\n\t\t\ttpb.Append(lockType, table.Key);\n\n\t\t\tint? lockBehavior = null;\n\t\t\tif (table.Value.HasFlag(FbTransactionBehavior.Exclusive))\n\t\t\t{\n\t\t\t\tlockBehavior = IscCodes.isc_tpb_exclusive;\n\t\t\t}\n\t\t\telse if (table.Value.HasFlag(FbTransactionBehavior.Protected))\n\t\t\t{\n\t\t\t\tlockBehavior = IscCodes.isc_tpb_protected;\n\t\t\t}\n\t\t\telse if (table.Value.HasFlag(FbTransactionBehavior.Shared))\n\t\t\t{\n\t\t\t\tlockBehavior = IscCodes.isc_tpb_shared;\n\t\t\t}\n\t\t\tif (lockBehavior != null)\n\t\t\t{\n\t\t\t\ttpb.Append((int)lockBehavior);\n\t\t\t}\n\t\t}\n\t\tif (options.TransactionBehavior.HasFlag(FbTransactionBehavior.ReadCommitted))\n\t\t{\n\t\t\ttpb.Append(IscCodes.isc_tpb_read_committed);\n\t\t}\n\t\tif (options.TransactionBehavior.HasFlag(FbTransactionBehavior.Autocommit))\n\t\t{\n\t\t\ttpb.Append(IscCodes.isc_tpb_autocommit);\n\t\t}\n\t\tif (options.TransactionBehavior.HasFlag(FbTransactionBehavior.RecVersion))\n\t\t{\n\t\t\ttpb.Append(IscCodes.isc_tpb_rec_version);\n\t\t}\n\t\tif (options.TransactionBehavior.HasFlag(FbTransactionBehavior.NoRecVersion))\n\t\t{\n\t\t\ttpb.Append(IscCodes.isc_tpb_no_rec_version);\n\t\t}\n\t\tif (options.TransactionBehavior.HasFlag(FbTransactionBehavior.RestartRequests))\n\t\t{\n\t\t\ttpb.Append(IscCodes.isc_tpb_restart_requests);\n\t\t}\n\t\tif (options.TransactionBehavior.HasFlag(FbTransactionBehavior.NoAutoUndo))\n\t\t{\n\t\t\ttpb.Append(IscCodes.isc_tpb_no_auto_undo);\n\t\t}\n\t\tif (options.TransactionBehavior.HasFlag(FbTransactionBehavior.ReadConsistency))\n\t\t{\n\t\t\ttpb.Append(IscCodes.isc_tpb_read_consistency);\n\t\t}\n\n\t\tif (options.SnapshotAtNumber != null)\n\t\t{\n\t\t\ttpb.Append(IscCodes.isc_tpb_at_snapshot_number, (long)options.SnapshotAtNumber);\n\t\t}\n\n\t\treturn tpb;\n\t}\n\n\tprivate static void EnsureSavePointName(string savePointName)\n\t{\n\t\tif (string.IsNullOrWhiteSpace(savePointName))\n\t\t{\n\t\t\tthrow new ArgumentException(\"No transaction name was specified.\");\n\t\t}\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbTransactionBehavior.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\n[Serializable]\n[Flags]\npublic enum FbTransactionBehavior\n{\n\tConsistency = 1 << 0,\n\tConcurrency = 1 << 1,\n\tShared = 1 << 2,\n\tProtected = 1 << 3,\n\tExclusive = 1 << 4,\n\tWait = 1 << 5,\n\tNoWait = 1 << 6,\n\tRead = 1 << 7,\n\tWrite = 1 << 8,\n\tLockRead = 1 << 9,\n\tLockWrite = 1 << 10,\n\tReadCommitted = 1 << 11,\n\tAutocommit = 1 << 12,\n\tRecVersion = 1 << 13,\n\tNoRecVersion = 1 << 14,\n\tRestartRequests = 1 << 15,\n\tNoAutoUndo = 1 << 16,\n\tReadConsistency = 1 << 17,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbTransactionInfo.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic sealed class FbTransactionInfo\n{\n\t#region Properties\n\n\tpublic FbTransaction Transaction { get; set; }\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic long GetTransactionSnapshotNumber()\n\t{\n\t\treturn GetValue<long>(IscCodes.fb_info_tra_snapshot_number);\n\t}\n\tpublic Task<long> GetTransactionSnapshotNumberAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetValueAsync<long>(IscCodes.fb_info_tra_snapshot_number, cancellationToken);\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tpublic FbTransactionInfo(FbTransaction transaction = null)\n\t{\n\t\tTransaction = transaction;\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate T GetValue<T>(byte item)\n\t{\n\t\tFbTransaction.EnsureActive(Transaction);\n\n\t\tvar items = new byte[]\n\t\t{\n\t\t\titem,\n\t\t\tIscCodes.isc_info_end\n\t\t};\n\t\tvar info = Transaction.Transaction.GetTransactionInfo(items);\n\t\treturn info.Any() ? InfoValuesHelper.ConvertValue<T>(info[0]) : default;\n\t}\n\tprivate async Task<T> GetValueAsync<T>(byte item, CancellationToken cancellationToken = default)\n\t{\n\t\tFbTransaction.EnsureActive(Transaction);\n\n\t\tvar items = new byte[]\n\t\t{\n\t\t\titem,\n\t\t\tIscCodes.isc_info_end\n\t\t};\n\t\tvar info = await Transaction.Transaction.GetTransactionInfoAsync(items, cancellationToken).ConfigureAwait(false);\n\t\treturn info.Any() ? InfoValuesHelper.ConvertValue<T>(info[0]) : default;\n\t}\n\n\tprivate List<T> GetList<T>(byte item)\n\t{\n\t\tFbTransaction.EnsureActive(Transaction);\n\n\t\tvar items = new byte[]\n\t\t{\n\t\t\titem,\n\t\t\tIscCodes.isc_info_end\n\t\t};\n\n\t\treturn (Transaction.Transaction.GetTransactionInfo(items)).Select(InfoValuesHelper.ConvertValue<T>).ToList();\n\t}\n\tprivate async Task<List<T>> GetListAsync<T>(byte item, CancellationToken cancellationToken = default)\n\t{\n\t\tFbTransaction.EnsureActive(Transaction);\n\n\t\tvar items = new byte[]\n\t\t{\n\t\t\titem,\n\t\t\tIscCodes.isc_info_end\n\t\t};\n\n\t\treturn (await Transaction.Transaction.GetTransactionInfoAsync(items, cancellationToken).ConfigureAwait(false)).Select(InfoValuesHelper.ConvertValue<T>).ToList();\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbTransactionOptions.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic class FbTransactionOptions\n{\n\tprivate TimeSpan? _waitTimeout;\n\tpublic TimeSpan? WaitTimeout\n\t{\n\t\tget { return _waitTimeout; }\n\t\tset\n\t\t{\n\t\t\tif (value.HasValue)\n\t\t\t{\n\t\t\t\tvar secs = ((TimeSpan)value).TotalSeconds;\n\t\t\t\tif (secs < 1 || secs > short.MaxValue)\n\t\t\t\t\tthrow new ArgumentException($\"The value must be between 1 and {short.MaxValue}.\");\n\t\t\t}\n\n\t\t\t_waitTimeout = value;\n\t\t}\n\t}\n\tinternal short? WaitTimeoutTPBValue => (short?)_waitTimeout?.TotalSeconds;\n\n\tpublic FbTransactionBehavior TransactionBehavior { get; set; }\n\n\tprivate IDictionary<string, FbTransactionBehavior> _lockTables;\n\tpublic IDictionary<string, FbTransactionBehavior> LockTables\n\t{\n\t\tget\n\t\t{\n\t\t\treturn _lockTables ??= new Dictionary<string, FbTransactionBehavior>();\n\t\t}\n\t\tset\n\t\t{\n\t\t\t_lockTables = value ?? throw new ArgumentNullException($\"{nameof(LockTables)} cannot be null.\");\n\t\t}\n\t}\n\n\tpublic long? SnapshotAtNumber { get; set; }\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbWireCrypt.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\n[Serializable]\npublic enum FbWireCrypt\n{\n\tDisabled,\n\tEnabled,\n\tRequired,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FirebirdClientFactory.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System.Data.Common;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\npublic class FirebirdClientFactory : DbProviderFactory\n{\n\t#region Static Properties\n\n\tpublic static readonly FirebirdClientFactory Instance = new FirebirdClientFactory();\n\n\t#endregion\n\n\t#region Properties\n\n\tpublic override bool CanCreateDataSourceEnumerator\n\t{\n\t\tget { return false; }\n\t}\n\n\t#endregion\n\n\t#region Constructors\n\n\tprivate FirebirdClientFactory()\n\t\t: base()\n\t{ }\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic override DbCommand CreateCommand()\n\t{\n\t\treturn new FbCommand();\n\t}\n\n\tpublic override DbCommandBuilder CreateCommandBuilder()\n\t{\n\t\treturn new FbCommandBuilder();\n\t}\n\n\tpublic override DbConnection CreateConnection()\n\t{\n\t\treturn new FbConnection();\n\t}\n\n\tpublic override DbConnectionStringBuilder CreateConnectionStringBuilder()\n\t{\n\t\treturn new FbConnectionStringBuilder();\n\t}\n\n\tpublic override DbDataAdapter CreateDataAdapter()\n\t{\n\t\treturn new FbDataAdapter();\n\t}\n\n\tpublic override DbParameter CreateParameter()\n\t{\n\t\treturn new FbParameter();\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdClient/IFbPreparedCommand.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace FirebirdSql.Data.FirebirdClient;\n\ninternal interface IFbPreparedCommand\n{\n\tvoid Release();\n\tTask ReleaseAsync(CancellationToken cancellationToken = default);\n\tvoid TransactionCompleted();\n\tTask TransactionCompletedAsync(CancellationToken cancellationToken = default);\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/FirebirdSql.Data.FirebirdClient.csproj",
    "content": "﻿<Project Sdk=\"Microsoft.NET.Sdk\">\n\t<PropertyGroup>\n\t\t<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>\n\t\t<AssemblyName>FirebirdSql.Data.FirebirdClient</AssemblyName>\n\t\t<RootNamespace>FirebirdSql.Data</RootNamespace>\n\t\t<SignAssembly>true</SignAssembly>\n\t\t<AssemblyOriginatorKeyFile>Properties\\FirebirdSql.Data.FirebirdClient.snk</AssemblyOriginatorKeyFile>\n\t\t<GenerateAssemblyInfo>true</GenerateAssemblyInfo>\n\t\t<GeneratePackageOnBuild>true</GeneratePackageOnBuild>\n\t\t<AllowUnsafeBlocks>true</AllowUnsafeBlocks>\n\t</PropertyGroup>\n\t<PropertyGroup>\n\t\t<Version>$(ProviderVersion)</Version>\n\t\t<AssemblyTitle>NETProvider - ADO.NET Data Provider</AssemblyTitle>\n\t\t<Copyright>(c) 2002-$(CopyrightEndYear)</Copyright>\n\t</PropertyGroup>\n\t<PropertyGroup>\n\t\t<PackageId>FirebirdSql.Data.FirebirdClient</PackageId>\n\t\t<Title>Firebird ADO.NET Data provider</Title>\n\t\t<PackageDescription>Firebird ADO.NET data provider</PackageDescription>\n\t\t<PackageTags>firebird firebirsql firebirdclient adonet database</PackageTags>\n\t\t<PackageReadmeFile>README.md</PackageReadmeFile>\n\t</PropertyGroup>\n\t<PropertyGroup Condition=\"'$(Configuration)'=='Release'\">\n\t\t<DefineConstants>TRACE</DefineConstants>\n\t</PropertyGroup>\n\t<PropertyGroup Condition=\"'$(Configuration)'=='Debug'\">\n\t\t<DefineConstants>DEBUG;TRACE</DefineConstants>\n\t</PropertyGroup>\n\t<ItemGroup>\n\t\t<None Remove=\"Schema\\FbMetaData.xml\" />\n\t</ItemGroup>\n\t<ItemGroup>\n\t\t<EmbeddedResource Include=\"Schema\\FbMetaData.xml\" />\n\t</ItemGroup>\n\t<ItemGroup>\n\t\t<None Include=\"..\\..\\README.md\" Pack=\"true\" PackagePath=\"\" />\n\t\t<None Include=\"..\\..\\license.txt\" Pack=\"true\" PackagePath=\"\" />\n\t\t<None Include=\"..\\..\\firebird-logo.png\" Pack=\"true\" PackagePath=\"\" />\n\t</ItemGroup>\n\t<ItemGroup Condition=\"'$(TargetFramework)'=='net8.0'\">\n\t  <PackageReference Include=\"Microsoft.Extensions.Logging.Abstractions\" Version=\"8.0.3\" />\n\t</ItemGroup>\n\t<ItemGroup Condition=\"'$(TargetFramework)'=='net9.0'\">\n\t  <PackageReference Include=\"Microsoft.Extensions.Logging.Abstractions\" Version=\"9.0.11\" />\n\t</ItemGroup>\n\t<ItemGroup Condition=\"'$(TargetFramework)'=='net10.0'\">\n\t  <PackageReference Include=\"Microsoft.Extensions.Logging.Abstractions\" Version=\"10.0.1\" />\n\t</ItemGroup>\n\t<ItemGroup>\n\t  <PackageReference Include=\"ConfigureAwaitChecker.Analyzer\" Version=\"5.0.0.1\">\n\t    <PrivateAssets>all</PrivateAssets>\n\t    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n\t  </PackageReference>\n\t</ItemGroup>\n\t<Import Project=\"..\\FirebirdSql.Data.External\\FirebirdSql.Data.External.projitems\" Label=\"Shared\" />\n</Project>\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Isql/CommandExecutedEventArgs.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Abel Eduardo Pereira, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Isql;\n\npublic class CommandExecutedEventArgs : EventArgs\n{\n\tpublic FbDataReader DataReader { get; private set; }\n\tpublic string CommandText { get; private set; }\n\tpublic SqlStatementType StatementType { get; private set; }\n\tpublic int RowsAffected { get; private set; }\n\n\tpublic CommandExecutedEventArgs(FbDataReader dataReader, string commandText, SqlStatementType statementType, int rowsAffected)\n\t{\n\t\tDataReader = dataReader;\n\t\tCommandText = commandText;\n\t\tStatementType = statementType;\n\t\tRowsAffected = rowsAffected;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Isql/CommandExecutingEventArgs.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Abel Eduardo Pereira, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Isql;\n\npublic class CommandExecutingEventArgs : EventArgs\n{\n\tpublic FbCommand SqlCommand { get; private set; }\n\tpublic SqlStatementType StatementType { get; private set; }\n\n\tpublic CommandExecutingEventArgs(FbCommand sqlCommand, SqlStatementType statementType)\n\t{\n\t\tSqlCommand = sqlCommand;\n\t\tStatementType = statementType;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Isql/FbBatchExecution.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Abel Eduardo Pereira, Jiri Cincura (jiri@cincura.net), Olivier Metod\n\nusing System;\nusing System.Data;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Isql;\n\npublic sealed class FbBatchExecution\n{\n\tprivate static readonly string[] StandardParseTokens = new[] { \" \", \"\\r\\n\", \"\\n\", \"\\r\" };\n\n\t/// <summary>\n\t/// The event trigged before a SQL statement goes for execution.\n\t/// </summary>\n\tpublic event EventHandler<CommandExecutingEventArgs> CommandExecuting;\n\n\t/// <summary>\n\t/// The event trigged after a SQL statement execution.\n\t/// </summary>\n\tpublic event EventHandler<CommandExecutedEventArgs> CommandExecuted;\n\n\tFbStatementCollection _statements;\n\tFbConnection _sqlConnection;\n\tFbTransaction _sqlTransaction;\n\tFbConnectionStringBuilder _connectionString;\n\tFbCommand _sqlCommand;\n\n\t// control fields\n\tbool _requiresNewConnection;\n\tbool _shouldClose;\n\n\t/// <summary>\n\t/// Represents the list of SQL statements for batch execution.\n\t/// </summary>\n\tpublic FbStatementCollection Statements\n\t{\n\t\tget { return _statements; }\n\t}\n\n\t/// <summary>\n\t/// Creates an instance of FbBatchExecution engine with the given\n\t/// connection.\n\t/// </summary>\n\t/// <param name=\"sqlConnection\">A <see cref=\"FbConnection\"/> object.</param>\n\tpublic FbBatchExecution(FbConnection sqlConnection = null)\n\t{\n\t\t_statements = new FbStatementCollection();\n\t\tif (sqlConnection == null)\n\t\t{\n\t\t\t_sqlConnection = new FbConnection(); // do not specify the connection string\n\t\t\t_connectionString = new FbConnectionStringBuilder();\n\t\t}\n\t\telse\n\t\t{\n\t\t\t_sqlConnection = sqlConnection;\n\t\t\t_connectionString = new FbConnectionStringBuilder(sqlConnection.ConnectionString);\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Appends SQL statements from <see cref=\"FbScript\"/> instance. <see cref=\"FbScript.Parse\"/> should be already called.\n\t/// </summary>\n\t/// <param name=\"isqlScript\">A <see cref=\"FbScript\"/> object.</param>\n\tpublic void AppendSqlStatements(FbScript isqlScript)\n\t{\n\t\t_statements.AddRange(isqlScript.Results);\n\t}\n\n\t/// <summary>\n\t/// Starts the ordered execution of the SQL statements that are in <see cref=\"SqlStatements\"/> collection.\n\t/// </summary>\n\t/// <param name=\"autoCommit\">Specifies if the transaction should be committed after a DDL command execution</param>\n\tpublic void Execute(bool autoCommit = true)\n\t{\n\t\tif ((_statements?.Count ?? 0) == 0)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"There are no commands for execution.\");\n\t\t}\n\n\t\t_shouldClose = false;\n\n\t\tforeach (var statement in Statements)\n\t\t{\n\t\t\tif (!(statement.StatementType == SqlStatementType.Connect ||\n\t\t\t\tstatement.StatementType == SqlStatementType.CreateDatabase ||\n\t\t\t\tstatement.StatementType == SqlStatementType.Disconnect ||\n\t\t\t\tstatement.StatementType == SqlStatementType.DropDatabase ||\n\t\t\t\tstatement.StatementType == SqlStatementType.SetAutoDDL ||\n\t\t\t\tstatement.StatementType == SqlStatementType.SetDatabase ||\n\t\t\t\tstatement.StatementType == SqlStatementType.SetNames ||\n\t\t\t\tstatement.StatementType == SqlStatementType.SetSQLDialect))\n\t\t\t{\n\t\t\t\tProvideCommand();\n\t\t\t\t_sqlCommand.CommandText = statement.Text;\n\t\t\t\tif (_sqlTransaction == null && !(statement.StatementType == SqlStatementType.Commit || statement.StatementType == SqlStatementType.Rollback))\n\t\t\t\t{\n\t\t\t\t\t_sqlTransaction = _sqlConnection.BeginTransaction(FbTransaction.DefaultIsolationLevel, null);\n\t\t\t\t}\n\t\t\t\t_sqlCommand.Transaction = _sqlTransaction;\n\t\t\t}\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\tswitch (statement.StatementType)\n\t\t\t\t{\n\t\t\t\t\tcase SqlStatementType.AlterCharacterSet:\n\t\t\t\t\tcase SqlStatementType.AlterDatabase:\n\t\t\t\t\tcase SqlStatementType.AlterDomain:\n\t\t\t\t\tcase SqlStatementType.AlterException:\n\t\t\t\t\tcase SqlStatementType.AlterExternalFunction:\n\t\t\t\t\tcase SqlStatementType.AlterFunction:\n\t\t\t\t\tcase SqlStatementType.AlterIndex:\n\t\t\t\t\tcase SqlStatementType.AlterPackage:\n\t\t\t\t\tcase SqlStatementType.AlterProcedure:\n\t\t\t\t\tcase SqlStatementType.AlterRole:\n\t\t\t\t\tcase SqlStatementType.AlterSequence:\n\t\t\t\t\tcase SqlStatementType.AlterTable:\n\t\t\t\t\tcase SqlStatementType.AlterTrigger:\n\t\t\t\t\tcase SqlStatementType.AlterView:\n\t\t\t\t\tcase SqlStatementType.CommentOn:\n\t\t\t\t\tcase SqlStatementType.CreateCollation:\n\t\t\t\t\tcase SqlStatementType.CreateDomain:\n\t\t\t\t\tcase SqlStatementType.CreateException:\n\t\t\t\t\tcase SqlStatementType.CreateFunction:\n\t\t\t\t\tcase SqlStatementType.CreateGenerator:\n\t\t\t\t\tcase SqlStatementType.CreateIndex:\n\t\t\t\t\tcase SqlStatementType.CreatePackage:\n\t\t\t\t\tcase SqlStatementType.CreatePackageBody:\n\t\t\t\t\tcase SqlStatementType.CreateProcedure:\n\t\t\t\t\tcase SqlStatementType.CreateRole:\n\t\t\t\t\tcase SqlStatementType.CreateSequence:\n\t\t\t\t\tcase SqlStatementType.CreateShadow:\n\t\t\t\t\tcase SqlStatementType.CreateTable:\n\t\t\t\t\tcase SqlStatementType.CreateTrigger:\n\t\t\t\t\tcase SqlStatementType.CreateView:\n\t\t\t\t\tcase SqlStatementType.DeclareCursor:\n\t\t\t\t\tcase SqlStatementType.DeclareExternalFunction:\n\t\t\t\t\tcase SqlStatementType.DeclareFilter:\n\t\t\t\t\tcase SqlStatementType.DeclareStatement:\n\t\t\t\t\tcase SqlStatementType.DeclareTable:\n\t\t\t\t\tcase SqlStatementType.Delete:\n\t\t\t\t\tcase SqlStatementType.DropCollation:\n\t\t\t\t\tcase SqlStatementType.DropDomain:\n\t\t\t\t\tcase SqlStatementType.DropException:\n\t\t\t\t\tcase SqlStatementType.DropExternalFunction:\n\t\t\t\t\tcase SqlStatementType.DropFunction:\n\t\t\t\t\tcase SqlStatementType.DropFilter:\n\t\t\t\t\tcase SqlStatementType.DropGenerator:\n\t\t\t\t\tcase SqlStatementType.DropIndex:\n\t\t\t\t\tcase SqlStatementType.DropPackage:\n\t\t\t\t\tcase SqlStatementType.DropPackageBody:\n\t\t\t\t\tcase SqlStatementType.DropProcedure:\n\t\t\t\t\tcase SqlStatementType.DropSequence:\n\t\t\t\t\tcase SqlStatementType.DropRole:\n\t\t\t\t\tcase SqlStatementType.DropShadow:\n\t\t\t\t\tcase SqlStatementType.DropTable:\n\t\t\t\t\tcase SqlStatementType.DropTrigger:\n\t\t\t\t\tcase SqlStatementType.DropView:\n\t\t\t\t\tcase SqlStatementType.EventInit:\n\t\t\t\t\tcase SqlStatementType.EventWait:\n\t\t\t\t\tcase SqlStatementType.Execute:\n\t\t\t\t\tcase SqlStatementType.ExecuteImmediate:\n\t\t\t\t\tcase SqlStatementType.ExecuteProcedure:\n\t\t\t\t\tcase SqlStatementType.Grant:\n\t\t\t\t\tcase SqlStatementType.Insert:\n\t\t\t\t\tcase SqlStatementType.InsertCursor:\n\t\t\t\t\tcase SqlStatementType.Merge:\n\t\t\t\t\tcase SqlStatementType.Open:\n\t\t\t\t\tcase SqlStatementType.Prepare:\n\t\t\t\t\tcase SqlStatementType.Revoke:\n\t\t\t\t\tcase SqlStatementType.RecreateFunction:\n\t\t\t\t\tcase SqlStatementType.RecreatePackage:\n\t\t\t\t\tcase SqlStatementType.RecreatePackageBody:\n\t\t\t\t\tcase SqlStatementType.RecreateProcedure:\n\t\t\t\t\tcase SqlStatementType.RecreateTable:\n\t\t\t\t\tcase SqlStatementType.RecreateTrigger:\n\t\t\t\t\tcase SqlStatementType.RecreateView:\n\t\t\t\t\tcase SqlStatementType.SetGenerator:\n\t\t\t\t\tcase SqlStatementType.Update:\n\t\t\t\t\tcase SqlStatementType.Whenever:\n\t\t\t\t\t\tOnCommandExecuting(_sqlCommand, statement.StatementType);\n\n\t\t\t\t\t\tvar rowsAffected = ExecuteCommand(autoCommit);\n\t\t\t\t\t\t_requiresNewConnection = false;\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, rowsAffected);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.ExecuteBlock:\n\t\t\t\t\tcase SqlStatementType.Select:\n\t\t\t\t\t\t(ProvideCommand()).CommandText = statement.Text;\n\n\t\t\t\t\t\tOnCommandExecuting(_sqlCommand, statement.StatementType);\n\n\t\t\t\t\t\tvar dataReader = _sqlCommand.ExecuteReader(CommandBehavior.Default);\n\t\t\t\t\t\ttry\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t_requiresNewConnection = false;\n\n\t\t\t\t\t\t\tOnCommandExecuted(dataReader, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfinally\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdataReader.Dispose();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.Commit:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tCommitTransaction();\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.Rollback:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tRollbackTransaction();\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.CreateDatabase:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tCreateDatabase(statement.CleanText);\n\t\t\t\t\t\t_requiresNewConnection = false;\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.DropDatabase:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tFbConnection.DropDatabase(_connectionString.ToString());\n\t\t\t\t\t\t_requiresNewConnection = true;\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.Connect:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tConnectToDatabase(statement.CleanText);\n\t\t\t\t\t\t_requiresNewConnection = false;\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.Disconnect:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\t_sqlConnection.Close();\n\t\t\t\t\t\tFbConnection.ClearPool(_sqlConnection);\n\t\t\t\t\t\t_requiresNewConnection = false;\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.SetAutoDDL:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tSetAutoDdl(statement.CleanText, ref autoCommit);\n\t\t\t\t\t\t_requiresNewConnection = false;\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.SetNames:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tSetNames(statement.CleanText);\n\t\t\t\t\t\t_requiresNewConnection = true;\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.SetSQLDialect:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tSetSqlDialect(statement.CleanText);\n\t\t\t\t\t\t_requiresNewConnection = true;\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.Fetch:\n\t\t\t\t\tcase SqlStatementType.Describe:\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.SetDatabase:\n\t\t\t\t\tcase SqlStatementType.SetStatistics:\n\t\t\t\t\tcase SqlStatementType.SetTransaction:\n\t\t\t\t\tcase SqlStatementType.ShowSQLDialect:\n\t\t\t\t\t\tthrow new NotImplementedException();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (Exception ex)\n\t\t\t{\n\t\t\t\tDisposeCommand();\n\t\t\t\tRollbackTransaction();\n\t\t\t\tCloseConnection();\n\n\t\t\t\tvar message = string.Format(\"An exception was thrown when executing command: {1}.{0}Batch execution aborted.{0}The returned message was: {2}.\",\n\t\t\t\t\tEnvironment.NewLine,\n\t\t\t\t\tstatement.Text,\n\t\t\t\t\tex.Message);\n\t\t\t\tthrow FbException.Create(message, ex);\n\t\t\t}\n\t\t}\n\n\t\tDisposeCommand();\n\t\tCommitTransaction();\n\t\tCloseConnection();\n\t}\n\t/// <summary>\n\t/// Starts the ordered execution of the SQL statements that are in <see cref=\"SqlStatements\"/> collection.\n\t/// </summary>\n\t/// <param name=\"autoCommit\">Specifies if the transaction should be committed after a DDL command execution</param>\n\tpublic async Task ExecuteAsync(bool autoCommit = true, CancellationToken cancellationToken = default)\n\t{\n\t\tif ((_statements?.Count ?? 0) == 0)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"There are no commands for execution.\");\n\t\t}\n\n\t\t_shouldClose = false;\n\n\t\tforeach (var statement in Statements)\n\t\t{\n\t\t\tif (!(statement.StatementType == SqlStatementType.Connect ||\n\t\t\t\tstatement.StatementType == SqlStatementType.CreateDatabase ||\n\t\t\t\tstatement.StatementType == SqlStatementType.Disconnect ||\n\t\t\t\tstatement.StatementType == SqlStatementType.DropDatabase ||\n\t\t\t\tstatement.StatementType == SqlStatementType.SetAutoDDL ||\n\t\t\t\tstatement.StatementType == SqlStatementType.SetDatabase ||\n\t\t\t\tstatement.StatementType == SqlStatementType.SetNames ||\n\t\t\t\tstatement.StatementType == SqlStatementType.SetSQLDialect))\n\t\t\t{\n\t\t\t\tawait ProvideCommandAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\t_sqlCommand.CommandText = statement.Text;\n\t\t\t\tif (_sqlTransaction == null && !(statement.StatementType == SqlStatementType.Commit || statement.StatementType == SqlStatementType.Rollback))\n\t\t\t\t{\n\t\t\t\t\t_sqlTransaction = await _sqlConnection.BeginTransactionAsync(FbTransaction.DefaultIsolationLevel, null, cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t\t_sqlCommand.Transaction = _sqlTransaction;\n\t\t\t}\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\tswitch (statement.StatementType)\n\t\t\t\t{\n\t\t\t\t\tcase SqlStatementType.AlterCharacterSet:\n\t\t\t\t\tcase SqlStatementType.AlterDatabase:\n\t\t\t\t\tcase SqlStatementType.AlterDomain:\n\t\t\t\t\tcase SqlStatementType.AlterException:\n\t\t\t\t\tcase SqlStatementType.AlterFunction:\n\t\t\t\t\tcase SqlStatementType.AlterIndex:\n\t\t\t\t\tcase SqlStatementType.AlterPackage:\n\t\t\t\t\tcase SqlStatementType.AlterProcedure:\n\t\t\t\t\tcase SqlStatementType.AlterRole:\n\t\t\t\t\tcase SqlStatementType.AlterSequence:\n\t\t\t\t\tcase SqlStatementType.AlterTable:\n\t\t\t\t\tcase SqlStatementType.AlterTrigger:\n\t\t\t\t\tcase SqlStatementType.AlterView:\n\t\t\t\t\tcase SqlStatementType.CommentOn:\n\t\t\t\t\tcase SqlStatementType.CreateCollation:\n\t\t\t\t\tcase SqlStatementType.CreateDomain:\n\t\t\t\t\tcase SqlStatementType.CreateException:\n\t\t\t\t\tcase SqlStatementType.CreateFunction:\n\t\t\t\t\tcase SqlStatementType.CreateGenerator:\n\t\t\t\t\tcase SqlStatementType.CreateIndex:\n\t\t\t\t\tcase SqlStatementType.CreatePackage:\n\t\t\t\t\tcase SqlStatementType.CreatePackageBody:\n\t\t\t\t\tcase SqlStatementType.CreateProcedure:\n\t\t\t\t\tcase SqlStatementType.CreateRole:\n\t\t\t\t\tcase SqlStatementType.CreateSequence:\n\t\t\t\t\tcase SqlStatementType.CreateShadow:\n\t\t\t\t\tcase SqlStatementType.CreateTable:\n\t\t\t\t\tcase SqlStatementType.CreateTrigger:\n\t\t\t\t\tcase SqlStatementType.CreateView:\n\t\t\t\t\tcase SqlStatementType.DeclareCursor:\n\t\t\t\t\tcase SqlStatementType.DeclareExternalFunction:\n\t\t\t\t\tcase SqlStatementType.DeclareFilter:\n\t\t\t\t\tcase SqlStatementType.DeclareStatement:\n\t\t\t\t\tcase SqlStatementType.DeclareTable:\n\t\t\t\t\tcase SqlStatementType.Delete:\n\t\t\t\t\tcase SqlStatementType.DropCollation:\n\t\t\t\t\tcase SqlStatementType.DropDomain:\n\t\t\t\t\tcase SqlStatementType.DropException:\n\t\t\t\t\tcase SqlStatementType.DropExternalFunction:\n\t\t\t\t\tcase SqlStatementType.DropFunction:\n\t\t\t\t\tcase SqlStatementType.DropFilter:\n\t\t\t\t\tcase SqlStatementType.DropGenerator:\n\t\t\t\t\tcase SqlStatementType.DropIndex:\n\t\t\t\t\tcase SqlStatementType.DropPackage:\n\t\t\t\t\tcase SqlStatementType.DropPackageBody:\n\t\t\t\t\tcase SqlStatementType.DropProcedure:\n\t\t\t\t\tcase SqlStatementType.DropSequence:\n\t\t\t\t\tcase SqlStatementType.DropRole:\n\t\t\t\t\tcase SqlStatementType.DropShadow:\n\t\t\t\t\tcase SqlStatementType.DropTable:\n\t\t\t\t\tcase SqlStatementType.DropTrigger:\n\t\t\t\t\tcase SqlStatementType.DropView:\n\t\t\t\t\tcase SqlStatementType.EventInit:\n\t\t\t\t\tcase SqlStatementType.EventWait:\n\t\t\t\t\tcase SqlStatementType.Execute:\n\t\t\t\t\tcase SqlStatementType.ExecuteImmediate:\n\t\t\t\t\tcase SqlStatementType.ExecuteProcedure:\n\t\t\t\t\tcase SqlStatementType.Grant:\n\t\t\t\t\tcase SqlStatementType.Insert:\n\t\t\t\t\tcase SqlStatementType.InsertCursor:\n\t\t\t\t\tcase SqlStatementType.Merge:\n\t\t\t\t\tcase SqlStatementType.Open:\n\t\t\t\t\tcase SqlStatementType.Prepare:\n\t\t\t\t\tcase SqlStatementType.Revoke:\n\t\t\t\t\tcase SqlStatementType.RecreateFunction:\n\t\t\t\t\tcase SqlStatementType.RecreatePackage:\n\t\t\t\t\tcase SqlStatementType.RecreatePackageBody:\n\t\t\t\t\tcase SqlStatementType.RecreateProcedure:\n\t\t\t\t\tcase SqlStatementType.RecreateTable:\n\t\t\t\t\tcase SqlStatementType.RecreateTrigger:\n\t\t\t\t\tcase SqlStatementType.RecreateView:\n\t\t\t\t\tcase SqlStatementType.SetGenerator:\n\t\t\t\t\tcase SqlStatementType.Update:\n\t\t\t\t\tcase SqlStatementType.Whenever:\n\t\t\t\t\t\tOnCommandExecuting(_sqlCommand, statement.StatementType);\n\n\t\t\t\t\t\tvar rowsAffected = await ExecuteCommandAsync(autoCommit, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t_requiresNewConnection = false;\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, rowsAffected);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.ExecuteBlock:\n\t\t\t\t\tcase SqlStatementType.Select:\n\t\t\t\t\t\t(await ProvideCommandAsync(cancellationToken).ConfigureAwait(false)).CommandText = statement.Text;\n\n\t\t\t\t\t\tOnCommandExecuting(_sqlCommand, statement.StatementType);\n\n\t\t\t\t\t\tvar dataReader = await _sqlCommand.ExecuteReaderAsync(CommandBehavior.Default, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\ttry\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t_requiresNewConnection = false;\n\n\t\t\t\t\t\t\tOnCommandExecuted(dataReader, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfinally\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tawait dataReader.DisposeAsync().ConfigureAwait(false);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.Commit:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tawait CommitTransactionAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.Rollback:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tawait RollbackTransactionAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.CreateDatabase:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tawait CreateDatabaseAsync(statement.CleanText, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t_requiresNewConnection = false;\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.DropDatabase:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tawait FbConnection.DropDatabaseAsync(_connectionString.ToString(), cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t_requiresNewConnection = true;\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.Connect:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tawait ConnectToDatabaseAsync(statement.CleanText, cancellationToken).ConfigureAwait(false);\n\t\t\t\t\t\t_requiresNewConnection = false;\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.Disconnect:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tawait _sqlConnection.CloseAsync().ConfigureAwait(false);\n\t\t\t\t\t\tFbConnection.ClearPool(_sqlConnection);\n\t\t\t\t\t\t_requiresNewConnection = false;\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.SetAutoDDL:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tSetAutoDdl(statement.CleanText, ref autoCommit);\n\t\t\t\t\t\t_requiresNewConnection = false;\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.SetNames:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tSetNames(statement.CleanText);\n\t\t\t\t\t\t_requiresNewConnection = true;\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.SetSQLDialect:\n\t\t\t\t\t\tOnCommandExecuting(null, statement.StatementType);\n\n\t\t\t\t\t\tSetSqlDialect(statement.CleanText);\n\t\t\t\t\t\t_requiresNewConnection = true;\n\n\t\t\t\t\t\tOnCommandExecuted(null, statement.Text, statement.StatementType, -1);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.Fetch:\n\t\t\t\t\tcase SqlStatementType.Describe:\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase SqlStatementType.SetDatabase:\n\t\t\t\t\tcase SqlStatementType.SetStatistics:\n\t\t\t\t\tcase SqlStatementType.SetTransaction:\n\t\t\t\t\tcase SqlStatementType.ShowSQLDialect:\n\t\t\t\t\t\tthrow new NotImplementedException();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (Exception ex)\n\t\t\t{\n\t\t\t\tawait DisposeCommandAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait RollbackTransactionAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait CloseConnectionAsync(cancellationToken).ConfigureAwait(false);\n\n\t\t\t\tvar message = string.Format(\"An exception was thrown when executing command: {1}.{0}Batch execution aborted.{0}The returned message was: {2}.\",\n\t\t\t\t\tEnvironment.NewLine,\n\t\t\t\t\tstatement.Text,\n\t\t\t\t\tex.Message);\n\t\t\t\tthrow FbException.Create(message, ex);\n\t\t\t}\n\t\t}\n\n\t\tawait DisposeCommandAsync(cancellationToken).ConfigureAwait(false);\n\t\tawait CommitTransactionAsync(cancellationToken).ConfigureAwait(false);\n\t\tawait CloseConnectionAsync(cancellationToken).ConfigureAwait(false);\n\t}\n\n\t/// <summary>\n\t/// Updates the connection string with the data parsed from the parameter and opens a connection\n\t/// to the database.\n\t/// </summary>\n\t/// <param name=\"connectDbStatement\"></param>\n\tprivate void ConnectToDatabase(string connectDbStatement)\n\t{\n\t\t// CONNECT 'filespec'\n\t\t// [USER 'username']\n\t\t// [PASSWORD 'password']\n\t\t// [CACHE int]\n\t\t// [ROLE 'rolename']\n\t\tvar parser = new SqlStringParser(connectDbStatement);\n\t\tparser.Tokens = StandardParseTokens;\n\t\tusing (var enumerator = parser.Parse().GetEnumerator())\n\t\t{\n\t\t\tenumerator.MoveNext();\n\t\t\tif (enumerator.Current.Text.ToUpperInvariant() != \"CONNECT\")\n\t\t\t{\n\t\t\t\tthrow new ArgumentException(\"Malformed isql CONNECT statement. Expected keyword CONNECT but something else was found.\");\n\t\t\t}\n\t\t\tenumerator.MoveNext();\n\t\t\t_connectionString.Database = enumerator.Current.Text.Replace(\"'\", string.Empty);\n\t\t\twhile (enumerator.MoveNext())\n\t\t\t{\n\t\t\t\tswitch (enumerator.Current.Text.ToUpperInvariant())\n\t\t\t\t{\n\t\t\t\t\tcase \"USER\":\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\t_connectionString.UserID = enumerator.Current.Text.Replace(\"'\", string.Empty);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"PASSWORD\":\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\t_connectionString.Password = enumerator.Current.Text.Replace(\"'\", string.Empty);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"CACHE\":\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"ROLE\":\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\t_connectionString.Role = enumerator.Current.Text.Replace(\"'\", string.Empty);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new ArgumentException(\"Unexpected token '\" + enumerator.Current.Text + \"' on isql CONNECT statement.\");\n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t_requiresNewConnection = true;\n\t\tProvideConnection();\n\t}\n\t/// <summary>\n\t/// Updates the connection string with the data parsed from the parameter and opens a connection\n\t/// to the database.\n\t/// </summary>\n\t/// <param name=\"connectDbStatement\"></param>\n\tprivate async Task ConnectToDatabaseAsync(string connectDbStatement, CancellationToken cancellationToken = default)\n\t{\n\t\t// CONNECT 'filespec'\n\t\t// [USER 'username']\n\t\t// [PASSWORD 'password']\n\t\t// [CACHE int]\n\t\t// [ROLE 'rolename']\n\t\tvar parser = new SqlStringParser(connectDbStatement);\n\t\tparser.Tokens = StandardParseTokens;\n\t\tusing (var enumerator = parser.Parse().GetEnumerator())\n\t\t{\n\t\t\tenumerator.MoveNext();\n\t\t\tif (enumerator.Current.Text.ToUpperInvariant() != \"CONNECT\")\n\t\t\t{\n\t\t\t\tthrow new ArgumentException(\"Malformed isql CONNECT statement. Expected keyword CONNECT but something else was found.\");\n\t\t\t}\n\t\t\tenumerator.MoveNext();\n\t\t\t_connectionString.Database = enumerator.Current.Text.Replace(\"'\", string.Empty);\n\t\t\twhile (enumerator.MoveNext())\n\t\t\t{\n\t\t\t\tswitch (enumerator.Current.Text.ToUpperInvariant())\n\t\t\t\t{\n\t\t\t\t\tcase \"USER\":\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\t_connectionString.UserID = enumerator.Current.Text.Replace(\"'\", string.Empty);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"PASSWORD\":\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\t_connectionString.Password = enumerator.Current.Text.Replace(\"'\", string.Empty);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"CACHE\":\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"ROLE\":\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\t_connectionString.Role = enumerator.Current.Text.Replace(\"'\", string.Empty);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new ArgumentException(\"Unexpected token '\" + enumerator.Current.Text + \"' on isql CONNECT statement.\");\n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t_requiresNewConnection = true;\n\t\tawait ProvideConnectionAsync(cancellationToken).ConfigureAwait(false);\n\t}\n\n\t/// <summary>\n\t/// Parses the isql statement CREATE DATABASE and creates the database and opens a connection to the recently created database.\n\t/// </summary>\n\t/// <param name=\"createDatabaseStatement\">The create database statement.</param>\n\tprivate void CreateDatabase(string createDatabaseStatement)\n\t{\n\t\t// CREATE {DATABASE | SCHEMA} 'filespec'\n\t\t// [USER 'username' [PASSWORD 'password']]\n\t\t// [PAGE_SIZE [=] int]\n\t\t// [LENGTH [=] int [PAGE[S]]]\n\t\t// [DEFAULT CHARACTER SET charset]\n\t\t// [<secondary_file>];\n\t\tvar pageSize = 0;\n\t\tvar parser = new SqlStringParser(createDatabaseStatement);\n\t\tparser.Tokens = StandardParseTokens;\n\t\tusing (var enumerator = parser.Parse().GetEnumerator())\n\t\t{\n\t\t\tenumerator.MoveNext();\n\t\t\tif (enumerator.Current.Text.ToUpperInvariant() != \"CREATE\")\n\t\t\t{\n\t\t\t\tthrow new ArgumentException(\"Malformed isql CREATE statement. Expected keyword CREATE but something else was found.\");\n\t\t\t}\n\t\t\tenumerator.MoveNext(); // {DATABASE | SCHEMA}\n\t\t\tenumerator.MoveNext();\n\t\t\t_connectionString.Database = enumerator.Current.Text.Replace(\"'\", string.Empty);\n\t\t\twhile (enumerator.MoveNext())\n\t\t\t{\n\t\t\t\tswitch (enumerator.Current.Text.ToUpperInvariant())\n\t\t\t\t{\n\t\t\t\t\tcase \"USER\":\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\t_connectionString.UserID = enumerator.Current.Text.Replace(\"'\", string.Empty);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"PASSWORD\":\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\t_connectionString.Password = enumerator.Current.Text.Replace(\"'\", string.Empty);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"PAGE_SIZE\":\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\tif (enumerator.Current.Text == \"=\")\n\t\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\tint.TryParse(enumerator.Current.Text, out pageSize);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"DEFAULT\":\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\tif (enumerator.Current.Text.ToUpperInvariant() != \"CHARACTER\")\n\t\t\t\t\t\t\tthrow new ArgumentException(\"Expected the keyword CHARACTER but something else was found.\");\n\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\tif (enumerator.Current.Text.ToUpperInvariant() != \"SET\")\n\t\t\t\t\t\t\tthrow new ArgumentException(\"Expected the keyword SET but something else was found.\");\n\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\t_connectionString.Charset = enumerator.Current.Text;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tFbConnection.CreateDatabase(_connectionString.ToString(), pageSize: pageSize);\n\t\t_requiresNewConnection = true;\n\t\tProvideConnection();\n\t}\n\t/// <summary>\n\t/// Parses the isql statement CREATE DATABASE and creates the database and opens a connection to the recently created database.\n\t/// </summary>\n\t/// <param name=\"createDatabaseStatement\">The create database statement.</param>\n\tprivate async Task CreateDatabaseAsync(string createDatabaseStatement, CancellationToken cancellationToken = default)\n\t{\n\t\t// CREATE {DATABASE | SCHEMA} 'filespec'\n\t\t// [USER 'username' [PASSWORD 'password']]\n\t\t// [PAGE_SIZE [=] int]\n\t\t// [LENGTH [=] int [PAGE[S]]]\n\t\t// [DEFAULT CHARACTER SET charset]\n\t\t// [<secondary_file>];\n\t\tvar pageSize = 0;\n\t\tvar parser = new SqlStringParser(createDatabaseStatement);\n\t\tparser.Tokens = StandardParseTokens;\n\t\tusing (var enumerator = parser.Parse().GetEnumerator())\n\t\t{\n\t\t\tenumerator.MoveNext();\n\t\t\tif (enumerator.Current.Text.ToUpperInvariant() != \"CREATE\")\n\t\t\t{\n\t\t\t\tthrow new ArgumentException(\"Malformed isql CREATE statement. Expected keyword CREATE but something else was found.\");\n\t\t\t}\n\t\t\tenumerator.MoveNext(); // {DATABASE | SCHEMA}\n\t\t\tenumerator.MoveNext();\n\t\t\t_connectionString.Database = enumerator.Current.Text.Replace(\"'\", string.Empty);\n\t\t\twhile (enumerator.MoveNext())\n\t\t\t{\n\t\t\t\tswitch (enumerator.Current.Text.ToUpperInvariant())\n\t\t\t\t{\n\t\t\t\t\tcase \"USER\":\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\t_connectionString.UserID = enumerator.Current.Text.Replace(\"'\", string.Empty);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"PASSWORD\":\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\t_connectionString.Password = enumerator.Current.Text.Replace(\"'\", string.Empty);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"PAGE_SIZE\":\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\tif (enumerator.Current.Text == \"=\")\n\t\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\tint.TryParse(enumerator.Current.Text, out pageSize);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"DEFAULT\":\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\tif (enumerator.Current.Text.ToUpperInvariant() != \"CHARACTER\")\n\t\t\t\t\t\t\tthrow new ArgumentException(\"Expected the keyword CHARACTER but something else was found.\");\n\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\tif (enumerator.Current.Text.ToUpperInvariant() != \"SET\")\n\t\t\t\t\t\t\tthrow new ArgumentException(\"Expected the keyword SET but something else was found.\");\n\n\t\t\t\t\t\tenumerator.MoveNext();\n\t\t\t\t\t\t_connectionString.Charset = enumerator.Current.Text;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tawait FbConnection.CreateDatabaseAsync(_connectionString.ToString(), pageSize: pageSize, cancellationToken: cancellationToken).ConfigureAwait(false);\n\t\t_requiresNewConnection = true;\n\t\tawait ProvideConnectionAsync(cancellationToken).ConfigureAwait(false);\n\t}\n\n\t/// <summary>\n\t/// Parses the isql statement SET AUTODDL and sets the character set to current connection string.\n\t/// </summary>\n\t/// <param name=\"setAutoDdlStatement\">The set names statement.</param>\n\tprivate void SetAutoDdl(string setAutoDdlStatement, ref bool autoCommit)\n\t{\n\t\t// SET AUTODDL [ON | OFF]\n\t\tvar parser = new SqlStringParser(setAutoDdlStatement);\n\t\tparser.Tokens = StandardParseTokens;\n\t\tusing (var enumerator = parser.Parse().GetEnumerator())\n\t\t{\n\t\t\tenumerator.MoveNext();\n\t\t\tif (enumerator.Current.Text.ToUpperInvariant() != \"SET\")\n\t\t\t{\n\t\t\t\tthrow new ArgumentException(\"Malformed isql SET statement. Expected keyword SET but something else was found.\");\n\t\t\t}\n\t\t\tenumerator.MoveNext(); // AUTO\n\t\t\tif (enumerator.MoveNext())\n\t\t\t{\n\t\t\t\tvar onOff = enumerator.Current.Text.ToUpperInvariant();\n\t\t\t\tif (onOff == \"ON\")\n\t\t\t\t{\n\t\t\t\t\tautoCommit = true;\n\t\t\t\t}\n\t\t\t\telse if (onOff == \"OFF\")\n\t\t\t\t{\n\t\t\t\t\tautoCommit = false;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tthrow new ArgumentException(\"Expected the ON or OFF but something else was found.\");\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tautoCommit = !autoCommit;\n\t\t\t}\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Parses the isql statement SET NAMES and sets the character set to current connection string.\n\t/// </summary>\n\t/// <param name=\"setNamesStatement\">The set names statement.</param>\n\tprivate void SetNames(string setNamesStatement)\n\t{\n\t\t// SET NAMES charset\n\t\tvar parser = new SqlStringParser(setNamesStatement);\n\t\tparser.Tokens = StandardParseTokens;\n\t\tusing (var enumerator = parser.Parse().GetEnumerator())\n\t\t{\n\t\t\tenumerator.MoveNext();\n\t\t\tif (enumerator.Current.Text.ToUpperInvariant() != \"SET\")\n\t\t\t{\n\t\t\t\tthrow new ArgumentException(\"Malformed isql SET statement. Expected keyword SET but something else was found.\");\n\t\t\t}\n\t\t\tenumerator.MoveNext(); // NAMES\n\t\t\tenumerator.MoveNext();\n\t\t\t_connectionString.Charset = enumerator.Current.Text;\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// Parses the isql statement SET SQL DIALECT and sets the dialect set to current connection string.\n\t/// </summary>\n\t/// <param name=\"setSqlDialectStatement\">The set sql dialect statement.</param>\n\tprivate void SetSqlDialect(string setSqlDialectStatement)\n\t{\n\t\t// SET SQL DIALECT dialect\n\t\tvar parser = new SqlStringParser(setSqlDialectStatement);\n\t\tparser.Tokens = StandardParseTokens;\n\t\tusing (var enumerator = parser.Parse().GetEnumerator())\n\t\t{\n\t\t\tenumerator.MoveNext();\n\t\t\tif (enumerator.Current.Text.ToUpperInvariant() != \"SET\")\n\t\t\t{\n\t\t\t\tthrow new ArgumentException(\"Malformed isql SET statement. Expected keyword SET but something else was found.\");\n\t\t\t}\n\t\t\tenumerator.MoveNext(); // SQL\n\t\t\tenumerator.MoveNext(); // DIALECT\n\t\t\tenumerator.MoveNext();\n\t\t\tint.TryParse(enumerator.Current.Text, out var dialect);\n\t\t\t_connectionString.Dialect = dialect;\n\t\t}\n\t}\n\n\tprivate FbCommand ProvideCommand()\n\t{\n\t\tif (_sqlCommand == null)\n\t\t{\n\t\t\t_sqlCommand = new FbCommand();\n\t\t}\n\n\t\t_sqlCommand.Connection = ProvideConnection();\n\n\t\treturn _sqlCommand;\n\t}\n\tprivate async Task<FbCommand> ProvideCommandAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_sqlCommand == null)\n\t\t{\n\t\t\t_sqlCommand = new FbCommand();\n\t\t}\n\n\t\t_sqlCommand.Connection = await ProvideConnectionAsync(cancellationToken).ConfigureAwait(false);\n\n\t\treturn _sqlCommand;\n\t}\n\n\tprivate FbConnection ProvideConnection()\n\t{\n\t\tif (_requiresNewConnection)\n\t\t{\n\t\t\tif (_sqlConnection != null && _sqlConnection.State != ConnectionState.Closed)\n\t\t\t{\n\t\t\t\tCloseConnection();\n\t\t\t}\n\t\t\t_sqlConnection = new FbConnection(_connectionString.ToString());\n\t\t}\n\n\t\tif (_sqlConnection.State == ConnectionState.Closed)\n\t\t{\n\t\t\t_sqlConnection.Open();\n\t\t\t_shouldClose = true;\n\t\t}\n\n\t\treturn _sqlConnection;\n\t}\n\tprivate async Task<FbConnection> ProvideConnectionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_requiresNewConnection)\n\t\t{\n\t\t\tif (_sqlConnection != null && _sqlConnection.State != ConnectionState.Closed)\n\t\t\t{\n\t\t\t\tawait CloseConnectionAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\t_sqlConnection = new FbConnection(_connectionString.ToString());\n\t\t}\n\n\t\tif (_sqlConnection.State == ConnectionState.Closed)\n\t\t{\n\t\t\tawait _sqlConnection.OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t_shouldClose = true;\n\t\t}\n\n\t\treturn _sqlConnection;\n\t}\n\n\tprivate int ExecuteCommand(bool autoCommit)\n\t{\n\t\tvar rowsAffected = _sqlCommand.ExecuteNonQuery();\n\t\tif (autoCommit && _sqlCommand.IsDDLCommand)\n\t\t{\n\t\t\tCommitTransaction();\n\t\t}\n\t\treturn rowsAffected;\n\t}\n\tprivate async Task<int> ExecuteCommandAsync(bool autoCommit, CancellationToken cancellationToken = default)\n\t{\n\t\tvar rowsAffected = await _sqlCommand.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false);\n\t\tif (autoCommit && _sqlCommand.IsDDLCommand)\n\t\t{\n\t\t\tawait CommitTransactionAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\treturn rowsAffected;\n\t}\n\n\tprivate void CommitTransaction()\n\t{\n\t\tif (_sqlTransaction != null)\n\t\t{\n\t\t\t_sqlTransaction.Commit();\n\t\t\t_sqlTransaction.Dispose();\n\t\t\t_sqlTransaction = null;\n\t\t}\n\t}\n\tprivate async Task CommitTransactionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_sqlTransaction != null)\n\t\t{\n\t\t\tawait _sqlTransaction.CommitAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tawait _sqlTransaction.DisposeAsync().ConfigureAwait(false);\n\t\t\t_sqlTransaction = null;\n\t\t}\n\t}\n\n\tprivate void RollbackTransaction()\n\t{\n\t\tif (_sqlTransaction != null)\n\t\t{\n\t\t\t_sqlTransaction.Rollback();\n\t\t\t_sqlTransaction.Dispose();\n\t\t\t_sqlTransaction = null;\n\t\t}\n\t}\n\tprivate async Task RollbackTransactionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_sqlTransaction != null)\n\t\t{\n\t\t\tawait _sqlTransaction.RollbackAsync(cancellationToken).ConfigureAwait(false);\n\t\t\tawait _sqlTransaction.DisposeAsync().ConfigureAwait(false);\n\t\t\t_sqlTransaction = null;\n\t\t}\n\t}\n\n\tprivate void CloseConnection()\n\t{\n\t\tif (_shouldClose)\n\t\t{\n\t\t\t_sqlConnection.Close();\n\t\t}\n\t}\n\tprivate async Task CloseConnectionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_shouldClose)\n\t\t{\n\t\t\tawait _sqlConnection.CloseAsync().ConfigureAwait(false);\n\t\t}\n\t}\n\n\tprivate void DisposeCommand()\n\t{\n\t\tif (_sqlCommand != null)\n\t\t{\n\t\t\t_sqlCommand.Dispose();\n\t\t}\n\t}\n\tprivate async Task DisposeCommandAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (_sqlCommand != null)\n\t\t{\n\t\t\tawait _sqlCommand.DisposeAsync().ConfigureAwait(false);\n\t\t}\n\t}\n\n\t/// <summary>\n\t/// The trigger function for <see cref=\"CommandExecuting\"/>\tevent.\n\t/// </summary>\n\t/// <param name=\"sqlCommand\">The SQL command that is going for execution.</param>\n\tprivate void OnCommandExecuting(FbCommand sqlCommand, SqlStatementType statementType)\n\t{\n\t\tCommandExecuting?.Invoke(this, new CommandExecutingEventArgs(sqlCommand, statementType));\n\t}\n\n\t/// <summary>\n\t/// The trigger function for <see cref=\"CommandExecuted\"/> event.\n\t/// </summary>\n\t/// <param name=\"commandText\">The <see cref=\"FbCommand.CommandText\"/> of the executed SQL command.</param>\n\t/// <param name=\"dataReader\">The <see cref=\"FbDataReader\"/> instance with the returned data. If the\n\t/// command executed is not meant to return data (ex: UPDATE, INSERT...) this parameter must be\n\t/// setled to <b>null</b>.</param>\n\t/// <param name=\"rowsAffected\">The rows that were affected by the executed SQL command. If the executed\n\t/// command is not meant to return this kind of information (ex: SELECT) this parameter must\n\t/// be setled to <b>-1</b>.</param>\n\tprivate void OnCommandExecuted(FbDataReader dataReader, string commandText, SqlStatementType statementType, int rowsAffected)\n\t{\n\t\tCommandExecuted?.Invoke(this, new CommandExecutedEventArgs(dataReader, commandText, statementType, rowsAffected));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Isql/FbScript.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Abel Eduardo Pereira, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.IO;\nusing System.Linq;\n\nnamespace FirebirdSql.Data.Isql;\n\n/// <summary>\n/// FbScript parses a SQL file and returns its SQL statements.\n/// The class take in consideration that the statement separator can change in code.\n/// For instance, in Firebird databases the statement <c>SET TERM !! ;</c> will change the\n/// statement token terminator <b>;</b> into <b>!!</b>.\n/// </summary>\npublic class FbScript\n{\n\tpublic event EventHandler<UnknownStatementEventArgs> UnknownStatement;\n\n\tSqlStringParser _parser;\n\tFbStatementCollection _results;\n\n\t/// <summary>\n\t/// Returns a FbStatementCollection containing all the SQL statements (without comments) present on the file.\n\t/// This property is loaded after the method call <see cref=\"Parse\"/>.\n\t/// </summary>\n\tpublic FbStatementCollection Results\n\t{\n\t\tget { return _results; }\n\t}\n\n\t/// <summary>\n\t/// Creates FbScript reading content from file.\n\t/// </summary>\n\tpublic static FbScript LoadFromFile(string fileName)\n\t{\n\t\treturn new FbScript(File.ReadAllText(fileName));\n\t}\n\n\tpublic FbScript(string script)\n\t{\n\t\tif (script == null)\n\t\t\tthrow new ArgumentNullException();\n\n\t\t_results = new FbStatementCollection();\n\t\t_parser = new SqlStringParser(script);\n\t\t_parser.Tokens = new[] { \";\" };\n\t}\n\n\t/// <summary>\n\t/// Parses the SQL code and loads the SQL statements into the StringCollection <see cref=\"Results\"/>.\n\t/// </summary>\n\t/// <returns>The number of statements found.</returns>\n\tpublic int Parse()\n\t{\n\t\t_results.Clear();\n\t\tforeach (var statement in _parser.Parse())\n\t\t{\n\t\t\tif (IsSetTermStatement(statement.CleanText, out var newParserToken))\n\t\t\t{\n\t\t\t\t_parser.Tokens = new[] { newParserToken };\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (statement.CleanText != string.Empty)\n\t\t\t{\n\t\t\t\tvar type = GetStatementType(statement.CleanText);\n\t\t\t\tif (type != null)\n\t\t\t\t{\n\t\t\t\t\tstatement.SetStatementType((SqlStatementType)type);\n\t\t\t\t\t_results.Add(statement);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (statement.Text.Trim() != string.Empty)\n\t\t\t{\n\t\t\t\tvar unknownStatementEventArgs = new UnknownStatementEventArgs(statement);\n\t\t\t\tUnknownStatement?.Invoke(this, unknownStatementEventArgs);\n\t\t\t\tif (unknownStatementEventArgs.Handled && !unknownStatementEventArgs.Ignore)\n\t\t\t\t{\n\t\t\t\t\tstatement.SetStatementType(unknownStatementEventArgs.NewStatementType);\n\t\t\t\t\t_results.Add(statement);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\telse if (!unknownStatementEventArgs.Handled && unknownStatementEventArgs.Ignore)\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\telse if (unknownStatementEventArgs.Handled && unknownStatementEventArgs.Ignore)\n\t\t\t\t{\n\t\t\t\t\tthrow new InvalidOperationException($\"Both {nameof(UnknownStatementEventArgs.Handled)} and {nameof(UnknownStatementEventArgs.Ignore)} should not be set.\");\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tthrow new ArgumentException($\"The type of the SQL statement could not be determined. See also {nameof(UnknownStatement)} event.{Environment.NewLine}Statement: {statement.Text}.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn _results.Count;\n\t}\n\n\tstatic bool IsSetTermStatement(string statement, out string newTerm)\n\t{\n\t\tif (statement.StartsWith(\"SET TERM\", StringComparison.OrdinalIgnoreCase))\n\t\t{\n\t\t\tnewTerm = statement.Substring(8).Trim();\n\t\t\treturn true;\n\t\t}\n\n\t\tnewTerm = default;\n\t\treturn false;\n\t}\n\n\tstatic SqlStatementType? GetStatementType(string sqlStatement)\n\t{\n\t\tswitch (sqlStatement.FirstOrDefault())\n\t\t{\n\t\t\tcase 'A':\n\t\t\tcase 'a':\n\t\t\t\tif (sqlStatement.StartsWith(\"ALTER CHARACTER SET\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.AlterCharacterSet;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"ALTER DATABASE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.AlterDatabase;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"ALTER DOMAIN\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.AlterDomain;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"ALTER EXCEPTION\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.AlterException;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"ALTER EXTERNAL FUNCTION\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.AlterExternalFunction;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"ALTER FUNCTION\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.AlterFunction;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"ALTER INDEX\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.AlterIndex;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"ALTER PACKAGE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.AlterPackage;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"ALTER PROCEDURE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.AlterProcedure;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"ALTER ROLE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.AlterRole;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"ALTER SEQUENCE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.AlterSequence;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"ALTER TABLE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.AlterTable;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"ALTER TRIGGER\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.AlterTrigger;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"ALTER VIEW\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.AlterView;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 'C':\n\t\t\tcase 'c':\n\t\t\t\tif (sqlStatement.StartsWith(\"CLOSE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Close;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"COMMENT ON\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CommentOn;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"COMMIT\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Commit;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CONNECT\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Connect;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE COLLATION\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreateCollation;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE DATABASE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreateDatabase;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE DOMAIN\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreateDomain;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE EXCEPTION\", StringComparison.OrdinalIgnoreCase) ||\n\t\t\t\t\tsqlStatement.StartsWith(\"CREATE OR ALTER EXCEPTION\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreateException;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE FUNCTION\", StringComparison.OrdinalIgnoreCase) ||\n\t\t\t\t\tsqlStatement.StartsWith(\"CREATE OR ALTER FUNCTION\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreateFunction;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE GENERATOR\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreateGenerator;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE INDEX\", StringComparison.OrdinalIgnoreCase) ||\n\t\t\t\t\tsqlStatement.StartsWith(\"CREATE ASC INDEX\", StringComparison.OrdinalIgnoreCase) ||\n\t\t\t\t\tsqlStatement.StartsWith(\"CREATE ASCENDING INDEX\", StringComparison.OrdinalIgnoreCase) ||\n\t\t\t\t\tsqlStatement.StartsWith(\"CREATE DESC INDEX\", StringComparison.OrdinalIgnoreCase) ||\n\t\t\t\t\tsqlStatement.StartsWith(\"CREATE DESCENDING INDEX\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreateIndex;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE PACKAGE BODY\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreatePackageBody;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE PACKAGE\", StringComparison.OrdinalIgnoreCase) ||\n\t\t\t\t\tsqlStatement.StartsWith(\"CREATE OR ALTER PACKAGE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreatePackage;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE PROCEDURE\", StringComparison.OrdinalIgnoreCase) ||\n\t\t\t\t\tsqlStatement.StartsWith(\"CREATE OR ALTER PROCEDURE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreateProcedure;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE ROLE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreateRole;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE SEQUENCE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreateSequence;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE SHADOW\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreateShadow;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE TABLE\", StringComparison.OrdinalIgnoreCase) ||\n\t\t\t\t\tsqlStatement.StartsWith(\"CREATE GLOBAL TEMPORARY TABLE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreateTable;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE TRIGGER\", StringComparison.OrdinalIgnoreCase) ||\n\t\t\t\t\tsqlStatement.StartsWith(\"CREATE OR ALTER TRIGGER\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreateTrigger;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE UNIQUE INDEX\", StringComparison.OrdinalIgnoreCase) ||\n\t\t\t\t\tsqlStatement.StartsWith(\"CREATE UNIQUE ASC INDEX\", StringComparison.OrdinalIgnoreCase) ||\n\t\t\t\t\tsqlStatement.StartsWith(\"CREATE UNIQUE ASCENDING INDEX\", StringComparison.OrdinalIgnoreCase) ||\n\t\t\t\t\tsqlStatement.StartsWith(\"CREATE UNIQUE DESC INDEX\", StringComparison.OrdinalIgnoreCase) ||\n\t\t\t\t\tsqlStatement.StartsWith(\"CREATE UNIQUE DESCENDING INDEX\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreateIndex;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"CREATE VIEW\", StringComparison.OrdinalIgnoreCase) ||\n\t\t\t\t\tsqlStatement.StartsWith(\"CREATE OR ALTER VIEW\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.CreateView;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 'D':\n\t\t\tcase 'd':\n\t\t\t\tif (sqlStatement.StartsWith(\"DECLARE CURSOR\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DeclareCursor;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DECLARE EXTERNAL FUNCTION\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DeclareExternalFunction;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DECLARE FILTER\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DeclareFilter;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DECLARE STATEMENT\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DeclareStatement;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DECLARE TABLE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DeclareTable;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DELETE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Delete;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DESCRIBE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Describe;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DISCONNECT\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Disconnect;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP COLLATION\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropCollation;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP DATABASE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropDatabase;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP DOMAIN\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropDomain;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP EXCEPTION\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropException;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP EXTERNAL FUNCTION\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropExternalFunction;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP FUNCTION\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropFunction;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP FILTER\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropFilter;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP GENERATOR\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropGenerator;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP INDEX\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropIndex;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP PACKAGE BODY\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropPackageBody;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP PACKAGE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropPackage;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP PROCEDURE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropProcedure;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP SEQUENCE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropSequence;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP ROLE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropRole;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP SHADOW\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropShadow;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP TABLE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropTable;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP TRIGGER\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropTrigger;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"DROP VIEW\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.DropView;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 'E':\n\t\t\tcase 'e':\n\t\t\t\tif (sqlStatement.StartsWith(\"EXECUTE BLOCK\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.ExecuteBlock;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"EXECUTE IMMEDIATE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.ExecuteImmediate;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"EXECUTE PROCEDURE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.ExecuteProcedure;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"EXECUTE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Execute;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"EVENT WAIT\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.EventWait;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"EVENT INIT\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.EventInit;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"END DECLARE SECTION\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.EndDeclareSection;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 'F':\n\t\t\tcase 'f':\n\t\t\t\tif (sqlStatement.StartsWith(\"FETCH\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Fetch;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 'G':\n\t\t\tcase 'g':\n\t\t\t\tif (sqlStatement.StartsWith(\"GRANT\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Grant;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 'I':\n\t\t\tcase 'i':\n\t\t\t\tif (sqlStatement.StartsWith(\"INSERT CURSOR\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.InsertCursor;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"INSERT\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Insert;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 'M':\n\t\t\tcase 'm':\n\t\t\t\tif (sqlStatement.StartsWith(\"MERGE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Merge;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 'O':\n\t\t\tcase 'o':\n\t\t\t\tif (sqlStatement.StartsWith(\"OPEN\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Open;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 'P':\n\t\t\tcase 'p':\n\t\t\t\tif (sqlStatement.StartsWith(\"PREPARE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Prepare;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 'R':\n\t\t\tcase 'r':\n\t\t\t\tif (sqlStatement.StartsWith(\"REVOKE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Revoke;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"RECREATE FUNCTION\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.RecreateFunction;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"RECREATE PACKAGE BODY\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.RecreatePackageBody;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"RECREATE PACKAGE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.RecreatePackage;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"RECREATE PROCEDURE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.RecreateProcedure;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"RECREATE TABLE\", StringComparison.OrdinalIgnoreCase) ||\n\t\t\t\t\tsqlStatement.StartsWith(\"RECREATE GLOBAL TEMPORARY TABLE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.RecreateTable;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"RECREATE TRIGGER\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.RecreateTrigger;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"RECREATE VIEW\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.RecreateView;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"ROLLBACK\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Rollback;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 'S':\n\t\t\tcase 's':\n\t\t\t\tif (sqlStatement.StartsWith(\"SELECT\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Select;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"SET AUTODDL\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.SetAutoDDL;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"SET DATABASE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.SetDatabase;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"SET GENERATOR\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.SetGenerator;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"SET NAMES\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.SetNames;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"SET SQL DIALECT\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.SetSQLDialect;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"SET STATISTICS\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.SetStatistics;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"SET TRANSACTION\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.SetTransaction;\n\t\t\t\t}\n\t\t\t\tif (sqlStatement.StartsWith(\"SHOW SQL DIALECT\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.ShowSQLDialect;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 'U':\n\t\t\tcase 'u':\n\t\t\t\tif (sqlStatement.StartsWith(\"UPDATE\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Update;\n\t\t\t\t}\n\t\t\t\tbreak;\n\n\t\t\tcase 'W':\n\t\t\tcase 'w':\n\t\t\t\tif (sqlStatement.StartsWith(\"WHENEVER\", StringComparison.OrdinalIgnoreCase))\n\t\t\t\t{\n\t\t\t\t\treturn SqlStatementType.Whenever;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Isql/FbStatement.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.Isql;\n\n[Serializable]\npublic class FbStatement\n{\n\tpublic string Text { get; private set; }\n\tinternal string CleanText { get; private set; }\n\tpublic SqlStatementType StatementType { get; private set; }\n\n\tinternal FbStatement(string text, string cleanText)\n\t{\n\t\tText = text;\n\t\tCleanText = cleanText;\n\t}\n\n\tinternal void SetStatementType(SqlStatementType statementType)\n\t{\n\t\tStatementType = statementType;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Isql/FbStatementCollection.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\n\nnamespace FirebirdSql.Data.Isql;\n\n[Serializable]\npublic class FbStatementCollection : List<FbStatement>\n{\n\tinternal FbStatementCollection()\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Isql/SqlStatementType.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Abel Eduardo Pereira, Jiri Cincura (jiri@cincura.net), Olivier Metod\n\nusing System;\n\nnamespace FirebirdSql.Data.Isql;\n\n[Serializable]\npublic enum SqlStatementType\n{\n\tAlterCharacterSet,\n\tAlterDatabase,\n\tAlterDomain,\n\tAlterException,\n\tAlterExternalFunction,\n\tAlterFunction,\n\tAlterIndex,\n\tAlterPackage,\n\tAlterProcedure,\n\tAlterRole,\n\tAlterSequence,\n\tAlterTable,\n\tAlterTrigger,\n\tAlterView,\n\tClose,\n\tCommentOn,\n\tCommit,\n\tConnect,\n\tCreateCollation,\n\tCreateDatabase,\n\tCreateDomain,\n\tCreateException,\n\tCreateFunction,\n\tCreateGenerator,\n\tCreateIndex,\n\tCreatePackage,\n\tCreatePackageBody,\n\tCreateProcedure,\n\tCreateRole,\n\tCreateSequence,\n\tCreateShadow,\n\tCreateTable,\n\tCreateTrigger,\n\tCreateView,\n\tDeclareCursor,\n\tDeclareExternalFunction,\n\tDeclareFilter,\n\tDeclareStatement,\n\tDeclareTable,\n\tDelete,\n\tDescribe,\n\tDisconnect,\n\tDropCollation,\n\tDropDatabase,\n\tDropDomain,\n\tDropException,\n\tDropExternalFunction,\n\tDropFunction,\n\tDropFilter,\n\tDropGenerator,\n\tDropIndex,\n\tDropPackage,\n\tDropPackageBody,\n\tDropProcedure,\n\tDropSequence,\n\tDropRole,\n\tDropShadow,\n\tDropTable,\n\tDropTrigger,\n\tDropView,\n\tEndDeclareSection,\n\tEventInit,\n\tEventWait,\n\tExecute,\n\tExecuteBlock,\n\tExecuteImmediate,\n\tExecuteProcedure,\n\tFetch,\n\tGrant,\n\tInsert,\n\tInsertCursor,\n\tMerge,\n\tOpen,\n\tPrepare,\n\tRecreateFunction,\n\tRecreatePackage,\n\tRecreatePackageBody,\n\tRecreateProcedure,\n\tRecreateTable,\n\tRecreateTrigger,\n\tRecreateView,\n\tRevoke,\n\tRollback,\n\tSelect,\n\tSetAutoDDL,\n\tSetDatabase,\n\tSetGenerator,\n\tSetNames,\n\tSetSQLDialect,\n\tSetStatistics,\n\tSetTransaction,\n\tShowSQLDialect,\n\tUpdate,\n\tWhenever,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Isql/SqlStringParser.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Abel Eduardo Pereira, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Isql;\n\nclass SqlStringParser\n{\n\tstring _source;\n\tint _sourceLength;\n\tstring[] _tokens;\n\n\tpublic string[] Tokens\n\t{\n\t\tget { return _tokens; }\n\t\tset\n\t\t{\n\t\t\tif (value == null)\n\t\t\t\tthrow new ArgumentNullException();\n\t\t\tforeach (var item in value)\n\t\t\t{\n\t\t\t\tif (value == null)\n\t\t\t\t\tthrow new ArgumentNullException();\n\t\t\t\tif (string.IsNullOrEmpty(item))\n\t\t\t\t\tthrow new ArgumentException();\n\t\t\t}\n\t\t\t_tokens = value;\n\t\t}\n\t}\n\n\tpublic SqlStringParser(string targetString)\n\t{\n\t\t_tokens = new[] { \" \" };\n\t\t_source = targetString;\n\t\t_sourceLength = targetString.Length;\n\t}\n\n\tpublic IEnumerable<FbStatement> Parse()\n\t{\n\t\tvar lastYield = 0;\n\t\tvar index = 0;\n\t\tvar rawResult = new StringBuilder();\n\t\twhile (true)\n\t\t{\n\t\t\tContinue:\n\t\t\t{ }\n\t\t\tif (index >= _sourceLength)\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (GetChar(index) == '\\'')\n\t\t\t{\n\t\t\t\trawResult.Append(GetChar(index));\n\t\t\t\tindex++;\n\t\t\t\trawResult.Append(ProcessLiteral(ref index));\n\t\t\t\trawResult.Append(GetChar(index));\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse if (GetChar(index) == '-' && GetNextChar(index) == '-')\n\t\t\t{\n\t\t\t\tindex++;\n\t\t\t\tProcessSinglelineComment(ref index);\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse if (GetChar(index) == '/' && GetNextChar(index) == '*')\n\t\t\t{\n\t\t\t\tindex++;\n\t\t\t\tProcessMultilineComment(ref index);\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tforeach (var token in Tokens)\n\t\t\t\t{\n\t\t\t\t\tif (string.Compare(_source, index, token, 0, token.Length, StringComparison.Ordinal) == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tindex += token.Length;\n\t\t\t\t\t\tyield return new FbStatement(_source.Substring(lastYield, index - lastYield - token.Length), rawResult.ToString());\n\t\t\t\t\t\tlastYield = index;\n\t\t\t\t\t\trawResult.Clear();\n\t\t\t\t\t\tgoto Continue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!(rawResult.Length == 0 && char.IsWhiteSpace(GetChar(index))))\n\t\t\t\t{\n\t\t\t\t\trawResult.Append(GetChar(index));\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t}\n\t\t}\n\n\t\tif (index >= _sourceLength)\n\t\t{\n\t\t\tvar parsed = _source.Substring(lastYield);\n\t\t\tif (parsed.Trim() == string.Empty)\n\t\t\t{\n\t\t\t\tyield break;\n\t\t\t}\n\t\t\tyield return new FbStatement(parsed, rawResult.ToString());\n\t\t\tlastYield = _sourceLength;\n\t\t\trawResult.Clear();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tyield return new FbStatement(_source.Substring(lastYield, index - lastYield), rawResult.ToString());\n\t\t\tlastYield = index;\n\t\t\trawResult.Clear();\n\t\t}\n\t}\n\n\tstring ProcessLiteral(ref int index)\n\t{\n\t\tvar sb = new StringBuilder();\n\t\twhile (index < _sourceLength)\n\t\t{\n\t\t\tif (GetChar(index) == '\\'')\n\t\t\t{\n\t\t\t\tif (GetNextChar(index) == '\\'')\n\t\t\t\t{\n\t\t\t\t\tsb.Append(GetChar(index));\n\t\t\t\t\tindex++;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tsb.Append(GetChar(index));\n\t\t\tindex++;\n\t\t}\n\t\treturn sb.ToString();\n\t}\n\n\tvoid ProcessMultilineComment(ref int index)\n\t{\n\t\twhile (index < _sourceLength)\n\t\t{\n\t\t\tif (GetChar(index) == '*' && GetNextChar(index) == '/')\n\t\t\t{\n\t\t\t\tindex++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tindex++;\n\t\t}\n\t}\n\n\tvoid ProcessSinglelineComment(ref int index)\n\t{\n\t\twhile (index < _sourceLength)\n\t\t{\n\t\t\tif (GetChar(index) == '\\n')\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (GetChar(index) == '\\r')\n\t\t\t{\n\t\t\t\tif (GetNextChar(index) == '\\n')\n\t\t\t\t{\n\t\t\t\t\tindex++;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tindex++;\n\t\t}\n\t}\n\n\tchar GetChar(int index)\n\t{\n\t\treturn _source[index];\n\t}\n\n\tchar? GetNextChar(int index)\n\t{\n\t\treturn index + 1 < _sourceLength\n\t\t\t? _source[index + 1]\n\t\t\t: (char?)null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Isql/UnknownStatementEventArgs.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.Isql;\n\npublic class UnknownStatementEventArgs : EventArgs\n{\n\tpublic FbStatement Statement { get; private set; }\n\tpublic bool Handled { get; set; }\n\tpublic bool Ignore { get; set; }\n\tpublic SqlStatementType NewStatementType { get; set; }\n\n\tpublic UnknownStatementEventArgs(FbStatement statement)\n\t{\n\t\tStatement = statement;\n\t\tHandled = false;\n\t\tIgnore = false;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Logging/FbLogManager.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.Extensions.Logging.Abstractions;\nusing Microsoft.Extensions.Logging;\n\nnamespace FirebirdSql.Data.Logging;\n\npublic static class FbLogManager\n{\n\tpublic static bool IsParameterLoggingEnabled { get; private set; } = false;\n\n\tprivate static ILoggerFactory LoggerFactory = NullLoggerFactory.Instance;\n\n\tpublic static void UseLoggerFactory(ILoggerFactory loggerFactory) =>\n\t\tLoggerFactory = loggerFactory;\n\n\tpublic static void EnableParameterLogging(bool enable = true) =>\n\t\tIsParameterLoggingEnabled = enable;\n\n\tinternal static ILogger<T> CreateLogger<T>() =>\n\t\tLoggerFactory.CreateLogger<T>();\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Logging/LogMessages.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Data.Common;\nusing System.Linq;\nusing FirebirdSql.Data.FirebirdClient;\nusing Microsoft.Extensions.Logging;\n\nnamespace FirebirdSql.Data.Logging;\n\nstatic class LogMessages\n{\n\tpublic static void CommandExecution(ILogger log, FbCommand command)\n\t{\n\t\tif (!log.IsEnabled(LogLevel.Debug))\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tif (FbLogManager.IsParameterLoggingEnabled && command.HasParameters)\n\t\t{\n\t\t\tvar parameters = FbParameterCollectionToDictionary(command.Parameters);\n\t\t\tlog.LogDebug(\"Command execution: {command}, {parameters}\", command.CommandText, parameters);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlog.LogDebug(\"Command execution: {command}\", command.CommandText);\n\t\t}\n\t}\n\n\tpublic static void CommandExecution(ILogger log, FbBatchCommand command)\n\t{\n\t\tif (!log.IsEnabled(LogLevel.Debug))\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tif (FbLogManager.IsParameterLoggingEnabled && command.HasParameters)\n\t\t{\n\t\t\tvar parameters = command.BatchParameters.SelectMany(FbParameterCollectionToDictionary);\n\t\t\tlog.LogDebug(\"Command execution: {command}, {parameters}\", command.CommandText, parameters);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlog.LogDebug(\"Command execution: {command}\", command.CommandText);\n\t\t}\n\t}\n\n\tpublic static void ConnectionOpening(ILogger log, FbConnection connection) =>\n\t\tlog.LogDebug(\"Opening connection: {connectionString}\", connection.ConnectionString);\n\n\tpublic static void ConnectionOpened(ILogger log, FbConnection connection) =>\n\t\tlog.LogDebug(\"Opened connection: {connectionString}\", connection.ConnectionString);\n\n\tpublic static void ConnectionClosing(ILogger log, FbConnection connection) =>\n\t\tlog.LogDebug(\"Closing connection: {connectionString}\", connection.ConnectionString);\n\n\tpublic static void ConnectionClosed(ILogger log, FbConnection connection) =>\n\t\tlog.LogDebug(\"Closed connection: {connectionString}\", connection.ConnectionString);\n\n\tpublic static void TransactionBeginning(ILogger log, FbTransaction transaction) =>\n\t\t// TODO: Transaction Id?\n\t\tlog.LogDebug(\"Beginning transaction: {isolationLevel}\", transaction.IsolationLevel);\n\n\tpublic static void TransactionBegan(ILogger log, FbTransaction transaction) =>\n\t\tlog.LogDebug(\"Began transaction: {isolationLevel}\", transaction.IsolationLevel);\n\n\tpublic static void TransactionCommitting(ILogger log, FbTransaction transaction) =>\n\t\tlog.LogDebug(\"Committing transaction: {isolationLevel}\", transaction.IsolationLevel);\n\n\tpublic static void TransactionCommitted(ILogger log, FbTransaction transaction) =>\n\t\tlog.LogDebug(\"Committed transaction: {isolationLevel}\", transaction.IsolationLevel);\n\n\tpublic static void TransactionRollingBack(ILogger log, FbTransaction transaction) =>\n\t\tlog.LogDebug(\"Rolling back transaction: {isolationLevel}\", transaction.IsolationLevel);\n\n\tpublic static void TransactionRolledBack(ILogger log, FbTransaction transaction) =>\n\t\tlog.LogDebug(\"Rolled back transaction: {isolationLevel}\", transaction.IsolationLevel);\n\n\tpublic static void TransactionSaving(ILogger log, FbTransaction transaction) =>\n\t\tlog.LogDebug(\"Creating savepoint: {isolationLevel}\", transaction.IsolationLevel);\n\n\tpublic static void TransactionSaved(ILogger log, FbTransaction transaction) =>\n\t\tlog.LogDebug(\"Created savepoint: {isolationLevel}\", transaction.IsolationLevel);\n\n\tpublic static void TransactionReleasingSavepoint(ILogger log, FbTransaction transaction) =>\n\t\tlog.LogDebug(\"Releasing savepoint: {isolationLevel}\", transaction.IsolationLevel);\n\n\tpublic static void TransactionReleasedSavepoint(ILogger log, FbTransaction transaction) =>\n\t\tlog.LogDebug(\"Released savepoint: {isolationLevel}\", transaction.IsolationLevel);\n\n\tpublic static void TransactionRollingBackSavepoint(ILogger log, FbTransaction transaction) =>\n\t\tlog.LogDebug(\"Rolling back savepoint: {isolationLevel}\", transaction.IsolationLevel);\n\n\tpublic static void TransactionRolledBackSavepoint(ILogger log, FbTransaction transaction) =>\n\t\tlog.LogDebug(\"Rolled back savepoint: {isolationLevel}\", transaction.IsolationLevel);\n\n\tpublic static void TransactionCommittingRetaining(ILogger log, FbTransaction transaction) =>\n\t\tlog.LogDebug(\"Committing (retaining) transaction: {isolationLevel}\", transaction.IsolationLevel);\n\n\tpublic static void TransactionCommittedRetaining(ILogger log, FbTransaction transaction) =>\n\t\tlog.LogDebug(\"Committed (retaining) transaction: {isolationLevel}\", transaction.IsolationLevel);\n\n\tpublic static void TransactionRollingBackRetaining(ILogger log, FbTransaction transaction) =>\n\t\tlog.LogDebug(\"Rolling back (retaining) transaction: {isolationLevel}\", transaction.IsolationLevel);\n\n\tpublic static void TransactionRolledBackRetaining(ILogger log, FbTransaction transaction) =>\n\t\tlog.LogDebug(\"Rolled back (retaining) transaction: {isolationLevel}\", transaction.IsolationLevel);\n\n\tprivate static object NormalizeDbNull(object value) =>\n\t\tvalue == DBNull.Value || value == null\n\t\t\t? null\n\t\t\t: value;\n\n\tprivate static Dictionary<string, object> FbParameterCollectionToDictionary(FbParameterCollection parameters) =>\n\t\tparameters\n\t\t\t.Cast<DbParameter>()\n\t\t\t.ToDictionary(\n\t\t\t\tp => p.ParameterName,\n\t\t\t\tp => NormalizeDbNull(p.Value)\n\t\t\t);\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Properties/ComAssemblyInfo.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Runtime.InteropServices;\n\n[assembly: ComVisible(true)]\n[assembly: Guid(\"F37B8373-51FA-4CC6-934E-DF147DFBD9F1\")]\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Properties/InternalsVisibleToAssemblyInfo.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Runtime.CompilerServices;\n\n[assembly: InternalsVisibleTo(\"FirebirdSql.Data.FirebirdClient.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001002f636382c6d70ed5596f3db517cf3bf37950ee9ee86340d32d6f98143f0a4fdf0e934d361de0a6ce63c61e0a0dddc5f66d8ec752306b94931241061817f3c203e1105da8958ca9a889af83083bbb53dfdfee2d028d554bef2ce8a577816202a7bb38885e2dc74695d2a0fecfef259a34860a8faf54ce49a0cd5b5fdfa90f4bb7\")]\n[assembly: InternalsVisibleTo(\"Scratchpad, PublicKey=00240000048000009400000006020000002400005253413100040000010001002f636382c6d70ed5596f3db517cf3bf37950ee9ee86340d32d6f98143f0a4fdf0e934d361de0a6ce63c61e0a0dddc5f66d8ec752306b94931241061817f3c203e1105da8958ca9a889af83083bbb53dfdfee2d028d554bef2ce8a577816202a7bb38885e2dc74695d2a0fecfef259a34860a8faf54ce49a0cd5b5fdfa90f4bb7\")]\n[assembly: InternalsVisibleTo(\"EntityFramework.Firebird, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d781cab4da72af6b1ec44a92c8dc554760c0f3ba89a355335eeb29c5b42bc9ad476f6340dbd25f34f186f59fea814a891a787c0d37d65a1f5a481a1ea221274e498bc446ee91eeae009949ff16a24c553b97a23873c4428b6027082abe7166bae12b56864976d9fca3155249adc4d9b4e6b6cdb530b7888b7528c8cb401b96d2\")]\n[assembly: InternalsVisibleTo(\"FirebirdSql.EntityFrameworkCore.Firebird, PublicKey=0024000004800000940000000602000000240000525341310004000001000100013879c35829256e79bd0a8badda8c8ef055ced0d96a26f7eb7ed2a6ac17c45ea3182cf93ec2f9ee18a5d7235e8c552d063a859dfd85274a98d180a66f042c3b31e10ab4280ccb417a92c0e3ed6828531af1d1196662fabd83e394bbfb1169abca8906f82302355aae2859b2d0dde80d43c1827849b92a1d2e26baed9c8d7be2\")]\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbCharacterSets.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbCharacterSets : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS CHARACTER_SET_CATALOG,\n\t\t\t\t\tnull AS CHARACTER_SET_SCHEMA,\n\t\t\t\t\trdb$character_set_name AS CHARACTER_SET_NAME,\n\t\t\t\t\trdb$character_set_id AS CHARACTER_SET_ID,\n\t\t\t\t    rdb$default_collate_name AS DEFAULT_COLLATION,\n\t\t\t\t    rdb$bytes_per_character AS BYTES_PER_CHARACTER,\n\t\t\t\t    rdb$description AS DESCRIPTION\n\t\t\t\t FROM rdb$character_sets\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* CHARACTER_SET_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* CHARACTER_SET_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* CHARACTER_SET_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\"rdb$character_set_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY CHARACTER_SET_NAME\");\n\n\t\treturn sql;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbCheckConstraints.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Text;\nusing System.Globalization;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbCheckConstraints : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS CONSTRAINT_CATALOG,\n\t\t\t\t\tnull AS CONSTRAINT_SCHEMA,\n\t\t\t\t\tchk.rdb$constraint_name AS CONSTRAINT_NAME,\n\t\t\t\t\ttrig.rdb$trigger_source AS CHECK_CLAUSULE,\n\t\t\t\t    trig.rdb$description AS DESCRIPTION\n\t\t\t\tFROM rdb$check_constraints chk\n\t\t\t\t    INNER JOIN rdb$triggers trig ON chk.rdb$trigger_name = trig.rdb$trigger_name\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\t/* CONSTRAINT_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* CONSTRAINT_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* CONSTRAINT_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.Append(\"chk.rdb$constraint_name = @p0\");\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0}\", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY CONSTRAINT_NAME\");\n\n\t\treturn sql;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbChecksByTable.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Text;\nusing System.Globalization;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbChecksByTable : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS CONSTRAINT_CATALOG,\n\t\t\t\t\tnull AS CONSTRAINT_SCHEMA,\n\t\t\t\t\tchktb.rdb$constraint_name AS CONSTRAINT_NAME,\n\t\t\t\t\tchktb.rdb$relation_name AS TABLE_NAME,\n\t\t\t\t\ttrig.rdb$trigger_source AS CHECK_CLAUSULE,\n\t\t\t\t    trig.rdb$description AS DESCRIPTION\n\t\t\t\tFROM rdb$relation_constraints chktb\n\t\t\t\t    INNER JOIN rdb$check_constraints chk ON (chktb.rdb$constraint_name = chk.rdb$constraint_name AND chktb.rdb$constraint_type = 'CHECK')\n\t\t\t\t    INNER JOIN rdb$triggers trig ON chk.rdb$trigger_name = trig.rdb$trigger_name\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* CONSTRAINT_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* CONSTRAINT_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* CONSTRAINT_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\"chktb.rdb$constraint_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY TABLE_NAME, CONSTRAINT_NAME\");\n\n\t\treturn sql;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbCollations.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Globalization;\nusing System.Data;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbCollations : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS COLLATION_CATALOG,\n\t\t\t\t\tnull AS COLLATION_SCHEMA,\n\t\t\t\t\tcoll.rdb$collation_name AS COLLATION_NAME,\n\t\t\t\t\tcs.rdb$character_set_name AS CHARACTER_SET_NAME,\n\t\t\t\t\tcoll.rdb$description AS DESCRIPTION\n\t\t\t\tFROM rdb$collations coll\n\t\t\t\t\tLEFT JOIN rdb$character_sets cs ON coll.rdb$character_set_id = cs.rdb$character_set_id\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* COLLATION_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* COLLATION_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* COLLATION_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\"coll.rdb$collation_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY CHARACTER_SET_NAME, COLLATION_NAME\");\n\n\t\treturn sql;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbColumnPrivileges.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbColumnPrivileges : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS TABLE_CATALOG,\n\t\t\t\t\tnull AS TABLE_SCHEMA,\n\t\t\t\t\trdb$relation_name AS TABLE_NAME,\n\t\t\t\t\trdb$field_name AS COLUMN_NAME,\n\t\t\t\t\trdb$user AS GRANTEE,\n\t\t\t\t\trdb$grantor AS GRANTOR,\n\t\t\t\t\trdb$privilege AS PRIVILEGE,\n\t\t\t\t\trdb$grant_option AS WITH_GRANT\n\t\t\t\tFROM rdb$user_privileges\");\n\n\t\twhere.Append(\"rdb$object_type = 0\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* TABLE_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* COLUMN_NAME */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rdb$field_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* GRANTOR */\n\t\t\tif (restrictions.Length >= 6 && restrictions[5] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rdb$grantor = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* GRANTEE */\n\t\t\tif (restrictions.Length >= 5 && restrictions[4] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rdb$user = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY TABLE_NAME\");\n\n\t\treturn sql;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbColumns.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbColumns : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.AppendFormat(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS TABLE_CATALOG,\n\t\t\t\t\tnull AS TABLE_SCHEMA,\n\t\t\t\t\trfr.rdb$relation_name AS TABLE_NAME,\n\t\t\t\t\trfr.rdb$field_name AS COLUMN_NAME,\n\t\t\t\t    null AS COLUMN_DATA_TYPE,\n\t\t\t\t    fld.rdb$field_sub_type AS COLUMN_SUB_TYPE,\n\t\t\t\t\tCAST(fld.rdb$field_length AS integer) AS COLUMN_SIZE,\n\t\t\t\t\tCAST(fld.rdb$field_precision AS integer) AS NUMERIC_PRECISION,\n\t\t\t\t\tCAST(fld.rdb$field_scale AS integer) AS NUMERIC_SCALE,\n\t\t\t\t\tCAST(fld.rdb$character_length AS integer) AS CHARACTER_MAX_LENGTH,\n\t\t\t\t\tCAST(fld.rdb$field_length AS integer) AS CHARACTER_OCTET_LENGTH,\n\t\t\t\t\trfr.rdb$field_position AS ORDINAL_POSITION,\n\t\t\t\t\tnull AS DOMAIN_CATALOG,\n\t\t\t\t\tnull AS DOMAIN_SCHEMA,\n\t\t\t\t\trfr.rdb$field_source AS DOMAIN_NAME,\n\t\t\t\t\tnull AS SYSTEM_DATA_TYPE,\n\t\t\t\t\trfr.rdb$default_source AS COLUMN_DEFAULT,\n\t\t\t\t    fld.rdb$computed_source AS COMPUTED_SOURCE,\n\t\t\t\t\tfld.rdb$dimensions AS COLUMN_ARRAY,\n\t\t\t\t\tcoalesce(fld.rdb$null_flag, rfr.rdb$null_flag) AS COLUMN_NULLABLE,\n\t\t\t\t    0 AS IS_READONLY,\n\t\t\t\t\tfld.rdb$field_type AS FIELD_TYPE,\n\t\t\t\t\tnull AS CHARACTER_SET_CATALOG,\n\t\t\t\t\tnull AS CHARACTER_SET_SCHEMA,\n\t\t\t\t\tcs.rdb$character_set_name AS CHARACTER_SET_NAME,\n\t\t\t\t\tnull AS COLLATION_CATALOG,\n\t\t\t\t\tnull AS COLLATION_SCHEMA,\n\t\t\t\t\tcoll.rdb$collation_name AS COLLATION_NAME,\n\t\t\t\t\trfr.rdb$description AS DESCRIPTION,\n\t\t\t\t\t{0} AS IDENTITY_TYPE\n\t\t\t\tFROM rdb$relation_fields rfr\n\t\t\t\t    LEFT JOIN rdb$fields fld ON rfr.rdb$field_source = fld.rdb$field_name\n\t\t\t\t    LEFT JOIN rdb$character_sets cs ON cs.rdb$character_set_id = fld.rdb$character_set_id\n\t\t\t\t    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)\",\n\t\t\tMajorVersionNumber >= 3 ? \"rfr.rdb$identity_type\" : \"null\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* TABLE_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\"rfr.rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* COLUMN_NAME */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\tif (where.Length > 0)\n\t\t\t\t{\n\t\t\t\t\twhere.Append(\" AND \");\n\t\t\t\t}\n\n\t\t\t\twhere.AppendFormat(\"rfr.rdb$field_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY TABLE_NAME, ORDINAL_POSITION\");\n\n\t\treturn sql;\n\t}\n\n\tprotected override void ProcessResult(DataTable schema)\n\t{\n\t\tschema.BeginLoadData();\n\t\tschema.Columns.Add(\"IS_NULLABLE\", typeof(bool));\n\t\tschema.Columns.Add(\"IS_ARRAY\", typeof(bool));\n\t\tschema.Columns.Add(\"IS_IDENTITY\", typeof(bool));\n\n\t\tforeach (DataRow row in schema.Rows)\n\t\t{\n\t\t\tvar blrType = Convert.ToInt32(row[\"FIELD_TYPE\"], CultureInfo.InvariantCulture);\n\n\t\t\tvar subType = 0;\n\t\t\tif (row[\"COLUMN_SUB_TYPE\"] != DBNull.Value)\n\t\t\t{\n\t\t\t\tsubType = Convert.ToInt32(row[\"COLUMN_SUB_TYPE\"], CultureInfo.InvariantCulture);\n\t\t\t}\n\n\t\t\tvar scale = 0;\n\t\t\tif (row[\"NUMERIC_SCALE\"] != DBNull.Value)\n\t\t\t{\n\t\t\t\tscale = Convert.ToInt32(row[\"NUMERIC_SCALE\"], CultureInfo.InvariantCulture);\n\t\t\t}\n\n\t\t\trow[\"IS_NULLABLE\"] = (row[\"COLUMN_NULLABLE\"] == DBNull.Value);\n\t\t\trow[\"IS_ARRAY\"] = (row[\"COLUMN_ARRAY\"] != DBNull.Value);\n\n\t\t\tvar dbType = (FbDbType)TypeHelper.GetDbDataTypeFromBlrType(blrType, subType, scale);\n\t\t\trow[\"COLUMN_DATA_TYPE\"] = TypeHelper.GetDataTypeName((DbDataType)dbType).ToLowerInvariant();\n\n\t\t\tif (dbType == FbDbType.Binary || dbType == FbDbType.Text)\n\t\t\t{\n\t\t\t\trow[\"COLUMN_SIZE\"] = Int32.MaxValue;\n\t\t\t}\n\n\t\t\tif (dbType == FbDbType.Char || dbType == FbDbType.VarChar)\n\t\t\t{\n\t\t\t\tif (!row.IsNull(\"CHARACTER_MAX_LENGTH\"))\n\t\t\t\t{\n\t\t\t\t\trow[\"COLUMN_SIZE\"] = row[\"CHARACTER_MAX_LENGTH\"];\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\trow[\"CHARACTER_OCTET_LENGTH\"] = 0;\n\t\t\t}\n\n\t\t\tif (row[\"NUMERIC_PRECISION\"] == DBNull.Value)\n\t\t\t{\n\t\t\t\trow[\"NUMERIC_PRECISION\"] = 0;\n\t\t\t}\n\n\t\t\tif ((dbType == FbDbType.Decimal || dbType == FbDbType.Numeric) &&\n\t\t\t\t(row[\"NUMERIC_PRECISION\"] == DBNull.Value || Convert.ToInt32(row[\"NUMERIC_PRECISION\"]) == 0))\n\t\t\t{\n\t\t\t\trow[\"NUMERIC_PRECISION\"] = row[\"COLUMN_SIZE\"];\n\t\t\t}\n\n\t\t\trow[\"NUMERIC_SCALE\"] = (-1) * scale;\n\n\t\t\tvar domainName = row[\"DOMAIN_NAME\"].ToString();\n\t\t\tif (domainName != null && domainName.StartsWith(\"RDB$\"))\n\t\t\t{\n\t\t\t\trow[\"DOMAIN_NAME\"] = null;\n\t\t\t}\n\n\t\t\trow[\"IS_IDENTITY\"] = row[\"IDENTITY_TYPE\"] != DBNull.Value;\n\t\t}\n\n\t\tschema.EndLoadData();\n\t\tschema.AcceptChanges();\n\n\t\t// Remove not more needed columns\n\t\tschema.Columns.Remove(\"COLUMN_NULLABLE\");\n\t\tschema.Columns.Remove(\"COLUMN_ARRAY\");\n\t\tschema.Columns.Remove(\"FIELD_TYPE\");\n\t\tschema.Columns.Remove(\"CHARACTER_MAX_LENGTH\");\n\t\tschema.Columns.Remove(\"IDENTITY_TYPE\");\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbDomains.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbDomains : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS DOMAIN_CATALOG,\n\t\t\t\t\tnull AS DOMAIN_SCHEMA,\n\t\t\t\t\tfld.rdb$field_name AS DOMAIN_NAME,\n\t\t\t\t\tnull AS DOMAIN_DATA_TYPE,\n\t\t\t\t\trdb$field_sub_type AS DOMAIN_SUB_TYPE,\n\t\t\t\t\tCAST(fld.rdb$field_length AS integer) AS DOMAIN_SIZE,\n\t\t\t\t\tCAST(fld.rdb$field_precision AS integer) AS NUMERIC_PRECISION,\n\t\t\t\t\tCAST(fld.rdb$field_scale  AS integer) AS NUMERIC_SCALE,\n\t\t\t\t\tCAST(fld.rdb$character_length AS integer) AS CHARACTER_MAX_LENGTH,\n\t\t\t\t\tCAST(fld.rdb$field_length AS integer) AS CHARACTER_OCTET_LENGTH,\n\t\t\t\t\tfld.rdb$null_flag AS COLUMN_NULLABLE,\n\t\t\t\t\tfld.rdb$dimensions AS COLUMN_ARRAY,\n\t\t\t\t\tfld.rdb$description AS DESCRIPTION,\n\t\t\t\t\tfld.rdb$field_type AS FIELD_TYPE,\n\t\t\t\t\tnull AS CHARACTER_SET_CATALOG,\n\t\t\t\t\tnull AS CHARACTER_SET_SCHEMA,\n\t\t\t\t\tcs.rdb$character_set_name AS CHARACTER_SET_NAME,\n\t\t\t\t\tnull AS COLLATION_CATALOG,\n\t\t\t\t\tnull AS COLLATION_SCHEMA,\n\t\t\t\t\tcoll.rdb$collation_name AS COLLATION_NAME\n\t\t\t\tFROM rdb$fields fld\n\t\t\t\t\tLEFT JOIN rdb$character_sets cs ON cs.rdb$character_set_id = fld.rdb$character_set_id\n\t\t\t\t\tLEFT JOIN rdb$collations coll ON (coll.rdb$collation_id = fld.rdb$collation_id AND coll.rdb$character_set_id = fld.rdb$character_set_id)\");\n\n\t\twhere.Append(\"rdb$field_name NOT STARTING WITH 'RDB$'\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* DOMAIN_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* DOMAIN_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* DOMAIN_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rdb$field_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY DOMAIN_NAME\");\n\n\t\treturn sql;\n\t}\n\n\tprotected override void ProcessResult(DataTable schema)\n\t{\n\t\tschema.BeginLoadData();\n\t\tschema.Columns.Add(\"IS_NULLABLE\", typeof(bool));\n\t\tschema.Columns.Add(\"IS_ARRAY\", typeof(bool));\n\n\t\tforeach (DataRow row in schema.Rows)\n\t\t{\n\t\t\tvar blrType = Convert.ToInt32(row[\"FIELD_TYPE\"], CultureInfo.InvariantCulture);\n\n\t\t\tvar subType = 0;\n\t\t\tif (row[\"DOMAIN_SUB_TYPE\"] != DBNull.Value)\n\t\t\t{\n\t\t\t\tsubType = Convert.ToInt32(row[\"DOMAIN_SUB_TYPE\"], CultureInfo.InvariantCulture);\n\t\t\t}\n\n\t\t\tvar scale = 0;\n\t\t\tif (row[\"NUMERIC_SCALE\"] != DBNull.Value)\n\t\t\t{\n\t\t\t\tscale = Convert.ToInt32(row[\"NUMERIC_SCALE\"], CultureInfo.InvariantCulture);\n\t\t\t}\n\n\t\t\trow[\"IS_NULLABLE\"] = (row[\"COLUMN_NULLABLE\"] == DBNull.Value);\n\t\t\trow[\"IS_ARRAY\"] = (row[\"COLUMN_ARRAY\"] != DBNull.Value);\n\n\t\t\tvar dbType = (FbDbType)TypeHelper.GetDbDataTypeFromBlrType(blrType, subType, scale);\n\t\t\trow[\"DOMAIN_DATA_TYPE\"] = TypeHelper.GetDataTypeName((DbDataType)dbType).ToLowerInvariant();\n\n\t\t\tif (dbType == FbDbType.Char || dbType == FbDbType.VarChar)\n\t\t\t{\n\t\t\t\trow[\"DOMAIN_SIZE\"] = row[\"CHARACTER_MAX_LENGTH\"];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\trow[\"CHARACTER_OCTET_LENGTH\"] = 0;\n\t\t\t}\n\n\t\t\tif (dbType == FbDbType.Binary || dbType == FbDbType.Text)\n\t\t\t{\n\t\t\t\trow[\"DOMAIN_SIZE\"] = Int32.MaxValue;\n\t\t\t}\n\n\t\t\tif (row[\"NUMERIC_PRECISION\"] == DBNull.Value)\n\t\t\t{\n\t\t\t\trow[\"NUMERIC_PRECISION\"] = 0;\n\t\t\t}\n\n\t\t\tif ((dbType == FbDbType.Decimal || dbType == FbDbType.Numeric) &&\n\t\t\t\t(row[\"NUMERIC_PRECISION\"] == DBNull.Value || Convert.ToInt32(row[\"NUMERIC_PRECISION\"]) == 0))\n\t\t\t{\n\t\t\t\trow[\"NUMERIC_PRECISION\"] = row[\"DOMAIN_SIZE\"];\n\t\t\t}\n\n\t\t\trow[\"NUMERIC_SCALE\"] = (-1) * scale;\n\t\t}\n\n\t\tschema.EndLoadData();\n\t\tschema.AcceptChanges();\n\n\t\t// Remove not more needed columns\n\t\tschema.Columns.Remove(\"COLUMN_NULLABLE\");\n\t\tschema.Columns.Remove(\"COLUMN_ARRAY\");\n\t\tschema.Columns.Remove(\"FIELD_TYPE\");\n\t\tschema.Columns.Remove(\"CHARACTER_MAX_LENGTH\");\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbForeignKeyColumns.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbForeignKeyColumns : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS CONSTRAINT_CATALOG,\n\t\t\t\t\tnull AS CONSTRAINT_SCHEMA,\n\t\t\t\t\tco.rdb$constraint_name AS CONSTRAINT_NAME,\n\t\t\t\t\tnull AS TABLE_CATALOG,\n\t\t\t\t\tnull AS TABLE_SCHEMA,\n\t\t\t\t\tco.rdb$relation_name AS TABLE_NAME,\n\t\t\t\t\tcoidxseg.rdb$field_name AS COLUMN_NAME,\n\t\t\t\t\tnull as REFERENCED_TABLE_CATALOG,\n\t\t\t\t\tnull as REFERENCED_TABLE_SCHEMA,\n\t\t\t\t\trefidx.rdb$relation_name as REFERENCED_TABLE_NAME,\n\t\t\t\t\trefidxseg.rdb$field_name AS REFERENCED_COLUMN_NAME,\n\t\t\t\t\tcoidxseg.rdb$field_position as ORDINAL_POSITION\n\t\t\t\tFROM rdb$relation_constraints co\n\t\t\t\t\tINNER JOIN rdb$ref_constraints ref ON co.rdb$constraint_name = ref.rdb$constraint_name\n\t\t\t\t\tINNER JOIN rdb$indices tempidx ON co.rdb$index_name = tempidx.rdb$index_name\n\t\t\t\t\tINNER JOIN rdb$index_segments coidxseg ON co.rdb$index_name = coidxseg.rdb$index_name\n\t\t\t\t\tINNER JOIN rdb$indices refidx ON refidx.rdb$index_name = tempidx.rdb$foreign_key\n\t\t\t\t\tINNER JOIN rdb$index_segments refidxseg ON refidxseg.rdb$index_name = refidx.rdb$index_name AND refidxseg.rdb$field_position = coidxseg.rdb$field_position\");\n\n\t\twhere.Append(\"co.rdb$constraint_type = 'FOREIGN KEY'\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* TABLE_CATALOG\t*/\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND co.rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* CONSTRAINT_NAME */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND co.rdb$constraint_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* COLUMN_NAME */\n\t\t\tif (restrictions.Length >= 5 && restrictions[4] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND coidxseg.rdb$field_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY CONSTRAINT_NAME, ORDINAL_POSITION\");\n\n\t\treturn sql;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbForeignKeys.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbForeignKeys : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS CONSTRAINT_CATALOG,\n\t\t\t\t\tnull AS CONSTRAINT_SCHEMA,\n\t\t\t\t\tco.rdb$constraint_name AS CONSTRAINT_NAME,\n\t\t\t\t\tnull AS TABLE_CATALOG,\n\t                null AS TABLE_SCHEMA,\n\t\t\t\t\tco.rdb$relation_name AS TABLE_NAME,\n\t\t\t\t\tnull as REFERENCED_TABLE_CATALOG,\n\t\t\t\t\tnull as REFERENCED_TABLE_SCHEMA,\n\t\t\t\t\trefidx.rdb$relation_name as REFERENCED_TABLE_NAME,\n\t\t\t\t\tco.rdb$deferrable AS IS_DEFERRABLE,\n\t\t\t\t\tco.rdb$initially_deferred AS INITIALLY_DEFERRED,\n\t\t\t\t\tref.rdb$match_option AS MATCH_OPTION,\n\t\t\t\t\tref.rdb$update_rule AS UPDATE_RULE,\n\t\t\t\t\tref.rdb$delete_rule AS DELETE_RULE,\n\t\t\t\t\tco.rdb$index_name as INDEX_NAME\n\t\t\t\tFROM rdb$relation_constraints co\n\t                INNER JOIN rdb$ref_constraints ref ON co.rdb$constraint_name = ref.rdb$constraint_name\n\t\t\t\t\tINNER JOIN rdb$indices tempidx ON co.rdb$index_name = tempidx.rdb$index_name\n\t\t\t\t\tINNER JOIN rdb$indices refidx ON refidx.rdb$index_name = tempidx.rdb$foreign_key\");\n\n\t\twhere.Append(\"co.rdb$constraint_type = 'FOREIGN KEY'\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* CONSTRAINT_CATALOG\t*/\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* CONSTRAINT_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND co.rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* CONSTRAINT_NAME */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rel.rdb$constraint_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY TABLE_NAME, CONSTRAINT_NAME\");\n\n\t\treturn sql;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbFunctionArguments.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbFunctionArguments : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.AppendFormat(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS FUNCTION_CATALOG,\n\t\t\t\t\tnull AS FUNCTION_SCHEMA,\n\t\t\t\t\tfa.rdb$function_name AS FUNCTION_NAME,\n\t\t\t\t\tfa.rdb$argument_name AS ARGUMENT_NAME,\n\t\t\t\t\tnull AS PARAMETER_DATA_TYPE,\n\t\t\t\t\tfld.rdb$field_sub_type AS PARAMETER_SUB_TYPE,\n\t\t\t\t\tfa.rdb$argument_position AS ORDINAL_POSITION,\n\t\t\t\t\tCAST(fld.rdb$field_length AS integer) AS PARAMETER_SIZE,\n\t\t\t\t\tCAST(fld.rdb$field_precision AS integer) AS NUMERIC_PRECISION,\n\t\t\t\t\tCAST(fld.rdb$field_scale AS integer) AS NUMERIC_SCALE,\n\t\t\t\t\tCAST(fld.rdb$character_length AS integer) AS CHARACTER_MAX_LENGTH,\n\t\t\t\t\tCAST(fld.rdb$field_length AS integer) AS CHARACTER_OCTET_LENGTH,\n\t\t\t\t\tcoalesce(fld.rdb$null_flag, fa.rdb$null_flag) AS COLUMN_NULLABLE,\n\t\t\t\t\tnull AS CHARACTER_SET_CATALOG,\n\t\t\t\t\tnull AS CHARACTER_SET_SCHEMA,\n\t\t\t\t\tcs.rdb$character_set_name AS CHARACTER_SET_NAME,\n\t\t\t\t\tnull AS COLLATION_CATALOG,\n\t\t\t\t\tnull AS COLLATION_SCHEMA,\n\t\t\t\t\tcoll.rdb$collation_name AS COLLATION_NAME,\n\t\t\t\t\tnull AS COLLATION_CATALOG,\n\t\t\t\t\tnull AS COLLATION_SCHEMA,\n\t\t\t\t\tfa.rdb$description AS DESCRIPTION,\n\t\t\t\t\tfld.rdb$field_type AS FIELD_TYPE,\n\t\t\t\t\t{0} AS PACKAGE_NAME\n\t\t\t\tFROM rdb$function_arguments fa\n\t\t\t\t\tLEFT JOIN rdb$fields fld ON fa.rdb$field_source = fld.rdb$field_name\n\t\t\t\t\tLEFT JOIN rdb$character_sets cs ON cs.rdb$character_set_id = fld.rdb$character_set_id\n\t\t\t\t\tLEFT JOIN rdb$collations coll ON (coll.rdb$collation_id = fld.rdb$collation_id AND coll.rdb$character_set_id = fld.rdb$character_set_id)\",\n\t\t\tMajorVersionNumber >= 3 ? \"fa.rdb$package_name\" : \"null\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* FUNCTION_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* FUNCTION_SCHEMA\t*/\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* FUNCTION_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\"fa.rdb$function_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* PARAMETER_NAME */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\tif (where.Length > 0)\n\t\t\t\t{\n\t\t\t\t\twhere.Append(\" AND \");\n\t\t\t\t}\n\n\t\t\t\twhere.AppendFormat(\"fa.rdb$argument_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY PACKAGE_NAME, FUNCTION_NAME, ORDINAL_POSITION\");\n\n\t\treturn sql;\n\t}\n\n\tprotected override void ProcessResult(DataTable schema)\n\t{\n\t\tschema.BeginLoadData();\n\t\tschema.Columns.Add(\"IS_NULLABLE\", typeof(bool));\n\n\t\tforeach (DataRow row in schema.Rows)\n\t\t{\n\t\t\tvar blrType = Convert.ToInt32(row[\"FIELD_TYPE\"], CultureInfo.InvariantCulture);\n\n\t\t\tvar subType = 0;\n\t\t\tif (row[\"PARAMETER_SUB_TYPE\"] != DBNull.Value)\n\t\t\t{\n\t\t\t\tsubType = Convert.ToInt32(row[\"PARAMETER_SUB_TYPE\"], CultureInfo.InvariantCulture);\n\t\t\t}\n\n\t\t\tvar scale = 0;\n\t\t\tif (row[\"NUMERIC_SCALE\"] != DBNull.Value)\n\t\t\t{\n\t\t\t\tscale = Convert.ToInt32(row[\"NUMERIC_SCALE\"], CultureInfo.InvariantCulture);\n\t\t\t}\n\n\t\t\trow[\"IS_NULLABLE\"] = (row[\"COLUMN_NULLABLE\"] == DBNull.Value);\n\n\t\t\tvar dbType = (FbDbType)TypeHelper.GetDbDataTypeFromBlrType(blrType, subType, scale);\n\t\t\trow[\"PARAMETER_DATA_TYPE\"] = TypeHelper.GetDataTypeName((DbDataType)dbType).ToLowerInvariant();\n\n\t\t\tif (dbType == FbDbType.Char || dbType == FbDbType.VarChar)\n\t\t\t{\n\t\t\t\trow[\"PARAMETER_SIZE\"] = row[\"CHARACTER_MAX_LENGTH\"];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\trow[\"CHARACTER_OCTET_LENGTH\"] = 0;\n\t\t\t}\n\n\t\t\tif (dbType == FbDbType.Binary || dbType == FbDbType.Text)\n\t\t\t{\n\t\t\t\trow[\"PARAMETER_SIZE\"] = Int32.MaxValue;\n\t\t\t}\n\n\t\t\tif (row[\"NUMERIC_PRECISION\"] == DBNull.Value)\n\t\t\t{\n\t\t\t\trow[\"NUMERIC_PRECISION\"] = 0;\n\t\t\t}\n\n\t\t\tif ((dbType == FbDbType.Decimal || dbType == FbDbType.Numeric) &&\n\t\t\t\t(row[\"NUMERIC_PRECISION\"] == DBNull.Value || Convert.ToInt32(row[\"NUMERIC_PRECISION\"]) == 0))\n\t\t\t{\n\t\t\t\trow[\"NUMERIC_PRECISION\"] = row[\"PARAMETER_SIZE\"];\n\t\t\t}\n\n\t\t\trow[\"NUMERIC_SCALE\"] = (-1) * scale;\n\t\t}\n\n\t\tschema.EndLoadData();\n\t\tschema.AcceptChanges();\n\n\t\t// Remove not more needed columns\n\t\tschema.Columns.Remove(\"COLUMN_NULLABLE\");\n\t\tschema.Columns.Remove(\"FIELD_TYPE\");\n\t\tschema.Columns.Remove(\"CHARACTER_MAX_LENGTH\");\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbFunctionPrivileges.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbFunctionPrivileges : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS FUNCTION_CATALOG,\n\t\t\t\t\tnull AS FUNCTION_SCHEMA,\n\t\t\t\t\trdb$relation_name AS FUNCTION_NAME,\n\t\t\t\t\trdb$user AS GRANTEE,\n\t\t\t\t\trdb$grantor AS GRANTOR,\n\t\t\t\t\trdb$privilege AS PRIVILEGE,\n\t\t\t\t\trdb$grant_option AS WITH_GRANT\n\t\t\t\tFROM rdb$user_privileges\");\n\n\t\twhere.Append(\"rdb$object_type = 15\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* FUNCTION_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* FUNCTION_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* FUNCTION_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* GRANTOR */\n\t\t\tif (restrictions.Length >= 5 && restrictions[4] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rdb$grantor = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* GRANTEE */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rdb$user = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY FUNCTION_NAME\");\n\n\t\treturn sql;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbFunctions.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbFunctions : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.AppendFormat(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS FUNCTION_CATALOG,\n\t\t\t\t\tnull AS FUNCTION_SCHEMA,\n\t\t\t\t\trdb$function_name AS FUNCTION_NAME,\n\t\t\t\t\trdb$system_flag AS IS_SYSTEM_FUNCTION,\n\t\t\t\t\trdb$function_type AS FUNCTION_TYPE,\n\t\t\t\t\trdb$query_name AS QUERY_NAME,\n\t\t\t\t\trdb$module_name AS FUNCTION_MODULE_NAME,\n\t\t\t\t\trdb$entrypoint AS FUNCTION_ENTRY_POINT,\n\t\t\t\t\trdb$return_argument AS RETURN_ARGUMENT,\n\t\t\t\t\trdb$description AS DESCRIPTION,\n\t\t\t\t\t{0} AS PACKAGE_NAME\n\t\t\t\tFROM rdb$functions\",\n\t\t\tMajorVersionNumber >= 3 ? \"rdb$package_name\" : \"null\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* FUNCTION_CATALOG\t*/\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* FUNCTION_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* FUNCTION_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\"rdb$function_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* IS_SYSTEM_FUNCTION */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\tif (where.Length > 0)\n\t\t\t\t{\n\t\t\t\t\twhere.Append(\" AND \");\n\t\t\t\t}\n\n\t\t\t\twhere.AppendFormat(\"rdb$system_flag = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY PACKAGE_NAME, FUNCTION_NAME\");\n\n\t\treturn sql;\n\t}\n\n\tprotected override void ProcessResult(DataTable schema)\n\t{\n\t\tschema.BeginLoadData();\n\n\t\tforeach (DataRow row in schema.Rows)\n\t\t{\n\t\t\tif (row[\"IS_SYSTEM_FUNCTION\"] == DBNull.Value ||\n\t\t\t\tConvert.ToInt32(row[\"IS_SYSTEM_FUNCTION\"], CultureInfo.InvariantCulture) == 0)\n\t\t\t{\n\t\t\t\trow[\"IS_SYSTEM_FUNCTION\"] = false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\trow[\"IS_SYSTEM_FUNCTION\"] = true;\n\t\t\t}\n\t\t}\n\n\t\tschema.EndLoadData();\n\t\tschema.AcceptChanges();\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbGenerators.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbGenerators : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS GENERATOR_CATALOG,\n\t\t\t\t\tnull AS GENERATOR_SCHEMA,\n\t\t\t\t\trdb$generator_name AS GENERATOR_NAME,\n\t\t\t\t\trdb$system_flag AS IS_SYSTEM_GENERATOR,\n\t\t\t\t\trdb$generator_id AS GENERATOR_ID\n\t\t\t\tFROM rdb$generators\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* GENERATOR_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* GENERATOR_SCHEMA\t*/\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* GENERATOR_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\"rdb$generator_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* IS_SYSTEM_GENERATOR\t*/\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\tif (where.Length > 0)\n\t\t\t\t{\n\t\t\t\t\twhere.Append(\" AND \");\n\t\t\t\t}\n\n\t\t\t\twhere.AppendFormat(\"rdb$system_flag = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY GENERATOR_NAME\");\n\n\t\treturn sql;\n\t}\n\n\tprotected override void ProcessResult(DataTable schema)\n\t{\n\t\tschema.BeginLoadData();\n\n\t\tforeach (DataRow row in schema.Rows)\n\t\t{\n\t\t\tif (row[\"IS_SYSTEM_GENERATOR\"] == DBNull.Value ||\n\t\t\t\tConvert.ToInt32(row[\"IS_SYSTEM_GENERATOR\"], CultureInfo.InvariantCulture) == 0)\n\t\t\t{\n\t\t\t\trow[\"IS_SYSTEM_GENERATOR\"] = false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\trow[\"IS_SYSTEM_GENERATOR\"] = true;\n\t\t\t}\n\t\t}\n\n\t\tschema.EndLoadData();\n\t\tschema.AcceptChanges();\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbIndexColumns.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbIndexColumns : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS CONSTRAINT_CATALOG,\n\t\t\t\t\tnull AS CONSTRAINT_SCHEMA,\n\t\t\t\t\tidx.rdb$index_name AS CONSTRAINT_NAME,\n\t\t\t\t\tnull AS TABLE_CATALOG,\n\t\t\t\t\tnull AS TABLE_SCHEMA,\n\t\t\t\t\tidx.rdb$relation_name AS TABLE_NAME,\n\t\t\t\t\tseg.rdb$field_name AS COLUMN_NAME,\n\t\t\t\t\tseg.rdb$field_position AS ORDINAL_POSITION,\n\t\t\t\t\tidx.rdb$index_name AS INDEX_NAME\n\t\t\t\tFROM rdb$indices idx\n\t\t\t\t\tLEFT JOIN rdb$index_segments seg ON idx.rdb$index_name = seg.rdb$index_name\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* TABLE_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_SCHEMA\t*/\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\"idx.rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* INDEX_NAME */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\tif (where.Length > 0)\n\t\t\t\t{\n\t\t\t\t\twhere.Append(\" AND \");\n\t\t\t\t}\n\n\t\t\t\twhere.AppendFormat(\"idx.rdb$index_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* COLUMN_NAME */\n\t\t\tif (restrictions.Length >= 5 && restrictions[4] != null)\n\t\t\t{\n\t\t\t\tif (where.Length > 0)\n\t\t\t\t{\n\t\t\t\t\twhere.Append(\" AND \");\n\t\t\t\t}\n\n\t\t\t\twhere.AppendFormat(\"seg.rdb$field_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY TABLE_NAME, INDEX_NAME, ORDINAL_POSITION\");\n\n\t\treturn sql;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbIndexes.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbIndexes : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS TABLE_CATALOG,\n\t\t\t\t\tnull AS TABLE_SCHEMA,\n\t\t\t\t\tidx.rdb$relation_name AS TABLE_NAME,\n\t\t\t\t\tidx.rdb$index_name AS INDEX_NAME,\n\t\t\t\t\tidx.rdb$index_inactive AS IS_INACTIVE,\n\t\t\t\t\tidx.rdb$unique_flag AS IS_UNIQUE,\n\t\t\t\t    (SELECT COUNT(*) FROM rdb$relation_constraints rel\n\t\t\t\t    WHERE rel.rdb$constraint_type = 'PRIMARY KEY' AND rel.rdb$index_name = idx.rdb$index_name AND rel.rdb$relation_name = idx.rdb$relation_name) as PRIMARY_KEY,\n\t\t\t\t\t(SELECT COUNT(*) FROM rdb$relation_constraints rel\n\t\t\t\t\tWHERE rel.rdb$constraint_type = 'UNIQUE' AND rel.rdb$index_name = idx.rdb$index_name AND rel.rdb$relation_name = idx.rdb$relation_name) as UNIQUE_KEY,\n\t\t\t\t\tidx.rdb$system_flag AS IS_SYSTEM_INDEX,\n\t\t\t\t\tidx.rdb$index_type AS INDEX_TYPE,\n\t\t\t\t\tidx.rdb$description AS DESCRIPTION\n\t\t\t\tFROM rdb$indices idx\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* TABLE_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_SCHEMA\t*/\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\"idx.rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* INDEX_NAME */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\tif (where.Length > 0)\n\t\t\t\t{\n\t\t\t\t\twhere.Append(\" AND \");\n\t\t\t\t}\n\n\t\t\t\twhere.AppendFormat(\"idx.rdb$index_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY TABLE_NAME, INDEX_NAME\");\n\n\t\treturn sql;\n\t}\n\n\tprotected override void ProcessResult(DataTable schema)\n\t{\n\t\tschema.BeginLoadData();\n\t\tschema.Columns.Add(\"IS_PRIMARY\", typeof(bool));\n\n\t\tforeach (DataRow row in schema.Rows)\n\t\t{\n\t\t\trow[\"IS_UNIQUE\"] = !(row[\"IS_UNIQUE\"] == DBNull.Value || Convert.ToInt32(row[\"IS_UNIQUE\"], CultureInfo.InvariantCulture) == 0);\n\n\t\t\trow[\"IS_PRIMARY\"] = !(row[\"PRIMARY_KEY\"] == DBNull.Value || Convert.ToInt32(row[\"PRIMARY_KEY\"], CultureInfo.InvariantCulture) == 0);\n\n\t\t\trow[\"IS_INACTIVE\"] = !(row[\"IS_INACTIVE\"] == DBNull.Value || Convert.ToInt32(row[\"IS_INACTIVE\"], CultureInfo.InvariantCulture) == 0);\n\n\t\t\trow[\"IS_SYSTEM_INDEX\"] = !(row[\"IS_SYSTEM_INDEX\"] == DBNull.Value || Convert.ToInt32(row[\"IS_SYSTEM_INDEX\"], CultureInfo.InvariantCulture) == 0);\n\t\t}\n\n\t\tschema.EndLoadData();\n\t\tschema.AcceptChanges();\n\n\t\tschema.Columns.Remove(\"PRIMARY_KEY\");\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbMetaData.xml",
    "content": "<?xml version=\"1.0\" standalone=\"yes\"?>\n<NewDataSet>\n\t<xs:schema id=\"NewDataSet\" xmlns=\"\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n\t\t<xs:element name=\"NewDataSet\" msdata:IsDataSet=\"true\">\n\t\t\t<xs:complexType>\n\t\t\t\t<xs:choice minOccurs=\"0\" maxOccurs=\"unbounded\">\n\t\t\t\t\t<xs:element name=\"MetaDataCollections\" msdata:MinimumCapacity=\"9\">\n\t\t\t\t\t\t<xs:complexType>\n\t\t\t\t\t\t\t<xs:sequence>\n\t\t\t\t\t\t\t\t<xs:element name=\"CollectionName\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"NumberOfRestrictions\" type=\"xs:int\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"NumberOfIdentifierParts\" type=\"xs:int\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"PopulationMechanism\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"PopulationString\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"MinimumVersion\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"MaximumVersion\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t</xs:sequence>\n\t\t\t\t\t\t</xs:complexType>\n\t\t\t\t\t</xs:element>\n\t\t\t\t\t<xs:element name=\"Restrictions\" msdata:MinimumCapacity=\"3\">\n\t\t\t\t\t\t<xs:complexType>\n\t\t\t\t\t\t\t<xs:sequence>\n\t\t\t\t\t\t\t\t<xs:element name=\"CollectionName\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"RestrictionName\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"RestrictionDefault\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"RestrictionNumber\" type=\"xs:int\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"MinimumVersion\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"MaximumVersion\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t</xs:sequence>\n\t\t\t\t\t\t</xs:complexType>\n\t\t\t\t\t</xs:element>\n\t\t\t\t\t<xs:element name=\"DataSourceInformation\" msdata:MinimumCapacity=\"18\">\n\t\t\t\t\t\t<xs:complexType>\n\t\t\t\t\t\t\t<xs:sequence>\n\t\t\t\t\t\t\t\t<xs:element name=\"CompositeIdentifierSeparatorPattern\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"DataSourceProductName\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"DataSourceProductVersion\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"DataSourceProductVersionNormalized\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"GroupByBehavior\" msdata:DataType=\"System.Data.Common.GroupByBehavior, System.Data, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"IdentifierPattern\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"IdentifierCase\" msdata:DataType=\"System.Data.Common.IdentifierCase, System.Data, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"OrderByColumnsInSelect\" type=\"xs:boolean\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"ParameterMarkerFormat\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"ParameterMarkerPattern\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"ParameterNameMaxLength\" type=\"xs:int\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"ParameterNamePattern\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"QuotedIdentifierPattern\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"QuotedIdentifierCase\" msdata:DataType=\"System.Data.Common.IdentifierCase, System.Data, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"StatementSeparatorPattern\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"StringLiteralPattern\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"SupportedJoinOperators\" msdata:DataType=\"System.Data.Common.SupportedJoinOperators, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t</xs:sequence>\n\t\t\t\t\t\t</xs:complexType>\n\t\t\t\t\t</xs:element>\n\t\t\t\t\t<xs:element name=\"DataTypes\" msdata:MinimumCapacity=\"18\">\n\t\t\t\t\t\t<xs:complexType>\n\t\t\t\t\t\t\t<xs:sequence>\n\t\t\t\t\t\t\t\t<xs:element name=\"TypeName\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"ProviderDbType\" type=\"xs:int\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"ColumnSize\" type=\"xs:long\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"CreateFormat\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"CreateParameters\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"DataType\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"IsAutoIncrementable\" type=\"xs:boolean\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"IsBestMatch\" type=\"xs:boolean\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"IsCaseSensitive\" type=\"xs:boolean\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"IsFixedLength\" type=\"xs:boolean\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"IsFixedPrecisionScale\" type=\"xs:boolean\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"IsLong\" type=\"xs:boolean\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"IsNullable\" type=\"xs:boolean\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"IsSearchable\" type=\"xs:boolean\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"IsSearchableWithLike\" type=\"xs:boolean\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"IsUnsigned\" type=\"xs:boolean\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"MaximumScale\" type=\"xs:short\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"MinimumScale\" type=\"xs:short\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"IsConcurrencyType\" type=\"xs:boolean\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"MaximumVersion\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"MinimumVersion\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"IsLiteralSupported\" type=\"xs:boolean\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"LiteralPrefix\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"LiteralSuffix\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"DbType\" type=\"xs:int\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t</xs:sequence>\n\t\t\t\t\t\t</xs:complexType>\n\t\t\t\t\t</xs:element>\n\t\t\t\t\t<xs:element name=\"ReservedWords\" msdata:MinimumCapacity=\"3\">\n\t\t\t\t\t\t<xs:complexType>\n\t\t\t\t\t\t\t<xs:sequence>\n\t\t\t\t\t\t\t\t<xs:element name=\"ReservedWord\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"MaximumVersion\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t\t<xs:element name=\"MinimumVersion\" type=\"xs:string\" minOccurs=\"0\" />\n\t\t\t\t\t\t\t</xs:sequence>\n\t\t\t\t\t\t</xs:complexType>\n\t\t\t\t\t</xs:element>\n\t\t\t\t</xs:choice>\n\t\t\t</xs:complexType>\n\t\t</xs:element>\n\t</xs:schema>\n\t<MetaDataCollections>\n\t\t<CollectionName>CharacterSets</CollectionName>\n\t\t<NumberOfRestrictions>3</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>CheckConstraints</CollectionName>\n\t\t<NumberOfRestrictions>3</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>CheckConstraintsByTable</CollectionName>\n\t\t<NumberOfRestrictions>3</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>Collations</CollectionName>\n\t\t<NumberOfRestrictions>3</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>ColumnPrivileges</CollectionName>\n\t\t<NumberOfRestrictions>6</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>Columns</CollectionName>\n\t\t<NumberOfRestrictions>4</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>DataSourceInformation</CollectionName>\n\t\t<NumberOfRestrictions>0</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>DataTable</PopulationMechanism>\n\t\t<PopulationString>DataSourceInformation</PopulationString>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>DataTypes</CollectionName>\n\t\t<NumberOfRestrictions>0</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>DataTable</PopulationMechanism>\n\t\t<PopulationString>DataTypes</PopulationString>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>Domains</CollectionName>\n\t\t<NumberOfRestrictions>3</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>ForeignKeyColumns</CollectionName>\n\t\t<NumberOfRestrictions>5</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>ForeignKeys</CollectionName>\n\t\t<NumberOfRestrictions>4</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>FunctionArguments</CollectionName>\n\t\t<NumberOfRestrictions>4</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>FunctionPrivileges</CollectionName>\n\t\t<NumberOfRestrictions>5</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>Functions</CollectionName>\n\t\t<NumberOfRestrictions>4</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>Generators</CollectionName>\n\t\t<NumberOfRestrictions>4</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>IndexColumns</CollectionName>\n\t\t<NumberOfRestrictions>5</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>Indexes</CollectionName>\n\t\t<NumberOfRestrictions>4</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>MetaDataCollections</CollectionName>\n\t\t<NumberOfRestrictions>0</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>DataTable</PopulationMechanism>\n\t\t<PopulationString>MetaDataCollections</PopulationString>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>PrimaryKeys</CollectionName>\n\t\t<NumberOfRestrictions>3</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>ProcedureParameters</CollectionName>\n\t\t<NumberOfRestrictions>4</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>ProcedurePrivileges</CollectionName>\n\t\t<NumberOfRestrictions>5</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>Procedures</CollectionName>\n\t\t<NumberOfRestrictions>3</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>ReservedWords</CollectionName>\n\t\t<NumberOfRestrictions>0</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>DataTable</PopulationMechanism>\n\t\t<PopulationString>ReservedWords</PopulationString>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>Restrictions</CollectionName>\n\t\t<NumberOfRestrictions>0</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>DataTable</PopulationMechanism>\n\t\t<PopulationString>Restrictions</PopulationString>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>Roles</CollectionName>\n\t\t<NumberOfRestrictions>1</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>Tables</CollectionName>\n\t\t<NumberOfRestrictions>4</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>TableConstraints</CollectionName>\n\t\t<NumberOfRestrictions>7</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>TablePrivileges</CollectionName>\n\t\t<NumberOfRestrictions>5</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>Triggers</CollectionName>\n\t\t<NumberOfRestrictions>4</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>UniqueKeys</CollectionName>\n\t\t<NumberOfRestrictions>3</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>ViewColumns</CollectionName>\n\t\t<NumberOfRestrictions>4</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>ViewPrivileges</CollectionName>\n\t\t<NumberOfRestrictions>5</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<MetaDataCollections>\n\t\t<CollectionName>Views</CollectionName>\n\t\t<NumberOfRestrictions>3</NumberOfRestrictions>\n\t\t<NumberOfIdentifierParts>0</NumberOfIdentifierParts>\n\t\t<PopulationMechanism>PrepareCollection</PopulationMechanism>\n\t</MetaDataCollections>\n\t<Restrictions>\n\t\t<CollectionName>CharacterSets</CollectionName>\n\t\t<RestrictionName>Catalog</RestrictionName>\n\t\t<RestrictionDefault>table_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>CharacterSets</CollectionName>\n\t\t<RestrictionName>Schema</RestrictionName>\n\t\t<RestrictionDefault>table_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>CharacterSets</CollectionName>\n\t\t<RestrictionName>Name</RestrictionName>\n\t\t<RestrictionDefault>character_set_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>CheckConstraints</CollectionName>\n\t\t<RestrictionName>Catalog</RestrictionName>\n\t\t<RestrictionDefault>constraint_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>CheckConstraints</CollectionName>\n\t\t<RestrictionName>Schema</RestrictionName>\n\t\t<RestrictionDefault>constraint_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>CheckConstraints</CollectionName>\n\t\t<RestrictionName>Name</RestrictionName>\n\t\t<RestrictionDefault>constraint_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>CheckConstraintsByTable</CollectionName>\n\t\t<RestrictionName>Catalog</RestrictionName>\n\t\t<RestrictionDefault>constraint_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>CheckConstraintsByTable</CollectionName>\n\t\t<RestrictionName>Schema</RestrictionName>\n\t\t<RestrictionDefault>constraint_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>CheckConstraintsByTable</CollectionName>\n\t\t<RestrictionName>Name</RestrictionName>\n\t\t<RestrictionDefault>constraint_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Collations</CollectionName>\n\t\t<RestrictionName>Catalog</RestrictionName>\n\t\t<RestrictionDefault>collation_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Collations</CollectionName>\n\t\t<RestrictionName>Schema</RestrictionName>\n\t\t<RestrictionDefault>collation_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Collations</CollectionName>\n\t\t<RestrictionName>Name</RestrictionName>\n\t\t<RestrictionDefault>collation_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ColumnPrivileges</CollectionName>\n\t\t<RestrictionName>TableCatalog</RestrictionName>\n\t\t<RestrictionDefault>table_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ColumnPrivileges</CollectionName>\n\t\t<RestrictionName>TableSchema</RestrictionName>\n\t\t<RestrictionDefault>table_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ColumnPrivileges</CollectionName>\n\t\t<RestrictionName>TableName</RestrictionName>\n\t\t<RestrictionDefault>table_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ColumnPrivileges</CollectionName>\n\t\t<RestrictionName>ColumnName</RestrictionName>\n\t\t<RestrictionDefault>column_name</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ColumnPrivileges</CollectionName>\n\t\t<RestrictionName>Grantor</RestrictionName>\n\t\t<RestrictionDefault>grantor</RestrictionDefault>\n\t\t<RestrictionNumber>5</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ColumnPrivileges</CollectionName>\n\t\t<RestrictionName>Grantee</RestrictionName>\n\t\t<RestrictionDefault>grantee</RestrictionDefault>\n\t\t<RestrictionNumber>6</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Columns</CollectionName>\n\t\t<RestrictionName>TableCatalog</RestrictionName>\n\t\t<RestrictionDefault>table_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Columns</CollectionName>\n\t\t<RestrictionName>TableSchema</RestrictionName>\n\t\t<RestrictionDefault>table_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Columns</CollectionName>\n\t\t<RestrictionName>TableName</RestrictionName>\n\t\t<RestrictionDefault>table_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Columns</CollectionName>\n\t\t<RestrictionName>ColumnName</RestrictionName>\n\t\t<RestrictionDefault>column_name</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Domains</CollectionName>\n\t\t<RestrictionName>Catalog</RestrictionName>\n\t\t<RestrictionDefault>domain_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Domains</CollectionName>\n\t\t<RestrictionName>Schema</RestrictionName>\n\t\t<RestrictionDefault>domain_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Domains</CollectionName>\n\t\t<RestrictionName>Name</RestrictionName>\n\t\t<RestrictionDefault>domain_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ForeignKeys</CollectionName>\n\t\t<RestrictionName>ConstraintCatalog</RestrictionName>\n\t\t<RestrictionDefault>constraint_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ForeignKeys</CollectionName>\n\t\t<RestrictionName>ConstraintSchema</RestrictionName>\n\t\t<RestrictionDefault>constraint_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ForeignKeys</CollectionName>\n\t\t<RestrictionName>TableName</RestrictionName>\n\t\t<RestrictionDefault>table_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ForeignKeys</CollectionName>\n\t\t<RestrictionName>ConstraintName</RestrictionName>\n\t\t<RestrictionDefault>constraint_name</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ForeignKeyColumns</CollectionName>\n\t\t<RestrictionName>ConstraintCatalog</RestrictionName>\n\t\t<RestrictionDefault>constraint_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ForeignKeyColumns</CollectionName>\n\t\t<RestrictionName>ConstraintSchema</RestrictionName>\n\t\t<RestrictionDefault>constraint_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ForeignKeyColumns</CollectionName>\n\t\t<RestrictionName>TableName</RestrictionName>\n\t\t<RestrictionDefault>table_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ForeignKeyColumns</CollectionName>\n\t\t<RestrictionName>ConstraintName</RestrictionName>\n\t\t<RestrictionDefault>constraint_name</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ForeignKeyColumns</CollectionName>\n\t\t<RestrictionName>ColumnName</RestrictionName>\n\t\t<RestrictionDefault>column_name</RestrictionDefault>\n\t\t<RestrictionNumber>5</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>FunctionArguments</CollectionName>\n\t\t<RestrictionName>FunctionCatalog</RestrictionName>\n\t\t<RestrictionDefault>function_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>FunctionArguments</CollectionName>\n\t\t<RestrictionName>FunctionSchema</RestrictionName>\n\t\t<RestrictionDefault>function_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>FunctionArguments</CollectionName>\n\t\t<RestrictionName>FunctionName</RestrictionName>\n\t\t<RestrictionDefault>function_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>FunctionArguments</CollectionName>\n\t\t<RestrictionName>Name</RestrictionName>\n\t\t<RestrictionDefault>function_argument</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>FunctionPrivileges</CollectionName>\n\t\t<RestrictionName>FunctionCatalog</RestrictionName>\n\t\t<RestrictionDefault>function_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>FunctionPrivileges</CollectionName>\n\t\t<RestrictionName>FunctionSchema</RestrictionName>\n\t\t<RestrictionDefault>function_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>FunctionPrivileges</CollectionName>\n\t\t<RestrictionName>FunctionName</RestrictionName>\n\t\t<RestrictionDefault>function_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>FunctionPrivileges</CollectionName>\n\t\t<RestrictionName>Grantor</RestrictionName>\n\t\t<RestrictionDefault>grantor</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>FunctionPrivileges</CollectionName>\n\t\t<RestrictionName>Grantee</RestrictionName>\n\t\t<RestrictionDefault>grantee</RestrictionDefault>\n\t\t<RestrictionNumber>5</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Functions</CollectionName>\n\t\t<RestrictionName>Catalog</RestrictionName>\n\t\t<RestrictionDefault>function_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Functions</CollectionName>\n\t\t<RestrictionName>Schema</RestrictionName>\n\t\t<RestrictionDefault>function_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Functions</CollectionName>\n\t\t<RestrictionName>Name</RestrictionName>\n\t\t<RestrictionDefault>function_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Functions</CollectionName>\n\t\t<RestrictionName>IsSystemFunction</RestrictionName>\n\t\t<RestrictionDefault>is_system_function</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Generators</CollectionName>\n\t\t<RestrictionName>Catalog</RestrictionName>\n\t\t<RestrictionDefault>generator_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Generators</CollectionName>\n\t\t<RestrictionName>Schema</RestrictionName>\n\t\t<RestrictionDefault>generator_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Generators</CollectionName>\n\t\t<RestrictionName>Name</RestrictionName>\n\t\t<RestrictionDefault>generator_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Generators</CollectionName>\n\t\t<RestrictionName>IsSystemGenerator</RestrictionName>\n\t\t<RestrictionDefault>is_system_generator</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>IndexColumns</CollectionName>\n\t\t<RestrictionName>TableCatalog</RestrictionName>\n\t\t<RestrictionDefault>table_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>IndexColumns</CollectionName>\n\t\t<RestrictionName>TableSchema</RestrictionName>\n\t\t<RestrictionDefault>table_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>IndexColumns</CollectionName>\n\t\t<RestrictionName>TableName</RestrictionName>\n\t\t<RestrictionDefault>table_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>IndexColumns</CollectionName>\n\t\t<RestrictionName>IndexName</RestrictionName>\n\t\t<RestrictionDefault>index_name</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>IndexColumns</CollectionName>\n\t\t<RestrictionName>ColumnName</RestrictionName>\n\t\t<RestrictionDefault>column_name</RestrictionDefault>\n\t\t<RestrictionNumber>5</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Indexes</CollectionName>\n\t\t<RestrictionName>TableCatalog</RestrictionName>\n\t\t<RestrictionDefault>table_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Indexes</CollectionName>\n\t\t<RestrictionName>TableSchema</RestrictionName>\n\t\t<RestrictionDefault>table_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Indexes</CollectionName>\n\t\t<RestrictionName>TableName</RestrictionName>\n\t\t<RestrictionDefault>table_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Indexes</CollectionName>\n\t\t<RestrictionName>IndexName</RestrictionName>\n\t\t<RestrictionDefault>index_name</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>PrimaryKeys</CollectionName>\n\t\t<RestrictionName>TableCatalog</RestrictionName>\n\t\t<RestrictionDefault>table_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>PrimaryKeys</CollectionName>\n\t\t<RestrictionName>TableSchema</RestrictionName>\n\t\t<RestrictionDefault>table_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>PrimaryKeys</CollectionName>\n\t\t<RestrictionName>TableName</RestrictionName>\n\t\t<RestrictionDefault>table_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ProcedureParameters</CollectionName>\n\t\t<RestrictionName>ProcedureCatalog</RestrictionName>\n\t\t<RestrictionDefault>procedure_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ProcedureParameters</CollectionName>\n\t\t<RestrictionName>ProcedureSchema</RestrictionName>\n\t\t<RestrictionDefault>procedure_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ProcedureParameters</CollectionName>\n\t\t<RestrictionName>ProcedureName</RestrictionName>\n\t\t<RestrictionDefault>procedure_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ProcedureParameters</CollectionName>\n\t\t<RestrictionName>Name</RestrictionName>\n\t\t<RestrictionDefault>procedure_parameter</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ProcedurePrivileges</CollectionName>\n\t\t<RestrictionName>ProcedureCatalog</RestrictionName>\n\t\t<RestrictionDefault>procedure_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ProcedurePrivileges</CollectionName>\n\t\t<RestrictionName>ProcedureSchema</RestrictionName>\n\t\t<RestrictionDefault>procedure_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ProcedurePrivileges</CollectionName>\n\t\t<RestrictionName>ProcedureName</RestrictionName>\n\t\t<RestrictionDefault>procedure_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ProcedurePrivileges</CollectionName>\n\t\t<RestrictionName>Grantor</RestrictionName>\n\t\t<RestrictionDefault>grantor</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ProcedurePrivileges</CollectionName>\n\t\t<RestrictionName>Grantee</RestrictionName>\n\t\t<RestrictionDefault>grantee</RestrictionDefault>\n\t\t<RestrictionNumber>5</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Procedures</CollectionName>\n\t\t<RestrictionName>ProcedureCatalog</RestrictionName>\n\t\t<RestrictionDefault>procedure_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Procedures</CollectionName>\n\t\t<RestrictionName>ProcedureSchema</RestrictionName>\n\t\t<RestrictionDefault>procedure_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Procedures</CollectionName>\n\t\t<RestrictionName>Name</RestrictionName>\n\t\t<RestrictionDefault>procedure_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Roles</CollectionName>\n\t\t<RestrictionName>Name</RestrictionName>\n\t\t<RestrictionDefault>role_name</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>TableConstraints</CollectionName>\n\t\t<RestrictionName>ConstraintCatalog</RestrictionName>\n\t\t<RestrictionDefault>constraint_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>TableConstraints</CollectionName>\n\t\t<RestrictionName>ConstraintSchema</RestrictionName>\n\t\t<RestrictionDefault>constraint_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>TableConstraints</CollectionName>\n\t\t<RestrictionName>ConstraintName</RestrictionName>\n\t\t<RestrictionDefault>constraint_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>TableConstraints</CollectionName>\n\t\t<RestrictionName>TableCatalog</RestrictionName>\n\t\t<RestrictionDefault>table_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>TableConstraints</CollectionName>\n\t\t<RestrictionName>TableSchema</RestrictionName>\n\t\t<RestrictionDefault>table_schema</RestrictionDefault>\n\t\t<RestrictionNumber>5</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>TableConstraints</CollectionName>\n\t\t<RestrictionName>TableName</RestrictionName>\n\t\t<RestrictionDefault>table_name</RestrictionDefault>\n\t\t<RestrictionNumber>6</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>TableConstraints</CollectionName>\n\t\t<RestrictionName>ConstraintType</RestrictionName>\n\t\t<RestrictionDefault>constraint_type</RestrictionDefault>\n\t\t<RestrictionNumber>7</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>TablePrivileges</CollectionName>\n\t\t<RestrictionName>TableCatalog</RestrictionName>\n\t\t<RestrictionDefault>table_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>TablePrivileges</CollectionName>\n\t\t<RestrictionName>TableSchema</RestrictionName>\n\t\t<RestrictionDefault>table_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>TablePrivileges</CollectionName>\n\t\t<RestrictionName>TableName</RestrictionName>\n\t\t<RestrictionDefault>table_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>TablePrivileges</CollectionName>\n\t\t<RestrictionName>Grantor</RestrictionName>\n\t\t<RestrictionDefault>grantor</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>TablePrivileges</CollectionName>\n\t\t<RestrictionName>Grantee</RestrictionName>\n\t\t<RestrictionDefault>grantee</RestrictionDefault>\n\t\t<RestrictionNumber>5</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Tables</CollectionName>\n\t\t<RestrictionName>Catalog</RestrictionName>\n\t\t<RestrictionDefault>table_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Tables</CollectionName>\n\t\t<RestrictionName>Schema</RestrictionName>\n\t\t<RestrictionDefault>table_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Tables</CollectionName>\n\t\t<RestrictionName>Name</RestrictionName>\n\t\t<RestrictionDefault>table_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Tables</CollectionName>\n\t\t<RestrictionName>TableType</RestrictionName>\n\t\t<RestrictionDefault>table_type</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Triggers</CollectionName>\n\t\t<RestrictionName>TableCatalog</RestrictionName>\n\t\t<RestrictionDefault>table_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Triggers</CollectionName>\n\t\t<RestrictionName>TableSchema</RestrictionName>\n\t\t<RestrictionDefault>table_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Triggers</CollectionName>\n\t\t<RestrictionName>TableName</RestrictionName>\n\t\t<RestrictionDefault>table_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Triggers</CollectionName>\n\t\t<RestrictionName>Name</RestrictionName>\n\t\t<RestrictionDefault>trigger_name</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>UniqueKeys</CollectionName>\n\t\t<RestrictionName>TableCatalog</RestrictionName>\n\t\t<RestrictionDefault>table_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>UniqueKeys</CollectionName>\n\t\t<RestrictionName>TableSchema</RestrictionName>\n\t\t<RestrictionDefault>table_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>UniqueKeys</CollectionName>\n\t\t<RestrictionName>TableName</RestrictionName>\n\t\t<RestrictionDefault>table_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ViewColumns</CollectionName>\n\t\t<RestrictionName>ViewCatalog</RestrictionName>\n\t\t<RestrictionDefault>view_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ViewColumns</CollectionName>\n\t\t<RestrictionName>ViewSchema</RestrictionName>\n\t\t<RestrictionDefault>view_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ViewColumns</CollectionName>\n\t\t<RestrictionName>ViewName</RestrictionName>\n\t\t<RestrictionDefault>view_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ViewColumns</CollectionName>\n\t\t<RestrictionName>ColumnName</RestrictionName>\n\t\t<RestrictionDefault>column_name</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ViewPrivileges</CollectionName>\n\t\t<RestrictionName>ViewCatalog</RestrictionName>\n\t\t<RestrictionDefault>view_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ViewPrivileges</CollectionName>\n\t\t<RestrictionName>ViewSchema</RestrictionName>\n\t\t<RestrictionDefault>view_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ViewPrivileges</CollectionName>\n\t\t<RestrictionName>ViewName</RestrictionName>\n\t\t<RestrictionDefault>view_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ViewPrivileges</CollectionName>\n\t\t<RestrictionName>Grantor</RestrictionName>\n\t\t<RestrictionDefault>grantor</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>ViewPrivileges</CollectionName>\n\t\t<RestrictionName>Grantee</RestrictionName>\n\t\t<RestrictionDefault>grantee</RestrictionDefault>\n\t\t<RestrictionNumber>5</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>namespace Framework.Traces</CollectionName>\n\t\t<RestrictionName>ViewCatalog</RestrictionName>\n\t\t<RestrictionDefault>view_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>namespace Framework.Traces</CollectionName>\n\t\t<RestrictionName>ViewSchema</RestrictionName>\n\t\t<RestrictionDefault>view_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>namespace Framework.Traces</CollectionName>\n\t\t<RestrictionName>ViewName</RestrictionName>\n\t\t<RestrictionDefault>view_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>namespace Framework.Traces</CollectionName>\n\t\t<RestrictionName>Name</RestrictionName>\n\t\t<RestrictionDefault>column_name</RestrictionDefault>\n\t\t<RestrictionNumber>4</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Views</CollectionName>\n\t\t<RestrictionName>Catalog</RestrictionName>\n\t\t<RestrictionDefault>view_catalog</RestrictionDefault>\n\t\t<RestrictionNumber>1</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Views</CollectionName>\n\t\t<RestrictionName>Schema</RestrictionName>\n\t\t<RestrictionDefault>view_schema</RestrictionDefault>\n\t\t<RestrictionNumber>2</RestrictionNumber>\n\t</Restrictions>\n\t<Restrictions>\n\t\t<CollectionName>Views</CollectionName>\n\t\t<RestrictionName>Name</RestrictionName>\n\t\t<RestrictionDefault>view_name</RestrictionDefault>\n\t\t<RestrictionNumber>3</RestrictionNumber>\n\t</Restrictions>\n\t<DataSourceInformation>\n\t\t<CompositeIdentifierSeparatorPattern>.</CompositeIdentifierSeparatorPattern>\n\t\t<DataSourceProductName>Firebird</DataSourceProductName>\n\t\t<GroupByBehavior>2</GroupByBehavior>\n\t\t<IdentifierPattern>(^\\[\\p{Lo}\\p{Lu}\\p{Ll}_@#][\\p{Lo}\\p{Lu}\\p{Ll}\\p{Nd}@$#_]*$)|(^\\[[^\\]\\0]|\\]\\]+\\]$)|(^\\\"[^\\\"\\0]|\\\"\\\"+\\\"$)</IdentifierPattern>\n\t\t<IdentifierCase>1</IdentifierCase>\n\t\t<OrderByColumnsInSelect>false</OrderByColumnsInSelect>\n\t\t<ParameterMarkerFormat>{0}</ParameterMarkerFormat>\n\t\t<ParameterMarkerPattern>@[\\p{Lo}\\p{Lu}\\p{Ll}\\p{Lm}_@#][\\p{Lo}\\p{Lu}\\p{Ll}\\p{Lm}\\p{Nd}\\uff3f_@#\\$]*(?=\\s+|$)</ParameterMarkerPattern>\n\t\t<ParameterNameMaxLength>128</ParameterNameMaxLength>\n\t\t<ParameterNamePattern>^[\\p{Lo}\\p{Lu}\\p{Ll}\\p{Lm}_@#][\\p{Lo}\\p{Lu}\\p{Ll}\\p{Lm}\\p{Nd}\\uff3f_@#\\$]*(?=\\s+|$)</ParameterNamePattern>\n\t\t<QuotedIdentifierPattern>\"^(([^\"]|\"\")*)$\"</QuotedIdentifierPattern>\n\t\t<QuotedIdentifierCase>2</QuotedIdentifierCase>\n\t\t<StatementSeparatorPattern>;</StatementSeparatorPattern>\n\t\t<StringLiteralPattern>'(([^']|'')*)'</StringLiteralPattern>\n\t\t<SupportedJoinOperators>15</SupportedJoinOperators>\n\t</DataSourceInformation>\n\t<DataTypes>\n\t\t<TypeName>array</TypeName>\n\t\t<ProviderDbType>0</ProviderDbType>\n\t\t<ColumnSize>2147483647</ColumnSize>\n\t\t<CreateFormat />\n\t\t<CreateParameters />\n\t\t<DataType>System.Array</DataType>\n\t\t<IsAutoIncrementable>false</IsAutoIncrementable>\n\t\t<IsBestMatch>false</IsBestMatch>\n\t\t<IsCaseSensitive>false</IsCaseSensitive>\n\t\t<IsFixedLength>false</IsFixedLength>\n\t\t<IsFixedPrecisionScale>false</IsFixedPrecisionScale>\n\t\t<IsLong>true</IsLong>\n\t\t<IsNullable>true</IsNullable>\n\t\t<IsSearchable>false</IsSearchable>\n\t\t<IsSearchableWithLike>false</IsSearchableWithLike>\n\t\t<IsUnsigned>false</IsUnsigned>\n\t\t<MaximumScale>0</MaximumScale>\n\t\t<MinimumScale>0</MinimumScale>\n\t\t<IsConcurrencyType>false</IsConcurrencyType>\n\t\t<IsLiteralSupported>false</IsLiteralSupported>\n\t\t<DbType>13</DbType>\n\t</DataTypes>\n\t<DataTypes>\n\t\t<TypeName>bigint</TypeName>\n\t\t<ProviderDbType>1</ProviderDbType>\n\t\t<ColumnSize>8</ColumnSize>\n\t\t<CreateFormat />\n\t\t<CreateParameters />\n\t\t<DataType>System.Int64</DataType>\n\t\t<IsAutoIncrementable>false</IsAutoIncrementable>\n\t\t<IsBestMatch>false</IsBestMatch>\n\t\t<IsCaseSensitive>false</IsCaseSensitive>\n\t\t<IsFixedLength>false</IsFixedLength>\n\t\t<IsFixedPrecisionScale>false</IsFixedPrecisionScale>\n\t\t<IsLong>false</IsLong>\n\t\t<IsNullable>true</IsNullable>\n\t\t<IsSearchable>true</IsSearchable>\n\t\t<IsSearchableWithLike>true</IsSearchableWithLike>\n\t\t<IsUnsigned>false</IsUnsigned>\n\t\t<MaximumScale>0</MaximumScale>\n\t\t<MinimumScale>0</MinimumScale>\n\t\t<IsConcurrencyType>false</IsConcurrencyType>\n\t\t<IsLiteralSupported>false</IsLiteralSupported>\n\t\t<DbType>12</DbType>\n\t</DataTypes>\n\t<DataTypes>\n\t\t<TypeName>blob</TypeName>\n\t\t<ProviderDbType>2</ProviderDbType>\n\t\t<ColumnSize>2147483647</ColumnSize>\n\t\t<CreateFormat />\n\t\t<CreateParameters />\n\t\t<DataType>System.Byte[]</DataType>\n\t\t<IsAutoIncrementable>false</IsAutoIncrementable>\n\t\t<IsBestMatch>false</IsBestMatch>\n\t\t<IsCaseSensitive>false</IsCaseSensitive>\n\t\t<IsFixedLength>false</IsFixedLength>\n\t\t<IsFixedPrecisionScale>false</IsFixedPrecisionScale>\n\t\t<IsLong>true</IsLong>\n\t\t<IsNullable>true</IsNullable>\n\t\t<IsSearchable>false</IsSearchable>\n\t\t<IsSearchableWithLike>false</IsSearchableWithLike>\n\t\t<IsUnsigned>false</IsUnsigned>\n\t\t<MaximumScale>0</MaximumScale>\n\t\t<MinimumScale>0</MinimumScale>\n\t\t<IsConcurrencyType>false</IsConcurrencyType>\n\t\t<IsLiteralSupported>true</IsLiteralSupported>\n\t\t<LiteralPrefix>x'</LiteralPrefix>\n\t\t<LiteralSuffix>'</LiteralSuffix>\n\t\t<DbType>1</DbType>\n\t</DataTypes>\n\t<DataTypes>\n\t\t<TypeName>char</TypeName>\n\t\t<ProviderDbType>4</ProviderDbType>\n\t\t<ColumnSize>32767</ColumnSize>\n\t\t<CreateFormat />\n\t\t<CreateParameters>length</CreateParameters>\n\t\t<DataType>System.String</DataType>\n\t\t<IsAutoIncrementable>false</IsAutoIncrementable>\n\t\t<IsBestMatch>false</IsBestMatch>\n\t\t<IsCaseSensitive>true</IsCaseSensitive>\n\t\t<IsFixedLength>false</IsFixedLength>\n\t\t<IsFixedPrecisionScale>false</IsFixedPrecisionScale>\n\t\t<IsLong>false</IsLong>\n\t\t<IsNullable>true</IsNullable>\n\t\t<IsSearchable>true</IsSearchable>\n\t\t<IsSearchableWithLike>true</IsSearchableWithLike>\n\t\t<IsUnsigned>false</IsUnsigned>\n\t\t<MaximumScale>0</MaximumScale>\n\t\t<MinimumScale>0</MinimumScale>\n\t\t<IsConcurrencyType>false</IsConcurrencyType>\n\t\t<IsLiteralSupported>true</IsLiteralSupported>\n\t\t<LiteralPrefix>'</LiteralPrefix>\n\t\t<LiteralSuffix>'</LiteralSuffix>\n\t\t<DbType>23</DbType>\n\t</DataTypes>\n\t<DataTypes>\n\t\t<TypeName>date</TypeName>\n\t\t<ProviderDbType>5</ProviderDbType>\n\t\t<ColumnSize>4</ColumnSize>\n\t\t<CreateFormat />\n\t\t<CreateParameters />\n\t\t<DataType>System.DateTime</DataType>\n\t\t<IsAutoIncrementable>false</IsAutoIncrementable>\n\t\t<IsBestMatch>false</IsBestMatch>\n\t\t<IsCaseSensitive>false</IsCaseSensitive>\n\t\t<IsFixedLength>false</IsFixedLength>\n\t\t<IsFixedPrecisionScale>false</IsFixedPrecisionScale>\n\t\t<IsLong>false</IsLong>\n\t\t<IsNullable>true</IsNullable>\n\t\t<IsSearchable>true</IsSearchable>\n\t\t<IsSearchableWithLike>true</IsSearchableWithLike>\n\t\t<IsUnsigned>false</IsUnsigned>\n\t\t<MaximumScale>0</MaximumScale>\n\t\t<MinimumScale>0</MinimumScale>\n\t\t<IsConcurrencyType>false</IsConcurrencyType>\n\t\t<IsLiteralSupported>true</IsLiteralSupported>\n\t\t<LiteralPrefix>'</LiteralPrefix>\n\t\t<LiteralSuffix>'</LiteralSuffix>\n\t\t<DbType>5</DbType>\n\t</DataTypes>\n\t<DataTypes>\n\t\t<TypeName>decimal</TypeName>\n\t\t<ProviderDbType>6</ProviderDbType>\n\t\t<ColumnSize>0</ColumnSize>\n\t\t<CreateFormat />\n\t\t<CreateParameters>precision,scale</CreateParameters>\n\t\t<DataType>System.Decimal</DataType>\n\t\t<IsAutoIncrementable>false</IsAutoIncrementable>\n\t\t<IsBestMatch>false</IsBestMatch>\n\t\t<IsCaseSensitive>false</IsCaseSensitive>\n\t\t<IsFixedLength>false</IsFixedLength>\n\t\t<IsFixedPrecisionScale>false</IsFixedPrecisionScale>\n\t\t<IsLong>false</IsLong>\n\t\t<IsNullable>true</IsNullable>\n\t\t<IsSearchable>true</IsSearchable>\n\t\t<IsSearchableWithLike>true</IsSearchableWithLike>\n\t\t<IsUnsigned>false</IsUnsigned>\n\t\t<MaximumScale>18</MaximumScale>\n\t\t<MinimumScale>0</MinimumScale>\n\t\t<IsConcurrencyType>false</IsConcurrencyType>\n\t\t<DbType>7</DbType>\n\t</DataTypes>\n\t<DataTypes>\n\t\t<TypeName>double precision</TypeName>\n\t\t<ProviderDbType>7</ProviderDbType>\n\t\t<ColumnSize>8</ColumnSize>\n\t\t<CreateFormat />\n\t\t<CreateParameters />\n\t\t<DataType>System.Double</DataType>\n\t\t<IsAutoIncrementable>false</IsAutoIncrementable>\n\t\t<IsBestMatch>false</IsBestMatch>\n\t\t<IsCaseSensitive>false</IsCaseSensitive>\n\t\t<IsFixedLength>false</IsFixedLength>\n\t\t<IsFixedPrecisionScale>false</IsFixedPrecisionScale>\n\t\t<IsLong>false</IsLong>\n\t\t<IsNullable>true</IsNullable>\n\t\t<IsSearchable>true</IsSearchable>\n\t\t<IsSearchableWithLike>true</IsSearchableWithLike>\n\t\t<IsUnsigned>false</IsUnsigned>\n\t\t<MaximumScale>0</MaximumScale>\n\t\t<MinimumScale>0</MinimumScale>\n\t\t<IsConcurrencyType>false</IsConcurrencyType>\n\t\t<DbType>8</DbType>\n\t</DataTypes>\n\t<DataTypes>\n\t\t<TypeName>float</TypeName>\n\t\t<ProviderDbType>8</ProviderDbType>\n\t\t<ColumnSize>4</ColumnSize>\n\t\t<CreateFormat />\n\t\t<CreateParameters />\n\t\t<DataType>System.Single</DataType>\n\t\t<IsAutoIncrementable>false</IsAutoIncrementable>\n\t\t<IsBestMatch>false</IsBestMatch>\n\t\t<IsCaseSensitive>false</IsCaseSensitive>\n\t\t<IsFixedLength>false</IsFixedLength>\n\t\t<IsFixedPrecisionScale>false</IsFixedPrecisionScale>\n\t\t<IsLong>false</IsLong>\n\t\t<IsNullable>true</IsNullable>\n\t\t<IsSearchable>true</IsSearchable>\n\t\t<IsSearchableWithLike>true</IsSearchableWithLike>\n\t\t<IsUnsigned>false</IsUnsigned>\n\t\t<MaximumScale>0</MaximumScale>\n\t\t<MinimumScale>0</MinimumScale>\n\t\t<IsConcurrencyType>false</IsConcurrencyType>\n\t\t<DbType>15</DbType>\n\t</DataTypes>\n\t<DataTypes>\n\t\t<TypeName>integer</TypeName>\n\t\t<ProviderDbType>10</ProviderDbType>\n\t\t<ColumnSize>4</ColumnSize>\n\t\t<CreateFormat />\n\t\t<CreateParameters />\n\t\t<DataType>System.Int32</DataType>\n\t\t<IsAutoIncrementable>false</IsAutoIncrementable>\n\t\t<IsBestMatch>false</IsBestMatch>\n\t\t<IsCaseSensitive>false</IsCaseSensitive>\n\t\t<IsFixedLength>false</IsFixedLength>\n\t\t<IsFixedPrecisionScale>false</IsFixedPrecisionScale>\n\t\t<IsLong>false</IsLong>\n\t\t<IsNullable>true</IsNullable>\n\t\t<IsSearchable>true</IsSearchable>\n\t\t<IsSearchableWithLike>true</IsSearchableWithLike>\n\t\t<IsUnsigned>false</IsUnsigned>\n\t\t<MaximumScale>0</MaximumScale>\n\t\t<MinimumScale>0</MinimumScale>\n\t\t<IsConcurrencyType>false</IsConcurrencyType>\n\t\t<DbType>11</DbType>\n\t</DataTypes>\n\t<DataTypes>\n\t\t<TypeName>numeric</TypeName>\n\t\t<ProviderDbType>11</ProviderDbType>\n\t\t<ColumnSize>0</ColumnSize>\n\t\t<CreateFormat />\n\t\t<CreateParameters>precision,scale</CreateParameters>\n\t\t<DataType>System.Decimal</DataType>\n\t\t<IsAutoIncrementable>false</IsAutoIncrementable>\n\t\t<IsBestMatch>false</IsBestMatch>\n\t\t<IsCaseSensitive>false</IsCaseSensitive>\n\t\t<IsFixedLength>false</IsFixedLength>\n\t\t<IsFixedPrecisionScale>false</IsFixedPrecisionScale>\n\t\t<IsLong>false</IsLong>\n\t\t<IsNullable>true</IsNullable>\n\t\t<IsSearchable>true</IsSearchable>\n\t\t<IsSearchableWithLike>true</IsSearchableWithLike>\n\t\t<IsUnsigned>false</IsUnsigned>\n\t\t<MaximumScale>18</MaximumScale>\n\t\t<MinimumScale>0</MinimumScale>\n\t\t<IsConcurrencyType>false</IsConcurrencyType>\n\t\t<DbType>7</DbType>\n\t</DataTypes>\n\t<DataTypes>\n\t\t<TypeName>smallint</TypeName>\n\t\t<ProviderDbType>12</ProviderDbType>\n\t\t<ColumnSize>2</ColumnSize>\n\t\t<CreateFormat />\n\t\t<CreateParameters />\n\t\t<DataType>System.Int16</DataType>\n\t\t<IsAutoIncrementable>false</IsAutoIncrementable>\n\t\t<IsBestMatch>false</IsBestMatch>\n\t\t<IsCaseSensitive>false</IsCaseSensitive>\n\t\t<IsFixedLength>false</IsFixedLength>\n\t\t<IsFixedPrecisionScale>false</IsFixedPrecisionScale>\n\t\t<IsLong>false</IsLong>\n\t\t<IsNullable>true</IsNullable>\n\t\t<IsSearchable>true</IsSearchable>\n\t\t<IsSearchableWithLike>true</IsSearchableWithLike>\n\t\t<IsUnsigned>false</IsUnsigned>\n\t\t<MaximumScale>0</MaximumScale>\n\t\t<MinimumScale>0</MinimumScale>\n\t\t<IsConcurrencyType>false</IsConcurrencyType>\n\t\t<DbType>10</DbType>\n\t</DataTypes>\n\t<DataTypes>\n\t\t<TypeName>blob sub_type 1</TypeName>\n\t\t<ProviderDbType>13</ProviderDbType>\n\t\t<ColumnSize>2147483647</ColumnSize>\n\t\t<CreateFormat />\n\t\t<CreateParameters />\n\t\t<DataType>System.String</DataType>\n\t\t<IsAutoIncrementable>false</IsAutoIncrementable>\n\t\t<IsBestMatch>false</IsBestMatch>\n\t\t<IsCaseSensitive>true</IsCaseSensitive>\n\t\t<IsFixedLength>false</IsFixedLength>\n\t\t<IsFixedPrecisionScale>false</IsFixedPrecisionScale>\n\t\t<IsLong>true</IsLong>\n\t\t<IsNullable>true</IsNullable>\n\t\t<IsSearchable>true</IsSearchable>\n\t\t<IsSearchableWithLike>true</IsSearchableWithLike>\n\t\t<IsUnsigned>false</IsUnsigned>\n\t\t<MaximumScale>0</MaximumScale>\n\t\t<MinimumScale>0</MinimumScale>\n\t\t<IsConcurrencyType>false</IsConcurrencyType>\n\t\t<IsLiteralSupported>true</IsLiteralSupported>\n\t\t<LiteralPrefix>'</LiteralPrefix>\n\t\t<LiteralSuffix>'</LiteralSuffix>\n\t\t<DbType>16</DbType>\n\t</DataTypes>\n\t<DataTypes>\n\t\t<TypeName>time</TypeName>\n\t\t<ProviderDbType>14</ProviderDbType>\n\t\t<ColumnSize>4</ColumnSize>\n\t\t<CreateFormat />\n\t\t<CreateParameters />\n\t\t<DataType>System.TimeSpan</DataType>\n\t\t<IsAutoIncrementable>false</IsAutoIncrementable>\n\t\t<IsBestMatch>false</IsBestMatch>\n\t\t<IsCaseSensitive>false</IsCaseSensitive>\n\t\t<IsFixedLength>false</IsFixedLength>\n\t\t<IsFixedPrecisionScale>false</IsFixedPrecisionScale>\n\t\t<IsLong>false</IsLong>\n\t\t<IsNullable>true</IsNullable>\n\t\t<IsSearchable>true</IsSearchable>\n\t\t<IsSearchableWithLike>true</IsSearchableWithLike>\n\t\t<IsUnsigned>false</IsUnsigned>\n\t\t<MaximumScale>0</MaximumScale>\n\t\t<MinimumScale>0</MinimumScale>\n\t\t<IsConcurrencyType>false</IsConcurrencyType>\n\t\t<IsLiteralSupported>true</IsLiteralSupported>\n\t\t<LiteralPrefix>'</LiteralPrefix>\n\t\t<LiteralSuffix>'</LiteralSuffix>\n\t\t<DbType>17</DbType>\n\t</DataTypes>\n\t<DataTypes>\n\t\t<TypeName>timestamp</TypeName>\n\t\t<ProviderDbType>15</ProviderDbType>\n\t\t<ColumnSize>8</ColumnSize>\n\t\t<CreateFormat />\n\t\t<CreateParameters />\n\t\t<DataType>System.DateTime</DataType>\n\t\t<IsAutoIncrementable>false</IsAutoIncrementable>\n\t\t<IsBestMatch>false</IsBestMatch>\n\t\t<IsCaseSensitive>false</IsCaseSensitive>\n\t\t<IsFixedLength>false</IsFixedLength>\n\t\t<IsFixedPrecisionScale>false</IsFixedPrecisionScale>\n\t\t<IsLong>false</IsLong>\n\t\t<IsNullable>true</IsNullable>\n\t\t<IsSearchable>true</IsSearchable>\n\t\t<IsSearchableWithLike>true</IsSearchableWithLike>\n\t\t<IsUnsigned>false</IsUnsigned>\n\t\t<MaximumScale>0</MaximumScale>\n\t\t<MinimumScale>0</MinimumScale>\n\t\t<IsConcurrencyType>false</IsConcurrencyType>\n\t\t<IsLiteralSupported>true</IsLiteralSupported>\n\t\t<LiteralPrefix>'</LiteralPrefix>\n\t\t<LiteralSuffix>'</LiteralSuffix>\n\t\t<DbType>6</DbType>\n\t</DataTypes>\n\t<DataTypes>\n\t\t<TypeName>varchar</TypeName>\n\t\t<ProviderDbType>16</ProviderDbType>\n\t\t<ColumnSize>32767</ColumnSize>\n\t\t<CreateFormat />\n\t\t<CreateParameters>length</CreateParameters>\n\t\t<DataType>System.String</DataType>\n\t\t<IsAutoIncrementable>false</IsAutoIncrementable>\n\t\t<IsBestMatch>false</IsBestMatch>\n\t\t<IsCaseSensitive>true</IsCaseSensitive>\n\t\t<IsFixedLength>false</IsFixedLength>\n\t\t<IsFixedPrecisionScale>false</IsFixedPrecisionScale>\n\t\t<IsLong>false</IsLong>\n\t\t<IsNullable>true</IsNullable>\n\t\t<IsSearchable>true</IsSearchable>\n\t\t<IsSearchableWithLike>true</IsSearchableWithLike>\n\t\t<IsUnsigned>false</IsUnsigned>\n\t\t<MaximumScale>0</MaximumScale>\n\t\t<MinimumScale>0</MinimumScale>\n\t\t<IsConcurrencyType>false</IsConcurrencyType>\n\t\t<IsLiteralSupported>true</IsLiteralSupported>\n\t\t<LiteralPrefix>'</LiteralPrefix>\n\t\t<LiteralSuffix>'</LiteralSuffix>\n\t\t<DbType>16</DbType>\n\t</DataTypes>\n\t<ReservedWords>\n\t\t<ReservedWord>ACTIVE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ADD</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ADMIN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>AFTER</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ALL</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ALTER</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>AND</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ANY</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>AS</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ASC</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ASCENDING</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>AT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>AUTO</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>AVG</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>BEFORE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>BEGIN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>BETWEEN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>BIGINT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>BINARY</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>BIT_LENGTH</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>BLOB</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>BOOLEAN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>BOTH</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>BY</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CASE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CAST</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CHAR</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CHARACTER</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CHARACTER_LENGTH</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CHAR_LENGTH</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CHECK</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CLOSE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>COLLATE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>COLUMN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>COMMENT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>COMMIT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>COMMITTED</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>COMPUTED</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CONDITIONAL</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CONNECT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CONSTRAINT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CONTAINING</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CORR</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>COUNT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>COVAR_POP</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>COVAR_SAMP</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CREATE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CROSS</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CSTRING</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CURRENT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CURRENT_CONNECTION</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CURRENT_DATE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CURRENT_ROLE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CURRENT_TIME</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CURRENT_TIMESTAMP</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CURRENT_TRANSACTION</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CURRENT_USER</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>CURSOR</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DATABASE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DATE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DAY</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DEBUG</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DEC</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DECFLOAT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DECIMAL</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DECLARE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DEFAULT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DELETE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DELETING</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DESC</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DESCENDING</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DETERMINISTIC</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DISCONNECT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DISTINCT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DO</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DOMAIN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DOUBLE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>DROP</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ELSE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>END</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ENTRY_POINT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ESCAPE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>EXCEPTION</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>EXECUTE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>EXISTS</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>EXIT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>EXTERNAL</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>EXTRACT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>FALSE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>FETCH</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>FILE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>FILTER</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>FLOAT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>FOR</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>FOREIGN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>FROM</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>FULL</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>FUNCTION</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>GDSCODE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>GENERATOR</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>GEN_ID</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>GLOBAL</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>GRANT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>GROUP</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>HAVING</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>HOUR</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>IF</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>IN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>INACTIVE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>INDEX</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>INNER</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>INPUT_TYPE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>INSENSITIVE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>INSERT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>INSERTING</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>INT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>INT128</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>INTEGER</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>INTO</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>IS</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ISOLATION</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>JOIN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>KEY</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>LATERAL</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>LEADING</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>LEFT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>LENGTH</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>LEVEL</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>LIKE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>LOCAL</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>LOCALTIME</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>LOCALTIMESTAMP</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>LONG</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>LOWER</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>MANUAL</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>MAX</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>MAXIMUM_SEGMENT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>MERGE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>MESSAGE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>MIN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>MINUTE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>MODULE_NAME</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>MONTH</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>NAMES</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>NATIONAL</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>NATURAL</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>NCHAR</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>NO</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>NOT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>NULL</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>NUMERIC</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>OCTET_LENGTH</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>OF</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>OFFSET</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ON</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ONLY</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>OPEN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>OPTION</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>OR</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ORDER</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>OUTER</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>OUTPUT_TYPE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>OVER</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>OVERFLOW</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>PAGE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>PAGES</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>PAGE_SIZE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>PARAMETER</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>PASSWORD</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>PLAN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>POSITION</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>POST_EVENT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>PRECISION</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>PRIMARY</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>PRIVILEGES</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>PROCEDURE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>PROTECTED</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>PUBLICATION</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RDB$DB_KEY</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RDB$ERROR</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RDB$GET_CONTEXT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RDB$GET_TRANSACTION_CN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RDB$RECORD_VERSION</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RDB$ROLE_IN_USE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RDB$SET_CONTEXT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RDB$SYSTEM_PRIVILEGE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>READ</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>REAL</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RECORD_VERSION</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RECREATE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RECURSIVE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>REFERENCES</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>REGR_AVGX</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>REGR_AVGY</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>REGR_COUNT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>REGR_INTERCEPT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>REGR_R2</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>REGR_SLOPE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>REGR_SXX</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>REGR_SXY</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>REGR_SYY</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RELEASE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RESERV</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RESERVING</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RESETTING</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RETAIN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RETURN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RETURNING_VALUES</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RETURNS</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>REVOKE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>RIGHT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ROLLBACK</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ROW</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ROWS</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>ROW_COUNT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SAVEPOINT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SCHEMA</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SCROLL</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SECOND</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SEGMENT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SELECT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SENSITIVE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SET</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SHADOW</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SHARED</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SIMILAR</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SINGULAR</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SIZE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SMALLINT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SNAPSHOT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SOME</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SORT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SQLCODE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SQLSTATE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>STABILITY</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>START</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>STARTING</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>STARTS</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>STATISTICS</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>STDDEV_POP</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>STDDEV_SAMP</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SUB_TYPE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SUM</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>SUSPEND</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>TABLE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>THEN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>TIME</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>TIMESTAMP</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>TIMEZONE_HOUR</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>TIMEZONE_MINUTE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>TO</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>TRAILING</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>TRANSACTION</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>TRIGGER</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>TRIM</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>TRUE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>UNBOUNDED</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>UNCOMMITTED</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>UNION</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>UNIQUE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>UNKNOWN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>UPDATE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>UPDATING</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>UPPER</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>USER</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>USING</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>VALUE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>VALUES</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>VARBINARY</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>VARCHAR</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>VARIABLE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>VARYING</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>VAR_POP</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>VAR_SAMP</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>VIEW</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>WAIT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>WHEN</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>WHERE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>WHILE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>WINDOW</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>WITH</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>WITHOUT</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>WORK</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>WRITE</ReservedWord>\n\t</ReservedWords>\n\t<ReservedWords>\n\t\t<ReservedWord>YEAR</ReservedWord>\n\t</ReservedWords>\n</NewDataSet>\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbPrimaryKeys.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbPrimaryKeys : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS TABLE_CATALOG,\n\t\t\t\t\tnull AS TABLE_SCHEMA,\n\t\t\t\t\trel.rdb$relation_name AS TABLE_NAME,\n\t\t\t\t\tseg.rdb$field_name AS COLUMN_NAME,\n\t\t\t\t\tseg.rdb$field_position AS ORDINAL_POSITION,\n\t\t\t\t\trel.rdb$constraint_name AS PK_NAME\n\t\t\t\tFROM rdb$relation_constraints rel\n\t\t\t\t\tLEFT JOIN rdb$indices idx ON rel.rdb$index_name = idx.rdb$index_name\n\t\t\t\t\tLEFT JOIN rdb$index_segments seg ON idx.rdb$index_name = seg.rdb$index_name\");\n\n\t\twhere.Append(\"rel.rdb$constraint_type = 'PRIMARY KEY'\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* TABLE_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_SCHEMA\t*/\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rel.rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY TABLE_NAME, PK_NAME, ORDINAL_POSITION\");\n\n\t\treturn sql;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbProcedureParameters.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbProcedureParameters : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.AppendFormat(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS PROCEDURE_CATALOG,\n\t\t\t\t\tnull AS PROCEDURE_SCHEMA,\n\t\t\t\t\tpp.rdb$procedure_name AS PROCEDURE_NAME,\n\t\t\t\t\tpp.rdb$parameter_name AS PARAMETER_NAME,\n\t\t\t\t\tnull AS PARAMETER_DATA_TYPE,\n\t\t\t\t\tfld.rdb$field_sub_type AS PARAMETER_SUB_TYPE,\n\t\t\t\t\tpp.rdb$parameter_number AS ORDINAL_POSITION,\n\t\t\t\t\tCAST(pp.rdb$parameter_type AS integer) AS PARAMETER_DIRECTION,\n\t\t\t\t\tCAST(fld.rdb$field_length AS integer) AS PARAMETER_SIZE,\n\t\t\t\t\tCAST(fld.rdb$field_precision AS integer) AS NUMERIC_PRECISION,\n\t\t\t\t\tCAST(fld.rdb$field_scale AS integer) AS NUMERIC_SCALE,\n\t\t\t\t\tCAST(fld.rdb$character_length AS integer) AS CHARACTER_MAX_LENGTH,\n\t\t\t\t\tCAST(fld.rdb$field_length AS integer) AS CHARACTER_OCTET_LENGTH,\n\t\t\t\t\tcoalesce(fld.rdb$null_flag, pp.rdb$null_flag) AS COLUMN_NULLABLE,\n\t\t\t\t\tnull AS CHARACTER_SET_CATALOG,\n\t\t\t\t\tnull AS CHARACTER_SET_SCHEMA,\n\t\t\t\t\tcs.rdb$character_set_name AS CHARACTER_SET_NAME,\n\t\t\t\t\tnull AS COLLATION_CATALOG,\n\t\t\t\t\tnull AS COLLATION_SCHEMA,\n\t\t\t\t\tcoll.rdb$collation_name AS COLLATION_NAME,\n\t\t\t\t\tnull AS COLLATION_CATALOG,\n\t\t\t\t\tnull AS COLLATION_SCHEMA,\n\t\t\t\t\tpp.rdb$description AS DESCRIPTION,\n\t\t\t\t\tfld.rdb$field_type AS FIELD_TYPE,\n\t\t\t\t\t{0} AS PACKAGE_NAME\n\t\t\t\tFROM rdb$procedure_parameters pp\n\t\t\t\t\tLEFT JOIN rdb$fields fld ON pp.rdb$field_source = fld.rdb$field_name\n\t\t\t\t\tLEFT JOIN rdb$character_sets cs ON cs.rdb$character_set_id = fld.rdb$character_set_id\n\t\t\t\t\tLEFT JOIN rdb$collations coll ON (coll.rdb$collation_id = fld.rdb$collation_id AND coll.rdb$character_set_id = fld.rdb$character_set_id)\",\n\t\t\tMajorVersionNumber >= 3 ? \"pp.rdb$package_name\" : \"null\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* PROCEDURE_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* PROCEDURE_SCHEMA\t*/\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* PROCEDURE_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\"pp.rdb$procedure_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* PARAMETER_NAME */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\tif (where.Length > 0)\n\t\t\t\t{\n\t\t\t\t\twhere.Append(\" AND \");\n\t\t\t\t}\n\n\t\t\t\twhere.AppendFormat(\"pp.rdb$parameter_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY PACKAGE_NAME, PROCEDURE_NAME, PARAMETER_DIRECTION, ORDINAL_POSITION\");\n\n\t\treturn sql;\n\t}\n\n\tprotected override void ProcessResult(DataTable schema)\n\t{\n\t\tschema.BeginLoadData();\n\t\tschema.Columns.Add(\"IS_NULLABLE\", typeof(bool));\n\n\t\tforeach (DataRow row in schema.Rows)\n\t\t{\n\t\t\tvar blrType = Convert.ToInt32(row[\"FIELD_TYPE\"], CultureInfo.InvariantCulture);\n\n\t\t\tvar subType = 0;\n\t\t\tif (row[\"PARAMETER_SUB_TYPE\"] != DBNull.Value)\n\t\t\t{\n\t\t\t\tsubType = Convert.ToInt32(row[\"PARAMETER_SUB_TYPE\"], CultureInfo.InvariantCulture);\n\t\t\t}\n\n\t\t\tvar scale = 0;\n\t\t\tif (row[\"NUMERIC_SCALE\"] != DBNull.Value)\n\t\t\t{\n\t\t\t\tscale = Convert.ToInt32(row[\"NUMERIC_SCALE\"], CultureInfo.InvariantCulture);\n\t\t\t}\n\n\t\t\trow[\"IS_NULLABLE\"] = (row[\"COLUMN_NULLABLE\"] == DBNull.Value);\n\n\t\t\tvar dbType = (FbDbType)TypeHelper.GetDbDataTypeFromBlrType(blrType, subType, scale);\n\t\t\trow[\"PARAMETER_DATA_TYPE\"] = TypeHelper.GetDataTypeName((DbDataType)dbType).ToLowerInvariant();\n\n\t\t\tif (dbType == FbDbType.Char || dbType == FbDbType.VarChar)\n\t\t\t{\n\t\t\t\trow[\"PARAMETER_SIZE\"] = row[\"CHARACTER_MAX_LENGTH\"];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\trow[\"CHARACTER_OCTET_LENGTH\"] = 0;\n\t\t\t}\n\n\t\t\tif (dbType == FbDbType.Binary || dbType == FbDbType.Text)\n\t\t\t{\n\t\t\t\trow[\"PARAMETER_SIZE\"] = Int32.MaxValue;\n\t\t\t}\n\n\t\t\tif (row[\"NUMERIC_PRECISION\"] == DBNull.Value)\n\t\t\t{\n\t\t\t\trow[\"NUMERIC_PRECISION\"] = 0;\n\t\t\t}\n\n\t\t\tif ((dbType == FbDbType.Decimal || dbType == FbDbType.Numeric) &&\n\t\t\t\t(row[\"NUMERIC_PRECISION\"] == DBNull.Value || Convert.ToInt32(row[\"NUMERIC_PRECISION\"]) == 0))\n\t\t\t{\n\t\t\t\trow[\"NUMERIC_PRECISION\"] = row[\"PARAMETER_SIZE\"];\n\t\t\t}\n\n\t\t\trow[\"NUMERIC_SCALE\"] = (-1) * scale;\n\n\t\t\tvar direction = Convert.ToInt32(row[\"PARAMETER_DIRECTION\"], CultureInfo.InvariantCulture);\n\t\t\tswitch (direction)\n\t\t\t{\n\t\t\t\tcase 0:\n\t\t\t\t\trow[\"PARAMETER_DIRECTION\"] = ParameterDirection.Input;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 1:\n\t\t\t\t\trow[\"PARAMETER_DIRECTION\"] = ParameterDirection.Output;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tschema.EndLoadData();\n\t\tschema.AcceptChanges();\n\n\t\t// Remove not more needed columns\n\t\tschema.Columns.Remove(\"COLUMN_NULLABLE\");\n\t\tschema.Columns.Remove(\"FIELD_TYPE\");\n\t\tschema.Columns.Remove(\"CHARACTER_MAX_LENGTH\");\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbProcedurePrivileges.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbProcedurePrivileges : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS PROCEDURE_CATALOG,\n\t\t\t\t\tnull AS PROCEDURE_SCHEMA,\n\t\t\t\t\trdb$relation_name AS PROCEDURE_NAME,\n\t\t\t\t\trdb$user AS GRANTEE,\n\t\t\t\t\trdb$grantor AS GRANTOR,\n\t\t\t\t\trdb$privilege AS PRIVILEGE,\n\t\t\t\t\trdb$grant_option AS WITH_GRANT\n\t\t\t\tFROM rdb$user_privileges\");\n\n\t\twhere.Append(\"rdb$object_type = 5\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* PROCEDURE_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* PROCEDURE_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* PROCEDURE_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* GRANTOR */\n\t\t\tif (restrictions.Length >= 5 && restrictions[4] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rdb$grantor = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* GRANTEE */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rdb$user = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY PROCEDURE_NAME\");\n\n\t\treturn sql;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbProcedures.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbProcedures : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.AppendFormat(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS PROCEDURE_CATALOG,\n\t\t\t\t\tnull AS PROCEDURE_SCHEMA,\n\t\t\t\t\trdb$procedure_name AS PROCEDURE_NAME,\n\t\t\t\t\trdb$procedure_inputs AS INPUTS,\n\t\t\t\t\trdb$procedure_outputs AS OUTPUTS,\n\t\t\t\t\trdb$system_flag AS IS_SYSTEM_PROCEDURE,\n\t\t\t\t\trdb$procedure_source AS SOURCE,\n\t\t\t\t\trdb$description AS DESCRIPTION,\n\t\t\t\t\t{0} AS PACKAGE_NAME\n\t\t\t\tFROM rdb$procedures\",\n\t\t\tMajorVersionNumber >= 3 ? \"rdb$package_name\" : \"null\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* PROCEDURE_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* PROCEDURE_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* PROCEDURE_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\"rdb$procedure_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY PACKAGE_NAME, PROCEDURE_NAME\");\n\n\t\treturn sql;\n\t}\n\n\tprotected override void ProcessResult(DataTable schema)\n\t{\n\t\tschema.BeginLoadData();\n\n\t\tforeach (DataRow row in schema.Rows)\n\t\t{\n\t\t\tif (row[\"INPUTS\"] == DBNull.Value)\n\t\t\t{\n\t\t\t\trow[\"INPUTS\"] = 0;\n\t\t\t}\n\t\t\tif (row[\"OUTPUTS\"] == DBNull.Value)\n\t\t\t{\n\t\t\t\trow[\"OUTPUTS\"] = 0;\n\t\t\t}\n\t\t\tif (row[\"IS_SYSTEM_PROCEDURE\"] == DBNull.Value ||\n\t\t\t\tConvert.ToInt32(row[\"IS_SYSTEM_PROCEDURE\"], CultureInfo.InvariantCulture) == 0)\n\t\t\t{\n\t\t\t\trow[\"IS_SYSTEM_PROCEDURE\"] = false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\trow[\"IS_SYSTEM_PROCEDURE\"] = true;\n\t\t\t}\n\t\t}\n\n\t\tschema.EndLoadData();\n\t\tschema.AcceptChanges();\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbRoles.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbRoles : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\trdb$role_name AS ROLE_NAME,\n\t\t\t\t\trdb$owner_name AS OWNER_NAME\n\t\t\t\tFROM rdb$roles\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\"rdb$role_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY ROLE_NAME\");\n\n\t\treturn sql;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbSchema.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Data.Common;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\nusing FirebirdSql.Data.Services;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal abstract class FbSchema\n{\n\t#region Abstract Methods\n\n\tprotected abstract StringBuilder GetCommandText(string[] restrictions);\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic DataTable GetSchema(FbConnection connection, string collectionName, string[] restrictions)\n\t{\n\t\tvar dataTable = new DataTable(collectionName);\n\t\tvar command = BuildCommand(connection, collectionName, ParseRestrictions(restrictions));\n\t\ttry\n\t\t{\n\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t{\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tadapter.Fill(dataTable);\n\t\t\t\t}\n\t\t\t\tcatch (Exception ex)\n\t\t\t\t{\n\t\t\t\t\tthrow FbException.Create(ex);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tcommand.Dispose();\n\t\t}\n\t\tTrimStringFields(dataTable);\n\t\tProcessResult(dataTable);\n\t\treturn dataTable;\n\t}\n\tpublic async Task<DataTable> GetSchemaAsync(FbConnection connection, string collectionName, string[] restrictions, CancellationToken cancellationToken = default)\n\t{\n\t\tvar dataTable = new DataTable(collectionName);\n\t\tvar command = BuildCommand(connection, collectionName, ParseRestrictions(restrictions));\n\t\ttry\n\t\t{\n\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t{\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tadapter.Fill(dataTable);\n\t\t\t\t}\n\t\t\t\tcatch (Exception ex)\n\t\t\t\t{\n\t\t\t\t\tthrow FbException.Create(ex);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tawait command.DisposeAsync().ConfigureAwait(false);\n\t\t}\n\t\tTrimStringFields(dataTable);\n\t\tProcessResult(dataTable);\n\t\treturn dataTable;\n\t}\n\n\t#endregion\n\n\t#region Protected Methods\n\n\tprotected FbCommand BuildCommand(FbConnection connection, string collectionName, string[] restrictions)\n\t{\n\t\tSetMajorVersionNumber(connection);\n\t\tvar filter = string.Format(\"CollectionName='{0}'\", collectionName);\n\t\tvar builder = GetCommandText(restrictions);\n\t\tvar restriction = connection.GetSchema(DbMetaDataCollectionNames.Restrictions).Select(filter);\n\t\tvar transaction = connection.InnerConnection.ActiveTransaction;\n\t\tvar command = new FbCommand(builder.ToString(), connection, transaction);\n\n\t\tif (restrictions != null && restrictions.Length > 0)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\tfor (var i = 0; i < restrictions.Length; i++)\n\t\t\t{\n\t\t\t\tvar rname = restriction[i][\"RestrictionName\"].ToString();\n\t\t\t\tif (restrictions[i] != null)\n\t\t\t\t{\n\t\t\t\t\t// Catalog, Schema and TableType are no real restrictions\n\t\t\t\t\tif (!rname.EndsWith(\"Catalog\") && !rname.EndsWith(\"Schema\") && rname != \"TableType\")\n\t\t\t\t\t{\n\t\t\t\t\t\tvar pname = string.Format(\"@p{0}\", index++);\n\n\t\t\t\t\t\tcommand.Parameters.Add(pname, FbDbType.VarChar, 255).Value = restrictions[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn command;\n\t}\n\n\n\tprotected virtual void ProcessResult(DataTable schema)\n\t{ }\n\n\tprotected virtual string[] ParseRestrictions(string[] restrictions)\n\t{\n\t\treturn restrictions;\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\t/// <summary>\n\t/// Determines the major version number from the Serverversion on the inner connection.\n\t/// </summary>\n\t/// <param name=\"connection\">an open connection, which is used to determine the version number of the connected database server</param>\n\tprivate void SetMajorVersionNumber(FbConnection connection)\n\t{\n\t\tvar serverVersion = FbServerProperties.ParseServerVersion(connection.ServerVersion);\n\t\tMajorVersionNumber = serverVersion.Major;\n\t}\n\t#endregion\n\n\t#region Private Static Methods\n\n\tprivate static void TrimStringFields(DataTable schema)\n\t{\n\t\tschema.BeginLoadData();\n\n\t\tforeach (DataRow row in schema.Rows)\n\t\t{\n\t\t\tfor (var i = 0; i < schema.Columns.Count; i++)\n\t\t\t{\n\t\t\t\tif (!row.IsNull(schema.Columns[i]) &&\n\t\t\t\t\tschema.Columns[i].DataType == typeof(System.String))\n\t\t\t\t{\n\t\t\t\t\trow[schema.Columns[i]] = row[schema.Columns[i]].ToString().Trim();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tschema.EndLoadData();\n\t\tschema.AcceptChanges();\n\t}\n\n\t#endregion\n\n\t#region Properties\n\t/// <summary>\n\t/// The major version of the connected Firebird server\n\t/// </summary>\n\tprotected int MajorVersionNumber { get; private set; }\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbSchemaFactory.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Data.Common;\nusing System.Globalization;\nusing System.IO;\nusing System.Reflection;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal sealed class FbSchemaFactory\n{\n\t#region Static Members\n\n\tprivate static readonly string ResourceName = \"FirebirdSql.Data.Schema.FbMetaData.xml\";\n\n\t#endregion\n\n\t#region Constructors\n\n\tprivate FbSchemaFactory()\n\t{ }\n\n\t#endregion\n\n\t#region Methods\n\n\tpublic static DataTable GetSchema(FbConnection connection, string collectionName, string[] restrictions)\n\t{\n\t\tvar filter = string.Format(\"CollectionName = '{0}'\", collectionName);\n\t\tvar ds = new DataSet();\n\t\tusing (var xmlStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(ResourceName))\n\t\t{\n\t\t\tvar oldCulture = Thread.CurrentThread.CurrentCulture;\n\t\t\ttry\n\t\t\t{\n\t\t\t\tThread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\t\t\t\t// ReadXml contains error: http://connect.microsoft.com/VisualStudio/feedback/Validation.aspx?FeedbackID=95116\n\t\t\t\t// that's the reason for temporarily changing culture\n\t\t\t\tds.ReadXml(xmlStream);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tThread.CurrentThread.CurrentCulture = oldCulture;\n\t\t\t}\n\t\t}\n\n\t\tvar collection = ds.Tables[DbMetaDataCollectionNames.MetaDataCollections].Select(filter);\n\n\t\tif (collection.Length != 1)\n\t\t{\n\t\t\tthrow new NotSupportedException(\"Unsupported collection name.\");\n\t\t}\n\n\t\tif (restrictions != null && restrictions.Length > (int)collection[0][\"NumberOfRestrictions\"])\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"The number of specified restrictions is not valid.\");\n\t\t}\n\n\t\tif (ds.Tables[DbMetaDataCollectionNames.Restrictions].Select(filter).Length != (int)collection[0][\"NumberOfRestrictions\"])\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Incorrect restriction definition.\");\n\t\t}\n\n\t\tswitch (collection[0][\"PopulationMechanism\"].ToString())\n\t\t{\n\t\t\tcase \"PrepareCollection\":\n\t\t\t\treturn PrepareCollection(connection, collectionName, restrictions);\n\n\t\t\tcase \"DataTable\":\n\t\t\t\treturn ds.Tables[collection[0][\"PopulationString\"].ToString()].Copy();\n\n\t\t\tcase \"SQLCommand\":\n\t\t\t\treturn SqlCommandSchema(connection, collectionName, restrictions);\n\n\t\t\tdefault:\n\t\t\t\tthrow new NotSupportedException(\"Unsupported population mechanism\");\n\t\t}\n\t}\n\tpublic static Task<DataTable> GetSchemaAsync(FbConnection connection, string collectionName, string[] restrictions, CancellationToken cancellationToken = default)\n\t{\n\t\tvar filter = string.Format(\"CollectionName = '{0}'\", collectionName);\n\t\tvar ds = new DataSet();\n\t\tusing (var xmlStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(ResourceName))\n\t\t{\n\t\t\tvar oldCulture = Thread.CurrentThread.CurrentCulture;\n\t\t\ttry\n\t\t\t{\n\t\t\t\tThread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\t\t\t\t// ReadXml contains error: http://connect.microsoft.com/VisualStudio/feedback/Validation.aspx?FeedbackID=95116\n\t\t\t\t// that's the reason for temporarily changing culture\n\t\t\t\tds.ReadXml(xmlStream);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tThread.CurrentThread.CurrentCulture = oldCulture;\n\t\t\t}\n\t\t}\n\n\t\tvar collection = ds.Tables[DbMetaDataCollectionNames.MetaDataCollections].Select(filter);\n\n\t\tif (collection.Length != 1)\n\t\t{\n\t\t\tthrow new NotSupportedException(\"Unsupported collection name.\");\n\t\t}\n\n\t\tif (restrictions != null && restrictions.Length > (int)collection[0][\"NumberOfRestrictions\"])\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"The number of specified restrictions is not valid.\");\n\t\t}\n\n\t\tif (ds.Tables[DbMetaDataCollectionNames.Restrictions].Select(filter).Length != (int)collection[0][\"NumberOfRestrictions\"])\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Incorrect restriction definition.\");\n\t\t}\n\n\t\tswitch (collection[0][\"PopulationMechanism\"].ToString())\n\t\t{\n\t\t\tcase \"PrepareCollection\":\n\t\t\t\treturn PrepareCollectionAsync(connection, collectionName, restrictions, cancellationToken);\n\n\t\t\tcase \"DataTable\":\n\t\t\t\treturn Task.FromResult(ds.Tables[collection[0][\"PopulationString\"].ToString()].Copy());\n\n\t\t\tcase \"SQLCommand\":\n\t\t\t\treturn SqlCommandSchemaAsync(connection, collectionName, restrictions, cancellationToken);\n\n\t\t\tdefault:\n\t\t\t\tthrow new NotSupportedException(\"Unsupported population mechanism\");\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region Private Methods\n\n\tprivate static DataTable PrepareCollection(FbConnection connection, string collectionName, string[] restrictions)\n\t{\n\t\tFbSchema returnSchema = collectionName.ToUpperInvariant() switch\n\t\t{\n\t\t\t\"CHARACTERSETS\" => new FbCharacterSets(),\n\t\t\t\"CHECKCONSTRAINTS\" => new FbCheckConstraints(),\n\t\t\t\"CHECKCONSTRAINTSBYTABLE\" => new FbChecksByTable(),\n\t\t\t\"COLLATIONS\" => new FbCollations(),\n\t\t\t\"COLUMNS\" => new FbColumns(),\n\t\t\t\"COLUMNPRIVILEGES\" => new FbColumnPrivileges(),\n\t\t\t\"DOMAINS\" => new FbDomains(),\n\t\t\t\"FOREIGNKEYCOLUMNS\" => new FbForeignKeyColumns(),\n\t\t\t\"FOREIGNKEYS\" => new FbForeignKeys(),\n\t\t\t\"FUNCTIONS\" => new FbFunctions(),\n\t\t\t\"FUNCTIONARGUMENTS\" => new FbFunctionArguments(),\n\t\t\t\"FUNCTIONPRIVILEGES\" => new FbFunctionPrivileges(),\n\t\t\t\"GENERATORS\" => new FbGenerators(),\n\t\t\t\"INDEXCOLUMNS\" => new FbIndexColumns(),\n\t\t\t\"INDEXES\" => new FbIndexes(),\n\t\t\t\"PRIMARYKEYS\" => new FbPrimaryKeys(),\n\t\t\t\"PROCEDURES\" => new FbProcedures(),\n\t\t\t\"PROCEDUREPARAMETERS\" => new FbProcedureParameters(),\n\t\t\t\"PROCEDUREPRIVILEGES\" => new FbProcedurePrivileges(),\n\t\t\t\"ROLES\" => new FbRoles(),\n\t\t\t\"TABLES\" => new FbTables(),\n\t\t\t\"TABLECONSTRAINTS\" => new FbTableConstraints(),\n\t\t\t\"TABLEPRIVILEGES\" => new FbTablePrivileges(),\n\t\t\t\"TRIGGERS\" => new FbTriggers(),\n\t\t\t\"UNIQUEKEYS\" => new FbUniqueKeys(),\n\t\t\t\"VIEWCOLUMNS\" => new FbViewColumns(),\n\t\t\t\"VIEWS\" => new FbViews(),\n\t\t\t\"VIEWPRIVILEGES\" => new FbViewPrivileges(),\n\t\t\t_ => throw new NotSupportedException(\"The specified metadata collection is not supported.\"),\n\t\t};\n\t\treturn returnSchema.GetSchema(connection, collectionName, restrictions);\n\t}\n\tprivate static Task<DataTable> PrepareCollectionAsync(FbConnection connection, string collectionName, string[] restrictions, CancellationToken cancellationToken = default)\n\t{\n\t\tFbSchema returnSchema = collectionName.ToUpperInvariant() switch\n\t\t{\n\t\t\t\"CHARACTERSETS\" => new FbCharacterSets(),\n\t\t\t\"CHECKCONSTRAINTS\" => new FbCheckConstraints(),\n\t\t\t\"CHECKCONSTRAINTSBYTABLE\" => new FbChecksByTable(),\n\t\t\t\"COLLATIONS\" => new FbCollations(),\n\t\t\t\"COLUMNS\" => new FbColumns(),\n\t\t\t\"COLUMNPRIVILEGES\" => new FbColumnPrivileges(),\n\t\t\t\"DOMAINS\" => new FbDomains(),\n\t\t\t\"FOREIGNKEYCOLUMNS\" => new FbForeignKeyColumns(),\n\t\t\t\"FOREIGNKEYS\" => new FbForeignKeys(),\n\t\t\t\"FUNCTIONS\" => new FbFunctions(),\n\t\t\t\"FUNCTIONARGUMENTS\" => new FbFunctionArguments(),\n\t\t\t\"FUNCTIONPRIVILEGES\" => new FbFunctionPrivileges(),\n\t\t\t\"GENERATORS\" => new FbGenerators(),\n\t\t\t\"INDEXCOLUMNS\" => new FbIndexColumns(),\n\t\t\t\"INDEXES\" => new FbIndexes(),\n\t\t\t\"PRIMARYKEYS\" => new FbPrimaryKeys(),\n\t\t\t\"PROCEDURES\" => new FbProcedures(),\n\t\t\t\"PROCEDUREPARAMETERS\" => new FbProcedureParameters(),\n\t\t\t\"PROCEDUREPRIVILEGES\" => new FbProcedurePrivileges(),\n\t\t\t\"ROLES\" => new FbRoles(),\n\t\t\t\"TABLES\" => new FbTables(),\n\t\t\t\"TABLECONSTRAINTS\" => new FbTableConstraints(),\n\t\t\t\"TABLEPRIVILEGES\" => new FbTablePrivileges(),\n\t\t\t\"TRIGGERS\" => new FbTriggers(),\n\t\t\t\"UNIQUEKEYS\" => new FbUniqueKeys(),\n\t\t\t\"VIEWCOLUMNS\" => new FbViewColumns(),\n\t\t\t\"VIEWS\" => new FbViews(),\n\t\t\t\"VIEWPRIVILEGES\" => new FbViewPrivileges(),\n\t\t\t_ => throw new NotSupportedException(\"The specified metadata collection is not supported.\"),\n\t\t};\n\t\treturn returnSchema.GetSchemaAsync(connection, collectionName, restrictions, cancellationToken);\n\t}\n\n\tprivate static DataTable SqlCommandSchema(FbConnection connection, string collectionName, string[] restrictions)\n\t{\n\t\tthrow new NotImplementedException();\n\t}\n\tprivate static Task<DataTable> SqlCommandSchemaAsync(FbConnection connection, string collectionName, string[] restrictions, CancellationToken cancellationToken = default)\n\t{\n\t\tthrow new NotImplementedException();\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbTableConstraints.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbTableConstraints : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS CONSTRAINT_CATALOG,\n\t\t\t\t\tnull AS CONSTRAINT_SCHEMA,\n\t\t\t\t\trc.rdb$constraint_name AS CONSTRAINT_NAME,\n\t\t\t\t\tnull AS TABLE_CATALOG,\n\t\t\t\t\tnull AS TABLE_SCHEMA,\n\t\t\t\t\trc.rdb$relation_name AS TABLE_NAME,\n\t\t\t\t\trc.rdb$constraint_type AS CONSTRAINT_TYPE,\n\t\t\t\t    rc.rdb$deferrable AS IS_DEFERRABLE,\n\t\t\t\t    rc.rdb$initially_deferred AS INITIALLY_DEFERRED\n\t\t\t\tFROM rdb$relation_constraints rc\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* CONSTRAINT_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* CONSTRAINT_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* CONSTRAINT_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\tif (where.Length > 0)\n\t\t\t\t{\n\t\t\t\t\twhere.Append(\" AND \");\n\t\t\t\t}\n\n\t\t\t\twhere.AppendFormat(\"rc.rdb$constraint_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* TABLE_CATALOG */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_SCHEMA */\n\t\t\tif (restrictions.Length >= 5 && restrictions[4] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_NAME */\n\t\t\tif (restrictions.Length >= 6 && restrictions[5] != null)\n\t\t\t{\n\t\t\t\tif (where.Length > 0)\n\t\t\t\t{\n\t\t\t\t\twhere.Append(\" AND \");\n\t\t\t\t}\n\n\t\t\t\twhere.AppendFormat(\"rc.rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* CONSTRAINT_TYPE */\n\t\t\tif (restrictions.Length >= 7 && restrictions[6] != null)\n\t\t\t{\n\t\t\t\tif (where.Length > 0)\n\t\t\t\t{\n\t\t\t\t\twhere.Append(\" AND \");\n\t\t\t\t}\n\n\t\t\t\twhere.AppendFormat(\"rc.rdb$constraint_type = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY TABLE_NAME, CONSTRAINT_NAME\");\n\n\t\treturn sql;\n\t}\n\n\tprotected override string[] ParseRestrictions(string[] restrictions)\n\t{\n\t\tvar parsed = restrictions;\n\n\t\tif (parsed != null)\n\t\t{\n\t\t\tif (parsed.Length == 7 && parsed[6] != null)\n\t\t\t{\n\t\t\t\tswitch (parsed[6].ToString().ToUpperInvariant())\n\t\t\t\t{\n\t\t\t\t\tcase \"UNIQUE\":\n\t\t\t\t\t\tparsed[3] = \"u\";\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"PRIMARY KEY\":\n\t\t\t\t\t\tparsed[3] = \"p\";\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"FOREIGN KEY\":\n\t\t\t\t\t\tparsed[3] = \"f\";\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"CHECK\":\n\t\t\t\t\t\tparsed[3] = \"c\";\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn parsed;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbTablePrivileges.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbTablePrivileges : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS TABLE_CATALOG,\n\t\t\t\t\tnull AS TABLE_SCHEMA,\n\t\t\t\t\trdb$relation_name AS TABLE_NAME,\n\t\t\t\t\trdb$user AS GRANTEE,\n\t\t\t\t\trdb$grantor AS GRANTOR,\n\t\t\t\t\trdb$privilege AS PRIVILEGE,\n\t\t\t\t\trdb$grant_option AS WITH_GRANT\n\t\t\t\tFROM rdb$user_privileges\");\n\n\t\twhere.Append(\"rdb$object_type = 0\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* TABLE_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* GRANTOR */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rdb$grantor = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* GRANTEE */\n\t\t\tif (restrictions.Length >= 5 && restrictions[4] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rdb$user = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY TABLE_NAME\");\n\n\t\treturn sql;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbTables.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbTables : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS TABLE_CATALOG,\n\t\t\t\t\tnull AS TABLE_SCHEMA,\n\t\t\t\t\trdb$relation_name AS TABLE_NAME,\n\t\t\t\t\tnull AS TABLE_TYPE,\n\t\t\t\t\trdb$system_flag AS IS_SYSTEM_TABLE,\n\t\t\t\t\trdb$owner_name AS OWNER_NAME,\n\t\t\t\t\trdb$description AS DESCRIPTION,\n\t\t\t\t\trdb$view_source AS VIEW_SOURCE\n\t\t\t\tFROM rdb$relations\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* TABLE_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\"rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* TABLE_TYPE */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\tif (where.Length > 0)\n\t\t\t\t{\n\t\t\t\t\twhere.Append(\" AND \");\n\t\t\t\t}\n\n\t\t\t\tswitch (restrictions[3].ToString())\n\t\t\t\t{\n\t\t\t\t\tcase \"VIEW\":\n\t\t\t\t\t\twhere.Append(\"rdb$view_source IS NOT NULL\");\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"SYSTEM TABLE\":\n\t\t\t\t\t\twhere.Append(\"rdb$view_source IS NULL and rdb$system_flag = 1\");\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase \"TABLE\":\n\t\t\t\t\tdefault:\n\t\t\t\t\t\twhere.Append(\"rdb$view_source IS NULL and rdb$system_flag = 0\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY IS_SYSTEM_TABLE, OWNER_NAME, TABLE_NAME\");\n\n\t\treturn sql;\n\t}\n\n\tprotected override void ProcessResult(DataTable schema)\n\t{\n\t\tschema.BeginLoadData();\n\n\t\tforeach (DataRow row in schema.Rows)\n\t\t{\n\t\t\trow[\"TABLE_TYPE\"] = \"TABLE\";\n\t\t\tif (row[\"IS_SYSTEM_TABLE\"] == DBNull.Value ||\n\t\t\t\tConvert.ToInt32(row[\"IS_SYSTEM_TABLE\"], CultureInfo.InvariantCulture) == 0)\n\t\t\t{\n\t\t\t\trow[\"IS_SYSTEM_TABLE\"] = false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\trow[\"IS_SYSTEM_TABLE\"] = true;\n\t\t\t\trow[\"TABLE_TYPE\"] = \"SYSTEM_TABLE\";\n\t\t\t}\n\t\t\tif (row[\"VIEW_SOURCE\"] != null &&\n\t\t\t\trow[\"VIEW_SOURCE\"].ToString().Length > 0)\n\t\t\t{\n\t\t\t\trow[\"TABLE_TYPE\"] = \"VIEW\";\n\t\t\t}\n\t\t}\n\n\t\tschema.EndLoadData();\n\t\tschema.AcceptChanges();\n\n\t\tschema.Columns.Remove(\"VIEW_SOURCE\");\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbTriggers.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbTriggers : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS TABLE_CATALOG,\n\t\t\t\t\tnull AS TABLE_SCHEMA,\n\t\t\t\t\trdb$relation_name AS TABLE_NAME,\n\t\t\t\t\trdb$trigger_name AS TRIGGER_NAME,\n\t\t\t\t\trdb$system_flag AS IS_SYSTEM_TRIGGER,\n\t\t\t\t\trdb$trigger_type AS TRIGGER_TYPE,\n\t\t\t\t\trdb$trigger_inactive AS IS_INACTIVE,\n\t\t\t\t\trdb$trigger_sequence AS SEQUENCE,\n\t\t\t\t\trdb$trigger_source AS SOURCE,\n\t\t\t\t\trdb$description AS DESCRIPTION\n\t\t\t\tFROM rdb$triggers\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* TABLE_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\"rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* TRIGGER_NAME */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\tif (where.Length > 0)\n\t\t\t\t{\n\t\t\t\t\twhere.Append(\" AND \");\n\t\t\t\t}\n\n\t\t\t\twhere.AppendFormat(\"rdb$trigger_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY TABLE_NAME, TRIGGER_NAME\");\n\n\t\treturn sql;\n\t}\n\n\tprotected override void ProcessResult(DataTable schema)\n\t{\n\t\tschema.BeginLoadData();\n\n\t\tforeach (DataRow row in schema.Rows)\n\t\t{\n\t\t\tif (row[\"IS_SYSTEM_TRIGGER\"] == DBNull.Value ||\n\t\t\t\tConvert.ToInt32(row[\"IS_SYSTEM_TRIGGER\"], CultureInfo.InvariantCulture) == 0)\n\t\t\t{\n\t\t\t\trow[\"IS_SYSTEM_TRIGGER\"] = false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\trow[\"IS_SYSTEM_TRIGGER\"] = true;\n\t\t\t}\n\t\t}\n\n\t\tschema.EndLoadData();\n\t\tschema.AcceptChanges();\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbUniqueKeys.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbUniqueKeys : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS TABLE_CATALOG,\n\t\t\t\t\tnull AS TABLE_SCHEMA,\n\t\t\t\t\trel.rdb$relation_name AS TABLE_NAME,\n\t\t\t\t\tseg.rdb$field_name AS COLUMN_NAME,\n\t\t\t\t\tseg.rdb$field_position AS ORDINAL_POSITION,\n\t\t\t\t\trel.rdb$constraint_name AS UK_NAME\n\t\t\t\tFROM rdb$relation_constraints rel\n\t\t\t\t\tLEFT JOIN rdb$indices idx ON rel.rdb$index_name = idx.rdb$index_name\n\t\t\t\t\tLEFT JOIN rdb$index_segments seg ON idx.rdb$index_name = seg.rdb$index_name\");\n\n\t\twhere.Append(\"rel.rdb$constraint_type = 'UNIQUE'\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* TABLE_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* TABLE_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rel.rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY TABLE_NAME, UK_NAME, ORDINAL_POSITION\");\n\n\t\treturn sql;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbViewColumns.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbViewColumns : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS VIEW_CATALOG,\n\t\t\t\t\tnull AS VIEW_SCHEMA,\n\t\t\t\t\trel.rdb$relation_name AS VIEW_NAME,\n\t\t\t\t\trfr.rdb$field_name AS COLUMN_NAME,\n\t\t\t\t\tnull AS COLUMN_DATA_TYPE,\n\t\t\t\t\tfld.rdb$field_sub_type AS COLUMN_SUB_TYPE,\n\t\t\t\t\tCAST(fld.rdb$field_length AS integer) AS COLUMN_SIZE,\n\t\t\t\t\tCAST(fld.rdb$field_precision AS integer) AS NUMERIC_PRECISION,\n\t\t\t\t\tCAST(fld.rdb$field_scale AS integer) AS NUMERIC_SCALE,\n\t\t\t\t\tCAST(fld.rdb$character_length AS integer) AS CHARACTER_MAX_LENGTH,\n\t\t\t\t\tCAST(fld.rdb$field_length AS integer) AS CHARACTER_OCTET_LENGTH,\n\t\t\t\t\trfr.rdb$field_position AS ORDINAL_POSITION,\n\t\t\t\t\tfld.rdb$default_source AS COLUMN_DEFAULT,\n\t\t\t\t\tcoalesce(fld.rdb$null_flag, rfr.rdb$null_flag) AS COLUMN_NULLABLE,\n\t\t\t\t\tfld.rdb$dimensions AS COLUMN_ARRAY,\n\t\t\t\t\t0 AS IS_READONLY,\n\t\t\t\t\tfld.rdb$field_type AS FIELD_TYPE,\n\t\t\t\t\tnull AS CHARACTER_SET_CATALOG,\n\t\t\t\t\tnull AS CHARACTER_SET_SCHEMA,\n\t\t\t\t\tcs.rdb$character_set_name AS CHARACTER_SET_NAME,\n\t\t\t\t\tnull AS COLLATION_CATALOG,\n\t\t\t\t\tnull AS COLLATION_SCHEMA,\n\t\t\t\t\tcoll.rdb$collation_name AS COLLATION_NAME,\n\t\t\t\t\trfr.rdb$description AS DESCRIPTION\n\t\t\t\tFROM rdb$relations rel\n\t\t\t\t\tLEFT JOIN rdb$relation_fields rfr ON rel.rdb$relation_name = rfr.rdb$relation_name\n\t\t\t\t\tLEFT JOIN rdb$fields fld ON rfr.rdb$field_source = fld.rdb$field_name\n\t\t\t\t\tLEFT JOIN rdb$character_sets cs ON cs.rdb$character_set_id = fld.rdb$character_set_id\n\t\t\t\t    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)\");\n\n\t\twhere.Append(\"rel.rdb$view_source IS NOT NULL\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* VIEW_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* VIEW_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* VIEW_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rel.rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* COLUMN_NAME */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rfr.rdb$field_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY VIEW_NAME, ORDINAL_POSITION\");\n\n\t\treturn sql;\n\t}\n\n\tprotected override void ProcessResult(DataTable schema)\n\t{\n\t\tschema.BeginLoadData();\n\t\tschema.Columns.Add(\"IS_NULLABLE\", typeof(bool));\n\t\tschema.Columns.Add(\"IS_ARRAY\", typeof(bool));\n\n\t\tforeach (DataRow row in schema.Rows)\n\t\t{\n\t\t\tvar blrType = Convert.ToInt32(row[\"FIELD_TYPE\"], CultureInfo.InvariantCulture);\n\n\t\t\tvar subType = 0;\n\t\t\tif (row[\"COLUMN_SUB_TYPE\"] != DBNull.Value)\n\t\t\t{\n\t\t\t\tsubType = Convert.ToInt32(row[\"COLUMN_SUB_TYPE\"], CultureInfo.InvariantCulture);\n\t\t\t}\n\n\t\t\tvar scale = 0;\n\t\t\tif (row[\"NUMERIC_SCALE\"] != DBNull.Value)\n\t\t\t{\n\t\t\t\tscale = Convert.ToInt32(row[\"NUMERIC_SCALE\"], CultureInfo.InvariantCulture);\n\t\t\t}\n\n\t\t\trow[\"IS_NULLABLE\"] = (row[\"COLUMN_NULLABLE\"] == DBNull.Value);\n\t\t\trow[\"IS_ARRAY\"] = (row[\"COLUMN_ARRAY\"] != DBNull.Value);\n\n\t\t\tvar dbType = (FbDbType)TypeHelper.GetDbDataTypeFromBlrType(blrType, subType, scale);\n\t\t\trow[\"COLUMN_DATA_TYPE\"] = TypeHelper.GetDataTypeName((DbDataType)dbType).ToLowerInvariant();\n\n\t\t\tif (dbType == FbDbType.Char || dbType == FbDbType.VarChar)\n\t\t\t{\n\t\t\t\tif (!row.IsNull(\"CHARACTER_MAX_LENGTH\"))\n\t\t\t\t{\n\t\t\t\t\trow[\"COLUMN_SIZE\"] = row[\"CHARACTER_MAX_LENGTH\"];\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\trow[\"CHARACTER_OCTET_LENGTH\"] = 0;\n\t\t\t}\n\n\t\t\tif (dbType == FbDbType.Binary || dbType == FbDbType.Text)\n\t\t\t{\n\t\t\t\trow[\"COLUMN_SIZE\"] = Int32.MaxValue;\n\t\t\t}\n\n\t\t\tif (row[\"NUMERIC_PRECISION\"] == DBNull.Value)\n\t\t\t{\n\t\t\t\trow[\"NUMERIC_PRECISION\"] = 0;\n\t\t\t}\n\n\t\t\tif ((dbType == FbDbType.Decimal || dbType == FbDbType.Numeric) &&\n\t\t\t\t(row[\"NUMERIC_PRECISION\"] == DBNull.Value || Convert.ToInt32(row[\"NUMERIC_PRECISION\"]) == 0))\n\t\t\t{\n\t\t\t\trow[\"NUMERIC_PRECISION\"] = row[\"COLUMN_SIZE\"];\n\t\t\t}\n\n\t\t\trow[\"NUMERIC_SCALE\"] = (-1) * scale;\n\t\t}\n\n\t\tschema.EndLoadData();\n\t\tschema.AcceptChanges();\n\n\t\t// Remove not more needed columns\n\t\tschema.Columns.Remove(\"COLUMN_NULLABLE\");\n\t\tschema.Columns.Remove(\"COLUMN_ARRAY\");\n\t\tschema.Columns.Remove(\"FIELD_TYPE\");\n\t\tschema.Columns.Remove(\"CHARACTER_MAX_LENGTH\");\n\t}\n\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbViewPrivileges.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbViewPrivileges : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS VIEW_CATALOG,\n\t\t\t\t\tnull AS VIEW_SCHEMA,\n\t\t\t\t\tpriv.rdb$relation_name AS VIEW_NAME,\n\t\t\t\t\tpriv.rdb$user AS GRANTEE,\n\t\t\t\t\tpriv.rdb$grantor AS GRANTOR,\n\t\t\t\t\tpriv.rdb$privilege AS PRIVILEGE,\n\t\t\t\t\tpriv.rdb$grant_option AS WITH_GRANT\n\t\t\t\tFROM rdb$user_privileges priv\n\t\t\t\t\tLEFT JOIN rdb$relations rel ON priv.rdb$relation_name = rel.rdb$relation_name\");\n\n\t\twhere.Append(\"priv.rdb$object_type = 0\");\n\t\twhere.Append(\" AND rel.rdb$view_source IS NOT NULL\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* VIEW_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* VIEW_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* VIEW_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND priv.rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* GRANTOR */\n\t\t\tif (restrictions.Length >= 4 && restrictions[3] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND priv.rdb$grantor = @p{0}\", index++);\n\t\t\t}\n\n\t\t\t/* GRANTEE */\n\t\t\tif (restrictions.Length >= 5 && restrictions[4] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND priv.rdb$user = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY VIEW_NAME, GRANTEE\");\n\n\t\treturn sql;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Schema/FbViews.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Globalization;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Schema;\n\ninternal class FbViews : FbSchema\n{\n\t#region Protected Methods\n\n\tprotected override StringBuilder GetCommandText(string[] restrictions)\n\t{\n\t\tvar sql = new StringBuilder();\n\t\tvar where = new StringBuilder();\n\n\t\tsql.Append(\n\t\t\t@\"SELECT\n\t\t\t\t\tnull AS VIEW_CATALOG,\n\t\t\t\t\tnull AS VIEW_SCHEMA,\n\t\t\t\t\trel.rdb$relation_name AS VIEW_NAME,\n\t\t\t\t\trel.rdb$system_flag AS IS_SYSTEM_VIEW,\n\t\t\t\t\trel.rdb$view_source AS DEFINITION,\n\t\t\t\t\trel.rdb$description AS DESCRIPTION\n\t\t\t\tFROM rdb$relations rel\");\n\n\t\twhere.Append(\"rel.rdb$view_source IS NOT NULL\");\n\n\t\tif (restrictions != null)\n\t\t{\n\t\t\tvar index = 0;\n\n\t\t\t/* VIEW_CATALOG */\n\t\t\tif (restrictions.Length >= 1 && restrictions[0] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* VIEW_SCHEMA */\n\t\t\tif (restrictions.Length >= 2 && restrictions[1] != null)\n\t\t\t{\n\t\t\t}\n\n\t\t\t/* VIEW_NAME */\n\t\t\tif (restrictions.Length >= 3 && restrictions[2] != null)\n\t\t\t{\n\t\t\t\twhere.AppendFormat(\" AND rel.rdb$relation_name = @p{0}\", index++);\n\t\t\t}\n\t\t}\n\n\t\tif (where.Length > 0)\n\t\t{\n\t\t\tsql.AppendFormat(\" WHERE {0} \", where.ToString());\n\t\t}\n\n\t\tsql.Append(\" ORDER BY VIEW_NAME\");\n\n\t\treturn sql;\n\t}\n\n\tprotected override void ProcessResult(DataTable schema)\n\t{\n\t\tschema.BeginLoadData();\n\n\t\tforeach (DataRow row in schema.Rows)\n\t\t{\n\t\t\tif (row[\"IS_SYSTEM_VIEW\"] == DBNull.Value ||\n\t\t\t\tConvert.ToInt32(row[\"IS_SYSTEM_VIEW\"], CultureInfo.InvariantCulture) == 0)\n\t\t\t{\n\t\t\t\trow[\"IS_SYSTEM_VIEW\"] = false;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\trow[\"IS_SYSTEM_VIEW\"] = true;\n\t\t\t}\n\t\t}\n\n\t\tschema.EndLoadData();\n\t\tschema.AcceptChanges();\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbBackup.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Services;\n\npublic sealed class FbBackup : FbService\n{\n\tpublic FbBackupFileCollection BackupFiles { get; }\n\tpublic bool Verbose { get; set; }\n\tpublic int? VerboseInterval { get; set; }\n\tpublic int Factor { get; set; }\n\tpublic string SkipData { get; set; }\n\tpublic FbBackupFlags Options { get; set; }\n\tpublic FbBackupRestoreStatistics? Statistics { get; set; }\n\n\tpublic FbBackup(string connectionString = null)\n\t\t: base(connectionString)\n\t{\n\t\tBackupFiles = new FbBackupFileCollection();\n\t}\n\n\tpublic void Execute()\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_backup);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tforeach (var file in BackupFiles)\n\t\t\t\t{\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_bkp_file, file.BackupFile);\n\t\t\t\t\tif (file.BackupLength.HasValue)\n\t\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_bkp_length, (int)file.BackupLength);\n\t\t\t\t}\n\t\t\t\tif (Verbose)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_verbose);\n\t\t\t\tif (VerboseInterval.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_verbint, (int)VerboseInterval);\n\t\t\t\tif (Factor > 0)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_bkp_factor, Factor);\n\t\t\t\tif (!string.IsNullOrEmpty(SkipData))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_bkp_skip_data, SkipData);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, (int)Options);\n\t\t\t\tif (Statistics.HasValue)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_bkp_stat, Statistics.Value.BuildConfiguration());\n\t\t\t\tif (ConnectionStringOptions.ParallelWorkers > 0)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_bkp_parallel_workers, ConnectionStringOptions.ParallelWorkers);\n\t\t\t\tStartTask(startSpb);\n\t\t\t\tif (Verbose || VerboseInterval.HasValue)\n\t\t\t\t{\n\t\t\t\t\tProcessServiceOutput(new ServiceParameterBuffer2(Service.ParameterBufferEncoding));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task ExecuteAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_backup);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tforeach (var file in BackupFiles)\n\t\t\t\t{\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_bkp_file, file.BackupFile);\n\t\t\t\t\tif (file.BackupLength.HasValue)\n\t\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_bkp_length, (int)file.BackupLength);\n\t\t\t\t}\n\t\t\t\tif (Verbose)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_verbose);\n\t\t\t\tif (VerboseInterval.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_verbint, (int)VerboseInterval);\n\t\t\t\tif (Factor > 0)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_bkp_factor, Factor);\n\t\t\t\tif (!string.IsNullOrEmpty(SkipData))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_bkp_skip_data, SkipData);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, (int)Options);\n\t\t\t\tif (Statistics.HasValue)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_bkp_stat, Statistics.Value.BuildConfiguration());\n\t\t\t\tif (ConnectionStringOptions.ParallelWorkers > 0)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_bkp_parallel_workers, ConnectionStringOptions.ParallelWorkers);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t\tif (Verbose || VerboseInterval.HasValue)\n\t\t\t\t{\n\t\t\t\t\tawait ProcessServiceOutputAsync(new ServiceParameterBuffer2(Service.ParameterBufferEncoding), cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbBackupFile.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.Services;\n\npublic class FbBackupFile\n{\n\tpublic string BackupFile { get; set; }\n\tpublic int? BackupLength { get; set; }\n\n\tpublic FbBackupFile(string fileName, int? fileLength = null)\n\t{\n\t\tBackupFile = fileName;\n\t\tBackupLength = fileLength;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbBackupFileCollection.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\n\nnamespace FirebirdSql.Data.Services;\n\npublic class FbBackupFileCollection : List<FbBackupFile>\n{ }\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbBackupFlags.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Services;\n\n[Flags]\npublic enum FbBackupFlags\n{\n\tIgnoreChecksums = IscCodes.isc_spb_bkp_ignore_checksums,\n\tIgnoreLimbo = IscCodes.isc_spb_bkp_ignore_limbo,\n\tMetaDataOnly = IscCodes.isc_spb_bkp_metadata_only,\n\tNoGarbageCollect = IscCodes.isc_spb_bkp_no_garbage_collect,\n\tOldDescriptions = IscCodes.isc_spb_bkp_old_descriptions,\n\tNonTransportable = IscCodes.isc_spb_bkp_non_transportable,\n\tConvert = IscCodes.isc_spb_bkp_convert,\n\tExpand = IscCodes.isc_spb_bkp_expand,\n\tNoDatabaseTriggers = IscCodes.isc_spb_bkp_no_triggers,\n\tZip = IscCodes.isc_spb_bkp_zip,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbBackupRestoreStatistics.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Services;\n\n[Flags]\npublic enum FbBackupRestoreStatistics\n{\n\tTotalTime = 0b0001,\n\tTimeDelta = 0b0010,\n\tPageReads = 0b0100,\n\tPageWrites = 0b1000,\n}\n\ninternal static class FbBackupRestoreStatisticsExtensions\n{\n\tpublic static string BuildConfiguration(this FbBackupRestoreStatistics statistics)\n\t{\n\t\tvar sb = new StringBuilder();\n\t\tif (statistics.HasFlag(FbBackupRestoreStatistics.TotalTime))\n\t\t\tsb.Append(\"T\");\n\t\tif (statistics.HasFlag(FbBackupRestoreStatistics.TimeDelta))\n\t\t\tsb.Append(\"D\");\n\t\tif (statistics.HasFlag(FbBackupRestoreStatistics.PageReads))\n\t\t\tsb.Append(\"R\");\n\t\tif (statistics.HasFlag(FbBackupRestoreStatistics.PageWrites))\n\t\t\tsb.Append(\"W\");\n\t\treturn sb.ToString();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbConfiguration.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Services;\n\npublic sealed class FbConfiguration : FbService\n{\n\tpublic FbConfiguration(string connectionString = null)\n\t\t: base(connectionString)\n\t{ }\n\n\tpublic void SetSqlDialect(int sqlDialect)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_set_sql_dialect, sqlDialect);\n\t\t\t\tStartTask(startSpb);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task SetSqlDialectAsync(int sqlDialect, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_set_sql_dialect, sqlDialect);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic void SetSweepInterval(int sweepInterval)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_sweep_interval, sweepInterval);\n\t\t\t\tStartTask(startSpb);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task SetSweepIntervalAsync(int sweepInterval, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_sweep_interval, sweepInterval);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic void SetPageBuffers(int pageBuffers)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_page_buffers, pageBuffers);\n\t\t\t\tStartTask(startSpb);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task SetPageBuffersAsync(int pageBuffers, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_page_buffers, pageBuffers);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic void DatabaseShutdown(FbShutdownMode mode, int seconds)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tswitch (mode)\n\t\t\t\t{\n\t\t\t\t\tcase FbShutdownMode.Forced:\n\t\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_shutdown_db, seconds);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase FbShutdownMode.DenyTransaction:\n\t\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_deny_new_transactions, seconds);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase FbShutdownMode.DenyConnection:\n\t\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_deny_new_attachments, seconds);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tStartTask(startSpb);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task DatabaseShutdownAsync(FbShutdownMode mode, int seconds, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tswitch (mode)\n\t\t\t\t{\n\t\t\t\t\tcase FbShutdownMode.Forced:\n\t\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_shutdown_db, seconds);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase FbShutdownMode.DenyTransaction:\n\t\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_deny_new_transactions, seconds);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase FbShutdownMode.DenyConnection:\n\t\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_deny_new_attachments, seconds);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic void DatabaseShutdown2(FbShutdownOnlineMode mode, FbShutdownType type, int seconds)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_shutdown_mode, FbShutdownOnlineModeToIscCode(mode));\n\t\t\t\tswitch (type)\n\t\t\t\t{\n\t\t\t\t\tcase FbShutdownType.ForceShutdown:\n\t\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_force_shutdown, seconds);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase FbShutdownType.AttachmentsShutdown:\n\t\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_attachments_shutdown, seconds);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase FbShutdownType.TransactionsShutdown:\n\t\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_transactions_shutdown, seconds);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tStartTask(startSpb);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task DatabaseShutdown2Async(FbShutdownOnlineMode mode, FbShutdownType type, int seconds, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_shutdown_mode, FbShutdownOnlineModeToIscCode(mode));\n\t\t\t\tswitch (type)\n\t\t\t\t{\n\t\t\t\t\tcase FbShutdownType.ForceShutdown:\n\t\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_force_shutdown, seconds);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase FbShutdownType.AttachmentsShutdown:\n\t\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_attachments_shutdown, seconds);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase FbShutdownType.TransactionsShutdown:\n\t\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_transactions_shutdown, seconds);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic void DatabaseOnline()\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, IscCodes.isc_spb_prp_db_online);\n\t\t\t\tStartTask(startSpb);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task DatabaseOnlineAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, IscCodes.isc_spb_prp_db_online);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic void DatabaseOnline2(FbShutdownOnlineMode mode)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_online_mode, FbShutdownOnlineModeToIscCode(mode));\n\t\t\t\tStartTask(startSpb);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task DatabaseOnline2Async(FbShutdownOnlineMode mode, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_online_mode, FbShutdownOnlineModeToIscCode(mode));\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic void ActivateShadows()\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, IscCodes.isc_spb_prp_activate);\n\t\t\t\tStartTask(startSpb);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task ActivateShadowsAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, IscCodes.isc_spb_prp_activate);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic void SetForcedWrites(bool forcedWrites)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tif (forcedWrites)\n\t\t\t\t{\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_write_mode, (byte)IscCodes.isc_spb_prp_wm_sync);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_write_mode, (byte)IscCodes.isc_spb_prp_wm_async);\n\t\t\t\t}\n\t\t\t\tStartTask(startSpb);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task SetForcedWritesAsync(bool forcedWrites, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tif (forcedWrites)\n\t\t\t\t{\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_write_mode, (byte)IscCodes.isc_spb_prp_wm_sync);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_write_mode, (byte)IscCodes.isc_spb_prp_wm_async);\n\t\t\t\t}\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic void SetReserveSpace(bool reserveSpace)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tif (reserveSpace)\n\t\t\t\t{\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_reserve_space, (byte)IscCodes.isc_spb_prp_res);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_reserve_space, (byte)IscCodes.isc_spb_prp_res_use_full);\n\t\t\t\t}\n\t\t\t\tStartTask(startSpb);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task SetReserveSpaceAsync(bool reserveSpace, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tif (reserveSpace)\n\t\t\t\t{\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_reserve_space, (byte)IscCodes.isc_spb_prp_res);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_reserve_space, (byte)IscCodes.isc_spb_prp_res_use_full);\n\t\t\t\t}\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic void SetAccessMode(bool readOnly)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_access_mode, (byte)(readOnly ? IscCodes.isc_spb_prp_am_readonly : IscCodes.isc_spb_prp_am_readwrite));\n\t\t\t\tStartTask(startSpb);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task SetAccessModeAsync(bool readOnly, CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_prp_access_mode, (byte)(readOnly ? IscCodes.isc_spb_prp_am_readonly : IscCodes.isc_spb_prp_am_readwrite));\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic void NoLinger()\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, IscCodes.isc_spb_prp_nolinger);\n\t\t\t\tStartTask(startSpb);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task NoLingerAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_properties);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, IscCodes.isc_spb_prp_nolinger);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tprivate static byte FbShutdownOnlineModeToIscCode(FbShutdownOnlineMode mode)\n\t{\n\t\treturn mode switch\n\t\t{\n\t\t\tFbShutdownOnlineMode.Normal => IscCodes.isc_spb_prp_sm_normal,\n\t\t\tFbShutdownOnlineMode.Multi => IscCodes.isc_spb_prp_sm_multi,\n\t\t\tFbShutdownOnlineMode.Single => IscCodes.isc_spb_prp_sm_single,\n\t\t\tFbShutdownOnlineMode.Full => IscCodes.isc_spb_prp_sm_full,\n\t\t\t_ => throw new ArgumentOutOfRangeException(nameof(mode)),\n\t\t};\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbDatabaseTraceConfiguration.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Services;\n\npublic class FbDatabaseTraceConfiguration : FbTraceConfiguration\n{\n\tpublic FbDatabaseTraceConfiguration()\n\t{\n\t\tEnabled = false;\n\t\tConnectionID = 0;\n\t\tTimeThreshold = TimeSpan.FromMilliseconds(100);\n\t\tMaxSQLLength = 300;\n\t\tMaxBLRLength = 500;\n\t\tMaxDYNLength = 500;\n\t\tMaxArgumentLength = 80;\n\t\tMaxArgumentsCount = 30;\n\t}\n\n\tpublic string DatabaseName { get; set; }\n\n\tpublic bool Enabled { get; set; }\n\n\tpublic FbDatabaseTraceEvents Events { get; set; }\n\n\tpublic int ConnectionID { get; set; }\n\n\tpublic TimeSpan TimeThreshold { get; set; }\n\tpublic int MaxSQLLength { get; set; }\n\tpublic int MaxBLRLength { get; set; }\n\tpublic int MaxDYNLength { get; set; }\n\tpublic int MaxArgumentLength { get; set; }\n\tpublic int MaxArgumentsCount { get; set; }\n\n\tpublic string IncludeFilter { get; set; }\n\tpublic string ExcludeFilter { get; set; }\n\n\tpublic string IncludeGdsCodes { get; set; }\n\tpublic string ExcludeGdsCodes { get; set; }\n\n\tpublic string BuildConfiguration(FbTraceVersion version)\n\t{\n\t\tswitch (version)\n\t\t{\n\t\t\tcase FbTraceVersion.Version1:\n\t\t\t\treturn BuildConfiguration1();\n\t\t\tcase FbTraceVersion.Version2:\n\t\t\t\treturn BuildConfiguration2();\n\t\t\tdefault:\n\t\t\t\tthrow new ArgumentOutOfRangeException(nameof(version));\n\t\t}\n\t}\n\tstring BuildConfiguration1()\n\t{\n\t\tvar sb = new StringBuilder();\n\t\tsb.Append(\"<database\");\n\t\tsb.Append((!string.IsNullOrEmpty(DatabaseName) ? $\" {WriteRegEx(DatabaseName)}\" : string.Empty));\n\t\tsb.AppendLine(\">\");\n\t\tsb.AppendFormat(\"enabled {0}\", WriteBoolValue(Enabled));\n\t\tsb.AppendLine();\n\t\tif (!string.IsNullOrEmpty(IncludeFilter))\n\t\t{\n\t\t\tsb.AppendFormat(\"include_filter {0}\", WriteRegEx(IncludeFilter));\n\t\t\tsb.AppendLine();\n\t\t}\n\t\tif (!string.IsNullOrEmpty(ExcludeFilter))\n\t\t{\n\t\t\tsb.AppendFormat(\"exclude_filter {0}\", WriteRegEx(ExcludeFilter));\n\t\t\tsb.AppendLine();\n\t\t}\n\t\tsb.AppendFormat(\"log_connections {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.Connections)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"connection_id {0}\", WriteNumber(ConnectionID));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_transactions {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.Transactions)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_statement_prepare {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.StatementPrepare)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_statement_free {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.StatementFree)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_statement_start {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.StatementStart)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_statement_finish {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.StatementFinish)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_procedure_start {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.ProcedureStart)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_procedure_finish {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.ProcedureFinish)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_trigger_start {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.TriggerStart)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_trigger_finish {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.TriggerFinish)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_context {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.Context)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_errors {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.Errors)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_warnings {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.Warnings)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_initfini {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.InitFini)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_sweep {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.Sweep)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"print_plan {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.PrintPlan)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"print_perf {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.PrintPerf)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_blr_requests {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.BLRRequests)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"print_blr {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.PrintBLR)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_dyn_requests {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.DYNRequests)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"print_dyn {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.PrintDYN)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"time_threshold {0}\", WriteNumber((int)TimeThreshold.TotalMilliseconds));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"max_sql_length {0}\", WriteNumber(MaxSQLLength));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"max_blr_length {0}\", WriteNumber(MaxBLRLength));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"max_dyn_length {0}\", WriteNumber(MaxDYNLength));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"max_arg_length {0}\", WriteNumber(MaxArgumentLength));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"max_arg_count {0}\", WriteNumber(MaxArgumentsCount));\n\t\tsb.AppendLine();\n\t\tsb.AppendLine(\"</database>\");\n\t\treturn sb.ToString();\n\t}\n\tstring BuildConfiguration2()\n\t{\n\t\tvar sb = new StringBuilder();\n\t\tsb.Append(\"database\");\n\t\tsb.Append((!string.IsNullOrEmpty(DatabaseName) ? $\" = {WriteRegEx(DatabaseName)}\" : string.Empty));\n\t\tsb.AppendLine(\"{\");\n\t\tsb.AppendFormat(\"enabled = {0}\", WriteBoolValue(Enabled));\n\t\tsb.AppendLine();\n\t\tif (!string.IsNullOrEmpty(IncludeFilter))\n\t\t{\n\t\t\tsb.AppendFormat(\"include_filter = {0}\", WriteRegEx(IncludeFilter));\n\t\t\tsb.AppendLine();\n\t\t}\n\t\tif (!string.IsNullOrEmpty(ExcludeFilter))\n\t\t{\n\t\t\tsb.AppendFormat(\"exclude_filter = {0}\", WriteRegEx(ExcludeFilter));\n\t\t\tsb.AppendLine();\n\t\t}\n\t\tif (!string.IsNullOrEmpty(IncludeGdsCodes))\n\t\t{\n\t\t\tsb.AppendFormat(\"include_gds_codes = {0}\", WriteString(IncludeGdsCodes));\n\t\t\tsb.AppendLine();\n\t\t}\n\t\tif (!string.IsNullOrEmpty(ExcludeGdsCodes))\n\t\t{\n\t\t\tsb.AppendFormat(\"exclude_gds_codes = {0}\", WriteString(ExcludeGdsCodes));\n\t\t\tsb.AppendLine();\n\t\t}\n\t\tsb.AppendFormat(\"log_connections = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.Connections)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"connection_id = {0}\", WriteNumber(ConnectionID));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_transactions = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.Transactions)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_statement_prepare = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.StatementPrepare)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_statement_free = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.StatementFree)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_statement_start = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.StatementStart)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_statement_finish = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.StatementFinish)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_procedure_start = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.ProcedureStart)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_procedure_finish = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.ProcedureFinish)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_function_start = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.FunctionStart)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_function_finish = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.FunctionFinish)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_trigger_start = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.TriggerStart)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_trigger_finish = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.TriggerFinish)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_context = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.Context)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_errors = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.Errors)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_warnings = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.Warnings)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_initfini = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.InitFini)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_sweep = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.Sweep)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"print_plan = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.PrintPlan)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"explain_plan = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.ExplainPlan)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"print_perf = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.PrintPerf)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_blr_requests = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.BLRRequests)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"print_blr = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.PrintBLR)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_dyn_requests = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.DYNRequests)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"print_dyn = {0}\", WriteBoolValue(Events.HasFlag(FbDatabaseTraceEvents.PrintDYN)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"time_threshold = {0}\", WriteNumber((int)TimeThreshold.TotalMilliseconds));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"max_sql_length = {0}\", WriteNumber(MaxSQLLength));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"max_blr_length = {0}\", WriteNumber(MaxBLRLength));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"max_dyn_length = {0}\", WriteNumber(MaxDYNLength));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"max_arg_length = {0}\", WriteNumber(MaxArgumentLength));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"max_arg_count = {0}\", WriteNumber(MaxArgumentsCount));\n\t\tsb.AppendLine();\n\t\tsb.AppendLine(\"}\");\n\t\treturn sb.ToString();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbDatabaseTraceConfigurationCollection.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nnamespace FirebirdSql.Data.Services;\n\npublic class FbDatabaseTraceConfigurationCollection : List<FbDatabaseTraceConfiguration>\n{\n\tpublic string BuildConfiguration(FbTraceVersion version)\n\t{\n\t\treturn string.Join(Environment.NewLine, this.Select(x => x.BuildConfiguration(version)));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbDatabaseTraceEvents.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.Services;\n\n[Flags]\npublic enum FbDatabaseTraceEvents\n{\n\tConnections = 0x00_00_01,\n\tTransactions = 0x00_00_02,\n\tStatementPrepare = 0x00_00_04,\n\tStatementFree = 0x00_00_08,\n\tStatementStart = 0x00_00_10,\n\tStatementFinish = 0x00_00_20,\n\tProcedureStart = 0x00_00_40,\n\tProcedureFinish = 0x00_00_80,\n\tFunctionStart = 0x00_01_00,\n\tFunctionFinish = 0x00_02_00,\n\tTriggerStart = 0x00_04_00,\n\tTriggerFinish = 0x00_08_00,\n\tContext = 0x00_10_00,\n\tErrors = 0x00_20_00,\n\tWarnings = 0x00_40_00,\n\tInitFini = 0x00_80_00,\n\tSweep = 0x01_00_00,\n\tPrintPlan = 0x02_00_00,\n\tExplainPlan = 0x04_00_00,\n\tPrintPerf = 0x08_00_00,\n\tBLRRequests = 0x10_00_00,\n\tPrintBLR = 0x20_00_00,\n\tDYNRequests = 0x40_00_00,\n\tPrintDYN = 0x80_00_00,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbDatabasesInfo.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\n\nnamespace FirebirdSql.Data.Services;\n\npublic class FbDatabasesInfo\n{\n\tpublic int ConnectionCount { get; internal set; }\n\n\tprivate List<string> _databases;\n\tpublic IReadOnlyList<string> Databases\n\t{\n\t\tget\n\t\t{\n\t\t\treturn _databases.AsReadOnly();\n\t\t}\n\t}\n\n\tinternal FbDatabasesInfo()\n\t{\n\t\t_databases = new List<string>();\n\t}\n\n\tinternal void AddDatabase(string database)\n\t{\n\t\t_databases.Add(database);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbLog.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Services;\n\npublic sealed class FbLog : FbService\n{\n\tpublic FbLog(string connectionString = null)\n\t\t: base(connectionString)\n\t{ }\n\n\tpublic void Execute()\n\t{\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_get_fb_log);\n\t\t\t\tStartTask(startSpb);\n\t\t\t\tProcessServiceOutput(new ServiceParameterBuffer2(Service.ParameterBufferEncoding));\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task ExecuteAsync(CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_get_fb_log);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ProcessServiceOutputAsync(new ServiceParameterBuffer2(Service.ParameterBufferEncoding), cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbNBackup.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Services;\n\npublic sealed class FbNBackup : FbService\n{\n\tprivate int _level;\n\tpublic int Level\n\t{\n\t\tget { return _level; }\n\t\tset\n\t\t{\n\t\t\tif (value < 0)\n\t\t\t\tthrow new ArgumentOutOfRangeException();\n\t\t\t_level = value;\n\t\t}\n\t}\n\tpublic string BackupFile { get; set; }\n\tpublic bool DirectIO { get; set; }\n\tpublic FbNBackupFlags Options { get; set; }\n\n\tpublic FbNBackup(string connectionString = null)\n\t\t: base(connectionString)\n\t{ }\n\n\tpublic void Execute()\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_nbak);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_nbk_level, _level);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_nbk_file, BackupFile);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_nbk_direct, DirectIO ? \"ON\" : \"OFF\");\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, (int)Options);\n\t\t\t\tStartTask(startSpb);\n\t\t\t\tProcessServiceOutput(new ServiceParameterBuffer2(Service.ParameterBufferEncoding));\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task ExecuteAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_nbak);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_nbk_level, _level);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_nbk_file, BackupFile);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_nbk_direct, DirectIO ? \"ON\" : \"OFF\");\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, (int)Options);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ProcessServiceOutputAsync(new ServiceParameterBuffer2(Service.ParameterBufferEncoding), cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbNBackupFlags.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Services;\n\n[Flags]\npublic enum FbNBackupFlags\n{\n\tNoDatabaseTriggers = IscCodes.isc_spb_nbk_no_triggers,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbNFixup.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Services;\n\npublic sealed class FbNFixup : FbService\n{\n\tpublic FbNFixup(string connectionString = null)\n\t\t: base(connectionString)\n\t{ }\n\n\tpublic void Execute()\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_nfix);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tStartTask(startSpb);\n\t\t\t\tProcessServiceOutput(new ServiceParameterBuffer2(Service.ParameterBufferEncoding));\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task ExecuteAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_nfix);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ProcessServiceOutputAsync(new ServiceParameterBuffer2(Service.ParameterBufferEncoding), cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbNRestore.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Services;\n\npublic sealed class FbNRestore : FbService\n{\n\tpublic IEnumerable<string> BackupFiles { get; set; }\n\tpublic bool DirectIO { get; set; }\n\n\tpublic FbNRestore(string connectionString = null)\n\t\t: base(connectionString)\n\t{ }\n\n\tpublic void Execute()\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_nrest);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tforeach (var file in BackupFiles)\n\t\t\t\t{\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_nbk_file, file);\n\t\t\t\t}\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_nbk_direct, DirectIO ? \"ON\" : \"OFF\");\n\t\t\t\tStartTask(startSpb);\n\t\t\t\tProcessServiceOutput(new ServiceParameterBuffer2(Service.ParameterBufferEncoding));\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task ExecuteAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_nrest);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tforeach (var file in BackupFiles)\n\t\t\t\t{\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_nbk_file, file);\n\t\t\t\t}\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_nbk_direct, DirectIO ? \"ON\" : \"OFF\");\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ProcessServiceOutputAsync(new ServiceParameterBuffer2(Service.ParameterBufferEncoding), cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbRestore.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Services;\n\npublic sealed class FbRestore : FbService\n{\n\tprivate int? _pageSize;\n\tpublic int? PageSize\n\t{\n\t\tget { return _pageSize; }\n\t\tset\n\t\t{\n\t\t\tif (value is int v && !SizeHelper.IsValidPageSize(v))\n\t\t\t\tthrow SizeHelper.InvalidSizeException(\"page size\");\n\n\t\t\t_pageSize = value;\n\t\t}\n\t}\n\n\tpublic FbBackupFileCollection BackupFiles { get; }\n\tpublic bool Verbose { get; set; }\n\tpublic int? VerboseInterval { get; set; }\n\tpublic int? PageBuffers { get; set; }\n\tpublic bool ReadOnly { get; set; }\n\tpublic string SkipData { get; set; }\n\tpublic FbRestoreFlags Options { get; set; }\n\tpublic FbBackupRestoreStatistics? Statistics { get; set; }\n\n\tpublic FbRestore(string connectionString = null)\n\t\t: base(connectionString)\n\t{\n\t\tBackupFiles = new FbBackupFileCollection();\n\t}\n\n\tpublic void Execute()\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_restore);\n\t\t\t\tforeach (var bkpFile in BackupFiles)\n\t\t\t\t{\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_bkp_file, bkpFile.BackupFile);\n\t\t\t\t}\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tif (Verbose)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_verbose);\n\t\t\t\tif (VerboseInterval.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_verbint, (int)VerboseInterval);\n\t\t\t\tif (PageBuffers.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_res_buffers, (int)PageBuffers);\n\t\t\t\tif (_pageSize.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_res_page_size, (int)_pageSize);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_res_access_mode, (byte)(ReadOnly ? IscCodes.isc_spb_res_am_readonly : IscCodes.isc_spb_res_am_readwrite));\n\t\t\t\tif (!string.IsNullOrEmpty(SkipData))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_res_skip_data, SkipData);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, (int)Options);\n\t\t\t\tif (Statistics.HasValue)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_res_stat, Statistics.Value.BuildConfiguration());\n\t\t\t\tif (ConnectionStringOptions.ParallelWorkers > 0)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_res_parallel_workers, ConnectionStringOptions.ParallelWorkers);\n\t\t\t\tStartTask(startSpb);\n\t\t\t\tif (Verbose || VerboseInterval.HasValue)\n\t\t\t\t{\n\t\t\t\t\tProcessServiceOutput(new ServiceParameterBuffer2(Service.ParameterBufferEncoding));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task ExecuteAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_restore);\n\t\t\t\tforeach (var bkpFile in BackupFiles)\n\t\t\t\t{\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_bkp_file, bkpFile.BackupFile);\n\t\t\t\t}\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tif (Verbose)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_verbose);\n\t\t\t\tif (VerboseInterval.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_verbint, (int)VerboseInterval);\n\t\t\t\tif (PageBuffers.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_res_buffers, (int)PageBuffers);\n\t\t\t\tif (_pageSize.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_res_page_size, (int)_pageSize);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_res_access_mode, (byte)(ReadOnly ? IscCodes.isc_spb_res_am_readonly : IscCodes.isc_spb_res_am_readwrite));\n\t\t\t\tif (!string.IsNullOrEmpty(SkipData))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_res_skip_data, SkipData);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, (int)Options);\n\t\t\t\tif (Statistics.HasValue)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_res_stat, Statistics.Value.BuildConfiguration());\n\t\t\t\tif (ConnectionStringOptions.ParallelWorkers > 0)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_res_parallel_workers, ConnectionStringOptions.ParallelWorkers);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t\tif (Verbose || VerboseInterval.HasValue)\n\t\t\t\t{\n\t\t\t\t\tawait ProcessServiceOutputAsync(new ServiceParameterBuffer2(Service.ParameterBufferEncoding), cancellationToken).ConfigureAwait(false);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbRestoreFlags.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Services;\n\n[Flags]\npublic enum FbRestoreFlags\n{\n\tDeactivateIndexes = IscCodes.isc_spb_res_deactivate_idx,\n\tNoShadow = IscCodes.isc_spb_res_no_shadow,\n\tNoValidity = IscCodes.isc_spb_res_no_validity,\n\tIndividualCommit = IscCodes.isc_spb_res_one_at_a_time,\n\tReplace = IscCodes.isc_spb_res_replace,\n\tCreate = IscCodes.isc_spb_res_create,\n\tUseAllSpace = IscCodes.isc_spb_res_use_all_space,\n\tMetaDataOnly = IscCodes.isc_spb_res_metadata_only,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbSecurity.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Services;\n\npublic sealed class FbSecurity : FbService\n{\n\tpublic FbSecurity(string connectionString = null)\n\t\t: base(connectionString)\n\t{ }\n\n\tpublic void AddUser(FbUserData user)\n\t{\n\t\tif (string.IsNullOrEmpty(user.UserName))\n\t\t\tthrow new InvalidOperationException(\"Invalid user name.\");\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_add_user);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_username, user.UserName);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_password, user.UserPassword);\n\t\t\t\tif ((user.FirstName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_firstname, user.FirstName);\n\t\t\t\tif ((user.MiddleName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_middlename, user.MiddleName);\n\t\t\t\tif ((user.LastName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_lastname, user.LastName);\n\t\t\t\tif (user.UserID != 0)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_sec_userid, user.UserID);\n\t\t\t\tif (user.GroupID != 0)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_sec_groupid, user.GroupID);\n\t\t\t\tif ((user.GroupName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_groupname, user.GroupName);\n\t\t\t\tif ((user.RoleName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sql_role_name, user.RoleName);\n\t\t\t\tStartTask(startSpb);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task AddUserAsync(FbUserData user, CancellationToken cancellationToken = default)\n\t{\n\t\tif (string.IsNullOrEmpty(user.UserName))\n\t\t\tthrow new InvalidOperationException(\"Invalid user name.\");\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_add_user);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_username, user.UserName);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_password, user.UserPassword);\n\t\t\t\tif ((user.FirstName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_firstname, user.FirstName);\n\t\t\t\tif ((user.MiddleName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_middlename, user.MiddleName);\n\t\t\t\tif ((user.LastName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_lastname, user.LastName);\n\t\t\t\tif (user.UserID != 0)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_sec_userid, user.UserID);\n\t\t\t\tif (user.GroupID != 0)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_sec_groupid, user.GroupID);\n\t\t\t\tif ((user.GroupName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_groupname, user.GroupName);\n\t\t\t\tif ((user.RoleName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sql_role_name, user.RoleName);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic void DeleteUser(FbUserData user)\n\t{\n\t\tif (string.IsNullOrEmpty(user.UserName))\n\t\t\tthrow new InvalidOperationException(\"Invalid user name.\");\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_delete_user);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_username, user.UserName);\n\t\t\t\tif ((user.RoleName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sql_role_name, user.RoleName);\n\t\t\t\tStartTask(startSpb);\n\t\t\t}\n\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task DeleteUserAsync(FbUserData user, CancellationToken cancellationToken = default)\n\t{\n\t\tif (string.IsNullOrEmpty(user.UserName))\n\t\t\tthrow new InvalidOperationException(\"Invalid user name.\");\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_delete_user);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_username, user.UserName);\n\t\t\t\tif ((user.RoleName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sql_role_name, user.RoleName);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic void ModifyUser(FbUserData user)\n\t{\n\t\tif (string.IsNullOrEmpty(user.UserName))\n\t\t\tthrow new InvalidOperationException(\"Invalid user name.\");\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_modify_user);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_username, user.UserName);\n\t\t\t\tif ((user.UserPassword?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_password, user.UserPassword);\n\t\t\t\tif ((user.FirstName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_firstname, user.FirstName);\n\t\t\t\tif ((user.MiddleName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_middlename, user.MiddleName);\n\t\t\t\tif ((user.LastName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_lastname, user.LastName);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_sec_userid, user.UserID);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_sec_groupid, user.GroupID);\n\t\t\t\tif ((user.GroupName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_groupname, user.GroupName);\n\t\t\t\tif ((user.RoleName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sql_role_name, user.RoleName);\n\t\t\t\tStartTask(startSpb);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task ModifyUserAsync(FbUserData user, CancellationToken cancellationToken = default)\n\t{\n\t\tif (string.IsNullOrEmpty(user.UserName))\n\t\t\tthrow new InvalidOperationException(\"Invalid user name.\");\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_modify_user);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_username, user.UserName);\n\t\t\t\tif ((user.UserPassword?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_password, user.UserPassword);\n\t\t\t\tif ((user.FirstName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_firstname, user.FirstName);\n\t\t\t\tif ((user.MiddleName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_middlename, user.MiddleName);\n\t\t\t\tif ((user.LastName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_lastname, user.LastName);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_sec_userid, user.UserID);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_sec_groupid, user.GroupID);\n\t\t\t\tif ((user.GroupName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_groupname, user.GroupName);\n\t\t\t\tif ((user.RoleName?.Length ?? 0) != 0)\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sql_role_name, user.RoleName);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic FbUserData DisplayUser(string userName)\n\t{\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_display_user);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_username, userName);\n\t\t\t\tStartTask(startSpb);\n\t\t\t\tvar info = Query(new byte[] { IscCodes.isc_info_svc_get_users }, new ServiceParameterBuffer2(Service.ParameterBufferEncoding));\n\t\t\t\treturn ((FbUserData[])info.FirstOrDefault())?.FirstOrDefault();\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task<FbUserData> DisplayUserAsync(string userName, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_display_user);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_sec_username, userName);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar info = await QueryAsync(new byte[] { IscCodes.isc_info_svc_get_users }, new ServiceParameterBuffer2(Service.ParameterBufferEncoding), cancellationToken).ConfigureAwait(false);\n\t\t\t\treturn ((FbUserData[])info.FirstOrDefault())?.FirstOrDefault();\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic FbUserData[] DisplayUsers()\n\t{\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_display_user);\n\t\t\t\tStartTask(startSpb);\n\t\t\t\tvar info = Query(new byte[] { IscCodes.isc_info_svc_get_users }, new ServiceParameterBuffer2(Service.ParameterBufferEncoding));\n\t\t\t\treturn (FbUserData[])info.FirstOrDefault();\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task<FbUserData[]> DisplayUsersAsync(CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_display_user);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar info = await QueryAsync(new byte[] { IscCodes.isc_info_svc_get_users }, new ServiceParameterBuffer2(Service.ParameterBufferEncoding), cancellationToken).ConfigureAwait(false);\n\t\t\t\treturn (FbUserData[])info.FirstOrDefault();\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic string GetUsersDbPath()\n\t{\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar info = Query(new byte[] { IscCodes.isc_info_svc_user_dbpath }, new ServiceParameterBuffer2(Service.ParameterBufferEncoding));\n\t\t\t\treturn (string)info.FirstOrDefault();\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task<string> GetUsersDbPathAsync(CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar info = await QueryAsync(new byte[] { IscCodes.isc_info_svc_user_dbpath }, new ServiceParameterBuffer2(Service.ParameterBufferEncoding), cancellationToken).ConfigureAwait(false);\n\t\t\t\treturn (string)info.FirstOrDefault();\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbServerConfig.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.Services;\n\npublic class FbServerConfig\n{\n\tpublic int LockMemSize { get; internal set; }\n\tpublic int LockSemCount { get; internal set; }\n\tpublic int LockSignal { get; internal set; }\n\tpublic int EventMemorySize { get; internal set; }\n\tpublic int PrioritySwitchDelay { get; internal set; }\n\tpublic int MinMemory { get; internal set; }\n\tpublic int MaxMemory { get; internal set; }\n\tpublic int LockGrantOrder { get; internal set; }\n\tpublic int AnyLockMemory { get; internal set; }\n\tpublic int AnyLockSemaphore { get; internal set; }\n\tpublic int AnyLockSignal { get; internal set; }\n\tpublic int AnyEventMemory { get; internal set; }\n\tpublic int LockHashSlots { get; internal set; }\n\tpublic int DeadlockTimeout { get; internal set; }\n\tpublic int LockRequireSpins { get; internal set; }\n\tpublic int ConnectionTimeout { get; internal set; }\n\tpublic int DummyPacketInterval { get; internal set; }\n\tpublic int IpcMapSize { get; internal set; }\n\tpublic int DefaultDbCachePages { get; internal set; }\n\n\tinternal FbServerConfig()\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbServerProperties.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text.RegularExpressions;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Services;\n\npublic sealed class FbServerProperties : FbService\n{\n\tpublic FbServerProperties(string connectionString = null)\n\t\t: base(connectionString)\n\t{ }\n\n\tpublic int GetVersion()\n\t{\n\t\treturn GetInt32(IscCodes.isc_info_svc_version);\n\t}\n\tpublic Task<int> GetVersionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetInt32Async(IscCodes.isc_info_svc_version, cancellationToken);\n\t}\n\n\tpublic string GetServerVersion()\n\t{\n\t\treturn GetString(IscCodes.isc_info_svc_server_version);\n\t}\n\tpublic Task<string> GetServerVersionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetStringAsync(IscCodes.isc_info_svc_server_version, cancellationToken);\n\t}\n\n\tpublic string GetImplementation()\n\t{\n\t\treturn GetString(IscCodes.isc_info_svc_implementation);\n\t}\n\tpublic Task<string> GetImplementationAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetStringAsync(IscCodes.isc_info_svc_implementation, cancellationToken);\n\t}\n\n\tpublic string GetRootDirectory()\n\t{\n\t\treturn GetString(IscCodes.isc_info_svc_get_env);\n\t}\n\tpublic Task<string> GetRootDirectoryAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetStringAsync(IscCodes.isc_info_svc_get_env, cancellationToken);\n\t}\n\n\tpublic string GetLockManager()\n\t{\n\t\treturn GetString(IscCodes.isc_info_svc_get_env_lock);\n\t}\n\tpublic Task<string> GetLockManagerAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetStringAsync(IscCodes.isc_info_svc_get_env_lock, cancellationToken);\n\t}\n\n\tpublic string GetMessageFile()\n\t{\n\t\treturn GetString(IscCodes.isc_info_svc_get_env_msg);\n\t}\n\tpublic Task<string> GetMessageFileAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetStringAsync(IscCodes.isc_info_svc_get_env_msg, cancellationToken);\n\t}\n\n\tpublic FbDatabasesInfo GetDatabasesInfo()\n\t{\n\t\treturn (FbDatabasesInfo)(GetInfo(IscCodes.isc_info_svc_svr_db_info)).FirstOrDefault() ?? new FbDatabasesInfo();\n\t}\n\tpublic async Task<FbDatabasesInfo> GetDatabasesInfoAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn (FbDatabasesInfo)(await GetInfoAsync(IscCodes.isc_info_svc_svr_db_info, cancellationToken).ConfigureAwait(false)).FirstOrDefault() ?? new FbDatabasesInfo();\n\t}\n\n\tpublic FbServerConfig GetServerConfig()\n\t{\n\t\treturn (FbServerConfig)(GetInfo(IscCodes.isc_info_svc_get_config)).FirstOrDefault() ?? new FbServerConfig();\n\t}\n\tpublic async Task<FbServerConfig> GetServerConfigAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn (FbServerConfig)(await GetInfoAsync(IscCodes.isc_info_svc_get_config, cancellationToken).ConfigureAwait(false)).FirstOrDefault() ?? new FbServerConfig();\n\t}\n\n\tprivate string GetString(int item)\n\t{\n\t\treturn (string)(GetInfo(item)).FirstOrDefault();\n\t}\n\tprivate async Task<string> GetStringAsync(int item, CancellationToken cancellationToken = default)\n\t{\n\t\treturn (string)(await GetInfoAsync(item, cancellationToken).ConfigureAwait(false)).FirstOrDefault();\n\t}\n\n\tprivate int GetInt32(int item)\n\t{\n\t\treturn (int)(GetInfo(item)).FirstOrDefault();\n\t}\n\tprivate async Task<int> GetInt32Async(int item, CancellationToken cancellationToken = default)\n\t{\n\t\treturn (int)(await GetInfoAsync(item, cancellationToken).ConfigureAwait(false)).FirstOrDefault();\n\t}\n\n\tprivate List<object> GetInfo(int item)\n\t{\n\t\treturn GetInfo(new byte[] { (byte)item });\n\t}\n\tprivate Task<List<object>> GetInfoAsync(int item, CancellationToken cancellationToken = default)\n\t{\n\t\treturn GetInfoAsync(new byte[] { (byte)item }, cancellationToken);\n\t}\n\n\tprivate List<object> GetInfo(byte[] items)\n\t{\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\treturn Query(items, new ServiceParameterBuffer2(Service.ParameterBufferEncoding));\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tprivate async Task<List<object>> GetInfoAsync(byte[] items, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\treturn await QueryAsync(items, new ServiceParameterBuffer2(Service.ParameterBufferEncoding), cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic static Version ParseServerVersion(string version)\n\t{\n\t\tvar m = Regex.Match(version, @\"\\w{2}-\\w(\\d+\\.\\d+\\.\\d+\\.\\d+)\");\n\t\tif (!m.Success)\n\t\t\treturn null;\n\t\treturn new Version(m.Groups[1].Value);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbService.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Client;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Services;\n\npublic abstract class FbService\n{\n\tpublic event EventHandler<ServiceOutputEventArgs> ServiceOutput;\n\n\tpublic event EventHandler<FbInfoMessageEventArgs> InfoMessage;\n\n\tprivate const string ServiceName = \"service_mgr\";\n\n\tprivate ServiceManagerBase _svc;\n\tprivate ConnectionString _connectionStringOptions;\n\n\tprivate protected ServiceManagerBase Service => _svc;\n\tprivate protected ConnectionString ConnectionStringOptions => _connectionStringOptions;\n\n\tpublic FbServiceState State { get; private set; }\n\tpublic int QueryBufferSize { get; set; }\n\n\tprivate string _connectionString;\n\tpublic string ConnectionString\n\t{\n\t\tget { return _connectionString; }\n\t\tset\n\t\t{\n\t\t\tif (_svc != null && State == FbServiceState.Open)\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException(\"ConnectionString cannot be modified on open instances.\");\n\t\t\t}\n\n\t\t\t_connectionStringOptions = new ConnectionString(value);\n\n\t\t\tif (value == null)\n\t\t\t{\n\t\t\t\t_connectionString = string.Empty;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t_connectionString = value;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate protected FbService(string connectionString = null)\n\t{\n\t\tState = FbServiceState.Closed;\n\t\tQueryBufferSize = IscCodes.DEFAULT_MAX_BUFFER_SIZE;\n\t\tConnectionString = connectionString;\n\t}\n\n\tprivate ServiceParameterBufferBase BuildSpb()\n\t{\n\t\tvar spb = Service.CreateServiceParameterBuffer();\n\t\tspb.AppendPreamble();\n\t\tif (Service.UseUtf8ParameterBuffer)\n\t\t{\n\t\t\tspb.Append1(IscCodes.isc_spb_utf8_filename, new byte[] { 0 });\n\t\t}\n\t\tif (Service is Client.Managed.Version13.GdsServiceManager gdsSvc)\n\t\t{\n\t\t\tif (!gdsSvc.Connection.AuthBlock.HasClientData)\n\t\t\t{\n\t\t\t\tspb.Append1(IscCodes.isc_spb_auth_plugin_name, gdsSvc.Connection.AuthBlock.AcceptPluginName);\n\t\t\t\tspb.Append1(IscCodes.isc_spb_specific_auth_data, gdsSvc.Connection.AuthBlock.PublicClientData);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tspb.Append1(IscCodes.isc_spb_specific_auth_data, gdsSvc.Connection.AuthBlock.ClientData);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tspb.Append1(IscCodes.isc_spb_user_name, _connectionStringOptions.UserID);\n\t\t\tspb.Append1(IscCodes.isc_spb_password, _connectionStringOptions.Password);\n\t\t}\n\t\tspb.Append1(IscCodes.isc_spb_dummy_packet_interval, new byte[] { 120, 10, 0, 0 });\n\t\tif ((_connectionStringOptions?.Role.Length ?? 0) != 0)\n\t\t{\n\t\t\tspb.Append1(IscCodes.isc_spb_sql_role_name, _connectionStringOptions.Role);\n\t\t}\n\t\tspb.Append1(IscCodes.isc_spb_expected_db, _connectionStringOptions.Database);\n\t\treturn spb;\n\t}\n\n\tprivate protected void Open()\n\t{\n\t\tif (State != FbServiceState.Closed)\n\t\t\tthrow new InvalidOperationException(\"Service already open.\");\n\t\tif (string.IsNullOrEmpty(_connectionStringOptions.UserID))\n\t\t\tthrow new InvalidOperationException(\"No user name was specified.\");\n\t\tif (string.IsNullOrEmpty(_connectionStringOptions.Password))\n\t\t\tthrow new InvalidOperationException(\"No user password was specified.\");\n\t\tif (!Charset.TryGetByName(_connectionStringOptions.Charset, out var charset))\n\t\t\tthrow new ArgumentException(\"Invalid character set specified.\");\n\n\t\tif (_svc == null)\n\t\t{\n\t\t\t_svc = ClientFactory.CreateServiceManager(_connectionStringOptions);\n\t\t}\n\t\t_svc.Attach(BuildSpb(), _connectionStringOptions.DataSource, _connectionStringOptions.Port, ServiceName, _connectionStringOptions.CryptKey);\n\t\t_svc.WarningMessage = OnWarningMessage;\n\t\tState = FbServiceState.Open;\n\t}\n\tprivate protected async Task OpenAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (State != FbServiceState.Closed)\n\t\t\tthrow new InvalidOperationException(\"Service already open.\");\n\t\tif (string.IsNullOrEmpty(_connectionStringOptions.UserID))\n\t\t\tthrow new InvalidOperationException(\"No user name was specified.\");\n\t\tif (string.IsNullOrEmpty(_connectionStringOptions.Password))\n\t\t\tthrow new InvalidOperationException(\"No user password was specified.\");\n\t\tif (!Charset.TryGetByName(_connectionStringOptions.Charset, out var charset))\n\t\t\tthrow new ArgumentException(\"Invalid character set specified.\");\n\n\t\tif (_svc == null)\n\t\t{\n\t\t\t_svc = await ClientFactory.CreateServiceManagerAsync(_connectionStringOptions, cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\tawait _svc.AttachAsync(BuildSpb(), _connectionStringOptions.DataSource, _connectionStringOptions.Port, ServiceName, _connectionStringOptions.CryptKey, cancellationToken).ConfigureAwait(false);\n\t\t_svc.WarningMessage = OnWarningMessage;\n\t\tState = FbServiceState.Open;\n\t}\n\n\tprivate protected void Close()\n\t{\n\t\tif (State != FbServiceState.Open)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\t_svc.Detach();\n\t\t_svc = null;\n\t\tState = FbServiceState.Closed;\n\t}\n\tprivate protected async Task CloseAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tif (State != FbServiceState.Open)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tawait _svc.DetachAsync(cancellationToken).ConfigureAwait(false);\n\t\t_svc = null;\n\t\tState = FbServiceState.Closed;\n\t}\n\n\tprivate protected void StartTask(ServiceParameterBufferBase spb)\n\t{\n\t\tif (State == FbServiceState.Closed)\n\t\t\tthrow new InvalidOperationException(\"Service is closed.\");\n\n\t\tService.Start(spb);\n\t}\n\tprivate protected async Task StartTaskAsync(ServiceParameterBufferBase spb, CancellationToken cancellationToken = default)\n\t{\n\t\tif (State == FbServiceState.Closed)\n\t\t\tthrow new InvalidOperationException(\"Service is closed.\");\n\n\t\tawait Service.StartAsync(spb, cancellationToken).ConfigureAwait(false);\n\t}\n\n\tprivate protected List<object> Query(byte[] items, ServiceParameterBufferBase spb)\n\t{\n\t\tvar result = new List<object>();\n\t\tQuery(items, spb, (truncated, item) =>\n\t\t{\n\t\t\tif (item is string stringItem)\n\t\t\t{\n\t\t\t\tif (!truncated)\n\t\t\t\t{\n\t\t\t\t\tresult.Add(stringItem);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tvar lastValue = result[result.Count - 1] as string;\n\t\t\t\t\tresult[result.Count - 1] = lastValue + stringItem;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (item is byte[] byteArrayItem)\n\t\t\t{\n\t\t\t\tif (!truncated)\n\t\t\t\t{\n\t\t\t\t\tresult.Add(byteArrayItem);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tvar lastValue = result[result.Count - 1] as byte[];\n\t\t\t\t\tvar lastValueLength = lastValue.Length;\n\t\t\t\t\tArray.Resize(ref lastValue, lastValue.Length + byteArrayItem.Length);\n\t\t\t\t\tArray.Copy(byteArrayItem, 0, lastValue, lastValueLength, byteArrayItem.Length);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tresult.Add(item);\n\t\t});\n\t\treturn result;\n\t}\n\tprivate protected async Task<List<object>> QueryAsync(byte[] items, ServiceParameterBufferBase spb, CancellationToken cancellationToken = default)\n\t{\n\t\tvar result = new List<object>();\n\t\tawait QueryAsync(items, spb, (truncated, item) =>\n\t\t{\n\t\t\tif (item is string stringItem)\n\t\t\t{\n\t\t\t\tif (!truncated)\n\t\t\t\t{\n\t\t\t\t\tresult.Add(stringItem);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tvar lastValue = result[result.Count - 1] as string;\n\t\t\t\t\tresult[result.Count - 1] = lastValue + stringItem;\n\t\t\t\t}\n\t\t\t\treturn Task.CompletedTask;\n\t\t\t}\n\n\t\t\tif (item is byte[] byteArrayItem)\n\t\t\t{\n\t\t\t\tif (!truncated)\n\t\t\t\t{\n\t\t\t\t\tresult.Add(byteArrayItem);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tvar lastValue = result[result.Count - 1] as byte[];\n\t\t\t\t\tvar lastValueLength = lastValue.Length;\n\t\t\t\t\tArray.Resize(ref lastValue, lastValue.Length + byteArrayItem.Length);\n\t\t\t\t\tArray.Copy(byteArrayItem, 0, lastValue, lastValueLength, byteArrayItem.Length);\n\t\t\t\t}\n\t\t\t\treturn Task.CompletedTask;\n\t\t\t}\n\n\t\t\tresult.Add(item);\n\n\t\t\treturn Task.CompletedTask;\n\t\t}, cancellationToken).ConfigureAwait(false);\n\t\treturn result;\n\t}\n\n\tprivate protected void Query(byte[] items, ServiceParameterBufferBase spb, Action<bool, object> queryResponseAction)\n\t{\n\t\tvar pos = 0;\n\t\tvar truncated = false;\n\t\tvar type = default(int);\n\n\t\tvar buffer = QueryService(items, spb);\n\n\t\twhile ((type = buffer[pos++]) != IscCodes.isc_info_end)\n\t\t{\n\t\t\tif (type == IscCodes.isc_info_truncated)\n\t\t\t{\n\t\t\t\tbuffer = QueryService(items, spb);\n\t\t\t\tpos = 0;\n\t\t\t\ttruncated = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tswitch (type)\n\t\t\t{\n\t\t\t\tcase IscCodes.isc_info_svc_version:\n\t\t\t\tcase IscCodes.isc_info_svc_get_license_mask:\n\t\t\t\tcase IscCodes.isc_info_svc_capabilities:\n\t\t\t\tcase IscCodes.isc_info_svc_get_licensed_users:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar length = GetLength(buffer, 2, ref pos);\n\t\t\t\t\t\tif (length == 0)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tqueryResponseAction(truncated, (int)IscHelper.VaxInteger(buffer, pos, 4));\n\t\t\t\t\t\tpos += length;\n\t\t\t\t\t\ttruncated = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.isc_info_svc_server_version:\n\t\t\t\tcase IscCodes.isc_info_svc_implementation:\n\t\t\t\tcase IscCodes.isc_info_svc_get_env:\n\t\t\t\tcase IscCodes.isc_info_svc_get_env_lock:\n\t\t\t\tcase IscCodes.isc_info_svc_get_env_msg:\n\t\t\t\tcase IscCodes.isc_info_svc_user_dbpath:\n\t\t\t\tcase IscCodes.isc_info_svc_line:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar length = GetLength(buffer, 2, ref pos);\n\t\t\t\t\t\tif (length == 0)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tqueryResponseAction(truncated, Service.Charset.GetString(buffer, pos, length));\n\t\t\t\t\t\tpos += length;\n\t\t\t\t\t\ttruncated = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\tcase IscCodes.isc_info_svc_to_eof:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar length = GetLength(buffer, 2, ref pos);\n\t\t\t\t\t\tif (length == 0)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tvar block = new byte[length];\n\t\t\t\t\t\tArray.Copy(buffer, pos, block, 0, length);\n\t\t\t\t\t\tqueryResponseAction(truncated, block);\n\t\t\t\t\t\tpos += length;\n\t\t\t\t\t\ttruncated = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.isc_info_svc_svr_db_info:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar length = GetLength(buffer, 2, ref pos);\n\t\t\t\t\t\tif (length == 0)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tqueryResponseAction(truncated, ParseDatabasesInfo(buffer, ref pos, Service.Charset));\n\t\t\t\t\t\ttruncated = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.isc_info_svc_get_users:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar length = GetLength(buffer, 2, ref pos);\n\t\t\t\t\t\tif (length == 0)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tqueryResponseAction(truncated, ParseUserData(buffer, ref pos, Service.Charset));\n\t\t\t\t\t\ttruncated = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.isc_info_svc_get_config:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar length = GetLength(buffer, 2, ref pos);\n\t\t\t\t\t\tif (length == 0)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tqueryResponseAction(truncated, ParseServerConfig(buffer, ref pos, Service.Charset));\n\t\t\t\t\t\ttruncated = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.isc_info_svc_stdin:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar length = GetLength(buffer, 4, ref pos);\n\t\t\t\t\t\tqueryResponseAction(truncated, length);\n\t\t\t\t\t\ttruncated = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.isc_info_data_not_ready:\n\t\t\t\t\t{\n\t\t\t\t\t\tqueryResponseAction(truncated, typeof(void));\n\t\t\t\t\t\ttruncated = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprivate protected async Task QueryAsync(byte[] items, ServiceParameterBufferBase spb, Func<bool, object, Task> queryResponseAction, CancellationToken cancellationToken = default)\n\t{\n\t\tvar pos = 0;\n\t\tvar truncated = false;\n\t\tvar type = default(int);\n\n\t\tvar buffer = await QueryServiceAsync(items, spb, cancellationToken).ConfigureAwait(false);\n\n\t\twhile ((type = buffer[pos++]) != IscCodes.isc_info_end)\n\t\t{\n\t\t\tif (type == IscCodes.isc_info_truncated)\n\t\t\t{\n\t\t\t\tbuffer = await QueryServiceAsync(items, spb, cancellationToken).ConfigureAwait(false);\n\t\t\t\tpos = 0;\n\t\t\t\ttruncated = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tswitch (type)\n\t\t\t{\n\t\t\t\tcase IscCodes.isc_info_svc_version:\n\t\t\t\tcase IscCodes.isc_info_svc_get_license_mask:\n\t\t\t\tcase IscCodes.isc_info_svc_capabilities:\n\t\t\t\tcase IscCodes.isc_info_svc_get_licensed_users:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar length = GetLength(buffer, 2, ref pos);\n\t\t\t\t\t\tif (length == 0)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tawait queryResponseAction(truncated, (int)IscHelper.VaxInteger(buffer, pos, 4)).ConfigureAwait(false);\n\t\t\t\t\t\tpos += length;\n\t\t\t\t\t\ttruncated = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.isc_info_svc_server_version:\n\t\t\t\tcase IscCodes.isc_info_svc_implementation:\n\t\t\t\tcase IscCodes.isc_info_svc_get_env:\n\t\t\t\tcase IscCodes.isc_info_svc_get_env_lock:\n\t\t\t\tcase IscCodes.isc_info_svc_get_env_msg:\n\t\t\t\tcase IscCodes.isc_info_svc_user_dbpath:\n\t\t\t\tcase IscCodes.isc_info_svc_line:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar length = GetLength(buffer, 2, ref pos);\n\t\t\t\t\t\tif (length == 0)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tawait queryResponseAction(truncated, Service.Charset.GetString(buffer, pos, length)).ConfigureAwait(false);\n\t\t\t\t\t\tpos += length;\n\t\t\t\t\t\ttruncated = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\tcase IscCodes.isc_info_svc_to_eof:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar length = GetLength(buffer, 2, ref pos);\n\t\t\t\t\t\tif (length == 0)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tvar block = new byte[length];\n\t\t\t\t\t\tArray.Copy(buffer, pos, block, 0, length);\n\t\t\t\t\t\tawait queryResponseAction(truncated, block).ConfigureAwait(false);\n\t\t\t\t\t\tpos += length;\n\t\t\t\t\t\ttruncated = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.isc_info_svc_svr_db_info:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar length = GetLength(buffer, 2, ref pos);\n\t\t\t\t\t\tif (length == 0)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tawait queryResponseAction(truncated, ParseDatabasesInfo(buffer, ref pos, Service.Charset)).ConfigureAwait(false);\n\t\t\t\t\t\ttruncated = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.isc_info_svc_get_users:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar length = GetLength(buffer, 2, ref pos);\n\t\t\t\t\t\tif (length == 0)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tawait queryResponseAction(truncated, ParseUserData(buffer, ref pos, Service.Charset)).ConfigureAwait(false);\n\t\t\t\t\t\ttruncated = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.isc_info_svc_get_config:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar length = GetLength(buffer, 2, ref pos);\n\t\t\t\t\t\tif (length == 0)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tawait queryResponseAction(truncated, ParseServerConfig(buffer, ref pos, Service.Charset)).ConfigureAwait(false);\n\t\t\t\t\t\ttruncated = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.isc_info_svc_stdin:\n\t\t\t\t\t{\n\t\t\t\t\t\tvar length = GetLength(buffer, 4, ref pos);\n\t\t\t\t\t\tawait queryResponseAction(truncated, length).ConfigureAwait(false);\n\t\t\t\t\t\ttruncated = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\tcase IscCodes.isc_info_data_not_ready:\n\t\t\t\t\t{\n\t\t\t\t\t\tawait queryResponseAction(truncated, typeof(void)).ConfigureAwait(false);\n\t\t\t\t\t\ttruncated = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate protected void ProcessServiceOutput(ServiceParameterBufferBase spb)\n\t{\n\t\tstring line;\n\t\twhile ((line = GetNextLine(spb)) != null)\n\t\t{\n\t\t\tOnServiceOutput(line);\n\t\t}\n\t}\n\tprivate protected async Task ProcessServiceOutputAsync(ServiceParameterBufferBase spb, CancellationToken cancellationToken = default)\n\t{\n\t\tstring line;\n\t\twhile ((line = await GetNextLineAsync(spb, cancellationToken).ConfigureAwait(false)) != null)\n\t\t{\n\t\t\tOnServiceOutput(line);\n\t\t}\n\t}\n\n\tprivate protected string GetNextLine(ServiceParameterBufferBase spb)\n\t{\n\t\tvar info = Query(new byte[] { IscCodes.isc_info_svc_line }, spb);\n\t\tif (info.Count == 0)\n\t\t\treturn null;\n\t\treturn info[0] as string;\n\t}\n\tprivate protected async Task<string> GetNextLineAsync(ServiceParameterBufferBase spb, CancellationToken cancellationToken = default)\n\t{\n\t\tvar info = await QueryAsync(new byte[] { IscCodes.isc_info_svc_line }, spb, cancellationToken).ConfigureAwait(false);\n\t\tif (info.Count == 0)\n\t\t\treturn null;\n\t\treturn info[0] as string;\n\t}\n\n\tprivate protected void OnServiceOutput(string message)\n\t{\n\t\tServiceOutput?.Invoke(this, new ServiceOutputEventArgs(message));\n\t}\n\n\tprivate protected void EnsureDatabase()\n\t{\n\t\tif (string.IsNullOrEmpty(ConnectionStringOptions.Database))\n\t\t\tthrow FbException.Create(\"Action should be executed against a specific database.\");\n\t}\n\n\tprivate byte[] QueryService(byte[] items, ServiceParameterBufferBase spb)\n\t{\n\t\tvar buffer = new byte[QueryBufferSize];\n\t\tService.Query(spb, items.Length, items, buffer.Length, buffer);\n\t\treturn buffer;\n\n\t}\n\tprivate async Task<byte[]> QueryServiceAsync(byte[] items, ServiceParameterBufferBase spb, CancellationToken cancellationToken = default)\n\t{\n\t\tvar buffer = new byte[QueryBufferSize];\n\t\tawait Service.QueryAsync(spb, items.Length, items, buffer.Length, buffer, cancellationToken).ConfigureAwait(false);\n\t\treturn buffer;\n\t}\n\n\tprivate void OnWarningMessage(IscException warning)\n\t{\n\t\tInfoMessage?.Invoke(this, new FbInfoMessageEventArgs(warning));\n\t}\n\n\tprivate static FbServerConfig ParseServerConfig(byte[] buffer, ref int pos, Charset charset)\n\t{\n\t\tvar config = new FbServerConfig();\n\n\t\tpos = 1;\n\t\twhile (buffer[pos] != IscCodes.isc_info_flag_end)\n\t\t{\n\t\t\tpos++;\n\n\t\t\tint key = buffer[pos - 1];\n\t\t\tvar keyValue = (int)IscHelper.VaxInteger(buffer, pos, 4);\n\n\t\t\tpos += 4;\n\n\t\t\tswitch (key)\n\t\t\t{\n\t\t\t\tcase IscCodes.ISCCFG_LOCKMEM_KEY:\n\t\t\t\t\tconfig.LockMemSize = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_LOCKSEM_KEY:\n\t\t\t\t\tconfig.LockSemCount = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_LOCKSIG_KEY:\n\t\t\t\t\tconfig.LockSignal = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_EVNTMEM_KEY:\n\t\t\t\t\tconfig.EventMemorySize = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_PRIORITY_KEY:\n\t\t\t\t\tconfig.PrioritySwitchDelay = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_MEMMIN_KEY:\n\t\t\t\t\tconfig.MinMemory = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_MEMMAX_KEY:\n\t\t\t\t\tconfig.MaxMemory = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_LOCKORDER_KEY:\n\t\t\t\t\tconfig.LockGrantOrder = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_ANYLOCKMEM_KEY:\n\t\t\t\t\tconfig.AnyLockMemory = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_ANYLOCKSEM_KEY:\n\t\t\t\t\tconfig.AnyLockSemaphore = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_ANYLOCKSIG_KEY:\n\t\t\t\t\tconfig.AnyLockSignal = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_ANYEVNTMEM_KEY:\n\t\t\t\t\tconfig.AnyEventMemory = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_LOCKHASH_KEY:\n\t\t\t\t\tconfig.LockHashSlots = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_DEADLOCK_KEY:\n\t\t\t\t\tconfig.DeadlockTimeout = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_LOCKSPIN_KEY:\n\t\t\t\t\tconfig.LockRequireSpins = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_CONN_TIMEOUT_KEY:\n\t\t\t\t\tconfig.ConnectionTimeout = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_DUMMY_INTRVL_KEY:\n\t\t\t\t\tconfig.DummyPacketInterval = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_IPCMAP_KEY:\n\t\t\t\t\tconfig.IpcMapSize = keyValue;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.ISCCFG_DBCACHE_KEY:\n\t\t\t\t\tconfig.DefaultDbCachePages = keyValue;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tpos++;\n\n\t\treturn config;\n\t}\n\n\tprivate static FbDatabasesInfo ParseDatabasesInfo(byte[] buffer, ref int pos, Charset charset)\n\t{\n\t\tvar dbInfo = new FbDatabasesInfo();\n\t\tvar type = 0;\n\t\tvar length = 0;\n\n\t\tpos = 1;\n\n\t\twhile ((type = buffer[pos++]) != IscCodes.isc_info_end)\n\t\t{\n\t\t\tswitch (type)\n\t\t\t{\n\t\t\t\tcase IscCodes.isc_spb_num_att:\n\t\t\t\t\tdbInfo.ConnectionCount = (int)IscHelper.VaxInteger(buffer, pos, 4);\n\t\t\t\t\tpos += 4;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_spb_num_db:\n\t\t\t\t\tpos += 4;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_spb_dbname:\n\t\t\t\t\tlength = (int)IscHelper.VaxInteger(buffer, pos, 2);\n\t\t\t\t\tpos += 2;\n\t\t\t\t\tdbInfo.AddDatabase(charset.GetString(buffer, pos, length));\n\t\t\t\t\tpos += length;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tpos--;\n\n\t\treturn dbInfo;\n\t}\n\n\tprivate static FbUserData[] ParseUserData(byte[] buffer, ref int pos, Charset charset)\n\t{\n\t\tvar users = new List<FbUserData>();\n\t\tFbUserData currentUser = null;\n\t\tvar type = 0;\n\t\tvar length = 0;\n\n\t\twhile ((type = buffer[pos++]) != IscCodes.isc_info_end)\n\t\t{\n\t\t\tswitch (type)\n\t\t\t{\n\t\t\t\tcase IscCodes.isc_spb_sec_username:\n\t\t\t\t\t{\n\t\t\t\t\t\tlength = (int)IscHelper.VaxInteger(buffer, pos, 2);\n\t\t\t\t\t\tpos += 2;\n\t\t\t\t\t\tcurrentUser = new FbUserData();\n\t\t\t\t\t\tcurrentUser.UserName = charset.GetString(buffer, pos, length);\n\t\t\t\t\t\tpos += length;\n\n\t\t\t\t\t\tusers.Add(currentUser);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_spb_sec_firstname:\n\t\t\t\t\tlength = (int)IscHelper.VaxInteger(buffer, pos, 2);\n\t\t\t\t\tpos += 2;\n\t\t\t\t\tcurrentUser.FirstName = charset.GetString(buffer, pos, length);\n\t\t\t\t\tpos += length;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_spb_sec_middlename:\n\t\t\t\t\tlength = (int)IscHelper.VaxInteger(buffer, pos, 2);\n\t\t\t\t\tpos += 2;\n\t\t\t\t\tcurrentUser.MiddleName = charset.GetString(buffer, pos, length);\n\t\t\t\t\tpos += length;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_spb_sec_lastname:\n\t\t\t\t\tlength = (int)IscHelper.VaxInteger(buffer, pos, 2);\n\t\t\t\t\tpos += 2;\n\t\t\t\t\tcurrentUser.LastName = charset.GetString(buffer, pos, length);\n\t\t\t\t\tpos += length;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_spb_sec_userid:\n\t\t\t\t\tcurrentUser.UserID = (int)IscHelper.VaxInteger(buffer, pos, 4);\n\t\t\t\t\tpos += 4;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase IscCodes.isc_spb_sec_groupid:\n\t\t\t\t\tcurrentUser.GroupID = (int)IscHelper.VaxInteger(buffer, pos, 4);\n\t\t\t\t\tpos += 4;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tpos--;\n\n\t\treturn users.ToArray();\n\t}\n\n\tprivate static int GetLength(byte[] buffer, int size, ref int pos)\n\t{\n\t\tvar result = (int)IscHelper.VaxInteger(buffer, pos, size);\n\t\tpos += size;\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbServiceState.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.Services;\n\npublic enum FbServiceState\n{\n\tClosed = 0,\n\tOpen = 1\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbServiceTraceConfiguration.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Text;\n\nnamespace FirebirdSql.Data.Services;\n\npublic class FbServiceTraceConfiguration : FbTraceConfiguration\n{\n\tpublic FbServiceTraceConfiguration()\n\t{\n\t\tEnabled = false;\n\t}\n\n\tpublic bool Enabled { get; set; }\n\n\tpublic FbServiceTraceEvents Events { get; set; }\n\n\tpublic string IncludeFilter { get; set; }\n\tpublic string ExcludeFilter { get; set; }\n\n\tpublic string IncludeGdsCodes { get; set; }\n\tpublic string ExcludeGdsCodes { get; set; }\n\n\tpublic string BuildConfiguration(FbTraceVersion version)\n\t{\n\t\tswitch (version)\n\t\t{\n\t\t\tcase FbTraceVersion.Version1:\n\t\t\t\treturn BuildConfiguration1();\n\t\t\tcase FbTraceVersion.Version2:\n\t\t\t\treturn BuildConfiguration2();\n\t\t\tdefault:\n\t\t\t\tthrow new ArgumentOutOfRangeException(nameof(version));\n\t\t}\n\t}\n\tstring BuildConfiguration1()\n\t{\n\t\tvar sb = new StringBuilder();\n\t\tsb.AppendLine(\"<services>\");\n\t\tsb.AppendFormat(\"enabled {0}\", WriteBoolValue(Enabled));\n\t\tsb.AppendLine();\n\t\tif (!string.IsNullOrEmpty(IncludeFilter))\n\t\t{\n\t\t\tsb.AppendFormat(\"include_filter {0}\", WriteRegEx(IncludeFilter));\n\t\t\tsb.AppendLine();\n\t\t}\n\t\tif (!string.IsNullOrEmpty(ExcludeFilter))\n\t\t{\n\t\t\tsb.AppendFormat(\"exclude_filter {0}\", WriteRegEx(ExcludeFilter));\n\t\t\tsb.AppendLine();\n\t\t}\n\t\tsb.AppendFormat(\"log_services {0}\", WriteBoolValue(Events.HasFlag(FbServiceTraceEvents.Services)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_service_query {0}\", WriteBoolValue(Events.HasFlag(FbServiceTraceEvents.ServiceQuery)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_errors {0}\", WriteBoolValue(Events.HasFlag(FbServiceTraceEvents.Errors)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_warnings {0}\", WriteBoolValue(Events.HasFlag(FbServiceTraceEvents.Warnings)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_initfini {0}\", WriteBoolValue(Events.HasFlag(FbServiceTraceEvents.InitFini)));\n\t\tsb.AppendLine();\n\t\tsb.AppendLine(\"</services>\");\n\t\treturn sb.ToString();\n\t}\n\tstring BuildConfiguration2()\n\t{\n\t\tvar sb = new StringBuilder();\n\t\tsb.AppendLine(\"services\");\n\t\tsb.AppendLine(\"{\");\n\t\tsb.AppendFormat(\"enabled = {0}\", WriteBoolValue(Enabled));\n\t\tsb.AppendLine();\n\t\tif (!string.IsNullOrEmpty(IncludeFilter))\n\t\t{\n\t\t\tsb.AppendFormat(\"include_filter = {0}\", WriteRegEx(IncludeFilter));\n\t\t\tsb.AppendLine();\n\t\t}\n\t\tif (!string.IsNullOrEmpty(ExcludeFilter))\n\t\t{\n\t\t\tsb.AppendFormat(\"exclude_filter = {0}\", WriteRegEx(ExcludeFilter));\n\t\t\tsb.AppendLine();\n\t\t}\n\t\tif (!string.IsNullOrEmpty(IncludeGdsCodes))\n\t\t{\n\t\t\tsb.AppendFormat(\"include_gds_codes = {0}\", WriteString(IncludeGdsCodes));\n\t\t\tsb.AppendLine();\n\t\t}\n\t\tif (!string.IsNullOrEmpty(ExcludeGdsCodes))\n\t\t{\n\t\t\tsb.AppendFormat(\"exclude_gds_codes = {0}\", WriteString(ExcludeGdsCodes));\n\t\t\tsb.AppendLine();\n\t\t}\n\t\tsb.AppendFormat(\"log_services = {0}\", WriteBoolValue(Events.HasFlag(FbServiceTraceEvents.Services)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_service_query = {0}\", WriteBoolValue(Events.HasFlag(FbServiceTraceEvents.ServiceQuery)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_errors = {0}\", WriteBoolValue(Events.HasFlag(FbServiceTraceEvents.Errors)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_warnings = {0}\", WriteBoolValue(Events.HasFlag(FbServiceTraceEvents.Warnings)));\n\t\tsb.AppendLine();\n\t\tsb.AppendFormat(\"log_initfini = {0}\", WriteBoolValue(Events.HasFlag(FbServiceTraceEvents.InitFini)));\n\t\tsb.AppendLine();\n\t\tsb.AppendLine(\"}\");\n\t\treturn sb.ToString();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbServiceTraceEvents.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.Services;\n\n[Flags]\npublic enum FbServiceTraceEvents\n{\n\tServices = 0x01,\n\tServiceQuery = 0x02,\n\tErrors = 0x04,\n\tWarnings = 0x08,\n\tInitFini = 0x10,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbShutdownMode.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez\n\nusing System;\n\nnamespace FirebirdSql.Data.Services;\n\npublic enum FbShutdownMode\n{\n\tForced,\n\tDenyTransaction,\n\tDenyConnection\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbShutdownOnlineMode.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.Services;\n\npublic enum FbShutdownOnlineMode\n{\n\tNormal,\n\tMulti,\n\tSingle,\n\tFull,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbShutdownType.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.Services;\n\npublic enum FbShutdownType\n{\n\tForceShutdown,\n\tAttachmentsShutdown,\n\tTransactionsShutdown,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbStatistical.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Services;\n\npublic sealed class FbStatistical : FbService\n{\n\tpublic FbStatisticalFlags Options { get; set; }\n\n\tpublic FbStatistical(string connectionString = null)\n\t\t: base(connectionString)\n\t{ }\n\n\tpublic void Execute()\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_db_stats);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, (int)Options);\n\t\t\t\tStartTask(startSpb);\n\t\t\t\tProcessServiceOutput(new ServiceParameterBuffer2(Service.ParameterBufferEncoding));\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task ExecuteAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_db_stats);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, (int)Options);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ProcessServiceOutputAsync(new ServiceParameterBuffer2(Service.ParameterBufferEncoding), cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbStatisticalFlags.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.ComponentModel;\n\nnamespace FirebirdSql.Data.Services;\n\n/// <summary>\n/// Flags used by FbStatistical.Options\n/// </summary>\n[Flags]\npublic enum FbStatisticalFlags\n{\n\t/// <summary>\n\t/// analyze data pages\n\t/// </summary>\n\tDataPages = 0x01,\n\n\t/// <summary>\n\t/// DatabaseLog - no longer used by firebird\n\t/// </summary>\n\tDatabaseLog = 0x02,\n\n\t/// <summary>\n\t/// analyze header page ONLY\n\t/// </summary>\n\tHeaderPages = 0x04,\n\n\t/// <summary>\n\t/// analyze index leaf pages\n\t/// </summary>\n\tIndexPages = 0x08,\n\n\t/// <summary>\n\t/// analyze system relations in addition to user tables\n\t/// </summary>\n\tSystemTablesRelations = 0x10,\n\n\t/// <summary>\n\t/// analyze average record and version length\n\t/// </summary>\n\tRecordVersionStatistics = 0x20,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbStreamingBackup.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Services;\n\npublic sealed class FbStreamingBackup : FbService\n{\n\tpublic string SkipData { get; set; }\n\tpublic FbBackupFlags Options { get; set; }\n\tpublic Stream OutputStream { get; set; }\n\n\tpublic FbStreamingBackup(string connectionString = null)\n\t\t: base(connectionString)\n\t{ }\n\n\tpublic void Execute()\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_backup);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_bkp_file, \"stdout\");\n\t\t\t\tif (!string.IsNullOrEmpty(SkipData))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_bkp_skip_data, SkipData);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, (int)Options);\n\t\t\t\tif (ConnectionStringOptions.ParallelWorkers > 0)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_bkp_parallel_workers, ConnectionStringOptions.ParallelWorkers);\n\t\t\t\tStartTask(startSpb);\n\t\t\t\tReadOutput();\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task ExecuteAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_backup);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_bkp_file, \"stdout\");\n\t\t\t\tif (!string.IsNullOrEmpty(SkipData))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_bkp_skip_data, SkipData);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, (int)Options);\n\t\t\t\tif (ConnectionStringOptions.ParallelWorkers > 0)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_bkp_parallel_workers, ConnectionStringOptions.ParallelWorkers);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ReadOutputAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tvoid ReadOutput()\n\t{\n\t\tQuery(new byte[] { IscCodes.isc_info_svc_to_eof }, new ServiceParameterBuffer2(Service.ParameterBufferEncoding), (_, x) =>\n\t\t{\n\t\t\tvar buffer = x as byte[];\n\t\t\tOutputStream.Write(buffer, 0, buffer.Length);\n\t\t});\n\t}\n\tTask ReadOutputAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn QueryAsync(new byte[] { IscCodes.isc_info_svc_to_eof }, new ServiceParameterBuffer2(Service.ParameterBufferEncoding), async (_, x) =>\n\t\t{\n\t\t\tvar buffer = x as byte[];\n\t\t\tawait OutputStream.WriteAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false);\n\t\t}, cancellationToken);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbStreamingRestore.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.IO;\nusing System.Linq;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Services;\n\npublic class FbStreamingRestore : FbService\n{\n\tprivate int? _pageSize;\n\tpublic int? PageSize\n\t{\n\t\tget { return _pageSize; }\n\t\tset\n\t\t{\n\t\t\tif (value is int v && !SizeHelper.IsValidPageSize(v))\n\t\t\t\tthrow SizeHelper.InvalidSizeException(\"page size\");\n\n\t\t\t_pageSize = value;\n\t\t}\n\t}\n\n\tpublic Stream InputStream { get; set; }\n\tpublic bool Verbose { get; set; }\n\tpublic int? VerboseInterval { get; set; }\n\tpublic int? PageBuffers { get; set; }\n\tpublic bool ReadOnly { get; set; }\n\tpublic string SkipData { get; set; }\n\tpublic FbRestoreFlags Options { get; set; }\n\n\tpublic FbStreamingRestore(string connectionString = null)\n\t\t: base(connectionString)\n\t{ }\n\n\tpublic void Execute()\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_restore);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_bkp_file, \"stdin\");\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tif (Verbose)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_verbose);\n\t\t\t\tif (VerboseInterval.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_verbint, (int)VerboseInterval);\n\t\t\t\tif (PageBuffers.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_res_buffers, (int)PageBuffers);\n\t\t\t\tif (_pageSize.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_res_page_size, (int)_pageSize);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_res_access_mode, (byte)(ReadOnly ? IscCodes.isc_spb_res_am_readonly : IscCodes.isc_spb_res_am_readwrite));\n\t\t\t\tif (!string.IsNullOrEmpty(SkipData))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_res_skip_data, SkipData);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, (int)Options);\n\t\t\t\tif (ConnectionStringOptions.ParallelWorkers > 0)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_res_parallel_workers, ConnectionStringOptions.ParallelWorkers);\n\t\t\t\tStartTask(startSpb);\n\t\t\t\tReadInput();\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task ExecuteAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_restore);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_bkp_file, \"stdin\");\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tif (Verbose)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_verbose);\n\t\t\t\tif (VerboseInterval.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_verbint, (int)VerboseInterval);\n\t\t\t\tif (PageBuffers.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_res_buffers, (int)PageBuffers);\n\t\t\t\tif (_pageSize.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_res_page_size, (int)_pageSize);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_res_access_mode, (byte)(ReadOnly ? IscCodes.isc_spb_res_am_readonly : IscCodes.isc_spb_res_am_readwrite));\n\t\t\t\tif (!string.IsNullOrEmpty(SkipData))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_res_skip_data, SkipData);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, (int)Options);\n\t\t\t\tif (ConnectionStringOptions.ParallelWorkers > 0)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_res_parallel_workers, ConnectionStringOptions.ParallelWorkers);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ReadInputAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tvoid ReadInput()\n\t{\n\t\tvar items = new byte[] { IscCodes.isc_info_svc_stdin, IscCodes.isc_info_svc_line };\n\t\tvar spb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\tvar response = Query(items, spb);\n\t\tvar requestedLength = GetLength(response);\n\t\twhile (true)\n\t\t{\n\t\t\tif (requestedLength > 0)\n\t\t\t{\n\t\t\t\tvar data = new byte[requestedLength];\n\t\t\t\tvar read = InputStream.Read(data, 0, requestedLength);\n\t\t\t\tif (read > 0)\n\t\t\t\t{\n\t\t\t\t\tArray.Resize(ref data, read);\n\t\t\t\t\tspb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\t\tspb.Append2(IscCodes.isc_info_svc_line, data);\n\t\t\t\t}\n\t\t\t}\n\t\t\tresponse = Query(items, spb);\n\t\t\tif (response.Count == 1)\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (response[1] is string message)\n\t\t\t{\n\t\t\t\tOnServiceOutput(message);\n\t\t\t}\n\t\t\trequestedLength = GetLength(response);\n\t\t\tspb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t}\n\t}\n\tasync Task ReadInputAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar items = new byte[] { IscCodes.isc_info_svc_stdin, IscCodes.isc_info_svc_line };\n\t\tvar spb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\tvar response = await QueryAsync(items, spb, cancellationToken).ConfigureAwait(false);\n\t\tvar requestedLength = GetLength(response);\n\t\twhile (true)\n\t\t{\n\t\t\tif (requestedLength > 0)\n\t\t\t{\n\t\t\t\tvar data = new byte[requestedLength];\n\t\t\t\tvar read = await InputStream.ReadAsync(data, 0, requestedLength).ConfigureAwait(false);\n\t\t\t\tif (read > 0)\n\t\t\t\t{\n\t\t\t\t\tArray.Resize(ref data, read);\n\t\t\t\t\tspb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\t\tspb.Append2(IscCodes.isc_info_svc_line, data);\n\t\t\t\t}\n\t\t\t}\n\t\t\tresponse = await QueryAsync(items, spb, cancellationToken).ConfigureAwait(false);\n\t\t\tif (response.Count == 1)\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (response[1] is string message)\n\t\t\t{\n\t\t\t\tOnServiceOutput(message);\n\t\t\t}\n\t\t\trequestedLength = GetLength(response);\n\t\t\tspb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t}\n\t}\n\n\tstatic int GetLength(IList<object> items)\n\t{\n\t\t// minus the size of isc code\n\t\tconst int MaxLength = IscCodes.BUFFER_SIZE_32K - 4;\n\t\treturn Math.Min((int)items[0], MaxLength);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbTrace.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Services;\n\npublic sealed class FbTrace : FbService\n{\n\tFbTraceVersion _version;\n\n\tpublic FbDatabaseTraceConfigurationCollection DatabasesConfigurations { get; }\n\tpublic FbServiceTraceConfiguration ServiceConfiguration { get; set; }\n\n\tpublic FbTrace(FbTraceVersion version = FbTraceVersion.Detect, string connectionString = null)\n\t\t: base(connectionString)\n\t{\n\t\t_version = version;\n\t\tDatabasesConfigurations = new FbDatabaseTraceConfigurationCollection();\n\t}\n\n\tpublic void Start(string sessionName)\n\t{\n\t\tvar version = _version;\n\t\tif (version == FbTraceVersion.Detect)\n\t\t{\n\t\t\tversion = DetectVersion();\n\t\t}\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tvar config = string.Join(Environment.NewLine, DatabasesConfigurations.BuildConfiguration(version), ServiceConfiguration?.BuildConfiguration(version) ?? string.Empty);\n\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_trace_start);\n\t\t\t\tif (!string.IsNullOrEmpty(sessionName))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_trc_name, sessionName);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_trc_cfg, config);\n\t\t\t\tStartTask(startSpb);\n\t\t\t\tProcessServiceOutput(new ServiceParameterBuffer2(Service.ParameterBufferEncoding));\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task StartAsync(string sessionName, CancellationToken cancellationToken = default)\n\t{\n\t\tvar version = _version;\n\t\tif (version == FbTraceVersion.Detect)\n\t\t{\n\t\t\tversion = await DetectVersionAsync(cancellationToken).ConfigureAwait(false);\n\t\t}\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tvar config = string.Join(Environment.NewLine, DatabasesConfigurations.BuildConfiguration(version), ServiceConfiguration?.BuildConfiguration(version) ?? string.Empty);\n\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_trace_start);\n\t\t\t\tif (!string.IsNullOrEmpty(sessionName))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_trc_name, sessionName);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_trc_cfg, config);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ProcessServiceOutputAsync(new ServiceParameterBuffer2(Service.ParameterBufferEncoding), cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tpublic void Stop(int sessionID)\n\t{\n\t\tDoSimpleAction(IscCodes.isc_action_svc_trace_stop, sessionID);\n\t}\n\tpublic Task StopAsync(int sessionID, CancellationToken cancellationToken = default)\n\t{\n\t\treturn DoSimpleActionAsync(IscCodes.isc_action_svc_trace_stop, sessionID, cancellationToken);\n\t}\n\n\tpublic void Suspend(int sessionID)\n\t{\n\t\tDoSimpleAction(IscCodes.isc_action_svc_trace_suspend, sessionID);\n\t}\n\tpublic Task SuspendAsync(int sessionID, CancellationToken cancellationToken = default)\n\t{\n\t\treturn DoSimpleActionAsync(IscCodes.isc_action_svc_trace_suspend, sessionID, cancellationToken);\n\t}\n\n\tpublic void Resume(int sessionID)\n\t{\n\t\tDoSimpleAction(IscCodes.isc_action_svc_trace_resume, sessionID);\n\t}\n\tpublic Task ResumeAsync(int sessionID, CancellationToken cancellationToken = default)\n\t{\n\t\treturn DoSimpleActionAsync(IscCodes.isc_action_svc_trace_resume, sessionID, cancellationToken);\n\t}\n\n\tpublic void List()\n\t{\n\t\tDoSimpleAction(IscCodes.isc_action_svc_trace_list, null);\n\t}\n\tpublic Task ListAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn DoSimpleActionAsync(IscCodes.isc_action_svc_trace_list, null, cancellationToken);\n\t}\n\n\tvoid DoSimpleAction(int action, int? sessionID)\n\t{\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(action);\n\t\t\t\tif (sessionID.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_trc_id, (int)sessionID);\n\t\t\t\tStartTask(startSpb);\n\t\t\t\tProcessServiceOutput(new ServiceParameterBuffer2(Service.ParameterBufferEncoding));\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tasync Task DoSimpleActionAsync(int action, int? sessionID, CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(action);\n\t\t\t\tif (sessionID.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_trc_id, (int)sessionID);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ProcessServiceOutputAsync(new ServiceParameterBuffer2(Service.ParameterBufferEncoding), cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\n\tFbTraceVersion DetectVersion()\n\t{\n\t\tvar serverProperties = new FbServerProperties(ConnectionString);\n\t\tvar serverVersion = FbServerProperties.ParseServerVersion(serverProperties.GetServerVersion());\n\t\tif (serverVersion < new Version(3, 0, 0, 0))\n\t\t\treturn FbTraceVersion.Version1;\n\t\telse\n\t\t\treturn FbTraceVersion.Version2;\n\t}\n\tasync Task<FbTraceVersion> DetectVersionAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tvar serverProperties = new FbServerProperties(ConnectionString);\n\t\tvar serverVersion = FbServerProperties.ParseServerVersion(await serverProperties.GetServerVersionAsync(cancellationToken).ConfigureAwait(false));\n\t\tif (serverVersion < new Version(3, 0, 0, 0))\n\t\t\treturn FbTraceVersion.Version1;\n\t\telse\n\t\t\treturn FbTraceVersion.Version2;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbTraceConfiguration.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Globalization;\n\nnamespace FirebirdSql.Data.Services;\n\npublic abstract class FbTraceConfiguration\n{\n\tprotected static string WriteBoolValue(bool b)\n\t{\n\t\treturn b ? \"true\" : \"false\";\n\t}\n\n\tprotected static string WriteString(string s)\n\t{\n\t\ts = s\n\t\t\t.Replace(\"{\", \"{{\")\n\t\t\t.Replace(\"}\", \"}}\")\n\t\t\t.Replace(@\"\\\", @\"\\\\\")\n\t\t\t.Replace(\"\\\"\", \"\\\\\\\"\");\n\t\treturn string.Format(\"\\\"{0}\\\"\", s);\n\t}\n\n\tprotected static string WriteNumber(int i)\n\t{\n\t\treturn i.ToString(CultureInfo.InvariantCulture);\n\t}\n\n\tprotected static string WriteRegEx(string re)\n\t{\n\t\treturn WriteString(re);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbTraceVersion.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nnamespace FirebirdSql.Data.Services;\n\npublic enum FbTraceVersion\n{\n\tDetect,\n\tVersion1,\n\tVersion2,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbUserData.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez\n\nusing System;\n\nnamespace FirebirdSql.Data.Services;\n\npublic sealed class FbUserData\n{\n\tprivate string _userName;\n\tpublic string UserName\n\t{\n\t\tget { return _userName; }\n\t\tset\n\t\t{\n\t\t\tif (value == null)\n\t\t\t\tthrow new InvalidOperationException(\"The user name cannot be null.\");\n\t\t\tif (value.Length > 31)\n\t\t\t\tthrow new InvalidOperationException(\"The user name cannot have more than 31 characters.\");\n\t\t\t_userName = value;\n\t\t}\n\t}\n\n\tprivate string _userPassword;\n\tpublic string UserPassword\n\t{\n\t\tget { return _userPassword; }\n\t\tset\n\t\t{\n\t\t\tif (value == null)\n\t\t\t\tthrow new InvalidOperationException(\"The user password cannot be null.\");\n\t\t\tif (value.Length > 31)\n\t\t\t\tthrow new InvalidOperationException(\"The user password cannot have more than 31 characters.\");\n\t\t\t_userPassword = value;\n\t\t}\n\t}\n\n\tpublic string FirstName { get; set; }\n\tpublic string LastName { get; set; }\n\tpublic string MiddleName { get; set; }\n\tpublic int UserID { get; set; }\n\tpublic int GroupID { get; set; }\n\tpublic string GroupName { get; set; }\n\tpublic string RoleName { get; set; }\n\n\tpublic FbUserData()\n\t{\n\t\tUserName = string.Empty;\n\t\tUserPassword = string.Empty;\n\t\tFirstName = string.Empty;\n\t\tLastName = string.Empty;\n\t\tMiddleName = string.Empty;\n\t\tRoleName = string.Empty;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbValidation.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Services;\n\npublic sealed class FbValidation : FbService\n{\n\tpublic FbValidationFlags Options { get; set; }\n\n\tpublic FbValidation(string connectionString = null)\n\t\t: base(connectionString)\n\t{ }\n\n\tpublic void Execute()\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_repair);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, (int)Options);\n\t\t\t\tif (ConnectionStringOptions.ParallelWorkers > 0)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_rpr_par_workers, ConnectionStringOptions.ParallelWorkers);\n\t\t\t\tStartTask(startSpb);\n\t\t\t\tProcessServiceOutput(new ServiceParameterBuffer2(Service.ParameterBufferEncoding));\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task ExecuteAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_repair);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tstartSpb.Append(IscCodes.isc_spb_options, (int)Options);\n\t\t\t\tif (ConnectionStringOptions.ParallelWorkers > 0)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_rpr_par_workers, ConnectionStringOptions.ParallelWorkers);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ProcessServiceOutputAsync(new ServiceParameterBuffer2(Service.ParameterBufferEncoding), cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbValidation2.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace FirebirdSql.Data.Services;\n\npublic sealed class FbValidation2 : FbService\n{\n\tpublic string TablesInclude { get; set; }\n\tpublic string TablesExclude { get; set; }\n\tpublic string IndicesInclude { get; set; }\n\tpublic string IndicesExclude { get; set; }\n\tpublic int? LockTimeout { get; set; }\n\n\tpublic FbValidation2(string connectionString = null)\n\t\t: base(connectionString)\n\t{ }\n\n\tpublic void Execute()\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tOpen();\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_validate);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tif (!string.IsNullOrEmpty(TablesInclude))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_val_tab_incl, TablesInclude);\n\t\t\t\tif (!string.IsNullOrEmpty(TablesExclude))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_val_tab_excl, TablesExclude);\n\t\t\t\tif (!string.IsNullOrEmpty(IndicesInclude))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_val_idx_incl, IndicesInclude);\n\t\t\t\tif (!string.IsNullOrEmpty(IndicesExclude))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_val_idx_excl, IndicesExclude);\n\t\t\t\tif (LockTimeout.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_val_lock_timeout, (int)LockTimeout);\n\t\t\t\tStartTask(startSpb);\n\t\t\t\tProcessServiceOutput(new ServiceParameterBuffer2(Service.ParameterBufferEncoding));\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tClose();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n\tpublic async Task ExecuteAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tEnsureDatabase();\n\n\t\ttry\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t\tvar startSpb = new ServiceParameterBuffer2(Service.ParameterBufferEncoding);\n\t\t\t\tstartSpb.Append(IscCodes.isc_action_svc_validate);\n\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_dbname, ConnectionStringOptions.Database);\n\t\t\t\tif (!string.IsNullOrEmpty(TablesInclude))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_val_tab_incl, TablesInclude);\n\t\t\t\tif (!string.IsNullOrEmpty(TablesExclude))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_val_tab_excl, TablesExclude);\n\t\t\t\tif (!string.IsNullOrEmpty(IndicesInclude))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_val_idx_incl, IndicesInclude);\n\t\t\t\tif (!string.IsNullOrEmpty(IndicesExclude))\n\t\t\t\t\tstartSpb.Append2(IscCodes.isc_spb_val_idx_excl, IndicesExclude);\n\t\t\t\tif (LockTimeout.HasValue)\n\t\t\t\t\tstartSpb.Append(IscCodes.isc_spb_val_lock_timeout, (int)LockTimeout);\n\t\t\t\tawait StartTaskAsync(startSpb, cancellationToken).ConfigureAwait(false);\n\t\t\t\tawait ProcessServiceOutputAsync(new ServiceParameterBuffer2(Service.ParameterBufferEncoding), cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait CloseAsync(cancellationToken).ConfigureAwait(false);\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tthrow FbException.Create(ex);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/FbValidationFlags.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez\n\nusing System;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Services;\n\n[Flags]\npublic enum FbValidationFlags\n{\n\tValidateDatabase = IscCodes.isc_spb_rpr_validate_db,\n\tSweepDatabase = IscCodes.isc_spb_rpr_sweep_db,\n\tMendDatabase = IscCodes.isc_spb_rpr_mend_db,\n\tCheckDatabase = IscCodes.isc_spb_rpr_check_db,\n\tIgnoreChecksum = IscCodes.isc_spb_rpr_ignore_checksum,\n\tKillShadows = IscCodes.isc_spb_rpr_kill_shadows,\n\tFull = IscCodes.isc_spb_rpr_full,\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Services/ServiceOutputEventArgs.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\n\nnamespace FirebirdSql.Data.Services;\n\npublic sealed class ServiceOutputEventArgs : EventArgs\n{\n\tpublic string Message { get; }\n\n\tpublic ServiceOutputEventArgs(string message)\n\t{\n\t\tMessage = message;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Types/FbDecFloat.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Globalization;\nusing System.Numerics;\nusing System.Runtime.InteropServices;\nusing FirebirdSql.Data.Common;\n\nnamespace FirebirdSql.Data.Types;\n\n[StructLayout(LayoutKind.Auto)]\npublic readonly struct FbDecFloat : IEquatable<FbDecFloat>\n{\n\tinternal DecimalType Type { get; }\n\tinternal bool Negative { get; }\n\tpublic BigInteger Coefficient { get; }\n\tpublic int Exponent { get; }\n\n\tpublic static FbDecFloat NegativeZero { get; } = new FbDecFloat(DecimalType.Finite, true, BigInteger.Zero, 0);\n\tpublic static FbDecFloat PositiveInfinity { get; } = new FbDecFloat(DecimalType.Infinity, false, default, default);\n\tpublic static FbDecFloat NegativeInfinity { get; } = new FbDecFloat(DecimalType.Infinity, true, default, default);\n\tpublic static FbDecFloat PositiveNaN { get; } = new FbDecFloat(DecimalType.NaN, false, default, default);\n\tpublic static FbDecFloat NegativeNaN { get; } = new FbDecFloat(DecimalType.NaN, true, default, default);\n\tpublic static FbDecFloat PositiveSignalingNaN { get; } = new FbDecFloat(DecimalType.SignalingNaN, false, default, default);\n\tpublic static FbDecFloat NegativeSignalingNaN { get; } = new FbDecFloat(DecimalType.SignalingNaN, true, default, default);\n\n\tinternal FbDecFloat(DecimalType type, bool negative, BigInteger coefficient, int exponent)\n\t{\n\t\tType = type;\n\t\tNegative = negative;\n\t\tCoefficient = coefficient;\n\t\tExponent = exponent;\n\t}\n\n\tpublic FbDecFloat(BigInteger coefficient, int exponent = 0)\n\t\t: this(DecimalType.Finite, coefficient.Sign == -1, coefficient, exponent)\n\t{ }\n\n\tpublic static implicit operator FbDecFloat(byte value) => new FbDecFloat(value);\n\tpublic static implicit operator FbDecFloat(sbyte value) => new FbDecFloat(value);\n\tpublic static implicit operator FbDecFloat(short value) => new FbDecFloat(value);\n\tpublic static implicit operator FbDecFloat(ushort value) => new FbDecFloat(value);\n\tpublic static implicit operator FbDecFloat(int value) => new FbDecFloat(value);\n\tpublic static implicit operator FbDecFloat(uint value) => new FbDecFloat(value);\n\tpublic static implicit operator FbDecFloat(long value) => new FbDecFloat(value);\n\tpublic static implicit operator FbDecFloat(ulong value) => new FbDecFloat(value);\n\tpublic static explicit operator FbDecFloat(float value) => value switch\n\t{\n\t\tfloat.NaN => PositiveNaN,\n\t\tfloat.PositiveInfinity => PositiveInfinity,\n\t\tfloat.NegativeInfinity => NegativeInfinity,\n\t\t_ => ParseNumber(value, \"0.#######\"),\n\t};\n\tpublic static explicit operator FbDecFloat(double value) => value switch\n\t{\n\t\tdouble.NaN => PositiveNaN,\n\t\tdouble.PositiveInfinity => PositiveInfinity,\n\t\tdouble.NegativeInfinity => NegativeInfinity,\n\t\t_ => ParseNumber(value, \"0.###############\"),\n\t};\n\tpublic static explicit operator FbDecFloat(decimal value) => ParseNumber(value, \"0.############################\");\n\n\tpublic override string ToString()\n\t{\n\t\tif (this == NegativeZero)\n\t\t{\n\t\t\treturn \"-0\";\n\t\t}\n\t\tif (this == PositiveInfinity)\n\t\t{\n\t\t\treturn \"inf\";\n\t\t}\n\t\tif (this == NegativeInfinity)\n\t\t{\n\t\t\treturn \"-inf\";\n\t\t}\n\t\tif (this == PositiveNaN)\n\t\t{\n\t\t\treturn \"nan\";\n\t\t}\n\t\tif (this == PositiveSignalingNaN)\n\t\t{\n\t\t\treturn \"snan\";\n\t\t}\n\t\tif (this == NegativeNaN)\n\t\t{\n\t\t\treturn \"-nan\";\n\t\t}\n\t\tif (this == NegativeSignalingNaN)\n\t\t{\n\t\t\treturn \"-snan\";\n\t\t}\n\t\treturn $\"{Coefficient}E{Exponent}\";\n\t}\n\n\tpublic override bool Equals(object obj)\n\t{\n\t\treturn obj is FbDecFloat fbDecFloat && Equals(fbDecFloat);\n\t}\n\n\tpublic override int GetHashCode()\n\t{\n\t\tunchecked\n\t\t{\n\t\t\tvar hash = (int)2166136261;\n\t\t\thash = (hash * 16777619) ^ Type.GetHashCode();\n\t\t\thash = (hash * 16777619) ^ Negative.GetHashCode();\n\t\t\thash = (hash * 16777619) ^ Coefficient.GetHashCode();\n\t\t\thash = (hash * 16777619) ^ Exponent.GetHashCode();\n\t\t\treturn hash;\n\t\t}\n\t}\n\n\tpublic bool Equals(FbDecFloat other)\n\t{\n\t\tif (!(Type.Equals(other.Type) && Negative.Equals(other.Negative)))\n\t\t\treturn false;\n\t\tif (Coefficient.Equals(other.Coefficient) && Exponent.Equals(other.Exponent))\n\t\t\treturn true;\n\t\tif (Exponent < other.Exponent)\n\t\t{\n\t\t\tvar difference = other.Exponent - Exponent;\n\t\t\tvar value = other.Coefficient * BigInteger.Pow(10, difference);\n\t\t\treturn value.Equals(Coefficient);\n\t\t}\n\t\tif (Exponent > other.Exponent)\n\t\t{\n\t\t\tvar difference = Exponent - other.Exponent;\n\t\t\tvar value = Coefficient * BigInteger.Pow(10, difference);\n\t\t\treturn value.Equals(other.Coefficient);\n\t\t}\n\t\treturn false;\n\t}\n\n\tpublic static bool operator ==(FbDecFloat lhs, FbDecFloat rhs)\n\t{\n\t\treturn lhs.Equals(rhs);\n\t}\n\n\tpublic static bool operator !=(FbDecFloat lhs, FbDecFloat rhs)\n\t{\n\t\treturn lhs.Equals(rhs);\n\t}\n\n\tstatic FbDecFloat ParseNumber(IFormattable formattable, string format)\n\t{\n\t\tvar s = formattable.ToString(format, CultureInfo.InvariantCulture);\n\t\tvar pos = s.IndexOf('.');\n\t\treturn new FbDecFloat(BigInteger.Parse(s.Remove(pos, 1), CultureInfo.InvariantCulture), -(s.Length - pos - 1));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Types/FbZonedDateTime.cs",
    "content": "﻿/*\r\n *    The contents of this file are subject to the Initial\r\n *    Developer's Public License Version 1.0 (the \"License\");\r\n *    you may not use this file except in compliance with the\r\n *    License. You may obtain a copy of the License at\r\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\r\n *\r\n *    Software distributed under the License is distributed on\r\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\r\n *    express or implied. See the License for the specific\r\n *    language governing rights and limitations under the License.\r\n *\r\n *    All Rights Reserved.\r\n */\r\n\r\n//$Authors = Jiri Cincura (jiri@cincura.net)\r\n\r\nusing System;\r\nusing System.Runtime.InteropServices;\r\n\r\nnamespace FirebirdSql.Data.Types;\r\n\r\n[StructLayout(LayoutKind.Auto)]\r\npublic readonly struct FbZonedDateTime : IEquatable<FbZonedDateTime>, IConvertible\r\n{\r\n\tpublic DateTime DateTime { get; }\r\n\tpublic string TimeZone { get; }\r\n\tpublic TimeSpan? Offset { get; }\r\n\r\n\tinternal FbZonedDateTime(DateTime dateTime, string timeZone, TimeSpan? offset)\r\n\t{\r\n\t\tif (dateTime.Kind != DateTimeKind.Utc)\r\n\t\t\tthrow new ArgumentException(\"Value must be in UTC.\", nameof(dateTime));\r\n\t\tif (timeZone == null)\r\n\t\t\tthrow new ArgumentNullException(nameof(timeZone));\r\n\t\tif (string.IsNullOrWhiteSpace(timeZone))\r\n\t\t\tthrow new ArgumentException(nameof(timeZone));\r\n\r\n\t\tDateTime = dateTime;\r\n\t\tTimeZone = timeZone;\r\n\t\tOffset = offset;\r\n\t}\r\n\r\n\tpublic FbZonedDateTime(DateTime dateTime, string timeZone)\r\n\t\t: this(dateTime, timeZone, null)\r\n\t{ }\r\n\r\n\tpublic override string ToString()\r\n\t{\r\n\t\tif (Offset != null)\r\n\t\t{\r\n\t\t\treturn $\"{DateTime} {TimeZone} ({Offset})\";\r\n\t\t}\r\n\t\treturn $\"{DateTime} {TimeZone}\";\r\n\t}\r\n\r\n\tpublic override bool Equals(object obj)\r\n\t{\r\n\t\treturn obj is FbZonedDateTime fbZonedDateTime && Equals(fbZonedDateTime);\r\n\t}\r\n\r\n\tpublic override int GetHashCode()\r\n\t{\r\n\t\tunchecked\r\n\t\t{\r\n\t\t\tvar hash = (int)2166136261;\r\n\t\t\thash = (hash * 16777619) ^ DateTime.GetHashCode();\r\n\t\t\thash = (hash * 16777619) ^ TimeZone.GetHashCode();\r\n\t\t\tif (Offset != null)\r\n\t\t\t\thash = (hash * 16777619) ^ Offset.GetHashCode();\r\n\t\t\treturn hash;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic bool Equals(FbZonedDateTime other) => DateTime.Equals(other.DateTime) && TimeZone.Equals(other.TimeZone, StringComparison.OrdinalIgnoreCase);\r\n\r\n\tTypeCode IConvertible.GetTypeCode() => TypeCode.Object;\r\n\r\n\tDateTime IConvertible.ToDateTime(IFormatProvider provider) => DateTime;\r\n\r\n\tstring IConvertible.ToString(IFormatProvider provider) => ToString();\r\n\r\n\tobject IConvertible.ToType(Type conversionType, IFormatProvider provider)\r\n\t\t=> ReferenceEquals(conversionType, typeof(FbZonedDateTime))\r\n\t\t\t? this\r\n\t\t: throw new InvalidCastException(conversionType?.FullName);\r\n\r\n\tbool IConvertible.ToBoolean(IFormatProvider provider) => throw new InvalidCastException(nameof(Boolean));\r\n\tbyte IConvertible.ToByte(IFormatProvider provider) => throw new InvalidCastException(nameof(Byte));\r\n\tchar IConvertible.ToChar(IFormatProvider provider) => throw new InvalidCastException(nameof(Char));\r\n\tdecimal IConvertible.ToDecimal(IFormatProvider provider) => throw new InvalidCastException(nameof(Decimal));\r\n\tdouble IConvertible.ToDouble(IFormatProvider provider) => throw new InvalidCastException(nameof(Double));\r\n\tshort IConvertible.ToInt16(IFormatProvider provider) => throw new InvalidCastException(nameof(Int16));\r\n\tint IConvertible.ToInt32(IFormatProvider provider) => throw new InvalidCastException(nameof(Int32));\r\n\tlong IConvertible.ToInt64(IFormatProvider provider) => throw new InvalidCastException(nameof(Int64));\r\n\tsbyte IConvertible.ToSByte(IFormatProvider provider) => throw new InvalidCastException(nameof(SByte));\r\n\tfloat IConvertible.ToSingle(IFormatProvider provider) => throw new InvalidCastException(nameof(Single));\r\n\tushort IConvertible.ToUInt16(IFormatProvider provider) => throw new InvalidCastException(nameof(UInt16));\r\n\tuint IConvertible.ToUInt32(IFormatProvider provider) => throw new InvalidCastException(nameof(UInt32));\r\n\tulong IConvertible.ToUInt64(IFormatProvider provider) => throw new InvalidCastException(nameof(UInt64));\r\n\r\n\tpublic static bool operator ==(FbZonedDateTime lhs, FbZonedDateTime rhs) => lhs.Equals(rhs);\r\n\r\n\tpublic static bool operator !=(FbZonedDateTime lhs, FbZonedDateTime rhs) => lhs.Equals(rhs);\r\n}\r\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient/Types/FbZonedTime.cs",
    "content": "﻿/*\r\n *    The contents of this file are subject to the Initial\r\n *    Developer's Public License Version 1.0 (the \"License\");\r\n *    you may not use this file except in compliance with the\r\n *    License. You may obtain a copy of the License at\r\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\r\n *\r\n *    Software distributed under the License is distributed on\r\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\r\n *    express or implied. See the License for the specific\r\n *    language governing rights and limitations under the License.\r\n *\r\n *    All Rights Reserved.\r\n */\r\n\r\n//$Authors = Jiri Cincura (jiri@cincura.net)\r\n\r\nusing System;\r\nusing System.Runtime.InteropServices;\r\n\r\nnamespace FirebirdSql.Data.Types;\r\n\r\n[StructLayout(LayoutKind.Auto)]\r\npublic readonly struct FbZonedTime : IEquatable<FbZonedTime>, IConvertible\r\n{\r\n\tpublic TimeSpan Time { get; }\r\n\tpublic string TimeZone { get; }\r\n\tpublic TimeSpan? Offset { get; }\r\n\r\n\tinternal FbZonedTime(TimeSpan time, string timeZone, TimeSpan? offset)\r\n\t{\r\n\t\tif (timeZone == null)\r\n\t\t\tthrow new ArgumentNullException(nameof(timeZone));\r\n\t\tif (string.IsNullOrWhiteSpace(timeZone))\r\n\t\t\tthrow new ArgumentException(nameof(timeZone));\r\n\r\n\t\tTime = time;\r\n\t\tTimeZone = timeZone;\r\n\t\tOffset = offset;\r\n\t}\r\n\r\n\tpublic FbZonedTime(TimeSpan time, string timeZone)\r\n\t\t: this(time, timeZone, null)\r\n\t{ }\r\n\r\n\tpublic override string ToString()\r\n\t{\r\n\t\tif (Offset != null)\r\n\t\t{\r\n\t\t\treturn $\"{Time} {TimeZone} ({Offset})\";\r\n\t\t}\r\n\t\treturn $\"{Time} {TimeZone}\";\r\n\t}\r\n\r\n\tpublic override bool Equals(object obj)\r\n\t{\r\n\t\treturn obj is FbZonedTime fbZonedTime && Equals(fbZonedTime);\r\n\t}\r\n\r\n\tpublic override int GetHashCode()\r\n\t{\r\n\t\tunchecked\r\n\t\t{\r\n\t\t\tvar hash = (int)2166136261;\r\n\t\t\thash = (hash * 16777619) ^ Time.GetHashCode();\r\n\t\t\thash = (hash * 16777619) ^ TimeZone.GetHashCode();\r\n\t\t\tif (Offset != null)\r\n\t\t\t\thash = (hash * 16777619) ^ Offset.GetHashCode();\r\n\t\t\treturn hash;\r\n\t\t}\r\n\t}\r\n\r\n\tpublic bool Equals(FbZonedTime other) => Time.Equals(other.Time) && TimeZone.Equals(other.TimeZone, StringComparison.OrdinalIgnoreCase);\r\n\r\n\tTypeCode IConvertible.GetTypeCode() => TypeCode.Object;\r\n\r\n\tstring IConvertible.ToString(IFormatProvider provider) => ToString();\r\n\r\n\tobject IConvertible.ToType(Type conversionType, IFormatProvider provider)\r\n\t\t=> ReferenceEquals(conversionType, typeof(FbZonedTime))\r\n\t\t\t? this\r\n\t\t\t: ReferenceEquals(conversionType, typeof(TimeSpan))\r\n\t\t\t\t? Time\r\n\t\t\t\t: throw new InvalidCastException(conversionType?.FullName);\r\n\r\n\tbool IConvertible.ToBoolean(IFormatProvider provider) => throw new InvalidCastException(nameof(Boolean));\r\n\tbyte IConvertible.ToByte(IFormatProvider provider) => throw new InvalidCastException(nameof(Byte));\r\n\tchar IConvertible.ToChar(IFormatProvider provider) => throw new InvalidCastException(nameof(Char));\r\n\tDateTime IConvertible.ToDateTime(IFormatProvider provider) => throw new InvalidCastException(nameof(DateTime));\r\n\tdecimal IConvertible.ToDecimal(IFormatProvider provider) => throw new InvalidCastException(nameof(Decimal));\r\n\tdouble IConvertible.ToDouble(IFormatProvider provider) => throw new InvalidCastException(nameof(Double));\r\n\tshort IConvertible.ToInt16(IFormatProvider provider) => throw new InvalidCastException(nameof(Int16));\r\n\tint IConvertible.ToInt32(IFormatProvider provider) => throw new InvalidCastException(nameof(Int32));\r\n\tlong IConvertible.ToInt64(IFormatProvider provider) => throw new InvalidCastException(nameof(Int64));\r\n\tsbyte IConvertible.ToSByte(IFormatProvider provider) => throw new InvalidCastException(nameof(SByte));\r\n\tfloat IConvertible.ToSingle(IFormatProvider provider) => throw new InvalidCastException(nameof(Single));\r\n\tushort IConvertible.ToUInt16(IFormatProvider provider) => throw new InvalidCastException(nameof(UInt16));\r\n\tuint IConvertible.ToUInt32(IFormatProvider provider) => throw new InvalidCastException(nameof(UInt32));\r\n\tulong IConvertible.ToUInt64(IFormatProvider provider) => throw new InvalidCastException(nameof(UInt64));\r\n\r\n\tpublic static bool operator ==(FbZonedTime lhs, FbZonedTime rhs) => lhs.Equals(rhs);\r\n\r\n\tpublic static bool operator !=(FbZonedTime lhs, FbZonedTime rhs) => lhs.Equals(rhs);\r\n}\r\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/AuthBlockTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Mark Rotteveel\n\nusing System.Collections.Generic;\nusing FirebirdSql.Data.Client.Managed;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[NoServerCategory]\npublic class AuthBlockTests\n{\n\tstatic IEnumerable<TestCaseData> NormalizeLoginTestSource()\n\t{\n\t\tyield return new TestCaseData(\"sysdba\").Returns(\"SYSDBA\");\n\t\tyield return new TestCaseData(\"s\").Returns(\"S\");\n\t\tyield return new TestCaseData(\"\\\"CaseSensitive\\\"\").Returns(\"CaseSensitive\");\n\t\tyield return new TestCaseData(\"\\\"s\\\"\").Returns(\"s\");\n\t\tyield return new TestCaseData(\"\\\"With\\\"\\\"EscapedQuote\\\"\").Returns(\"With\\\"EscapedQuote\");\n\t\tyield return new TestCaseData(\"\\\"Invalid\\\"Escape\\\"\").Returns(\"Invalid\");\n\t\tyield return new TestCaseData(\"\\\"DanglingInvalidEscape\\\"\\\"\").Returns(\"DanglingInvalidEscape\");\n\t\tyield return new TestCaseData(\"\\\"EscapedQuoteAtEnd\\\"\\\"\\\"\").Returns(\"EscapedQuoteAtEnd\\\"\");\n\t\tyield return new TestCaseData(\"\\\"StartNoEndQuote\").Returns(\"\\\"STARTNOENDQUOTE\");\n\t\tyield return new TestCaseData(\"\\\"\\\"\").Returns(\"\\\"\\\"\");\n\t\tyield return new TestCaseData(\"\").Returns(\"\");\n\t\tyield return new TestCaseData(null).Returns(null);\n\t}\n\t[TestCaseSource(nameof(NormalizeLoginTestSource))]\n\tpublic string NormalizeLoginTest(string login)\n\t{\n\t\treturn AuthBlock.NormalizeLogin(login);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/BlobStreamTests.cs",
    "content": "﻿using System.IO;\nusing System.Security.Cryptography;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class BlobStreamTests : FbTestsBase\n{\n\tpublic BlobStreamTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic async Task FbBlobStreamReadTest()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tvar insert_values = RandomNumberGenerator.GetBytes(100000 * 4);\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, blob_field) values(@int_field, @blob_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@blob_field\", FbDbType.Binary).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT blob_field FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tawait using var reader = await select.ExecuteReaderAsync();\n\t\t\twhile (await reader.ReadAsync())\n\t\t\t{\n\t\t\t\tawait using var output = new MemoryStream();\n\t\t\t\tawait using (var stream = reader.GetStream(0))\n\t\t\t\t{\n\t\t\t\t\tawait stream.CopyToAsync(output);\n\t\t\t\t}\n\n\t\t\t\tvar select_values = output.ToArray();\n\t\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task FbBlobStreamWriteTest()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tvar insert_values = RandomNumberGenerator.GetBytes(100000 * 4);\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, blob_field) values(@int_field, @blob_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@blob_field\", FbDbType.Binary).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\n\t\t\tawait using (var select = new FbCommand($\"SELECT blob_field FROM TEST WHERE int_field = {id_value}\", Connection, transaction))\n\t\t\t{\n\t\t\t\tawait using var reader = await select.ExecuteReaderAsync();\n\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tawait using var stream = reader.GetStream(0);\n\t\t\t\t\tawait stream.WriteAsync(insert_values);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT blob_field FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tvar select_values = (byte[])await select.ExecuteScalarAsync();\n\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t}\n\t}\n}"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/ConnectionPoolLifetimeHelperTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = @realic, Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[NoServerCategory]\npublic class ConnectionPoolLifetimeHelperTests\n{\n\t[Test]\n\tpublic void IsAliveTrueIfLifetimeNotExceed()\n\t{\n\t\tvar now = 1_000_000;\n\t\tvar timeAgo = now - (10 * 1000);\n\t\tvar isAlive = ConnectionPoolLifetimeHelper.IsAlive(20, timeAgo, now);\n\t\tAssert.IsTrue(isAlive);\n\t}\n\n\t[Test]\n\tpublic void IsAliveFalseIfLifetimeIsExceed()\n\t{\n\t\tvar now = 1_000_000;\n\t\tvar timeAgo = now - (30 * 1000);\n\t\tvar isAlive = ConnectionPoolLifetimeHelper.IsAlive(20, timeAgo, now);\n\t\tAssert.IsFalse(isAlive);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/ConnectionStringTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Globalization;\nusing System.Threading;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[NoServerCategory]\npublic class ConnectionStringTests\n{\n\t[Test]\n\tpublic void ParsingNormalConnectionStringTest()\n\t{\n\t\tconst string ConnectionString = \"datasource=testserver;database=testdb.fdb;user=testuser;password=testpwd\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"testserver\", cs.DataSource);\n\t\tAssert.AreEqual(\"testdb.fdb\", cs.Database);\n\t\tAssert.AreEqual(\"testuser\", cs.UserID);\n\t\tAssert.AreEqual(\"testpwd\", cs.Password);\n\t}\n\n\t[Test]\n\tpublic void ParsingFullDatabaseConnectionStringTest()\n\t{\n\t\tconst string ConnectionString = \"database=testserver/1234:testdb.fdb;user=testuser;password=testpwd\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"testserver\", cs.DataSource);\n\t\tAssert.AreEqual(\"testdb.fdb\", cs.Database);\n\t\tAssert.AreEqual(\"testuser\", cs.UserID);\n\t\tAssert.AreEqual(\"testpwd\", cs.Password);\n\t\tAssert.AreEqual(1234, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingSingleQuotedConnectionStringTest()\n\t{\n\t\tconst string ConnectionString = \"datasource=testserver;database=testdb.fdb;user=testuser;password=test'pwd\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"test'pwd\", cs.Password);\n\t}\n\n\t[Test]\n\tpublic void ParsingDoubleQuotedConnectionStringTest()\n\t{\n\t\tconst string ConnectionString = \"datasource=testserver;database=testdb.fdb;user=testuser;password=test\\\"pwd\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"test\\\"pwd\", cs.Password);\n\t}\n\n\t[Test]\n\tpublic void ParsingSpacesInKeyConnectionStringTest()\n\t{\n\t\tconst string ConnectionString = \"data source=testserver\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"testserver\", cs.DataSource);\n\t}\n\n\t[Test]\n\tpublic void ParsingOneCharValueConnectionStringTest()\n\t{\n\t\tconst string ConnectionString = \"connection lifetime=6\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(6, cs.ConnectionLifetime);\n\t}\n\n\t[Test]\n\tpublic void ParsingWithEndingSemicolonConnectionStringTest()\n\t{\n\t\tconst string ConnectionString = \"user=testuser;password=testpwd;\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"testuser\", cs.UserID);\n\t\tAssert.AreEqual(\"testpwd\", cs.Password);\n\t}\n\n\t[Test]\n\tpublic void ParsingWithoutEndingSemicolonConnectionStringTest()\n\t{\n\t\tconst string ConnectionString = \"user=testuser;password=testpwd\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"testuser\", cs.UserID);\n\t\tAssert.AreEqual(\"testpwd\", cs.Password);\n\t}\n\n\t[Test]\n\tpublic void ParsingMultilineConnectionStringTest()\n\t{\n\t\tconst string ConnectionString = @\"DataSource=S05-04;\n User=SYSDBA;\n Password=masterkey;\n Role=;\n Database=Termine;\n Port=3050;\n Dialect=3;\n Charset=ISO8859_1;\n Connection lifetime=0;\n Connection timeout=15;\n Pooling=True;\n Packet Size=8192;\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"Termine\", cs.Database);\n\t\tAssert.AreEqual(\"\", cs.Role);\n\t}\n\n\t[Test]\n\tpublic void NormalizedConnectionStringIgnoresCultureTest()\n\t{\n\t\tconst string ConnectionString = \"datasource=testserver;database=testdb.fdb;user=testuser;password=testpwd\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tThread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(\"en-GB\");\n\t\tvar s1 = cs.NormalizedConnectionString;\n\t\tThread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(\"cs-CZ\");\n\t\tvar s2 = cs.NormalizedConnectionString;\n\n\t\tAssert.AreEqual(s1, s2);\n\t}\n\n\t[Test]\n\tpublic void ParsingWithEmptyKeyConnectionStringTest()\n\t{\n\t\tconst string ConnectionString = \"user=;password=testpwd\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"\", cs.UserID);\n\t\tAssert.AreEqual(\"testpwd\", cs.Password);\n\t}\n\n\t[Test]\n\tpublic void ParsingWithWhiteSpacesKeyConnectionStringTest()\n\t{\n\t\tconst string ConnectionString = \"user= \\t;password=testpwd\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"\", cs.UserID);\n\t\tAssert.AreEqual(\"testpwd\", cs.Password);\n\t}\n\n\t[Test]\n\tpublic void CryptKeyWithBase64FullPadding()\n\t{\n\t\tconst string ConnectionString = \"user=u;cryptkey=dGVzdA==;password=p\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"test\", cs.CryptKey);\n\t}\n\n\t[Test]\n\tpublic void CryptKeyWithBase64SinglePadding()\n\t{\n\t\tconst string ConnectionString = \"user=u;cryptkey=YWE=;password=p\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"aa\", cs.CryptKey);\n\t}\n\n\t[Test]\n\tpublic void CryptKeyWithBase64NoPadding()\n\t{\n\t\tconst string ConnectionString = \"user=u;cryptkey=YWFh;password=p\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"aaa\", cs.CryptKey);\n\t}\n\n\t[Test]\n\tpublic void WireCryptMixedCase()\n\t{\n\t\tconst string ConnectionString = \"wire crYpt=reQUIREd\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(FbWireCrypt.Required, cs.WireCrypt);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleHostnameWithoutPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=hostname:test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleHostnameWithoutPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=hostname:/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleHostnameWithoutPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=hostname:C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleIP4WithoutPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=127.0.0.1:test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleIP4WithoutPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=127.0.0.1:/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleIP4WithoutPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=127.0.0.1:C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleIP6WithoutPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=::1:test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleIP6WithoutPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=::1:/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleIP6WithoutPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=::1:C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleHostnameWithPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=hostname/6666:test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleHostnameWithPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=hostname/6666:/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleHostnameWithPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=hostname/6666:C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleIP4WithPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=127.0.0.1/6666:test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleIP4WithPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=127.0.0.1/6666:/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleIP4WithPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=127.0.0.1/6666:C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleIP6WithPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=::1/6666:test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleIP6WithPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=::1/6666:/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseOldStyleIP6WithPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=::1/6666:C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleHostnameWithoutPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=//hostname/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleHostnameWithoutPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=//hostname//test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleHostnameWithoutPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=//hostname/C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleIP4WithoutPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=//127.0.0.1/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleIP4WithoutPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=//127.0.0.1//test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleIP4WithoutPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=//127.0.0.1/C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleIP6WithoutPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=//::1/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleIP6WithoutPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=//::1//test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleIP6WithoutPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=//::1/C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleHostnameWithPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=//hostname:6666/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleHostnameWithPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=//hostname:6666//test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleHostnameWithPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=//hostname:6666/C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleIP4WithPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=//127.0.0.1:6666/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleIP4WithPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=//127.0.0.1:6666//test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleIP4WithPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=//127.0.0.1:6666/C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleIP6WithPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=//[::1]:6666/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleIP6WithPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=//[::1]:6666//test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNewStyleIP6WithPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=//[::1]:6666/C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleHostnameWithoutPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://hostname/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleHostnameWithoutPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://hostname//test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleHostnameWithoutPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://hostname/C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleIP4WithoutPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://127.0.0.1/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleIP4WithoutPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://127.0.0.1//test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleIP4WithoutPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://127.0.0.1/C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleIP6WithoutPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://::1/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleIP6WithoutPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://::1//test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleIP6WithoutPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://::1/C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleHostnameWithPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://hostname:6666/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleHostnameWithPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://hostname:6666//test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleHostnameWithPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://hostname:6666/C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"hostname\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleIP4WithPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://127.0.0.1:6666/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleIP4WithPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://127.0.0.1:6666//test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleIP4WithPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://127.0.0.1:6666/C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"127.0.0.1\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleIP6WithPortWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://[::1]:6666/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleIP6WithPortRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://[::1]:6666//test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleIP6WithPortDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=inet://[::1]:6666/C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"::1\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t\tAssert.AreEqual(6666, cs.Port);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleWithoutHostnameWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=inet:///test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"localhost\", cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleWithoutHostnameRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=inet:////test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"localhost\", cs.DataSource);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseURLStyleWithoutHostnameDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=inet:///C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"localhost\", cs.DataSource);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNoStyleWithoutPath()\n\t{\n\t\tconst string ConnectionString = \"database=test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t\tAssert.AreEqual(string.Empty, cs.DataSource);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNoStyleRootPath()\n\t{\n\t\tconst string ConnectionString = \"database=/test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"/test.fdb\", cs.Database);\n\t\tAssert.AreEqual(string.Empty, cs.DataSource);\n\t}\n\n\t[Test]\n\tpublic void ParsingDatabaseNoStyleDrivePath()\n\t{\n\t\tconst string ConnectionString = \"database=C:\\\\test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(\"C:\\\\test.fdb\", cs.Database);\n\t\tAssert.AreEqual(string.Empty, cs.DataSource);\n\t}\n\n\t[TestCase(\"test\")]\n\t[TestCase(\"test12\")]\n\t[TestCase(\"32test\")]\n\t[TestCase(\"test-12\")]\n\tpublic void ParsingDatabaseHostnames(string hostname)\n\t{\n\t\tvar ConnectionString = $\"database={hostname}:test.fdb\";\n\t\tvar cs = new ConnectionString(ConnectionString);\n\t\tAssert.AreEqual(hostname, cs.DataSource);\n\t\tAssert.AreEqual(\"test.fdb\", cs.Database);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbArrayTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Linq;\nusing System.Security.Cryptography;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbArrayTests : FbTestsBase\n{\n\tpublic FbArrayTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic async Task IntegerArrayTest()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tvar insert_values = new int[] { 10, 20, 30, 40 };\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, iarray_field) values(@int_field, @array_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@array_field\", FbDbType.Array).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT iarray_field FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tawait using (var reader = await select.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tif (!await reader.IsDBNullAsync(0))\n\t\t\t\t\t{\n\t\t\t\t\t\tvar select_values = new int[insert_values.Length];\n\t\t\t\t\t\tArray.Copy((Array)reader.GetValue(0), select_values, select_values.Length);\n\t\t\t\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ShortArrayTest()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tvar insert_values = new short[] { 50, 60, 70, 80 };\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, sarray_field) values(@int_field, @array_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@array_field\", FbDbType.Array).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT sarray_field FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tawait using (var reader = await select.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tif (!await reader.IsDBNullAsync(0))\n\t\t\t\t\t{\n\t\t\t\t\t\tvar select_values = new short[insert_values.Length];\n\t\t\t\t\t\tArray.Copy((Array)reader.GetValue(0), select_values, select_values.Length);\n\t\t\t\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task BigIntArrayTest()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tvar insert_values = new long[] { 50, 60, 70, 80 };\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, larray_field) values(@int_field, @array_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@array_field\", FbDbType.Array).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT larray_field FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tawait using (var reader = await select.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tif (!await reader.IsDBNullAsync(0))\n\t\t\t\t\t{\n\t\t\t\t\t\tvar select_values = new long[insert_values.Length];\n\t\t\t\t\t\tArray.Copy((Array)reader.GetValue(0), select_values, select_values.Length);\n\t\t\t\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task FloatArrayTest()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tvar insert_values = new float[] { 130.10F, 140.20F, 150.30F, 160.40F };\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, farray_field) values(@int_field, @array_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@array_field\", FbDbType.Array).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT farray_field FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tawait using (var reader = await select.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tif (!await reader.IsDBNullAsync(0))\n\t\t\t\t\t{\n\t\t\t\t\t\tvar select_values = new float[insert_values.Length];\n\t\t\t\t\t\tArray.Copy((Array)reader.GetValue(0), select_values, select_values.Length);\n\t\t\t\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DoubleArrayTest()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tvar insert_values = new double[] { 170.10, 180.20, 190.30, 200.40 };\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, barray_field) values(@int_field, @array_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@array_field\", FbDbType.Array).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT barray_field FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tawait using (var reader = await select.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tif (!await reader.IsDBNullAsync(0))\n\t\t\t\t\t{\n\t\t\t\t\t\tvar select_values = new double[insert_values.Length];\n\t\t\t\t\t\tArray.Copy((Array)reader.GetValue(0), select_values, select_values.Length);\n\t\t\t\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task NumericArrayTest()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tvar insert_values = new decimal[] { 210.10M, 220.20M, 230.30M, 240.40M };\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, narray_field) values(@int_field, @array_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@array_field\", FbDbType.Array).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT narray_field FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tawait using (var reader = await select.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tif (!await reader.IsDBNullAsync(0))\n\t\t\t\t\t{\n\t\t\t\t\t\tvar select_values = new decimal[insert_values.Length];\n\t\t\t\t\t\tArray.Copy((Array)reader.GetValue(0), select_values, select_values.Length);\n\t\t\t\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DateArrayTest()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tvar insert_values = new DateTime[] { DateTime.Today.AddDays(10), DateTime.Today.AddDays(20), DateTime.Today.AddDays(30), DateTime.Today.AddDays(40) };\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, darray_field) values(@int_field, @array_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@array_field\", FbDbType.Array).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT darray_field FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tawait using (var reader = await select.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tif (!await reader.IsDBNullAsync(0))\n\t\t\t\t\t{\n\t\t\t\t\t\tvar select_values = new DateTime[insert_values.Length];\n\t\t\t\t\t\tArray.Copy((Array)reader.GetValue(0), select_values, select_values.Length);\n\t\t\t\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task TimeArrayTest()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tvar insert_values = new TimeSpan[] { new TimeSpan(3, 9, 10), new TimeSpan(4, 11, 12), new TimeSpan(6, 13, 14), new TimeSpan(8, 15, 16) };\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, tarray_field) values(@int_field, @array_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@array_field\", FbDbType.Array).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT tarray_field FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tawait using (var reader = await select.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tif (!await reader.IsDBNullAsync(0))\n\t\t\t\t\t{\n\t\t\t\t\t\tvar select_values = new TimeSpan[insert_values.Length];\n\t\t\t\t\t\tArray.Copy((Array)reader.GetValue(0), select_values, select_values.Length);\n\t\t\t\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task TimeStampArrayTest()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tvar insert_values = new DateTime[] { DateTime.Now.AddSeconds(10), DateTime.Now.AddSeconds(20), DateTime.Now.AddSeconds(30), DateTime.Now.AddSeconds(40) };\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, tsarray_field) values(@int_field, @array_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@array_field\", FbDbType.Array).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT tsarray_field FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tawait using (var reader = await select.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tif (!await reader.IsDBNullAsync(0))\n\t\t\t\t\t{\n\t\t\t\t\t\tvar select_values = new DateTime[insert_values.Length];\n\t\t\t\t\t\tArray.Copy((Array)reader.GetValue(0), select_values, select_values.Length);\n\t\t\t\t\t\tinsert_values = insert_values.Select(x => new DateTime(x.Ticks / 1000 * 1000)).ToArray();\n\t\t\t\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task CharArrayTest()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tvar insert_values = new string[] { \"abc\", \"abcdef\", \"abcdefghi\", \"abcdefghijkl\" };\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, carray_field) values(@int_field, @array_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@array_field\", FbDbType.Array).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT carray_field FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tawait using (var reader = await select.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tif (!await reader.IsDBNullAsync(0))\n\t\t\t\t\t{\n\t\t\t\t\t\tvar select_values = new string[insert_values.Length];\n\t\t\t\t\t\tArray.Copy((Array)reader.GetValue(0), select_values, select_values.Length);\n\t\t\t\t\t\tselect_values = select_values.Select(x => x.TrimEnd(' ')).ToArray();\n\t\t\t\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task VarCharArrayTest()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tvar insert_values = new string[] { \"abc\", \"abcdef\", \"abcdefghi\", \"abcdefghijkl\" };\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, varray_field) values(@int_field, @array_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@array_field\", FbDbType.Array).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT varray_field FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tawait using (var reader = await select.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tif (!await reader.IsDBNullAsync(0))\n\t\t\t\t\t{\n\t\t\t\t\t\tvar select_values = new string[insert_values.Length];\n\t\t\t\t\t\tArray.Copy((Array)reader.GetValue(0), select_values, select_values.Length);\n\t\t\t\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task IntegerArrayPartialUpdateTest()\n\t{\n\t\tvar new_values = new int[] { 100, 200 };\n\n\t\tawait using (var update = new FbCommand(\"update TEST set iarray_field = @array_field WHERE int_field = 1\", Connection))\n\t\t{\n\t\t\tupdate.Parameters.Add(\"@array_field\", FbDbType.Array).Value = new_values;\n\t\t\tawait update.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ShortArrayPartialUpdateTest()\n\t{\n\t\tvar new_values = new short[] { 500, 600 };\n\n\t\tawait using (var update = new FbCommand(\"update TEST set sarray_field = @array_field WHERE int_field = 1\", Connection))\n\t\t{\n\t\t\tupdate.Parameters.Add(\"@array_field\", FbDbType.Array).Value = new_values;\n\t\t\tawait update.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task BigIntArrayPartialUpdateTest()\n\t{\n\t\tvar new_values = new long[] { 900, 1000, 1100, 1200 };\n\n\t\tawait using (var update = new FbCommand(\"update TEST set larray_field = @array_field WHERE int_field = 1\", Connection))\n\t\t{\n\t\t\tupdate.Parameters.Add(\"@array_field\", FbDbType.Array).Value = new_values;\n\t\t\tawait update.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task FloatArrayPartialUpdateTest()\n\t{\n\t\tvar new_values = new float[] { 1300.10F, 1400.20F };\n\n\t\tawait using (var update = new FbCommand(\"update TEST set farray_field = @array_field WHERE int_field = 1\", Connection))\n\t\t{\n\t\t\tupdate.Parameters.Add(\"@array_field\", FbDbType.Array).Value = new_values;\n\t\t\tawait update.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DoubleArrayPartialUpdateTest()\n\t{\n\t\tvar new_values = new double[] { 1700.10, 1800.20 };\n\n\t\tawait using (var update = new FbCommand(\"update TEST set barray_field = @array_field WHERE int_field = 1\", Connection))\n\t\t{\n\t\t\tupdate.Parameters.Add(\"@array_field\", FbDbType.Array).Value = new_values;\n\t\t\tawait update.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task NumericArrayPartialUpdateTest()\n\t{\n\t\tvar new_values = new decimal[] { 2100.10M, 2200.20M };\n\n\t\tawait using (var update = new FbCommand(\"update TEST set narray_field = @array_field WHERE int_field = 1\", Connection))\n\t\t{\n\t\t\tupdate.Parameters.Add(\"@array_field\", FbDbType.Array).Value = new_values;\n\t\t\tawait update.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DateArrayPartialUpdateTest()\n\t{\n\t\tvar new_values = new DateTime[] { DateTime.Now.AddDays(100), DateTime.Now.AddDays(200) };\n\n\t\tawait using (var update = new FbCommand(\"update TEST set darray_field = @array_field WHERE int_field = 1\", Connection))\n\t\t{\n\t\t\tupdate.Parameters.Add(\"@array_field\", FbDbType.Array).Value = new_values;\n\t\t\tawait update.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task TimeArrayPartialUpdateTest()\n\t{\n\t\tvar new_values = new TimeSpan[] { new TimeSpan(11, 13, 14), new TimeSpan(12, 15, 16) };\n\n\t\tawait using (var update = new FbCommand(\"update TEST set tarray_field = @array_field WHERE int_field = 1\", Connection))\n\t\t{\n\t\t\tupdate.Parameters.Add(\"@array_field\", FbDbType.Array).Value = new_values;\n\t\t\tawait update.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task TimeStampArrayPartialUpdateTest()\n\t{\n\t\tvar new_values = new DateTime[] { DateTime.Now.AddSeconds(100), DateTime.Now.AddSeconds(200) };\n\n\t\tawait using (var update = new FbCommand(\"update TEST set tsarray_field = @array_field WHERE int_field = 1\", Connection))\n\t\t{\n\t\t\tupdate.Parameters.Add(\"@array_field\", FbDbType.Array).Value = new_values;\n\t\t\tawait update.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task CharArrayPartialUpdateTest()\n\t{\n\t\tvar new_values = new string[] { \"abc\", \"abcdef\" };\n\n\t\tawait using (var update = new FbCommand(\"update TEST set carray_field = @array_field WHERE int_field = 1\", Connection))\n\t\t{\n\t\t\tupdate.Parameters.Add(\"@array_field\", FbDbType.Array).Value = new_values;\n\t\t\tawait update.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task VarCharArrayPartialUpdateTest()\n\t{\n\t\tvar new_values = new string[] { \"abc\", \"abcdef\" };\n\n\t\tawait using (var update = new FbCommand(\"update TEST set varray_field = @array_field WHERE int_field = 1\", Connection))\n\t\t{\n\t\t\tupdate.Parameters.Add(\"@array_field\", FbDbType.Array).Value = new_values;\n\t\t\tawait update.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task BigArrayTest()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tint elements = short.MaxValue;\n\t\tvar bytes = RandomNumberGenerator.GetBytes(elements * 4);\n\t\tvar insert_values = new int[elements];\n\t\tBuffer.BlockCopy(bytes, 0, insert_values, 0, bytes.Length);\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, big_array) values(@int_field, @array_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@array_field\", FbDbType.Array).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT big_array FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tawait using (var reader = await select.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tif (!await reader.IsDBNullAsync(0))\n\t\t\t\t\t{\n\t\t\t\t\t\tvar select_values = new int[insert_values.Length];\n\t\t\t\t\t\tArray.Copy((Array)reader.GetValue(0), select_values, select_values.Length);\n\t\t\t\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task PartialUpdatesTest()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tvar elements = 16384;\n\t\tvar bytes = RandomNumberGenerator.GetBytes(elements * 4);\n\t\tvar insert_values = new int[elements];\n\t\tBuffer.BlockCopy(bytes, 0, insert_values, 0, bytes.Length);\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, big_array) values(@int_field, @array_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@array_field\", FbDbType.Array).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT big_array FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tawait using (var reader = await select.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tif (!await reader.IsDBNullAsync(0))\n\t\t\t\t\t{\n\t\t\t\t\t\tvar select_values = new int[insert_values.Length];\n\t\t\t\t\t\tArray.Copy((Array)reader.GetValue(0), select_values, select_values.Length);\n\t\t\t\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbBatchCommandTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Numerics;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\npublic class FbBatchCommandTests : FbTestsBase\n{\n\tbool _shouldTearDown;\n\n\tpublic FbBatchCommandTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt, false)\n\t{\n\t\t_shouldTearDown = false;\n\t}\n\n\t[SetUp]\n\tpublic override async Task SetUp()\n\t{\n\t\tawait base.SetUp();\n\n\t\tif (!EnsureServerVersionAtLeast(new Version(4, 0, 0, 0)))\n\t\t\treturn;\n\n\t\t_shouldTearDown = true;\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"create table batch (i int check (i < 1000), i2 int128, ts timestamp)\";\n\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\t[TearDown]\n\tpublic override async Task TearDown()\n\t{\n\t\tif (_shouldTearDown)\n\t\t{\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"drop table batch\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t}\n\t\tawait base.TearDown();\n\t}\n\n\t[Test]\n\tpublic async Task DataProperlyInDatabase()\n\t{\n\t\tawait EmptyTable();\n\n\t\tvar @is = new[] { -1, 6 };\n\t\tvar bs = new[] { new BigInteger(long.MaxValue) * 2, new BigInteger(long.MaxValue) * 3 };\n\t\tvar ts = new[] { new DateTime(2022, 01, 17, 1, 0, 0), new DateTime(2022, 01, 17, 2, 0, 0) };\n\n\t\tawait using (var cmd = Connection.CreateBatchCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"insert into batch values (@i, @i2, @ts)\";\n\t\t\tvar batch1 = cmd.AddBatchParameters();\n\t\t\tbatch1.Add(\"i\", @is[0]);\n\t\t\tbatch1.Add(\"i2\", bs[0]);\n\t\t\tbatch1.Add(\"ts\", ts[0]);\n\t\t\tvar batch2 = cmd.AddBatchParameters();\n\t\t\tbatch2.Add(\"i\", @is[1]);\n\t\t\tbatch2.Add(\"i2\", bs[1]);\n\t\t\tbatch2.Add(\"ts\", ts[1]);\n\t\t\tvar result = await cmd.ExecuteNonQueryAsync();\n\t\t}\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select i, i2, ts from batch order by i\";\n\t\t\tusing (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tvar index = 0;\n\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tAssert.AreEqual(@is[index], reader[0]);\n\t\t\t\t\tAssert.AreEqual(bs[index], reader[1]);\n\t\t\t\t\tAssert.AreEqual(ts[index], reader[2]);\n\t\t\t\t\tindex += 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SuccessWithRecordsAffected()\n\t{\n\t\tawait EmptyTable();\n\n\t\tawait using (var cmd = Connection.CreateBatchCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"insert into batch (i) values (@i)\";\n\t\t\tvar batch1 = cmd.AddBatchParameters();\n\t\t\tbatch1.Add(\"i\", 1);\n\t\t\tvar batch2 = cmd.AddBatchParameters();\n\t\t\tbatch2.Add(\"i\", 2);\n\t\t\tvar result = await cmd.ExecuteNonQueryAsync();\n\n\t\t\tAssert.AreEqual(2, result.Count);\n\t\t\tAssert.IsTrue(result.AllSuccess);\n\t\t\tAssert.IsTrue(result[0].IsSuccess);\n\t\t\tAssert.IsNull(result[0].Exception);\n\t\t\tAssert.AreEqual(1, result[0].RecordsAffected);\n\t\t\tAssert.IsTrue(result[1].IsSuccess);\n\t\t\tAssert.IsNull(result[1].Exception);\n\t\t\tAssert.AreEqual(1, result[1].RecordsAffected);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SuccessWithoutRecordsAffected()\n\t{\n\t\tawait EmptyTable();\n\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.ReturnRecordsAffected = false;\n\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t\tawait using (var cmd = conn.CreateBatchCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"insert into batch (i) values (@i)\";\n\t\t\t\tvar batch1 = cmd.AddBatchParameters();\n\t\t\t\tbatch1.Add(\"i\", 1);\n\t\t\t\tvar batch2 = cmd.AddBatchParameters();\n\t\t\t\tbatch2.Add(\"i\", 2);\n\t\t\t\tvar result = await cmd.ExecuteNonQueryAsync();\n\n\t\t\t\tAssert.AreEqual(2, result.Count);\n\t\t\t\tAssert.IsTrue(result.AllSuccess);\n\t\t\t\tAssert.IsTrue(result[0].IsSuccess);\n\t\t\t\tAssert.IsNull(result[0].Exception);\n\t\t\t\tAssert.AreEqual(-1, result[0].RecordsAffected);\n\t\t\t\tAssert.IsTrue(result[1].IsSuccess);\n\t\t\t\tAssert.IsNull(result[1].Exception);\n\t\t\t\tAssert.AreEqual(-1, result[1].RecordsAffected);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ErrorWithoutMultiError()\n\t{\n\t\tawait EmptyTable();\n\n\t\tawait using (var cmd = Connection.CreateBatchCommand())\n\t\t{\n\t\t\tcmd.MultiError = false;\n\n\t\t\tcmd.CommandText = \"insert into batch (i) values (@i)\";\n\t\t\tvar batch1 = cmd.AddBatchParameters();\n\t\t\tbatch1.Add(\"i\", 1);\n\t\t\tvar batch2 = cmd.AddBatchParameters();\n\t\t\tbatch2.Add(\"i\", 1200);\n\t\t\tvar batch3 = cmd.AddBatchParameters();\n\t\t\tbatch3.Add(\"i\", 1300);\n\t\t\tvar result = await cmd.ExecuteNonQueryAsync();\n\n\t\t\tAssert.AreEqual(2, result.Count);\n\t\t\tAssert.IsFalse(result.AllSuccess);\n\t\t\tAssert.IsTrue(result[0].IsSuccess);\n\t\t\tAssert.IsNull(result[0].Exception);\n\t\t\tAssert.AreEqual(1, result[0].RecordsAffected);\n\t\t\tAssert.IsFalse(result[1].IsSuccess);\n\t\t\tAssert.IsInstanceOf<FbException>(result[1].Exception);\n\t\t\tAssert.AreEqual(-1, result[1].RecordsAffected);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ErrorWithMultiError()\n\t{\n\t\tawait EmptyTable();\n\n\t\tawait using (var cmd = Connection.CreateBatchCommand())\n\t\t{\n\t\t\tcmd.MultiError = true;\n\n\t\t\tcmd.CommandText = \"insert into batch (i) values (@i)\";\n\t\t\tvar batch1 = cmd.AddBatchParameters();\n\t\t\tbatch1.Add(\"i\", 1);\n\t\t\tvar batch2 = cmd.AddBatchParameters();\n\t\t\tbatch2.Add(\"i\", 1200);\n\t\t\tvar batch3 = cmd.AddBatchParameters();\n\t\t\tbatch3.Add(\"i\", 1300);\n\t\t\tvar result = await cmd.ExecuteNonQueryAsync();\n\n\t\t\tAssert.AreEqual(3, result.Count);\n\t\t\tAssert.IsFalse(result.AllSuccess);\n\t\t\tAssert.IsTrue(result[0].IsSuccess);\n\t\t\tAssert.IsNull(result[0].Exception);\n\t\t\tAssert.AreEqual(1, result[0].RecordsAffected);\n\t\t\tAssert.IsFalse(result[1].IsSuccess);\n\t\t\tAssert.IsInstanceOf<FbException>(result[1].Exception);\n\t\t\tAssert.AreEqual(-1, result[1].RecordsAffected);\n\t\t\tAssert.IsFalse(result[2].IsSuccess);\n\t\t\tAssert.IsInstanceOf<FbException>(result[2].Exception);\n\t\t\tAssert.AreEqual(-1, result[2].RecordsAffected);\n\t\t}\n\t}\n\n\t[Test]\n\t[Ignore(\"Server bug (#7099).\")]\n\tpublic async Task ErrorWithMultiErrorWithOverflow()\n\t{\n\t\tawait EmptyTable();\n\n\t\tawait using (var cmd = Connection.CreateBatchCommand())\n\t\t{\n\t\t\tcmd.MultiError = true;\n\n\t\t\tcmd.CommandText = \"insert into batch (i) values (@i)\";\n\t\t\tvar batch1 = cmd.AddBatchParameters();\n\t\t\tbatch1.Add(\"i\", 1);\n\t\t\tfor (var i = 0; i < 200; i++)\n\t\t\t{\n\t\t\t\tvar b = cmd.AddBatchParameters();\n\t\t\t\tb.Add(\"i\", 1200);\n\t\t\t}\n\t\t\tvar batch2 = cmd.AddBatchParameters();\n\t\t\tbatch2.Add(\"i\", 1);\n\t\t\tvar result = await cmd.ExecuteNonQueryAsync();\n\n\t\t\tAssert.AreEqual(202, result.Count);\n\t\t\tAssert.IsFalse(result.AllSuccess);\n\t\t\tAssert.AreEqual(1, result[0].RecordsAffected);\n\t\t\tAssert.IsTrue(result[0].IsSuccess);\n\t\t\tAssert.IsNull(result[0].Exception);\n\t\t\tAssert.AreEqual(1, result[201].RecordsAffected);\n\t\t\tAssert.IsTrue(result[201].IsSuccess);\n\t\t\tAssert.IsNull(result[201].Exception);\n\t\t\tfor (var i = 1; i < result.Count - 1; i++)\n\t\t\t{\n\t\t\t\tAssert.IsFalse(result[i].IsSuccess);\n\t\t\t\tif (i <= 64)\n\t\t\t\t{\n\t\t\t\t\tAssert.IsInstanceOf<FbException>(result[i].Exception);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tAssert.IsNull(result[i].Exception);\n\t\t\t\t}\n\t\t\t\tAssert.AreEqual(-1, result[i].RecordsAffected);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task BigBatch()\n\t{\n\t\tawait EmptyTable();\n\n\t\tconst int Size = 100_000;\n\n\t\tawait using (var cmd = Connection.CreateBatchCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"insert into batch (i) values (@i)\";\n\t\t\tfor (var i = 0; i < Size; i++)\n\t\t\t{\n\t\t\t\tvar b = cmd.AddBatchParameters();\n\t\t\t\tb.Add(\"i\", 6);\n\t\t\t}\n\t\t\tvar result = await cmd.ExecuteNonQueryAsync();\n\n\t\t\tAssert.AreEqual(Size, result.Count);\n\t\t\tAssert.IsTrue(result.AllSuccess);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task EnsureSuccessThrow()\n\t{\n\t\tawait EmptyTable();\n\n\t\tawait using (var cmd = Connection.CreateBatchCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"insert into batch (i) values (@i)\";\n\t\t\tvar batch1 = cmd.AddBatchParameters();\n\t\t\tbatch1.Add(\"i\", 2000);\n\t\t\tvar result = await cmd.ExecuteNonQueryAsync();\n\n\t\t\tAssert.Throws<FbException>(result.EnsureSuccess);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task EnsureSuccessNoThrow()\n\t{\n\t\tawait EmptyTable();\n\n\t\tawait using (var cmd = Connection.CreateBatchCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"insert into batch (i) values (@i)\";\n\t\t\tvar batch1 = cmd.AddBatchParameters();\n\t\t\tbatch1.Add(\"i\", 20);\n\t\t\tvar result = await cmd.ExecuteNonQueryAsync();\n\n\t\t\tAssert.DoesNotThrow(result.EnsureSuccess);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task BatchSizeDynamicHandling()\n\t{\n\t\tawait EmptyTable();\n\n\t\tusing (var cmd = Connection.CreateBatchCommand())\n\t\t{\n\t\t\t// something silly small\n\t\t\tcmd.BatchBufferSize = 32 * 1024;\n\t\t\tcmd.CommandText = \"insert into batch (i) values (@i)\";\n\t\t\tawait cmd.PrepareAsync();\n\t\t\tfor (var i = 0; i < 10_000; i++)\n\t\t\t{\n\t\t\t\tvar bp = cmd.AddBatchParameters();\n\t\t\t\tbp.Add(\"i\", 66);\n\n\t\t\t\tif (await cmd.ComputeCurrentBatchSizeAsync() > cmd.BatchBufferSize)\n\t\t\t\t{\n\t\t\t\t\tvar last = cmd.BatchParameters[^1];\n\t\t\t\t\tcmd.BatchParameters.Remove(last);\n\t\t\t\t\tvar result = await cmd.ExecuteNonQueryAsync();\n\t\t\t\t\tAssert.DoesNotThrow(result.EnsureSuccess);\n\t\t\t\t\tcmd.BatchParameters.Clear();\n\t\t\t\t\tcmd.BatchParameters.Add(last);\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar result2 = await cmd.ExecuteNonQueryAsync();\n\t\t\tAssert.DoesNotThrow(result2.EnsureSuccess);\n\t\t}\n\t}\n\n\tasync Task EmptyTable()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"delete from batch\";\n\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbBlobTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System.Security.Cryptography;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbBlobTests : FbTestsBase\n{\n\tpublic FbBlobTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic async Task BinaryBlobTest()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tvar insert_values = RandomNumberGenerator.GetBytes(100000 * 4);\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, blob_field) values(@int_field, @blob_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@blob_field\", FbDbType.Binary).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT blob_field FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tvar select_values = (byte[])await select.ExecuteScalarAsync();\n\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReaderGetBytes()\n\t{\n\t\tvar id_value = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\t\tvar insert_values = RandomNumberGenerator.GetBytes(100000 * 4);\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var insert = new FbCommand(\"INSERT INTO TEST (int_field, blob_field) values(@int_field, @blob_field)\", Connection, transaction))\n\t\t\t{\n\t\t\t\tinsert.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = id_value;\n\t\t\t\tinsert.Parameters.Add(\"@blob_field\", FbDbType.Binary).Value = insert_values;\n\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand($\"SELECT blob_field FROM TEST WHERE int_field = {id_value}\", Connection))\n\t\t{\n\t\t\tvar select_values = new byte[100000 * 4];\n\t\t\tusing (var reader = await select.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tvar index = 0;\n\t\t\t\tvar segmentSize = 1000;\n\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\twhile (index < 400000)\n\t\t\t\t\t{\n\t\t\t\t\t\treader.GetBytes(0, index, select_values, index, segmentSize);\n\n\t\t\t\t\t\tindex += segmentSize;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tCollectionAssert.AreEqual(insert_values, select_values);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbBooleanSupportTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbBooleanSupportTests : FbTestsBase\n{\n\tprivate bool _shouldTearDown;\n\n\tpublic FbBooleanSupportTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{\n\t\t_shouldTearDown = false;\n\t}\n\n\t[SetUp]\n\tpublic override async Task SetUp()\n\t{\n\t\tawait base.SetUp();\n\n\t\tif (!EnsureServerVersionAtLeast(new Version(3, 0, 0, 0)))\n\t\t\treturn;\n\n\t\t_shouldTearDown = true;\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"CREATE TABLE withboolean (id INTEGER, bool BOOLEAN)\";\n\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t}\n\t\tvar data = new (int, string)[]\n\t\t{\n\t\t\t\t(0, \"FALSE\"),\n\t\t\t\t(1, \"TRUE\"),\n\t\t\t\t(2, \"UNKNOWN\"),\n\t\t};\n\t\tforeach (var item in data)\n\t\t{\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = $\"INSERT INTO withboolean (id, bool) VALUES ({item.Item1}, {item.Item2})\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t}\n\t}\n\n\t[TearDown]\n\tpublic override async Task TearDown()\n\t{\n\t\tif (_shouldTearDown)\n\t\t{\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"DROP TABLE withboolean\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t}\n\t\tawait base.TearDown();\n\t}\n\n\t[Test]\n\tpublic async Task SimpleSelectTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"SELECT id, bool FROM withboolean\";\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tswitch (reader.GetInt32(0))\n\t\t\t\t\t{\n\t\t\t\t\t\tcase 0:\n\t\t\t\t\t\t\tAssert.IsFalse(reader.GetBoolean(1), \"Column with value FALSE should have value false.\");\n\t\t\t\t\t\t\tAssert.IsFalse(await reader.IsDBNullAsync(1), \"Column with value FALSE should not be null.\");\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 1:\n\t\t\t\t\t\t\tAssert.IsTrue(reader.GetBoolean(1), \"Column with value TRUE should have value true.\");\n\t\t\t\t\t\t\tAssert.IsFalse(await reader.IsDBNullAsync(1), \"Column with value TRUE should not be null.\");\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\tAssert.IsTrue(await reader.IsDBNullAsync(1), \"Column with value UNKNOWN should be null.\");\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tAssert.Fail(\"Unexpected row in result set.\");\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SimpleSelectSchemaTableTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"SELECT id, bool FROM withboolean\";\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tvar schema = await reader.GetSchemaTableAsync();\n\t\t\t\tAssert.AreEqual(typeof(bool), schema.Rows[1].ItemArray[5]);\n\t\t\t}\n\t\t}\n\t}\n\n\t[TestCase(false, 0)]\n\t[TestCase(true, 1)]\n\t[TestCase(null, 2)]\n\tpublic async Task SimpleSelectWithBoolConditionTest(bool? value, int id)\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = $\"SELECT id FROM withboolean WHERE bool IS NOT DISTINCT FROM @bool\";\n\t\t\tcmd.Parameters.Add(new FbParameter(\"bool\", value));\n\t\t\tAssert.AreEqual(id, await cmd.ExecuteScalarAsync());\n\t\t}\n\t}\n\n\t[TestCase(3, false)]\n\t[TestCase(4, true)]\n\t[TestCase(5, null)]\n\tpublic async Task ParametrizedInsertTest(int id, bool? value)\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"INSERT INTO withboolean (id, bool) VALUES (@id, @bool)\";\n\t\t\tcmd.Parameters.Add(\"id\", id);\n\t\t\tcmd.Parameters.Add(\"bool\", value);\n\t\t\tAssert.DoesNotThrowAsync(() => cmd.ExecuteNonQueryAsync());\n\t\t}\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = $\"SELECT bool FROM withboolean WHERE id = @id\";\n\t\t\tcmd.Parameters.Add(\"id\", id);\n\t\t\tAssert.AreEqual(value ?? (object)DBNull.Value, await cmd.ExecuteScalarAsync());\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbCommandBuilderTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbCommandBuilderTests : FbTestsBase\n{\n\tprivate FbDataAdapter _adapter;\n\n\tpublic FbCommandBuilderTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[SetUp]\n\tpublic override async Task SetUp()\n\t{\n\t\tawait base.SetUp();\n\t\t_adapter = new FbDataAdapter(new FbCommand(\"select * from TEST where VARCHAR_FIELD = ?\", Connection));\n\t}\n\n\t[TearDown]\n\tpublic override async Task TearDown()\n\t{\n\t\t_adapter.Dispose();\n\t\tawait base.TearDown();\n\t}\n\n\t[Test]\n\tpublic void GetInsertCommandTest()\n\t{\n\t\tusing (var builder = new FbCommandBuilder(_adapter))\n\t\t{\n\t\t\tStringAssert.StartsWith(\"INSERT\", builder.GetInsertCommand().CommandText);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic void GetUpdateCommandTest()\n\t{\n\t\tusing (var builder = new FbCommandBuilder(_adapter))\n\t\t{\n\t\t\tStringAssert.StartsWith(\"UPDATE\", builder.GetUpdateCommand().CommandText);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic void GetDeleteCommandTest()\n\t{\n\t\tusing (var builder = new FbCommandBuilder(_adapter))\n\t\t{\n\t\t\tStringAssert.StartsWith(\"DELETE\", builder.GetDeleteCommand().CommandText);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic void RefreshSchemaTest()\n\t{\n\t\tusing (var builder = new FbCommandBuilder(_adapter))\n\t\t{\n\t\t\tAssert.DoesNotThrow(() => builder.GetInsertCommand());\n\t\t\tAssert.DoesNotThrow(() => builder.GetUpdateCommand());\n\t\t\tAssert.DoesNotThrow(() => builder.GetDeleteCommand());\n\n\t\t\t_adapter.SelectCommand.CommandText = \"select * from TEST where BIGINT_FIELD = ?\";\n\n\t\t\tbuilder.RefreshSchema();\n\n\t\t\tAssert.DoesNotThrow(() => builder.GetInsertCommand());\n\t\t\tAssert.DoesNotThrow(() => builder.GetUpdateCommand());\n\t\t\tAssert.DoesNotThrow(() => builder.GetDeleteCommand());\n\t\t}\n\t}\n\n\t[Test]\n\tpublic void CommandBuilderWithExpressionFieldTest()\n\t{\n\t\t_adapter.SelectCommand.CommandText = \"select TEST.*, 0 AS VALOR from TEST\";\n\n\t\tusing (var builder = new FbCommandBuilder(_adapter))\n\t\t{\n\t\t\tStringAssert.DoesNotContain(\"VALOR\", builder.GetUpdateCommand().CommandText);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DeriveParameters()\n\t{\n\t\tawait using (var command = new FbCommand(\"GETVARCHARFIELD\", Connection))\n\t\t{\n\t\t\tcommand.CommandType = CommandType.StoredProcedure;\n\t\t\tFbCommandBuilder.DeriveParameters(command);\n\t\t\tAssert.AreEqual(2, command.Parameters.Count);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DeriveParameters2()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"GETVARCHARFIELD\", Connection, transaction))\n\t\t\t{\n\t\t\t\tcommand.CommandType = CommandType.StoredProcedure;\n\t\t\t\tFbCommandBuilder.DeriveParameters(command);\n\t\t\t\tAssert.AreEqual(2, command.Parameters.Count);\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DeriveParametersNonExistingSP()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"BlaBlaBla\", Connection, transaction))\n\t\t\t{\n\t\t\t\tcommand.CommandType = CommandType.StoredProcedure;\n\t\t\t\tAssert.Throws<InvalidOperationException>(() => FbCommandBuilder.DeriveParameters(command));\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task TestWithClosedConnection()\n\t{\n\t\tawait Connection.CloseAsync();\n\n\t\tusing (var builder = new FbCommandBuilder(_adapter))\n\t\t{\n\t\t\tAssert.DoesNotThrow(() => builder.GetInsertCommand());\n\t\t\tAssert.DoesNotThrow(() => builder.GetUpdateCommand());\n\t\t\tAssert.DoesNotThrow(() => builder.GetDeleteCommand());\n\n\t\t\t_adapter.SelectCommand.CommandText = \"select * from TEST where BIGINT_FIELD = ?\";\n\n\t\t\tbuilder.RefreshSchema();\n\n\t\t\tAssert.DoesNotThrow(() => builder.GetInsertCommand());\n\t\t\tAssert.DoesNotThrow(() => builder.GetUpdateCommand());\n\t\t\tAssert.DoesNotThrow(() => builder.GetDeleteCommand());\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbCommandTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Data;\nusing System.Diagnostics;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbCommandTests : FbTestsBase\n{\n\tconst string FiniteInfiniteLoopCommand =\n@\"execute block as\ndeclare variable start_time timestamp;\nbegin\n  start_time = cast('now' as timestamp);\n  while (datediff(second from start_time to cast('now' as timestamp)) <= 10) do\n  begin\n  end\nend\";\n\n\tpublic FbCommandTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic async Task ExecuteNonQueryTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcommand.Transaction = transaction;\n\t\t\t\tcommand.CommandText = \"insert into TEST (INT_FIELD) values (?)\";\n\t\t\t\tcommand.Parameters.Add(\"@INT_FIELD\", 100);\n\t\t\t\tvar affectedRows = await command.ExecuteNonQueryAsync();\n\t\t\t\tAssert.AreEqual(affectedRows, 1);\n\t\t\t\tawait transaction.RollbackAsync();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ExecuteReaderTest()\n\t{\n\t\tawait using (var command = Connection.CreateCommand())\n\t\t{\n\t\t\tcommand.CommandText = \"select * from TEST\";\n\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t{ }\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ExecuteMultipleReaderTest()\n\t{\n\t\tawait using (FbCommand\n\t\t\tcommand1 = Connection.CreateCommand(),\n\t\t\tcommand2 = Connection.CreateCommand())\n\t\t{\n\t\t\tcommand1.CommandText = \"select * from test where int_field = 1\";\n\t\t\tcommand2.CommandText = \"select * from test where int_field = 2\";\n\n\t\t\tawait using (var r1 = await command1.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tawait using (var r2 = await command2.ExecuteReaderAsync())\n\t\t\t\t{ }\n\n\t\t\t\t// Try to call ExecuteReader in\tcommand1\n\t\t\t\t// it should throw an exception\n\t\t\t\tAssert.ThrowsAsync<InvalidOperationException>(() => command1.ExecuteReaderAsync());\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ExecuteReaderWithBehaviorTest()\n\t{\n\t\tawait using (var command = new FbCommand(\"select * from TEST\", Connection))\n\t\t{\n\t\t\tawait using (var reader = await command.ExecuteReaderAsync(CommandBehavior.CloseConnection))\n\t\t\t{ }\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ExecuteScalarTest()\n\t{\n\t\tawait using (var command = Connection.CreateCommand())\n\t\t{\n\t\t\tcommand.CommandText = \"select CHAR_FIELD from TEST where INT_FIELD = ?\";\n\t\t\tcommand.Parameters.Add(\"@INT_FIELD\", 2);\n\t\t\tvar charFieldValue = (await command.ExecuteScalarAsync()).ToString();\n\t\t\tAssert.AreEqual(\"IRow 2\", charFieldValue.TrimEnd(' '));\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ExecuteScalarWithStoredProcedureTest()\n\t{\n\t\tawait using (var command = Connection.CreateCommand())\n\t\t{\n\t\t\tcommand.CommandText = \"SimpleSP\";\n\t\t\tcommand.CommandType = CommandType.StoredProcedure;\n\t\t\tvar result = (int)await command.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(1000, result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task NamedParametersTest()\n\t{\n\t\tawait using (var command = Connection.CreateCommand())\n\t\t{\n\t\t\tcommand.CommandText = \"select CHAR_FIELD from TEST where INT_FIELD = @int_field or CHAR_FIELD = @char_field\";\n\t\t\tcommand.Parameters.Add(\"@int_field\", 2);\n\t\t\tcommand.Parameters.Add(\"@char_field\", \"TWO\");\n\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tvar count = 0;\n\n\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\tAssert.AreEqual(1, count, \"Invalid number of records fetched.\");\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task NamedParametersAndLiterals()\n\t{\n\t\tawait using (var command = new FbCommand(\"update test set char_field = 'carlos@firebird.org', bigint_field = @bigint, varchar_field = 'carlos@ado.net' where int_field = @integer\", Connection))\n\t\t{\n\t\t\tcommand.Parameters.Add(\"@bigint\", FbDbType.BigInt).Value = 200;\n\t\t\tcommand.Parameters.Add(\"@integer\", FbDbType.Integer).Value = 1;\n\t\t\tvar recordsAffected = await command.ExecuteNonQueryAsync();\n\t\t\tAssert.AreEqual(recordsAffected, 1, \"Invalid number of records affected.\");\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task NamedParametersReuseTest()\n\t{\n\t\tawait using (var command = new FbCommand(\"select * from test where int_field >= @lang and int_field <= @lang\", Connection))\n\t\t{\n\t\t\tcommand.Parameters.Add(\"@lang\", FbDbType.Integer).Value = 10;\n\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tvar count = 0;\n\t\t\t\tvar intValue = 0;\n\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tif (count == 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tintValue = reader.GetInt32(0);\n\t\t\t\t\t}\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\tAssert.AreEqual(1, count, \"Invalid number of records fetched.\");\n\t\t\t\tAssert.AreEqual(10, intValue, \"Invalid record fetched.\");\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task NamedParametersPublicAccessor()\n\t{\n\t\tawait using (var command = new FbCommand(\"select * from test where int_field >= @x1 and int_field <= @x2\", Connection))\n\t\t{\n\t\t\tAssert.IsNotNull(command.NamedParameters, \"Unexpected null reference.\");\n\t\t\tAssert.IsTrue(command.NamedParameters.Count == 0, \"Expected count 0 of named parameters before command prepare.\");\n\n\t\t\tawait command.PrepareAsync();\n\n\t\t\tAssert.IsTrue(command.NamedParameters.Count == 2, \"Expected count 2 of named parameters after command prepare.\");\n\t\t\tAssert.AreEqual(command.NamedParameters[0], \"@x1\");\n\t\t\tAssert.AreEqual(command.NamedParameters[1], \"@x2\");\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ExecuteStoredProcTest()\n\t{\n\t\tawait using (var command = new FbCommand(\"EXECUTE PROCEDURE GETVARCHARFIELD(?)\", Connection))\n\t\t{\n\t\t\tcommand.CommandType = CommandType.StoredProcedure;\n\t\t\tcommand.Parameters.Add(\"@ID\", FbDbType.VarChar).Direction = ParameterDirection.Input;\n\t\t\tcommand.Parameters.Add(\"@VARCHAR_FIELD\", FbDbType.VarChar).Direction = ParameterDirection.Output;\n\t\t\tcommand.Parameters[0].Value = 1;\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t\tAssert.AreEqual(\"IRow Number 1\", command.Parameters[1].Value);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task RecordAffectedTest()\n\t{\n\t\tawait using (var command = new FbCommand(\"insert into test (int_field) values (100000)\", Connection))\n\t\t{\n\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tAssert.AreEqual(1, reader.RecordsAffected);\n\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t{ }\n\t\t\t\tAssert.AreEqual(1, reader.RecordsAffected);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ExecuteNonQueryWithOutputParameters()\n\t{\n\t\tawait using (var command = new FbCommand(\"EXECUTE PROCEDURE GETASCIIBLOB(?)\", Connection))\n\t\t{\n\t\t\tcommand.CommandType = CommandType.StoredProcedure;\n\t\t\tcommand.Parameters.Add(\"@ID\", FbDbType.VarChar).Direction = ParameterDirection.Input;\n\t\t\tcommand.Parameters.Add(\"@CLOB_FIELD\", FbDbType.Text).Direction = ParameterDirection.Output;\n\t\t\tcommand.Parameters[0].Value = 1;\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t\tAssert.AreEqual(\"IRow Number 1\", command.Parameters[1].Value, \"Output parameter value is not valid\");\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task InvalidParameterFormat()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait using (var command = new FbCommand(\"update test set timestamp_field = @timestamp where int_field = @integer\", Connection, transaction))\n\t\t\t\t{\n\t\t\t\t\tcommand.Parameters.Add(\"@timestamp\", FbDbType.TimeStamp).Value = 1;\n\t\t\t\t\tcommand.Parameters.Add(\"@integer\", FbDbType.Integer).Value = 1;\n\t\t\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t\t\t}\n\t\t\t\tawait transaction.CommitAsync();\n\t\t\t}\n\t\t\tcatch\n\t\t\t{\n\t\t\t\tawait transaction.RollbackAsync();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UnicodeTest()\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait using (var create = new FbCommand(\"CREATE TABLE VARCHARTEST (VARCHAR_FIELD  VARCHAR(10))\", Connection))\n\t\t\t{\n\t\t\t\tawait create.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tvar statements = new[]\n\t\t\t{\n\t\t\t\t\t\"INSERT INTO VARCHARTEST (VARCHAR_FIELD) VALUES ('1')\",\n\t\t\t\t\t\"INSERT INTO VARCHARTEST (VARCHAR_FIELD) VALUES ('11')\",\n\t\t\t\t\t\"INSERT INTO VARCHARTEST (VARCHAR_FIELD) VALUES ('111')\",\n\t\t\t\t\t\"INSERT INTO VARCHARTEST (VARCHAR_FIELD) VALUES ('1111')\"\n\t\t\t\t};\n\t\t\tforeach (string statement in statements)\n\t\t\t{\n\t\t\t\tawait using (var insert = new FbCommand(statement, Connection))\n\t\t\t\t{\n\t\t\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait using (var cmd = new FbCommand(\"select * from varchartest\", Connection))\n\t\t\t{\n\t\t\t\tawait using (var r = await cmd.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\twhile (await r.ReadAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\tvar dummy = r[0];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tawait using (var drop = new FbCommand(\"DROP TABLE VARCHARTEST\", Connection))\n\t\t\t{\n\t\t\t\tawait drop.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SimplifiedChineseTest()\n\t{\n\t\tconst string Value = \"中文\";\n\t\ttry\n\t\t{\n\t\t\tawait using (var cmd = new FbCommand(\"CREATE TABLE TABLE1 (FIELD1 varchar(20))\", Connection))\n\t\t\t{\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait using (var cmd = new FbCommand(\"INSERT INTO TABLE1 VALUES (@value)\", Connection))\n\t\t\t{\n\t\t\t\tcmd.Parameters.Add(\"@value\", FbDbType.VarChar).Value = Value;\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait using (var cmd = new FbCommand($\"INSERT INTO TABLE1 VALUES ('{Value}')\", Connection))\n\t\t\t{\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tawait using (var cmd = new FbCommand(\"SELECT * FROM TABLE1\", Connection))\n\t\t\t{\n\t\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\tAssert.AreEqual(Value, reader[0]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tawait using (var cmd = new FbCommand(\"DROP TABLE TABLE1\", Connection))\n\t\t\t{\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task InsertDateTest()\n\t{\n\t\tawait using (var command = new FbCommand(\"insert into TEST (int_field, date_field) values (1002, @date)\", Connection))\n\t\t{\n\t\t\tcommand.Parameters.Add(\"@date\", FbDbType.Date).Value = DateTime.Now.ToString();\n\t\t\tvar ra = await command.ExecuteNonQueryAsync();\n\t\t\tAssert.AreEqual(ra, 1);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task InsertNullTest()\n\t{\n\t\tawait using (var command = new FbCommand(\"insert into TEST (int_field) values (@value)\", Connection))\n\t\t{\n\t\t\tcommand.Parameters.Add(\"@value\", FbDbType.Integer).Value = null;\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t\t\tAssert.Fail(\"The command was executed without throwing an exception.\");\n\t\t\t}\n\t\t\tcatch\n\t\t\t{ }\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task InsertDateTimeTest()\n\t{\n\t\tvar value = DateTime.Now;\n\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"insert into test (int_field, timestamp_field) values (1002, @dt)\";\n\t\t\tcmd.Parameters.Add(\"@dt\", FbDbType.TimeStamp).Value = value;\n\t\t\tvar ra = await cmd.ExecuteNonQueryAsync();\n\t\t\tAssert.AreEqual(ra, 1);\n\t\t}\n\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select timestamp_field from test where int_field = 1002\";\n\t\t\tvar result = (DateTime)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(value.ToString(), result.ToString());\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task InsertTimeStampTest()\n\t{\n\t\tvar value = DateTime.Now.ToString();\n\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"insert into test (int_field, timestamp_field) values (1002, @ts)\";\n\t\t\tcmd.Parameters.Add(\"@ts\", FbDbType.TimeStamp).Value = value;\n\t\t\tvar ra = await cmd.ExecuteNonQueryAsync();\n\t\t\tAssert.AreEqual(ra, 1);\n\t\t}\n\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select timestamp_field from test where int_field = 1002\";\n\t\t\tvar result = (DateTime)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(value, result.ToString());\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task InsertTimeTest()\n\t{\n\t\tvar t = new TimeSpan(0, 5, 6, 7, 231);\n\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"insert into test (int_field, time_field) values (2245, @t)\";\n\t\t\tcmd.Parameters.Add(\"@t\", FbDbType.Time).Value = t;\n\t\t\tvar ra = await cmd.ExecuteNonQueryAsync();\n\t\t\tAssert.AreEqual(ra, 1);\n\t\t}\n\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select time_field from test where int_field = 2245\";\n\t\t\tvar result = (TimeSpan)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(t.Hours, result.Hours, \"hours are not same\");\n\t\t\tAssert.AreEqual(t.Minutes, result.Minutes, \"minutes are not same\");\n\t\t\tAssert.AreEqual(t.Seconds, result.Seconds, \"seconds are not same\");\n\t\t\tAssert.AreEqual(t.Milliseconds, result.Milliseconds, \"milliseconds are not same\");\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task InsertTimeOldTest()\n\t{\n\t\tvar t = DateTime.Today;\n\t\tt = t.AddHours(5);\n\t\tt = t.AddMinutes(6);\n\t\tt = t.AddSeconds(7);\n\t\tt = t.AddMilliseconds(231);\n\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"insert into test (int_field, time_field) values (2245, @t)\";\n\t\t\tcmd.Parameters.Add(\"@t\", FbDbType.Time).Value = t;\n\t\t\tvar ra = await cmd.ExecuteNonQueryAsync();\n\t\t\tAssert.AreEqual(ra, 1);\n\t\t}\n\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select time_field from test where int_field = 2245\";\n\t\t\tvar result = (TimeSpan)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(t.Hour, result.Hours, \"hours are not same\");\n\t\t\tAssert.AreEqual(t.Minute, result.Minutes, \"minutes are not same\");\n\t\t\tAssert.AreEqual(t.Second, result.Seconds, \"seconds are not same\");\n\t\t\tAssert.AreEqual(t.Millisecond, result.Milliseconds, \"milliseconds are not same\");\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ParameterDescribeTest()\n\t{\n\t\tawait using (var command = new FbCommand(\"insert into TEST (int_field) values (@value)\", Connection))\n\t\t{\n\t\t\tawait command.PrepareAsync();\n\t\t\tcommand.Parameters.Add(\"@value\", FbDbType.Integer).Value = 100000;\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReadOnlyTransactionTest()\n\t{\n\t\tawait using (var command = Connection.CreateCommand())\n\t\t{\n\t\t\tawait using (var transaction = await Connection.BeginTransactionAsync(new FbTransactionOptions() { TransactionBehavior = FbTransactionBehavior.Read, WaitTimeout = null }))\n\t\t\t{\n\t\t\t\tcommand.Transaction = transaction;\n\t\t\t\tcommand.CommandType = CommandType.Text;\n\t\t\t\tcommand.CommandText = \"CREATE TABLE X_TABLE_1(FIELD VARCHAR(50));\";\n\t\t\t\tAssert.ThrowsAsync<FbException>(() => command.ExecuteNonQueryAsync());\n\t\t\t\tawait transaction.CommitAsync();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReturningClauseParameterTest()\n\t{\n\t\tif (!EnsureServerVersionAtMost(new Version(5, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tconst int ColumnValue = 1234;\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = string.Format(\"update TEST set int_field = '{0}' where int_field = 1 returning int_field\", ColumnValue);\n\t\t\tcmd.Parameters.Add(new FbParameter() { Direction = ParameterDirection.Output });\n\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\tvar returningValue = cmd.Parameters[0].Value;\n\t\t\tAssert.AreEqual(ColumnValue, returningValue);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReturningClauseScalarTest()\n\t{\n\t\tconst int ColumnValue = 1234;\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = string.Format(\"update TEST set int_field = '{0}' where int_field = 1 returning int_field\", ColumnValue);\n\t\t\tvar returningValue = (int)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(ColumnValue, returningValue);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReturningClauseReaderTest()\n\t{\n\t\tconst int ColumnValue = 1234;\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = string.Format(\"update TEST set int_field = '{0}' where int_field = 1 returning int_field\", ColumnValue);\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tAssert.IsTrue(await reader.ReadAsync());\n\t\t\t\tvar returningValue = (int)reader[0];\n\t\t\t\tAssert.AreEqual(ColumnValue, returningValue);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReadingVarcharOctetsTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tconst string data = \"1234\";\n\t\t\tbyte[] read = null;\n\n\t\t\tcmd.CommandText = string.Format(\"select cast('{0}' as varchar(10) character set octets) from rdb$database\", data);\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tread = (byte[])reader[0];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar expected = Encoding.ASCII.GetBytes(data);\n\t\t\tAssert.AreEqual(expected, read);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReadingCharOctetsTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tconst string data = \"1234\";\n\t\t\tbyte[] read = null;\n\n\t\t\tcmd.CommandText = string.Format(\"select cast('{0}' as char(10) character set octets) from rdb$database\", data);\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tread = (byte[])reader[0];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar expected = new byte[10];\n\t\t\tEncoding.ASCII.GetBytes(data).CopyTo(expected, 0);\n\t\t\tAssert.AreEqual(expected, read);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task GetCommandPlanTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select * from test\";\n\t\t\tawait cmd.PrepareAsync();\n\t\t\tvar plan = default(string);\n\t\t\tAssert.DoesNotThrowAsync(async () => { plan = await cmd.GetCommandPlanAsync(); });\n\t\t\tAssert.IsNotEmpty(plan);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task GetCommandExplainedPlanTest()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(3, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select * from test\";\n\t\t\tawait cmd.PrepareAsync();\n\t\t\tvar plan = default(string);\n\t\t\tAssert.DoesNotThrowAsync(async () => { plan = await cmd.GetCommandExplainedPlanAsync(); });\n\t\t\tAssert.IsNotEmpty(plan);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task GetCommandPlanNoPlanTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"recreate table NoPlan (id int)\";\n\t\t\tawait cmd.PrepareAsync();\n\t\t\tvar plan = default(string);\n\t\t\tAssert.DoesNotThrowAsync(async () => { plan = await cmd.GetCommandPlanAsync(); });\n\t\t\tAssert.IsEmpty(plan);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task GetCommandExplainedPlanNoPlanTest()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(3, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"recreate table NoPaln (id int)\";\n\t\t\tawait cmd.PrepareAsync();\n\t\t\tvar plan = default(string);\n\t\t\tAssert.DoesNotThrowAsync(async () => { plan = await cmd.GetCommandExplainedPlanAsync(); });\n\t\t\tAssert.IsEmpty(plan);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReadsTimeWithProperPrecisionTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast('00:00:01.4321' as time) from rdb$database\";\n\t\t\tvar result = (TimeSpan)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(TimeSpan.FromTicks(14321000), result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task PassesTimeSpanWithProperPrecisionTest()\n\t{\n\t\tvar ts = TimeSpan.FromTicks(14321000);\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@value as time) from rdb$database\";\n\t\t\tcmd.Parameters.Add(\"value\", ts);\n\t\t\tvar result = (TimeSpan)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(ts, result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReadsDateTimeWithProperPrecisionTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast('1.2.2015 05:06:01.4321' as timestamp) from rdb$database\";\n\t\t\tvar result = (DateTime)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(new DateTime(635583639614321000), result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task PassesDateTimeWithProperPrecisionTest()\n\t{\n\t\tvar dt = new DateTime(635583639614321000);\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@value as timestamp) from rdb$database\";\n\t\t\tcmd.Parameters.Add(\"value\", dt);\n\t\t\tvar result = (DateTime)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(dt, result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task HighLowSurrogatePassingTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tconst string Value = \"😊!\";\n\t\t\tcmd.CommandText = \"select cast(@value1 as varchar(2) character set utf8), cast(@value2 as char(2) character set utf8) from rdb$database\";\n\t\t\tcmd.Parameters.Add(\"value1\", Value);\n\t\t\tcmd.Parameters.Add(\"value2\", Value);\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tawait reader.ReadAsync();\n\t\t\t\tAssert.AreEqual(Value, reader[0]);\n\t\t\t\tAssert.AreEqual(Value, reader[1]);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task HighLowSurrogateReadingTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tconst string Value = \"😊!\";\n\t\t\tcmd.CommandText = \"select cast(x'F09F988A21' as varchar(2) character set utf8), cast(x'F09F988A21' as char(2) character set utf8) from rdb$database\";\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tawait reader.ReadAsync();\n\t\t\t\tAssert.AreEqual(Value, reader[0]);\n\t\t\t\tAssert.AreEqual(Value, reader[1]);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ExecuteNonQueryReturnsMinusOneOnNonInsertUpdateDeleteTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select 1 from rdb$database\";\n\t\t\tvar ra = await cmd.ExecuteNonQueryAsync();\n\t\t\tAssert.AreEqual(-1, ra);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task CommandCancellationDirectTest()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(2, 5, 0, 0)))\n\t\t\treturn;\n\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = FiniteInfiniteLoopCommand;\n\t\t\tasync Task Execute()\n\t\t\t{\n\t\t\t\tawait Task.Yield();\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tvar executeTask = Execute();\n\t\t\tThread.Sleep(2000);\n\t\t\tcmd.Cancel();\n\t\t\tThread.Sleep(2000);\n\t\t\tAssert.ThrowsAsync<OperationCanceledException>(async () => await executeTask);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task CommandCancellationCancellationTokenTest()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(2, 5, 0, 0)))\n\t\t\treturn;\n\n\t\tusing (var cts = new CancellationTokenSource())\n\t\t{\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = FiniteInfiniteLoopCommand;\n\t\t\t\tasync Task Execute(CancellationToken cancellationToken)\n\t\t\t\t{\n\t\t\t\t\tawait Task.Yield();\n\t\t\t\t\tawait cmd.ExecuteNonQueryAsync(cancellationToken);\n\t\t\t\t}\n\t\t\t\tvar executeTask = Execute(cts.Token);\n\t\t\t\tThread.Sleep(2000);\n\t\t\t\tcts.Cancel();\n\t\t\t\tThread.Sleep(2000);\n\t\t\t\tAssert.ThrowsAsync<OperationCanceledException>(async () => await executeTask);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task CommandUsableAfterCancellationTest()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(2, 5, 0, 0)))\n\t\t\treturn;\n\n\t\tusing (var cts = new CancellationTokenSource())\n\t\t{\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = FiniteInfiniteLoopCommand;\n\t\t\t\tasync Task Execute(CancellationToken cancellationToken)\n\t\t\t\t{\n\t\t\t\t\tawait Task.Yield();\n\t\t\t\t\tawait cmd.ExecuteNonQueryAsync(cancellationToken);\n\t\t\t\t}\n\t\t\t\tvar executeTask = Execute(cts.Token);\n\t\t\t\tThread.Sleep(2000);\n\t\t\t\tcts.Cancel();\n\t\t\t\tThread.Sleep(2000);\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tawait executeTask;\n\t\t\t\t}\n\t\t\t\tcatch (OperationCanceledException)\n\t\t\t\t{ }\n\t\t\t\tcmd.CommandText = \"select 1 from rdb$database union all select 6 from rdb$database\";\n\t\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\tvar result = new List<int>();\n\t\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\tresult.Add(reader.GetInt32(0));\n\t\t\t\t\t}\n\t\t\t\t\tCollectionAssert.AreEqual(new[] { 1, 6 }, result);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ExecuteNonQueryOnAlreadyCancelledToken()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(2, 5, 0, 0)))\n\t\t\treturn;\n\n\t\tusing (var cts = new CancellationTokenSource())\n\t\t{\n\t\t\tcts.Cancel();\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"select 1 from rdb$database\";\n\t\t\t\tAssert.ThrowsAsync<OperationCanceledException>(() => cmd.ExecuteNonQueryAsync(cts.Token));\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task PassDateOnly()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@x as date) from rdb$database\";\n\t\t\tcmd.Parameters.Add(\"x\", new DateOnly(2021, 11, 29));\n\t\t\tvar value = (DateTime)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(2021, value.Year);\n\t\t\tAssert.AreEqual(11, value.Month);\n\t\t\tAssert.AreEqual(29, value.Day);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task PassTimeOnly()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@x as time) from rdb$database\";\n\t\t\tcmd.Parameters.Add(\"x\", new TimeOnly(501940213000));\n\t\t\tvar value = (TimeSpan)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(501940213000, value.Ticks);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task CommandTimeoutTest()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(4, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = FiniteInfiniteLoopCommand;\n\t\t\tcmd.CommandTimeout = 2;\n\t\t\tAssert.ThrowsAsync<OperationCanceledException>(async () => await cmd.ExecuteNonQueryAsync());\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DefaultTimeoutValueTest()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait using (var cmd = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tAssert.AreEqual(0, cmd.CommandTimeout);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task TimeoutConnectionStringTest()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.CommandTimeout = 20;\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait using (var cmd = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tAssert.AreEqual(20, cmd.CommandTimeout);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task TimeoutNegativeConnectionStringTest()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.CommandTimeout = -1;\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait using (var cmd = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tAssert.AreEqual(0, cmd.CommandTimeout);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task Timeout0ConnectionStringTest()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.CommandTimeout = 0;\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait using (var cmd = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tAssert.AreEqual(0, cmd.CommandTimeout);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SetTimeoutTest()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait using (var cmd = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandTimeout = 6;\n\t\t\t\tAssert.AreEqual(6, cmd.CommandTimeout);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SetTimeout0Test()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait using (var cmd = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandTimeout = 0;\n\t\t\t\tAssert.AreEqual(0, cmd.CommandTimeout);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task TimeoutConnectionStringOverrideTest()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.CommandTimeout = 20;\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait using (var cmd = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandTimeout = 2;\n\t\t\t\tAssert.AreEqual(2, cmd.CommandTimeout);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task TimeoutConnectionStringOverride0Test()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.CommandTimeout = 20;\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait using (var cmd = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandTimeout = 0;\n\t\t\t\tAssert.AreEqual(0, cmd.CommandTimeout);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbConnectionStringBuilderTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Text;\nusing FirebirdSql.Data.Common;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[NoServerCategory]\npublic class FbConnectionStringBuilderTests\n{\n\t[Test]\n\tpublic void EmptyCtorGeneratesEmptyString()\n\t{\n\t\tvar b = new FbConnectionStringBuilder();\n\t\tAssert.IsEmpty(b.ToString());\n\t}\n\n\t[Test]\n\tpublic void NoValueProvidedReturnsDefault()\n\t{\n\t\tvar b = new FbConnectionStringBuilder();\n\t\tAssert.AreEqual(b.MaxPoolSize, ConnectionString.DefaultValueMaxPoolSize);\n\t}\n\n\t[Test]\n\tpublic void CryptKeyValueSetter()\n\t{\n\t\tvar b = new FbConnectionStringBuilder();\n\t\tb.CryptKey = Encoding.ASCII.GetBytes(\"test\");\n\t\tAssert.AreEqual(\"crypt key=\\\"dGVzdA==\\\"\", b.ToString());\n\t}\n\n\t[Test]\n\tpublic void CryptKeyValueGetter()\n\t{\n\t\tvar b = new FbConnectionStringBuilder(\"CryptKey=dGVzdA==\");\n\t\tAssert.AreEqual(\"test\", Encoding.ASCII.GetString(b.CryptKey));\n\t}\n\n\t[Test]\n\tpublic void WireCryptSetter()\n\t{\n\t\tvar b = new FbConnectionStringBuilder();\n\t\tb.WireCrypt = FbWireCrypt.Disabled;\n\t\tAssert.AreEqual(\"wire crypt=Disabled\", b.ToString());\n\t}\n\n\t[Test]\n\tpublic void WireCryptGetter()\n\t{\n\t\tvar b = new FbConnectionStringBuilder(\"wire crypt=required\");\n\t\tAssert.AreEqual(FbWireCrypt.Required, b.WireCrypt);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbConnectionTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Data;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbConnectionTests : FbTestsBase\n{\n\tpublic FbConnectionTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic Task BeginTransactionILUnspecifiedTest() => BeginTransactionILTestsHelper(IsolationLevel.Unspecified);\n\n\t[Test]\n\tpublic Task BeginTransactionILReadCommittedTest() => BeginTransactionILTestsHelper(IsolationLevel.ReadCommitted);\n\n\t[Test]\n\tpublic Task BeginTransactionILReadUncommittedTest() => BeginTransactionILTestsHelper(IsolationLevel.ReadUncommitted);\n\n\t[Test]\n\tpublic Task BeginTransactionILRepeatableReadTest() => BeginTransactionILTestsHelper(IsolationLevel.RepeatableRead);\n\n\t[Test]\n\tpublic Task BeginTransactionILSerializableTest() => BeginTransactionILTestsHelper(IsolationLevel.Serializable);\n\n\t[Test]\n\tpublic async Task BeginTransactionNoWaitTimeoutTest()\n\t{\n\t\tawait using (var conn = new FbConnection(BuildConnectionString(ServerType, Compression, WireCrypt)))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t\tawait using (var tx = await conn.BeginTransactionAsync(new FbTransactionOptions() { WaitTimeout = null }))\n\t\t\t{\n\t\t\t\tAssert.NotNull(tx);\n\t\t\t\tawait tx.RollbackAsync();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task BeginTransactionWithWaitTimeoutTest()\n\t{\n\t\tawait using (var conn = new FbConnection(BuildConnectionString(ServerType, Compression, WireCrypt)))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t\tawait using (var tx = await conn.BeginTransactionAsync(new FbTransactionOptions() { WaitTimeout = TimeSpan.FromSeconds(10) }))\n\t\t\t{\n\t\t\t\tAssert.NotNull(tx);\n\t\t\t\tawait tx.RollbackAsync();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task BeginTransactionWithWaitTimeoutInvalidValue1Test()\n\t{\n\t\tawait using (var conn = new FbConnection(BuildConnectionString(ServerType, Compression, WireCrypt)))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t\tAssert.ThrowsAsync<ArgumentException>(() => conn.BeginTransactionAsync(new FbTransactionOptions() { WaitTimeout = TimeSpan.FromDays(9999) }));\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task BeginTransactionWithWaitTimeoutInvalidValue2Test()\n\t{\n\t\tawait using (var conn = new FbConnection(BuildConnectionString(ServerType, Compression, WireCrypt)))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t\tAssert.ThrowsAsync<ArgumentException>(() => conn.BeginTransactionAsync(new FbTransactionOptions() { WaitTimeout = TimeSpan.FromMilliseconds(1) }));\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task CreateCommandTest()\n\t{\n\t\tawait using (var command = Connection.CreateCommand())\n\t\t{\n\t\t\tAssert.AreEqual(command.Connection, Connection);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ConnectionPoolingOnTest()\n\t{\n\t\tFbConnection.ClearAllPools();\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.Pooling = true;\n\t\tcsb.ConnectionLifeTime = 5;\n\t\tvar cs = csb.ToString();\n\n\t\tvar active = await GetActiveConnections();\n\n\t\tawait using (FbConnection\n\t\t\tmyConnection1 = new FbConnection(cs),\n\t\t\tmyConnection2 = new FbConnection(cs))\n\t\t{\n\t\t\tawait myConnection1.OpenAsync();\n\t\t\tawait myConnection2.OpenAsync();\n\n\t\t\tAssert.AreEqual(active + 2, await GetActiveConnections());\n\t\t}\n\n\t\tAssert.AreEqual(active + 2, await GetActiveConnections());\n\t}\n\n\t[Test]\n\tpublic async Task ConnectionPoolingOffTest()\n\t{\n\t\tFbConnection.ClearAllPools();\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.Pooling = false;\n\t\tcsb.ConnectionLifeTime = 5;\n\t\tvar cs = csb.ToString();\n\n\t\tvar active = await GetActiveConnections();\n\n\t\tawait using (FbConnection\n\t\t\tmyConnection1 = new FbConnection(cs),\n\t\t\tmyConnection2 = new FbConnection(cs))\n\t\t{\n\t\t\tawait myConnection1.OpenAsync();\n\t\t\tawait myConnection2.OpenAsync();\n\n\t\t\tAssert.AreEqual(active + 2, await GetActiveConnections());\n\t\t}\n\n\t\tAssert.AreEqual(active, await GetActiveConnections());\n\t}\n\n\t[Test]\n\tpublic async Task ConnectionPoolingLifetimeTest()\n\t{\n\t\tFbConnection.ClearAllPools();\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.Pooling = true;\n\t\tcsb.ConnectionLifeTime = 5;\n\t\tvar cs = csb.ToString();\n\n\t\tvar active = await GetActiveConnections();\n\n\t\tawait using (FbConnection\n\t\t\tmyConnection1 = new FbConnection(cs),\n\t\t\tmyConnection2 = new FbConnection(cs))\n\t\t{\n\t\t\tawait myConnection1.OpenAsync();\n\t\t\tawait myConnection2.OpenAsync();\n\n\t\t\tAssert.AreEqual(active + 2, await GetActiveConnections());\n\t\t}\n\n\t\tThread.Sleep(TimeSpan.FromSeconds(csb.ConnectionLifeTime * 2));\n\t\tAssert.AreEqual(active, await GetActiveConnections());\n\t}\n\n\t[Test]\n\tpublic async Task ConnectionPoolingMaxPoolSizeTest()\n\t{\n\t\tFbConnection.ClearAllPools();\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.Pooling = true;\n\t\tcsb.ConnectionLifeTime = 120;\n\t\tcsb.MaxPoolSize = 10;\n\t\tvar cs = csb.ToString();\n\n\t\tvar connections = new List<FbConnection>();\n\t\ttry\n\t\t{\n\t\t\tfor (var i = 0; i <= csb.MaxPoolSize; i++)\n\t\t\t{\n\t\t\t\tvar connection = new FbConnection(cs);\n\t\t\t\tconnections.Add(connection);\n\t\t\t\tif (i == csb.MaxPoolSize)\n\t\t\t\t{\n\t\t\t\t\tAssert.ThrowsAsync<InvalidOperationException>(() => connection.OpenAsync());\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tAssert.DoesNotThrowAsync(() => connection.OpenAsync());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tforeach (var c in connections)\n\t\t\t\tawait c.DisposeAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ConnectionPoolingMinPoolSizeTest()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.Pooling = true;\n\t\tcsb.ConnectionLifeTime = 5;\n\t\tcsb.MinPoolSize = 3;\n\t\tvar cs = csb.ToString();\n\n\t\tvar active = await GetActiveConnections();\n\n\t\tvar connections = new List<FbConnection>();\n\t\ttry\n\t\t{\n\t\t\tfor (var i = 0; i < csb.MinPoolSize * 2; i++)\n\t\t\t{\n\t\t\t\tvar connection = new FbConnection(cs);\n\t\t\t\tconnections.Add(connection);\n\t\t\t\tAssert.DoesNotThrowAsync(() => connection.OpenAsync());\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tforeach (var c in connections)\n\t\t\t\tawait c.DisposeAsync();\n\t\t}\n\n\t\tThread.Sleep(TimeSpan.FromSeconds(csb.ConnectionLifeTime * 2));\n\t\tAssert.AreEqual(active + csb.MinPoolSize, await GetActiveConnections());\n\t}\n\n\t[Test]\n\tpublic async Task ConnectionPoolingFailedNewConnectionIsNotBlockingPool()\n\t{\n\t\tconst int Size = 2;\n\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.Pooling = true;\n\t\tcsb.ConnectionLifeTime = 100;\n\t\tcsb.MaxPoolSize = Size;\n\t\tcsb.Database = \"invalid\";\n\t\tvar cs = csb.ToString();\n\n\t\tvar retries = 0;\n\t\twhile (true)\n\t\t{\n\t\t\tawait using (var connection = new FbConnection(cs))\n\t\t\t{\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tawait connection.OpenAsync();\n\t\t\t\t}\n\t\t\t\tcatch (FbException)\n\t\t\t\t{\n\t\t\t\t\tif (retries++ >= Size)\n\t\t\t\t\t{\n\t\t\t\t\t\tAssert.Pass();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tAssert.Fail();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic void NoDatabaseTriggersWrongConnectionStringTest()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.Pooling = true;\n\t\tcsb.NoDatabaseTriggers = true;\n\t\tAssert.Throws<ArgumentException>(() => new FbConnection(csb.ToString()));\n\t}\n\n\t[Test]\n\tpublic async Task DatabaseTriggersTest()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.Pooling = false;\n\n\t\tint rows;\n\n\t\tcsb.NoDatabaseTriggers = false;\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t\trows = await GetLogRowsCount(conn);\n\t\t}\n\n\t\tcsb.NoDatabaseTriggers = true;\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t\tAssert.AreEqual(rows, await GetLogRowsCount(conn));\n\t\t}\n\n\t\tcsb.NoDatabaseTriggers = false;\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t\tAssert.AreEqual(rows + 1, await GetLogRowsCount(conn));\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UserIDCorrectlyPassedToServer()\n\t{\n\t\tawait using (var conn = new FbConnection(BuildConnectionString(ServerType, Compression, WireCrypt)))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t\tawait using (var command = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tcommand.CommandText = \"select CURRENT_USER from RDB$DATABASE\";\n\t\t\t\tvar loggedUser = (string)await command.ExecuteScalarAsync();\n\t\t\t\tAssert.AreEqual(FbTestsSetup.UserID, loggedUser);\n\t\t\t}\n\t\t}\n\n\t}\n\n\t[Test]\n\tpublic async Task UseTrustedAuth()\n\t{\n\t\tif (!EnsureWireCrypt(FbWireCrypt.Disabled))\n\t\t\treturn;\n\t\tif (!EnsureServerType(FbServerType.Default))\n\t\t\treturn;\n\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.UserID = string.Empty;\n\t\tcsb.Password = string.Empty;\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tAssert.DoesNotThrowAsync(conn.OpenAsync);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task CreateDropDatabaseUsingTrustedAuth()\n\t{\n\t\tif (!EnsureWireCrypt(FbWireCrypt.Disabled))\n\t\t\treturn;\n\t\tif (!EnsureServerType(FbServerType.Default))\n\t\t\treturn;\n\n\t\tif (ServerVersion >= new Version(3, 0, 0, 0))\n\t\t{\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"create or alter global mapping admin_trusted_auth using plugin win_sspi from any user to role rdb$admin\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t}\n\t\ttry\n\t\t{\n\t\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\t\tcsb.UserID = string.Empty;\n\t\t\tcsb.Password = string.Empty;\n\t\t\tcsb.Database = $\"{Guid.NewGuid()}.fdb\";\n\t\t\tvar cs = csb.ToString();\n\t\t\tAssert.DoesNotThrowAsync(() => FbConnection.CreateDatabaseAsync(cs, overwrite: true));\n\t\t\tAssert.DoesNotThrowAsync(() => FbConnection.DropDatabaseAsync(cs));\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tif (ServerVersion >= new Version(3, 0, 0, 0))\n\t\t\t{\n\t\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t\t{\n\t\t\t\t\tcmd.CommandText = \"drop global mapping admin_trusted_auth\";\n\t\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[TestCase(false)]\n\t[TestCase(true)]\n\tpublic async Task UseCompression(bool compression)\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(3, 0, 0, 0)))\n\t\t\treturn;\n\t\tif (!EnsureServerType(FbServerType.Default))\n\t\t\treturn;\n\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.Compression = compression;\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t\tconst string Pattern = \":[^:]*Z[^:]*$\";\n\t\t\tif (compression)\n\t\t\t{\n\t\t\t\tStringAssert.IsMatch(Pattern, conn.ServerVersion);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tStringAssert.DoesNotMatch(Pattern, conn.ServerVersion);\n\t\t\t}\n\t\t}\n\t}\n\n\t[TestCase(FbWireCrypt.Disabled)]\n\t[TestCase(FbWireCrypt.Enabled)]\n\t[TestCase(FbWireCrypt.Required)]\n\tpublic async Task UseWireCrypt(FbWireCrypt wireCrypt)\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(3, 0, 0, 0)))\n\t\t\treturn;\n\t\tif (!EnsureServerType(FbServerType.Default))\n\t\t\treturn;\n\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.WireCrypt = wireCrypt;\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t\tconst string Pattern = \":[^:]*C[^:]*$\";\n\t\t\tif (wireCrypt == FbWireCrypt.Enabled || wireCrypt == FbWireCrypt.Required)\n\t\t\t{\n\t\t\t\tStringAssert.IsMatch(Pattern, conn.ServerVersion);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tStringAssert.DoesNotMatch(Pattern, conn.ServerVersion);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test, Explicit]\n\tpublic void PassCryptKey()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.Database = \"enc.fdb\";\n\t\tasync Task Test()\n\t\t{\n\t\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t\t{\n\t\t\t\tawait conn.OpenAsync();\n\t\t\t}\n\t\t}\n\t\tAssert.ThrowsAsync<FbException>(Test);\n\t\tcsb.CryptKey = Encoding.ASCII.GetBytes(\"1234567890123456\");\n\t\tAssert.DoesNotThrowAsync(Test);\n\t}\n\n\t[Test, Explicit]\n\tpublic async Task DoNotGoBackToPoolAfterBroken()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.Pooling = true;\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t}\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait using (var cmd = conn.CreateCommand())\n\t\t\t\t{\n\t\t\t\t\tcmd.CommandText = \"select * from mon$statements union all select * from mon$statements\";\n\t\t\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t\t\t{ }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (FbException)\n\t\t\t{ }\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task CaseSensitiveLogin()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(3, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t\tawait using (var cmd = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"create or alter user \\\"CaseSensitive\\\" password 'password' using plugin Srp\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t}\n\n\t\t\tcsb.Pooling = false;\n\t\t\tcsb.UserID = \"\\\"CaseSensitive\\\"\";\n\t\t\tcsb.Password = \"password\";\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait using (var conn2 = new FbConnection(csb.ToString()))\n\t\t\t\t{\n\t\t\t\t\tAssert.DoesNotThrowAsync(() => conn2.OpenAsync());\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tawait using (var cmd = conn.CreateCommand())\n\t\t\t\t{\n\t\t\t\t\tcmd.CommandText = \"drop user \\\"CaseSensitive\\\" using plugin Srp\";\n\t\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task InvalidCredentialsGiveProperError()\n\t{\n\t\tif (!EnsureServerType(FbServerType.Default))\n\t\t\treturn;\n\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.Password = string.Empty;\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait conn.OpenAsync();\n\t\t\t\tAssert.Fail();\n\t\t\t}\n\t\t\tcatch (FbException ex) when (ex.ErrorCode == 335544472)\n\t\t\t{\n\t\t\t\tAssert.Pass();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task InfoMessageTest()\n\t{\n\t\tvar messageReceived = false;\n\t\tawait using (var conn = new FbConnection(BuildConnectionString(ServerType, Compression, WireCrypt)))\n\t\t{\n\t\t\tconn.InfoMessage += (object sender, FbInfoMessageEventArgs e) =>\n\t\t\t{\n\t\t\t\tmessageReceived = e.Message.Contains(\"jiri\", StringComparison.OrdinalIgnoreCase);\n\t\t\t};\n\t\t\tawait conn.OpenAsync();\n\t\t\tawait using (var cmd = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"revoke select on table test from jiri\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t}\n\t\tAssert.IsTrue(messageReceived);\n\t}\n\n\t[Test]\n\tpublic async Task ConnectionTimeoutUsingTimeout()\n\t{\n\t\tif (!EnsureServerType(FbServerType.Default))\n\t\t\treturn;\n\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.ConnectionTimeout = 1;\n\t\tcsb.DataSource = \"10.0.0.0\"; // intentionally wrong address\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait conn.OpenAsync();\n\t\t\t\tAssert.Fail();\n\t\t\t}\n\t\t\tcatch (TimeoutException)\n\t\t\t{\n\t\t\t\tAssert.Pass();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ConnectionTimeoutUsingCancellationToken()\n\t{\n\t\tif (!EnsureServerType(FbServerType.Default))\n\t\t\treturn;\n\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.DataSource = \"10.0.0.0\"; // intentionally wrong address\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tusing (var cts = new CancellationTokenSource(100))\n\t\t\t\t{\n\t\t\t\t\tawait conn.OpenAsync(cts.Token);\n\t\t\t\t}\n\t\t\t\tAssert.Fail();\n\t\t\t}\n\t\t\tcatch (OperationCanceledException)\n\t\t\t{\n\t\t\t\tAssert.Pass();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SrpWithLeadingZeros()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(3, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"create user DAVIDS password 'test' using plugin Srp\";\n\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t}\n\t\ttry\n\t\t{\n\t\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\t\tcsb.UserID = \"DAVIDS\";\n\t\t\tcsb.Password = \"test\";\n\t\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t\t{\n\t\t\t\tAssert.DoesNotThrowAsync(() => conn.OpenAsync());\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"drop user DAVIDS using plugin Srp\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ApplicationNameCorrectlyPassedToServer()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.ApplicationName = \"aPP NaME\";\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t\tawait using (var command = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tcommand.CommandText = \"select MON$REMOTE_PROCESS from MON$ATTACHMENTS\";\n\t\t\t\tvar applicationName = (string)await command.ExecuteScalarAsync();\n\t\t\t\tAssert.AreEqual(csb.ApplicationName, applicationName);\n\t\t\t}\n\t\t}\n\n\t}\n\n\tprivate async Task BeginTransactionILTestsHelper(IsolationLevel level)\n\t{\n\t\tawait using (var conn = new FbConnection(BuildConnectionString(ServerType, Compression, WireCrypt)))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t\tawait using (var tx = await conn.BeginTransactionAsync(level))\n\t\t\t{\n\t\t\t\tAssert.NotNull(tx);\n\t\t\t\tawait tx.RollbackAsync();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static async Task<int> GetLogRowsCount(FbConnection conn)\n\t{\n\t\tawait using (var cmd = conn.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select count(*) from log where text = 'on connect'\";\n\t\t\treturn Convert.ToInt32(await cmd.ExecuteScalarAsync());\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbDataAdapterTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbDataAdapterTests : FbTestsBase\n{\n\tpublic FbDataAdapterTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic async Task FillTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST\", Connection, transaction))\n\t\t\t{\n\t\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t\t{\n\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.Fill(ds, \"TEST\");\n\t\t\t\t\t\tAssert.AreEqual(100, ds.Tables[\"TEST\"].Rows.Count, \"Incorrect row count\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task FillMultipleTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST\", Connection, transaction))\n\t\t\t{\n\t\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t\t{\n\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\tusing (var ds1 = new DataSet())\n\t\t\t\t\tusing (var ds2 = new DataSet())\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.Fill(ds1, \"TEST\");\n\t\t\t\t\t\tadapter.Fill(ds2, \"TEST\");\n\n\t\t\t\t\t\tAssert.AreEqual(100, ds1.Tables[\"TEST\"].Rows.Count, \"Incorrect row count (ds1)\");\n\t\t\t\t\t\tAssert.AreEqual(100, ds2.Tables[\"TEST\"].Rows.Count, \"Incorrect row count (ds2)\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task FillMultipleWithImplicitTransactionTest()\n\t{\n\t\tawait using (var command = new FbCommand(\"select * from TEST\", Connection))\n\t\t{\n\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t{\n\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\tusing (var ds1 = new DataSet())\n\t\t\t\tusing (var ds2 = new DataSet())\n\t\t\t\t{\n\t\t\t\t\tadapter.Fill(ds1, \"TEST\");\n\t\t\t\t\tadapter.Fill(ds2, \"TEST\");\n\n\t\t\t\t\tAssert.AreEqual(100, ds1.Tables[\"TEST\"].Rows.Count, \"Incorrect row count (ds1)\");\n\t\t\t\t\tAssert.AreEqual(100, ds2.Tables[\"TEST\"].Rows.Count, \"Incorrect row count (ds2)\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task InsertTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST\", Connection, transaction))\n\t\t\t{\n\t\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t\t{\n\t\t\t\t\tusing (var builder = new FbCommandBuilder(adapter))\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tadapter.Fill(ds, \"TEST\");\n\n\t\t\t\t\t\t\tAssert.AreEqual(100, ds.Tables[\"TEST\"].Rows.Count, \"Incorrect row count\");\n\n\t\t\t\t\t\t\tvar newRow = ds.Tables[\"TEST\"].NewRow();\n\n\t\t\t\t\t\t\tnewRow[\"int_field\"] = 101;\n\t\t\t\t\t\t\tnewRow[\"CHAR_FIELD\"] = \"ONE THOUSAND\";\n\t\t\t\t\t\t\tnewRow[\"VARCHAR_FIELD\"] = \":;,.{}`+^*[]\\\\!|@#$%&/()?_-<>\";\n\t\t\t\t\t\t\tnewRow[\"BIGint_field\"] = 100000;\n\t\t\t\t\t\t\tnewRow[\"SMALLint_field\"] = 100;\n\t\t\t\t\t\t\tnewRow[\"DOUBLE_FIELD\"] = 100.01;\n\t\t\t\t\t\t\tnewRow[\"NUMERIC_FIELD\"] = 100.01;\n\t\t\t\t\t\t\tnewRow[\"DECIMAL_FIELD\"] = 100.01;\n\t\t\t\t\t\t\tnewRow[\"DATE_FIELD\"] = new DateTime(100, 10, 10);\n\t\t\t\t\t\t\tnewRow[\"TIME_FIELD\"] = new TimeSpan(10, 10, 10);\n\t\t\t\t\t\t\tnewRow[\"TIMESTAMP_FIELD\"] = new DateTime(100, 10, 10, 10, 10, 10, 10);\n\t\t\t\t\t\t\tnewRow[\"CLOB_FIELD\"] = \"ONE THOUSAND\";\n\n\t\t\t\t\t\t\tds.Tables[\"TEST\"].Rows.Add(newRow);\n\n\t\t\t\t\t\t\tadapter.Update(ds, \"TEST\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UpdateCharTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST where int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t\t{\n\t\t\t\t\tusing (var builder = new FbCommandBuilder(adapter))\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\t\tadapter.SelectCommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tadapter.Fill(ds, \"TEST\");\n\n\t\t\t\t\t\t\tAssert.AreEqual(1, ds.Tables[\"TEST\"].Rows.Count, \"Incorrect row count\");\n\n\t\t\t\t\t\t\tds.Tables[\"TEST\"].Rows[0][\"CHAR_FIELD\"] = \"ONE THOUSAND\";\n\n\t\t\t\t\t\t\tadapter.Update(ds, \"TEST\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"SELECT char_field FROM TEST WHERE int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\tvar val = (string)await command.ExecuteScalarAsync();\n\t\t\t\tAssert.AreEqual(\"ONE THOUSAND\", val.Trim(), \"char_field has not correct value\");\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UpdateVarCharTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST where int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t\t{\n\t\t\t\t\tusing (var builder = new FbCommandBuilder(adapter))\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\t\tadapter.SelectCommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tadapter.Fill(ds, \"TEST\");\n\n\t\t\t\t\t\t\tAssert.AreEqual(1, ds.Tables[\"TEST\"].Rows.Count, \"Incorrect row count\");\n\n\t\t\t\t\t\t\tds.Tables[\"TEST\"].Rows[0][\"VARCHAR_FIELD\"] = \"ONE VAR THOUSAND\";\n\n\t\t\t\t\t\t\tadapter.Update(ds, \"TEST\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"SELECT varchar_field FROM TEST WHERE int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\tvar val = (string)await command.ExecuteScalarAsync();\n\t\t\t\tAssert.AreEqual(\"ONE VAR THOUSAND\", val.Trim(), \"varchar_field has not correct value\");\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UpdateSmallIntTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST where int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t\t{\n\t\t\t\t\tusing (var builder = new FbCommandBuilder(adapter))\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\t\tadapter.SelectCommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tadapter.Fill(ds, \"TEST\");\n\n\t\t\t\t\t\t\tAssert.AreEqual(1, ds.Tables[\"TEST\"].Rows.Count, \"Incorrect row count\");\n\n\t\t\t\t\t\t\tds.Tables[\"TEST\"].Rows[0][\"SMALLint_field\"] = short.MaxValue;\n\n\t\t\t\t\t\t\tadapter.Update(ds, \"TEST\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"SELECT smallint_field FROM TEST WHERE int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\tvar val = (short)await command.ExecuteScalarAsync();\n\t\t\t\tAssert.AreEqual(short.MaxValue, val, \"smallint_field has not correct value\");\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UpdateBigIntTest()\n\t{\n\t\tawait using (var transaction = Connection.BeginTransaction())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST where int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t\t{\n\t\t\t\t\tusing (var builder = new FbCommandBuilder(adapter))\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\t\tadapter.SelectCommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tadapter.Fill(ds, \"TEST\");\n\n\t\t\t\t\t\t\tAssert.AreEqual(1, ds.Tables[\"TEST\"].Rows.Count, \"Incorrect row count\");\n\n\t\t\t\t\t\t\tds.Tables[\"TEST\"].Rows[0][\"BIGINT_FIELD\"] = int.MaxValue;\n\n\t\t\t\t\t\t\tadapter.Update(ds, \"TEST\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttransaction.Commit();\n\t\t}\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"SELECT bigint_field FROM TEST WHERE int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\tvar val = (long)await command.ExecuteScalarAsync();\n\t\t\t\tAssert.AreEqual(int.MaxValue, val, \"bigint_field has not correct value\");\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UpdateDoubleTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST where int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t\t{\n\t\t\t\t\tusing (var builder = new FbCommandBuilder(adapter))\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\t\tadapter.SelectCommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tadapter.Fill(ds, \"TEST\");\n\n\t\t\t\t\t\t\tAssert.AreEqual(1, ds.Tables[\"TEST\"].Rows.Count, \"Incorrect row count\");\n\n\t\t\t\t\t\t\tds.Tables[\"TEST\"].Rows[0][\"DOUBLE_FIELD\"] = int.MaxValue;\n\n\t\t\t\t\t\t\tadapter.Update(ds, \"TEST\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"SELECT double_field FROM TEST WHERE int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\tvar val = (double)await command.ExecuteScalarAsync();\n\t\t\t\tAssert.AreEqual(int.MaxValue, val, \"double_field has not correct value\");\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UpdateFloatTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST where int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t\t{\n\t\t\t\t\tusing (var builder = new FbCommandBuilder(adapter))\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\t\tadapter.SelectCommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tadapter.Fill(ds, \"TEST\");\n\n\t\t\t\t\t\t\tAssert.AreEqual(1, ds.Tables[\"TEST\"].Rows.Count, \"Incorrect row count\");\n\n\t\t\t\t\t\t\tds.Tables[\"TEST\"].Rows[0][\"FLOAT_FIELD\"] = (float)100.20;\n\n\t\t\t\t\t\t\tadapter.Update(ds, \"TEST\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"SELECT float_field FROM TEST WHERE int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\tvar val = (float)await command.ExecuteScalarAsync();\n\t\t\t\tAssert.AreEqual((float)100.20, val, \"double_field has not correct value\");\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UpdateNumericTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST where int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t\t{\n\t\t\t\t\tusing (var builder = new FbCommandBuilder(adapter))\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\t\tadapter.SelectCommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tadapter.Fill(ds, \"TEST\");\n\n\t\t\t\t\t\t\tAssert.AreEqual(1, ds.Tables[\"TEST\"].Rows.Count, \"Incorrect row count\");\n\n\t\t\t\t\t\t\tds.Tables[\"TEST\"].Rows[0][\"NUMERIC_FIELD\"] = int.MaxValue;\n\n\t\t\t\t\t\t\tadapter.Update(ds, \"TEST\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"SELECT numeric_field FROM TEST WHERE int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\tvar val = (decimal)await command.ExecuteScalarAsync();\n\t\t\t\tAssert.AreEqual(int.MaxValue, val, \"numeric_field has not correct value\");\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UpdateDecimalTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST where int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t\t{\n\t\t\t\t\tusing (var builder = new FbCommandBuilder(adapter))\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\t\tadapter.SelectCommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tadapter.Fill(ds, \"TEST\");\n\n\t\t\t\t\t\t\tAssert.AreEqual(1, ds.Tables[\"TEST\"].Rows.Count, \"Incorrect row count\");\n\n\t\t\t\t\t\t\tds.Tables[\"TEST\"].Rows[0][\"DECIMAL_FIELD\"] = int.MaxValue;\n\n\t\t\t\t\t\t\tadapter.Update(ds, \"TEST\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"SELECT decimal_field FROM TEST WHERE int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\tvar val = (decimal)await command.ExecuteScalarAsync();\n\t\t\t\tAssert.AreEqual(int.MaxValue, val, \"decimal_field has not correct value\");\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UpdateDateTest()\n\t{\n\t\tvar dtValue = DateTime.Now;\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST where int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t\t{\n\t\t\t\t\tusing (var builder = new FbCommandBuilder(adapter))\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\t\tadapter.SelectCommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tadapter.Fill(ds, \"TEST\");\n\n\t\t\t\t\t\t\tAssert.AreEqual(1, ds.Tables[\"TEST\"].Rows.Count, \"Incorrect row count\");\n\n\n\t\t\t\t\t\t\tds.Tables[\"TEST\"].Rows[0][\"DATE_FIELD\"] = dtValue;\n\n\t\t\t\t\t\t\tadapter.Update(ds, \"TEST\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"SELECT date_field FROM TEST WHERE int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\tvar val = (DateTime)await command.ExecuteScalarAsync();\n\t\t\t\tAssert.AreEqual(dtValue.Day, val.Day, \"date_field has not correct day\");\n\t\t\t\tAssert.AreEqual(dtValue.Month, val.Month, \"date_field has not correct month\");\n\t\t\t\tAssert.AreEqual(dtValue.Year, val.Year, \"date_field has not correct year\");\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UpdateTimeTest()\n\t{\n\t\tvar dtValue = new TimeSpan(5, 6, 7);\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST where int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t\t{\n\t\t\t\t\tusing (var builder = new FbCommandBuilder(adapter))\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\t\tadapter.SelectCommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tadapter.Fill(ds, \"TEST\");\n\n\t\t\t\t\t\t\tAssert.AreEqual(1, ds.Tables[\"TEST\"].Rows.Count, \"Incorrect row count\");\n\n\n\t\t\t\t\t\t\tds.Tables[\"TEST\"].Rows[0][\"TIME_FIELD\"] = dtValue;\n\n\t\t\t\t\t\t\tadapter.Update(ds, \"TEST\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"SELECT time_field FROM TEST WHERE int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\tvar val = (TimeSpan)await command.ExecuteScalarAsync();\n\t\t\t\tAssert.AreEqual(dtValue.Hours, val.Hours, \"time_field has not correct hour\");\n\t\t\t\tAssert.AreEqual(dtValue.Minutes, val.Minutes, \"time_field has not correct minute\");\n\t\t\t\tAssert.AreEqual(dtValue.Seconds, val.Seconds, \"time_field has not correct second\");\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UpdateTimeStampTest()\n\t{\n\t\tvar dtValue = DateTime.Now;\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST where int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t\t{\n\t\t\t\t\tusing (var builder = new FbCommandBuilder(adapter))\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\t\tadapter.SelectCommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tadapter.Fill(ds, \"TEST\");\n\n\t\t\t\t\t\t\tAssert.AreEqual(1, ds.Tables[\"TEST\"].Rows.Count, \"Incorrect row count\");\n\n\t\t\t\t\t\t\tds.Tables[\"TEST\"].Rows[0][\"TIMESTAMP_FIELD\"] = dtValue;\n\n\t\t\t\t\t\t\tadapter.Update(ds, \"TEST\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"SELECT timestamp_field FROM TEST WHERE int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\tvar val = (DateTime)await command.ExecuteScalarAsync();\n\t\t\t\tAssert.AreEqual(dtValue.Day, val.Day, \"timestamp_field has not correct day\");\n\t\t\t\tAssert.AreEqual(dtValue.Month, val.Month, \"timestamp_field has not correct month\");\n\t\t\t\tAssert.AreEqual(dtValue.Year, val.Year, \"timestamp_field has not correct year\");\n\t\t\t\tAssert.AreEqual(dtValue.Hour, val.Hour, \"timestamp_field has not correct hour\");\n\t\t\t\tAssert.AreEqual(dtValue.Minute, val.Minute, \"timestamp_field has not correct minute\");\n\t\t\t\tAssert.AreEqual(dtValue.Second, val.Second, \"timestamp_field has not correct second\");\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UpdateClobTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST where int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t\t{\n\t\t\t\t\tusing (var builder = new FbCommandBuilder(adapter))\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\t\tadapter.SelectCommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tadapter.Fill(ds, \"TEST\");\n\n\t\t\t\t\t\t\tAssert.AreEqual(1, ds.Tables[\"TEST\"].Rows.Count, \"Incorrect row count\");\n\n\t\t\t\t\t\t\tds.Tables[\"TEST\"].Rows[0][\"CLOB_FIELD\"] = \"ONE THOUSAND\";\n\n\t\t\t\t\t\t\tadapter.Update(ds, \"TEST\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DeleteTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST where int_field = @int_field\", Connection, transaction))\n\t\t\t{\n\t\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t\t{\n\t\t\t\t\tusing (var builder = new FbCommandBuilder(adapter))\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\t\tadapter.SelectCommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 10;\n\t\t\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tadapter.Fill(ds, \"TEST\");\n\n\t\t\t\t\t\t\tAssert.AreEqual(1, ds.Tables[\"TEST\"].Rows.Count, \"Incorrect row count\");\n\n\t\t\t\t\t\t\tds.Tables[\"TEST\"].Rows[0].Delete();\n\n\t\t\t\t\t\t\tadapter.Update(ds, \"TEST\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SubsequentDeletes()\n\t{\n\t\tawait using (var select = new FbCommand(\"SELECT * FROM test\", Connection))\n\t\t{\n\t\t\tawait using (var delete = new FbCommand(\"DELETE FROM test WHERE int_field = @id\", Connection))\n\t\t\t{\n\t\t\t\tdelete.Parameters.Add(\"@id\", FbDbType.Integer);\n\t\t\t\tdelete.Parameters[0].SourceColumn = \"INT_FIELD\";\n\t\t\t\tusing (var adapter = new FbDataAdapter(select))\n\t\t\t\t{\n\t\t\t\t\tadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;\n\t\t\t\t\tadapter.DeleteCommand = delete;\n\t\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t\t{\n\t\t\t\t\t\tadapter.Fill(ds);\n\n\t\t\t\t\t\tds.Tables[0].Rows[0].Delete();\n\t\t\t\t\t\tadapter.Update(ds);\n\n\t\t\t\t\t\tds.Tables[0].Rows[0].Delete();\n\t\t\t\t\t\tadapter.Update(ds);\n\n\t\t\t\t\t\tds.Tables[0].Rows[0].Delete();\n\t\t\t\t\t\tadapter.Update(ds);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbDataReaderTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbDataReaderTests : FbTestsBase\n{\n\tpublic FbDataReaderTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic async Task ReadTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST\", Connection, transaction))\n\t\t\t{\n\t\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\tfor (var i = 0; i < reader.FieldCount; i++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treader.GetValue(i);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReadClobTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST\", Connection, transaction))\n\t\t\t{\n\t\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\treader.GetValue(\"clob_field\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task BigIntGetStringTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST\", Connection, transaction))\n\t\t\t{\n\t\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\treader.GetString(\"bigint_field\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task GetValuesTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST\", Connection, transaction))\n\t\t\t{\n\t\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\tvar values = new object[reader.FieldCount];\n\t\t\t\t\t\treader.GetValues(values);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task IndexerByIndexTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST\", Connection, transaction))\n\t\t\t{\n\t\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\tfor (var i = 0; i < reader.FieldCount; i++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvar dummy = reader[i];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task IndexerByNameTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST\", Connection, transaction))\n\t\t\t{\n\t\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\tfor (var i = 0; i < reader.FieldCount; i++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvar dummy = reader[reader.GetName(i)];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task GetSchemaTableTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST\", Connection, transaction))\n\t\t\t{\n\t\t\t\tawait using (var reader = await command.ExecuteReaderAsync(CommandBehavior.SchemaOnly))\n\t\t\t\t{\n\t\t\t\t\tusing (var schema = await reader.GetSchemaTableAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\tvar currRows = schema.Select(null, null, DataViewRowState.CurrentRows);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task GetSchemaTableWithExpressionFieldTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select TEST.*, 0 AS VALOR from TEST\", Connection, transaction))\n\t\t\t{\n\t\t\t\tawait using (var reader = await command.ExecuteReaderAsync(CommandBehavior.SchemaOnly))\n\t\t\t\t{\n\t\t\t\t\tusing (var schema = await reader.GetSchemaTableAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\tvar currRows = schema.Select(null, null, DataViewRowState.CurrentRows);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task RecordAffectedTest()\n\t{\n\t\tawait using (var command = new FbCommand(\"insert into test (int_field) values (100000)\", Connection))\n\t\t{\n\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t{ }\n\t\t\t\tAssert.AreEqual(1, reader.RecordsAffected);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task GetBytesLengthTest()\n\t{\n\t\tawait using (var command = new FbCommand(\"select blob_field from TEST where int_field = @int_field\", Connection))\n\t\t{\n\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 2;\n\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tawait reader.ReadAsync();\n\t\t\t\tvar length = reader.GetBytes(0, 0, null, 0, 0);\n\t\t\t\tAssert.AreEqual(13, length, \"Incorrect blob length\");\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task GetCharsLengthTest()\n\t{\n\t\tawait using (var command = new FbCommand(\"select clob_field from TEST where int_field = @int_field\", Connection))\n\t\t{\n\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 50;\n\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tawait reader.ReadAsync();\n\t\t\t\tvar length = reader.GetChars(0, 0, null, 0, 0);\n\t\t\t\tAssert.AreEqual(14, length, \"Incorrect clob length\");\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ValidateDecimalSchema()\n\t{\n\t\tawait using (var test = new FbCommand(\"select decimal_field from test\", Connection))\n\t\t{\n\t\t\tawait using (var r = await test.ExecuteReaderAsync(CommandBehavior.SchemaOnly))\n\t\t\t{\n\t\t\t\tusing (var schema = await r.GetSchemaTableAsync())\n\t\t\t\t{\n\t\t\t\t\tAssert.AreEqual(schema.Rows[0][\"ColumnSize\"], 8, \"Invalid length\");\n\t\t\t\t\tAssert.AreEqual(schema.Rows[0][\"NumericPrecision\"], 15, \"Invalid precision\");\n\t\t\t\t\tAssert.AreEqual(schema.Rows[0][\"NumericScale\"], 2, \"Invalid scale\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DisposeTest()\n\t{\n\t\tawait using (var command = new FbCommand(\"DATAREADERTEST\", Connection))\n\t\t{\n\t\t\tcommand.CommandType = CommandType.StoredProcedure;\n\t\t\tFbCommandBuilder.DeriveParameters(command);\n\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t{ }\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task GetOrdinalTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select first 1 0 as fOo, 0 as \\\"BaR\\\", 0 as BAR from TEST\", Connection, transaction))\n\t\t\t{\n\t\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\tvar foo = reader.GetOrdinal(\"foo\");\n\t\t\t\t\t\tvar FOO = reader.GetOrdinal(\"FOO\");\n\t\t\t\t\t\tvar fOo = reader.GetOrdinal(\"fOo\");\n\t\t\t\t\t\tAssert.AreEqual(0, foo);\n\t\t\t\t\t\tAssert.AreEqual(0, FOO);\n\t\t\t\t\t\tAssert.AreEqual(0, fOo);\n\n\t\t\t\t\t\tvar bar = reader.GetOrdinal(\"bar\");\n\t\t\t\t\t\tvar BaR = reader.GetOrdinal(\"BaR\");\n\t\t\t\t\t\tAssert.AreEqual(1, bar);\n\t\t\t\t\t\tAssert.AreEqual(1, BaR);\n\n\t\t\t\t\t\tvar BAR = reader.GetOrdinal(\"BAR\");\n\t\t\t\t\t\tAssert.AreEqual(2, BAR);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReadBinaryTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tvar bytes = new byte[1024];\n\t\t\tvar random = new Random();\n\t\t\tfor (var i = 0; i < bytes.Length; i++)\n\t\t\t{\n\t\t\t\tbytes[i] = (byte)random.Next(byte.MinValue, byte.MaxValue);\n\t\t\t}\n\t\t\tvar binaryString = $\"x'{Convert.ToHexString(bytes)}'\";\n\n\t\t\tawait using (var command = new FbCommand($\"select {binaryString} from TEST\", Connection, transaction))\n\t\t\t{\n\t\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\tvar value = (byte[])reader[0];\n\t\t\t\t\t\tAssert.AreEqual(bytes, value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReadGuidRoundTripTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tvar guid = Guid.NewGuid();\n\t\t\tvar commandText = $\"select char_to_uuid('{guid}') from rdb$database\";\n\t\t\tcmd.CommandText = commandText;\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tAssert.AreEqual(guid, reader.GetGuid(0));\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tAssert.Fail();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReadGuidRoundTrip2Test()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tvar commandText = @\"\nexecute block\nreturns (a varchar(16) character set octets, b varchar(36) character set ascii)\nas\ndeclare guid varchar(16) character set octets;\nbegin\n\tguid = gen_uuid();\n\tfor select :guid, uuid_to_char(:guid) from rdb$database into a, b do\n\tbegin\n\t\tsuspend;\n\tend\nend\";\n\t\t\tcmd.CommandText = commandText;\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tStringAssert.AreEqualIgnoringCase(reader.GetString(1), reader.GetGuid(0).ToString());\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tAssert.Fail();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReadGuidRoundTrip3Test()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tvar guid = Guid.NewGuid();\n\t\t\tvar commandText = $\"select cast(@guid as varchar(16) character set octets) from rdb$database\";\n\t\t\tcmd.CommandText = commandText;\n\t\t\tcmd.Parameters.Add(\"guid\", guid);\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tAssert.AreEqual(guid, reader.GetGuid(0));\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tAssert.Fail();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DNET60_EmptyFieldReadingError()\n\t{\n\t\tawait using (var command = Connection.CreateCommand())\n\t\t{\n\t\t\tcommand.CommandText = \"select '' AS EmptyColumn from rdb$database\";\n\t\t\tawait using (var r = await command.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\twhile (await r.ReadAsync())\n\t\t\t\t{ }\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DNET183_VarcharSpacesShouldNotBeTrimmed()\n\t{\n\t\tconst string value = \"foo  \";\n\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@foo as varchar(5)) from rdb$database\";\n\t\t\tcmd.Parameters.Add(new FbParameter() { ParameterName = \"@foo\", FbDbType = FbDbType.VarChar, Size = 5, Value = value });\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tAssert.AreEqual(value, (string)reader[0]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DNET749_CommandBehaviorCloseConnectionStackOverflow()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select * from rdb$database\";\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync(CommandBehavior.CloseConnection))\n\t\t\t{\n\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t{ }\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReadCancellation()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(2, 5, 0, 0)))\n\t\t\treturn;\n\n\t\tusing (var cts = new CancellationTokenSource())\n\t\t{\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.FetchSize = 1;\n\t\t\t\tcmd.CommandText =\n@\"execute block\nreturns (i int)\nas\ndeclare variable start_time timestamp;\nbegin\n\ti = 0;\n\twhile (i < 100) do\n\tbegin\n\t\ti = i + 1;\n\t\tsuspend;\n\n\t\tstart_time = cast('now' as timestamp);\n\t\twhile (datediff(second from start_time to cast('now' as timestamp)) <= 2) do\n\t\tbegin\n\t\tend\n\tend\nend\";\n\t\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\tawait reader.ReadAsync(cts.Token);\n\t\t\t\t\tcts.CancelAfter(100);\n\t\t\t\t\tAssert.ThrowsAsync<OperationCanceledException>(async () =>\n\t\t\t\t\t{\n\t\t\t\t\t\twhile (await reader.ReadAsync(cts.Token))\n\t\t\t\t\t\t{ }\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReadOnAlreadyCancelledToken()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(2, 5, 0, 0)))\n\t\t\treturn;\n\n\t\tusing (var cts = new CancellationTokenSource())\n\t\t{\n\t\t\tcts.Cancel();\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"select 1 from rdb$database\";\n\t\t\t\tAssert.ThrowsAsync<OperationCanceledException>(() => cmd.ExecuteReaderAsync(cts.Token));\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task GetFieldValueTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select * from TEST\", Connection, transaction))\n\t\t\t{\n\t\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\tawait reader.GetFieldValueAsync<int>(\"int_field\");\n\t\t\t\t\t\tawait reader.GetFieldValueAsync<long>(\"bigint_field\");\n\t\t\t\t\t\tawait reader.GetFieldValueAsync<string>(\"varchar_field\");\n\t\t\t\t\t\tawait reader.GetFieldValueAsync<TimeOnly>(\"time_field\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbDatabaseInfoTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Linq;\nusing System.Reflection;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbDatabaseInfoTests : FbTestsBase\n{\n\tpublic FbDatabaseInfoTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic void CompleteDatabaseInfoTest()\n\t{\n\t\tvar dbInfo = new FbDatabaseInfo(Connection);\n\t\tforeach (var m in dbInfo.GetType()\n\t\t\t.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly)\n\t\t\t.Where(x => !x.IsSpecialName)\n\t\t\t.Where(x => x.Name.EndsWith(\"Async\")))\n\t\t{\n\t\t\tif (ServerVersion < new Version(4, 0, 0, 0)\n\t\t\t\t && new[] {\n\t\t\t\t\t\tnameof(FbDatabaseInfo.GetWireCryptAsync),\n\t\t\t\t\t\tnameof(FbDatabaseInfo.GetCryptPluginAsync),\n\t\t\t\t\t\tnameof(FbDatabaseInfo.GetNextAttachmentAsync),\n\t\t\t\t\t\tnameof(FbDatabaseInfo.GetNextStatementAsync),\n\t\t\t\t\t\tnameof(FbDatabaseInfo.GetReplicaModeAsync),\n\t\t\t\t\t\tnameof(FbDatabaseInfo.GetDbFileIdAsync),\n\t\t\t\t\t\tnameof(FbDatabaseInfo.GetDbGuidAsync),\n\t\t\t\t\t\tnameof(FbDatabaseInfo.GetCreationTimestampAsync),\n\t\t\t\t\t\tnameof(FbDatabaseInfo.GetProtocolVersionAsync),\n\t\t\t\t\t\tnameof(FbDatabaseInfo.GetStatementTimeoutDatabaseAsync),\n\t\t\t\t\t\tnameof(FbDatabaseInfo.GetStatementTimeoutAttachmentAsync),\n\t\t\t\t}.Contains(m.Name))\n\t\t\t\tcontinue;\n\n\t\t\tAssert.DoesNotThrowAsync(() => (Task)m.Invoke(dbInfo, new object[] { CancellationToken.None }), m.Name);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbDecFloat16SupportTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Numerics;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing FirebirdSql.Data.Types;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbDecFloat16SupportTests : FbTestsBase\n{\n\tpublic FbDecFloat16SupportTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt, false)\n\t{ }\n\n\t[SetUp]\n\tpublic override async Task SetUp()\n\t{\n\t\tawait base.SetUp();\n\n\t\tif (!EnsureServerVersionAtLeast(new Version(4, 0, 0, 0)))\n\t\t\treturn;\n\t}\n\n\tstatic readonly object[] TestValues = new[]\n\t{\n\t\t\tnew object[] { (FbDecFloat)0, \"0\" },\n\t\t\tnew object[] { (FbDecFloat)1, \"1\" },\n\t\t\tnew object[] { (FbDecFloat)(-1), \"-1\" },\n\t\t\tnew object[] { (FbDecFloat)6, \"6\" },\n\t\t\tnew object[] { (FbDecFloat)(-6), \"-6\" },\n\t\t\tnew object[] { FbDecFloat.NegativeZero, \"-0\" },\n\t\t\tnew object[] { FbDecFloat.PositiveInfinity, \"inf\" },\n\t\t\tnew object[] { FbDecFloat.NegativeInfinity, \"-inf\" },\n\t\t\tnew object[] { FbDecFloat.PositiveNaN, \"nan\" },\n\t\t\tnew object[] { FbDecFloat.NegativeNaN, \"-nan\" },\n\t\t\tnew object[] { FbDecFloat.PositiveSignalingNaN, \"snan\" },\n\t\t\tnew object[] { FbDecFloat.NegativeSignalingNaN, \"-snan\" },\n\t\t\tnew object[] { (FbDecFloat)0.1, \"0.1\" },\n\t\t\tnew object[] { (FbDecFloat)(-0.1), \"-0.1\" },\n\t\t\tnew object[] { (FbDecFloat)6.6, \"6.6\" },\n\t\t\tnew object[] { (FbDecFloat)(-6.6), \"-6.6\" },\n\t\t\tnew object[] { new FbDecFloat(10, 34), \"100000000000000000000000000000000000\" },\n\t\t\tnew object[] { new FbDecFloat(-10, 34), \"-100000000000000000000000000000000000\" },\n\t\t\tnew object[] { new FbDecFloat(BigInteger.Parse(\"123000000001\"), -10), \"123.000000001E-1\" },\n\t\t\tnew object[] { new FbDecFloat(BigInteger.Parse(\"-123000000001\"), -10), \"-123.000000001E-1\" },\n\t\t};\n\n\t[TestCaseSource(nameof(TestValues))]\n\tpublic async Task ReadsValueCorrectly(FbDecFloat value, string castValue)\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = $\"select cast('{castValue}' as decfloat(16)) from rdb$database\";\n\t\t\tvar result = (FbDecFloat)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(value, result);\n\t\t}\n\t}\n\n\t[TestCaseSource(nameof(TestValues))]\n\tpublic async Task PassesValueCorrectly(FbDecFloat value, string dummy)\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@value as decfloat(16)) from rdb$database\";\n\t\t\tcmd.Parameters.AddWithValue(\"value\", value);\n\t\t\tvar result = (FbDecFloat)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(value, result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReadsValueNullCorrectly()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(null as decfloat(16)) from rdb$database\";\n\t\t\tvar result = (DBNull)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(DBNull.Value, result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task PassesValueNullCorrectly()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@value as decfloat(16)) from rdb$database\";\n\t\t\tcmd.Parameters.AddWithValue(\"value\", DBNull.Value);\n\t\t\tvar result = (DBNull)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(DBNull.Value, result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectEmptyResultSet()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(null as decfloat(16)) from rdb$database where 0=1\";\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tAssert.DoesNotThrowAsync(reader.ReadAsync);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SimpleSelectSchemaTableTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(null as decfloat(16)) from rdb$database\";\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tvar schema = await reader.GetSchemaTableAsync();\n\t\t\t\tAssert.AreEqual(typeof(FbDecFloat), schema.Rows[0].ItemArray[5]);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbDecFloat34SupportTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Numerics;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing FirebirdSql.Data.Types;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbDecFloat34SupportTests : FbTestsBase\n{\n\tpublic FbDecFloat34SupportTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt, false)\n\t{ }\n\n\t[SetUp]\n\tpublic override async Task SetUp()\n\t{\n\t\tawait base.SetUp();\n\n\t\tif (!EnsureServerVersionAtLeast(new Version(4, 0, 0, 0)))\n\t\t\treturn;\n\t}\n\n\tstatic readonly object[] TestValues = new[]\n\t{\n\t\t\tnew object[] { (FbDecFloat)0, \"0\" },\n\t\t\tnew object[] { (FbDecFloat)1, \"1\" },\n\t\t\tnew object[] { (FbDecFloat)(-1), \"-1\" },\n\t\t\tnew object[] { (FbDecFloat)6, \"6\" },\n\t\t\tnew object[] { (FbDecFloat)(-6), \"-6\" },\n\t\t\tnew object[] { FbDecFloat.NegativeZero, \"-0\" },\n\t\t\tnew object[] { FbDecFloat.PositiveInfinity, \"inf\" },\n\t\t\tnew object[] { FbDecFloat.NegativeInfinity, \"-inf\" },\n\t\t\tnew object[] { FbDecFloat.PositiveNaN, \"nan\" },\n\t\t\tnew object[] { FbDecFloat.NegativeNaN, \"-nan\" },\n\t\t\tnew object[] { FbDecFloat.PositiveSignalingNaN, \"snan\" },\n\t\t\tnew object[] { FbDecFloat.NegativeSignalingNaN, \"-snan\" },\n\t\t\tnew object[] { (FbDecFloat)0.1, \"0.1\" },\n\t\t\tnew object[] { (FbDecFloat)(-0.1), \"-0.1\" },\n\t\t\tnew object[] { (FbDecFloat)6.6, \"6.6\" },\n\t\t\tnew object[] { (FbDecFloat)(-6.6), \"-6.6\" },\n\t\t\tnew object[] { new FbDecFloat(10, 34), \"100000000000000000000000000000000000\" },\n\t\t\tnew object[] { new FbDecFloat(-10, 34), \"-100000000000000000000000000000000000\" },\n\t\t\tnew object[] { new FbDecFloat(BigInteger.Parse(\"123000000001\"), -10), \"123.000000001E-1\" },\n\t\t\tnew object[] { new FbDecFloat(BigInteger.Parse(\"-123000000001\"), -10), \"-123.000000001E-1\" },\n\t\t};\n\n\t[TestCaseSource(nameof(TestValues))]\n\tpublic async Task ReadsValueCorrectly(FbDecFloat value, string castValue)\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = $\"select cast('{castValue}' as decfloat(34)) from rdb$database\";\n\t\t\tvar result = (FbDecFloat)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(value, result);\n\t\t}\n\t}\n\n\t[TestCaseSource(nameof(TestValues))]\n\tpublic async Task PassesValueCorrectly(FbDecFloat value, string dummy)\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@value as decfloat(34)) from rdb$database\";\n\t\t\tcmd.Parameters.AddWithValue(\"value\", value);\n\t\t\tvar result = (FbDecFloat)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(value, result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReadsValueNullCorrectly()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(null as decfloat(34)) from rdb$database\";\n\t\t\tvar result = (DBNull)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(DBNull.Value, result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task PassesValueNullCorrectly()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@value as decfloat(34)) from rdb$database\";\n\t\t\tcmd.Parameters.AddWithValue(\"value\", DBNull.Value);\n\t\t\tvar result = (DBNull)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(DBNull.Value, result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectEmptyResultSet()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(null as decfloat(34)) from rdb$database where 0=1\";\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tAssert.DoesNotThrowAsync(reader.ReadAsync);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SimpleSelectSchemaTableTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(null as decfloat(34)) from rdb$database\";\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tvar schema = await reader.GetSchemaTableAsync();\n\t\t\t\tAssert.AreEqual(typeof(FbDecFloat), schema.Rows[0].ItemArray[5]);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbDecFloatTypeTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Numerics;\nusing FirebirdSql.Data.TestsBase;\nusing FirebirdSql.Data.Types;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[NoServerCategory]\npublic class FbDecFloatTypeTests\n{\n\tstatic readonly object[] SimpleEqualityTrueSource = new object[]\n\t{\n\t\t\tnew object[] { new FbDecFloat(0), new FbDecFloat(0) },\n\t\t\tnew object[] { new FbDecFloat(10, 0), new FbDecFloat(10, 0) },\n\t\t\tnew object[] { new FbDecFloat(6, 3), new FbDecFloat(6, 3) },\n\t\t\tnew object[] { new FbDecFloat(6, -3), new FbDecFloat(6, -3) },\n\t\t\tnew object[] { new FbDecFloat(-6, 3), new FbDecFloat(-6, 3) },\n\t\t\tnew object[] { new FbDecFloat(-6, -3), new FbDecFloat(-6, -3) },\n\t\t\tnew object[] { new FbDecFloat(BigInteger.Parse(\"986767875675879890678765756798079808709\"), 1), new FbDecFloat(BigInteger.Parse(\"986767875675879890678765756798079808709\"), 1) },\n\t\t\tnew object[] { new FbDecFloat(10, 3), new FbDecFloat(100, 2) },\n\t\t\tnew object[] { new FbDecFloat(-10, 3), new FbDecFloat(-100, 2) },\n\t\t\tnew object[] { new FbDecFloat(10, -3), new FbDecFloat(1, -2) },\n\t\t\tnew object[] { new FbDecFloat(-10, -3), new FbDecFloat(-1, -2) },\n\t\t\tnew object[] { FbDecFloat.PositiveInfinity, FbDecFloat.PositiveInfinity },\n\t\t\tnew object[] { FbDecFloat.NegativeInfinity, FbDecFloat.NegativeInfinity },\n\t\t\tnew object[] { FbDecFloat.PositiveNaN, FbDecFloat.PositiveNaN },\n\t};\n\t[TestCaseSource(nameof(SimpleEqualityTrueSource))]\n\tpublic void EqualityTrue(FbDecFloat expected, FbDecFloat actual)\n\t{\n\t\tAssert.AreEqual(expected, actual);\n\t}\n\n\tstatic readonly object[] SimpleEqualityFalseSource = new object[]\n\t{\n\t\t\tnew object[] { new FbDecFloat(0), new FbDecFloat(BigInteger.Parse(\"986767875675879890678765756798079808709\")) },\n\t\t\tnew object[] { new FbDecFloat(6, 3), new FbDecFloat(-6, 3) },\n\t\t\tnew object[] { new FbDecFloat(6, 3), new FbDecFloat(6, -3) },\n\t\t\tnew object[] { FbDecFloat.PositiveInfinity, FbDecFloat.NegativeInfinity },\n\t\t\tnew object[] { FbDecFloat.PositiveNaN, FbDecFloat.NegativeNaN },\n\t\t\tnew object[] { FbDecFloat.PositiveInfinity, FbDecFloat.PositiveNaN },\n\t\t\tnew object[] { FbDecFloat.NegativeInfinity, FbDecFloat.NegativeNaN },\n\t};\n\t[TestCaseSource(nameof(SimpleEqualityFalseSource))]\n\tpublic void EqualityFalse(FbDecFloat expected, FbDecFloat actual)\n\t{\n\t\tAssert.AreNotEqual(expected, actual);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbExceptionTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\nclass FbExceptionTests : FbTestsBase\n{\n\tpublic FbExceptionTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic async Task SQLSTATETest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"drop exception nonexisting\";\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t\tcatch (FbException ex)\n\t\t\t{\n\t\t\t\tAssert.AreEqual(\"42000\", ex.SQLSTATE);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbImplicitTransactionTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Text;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbImplicitTransactionTests : FbTestsBase\n{\n\tpublic FbImplicitTransactionTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic async Task DataAdapterFillTest()\n\t{\n\t\tawait using (var command = new FbCommand(\"select * from TEST where DATE_FIELD <> ?\", Connection))\n\t\t{\n\t\t\tusing (var adapter = new FbDataAdapter(command))\n\t\t\t{\n\t\t\t\tadapter.SelectCommand.Parameters.Add(\"@DATE_FIELD\", FbDbType.Date, 4, \"DATE_FIELD\").Value = new DateTime(2003, 1, 5);\n\t\t\t\tusing (var ds = new DataSet())\n\t\t\t\t{\n\t\t\t\t\tadapter.Fill(ds, \"TEST\");\n\n\t\t\t\t\tAssert.AreEqual(1, ds.Tables.Count);\n\t\t\t\t\tAssert.Greater(ds.Tables[0].Rows.Count, 0);\n\t\t\t\t\tAssert.Greater(ds.Tables[0].Columns.Count, 0);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ExecuteScalarTest()\n\t{\n\t\tawait using (var command = new FbCommand(\"select sum(int_field) from TEST\", Connection))\n\t\t{\n\t\t\tAssert.DoesNotThrowAsync(command.ExecuteScalarAsync);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UpdatedClobFieldTest()\n\t{\n\t\tawait using (var command = new FbCommand(\"update TEST set clob_field = @clob_field where int_field = @int_field\", Connection))\n\t\t{\n\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\tcommand.Parameters.Add(\"@clob_field\", FbDbType.Text).Value = \"Clob field update with implicit transaction\";\n\t\t\tvar i = await command.ExecuteNonQueryAsync();\n\n\t\t\tAssert.AreEqual(i, 1, \"Clob field update with implicit transaction failed\");\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UpdatedBlobFieldTest()\n\t{\n\t\tawait using (var command = new FbCommand(\"update TEST set blob_field = @blob_field where int_field = @int_field\", Connection))\n\t\t{\n\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\tcommand.Parameters.Add(\"@blob_field\", FbDbType.Binary).Value = Encoding.UTF8.GetBytes(\"Blob field update with implicit transaction\");\n\t\t\tvar i = await command.ExecuteNonQueryAsync();\n\n\t\t\tAssert.AreEqual(i, 1, \"Blob field update with implicit transaction failed\");\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task UpdatedArrayFieldTest()\n\t{\n\t\tvar values = new int[] { 10, 20, 30, 40 };\n\t\tawait using (var command = new FbCommand(\"update TEST set iarray_field = @iarray_field where int_field = @int_field\", Connection))\n\t\t{\n\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer).Value = 1;\n\t\t\tcommand.Parameters.Add(\"@iarray_field\", FbDbType.Array).Value = values;\n\t\t\tvar i = await command.ExecuteNonQueryAsync();\n\n\t\t\tAssert.AreEqual(i, 1, \"Array field update with implicit transaction failed\");\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbInt128SupportTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Globalization;\nusing System.Numerics;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbInt128SupportTests : FbTestsBase\n{\n\tpublic FbInt128SupportTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt, false)\n\t{ }\n\n\t[SetUp]\n\tpublic override async Task SetUp()\n\t{\n\t\tawait base.SetUp();\n\n\t\tif (!EnsureServerVersionAtLeast(new Version(4, 0, 0, 0)))\n\t\t\treturn;\n\t}\n\n\tstatic readonly BigInteger[] TestValues = new[]\n\t{\n\t\t\tBigInteger.Parse(\"0\"),\n\t\t\tBigInteger.Parse(\"1\"),\n\t\t\tBigInteger.Parse(\"-1\"),\n\t\t\tBigInteger.Parse(\"6\"),\n\t\t\tBigInteger.Parse(\"-6\"),\n\t\t\tBigInteger.Parse(\"184467440737095516190874\"),\n\t\t\tBigInteger.Parse(\"-184467440737095516190874\"),\n\t\t};\n\n\t[TestCaseSource(nameof(TestValues))]\n\tpublic async Task ReadsValueCorrectly(BigInteger value)\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tvar svalue = value.ToString(CultureInfo.InvariantCulture);\n\t\t\tcmd.CommandText = $\"select cast({svalue} as int128) from rdb$database\";\n\t\t\tvar result = (BigInteger)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(value, result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic Task CanReadAsByte() => CanReadAsTypeHelper<byte>(6, r => r.GetByte(0));\n\t[Test]\n\tpublic Task CanReadAsInt16() => CanReadAsTypeHelper<short>(6, r => r.GetInt16(0));\n\t[Test]\n\tpublic Task CanReadAsInt32() => CanReadAsTypeHelper<int>(6, r => r.GetInt32(0));\n\t[Test]\n\tpublic Task CanReadAsInt64() => CanReadAsTypeHelper<long>(6, r => r.GetInt64(0));\n\n\t[TestCaseSource(nameof(TestValues))]\n\tpublic async Task PassesValueCorrectly(BigInteger value)\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@value as int128) from rdb$database\";\n\t\t\tcmd.Parameters.AddWithValue(\"value\", value);\n\t\t\tvar result = (BigInteger)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(value, result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic Task CanPassAsByte() => CanPassAsTypeHelper<byte>(6);\n\t[Test]\n\tpublic Task CanPassAsInt16() => CanPassAsTypeHelper<short>(6);\n\t[Test]\n\tpublic Task CanPassAsInt32() => CanPassAsTypeHelper<int>(6);\n\t[Test]\n\tpublic Task CanPassAsInt64() => CanPassAsTypeHelper<long>(6);\n\n\t[Test]\n\tpublic async Task ReadsValueNullCorrectly()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(null as int128) from rdb$database\";\n\t\t\tvar result = (DBNull)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(DBNull.Value, result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task PassesValueNullCorrectly()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@value as int128) from rdb$database\";\n\t\t\tcmd.Parameters.AddWithValue(\"value\", DBNull.Value);\n\t\t\tvar result = (DBNull)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(DBNull.Value, result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectEmptyResultSet()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(null as int128) from rdb$database where 0=1\";\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tAssert.DoesNotThrowAsync(reader.ReadAsync);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SimpleSelectSchemaTableTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(null as int128) from rdb$database\";\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tvar schema = await reader.GetSchemaTableAsync();\n\t\t\t\tAssert.AreEqual(typeof(BigInteger), schema.Rows[0].ItemArray[5]);\n\t\t\t}\n\t\t}\n\t}\n\n\tasync Task CanReadAsTypeHelper<T>(T value, Func<FbDataReader, T> getter)\n\t\twhere T : IFormattable\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tvar svalue = value.ToString(null, CultureInfo.InvariantCulture);\n\t\t\tcmd.CommandText = $\"select cast({svalue} as int128) from rdb$database\";\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tawait reader.ReadAsync();\n\t\t\t\tAssert.AreEqual(value, getter(reader));\n\t\t\t}\n\t\t}\n\t}\n\n\tasync Task CanPassAsTypeHelper<T>(T value)\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@value as int128) from rdb$database\";\n\t\t\tcmd.Parameters.AddWithValue(\"value\", value);\n\t\t\tAssert.DoesNotThrowAsync(cmd.ExecuteScalarAsync);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbLongNumericsSupportTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Globalization;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbLongNumericsSupportTests : FbTestsBase\n{\n\tpublic FbLongNumericsSupportTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[SetUp]\n\tpublic override async Task SetUp()\n\t{\n\t\tawait base.SetUp();\n\n\t\tif (!EnsureServerVersionAtLeast(new Version(4, 0, 0, 0)))\n\t\t\treturn;\n\t}\n\n\tstatic readonly object[] TestValues = new[]\n\t{\n\t\t\tnew object[] { 3.14159265359m, 20 },\n\t\t\tnew object[] { 7465205690.61m, 4 },\n\t\t};\n\n\t[TestCaseSource(nameof(TestValues))]\n\tpublic async Task ReadsValueCorrectly(decimal value, int scale)\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tvar svalue = value.ToString(CultureInfo.InvariantCulture);\n\t\t\tcmd.CommandText = $\"select cast({svalue} as decimal(20, {scale})) from rdb$database\";\n\t\t\tvar result = (decimal)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(value, result);\n\t\t}\n\t}\n\n\t[TestCaseSource(nameof(TestValues))]\n\tpublic async Task PassesValueCorrectly(decimal value, int scale)\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = $\"select cast(@value as decimal(20, {scale})) from rdb$database\";\n\t\t\tcmd.Parameters.AddWithValue(\"value\", value);\n\t\t\tvar result = (decimal)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(value, result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReadsValueNullCorrectly()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(null as decimal(20, 6)) from rdb$database\";\n\t\t\tvar result = (DBNull)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(DBNull.Value, result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task PassesValueNullCorrectly()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@value as decimal(20, 6)) from rdb$database\";\n\t\t\tcmd.Parameters.AddWithValue(\"value\", DBNull.Value);\n\t\t\tvar result = (DBNull)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(DBNull.Value, result);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SimpleSelectSchemaTableTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(null as decimal(20, 6)) from rdb$database\";\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tvar schema = await reader.GetSchemaTableAsync();\n\t\t\t\tAssert.AreEqual(typeof(decimal), schema.Rows[0].ItemArray[5]);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbParameterCollectionTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Globalization;\nusing System.Threading;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[NoServerCategory]\npublic class FbParameterCollectionTests\n{\n\t[Test]\n\tpublic void AddTest()\n\t{\n\t\tvar command = new FbCommand();\n\t\tcommand.Parameters.Add(new FbParameter(\"@p292\", 10000));\n\t\tcommand.Parameters.Add(\"@p01\", FbDbType.Integer);\n\t\tcommand.Parameters.Add(\"@p02\", 289273);\n\t\tcommand.Parameters.Add(\"#p3\", FbDbType.SmallInt, 2, \"sourceColumn\");\n\t}\n\n\t[Test]\n\tpublic void DNET532_CheckCultureAwareIndexOf()\n\t{\n\t\tvar curCulture = Thread.CurrentThread.CurrentCulture;\n\t\ttry\n\t\t{\n\t\t\tThread.CurrentThread.CurrentCulture = new CultureInfo(\"tr-TR\");\n\t\t\tvar command = new FbCommand();\n\t\t\t// \\u0131 is turkish symbol \"i without dot\" that uppercases to \"I\" symbol.\n\t\t\t// see https://msdn.microsoft.com/en-us/library/ms973919.aspx#stringsinnet20_topic5 for more information\n\t\t\tvar parameterName = \"Turkish\\u0131Parameter\";\n\t\t\tcommand.Parameters.Add(parameterName, FbDbType.Char);\n\t\t\tAssert.AreNotEqual(-1, command.Parameters.IndexOf(\"turkishIParameter\"));\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tThread.CurrentThread.CurrentCulture = curCulture;\n\t\t}\n\t}\n\n\t[Test]\n\tpublic void DNET532_CheckFlagForUsingOrdinalIgnoreCase()\n\t{\n\t\tvar command = new FbCommand();\n\t\tcommand.Parameters.IndexOf(\"SomeField\");\n\n\t\tfor (var i = 0; i < 100; ++i)\n\t\t{\n\t\t\tcommand.Parameters.Add(\"FIELD\" + i.ToString(), FbDbType.Integer);\n\t\t}\n\n\t\tconst string probeParameterName = \"FIELD0\";\n\t\tconst int noMatterValue = 12345;\n\t\tconst int deleteIndex = 12;\n\t\tcommand.Parameters[probeParameterName].Value = noMatterValue;\n\t\tAssert.IsFalse(command.Parameters.HasParameterWithNonAsciiName);\n\n\t\tcommand.Parameters.Remove(command.Parameters[deleteIndex]);\n\t\tcommand.Parameters[probeParameterName].Value = noMatterValue;\n\n\t\tcommand.Parameters.RemoveAt(deleteIndex);\n\t\tcommand.Parameters[probeParameterName].Value = noMatterValue;\n\n\t\tcommand.Parameters.Insert(deleteIndex, new FbParameter(\"FIELD101\", FbDbType.Integer));\n\t\tcommand.Parameters[probeParameterName].Value = noMatterValue;\n\n\t\tcommand.Parameters.Clear();\n\t}\n\n\t[Test]\n\tpublic void DNET532_CheckFlagForUsingOrdinalIgnoreCaseWithOuterChanges()\n\t{\n\t\tvar collection = new FbParameterCollection();\n\t\tvar parameter = new FbParameter() { ParameterName = \"test\" };\n\t\tcollection.Add(parameter);\n\t\tvar dummy1 = collection.IndexOf(\"dummy\");\n\t\tAssert.IsFalse(collection.HasParameterWithNonAsciiName);\n\t\tparameter.ParameterName = \"řčšřčšřčš\";\n\t\tvar dummy2 = collection.IndexOf(\"dummy\");\n\t\tAssert.IsTrue(parameter.IsUnicodeParameterName);\n\t\tAssert.IsTrue(collection.HasParameterWithNonAsciiName);\n\t}\n\n\t[Test]\n\tpublic void CheckFbParameterParentPropertyInvariant()\n\t{\n\t\tvar collection = new FbParameterCollection();\n\t\tvar parameter = collection.Add(\"Name\", FbDbType.Array);\n\t\tAssert.AreEqual(collection, parameter.Parent);\n\t\tAssert.Throws<ArgumentException>(() => collection.Add(parameter));\n\t\tAssert.Throws<ArgumentException>(() => collection.AddRange(new FbParameter[] { parameter }));\n\n\t\tcollection.Remove(parameter);\n\t\tAssert.IsNull(parameter.Parent);\n\n\t\tAssert.Throws<ArgumentException>(() => collection.Remove(parameter));\n\n\t\tcollection.Insert(0, parameter);\n\t\tAssert.AreEqual(collection, parameter.Parent);\n\t\tAssert.Throws<ArgumentException>(() => collection.Insert(0, parameter));\n\t}\n\n\t[Test]\n\tpublic void DNET635_ResetsParentOnClear()\n\t{\n\t\tvar collection = new FbParameterCollection();\n\t\tvar parameter = collection.Add(\"test\", 0);\n\t\tAssert.IsNotNull(parameter.Parent);\n\t\tcollection.Clear();\n\t\tAssert.IsNull(parameter.Parent);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbParameterTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[NoServerCategory]\npublic class FbParameterTests\n{\n\t[Test]\n\tpublic void ConstructorsTest()\n\t{\n\t\tvar ctor01 = new FbParameter();\n\t\tvar ctor02 = new FbParameter(\"ctor2\", 10);\n\t\tvar ctor03 = new FbParameter(\"ctor3\", FbDbType.Char);\n\t\tvar ctor04 = new FbParameter(\"ctor4\", FbDbType.Integer, 4);\n\t\tvar ctor05 = new FbParameter(\"ctor5\", FbDbType.Integer, 4, \"int_field\");\n\t\tvar ctor06 = new FbParameter(\n\t\t\t\"ctor6\",\n\t\t\tFbDbType.Integer,\n\t\t\t4,\n\t\t\tParameterDirection.Input,\n\t\t\tfalse,\n\t\t\t0,\n\t\t\t0,\n\t\t\t\"int_field\",\n\t\t\tDataRowVersion.Original,\n\t\t\t100);\n\n\t\tctor01 = null;\n\t\tctor02 = null;\n\t\tctor03 = null;\n\t\tctor04 = null;\n\t\tctor05 = null;\n\t\tctor06 = null;\n\t}\n\n\t[Test]\n\tpublic void CloneTest()\n\t{\n\t\tvar p = new FbParameter(\"@p1\", FbDbType.Integer);\n\t\tp.Value = 1;\n\t\tp.Charset = FbCharset.Dos850;\n\n\t\tvar p1 = ((ICloneable)p).Clone() as FbParameter;\n\n\t\tAssert.AreEqual(p1.ParameterName, p.ParameterName);\n\t\tAssert.AreEqual(p1.FbDbType, p.FbDbType);\n\t\tAssert.AreEqual(p1.DbType, p.DbType);\n\t\tAssert.AreEqual(p1.Direction, p.Direction);\n\t\tAssert.AreEqual(p1.SourceColumn, p.SourceColumn);\n\t\tAssert.AreEqual(p1.SourceVersion, p.SourceVersion);\n\t\tAssert.AreEqual(p1.Charset, p.Charset);\n\t\tAssert.AreEqual(p1.IsNullable, p.IsNullable);\n\t\tAssert.AreEqual(p1.Size, p.Size);\n\t\tAssert.AreEqual(p1.Scale, p.Scale);\n\t\tAssert.AreEqual(p1.Precision, p.Precision);\n\t\tAssert.AreEqual(p1.Value, p.Value);\n\t}\n\n\t[Test]\n\tpublic void FbDbTypeFromEnumAsValueTest()\n\t{\n\t\tvar p = new FbParameter();\n\t\tp.Value = FbServerType.Embedded;\n\t\tAssert.AreEqual(FbDbType.Integer, p.FbDbType);\n\t}\n\n\t[Test]\n\tpublic void FbDbTypeFromDBNullAsValueTest()\n\t{\n\t\tvar p = new FbParameter();\n\t\tp.Value = DBNull.Value;\n\t\tAssert.AreEqual(FbDbType.VarChar, p.FbDbType);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbRemoteEventTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\npublic class FbRemoteEventTests : FbTestsBase\n{\n\tpublic FbRemoteEventTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic async Task EventSimplyComesBackTest()\n\t{\n\t\tvar exception = (Exception)null;\n\t\tvar triggered = false;\n\t\tawait using (var @event = new FbRemoteEvent(Connection.ConnectionString))\n\t\t{\n\t\t\t@event.RemoteEventError += (sender, e) =>\n\t\t\t{\n\t\t\t\texception = e.Error;\n\t\t\t};\n\t\t\t@event.RemoteEventCounts += (sender, e) =>\n\t\t\t{\n\t\t\t\ttriggered = e.Name == \"test\" && e.Counts == 1;\n\t\t\t};\n\t\t\tawait @event.OpenAsync();\n\t\t\tawait @event.QueueEventsAsync(new[] { \"test\" });\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"execute block as begin post_event 'test'; end\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t\tThread.Sleep(2000);\n\t\t\t}\n\t\t\tAssert.IsNull(exception);\n\t\t\tAssert.IsTrue(triggered);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ProperCountsSingleTest()\n\t{\n\t\tvar exception = (Exception)null;\n\t\tvar triggered = false;\n\t\tawait using (var @event = new FbRemoteEvent(Connection.ConnectionString))\n\t\t{\n\t\t\t@event.RemoteEventError += (sender, e) =>\n\t\t\t{\n\t\t\t\texception = e.Error;\n\t\t\t};\n\t\t\t@event.RemoteEventCounts += (sender, e) =>\n\t\t\t{\n\t\t\t\ttriggered = e.Name == \"test\" && e.Counts == 5;\n\t\t\t};\n\t\t\tawait @event.OpenAsync();\n\t\t\tawait @event.QueueEventsAsync(new[] { \"test\" });\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"execute block as begin post_event 'test'; post_event 'test'; post_event 'test'; post_event 'test'; post_event 'test'; end\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t\tThread.Sleep(2000);\n\t\t\t}\n\t\t\tAssert.IsNull(exception);\n\t\t\tAssert.IsTrue(triggered);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task EventNameSeparateSelectionTest()\n\t{\n\t\tvar exception = (Exception)null;\n\t\tvar triggeredA = false;\n\t\tvar triggeredB = false;\n\t\tawait using (var @event = new FbRemoteEvent(Connection.ConnectionString))\n\t\t{\n\t\t\t@event.RemoteEventError += (sender, e) =>\n\t\t\t{\n\t\t\t\texception = e.Error;\n\t\t\t};\n\t\t\t@event.RemoteEventCounts += (sender, e) =>\n\t\t\t{\n\t\t\t\tswitch (e.Name)\n\t\t\t\t{\n\t\t\t\t\tcase \"a\":\n\t\t\t\t\t\ttriggeredA = e.Counts == 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"b\":\n\t\t\t\t\t\ttriggeredB = e.Counts == 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t};\n\t\t\tawait @event.OpenAsync();\n\t\t\tawait @event.QueueEventsAsync(new[] { \"a\", \"b\" });\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"execute block as begin post_event 'b'; end\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t\tcmd.CommandText = \"execute block as begin post_event 'a'; end\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t\tThread.Sleep(2000);\n\t\t\t}\n\t\t\tAssert.IsNull(exception);\n\t\t\tAssert.IsTrue(triggeredA);\n\t\t\tAssert.IsTrue(triggeredB);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task EventNameTogetherSelectionTest()\n\t{\n\t\tvar exception = (Exception)null;\n\t\tvar triggeredA = false;\n\t\tvar triggeredB = false;\n\t\tawait using (var @event = new FbRemoteEvent(Connection.ConnectionString))\n\t\t{\n\t\t\t@event.RemoteEventError += (sender, e) =>\n\t\t\t{\n\t\t\t\texception = e.Error;\n\t\t\t};\n\t\t\t@event.RemoteEventCounts += (sender, e) =>\n\t\t\t{\n\t\t\t\tswitch (e.Name)\n\t\t\t\t{\n\t\t\t\t\tcase \"a\":\n\t\t\t\t\t\ttriggeredA = e.Counts == 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"b\":\n\t\t\t\t\t\ttriggeredB = e.Counts == 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t};\n\t\t\tawait @event.OpenAsync();\n\t\t\tawait @event.QueueEventsAsync(new[] { \"a\", \"b\" });\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"execute block as begin post_event 'b'; post_event 'a'; end\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t\tThread.Sleep(2000);\n\t\t\t}\n\t\t\tAssert.IsNull(exception);\n\t\t\tAssert.IsTrue(triggeredA);\n\t\t\tAssert.IsTrue(triggeredB);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task CancelTest()\n\t{\n\t\tvar exception = (Exception)null;\n\t\tvar triggered = 0;\n\t\tawait using (var @event = new FbRemoteEvent(Connection.ConnectionString))\n\t\t{\n\t\t\t@event.RemoteEventError += (sender, e) =>\n\t\t\t{\n\t\t\t\texception = e.Error;\n\t\t\t};\n\t\t\t@event.RemoteEventCounts += (sender, e) =>\n\t\t\t{\n\t\t\t\ttriggered++;\n\t\t\t};\n\t\t\tawait @event.OpenAsync();\n\t\t\tawait @event.QueueEventsAsync(new[] { \"test\" });\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"execute block as begin post_event 'test'; end\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t\tThread.Sleep(2000);\n\t\t\t}\n\t\t\tawait @event.CancelEventsAsync();\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"execute block as begin post_event 'test'; end\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t\tThread.Sleep(2000);\n\t\t\t}\n\t\t\tAssert.IsNull(exception);\n\t\t\tAssert.AreEqual(1, triggered);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DoubleQueueingTest()\n\t{\n\t\tawait using (var @event = new FbRemoteEvent(Connection.ConnectionString))\n\t\t{\n\t\t\tawait @event.OpenAsync();\n\t\t\tAssert.DoesNotThrowAsync(() => @event.QueueEventsAsync(new[] { \"test\" }));\n\t\t\tAssert.ThrowsAsync<InvalidOperationException>(() => @event.QueueEventsAsync(new[] { \"test\" }));\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task NoEventsAfterDispose()\n\t{\n\t\tvar triggered = 0;\n\t\tawait using (var @event = new FbRemoteEvent(Connection.ConnectionString))\n\t\t{\n\t\t\t@event.RemoteEventCounts += (sender, e) =>\n\t\t\t{\n\t\t\t\ttriggered++;\n\t\t\t};\n\t\t\tawait @event.OpenAsync();\n\t\t\tawait @event.QueueEventsAsync(new[] { \"test\" });\n\t\t\tThread.Sleep(2000);\n\t\t}\n\t\tThread.Sleep(2000);\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"execute block as begin post_event 'test'; end\";\n\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\tThread.Sleep(2000);\n\t\t}\n\t\tAssert.AreEqual(0, triggered);\n\t}\n\n\t[Test]\n\tpublic async Task NoExceptionWithDispose()\n\t{\n\t\tvar exception = (Exception)null;\n\t\tawait using (var @event = new FbRemoteEvent(Connection.ConnectionString))\n\t\t{\n\t\t\t@event.RemoteEventError += (sender, e) =>\n\t\t\t{\n\t\t\t\texception = e.Error;\n\t\t\t};\n\t\t\tawait @event.OpenAsync();\n\t\t\tawait @event.QueueEventsAsync(new[] { \"test\" });\n\t\t\tThread.Sleep(2000);\n\t\t}\n\t\tThread.Sleep(2000);\n\t\tAssert.IsNull(exception);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbSchemaTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbSchemaTests : FbTestsBase\n{\n\tpublic FbSchemaTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic async Task CharacterSets()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"CharacterSets\");\n\t}\n\n\t[Test]\n\tpublic async Task CheckConstraints()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"CheckConstraints\");\n\t}\n\n\t[Test]\n\tpublic async Task CheckConstraintsByTable()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"CheckConstraintsByTable\");\n\t}\n\n\t[Test]\n\tpublic async Task Collations()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"Collations\");\n\t}\n\n\t[Test]\n\tpublic async Task Columns()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"Columns\");\n\n\t\tvar columns = await Connection.GetSchemaAsync(\"Columns\", new string[] { null, null, \"TEST\", \"INT_FIELD\" });\n\t\tAssert.AreEqual(1, columns.Rows.Count);\n\t}\n\n\t[Test]\n\tpublic async Task ColumnPrivileges()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"ColumnPrivileges\");\n\t}\n\n\t[Test]\n\tpublic async Task Domains()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"Domains\");\n\t}\n\n\t[Test]\n\tpublic async Task ForeignKeys()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"ForeignKeys\");\n\t}\n\n\t[Test]\n\tpublic async Task ForeignKeyColumns()\n\t{\n\t\tvar foreignKeys = await Connection.GetSchemaAsync(\"ForeignKeys\");\n\n\t\tforeach (DataRow row in foreignKeys.Rows)\n\t\t{\n\t\t\tawait Connection.GetSchemaAsync(\"ForeignKeyColumns\", new string[] { (string)row[\"TABLE_CATALOG\"], (string)row[\"TABLE_SCHEMA\"], (string)row[\"TABLE_NAME\"], (string)row[\"CONSTRAINT_NAME\"] });\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task FunctionArguments()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"FunctionArguments\");\n\n\t\tvar procedureParameters = await Connection.GetSchemaAsync(\"FunctionArguments\", new string[] { null, null, \"TEST_FUNC\" });\n\t\tAssert.AreEqual(2, procedureParameters.Rows.Count);\n\t}\n\n\t[Test]\n\tpublic async Task FunctionPrivileges()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"FunctionPrivileges\");\n\t}\n\n\t[Test]\n\tpublic async Task Functions()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"Functions\");\n\n\t\tif (ServerVersion >= new Version(3, 0, 0, 0))\n\t\t{\n\t\t\tvar functions = await Connection.GetSchemaAsync(\"Functions\", new string[] { null, null, \"TEST_FUNC\" });\n\t\t\tAssert.AreEqual(1, functions.Rows.Count);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task Function_ShouldSkipSchemaAndProperlyUseParametersForProcedureName()\n\t{\n\t\tvar functions = await Connection.GetSchemaAsync(\"Functions\", new string[] { null, \"DUMMY_SCHEMA\", \"TEST_FUNC\" });\n\t\tAssert.AreEqual(1, functions.Rows.Count);\n\t}\n\n\t[Test]\n\tpublic async Task Generators()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"Generators\");\n\t}\n\n\t[Test]\n\tpublic async Task Indexes()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"Indexes\");\n\t}\n\n\t[Test]\n\tpublic async Task IndexColumns()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"IndexColumns\");\n\t}\n\n\t[Test]\n\tpublic async Task PrimaryKeys()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"PrimaryKeys\");\n\n\t\tvar primaryKeys = await Connection.GetSchemaAsync(\"PrimaryKeys\", new string[] { null, null, \"TEST\" });\n\t\tAssert.AreEqual(1, primaryKeys.Rows.Count);\n\t}\n\n\t[Test]\n\tpublic async Task ProcedureParameters()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"ProcedureParameters\");\n\n\t\tvar procedureParameters = await Connection.GetSchemaAsync(\"ProcedureParameters\", new string[] { null, null, \"SELECT_DATA\" });\n\t\tAssert.AreEqual(3, procedureParameters.Rows.Count);\n\t}\n\n\t[Test]\n\tpublic async Task ProcedurePrivileges()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"ProcedurePrivileges\");\n\t}\n\n\t[Test]\n\tpublic async Task Procedures()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"Procedures\");\n\n\t\tvar procedures = await Connection.GetSchemaAsync(\"Procedures\", new string[] { null, null, \"SELECT_DATA\" });\n\t\tAssert.AreEqual(1, procedures.Rows.Count);\n\t}\n\n\t[Test]\n\tpublic async Task Procedures_ShouldSkipSchemaAndProperlyUseParametersForProcedureName()\n\t{\n\t\tvar procedures = await Connection.GetSchemaAsync(\"Procedures\", new string[] { null, \"DUMMY_SCHEMA\", \"SELECT_DATA\" });\n\t\tAssert.AreEqual(1, procedures.Rows.Count);\n\t}\n\n\t[Test]\n\tpublic async Task DataTypes()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"DataTypes\");\n\t}\n\n\t[Test]\n\tpublic async Task Roles()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"Roles\");\n\t}\n\n\t[Test]\n\tpublic async Task Tables()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"Tables\");\n\n\t\tvar tables1 = await Connection.GetSchemaAsync(\"Tables\", new string[] { null, null, \"TEST\" });\n\t\tAssert.AreEqual(1, tables1.Rows.Count);\n\n\t\tvar tables2 = await Connection.GetSchemaAsync(\"Tables\", new string[] { null, null, null, \"TABLE\" });\n\t\tAssert.AreEqual(3, tables2.Rows.Count);\n\t}\n\n\t[Test]\n\tpublic async Task TableConstraints()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"TableConstraints\");\n\t}\n\n\t[Test]\n\tpublic async Task TablePrivileges()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"TablePrivileges\");\n\t}\n\n\t[Test]\n\tpublic async Task Triggers()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"Triggers\");\n\t}\n\n\t[Test]\n\tpublic async Task UniqueKeys()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"UniqueKeys\");\n\t}\n\n\t[Test]\n\tpublic async Task ViewColumns()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"ViewColumns\");\n\t}\n\n\t[Test]\n\tpublic async Task Views()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"Views\");\n\t}\n\n\t[Test]\n\tpublic async Task ViewPrivileges()\n\t{\n\t\tawait Connection.GetSchemaAsync(\"ViewPrivileges\");\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbScriptTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Linq;\nusing FirebirdSql.Data.Isql;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[NoServerCategory]\npublic class FbScriptTests\n{\n\t[Test]\n\tpublic void NullScript()\n\t{\n\t\tAssert.Throws<ArgumentNullException>(() => new FbScript(null));\n\t}\n\n\t[Test]\n\tpublic void EmptyScript()\n\t{\n\t\tvar script = new FbScript(string.Empty);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(0, script.Results.Count());\n\t}\n\n\t[Test]\n\tpublic void WhiteSpacesScript()\n\t{\n\t\tvar script = new FbScript(\"\\t    \\t \");\n\t\tscript.Parse();\n\t\tAssert.AreEqual(0, script.Results.Count());\n\t}\n\n\t[Test]\n\tpublic void SimpleStatementNoSemicolonWithLiteral()\n\t{\n\t\tconst string text =\n@\"select * from foo where x = 'foobar'\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(text, script.Results[0].Text);\n\t}\n\n\t[Test]\n\tpublic void SimpleStatementWithSemicolonWithLiteral()\n\t{\n\t\tconst string text =\n@\"select * from foo where x = 'foobar';\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(text.Substring(0, text.Length - 1), script.Results[0].Text);\n\t}\n\n\t[Test]\n\tpublic void SimpleStatementNoSemicolonWithSemicolonInLiteral()\n\t{\n\t\tconst string text =\n@\"select * from foo where x = 'foo;bar'\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(text, script.Results[0].Text);\n\t}\n\n\t[Test]\n\tpublic void SimpleStatementNoSemicolonWithEscapedSingleQuoteInLiteral()\n\t{\n\t\tconst string text =\n@\"select * from foo where x = 'foo''bar'\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(text, script.Results[0].Text);\n\t}\n\n\t[Test]\n\tpublic void TwoStatements()\n\t{\n\t\tconst string text =\n@\"select * from foo;select * from bar\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(2, script.Results.Count());\n\t}\n\n\t[Test]\n\tpublic void OneStatementNoSemicolonOneAfterSingleLineComment()\n\t{\n\t\tconst string text =\n@\"select * from foo--;select * from bar\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(text, script.Results[0].Text);\n\t}\n\n\t[Test]\n\tpublic void OneStatementWithMultilineCommentNoSemicolon()\n\t{\n\t\tconst string text =\n@\"select * from foo /* foo */\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(text, script.Results[0].Text);\n\t}\n\n\t[Test]\n\tpublic void OneStatementWithMultilineCommentSeparatedBySemicolon()\n\t{\n\t\tconst string text =\n@\"select * from foo /* foo */;\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(text.Substring(0, text.Length - 1), script.Results[0].Text);\n\t}\n\n\t[Test]\n\tpublic void OneStatementWithMultilineCommentWithSemicolon()\n\t{\n\t\tconst string text =\n@\"select * from foo /* ;foo */\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(text, script.Results[0].Text);\n\t}\n\n\t[Test]\n\tpublic void OneStatementWithMultilineCommentWithSemicolonWithSemicolonAtTheEnd()\n\t{\n\t\tconst string text =\n@\"select * from foo /* ;foo */;\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(text.Substring(0, text.Length - 1), script.Results[0].Text);\n\t}\n\n\t[Test]\n\tpublic void SemicolonOnly()\n\t{\n\t\tconst string text =\n@\";\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(0, script.Results.Count());\n\t}\n\n\t[Test]\n\tpublic void MultilineCommentSeparatedBySemicolon()\n\t{\n\t\tconst string text =\n@\"/*\nfoo\n*/;\";\n\t\tvar script = new FbScript(text);\n\t\tscript.UnknownStatement += (sender, e) =>\n\t\t{\n\t\t\tif (e.Statement.Text == text.Substring(0, text.Length - 1))\n\t\t\t{\n\t\t\t\te.Ignore = true;\n\t\t\t}\n\t\t};\n\t\tscript.Parse();\n\t\tAssert.AreEqual(0, script.Results.Count());\n\t}\n\n\t[Test]\n\tpublic void OneStatementWithSemicolonOneAfterSingleLineComment()\n\t{\n\t\tconst string text =\n@\"select * from foo;--select * from bar\";\n\t\tvar script = new FbScript(text);\n\t\tscript.UnknownStatement += (sender, e) =>\n\t\t{\n\t\t\tif (e.Statement.Text == \"--select * from bar\")\n\t\t\t{\n\t\t\t\te.Ignore = true;\n\t\t\t}\n\t\t};\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(\"select * from foo\", script.Results[0].Text);\n\t}\n\n\t[Test]\n\tpublic void ManuallySettingStatementType()\n\t{\n\t\tconst string text =\n@\"create db 'foobar'\";\n\t\tvar script = new FbScript(text);\n\t\tscript.UnknownStatement += (sender, e) =>\n\t\t{\n\t\t\tif (e.Statement.Text == text)\n\t\t\t{\n\t\t\t\te.NewStatementType = SqlStatementType.CreateDatabase;\n\t\t\t\te.Handled = true;\n\t\t\t}\n\t\t};\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(SqlStatementType.CreateDatabase, script.Results[0].StatementType);\n\t}\n\n\t[Test]\n\tpublic void CreatePackage()\n\t{\n\t\tconst string text =\n@\"create package p as begin end\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(SqlStatementType.CreatePackage, script.Results[0].StatementType);\n\t}\n\n\t[Test]\n\tpublic void RecreatePackage()\n\t{\n\t\tconst string text =\n@\"recreate package p as begin end\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(SqlStatementType.RecreatePackage, script.Results[0].StatementType);\n\t}\n\n\t[Test]\n\tpublic void CreatePackageBody()\n\t{\n\t\tconst string text =\n@\"create package body p as begin end\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(SqlStatementType.CreatePackageBody, script.Results[0].StatementType);\n\t}\n\n\t[Test]\n\tpublic void RecreatePackageBody()\n\t{\n\t\tconst string text =\n@\"recreate package body p as begin end\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(SqlStatementType.RecreatePackageBody, script.Results[0].StatementType);\n\t}\n\n\t[Test]\n\tpublic void DropPackage()\n\t{\n\t\tconst string text =\n@\"drop package p as begin end\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(SqlStatementType.DropPackage, script.Results[0].StatementType);\n\t}\n\n\t[Test]\n\tpublic void DropPackageBody()\n\t{\n\t\tconst string text =\n@\"drop package body p as begin end\";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(SqlStatementType.DropPackageBody, script.Results[0].StatementType);\n\t}\n\n\t[Test]\n\tpublic void Merge()\n\t{\n\t\tconst string text =\n@\"merge into table t using foo f on f.id = t.id when \";\n\t\tvar script = new FbScript(text);\n\t\tscript.Parse();\n\t\tAssert.AreEqual(1, script.Results.Count());\n\t\tAssert.AreEqual(SqlStatementType.Merge, script.Results[0].StatementType);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbServicesTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.IO;\nusing System.Linq;\nusing System.Reflection;\nusing System.Text;\nusing System.Text.RegularExpressions;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.Services;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\npublic class FbServicesTests : FbTestsBase\n{\n\tpublic FbServicesTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[SetUp]\n\tpublic override async Task SetUp()\n\t{\n\t\tawait base.SetUp();\n\n\t\tif (Connection != null && Connection.State == ConnectionState.Open)\n\t\t{\n\t\t\tawait Connection.CloseAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task BackupRestoreTest()\n\t{\n\t\tvar backupName = $\"{Guid.NewGuid()}.bak\";\n\t\tvar connectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);\n\t\tawait BackupPartHelper(backupName, connectionString);\n\t\tawait RestorePartHelper(backupName, connectionString);\n\t\t// test the database was actually restored fine\n\t\tawait Connection.OpenAsync();\n\t\tawait Connection.CloseAsync();\n\t}\n\n\t[Test]\n\tpublic async Task BackupRestoreZipTest()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(4, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tvar backupName = $\"{Guid.NewGuid()}.bak\";\n\t\tvar csb = BuildServicesConnectionStringBuilder(ServerType, Compression, WireCrypt, true);\n\t\tvar connectionString = csb.ToString();\n\t\tawait BackupPartHelper(backupName, connectionString, x =>\n\t\t{\n\t\t\tx.Options |= FbBackupFlags.Zip;\n\t\t});\n\t\tawait RestorePartHelper(backupName, connectionString);\n\t\t// test the database was actually restored fine\n\t\tawait Connection.OpenAsync();\n\t\tawait Connection.CloseAsync();\n\t}\n\n\t[Test]\n\tpublic async Task BackupRestoreVerbIntTest()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(3, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tvar backupName = $\"{Guid.NewGuid()}.bak\";\n\t\tvar csb = BuildServicesConnectionStringBuilder(ServerType, Compression, WireCrypt, true);\n\t\tvar connectionString = csb.ToString();\n\t\tawait BackupPartHelper(backupName, connectionString, x =>\n\t\t{\n\t\t\tx.Verbose = false;\n\t\t\tx.VerboseInterval = 1_000_000;\n\t\t});\n\t\tawait RestorePartHelper(backupName, connectionString, x =>\n\t\t{\n\t\t\tx.Verbose = false;\n\t\t\tx.VerboseInterval = 1_000_000;\n\t\t});\n\t\t// test the database was actually restored fine\n\t\tawait Connection.OpenAsync();\n\t\tawait Connection.CloseAsync();\n\t}\n\n\t[Test]\n\tpublic async Task BackupRestoreParallelTest()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(5, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tvar backupName = $\"{Guid.NewGuid()}.bak\";\n\t\tvar csb = BuildServicesConnectionStringBuilder(ServerType, Compression, WireCrypt, true);\n\t\tcsb.ParallelWorkers = 6;\n\t\tvar connectionString = csb.ToString();\n\t\tawait BackupPartHelper(backupName, connectionString);\n\t\tawait RestorePartHelper(backupName, connectionString);\n\t\t// test the database was actually restored fine\n\t\tawait Connection.OpenAsync();\n\t\tawait Connection.CloseAsync();\n\t}\n\n\t[TestCase(true)]\n\t[TestCase(false)]\n\tpublic async Task StreamingBackupRestoreTest(bool verbose)\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(2, 5, 0, 0)))\n\t\t\treturn;\n\n\t\tTask BackupPart(MemoryStream buffer)\n\t\t{\n\t\t\tvar backupSvc = new FbStreamingBackup();\n\t\t\tbackupSvc.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);\n\t\t\tbackupSvc.Options = FbBackupFlags.IgnoreLimbo;\n\t\t\tbackupSvc.OutputStream = buffer;\n\t\t\tbackupSvc.ServiceOutput += ServiceOutput;\n\t\t\treturn backupSvc.ExecuteAsync();\n\t\t}\n\t\tTask RestorePart(MemoryStream buffer, bool verbose)\n\t\t{\n\t\t\tvar restoreSvc = new FbStreamingRestore();\n\t\t\trestoreSvc.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);\n\t\t\trestoreSvc.Options = FbRestoreFlags.Create | FbRestoreFlags.Replace;\n\t\t\trestoreSvc.PageSize = FbTestsSetup.PageSize;\n\t\t\trestoreSvc.Verbose = verbose;\n\t\t\trestoreSvc.InputStream = buffer;\n\t\t\trestoreSvc.ServiceOutput += ServiceOutput;\n\t\t\treturn restoreSvc.ExecuteAsync();\n\t\t}\n\n\t\tawait Connection.OpenAsync();\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"create table dummy_data (foo varchar(1000) primary key)\";\n\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t}\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = @\"execute block\nas\ndeclare cnt int;\nbegin\n\tcnt = 199999;\n\twhile (cnt > 0) do\n\tbegin\n\t\tinsert into dummy_data values (uuid_to_char(gen_uuid()));\n\t\tcnt = cnt - 1;\n\tend\nend\";\n\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t}\n\t\tawait Connection.CloseAsync();\n\n\t\tusing (var ms = new MemoryStream())\n\t\t{\n\t\t\tawait BackupPart(ms);\n\t\t\tms.Position = 0;\n\t\t\tawait RestorePart(ms, verbose);\n\t\t\t// test the database was actually restored fine\n\t\t\tawait Connection.OpenAsync();\n\t\t\tawait Connection.CloseAsync();\n\t\t}\n\n\t\tawait Connection.OpenAsync();\n\t\tusing (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"drop table dummy_data\";\n\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t}\n\t\tawait Connection.CloseAsync();\n\t}\n\n\t[Test]\n\tpublic async Task ValidationTest()\n\t{\n\t\tvar validationSvc = new FbValidation();\n\t\tvalidationSvc.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);\n\t\tvalidationSvc.Options = FbValidationFlags.ValidateDatabase;\n\t\tvalidationSvc.ServiceOutput += ServiceOutput;\n\t\tawait validationSvc.ExecuteAsync();\n\t}\n\n\t[Test]\n\tpublic async Task SweepTest()\n\t{\n\t\tvar validationSvc = new FbValidation();\n\t\tvalidationSvc.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);\n\t\tvalidationSvc.Options = FbValidationFlags.SweepDatabase;\n\t\tvalidationSvc.ServiceOutput += ServiceOutput;\n\t\tawait validationSvc.ExecuteAsync();\n\t}\n\n\t[Test]\n\tpublic async Task SweepParallelTest()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(5, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tvar validationSvc = new FbValidation();\n\t\tvar csb = BuildServicesConnectionStringBuilder(ServerType, Compression, WireCrypt, true);\n\t\tcsb.ParallelWorkers = 6;\n\t\tvalidationSvc.ConnectionString = csb.ToString();\n\t\tvalidationSvc.Options = FbValidationFlags.SweepDatabase;\n\t\tvalidationSvc.ServiceOutput += ServiceOutput;\n\t\tawait validationSvc.ExecuteAsync();\n\t}\n\n\t[Test]\n\tpublic async Task SetPropertiesTest()\n\t{\n\t\tvar configurationSvc = new FbConfiguration();\n\t\tconfigurationSvc.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);\n\t\tawait configurationSvc.SetSweepIntervalAsync(1000);\n\t\tawait configurationSvc.SetReserveSpaceAsync(true);\n\t\tawait configurationSvc.SetForcedWritesAsync(true);\n\t}\n\n\t[Test]\n\tpublic async Task ShutdownOnlineTest()\n\t{\n\t\tvar configurationSvc = new FbConfiguration();\n\t\tconfigurationSvc.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);\n\t\tawait configurationSvc.DatabaseShutdownAsync(FbShutdownMode.Forced, 10);\n\t\tawait configurationSvc.DatabaseOnlineAsync();\n\t}\n\n\t[Test]\n\tpublic async Task ShutdownOnline2Test()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(2, 5, 0, 0)))\n\t\t\treturn;\n\n\t\tvar configurationSvc = new FbConfiguration();\n\t\tconfigurationSvc.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);\n\t\tawait configurationSvc.DatabaseShutdown2Async(FbShutdownOnlineMode.Full, FbShutdownType.ForceShutdown, 10);\n\t\tawait configurationSvc.DatabaseOnline2Async(FbShutdownOnlineMode.Normal);\n\t}\n\n\t[Test]\n\tpublic async Task StatisticsTest()\n\t{\n\t\tvar statisticalSvc = new FbStatistical();\n\t\tstatisticalSvc.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);\n\t\tstatisticalSvc.Options = FbStatisticalFlags.SystemTablesRelations;\n\t\tstatisticalSvc.ServiceOutput += ServiceOutput;\n\t\tawait statisticalSvc.ExecuteAsync();\n\t}\n\n\t[Test]\n\tpublic async Task StatisticsRecordVersionTest()\n\t{\n\t\tvar sb = new StringBuilder();\n\t\tvar statisticalSvc = new FbStatistical();\n\t\tstatisticalSvc.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);\n\t\tstatisticalSvc.Options = FbStatisticalFlags.RecordVersionStatistics;\n\t\tstatisticalSvc.ServiceOutput += (object sender, ServiceOutputEventArgs e) =>\n\t\t{\n\t\t\tsb.AppendLine(e.Message);\n\t\t};\n\t\tawait statisticalSvc.ExecuteAsync();\n\t\tvar statisticalOutput = sb.ToString();\n\t\tAssert.IsTrue(statisticalOutput.Contains(\"Average record length\"), \"Record statistics not found\");\n\t}\n\n\t[Test]\n\tpublic async Task FbLogTest()\n\t{\n\t\tvar logSvc = new FbLog();\n\t\tlogSvc.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, false);\n\t\tlogSvc.ServiceOutput += ServiceOutput;\n\t\tawait logSvc.ExecuteAsync();\n\t}\n\n\t[Test]\n\tpublic async Task AddDeleteUserTest()\n\t{\n\t\tvar securitySvc = new FbSecurity();\n\t\tsecuritySvc.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, false);\n\t\t{\n\t\t\tvar user = new FbUserData();\n\t\t\tuser.UserName = \"new_user\";\n\t\t\tuser.UserPassword = \"1\";\n\t\t\tawait securitySvc.AddUserAsync(user);\n\t\t}\n\t\t{\n\t\t\tvar user = new FbUserData();\n\t\t\tuser.UserName = \"new_user\";\n\t\t\tawait securitySvc.DeleteUserAsync(user);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DisplayUser()\n\t{\n\t\tvar securitySvc = new FbSecurity();\n\t\tsecuritySvc.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, false);\n\t\tvar user = await securitySvc.DisplayUserAsync(\"SYSDBA\");\n\t}\n\n\t[Test]\n\tpublic async Task DisplayUsers()\n\t{\n\t\tvar securitySvc = new FbSecurity();\n\t\tsecuritySvc.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, false);\n\t\tvar users = await securitySvc.DisplayUsersAsync();\n\t}\n\n\t[Test]\n\tpublic void ServerPropertiesTest()\n\t{\n\t\tvar serverProp = new FbServerProperties();\n\t\tserverProp.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, false);\n\t\tforeach (var m in serverProp.GetType()\n\t\t\t.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly)\n\t\t\t.Where(x => !x.IsSpecialName)\n\t\t\t.Where(x => x.Name.EndsWith(\"Async\")))\n\t\t{\n\t\t\tAssert.DoesNotThrowAsync(() => (Task)m.Invoke(serverProp, new object[] { CancellationToken.None }), m.Name);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task NBackupBackupRestoreTest()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(2, 5, 0, 0)))\n\t\t\treturn;\n\n\t\tconst int Levels = 2;\n\t\tvar backupName = $\"{Guid.NewGuid()}.nbak\";\n\t\tasync Task BackupPart()\n\t\t{\n\t\t\tTask DoLevel(int level)\n\t\t\t{\n\t\t\t\tvar nbak = new FbNBackup();\n\t\t\t\tnbak.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);\n\t\t\t\tnbak.Level = level;\n\t\t\t\tnbak.BackupFile = backupName + level.ToString();\n\t\t\t\tnbak.DirectIO = true;\n\t\t\t\tnbak.Options = FbNBackupFlags.NoDatabaseTriggers;\n\t\t\t\tnbak.ServiceOutput += ServiceOutput;\n\t\t\t\treturn nbak.ExecuteAsync();\n\t\t\t}\n\t\t\tfor (var i = 0; i < Levels; i++)\n\t\t\t{\n\t\t\t\tawait DoLevel(i);\n\t\t\t}\n\t\t}\n\t\tTask RestorePart()\n\t\t{\n\t\t\tFbConnection.DropDatabase(BuildConnectionString(ServerType, Compression, WireCrypt));\n\t\t\tvar nrest = new FbNRestore();\n\t\t\tnrest.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);\n\t\t\tnrest.BackupFiles = Enumerable.Range(0, Levels).Select(l => backupName + l.ToString());\n\t\t\tnrest.DirectIO = true;\n\t\t\tnrest.ServiceOutput += ServiceOutput;\n\t\t\treturn nrest.ExecuteAsync();\n\t\t}\n\t\tawait BackupPart();\n\t\tawait RestorePart();\n\t}\n\n\t[Test]\n\tpublic async Task TraceTest()\n\t{\n\t\tvar trace = new FbTrace();\n\t\ttrace.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, false);\n\t\ttrace.DatabasesConfigurations.Add(new FbDatabaseTraceConfiguration()\n\t\t{\n\t\t\tEnabled = true,\n\t\t\tEvents = FbDatabaseTraceEvents.Connections | FbDatabaseTraceEvents.Errors,\n\t\t\tTimeThreshold = TimeSpan.FromMilliseconds(1),\n\t\t});\n\n\t\tvar sessionId = -1;\n\t\ttrace.ServiceOutput += (sender, e) =>\n\t\t{\n\t\t\tif (sessionId == -1)\n\t\t\t{\n\t\t\t\tvar match = Regex.Match(e.Message, @\"Trace session ID (\\d+) started\");\n\t\t\t\tif (match.Success)\n\t\t\t\t{\n\t\t\t\t\tsessionId = int.Parse(match.Groups[1].Value);\n\t\t\t\t}\n\t\t\t}\n\t\t\tServiceOutput(sender, e);\n\t\t};\n\n\t\tasync Task Stop()\n\t\t{\n\t\t\tawait Task.Delay(2000);\n\t\t\tawait new FbTrace(connectionString: BuildServicesConnectionString(ServerType, Compression, WireCrypt, false))\n\t\t\t\t.StopAsync(sessionId);\n\t\t}\n\t\tvar stopTask = Stop();\n\t\tawait trace.StartAsync(\"test\");\n\t\tawait stopTask;\n\n\t\tAssert.AreNotEqual(-1, sessionId);\n\t}\n\n\t[Test]\n\tpublic async Task NoLingerTest()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(3, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tvar configurationSvc = new FbConfiguration();\n\t\tconfigurationSvc.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);\n\t\tawait configurationSvc.NoLingerAsync();\n\t}\n\n\t[Test, Explicit]\n\tpublic void StatisticsWithEncryptedTest()\n\t{\n\t\tvar csb = BuildServicesConnectionStringBuilder(ServerType, Compression, WireCrypt, true);\n\t\tcsb.Database = \"enc.fdb\";\n\t\tTask Test()\n\t\t{\n\t\t\tvar statisticalSvc = new FbStatistical(csb.ToString());\n\t\t\tstatisticalSvc.ServiceOutput += ServiceOutput;\n\t\t\treturn statisticalSvc.ExecuteAsync();\n\t\t}\n\t\tAssert.ThrowsAsync<FbException>(Test);\n\t\tcsb.CryptKey = Encoding.ASCII.GetBytes(\"1234567890123456\");\n\t\tAssert.DoesNotThrowAsync(Test);\n\t}\n\n\t[Test]\n\tpublic async Task Validation2Test()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(3, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tvar validationSvc = new FbValidation2();\n\t\tvalidationSvc.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);\n\t\tvalidationSvc.TablesInclude = \"_*\";\n\t\tvalidationSvc.TablesExclude = \"X*\";\n\t\tvalidationSvc.IndicesInclude = \"_*\";\n\t\tvalidationSvc.IndicesExclude = \"X*\";\n\t\tvalidationSvc.LockTimeout = 6;\n\t\tvalidationSvc.ServiceOutput += ServiceOutput;\n\t\tawait validationSvc.ExecuteAsync();\n\t}\n\n\t[Test]\n\tpublic async Task NFixupTest()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(4, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tvar deltaFile = Path.GetTempFileName();\n\t\tConnection.Open();\n\t\ttry\n\t\t{\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = $\"alter database add difference file '{deltaFile}'\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t\tcmd.CommandText = \"alter database begin backup\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tConnection.Close();\n\t\t}\n\t\tFile.Delete(deltaFile);\n\n\t\tAssert.ThrowsAsync<FbException>(() => Connection.OpenAsync());\n\n\t\tvar fixup = new FbNFixup();\n\t\tfixup.ConnectionString = BuildServicesConnectionString(ServerType, Compression, WireCrypt, true);\n\t\tfixup.ServiceOutput += ServiceOutput;\n\t\tawait fixup.ExecuteAsync();\n\n\t\tAssert.DoesNotThrowAsync(() => Connection.OpenAsync());\n\t}\n\n\tstatic Task BackupPartHelper(string backupName, string connectionString, Action<FbBackup> configure = null)\n\t{\n\t\tvar backupSvc = new FbBackup();\n\t\tbackupSvc.ConnectionString = connectionString;\n\t\tbackupSvc.Options = FbBackupFlags.IgnoreLimbo;\n\t\tbackupSvc.BackupFiles.Add(new FbBackupFile(backupName, 2048));\n\t\tbackupSvc.Verbose = true;\n\t\tbackupSvc.Statistics = FbBackupRestoreStatistics.TotalTime | FbBackupRestoreStatistics.TimeDelta;\n\t\tbackupSvc.ServiceOutput += ServiceOutput;\n\t\tconfigure?.Invoke(backupSvc);\n\t\treturn backupSvc.ExecuteAsync();\n\t}\n\tstatic Task RestorePartHelper(string backupName, string connectionString, Action<FbRestore> configure = null)\n\t{\n\t\tvar restoreSvc = new FbRestore();\n\t\trestoreSvc.ConnectionString = connectionString;\n\t\trestoreSvc.Options = FbRestoreFlags.Create | FbRestoreFlags.Replace;\n\t\trestoreSvc.PageSize = FbTestsSetup.PageSize;\n\t\trestoreSvc.Verbose = true;\n\t\trestoreSvc.Statistics = FbBackupRestoreStatistics.TotalTime | FbBackupRestoreStatistics.TimeDelta;\n\t\trestoreSvc.BackupFiles.Add(new FbBackupFile(backupName, 2048));\n\t\trestoreSvc.ServiceOutput += ServiceOutput;\n\t\tconfigure?.Invoke(restoreSvc);\n\t\treturn restoreSvc.ExecuteAsync();\n\t}\n\n\tstatic void ServiceOutput(object sender, ServiceOutputEventArgs e)\n\t{\n\t\tvar dummy = e.Message;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbStoredProcedureCallsTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbStoredProcedureCallsTests : FbTestsBase\n{\n\tpublic FbStoredProcedureCallsTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic async Task FirebirdLikeTest00()\n\t{\n\t\tawait using (var command = new FbCommand(\"EXECUTE PROCEDURE GETVARCHARFIELD(?)\", Connection))\n\t\t{\n\t\t\tcommand.CommandType = CommandType.StoredProcedure;\n\t\t\tcommand.Parameters.Add(\"@ID\", FbDbType.VarChar).Direction = ParameterDirection.Input;\n\t\t\tcommand.Parameters.Add(\"@VARCHAR_FIELD\", FbDbType.VarChar).Direction = ParameterDirection.Output;\n\t\t\tcommand.Parameters[0].Value = 1;\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t\tvar value = command.Parameters[1].Value;\n\t\t\tAssert.AreEqual(\"IRow Number 1\", value);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task FirebirdLikeTest01()\n\t{\n\t\tawait using (var command = new FbCommand(\"SELECT * FROM GETVARCHARFIELD(?)\", Connection))\n\t\t{\n\t\t\tcommand.CommandType = CommandType.StoredProcedure;\n\t\t\tcommand.Parameters.Add(\"@ID\", FbDbType.VarChar).Direction = ParameterDirection.Input;\n\t\t\tcommand.Parameters[0].Value = 1;\n\t\t\tawait using (var reader = command.ExecuteReader())\n\t\t\t{\n\t\t\t\tawait reader.ReadAsync();\n\t\t\t\tvar value = reader[0];\n\t\t\t\tAssert.AreEqual(\"IRow Number 1\", value);\n\t\t\t}\n\t\t}\n\n\t}\n\n\t[Test]\n\tpublic async Task SqlServerLikeTest00()\n\t{\n\t\tawait using (var command = new FbCommand(\"GETVARCHARFIELD\", Connection))\n\t\t{\n\t\t\tcommand.CommandType = CommandType.StoredProcedure;\n\t\t\tcommand.Parameters.Add(\"@ID\", FbDbType.VarChar).Direction = ParameterDirection.Input;\n\t\t\tcommand.Parameters.Add(\"@VARCHAR_FIELD\", FbDbType.VarChar).Direction = ParameterDirection.Output;\n\t\t\tcommand.Parameters[0].Value = 1;\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t\tvar value = command.Parameters[1].Value;\n\t\t\tAssert.AreEqual(\"IRow Number 1\", value);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SqlServerLikeTest01()\n\t{\n\t\tawait using (var command = new FbCommand(\"GETRECORDCOUNT\", Connection))\n\t\t{\n\t\t\tcommand.CommandType = CommandType.StoredProcedure;\n\t\t\tcommand.Parameters.Add(\"@RECORDCOUNT\", FbDbType.Integer).Direction = ParameterDirection.Output;\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t\tvar value = command.Parameters[0].Value;\n\t\t\tAssert.Greater(Convert.ToInt32(value), 0);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SqlServerLikeTest02()\n\t{\n\t\tawait using (var command = new FbCommand(\"GETVARCHARFIELD\", Connection))\n\t\t{\n\t\t\tcommand.CommandType = CommandType.StoredProcedure;\n\t\t\tcommand.Parameters.Add(\"@ID\", FbDbType.VarChar).Value = 1;\n\t\t\tawait using (var r = await command.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tvar count = 0;\n\t\t\t\twhile (await r.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\tAssert.AreEqual(1, count);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbTimeZonesSupportTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing FirebirdSql.Data.Types;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbTimeZonesSupportTests : FbTestsBase\n{\n\tpublic FbTimeZonesSupportTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt, false)\n\t{ }\n\n\t[SetUp]\n\tpublic override async Task SetUp()\n\t{\n\t\tawait base.SetUp();\n\n\t\tif (!EnsureServerVersionAtLeast(new Version(4, 0, 0, 0)))\n\t\t\treturn;\n\t}\n\n\t[TestCase(true)]\n\t[TestCase(false)]\n\tpublic async Task ReadsZonedDateTimeCorrectly(bool isExtended)\n\t{\n\t\tif (isExtended)\n\t\t{\n\t\t\tawait SetExtended();\n\t\t}\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast('2020-08-27 10:00 Europe/Prague' as timestamp with time zone) from rdb$database\";\n\t\t\tvar result = (FbZonedDateTime)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(new DateTime(2020, 08, 27, 08, 00, 00, DateTimeKind.Utc), result.DateTime);\n\t\t\tAssert.AreEqual(\"Europe/Prague\", result.TimeZone);\n\t\t\tAssert.AreEqual(isExtended ? TimeSpan.FromMinutes(120) : (TimeSpan?)null, result.Offset);\n\t\t}\n\t}\n\n\t[TestCase(true)]\n\t[TestCase(false)]\n\tpublic async Task ReadsZonedDateTimeNullCorrectly(bool isExtended)\n\t{\n\t\tif (isExtended)\n\t\t{\n\t\t\tawait SetExtended();\n\t\t}\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(null as timestamp with time zone) from rdb$database\";\n\t\t\tvar result = (DBNull)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(DBNull.Value, result);\n\t\t}\n\t}\n\n\t[TestCase(true)]\n\t[TestCase(false)]\n\tpublic async Task PassesZonedDateTimeCorrectly(bool isExtended)\n\t{\n\t\tif (isExtended)\n\t\t{\n\t\t\tawait SetExtended();\n\t\t}\n\t\tvar value = new FbZonedDateTime(new DateTime(2020, 08, 27, 08, 00, 00, DateTimeKind.Utc), \"Europe/Prague\");\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@value as timestamp with time zone) from rdb$database\";\n\t\t\tcmd.Parameters.AddWithValue(\"value\", value);\n\t\t\tvar result = (FbZonedDateTime)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(value, result);\n\t\t}\n\t}\n\n\t[TestCase(true)]\n\t[TestCase(false)]\n\tpublic async Task PassesZonedDateTimeNullCorrectly(bool isExtended)\n\t{\n\t\tif (isExtended)\n\t\t{\n\t\t\tawait SetExtended();\n\t\t}\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@value as timestamp with time zone) from rdb$database\";\n\t\t\tcmd.Parameters.AddWithValue(\"value\", DBNull.Value);\n\t\t\tvar result = (DBNull)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(DBNull.Value, result);\n\t\t}\n\t}\n\n\t[TestCase(true)]\n\t[TestCase(false)]\n\tpublic async Task ReadsZonedTimeCorrectly(bool isExtended)\n\t{\n\t\tif (isExtended)\n\t\t{\n\t\t\tawait SetExtended();\n\t\t}\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast('15:00 Europe/Prague' as time with time zone) from rdb$database\";\n\t\t\tvar result = (FbZonedTime)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(new TimeSpan(14, 00, 00), result.Time);\n\t\t\tAssert.AreEqual(\"Europe/Prague\", result.TimeZone);\n\t\t\tAssert.AreEqual(isExtended ? TimeSpan.FromMinutes(60) : (TimeSpan?)null, result.Offset);\n\t\t}\n\t}\n\n\t[TestCase(true)]\n\t[TestCase(false)]\n\tpublic async Task ReadsZonedTimeNullCorrectly(bool isExtended)\n\t{\n\t\tif (isExtended)\n\t\t{\n\t\t\tawait SetExtended();\n\t\t}\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(null as time with time zone) from rdb$database\";\n\t\t\tvar result = (DBNull)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(DBNull.Value, result);\n\t\t}\n\t}\n\n\t[TestCase(true)]\n\t[TestCase(false)]\n\tpublic async Task PassesZonedTimeCorrectly(bool isExtended)\n\t{\n\t\tif (isExtended)\n\t\t{\n\t\t\tawait SetExtended();\n\t\t}\n\t\tvar value = new FbZonedTime(new TimeSpan(14, 00, 00), \"Europe/Prague\");\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@value as time with time zone) from rdb$database\";\n\t\t\tcmd.Parameters.AddWithValue(\"value\", value);\n\t\t\tvar result = (FbZonedTime)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(value, result);\n\t\t}\n\t}\n\n\t[TestCase(true)]\n\t[TestCase(false)]\n\tpublic async Task PassesZonedTimeNullCorrectly(bool isExtended)\n\t{\n\t\tif (isExtended)\n\t\t{\n\t\t\tawait SetExtended();\n\t\t}\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(@value as time with time zone) from rdb$database\";\n\t\t\tcmd.Parameters.AddWithValue(\"value\", DBNull.Value);\n\t\t\tvar result = (DBNull)await cmd.ExecuteScalarAsync();\n\t\t\tAssert.AreEqual(DBNull.Value, result);\n\t\t}\n\t}\n\n\t[TestCase(true)]\n\t[TestCase(false)]\n\tpublic async Task SelectEmptyResultSet(bool isExtended)\n\t{\n\t\tif (isExtended)\n\t\t{\n\t\t\tawait SetExtended();\n\t\t}\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select cast(null as time with time zone) from rdb$database where 0=1\";\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tAssert.DoesNotThrowAsync(reader.ReadAsync);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SimpleSelectSchemaTableTest()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"select current_timestamp, current_time from rdb$database\";\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tvar schema = await reader.GetSchemaTableAsync();\n\t\t\t\tAssert.AreEqual(typeof(FbZonedDateTime), schema.Rows[0].ItemArray[5]);\n\t\t\t\tAssert.AreEqual(typeof(FbZonedTime), schema.Rows[1].ItemArray[5]);\n\t\t\t}\n\t\t}\n\t}\n\n\tasync Task SetExtended()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"set bind of time zone to extended\";\n\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbTransactionInfoTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Linq;\nusing System.Reflection;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbTransactionInfoTests : FbTestsBase\n{\n\tpublic FbTransactionInfoTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic async Task CompleteTransactionInfoTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tvar txInfo = new FbTransactionInfo(transaction);\n\t\t\tforeach (var m in txInfo.GetType()\n\t\t\t\t.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly)\n\t\t\t\t.Where(x => !x.IsSpecialName)\n\t\t\t\t.Where(x => x.Name.EndsWith(\"Async\")))\n\t\t\t{\n\t\t\t\tif (ServerVersion < new Version(4, 0, 0, 0)\n\t\t\t\t\t && new[] {\n\t\t\t\t\t\tnameof(FbTransactionInfo.GetTransactionSnapshotNumberAsync),\n\t\t\t\t\t}.Contains(m.Name))\n\t\t\t\t\tcontinue;\n\n\t\t\t\tAssert.DoesNotThrowAsync(() => (Task)m.Invoke(txInfo, new object[] { CancellationToken.None }), m.Name);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbTransactionTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class FbTransactionTests : FbTestsBase\n{\n\tpublic FbTransactionTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic async Task CommitTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task RollbackTest()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SavePointTest()\n\t{\n\t\tawait using (var command = new FbCommand())\n\t\t{\n\t\t\tawait using (var transaction = await Connection.BeginTransactionAsync(\"InitialSavePoint\"))\n\t\t\t{\n\t\t\t\tcommand.Connection = Connection;\n\t\t\t\tcommand.Transaction = transaction;\n\n\t\t\t\tcommand.CommandText = \"insert into TEST (INT_FIELD) values (200)\";\n\t\t\t\tawait command.ExecuteNonQueryAsync();\n\n\t\t\t\tawait transaction.SaveAsync(\"FirstSavePoint\");\n\n\t\t\t\tcommand.CommandText = \"insert into TEST (INT_FIELD) values (201)\";\n\t\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t\t\tawait transaction.SaveAsync(\"SecondSavePoint\");\n\n\t\t\t\tcommand.CommandText = \"insert into TEST (INT_FIELD) values (202)\";\n\t\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t\t\tawait transaction.RollbackAsync(\"InitialSavePoint\");\n\n\t\t\t\tawait transaction.CommitAsync();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task AbortTransaction()\n\t{\n\t\tFbTransaction transaction = null;\n\t\tFbCommand command = null;\n\n\t\ttry\n\t\t{\n\t\t\ttransaction = await Connection.BeginTransactionAsync();\n\n\t\t\tcommand = new FbCommand(\"ALTER TABLE \\\"TEST\\\" drop \\\"INT_FIELD\\\"\", Connection, transaction);\n\t\t\tawait command.ExecuteNonQueryAsync();\n\n\t\t\tawait transaction.CommitAsync();\n\t\t}\n\t\tcatch (Exception)\n\t\t{\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tif (transaction != null)\n\t\t\t{\n\t\t\t\tawait command.DisposeAsync();\n\t\t\t}\n\t\t\tif (transaction != null)\n\t\t\t{\n\t\t\t\tawait command.DisposeAsync();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task ReadCommittedReadConsistency()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(4, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync(new FbTransactionOptions() { TransactionBehavior = FbTransactionBehavior.ReadConsistency }))\n\t\t{ }\n\t}\n\n\t[Test]\n\tpublic async Task SnapshotAtNumber()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(4, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tawait using (var transaction1 = await Connection.BeginTransactionAsync(new FbTransactionOptions() { TransactionBehavior = FbTransactionBehavior.Concurrency }))\n\t\t{\n\t\t\tvar number1 = await new FbTransactionInfo(transaction1).GetTransactionSnapshotNumberAsync();\n\t\t\tAssert.NotZero(number1);\n\t\t\tawait using (var conn = new FbConnection(BuildConnectionString(ServerType, Compression, WireCrypt)))\n\t\t\t{\n\t\t\t\tawait conn.OpenAsync();\n\t\t\t\tawait using (var transaction2 = await conn.BeginTransactionAsync(new FbTransactionOptions() { TransactionBehavior = FbTransactionBehavior.Concurrency, SnapshotAtNumber = number1 }))\n\t\t\t\t{\n\t\t\t\t\tvar number2 = await new FbTransactionInfo(transaction2).GetTransactionSnapshotNumberAsync();\n\t\t\t\t\tAssert.AreEqual(number1, number2);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbZonedDateTimeTypeTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.Data.TestsBase;\nusing FirebirdSql.Data.Types;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[NoServerCategory]\npublic class FbZonedDateTimeTypeTests\n{\n\tstatic readonly object[] SimpleEqualityTrueSource = new object[]\n\t{\n\t\t\tnew object[] { new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Utc), \"UTC\"), new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Utc), \"UTC\") },\n\t\t\tnew object[] { new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Utc), \"UTC\"), new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Utc), \"utc\") },\n\t};\n\t[TestCaseSource(nameof(SimpleEqualityTrueSource))]\n\tpublic void EqualityTrue(FbZonedDateTime expected, FbZonedDateTime actual)\n\t{\n\t\tAssert.AreEqual(expected, actual);\n\t}\n\n\tstatic readonly object[] SimpleEqualityFalseSource = new object[]\n\t{\n\t\t\tnew object[] { new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Utc), \"UTC\"), new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 1, DateTimeKind.Utc), \"UTC\") },\n\t\t\tnew object[] { new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Utc), \"foo\"), new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Utc), \"bar\") },\n\t};\n\t[TestCaseSource(nameof(SimpleEqualityFalseSource))]\n\tpublic void EqualityFalse(FbZonedDateTime expected, FbZonedDateTime actual)\n\t{\n\t\tAssert.AreNotEqual(expected, actual);\n\t}\n\n\t[Test]\n\tpublic void ConvertToDateTimeShouldNotThrow()\r\n\t{\n\t\tvar fbZonedDateTime = new FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Utc), \"UTC\");\n\t\t\r\n\t\tAssert.DoesNotThrow(() => Convert.ChangeType(fbZonedDateTime, typeof(DateTime)));\r\n\t}\n\n\tpublic void DateTimeShouldBeUtc()\n\t{\n\t\tAssert.Throws<ArgumentException>(() =>\n\t\t{\n\t\t\tnew FbZonedDateTime(new DateTime(2020, 12, 4, 10, 38, 0, DateTimeKind.Local), \"foo\");\n\t\t});\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FbZonedTimeTypeTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.Data.TestsBase;\nusing FirebirdSql.Data.Types;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[NoServerCategory]\npublic class FbZonedTimeTypeTests\n{\n\tstatic readonly object[] SimpleEqualityTrueSource = new object[]\n\t{\n\t\t\tnew object[] { new FbZonedTime(TimeSpan.FromMinutes(142), \"UTC\"), new FbZonedTime(TimeSpan.FromMinutes(142), \"UTC\") },\n\t\t\tnew object[] { new FbZonedTime(TimeSpan.FromMinutes(142), \"UTC\"), new FbZonedTime(TimeSpan.FromMinutes(142), \"utc\") },\n\t};\n\t[TestCaseSource(nameof(SimpleEqualityTrueSource))]\n\tpublic void EqualityTrue(FbZonedTime expected, FbZonedTime actual)\n\t{\n\t\tAssert.AreEqual(expected, actual);\n\t}\n\n\tstatic readonly object[] SimpleEqualityFalseSource = new object[]\n\t{\n\t\t\tnew object[] { new FbZonedTime(TimeSpan.FromMinutes(142), \"UTC\"), new FbZonedTime(TimeSpan.FromMinutes(141), \"UTC\") },\n\t\t\tnew object[] { new FbZonedTime(TimeSpan.FromMinutes(142), \"foo\"), new FbZonedTime(TimeSpan.FromMinutes(142), \"bar\") },\n\t};\n\t[TestCaseSource(nameof(SimpleEqualityFalseSource))]\n\tpublic void EqualityFalse(FbZonedTime expected, FbZonedTime actual)\n\t{\n\t\tAssert.AreNotEqual(expected, actual);\n\t}\n\n\t[Test]\n\tpublic void ConvertToTimeSpanShouldNotThrow()\n\t{\n\t\tvar fbZonedTime = new FbZonedTime(TimeSpan.FromMinutes(142), \"UTC\");\n\n\t\tAssert.DoesNotThrow(() => Convert.ChangeType(fbZonedTime, typeof(TimeSpan)));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/FirebirdSql.Data.FirebirdClient.Tests.csproj",
    "content": "﻿<Project Sdk=\"Microsoft.NET.Sdk\">\n\t<PropertyGroup>\n\t\t<TargetFramework>net10.0</TargetFramework>\n\t\t<GenerateAssemblyInfo>false</GenerateAssemblyInfo>\n\t\t<GeneratePackageOnBuild>false</GeneratePackageOnBuild>\n\t\t<SkipSourceLink>true</SkipSourceLink>\n\t\t<AssemblyName>FirebirdSql.Data.FirebirdClient.Tests</AssemblyName>\n\t\t<RootNamespace>FirebirdSql.Data.FirebirdClient.Tests</RootNamespace>\n\t\t<SignAssembly>true</SignAssembly>\n\t\t<AssemblyOriginatorKeyFile>..\\FirebirdSql.Data.TestsBase\\FirebirdSql.Data.TestsBase.snk</AssemblyOriginatorKeyFile>\n\t\t<OutputType>Exe</OutputType>\n\t\t<StartupObject>FirebirdSql.Data.TestsBase.Program</StartupObject>\n\t</PropertyGroup>\n\t<ItemGroup>\n\t\t<Using Include=\"NUnit.Framework.Legacy.ClassicAssert\" Alias=\"Assert\" />\n\t\t<Using Include=\"NUnit.Framework.Legacy.CollectionAssert\" Alias=\"CollectionAssert\" />\n\t\t<Using Include=\"NUnit.Framework.Legacy.StringAssert\" Alias=\"StringAssert\" />\n\t</ItemGroup>\n\t<ItemGroup>\n\t\t<PackageReference Include=\"Microsoft.NET.Test.Sdk\" Version=\"17.12.0\" />\n\t\t<PackageReference Include=\"NUnit\" Version=\"4.2.2\" />\n\t\t<PackageReference Include=\"NUnit3TestAdapter\" Version=\"4.6.0\" />\n\t\t<PackageReference Include=\"NUnitLite\" Version=\"4.2.2\" />\n\t</ItemGroup>\n\t<ItemGroup>\n\t\t<ProjectReference Include=\"..\\FirebirdSql.Data.FirebirdClient\\FirebirdSql.Data.FirebirdClient.csproj\" />\n\t</ItemGroup>\n\t<Import Project=\"..\\FirebirdSql.Data.TestsBase\\FirebirdSql.Data.TestsBase.projitems\" Label=\"Shared\" />\n\t<ItemGroup>\n\t\t<Service Include=\"{82a7f48d-3b50-4b1e-b82e-3ada8210c358}\" />\n\t</ItemGroup>\n</Project>\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/GuidTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Security.Cryptography;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class GuidTests : FbTestsBase\n{\n\tpublic GuidTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic async Task InsertGuidTest()\n\t{\n\t\tvar newGuid = Guid.Empty;\n\t\tvar guidValue = Guid.NewGuid();\n\n\t\tawait using (var insert = new FbCommand(\"INSERT INTO GUID_TEST (GUID_FIELD) VALUES (@GuidValue)\", Connection))\n\t\t{\n\t\t\tinsert.Parameters.Add(\"@GuidValue\", FbDbType.Guid).Value = guidValue;\n\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand(\"SELECT * FROM GUID_TEST\", Connection))\n\t\t{\n\t\t\tawait using (var r = await select.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await r.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tnewGuid = r.GetGuid(1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tAssert.AreEqual(guidValue, newGuid);\n\t}\n\n\t[Test]\n\tpublic async Task InsertNullGuidTest()\n\t{\n\t\tvar id = RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);\n\n\t\tawait using (var insert = new FbCommand(\"INSERT INTO GUID_TEST (INT_FIELD, GUID_FIELD) VALUES (@IntField, @GuidValue)\", Connection))\n\t\t{\n\t\t\tinsert.Parameters.Add(\"@IntField\", FbDbType.Integer).Value = id;\n\t\t\tinsert.Parameters.Add(\"@GuidValue\", FbDbType.Guid).Value = DBNull.Value;\n\t\t\tawait insert.ExecuteNonQueryAsync();\n\t\t}\n\n\t\tawait using (var select = new FbCommand(\"SELECT * FROM GUID_TEST WHERE INT_FIELD = @IntField\", Connection))\n\t\t{\n\t\t\tselect.Parameters.Add(\"@IntField\", FbDbType.Integer).Value = id;\n\t\t\tawait using (var r = await select.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\tif (await r.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tif (!await r.IsDBNullAsync(1))\n\t\t\t\t\t{\n\t\t\t\t\t\tAssert.Fail();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/Srp256ClientTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.Data.Client.Managed;\nusing FirebirdSql.Data.Client.Managed.Srp;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[NoServerCategory]\npublic class Srp256ClientTests\n{\n\t[Test]\n\tpublic void KeyMatchTest()\n\t{\n\t\tvar user = \"SYSDBA\";\n\t\tvar password = \"masterkey\";\n\t\tvar client = new Srp256Client();\n\t\tvar salt = client.GetSalt();\n\t\tvar serverKeyPair = client.ServerSeed(user, password, salt);\n\t\tvar serverSessionKey = client.GetServerSessionKey(user, password, salt, client.PublicKey, serverKeyPair.Item1, serverKeyPair.Item2);\n\t\tclient.ClientProof(user, password, salt, serverKeyPair.Item1);\n\t\tAssert.AreEqual(serverSessionKey.ToString(), client.SessionKey.ToString());\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/SrpClientTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Hajime Nakagami (nakagami@gmail.com), Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.Data.Client.Managed;\nusing FirebirdSql.Data.Client.Managed.Srp;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[NoServerCategory]\npublic class SrpClientTests\n{\n\t[Test]\n\tpublic void KeyMatchTest()\n\t{\n\t\tvar user = \"SYSDBA\";\n\t\tvar password = \"masterkey\";\n\t\tvar client = new SrpClient();\n\t\tvar salt = client.GetSalt();\n\t\tvar serverKeyPair = client.ServerSeed(user, password, salt);\n\t\tvar serverSessionKey = client.GetServerSessionKey(user, password, salt, client.PublicKey, serverKeyPair.Item1, serverKeyPair.Item2);\n\t\tclient.ClientProof(user, password, salt, serverKeyPair.Item1);\n\t\tAssert.AreEqual(serverSessionKey.ToString(), client.SessionKey.ToString());\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/TrackerIssuesTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Data;\nusing System.Diagnostics;\nusing System.Text;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class TrackerIssuesTests : FbTestsBase\n{\n\tpublic TrackerIssuesTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic async Task DNET217_ReadingALotOfFields()\n\t{\n\t\tvar timestampExpression = ServerVersion >= new Version(4, 0, 0, 0) ? \"localtimestamp\" : \"current_timestamp\";\n\n\t\tvar cols = new StringBuilder();\n\t\tvar separator = string.Empty;\n\t\tfor (var i = 0; i < 1235; i++)\n\t\t{\n\t\t\tif (i % 2 == 0)\n\t\t\t\tcols.AppendFormat(\"{0}'r' as col{1}\", separator, i);\n\t\t\telse\n\t\t\t\tcols.AppendFormat(\"{0}24 as col{1}\", separator, i);\n\n\t\t\tseparator = \",\";\n\t\t}\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = $\"select {cols} from rdb$database where 'x' = @x or 'x' = @x and {timestampExpression} = @y and {timestampExpression} = @y and {timestampExpression} = @y and {timestampExpression} = @y and {timestampExpression} = @y and {timestampExpression} = @y and {timestampExpression} = @y and {timestampExpression} = @y and {timestampExpression} = @y and {timestampExpression} = @y and {timestampExpression} = @y\";\n\t\t\tcmd.Parameters.Add(new FbParameter() { ParameterName = \"@x\", Value = \"z\" });\n\t\t\tcmd.Parameters.Add(new FbParameter() { ParameterName = \"@y\", Value = DateTime.Now });\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t{ }\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DNET260_ProcedureWithALotOfParameters()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = @\"\nRECREATE PROCEDURE TEST_SP (\n  P01 SMALLINT,\n  P02 INTEGER,\n  P03 INTEGER,\n  P04 FLOAT,\n  P05 INTEGER,\n  P06 INTEGER,\n  P07 DATE,\n  P08 DATE )\nRETURNS (\n  R01 FLOAT,\n  R02 FLOAT,\n  R03 FLOAT,\n  R04 FLOAT,\n  R05 FLOAT,\n  R06 FLOAT,\n  R07 FLOAT,\n  R08 FLOAT,\n  R09 FLOAT,\n  R10 FLOAT,\n  R11 FLOAT,\n  R12 FLOAT,\n  R13 FLOAT,\n  R14 FLOAT,\n  R15 FLOAT,\n  R16 FLOAT,\n  R17 FLOAT,\n  R18 FLOAT,\n  R19 FLOAT,\n  R20 FLOAT,\n  R21 FLOAT,\n  R22 FLOAT,\n  R23 FLOAT,\n  R24 FLOAT,\n  R25 FLOAT,\n  R26 FLOAT,\n  R27 FLOAT,\n  R28 FLOAT,\n  R29 FLOAT,\n  R30 FLOAT,\n  R31 FLOAT,\n  R32 FLOAT,\n  R33 FLOAT,\n  R34 FLOAT,\n  R35 FLOAT,\n  R36 FLOAT,\n  R37 FLOAT,\n  R38 FLOAT,\n  R39 FLOAT,\n  R40 FLOAT,\n  R41 FLOAT,\n  R42 FLOAT,\n  R43 FLOAT,\n  R44 FLOAT,\n  R45 FLOAT,\n  R46 FLOAT,\n  R47 FLOAT,\n  R48 FLOAT,\n  R49 FLOAT,\n  R50 FLOAT,\n  R51 FLOAT,\n  R52 FLOAT,\n  R53 FLOAT,\n  R54 FLOAT,\n  R55 FLOAT,\n  R56 FLOAT,\n  R57 FLOAT,\n  R58 FLOAT,\n  R59 FLOAT,\n  R60 FLOAT,\n  R61 FLOAT,\n  R62 FLOAT,\n  R63 FLOAT,\n  R64 FLOAT,\n  R65 FLOAT,\n  R66 FLOAT,\n  R67 FLOAT,\n  R68 FLOAT,\n  R69 FLOAT,\n  R70 FLOAT,\n  R71 FLOAT,\n  R72 FLOAT,\n  R73 FLOAT,\n  R74 FLOAT,\n  R75 FLOAT,\n  R76 FLOAT,\n  R77 FLOAT,\n  R78 FLOAT,\n  R79 FLOAT,\n  R80 FLOAT,\n  R81 FLOAT,\n  R82 FLOAT,\n  R83 FLOAT,\n  R84 FLOAT,\n  R85 FLOAT,\n  R86 FLOAT,\n  R87 FLOAT,\n  R88 FLOAT,\n  R89 FLOAT,\n  R90 FLOAT,\n  R91 FLOAT,\n  R92 FLOAT,\n  R93 FLOAT,\n  R94 FLOAT,\n  R95 FLOAT )\nAS\nBEGIN\n  SUSPEND;\nEND\n\";\n\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t}\n\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"TEST_SP\";\n\t\t\tcmd.CommandType = CommandType.StoredProcedure;\n\n\t\t\tcmd.Parameters.Add(new FbParameter() { Value = 1 });\n\t\t\tcmd.Parameters.Add(new FbParameter() { Value = 1 });\n\t\t\tcmd.Parameters.Add(new FbParameter() { Value = 1 });\n\t\t\tcmd.Parameters.Add(new FbParameter() { Value = 1 });\n\t\t\tcmd.Parameters.Add(new FbParameter() { Value = 1 });\n\t\t\tcmd.Parameters.Add(new FbParameter() { Value = 1 });\n\t\t\tcmd.Parameters.Add(new FbParameter() { Value = DateTime.Today });\n\t\t\tcmd.Parameters.Add(new FbParameter() { Value = DateTime.Today });\n\n\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DNET273_WritingClobAsBinary()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = \"insert into test (INT_FIELD, CLOB_FIELD) values (@INT_FIELD, @CLOB_FIELD)\";\n\t\t\tcmd.Parameters.Add(\"@INT_FIELD\", FbDbType.Integer).Value = 100;\n\t\t\tcmd.Parameters.Add(\"@CLOB_FIELD\", FbDbType.Binary).Value = new byte[] { 0x00, 0x001 };\n\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DNET595_ProperConnectionPoolConnectionsClosing()\n\t{\n\t\tFbConnection.ClearAllPools();\n\t\tconst int NumberOfThreads = 15;\n\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.Pooling = true;\n\t\tcsb.ConnectionLifeTime = 5;\n\t\tcsb.MinPoolSize = 0;\n\t\tvar cs = csb.ToString();\n\n\t\tvar active = await GetActiveConnections();\n\n\t\tvar tasks = new List<Task>();\n\t\tfor (var i = 0; i < NumberOfThreads; i++)\n\t\t{\n\t\t\ttasks.Add(GetSomethingLoopHelper(cs, 50));\n\t\t}\n\t\tawait Task.WhenAll(tasks);\n\n\t\tAssert.Greater(await GetActiveConnections(), active);\n\n\t\tvar sw = new Stopwatch();\n\t\tsw.Start();\n\t\twhile (sw.Elapsed.TotalSeconds < 60)\n\t\t{\n\t\t\tawait GetSomethingHelper(cs);\n\t\t}\n\n\t\tThread.Sleep(TimeSpan.FromSeconds(csb.ConnectionLifeTime * 2));\n\t\tAssert.AreEqual(active, await GetActiveConnections());\n\n\t\tstatic async Task GetSomethingHelper(string connectionString)\n\t\t{\n\t\t\tawait using (var conn = new FbConnection(connectionString))\n\t\t\t{\n\t\t\t\tawait conn.OpenAsync();\n\t\t\t\tawait using (var command = new FbCommand(\"select current_timestamp from mon$database\", conn))\n\t\t\t\t{\n\t\t\t\t\tawait command.ExecuteScalarAsync();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tstatic async Task GetSomethingLoopHelper(string connectionString, int loop)\n\t\t{\n\t\t\tfor (var i = 0; i < loop; i++)\n\t\t\t{\n\t\t\t\tawait GetSomethingHelper(connectionString);\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DNET313_MultiDimensionalArray()\n\t{\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.CommandText = @\"\nCREATE TABLE TABMAT (\n    ID INTEGER NOT NULL,\n\tMATRIX INTEGER[1:3, 1:4]\n)\";\n\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t}\n\t\ttry\n\t\t{\n\t\t\tvar sql = \"INSERT INTO TabMat (Id,Matrix) Values(@ValId,@ValMat)\";\n\t\t\tint[,] mat = { { 1, 2, 3, 4 }, { 10, 20, 30, 40 }, { 101, 102, 103, 104 } };\n\t\t\tvar random = new Random();\n\t\t\tawait using (var tx = await Connection.BeginTransactionAsync())\n\t\t\t{\n\t\t\t\tawait using (var cmd = new FbCommand(sql, Connection, tx))\n\t\t\t\t{\n\t\t\t\t\tcmd.Parameters.Add(\"@ValId\", FbDbType.Integer).Value = random.Next();\n\t\t\t\t\tcmd.Parameters.Add(\"@ValMat\", FbDbType.Array).Value = mat;\n\t\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t\t}\n\t\t\t\tawait tx.CommitAsync();\n\t\t\t}\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = @\"select matrix from tabmat\";\n\t\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\tif (await reader.ReadAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\tAssert.AreEqual(mat, reader[0]);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tAssert.Fail();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"drop table tabmat\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DNET304_VarcharOctetsParameterRoundtrip()\n\t{\n\t\tvar data = new byte[] { 10, 20 };\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.Parameters.Add(new FbParameter() { ParameterName = \"@x\", Value = data });\n\t\t\tcmd.CommandText = \"select cast(@x as varchar(10) character set octets) from rdb$database\";\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tAssert.AreEqual(data, reader[0]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DNET304_CharOctetsParameterRoundtrip()\n\t{\n\t\tvar data = new byte[] { 10, 20 };\n\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t{\n\t\t\tcmd.Parameters.Add(new FbParameter() { ParameterName = \"@x\", Value = data });\n\t\t\tcmd.CommandText = \"select cast(@x as char(10) character set octets) from rdb$database\";\n\t\t\tawait using (var reader = await cmd.ExecuteReaderAsync())\n\t\t\t{\n\t\t\t\twhile (await reader.ReadAsync())\n\t\t\t\t{\n\t\t\t\t\tAssert.AreEqual(new byte[] { data[0], data[1], 32, 32, 32, 32, 32, 32, 32, 32 }, reader[0]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DNET1036_ReadNumericScaleZero()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select cast(3 as numeric(18,0)) from rdb$database\", Connection, transaction))\n\t\t\t{\n\t\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\tawait reader.ReadAsync();\n\t\t\t\t\tAssert.AreEqual(3m, reader[0]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DNET1036_ReadDecimalScaleZero()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select cast(3 as decimal(18,0)) from rdb$database\", Connection, transaction))\n\t\t\t{\n\t\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\tawait reader.ReadAsync();\n\t\t\t\t\tAssert.AreEqual(3m, reader[0]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DNET1036_WriteNumericScaleZero()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select cast(@value as numeric(18,0)) from rdb$database\", Connection, transaction))\n\t\t\t{\n\t\t\t\tcommand.Parameters.AddWithValue(\"value\", 3m);\n\t\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\tawait reader.ReadAsync();\n\t\t\t\t\tAssert.AreEqual(3m, reader[0]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task DNET1036_WriteDecimalScaleZero()\n\t{\n\t\tawait using (var transaction = await Connection.BeginTransactionAsync())\n\t\t{\n\t\t\tawait using (var command = new FbCommand(\"select cast(@value as decimal(18,0)) from rdb$database\", Connection, transaction))\n\t\t\t{\n\t\t\t\tcommand.Parameters.AddWithValue(\"value\", 3m);\n\t\t\t\tawait using (var reader = await command.ExecuteReaderAsync())\n\t\t\t\t{\n\t\t\t\t\tawait reader.ReadAsync();\n\t\t\t\t\tAssert.AreEqual(3m, reader[0]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait transaction.RollbackAsync();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.FirebirdClient.Tests/TransactionScopeTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing System.Transactions;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.FirebirdClient.Tests;\n\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Default))]\n[TestFixtureSource(typeof(FbServerTypeTestFixtureSource), nameof(FbServerTypeTestFixtureSource.Embedded))]\npublic class TransactionScopeTests : FbTestsBase\n{\n\tpublic TransactionScopeTests(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t\t: base(serverType, compression, wireCrypt)\n\t{ }\n\n\t[Test]\n\tpublic async Task SimpleSelectTest()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\n\t\tcsb.Enlist = true;\n\n\t\tusing (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))\n\t\t{\n\t\t\tawait using (var c = new FbConnection(csb.ToString()))\n\t\t\t{\n\t\t\t\tc.Open();\n\n\t\t\t\tawait using (var command = new FbCommand(\"select * from TEST where (0=1)\", c))\n\t\t\t\t{\n\t\t\t\t\tawait using (var r = await command.ExecuteReaderAsync())\n\t\t\t\t\t{\n\t\t\t\t\t\twhile (await r.ReadAsync())\n\t\t\t\t\t\t{\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tscope.Complete();\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task InsertTest()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\n\t\tcsb.Enlist = true;\n\n\t\tusing (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))\n\t\t{\n\t\t\tawait using (var c = new FbConnection(csb.ToString()))\n\t\t\t{\n\t\t\t\tawait c.OpenAsync();\n\n\t\t\t\tvar sql = \"insert into TEST (int_field, date_field) values (1002, @date)\";\n\n\t\t\t\tawait using (var command = new FbCommand(sql, c))\n\t\t\t\t{\n\t\t\t\t\tcommand.Parameters.Add(\"@date\", FbDbType.Date).Value = DateTime.Now.ToString();\n\n\t\t\t\t\tvar ra = await command.ExecuteNonQueryAsync();\n\n\t\t\t\t\tAssert.AreEqual(ra, 1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tscope.Complete();\n\t\t}\n\t}\n}\n\n"
  },
  {
    "path": "src/FirebirdSql.Data.TestsBase/FbServerTypeTestFixtureSource.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections;\nusing FirebirdSql.Data.FirebirdClient;\nusing NUnit.Framework;\nusing NUnit.Framework.Internal;\n\nnamespace FirebirdSql.Data.TestsBase;\n\nclass FbServerTypeTestFixtureSource\n{\n\tpublic static IEnumerable Default()\n\t{\n\t\tyield return CreateTestFixtureData(FbServerType.Default, false, FbWireCrypt.Disabled);\n\t\tyield return CreateTestFixtureData(FbServerType.Default, false, FbWireCrypt.Required);\n\t\tyield return CreateTestFixtureData(FbServerType.Default, true, FbWireCrypt.Disabled);\n\t\tyield return CreateTestFixtureData(FbServerType.Default, true, FbWireCrypt.Required);\n\n\t}\n\n\tpublic static IEnumerable Embedded()\n\t{\n\t\tyield return CreateTestFixtureData(FbServerType.Embedded, false, FbWireCrypt.Disabled);\n\t}\n\n\tstatic TestFixtureData CreateTestFixtureData(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t{\n\t\tvar result = new TestFixtureData(serverType, compression, wireCrypt);\n\t\tresult.Properties.Set(nameof(FbTestsBase.ServerType), serverType.ToString());\n\t\tresult.Properties.Set(nameof(FbTestsBase.Compression), compression.ToString());\n\t\tresult.Properties.Set(nameof(FbTestsBase.WireCrypt), wireCrypt.ToString());\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.TestsBase/FbTestsBase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Carlos Guzman Alvarez, Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Security.Cryptography;\nusing System.Text;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.FirebirdClient;\nusing FirebirdSql.Data.Services;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.TestsBase;\n\npublic abstract class FbTestsBase\n{\n\t#region\tFields\n\n\tprivate readonly bool _insertTestData;\n\n\t#endregion\n\n\t#region\tProperties\n\n\tpublic FbServerType ServerType { get; }\n\tpublic bool Compression { get; }\n\tpublic FbWireCrypt WireCrypt { get; }\n\n\tpublic FbConnection Connection { get; private set; }\n\tpublic Version ServerVersion { get; private set; }\n\n\t#endregion\n\n\t#region\tConstructors\n\n\tpublic FbTestsBase(FbServerType serverType, bool compression, FbWireCrypt wireCrypt, bool insertTestData = true)\n\t{\n\t\tServerType = serverType;\n\t\tCompression = compression;\n\t\tWireCrypt = wireCrypt;\n\t\t_insertTestData = insertTestData;\n\t}\n\n\t#endregion\n\n\t#region\tSetUp and TearDown Methods\n\n\t[SetUp]\n\tpublic virtual async Task SetUp()\n\t{\n\t\tawait FbTestsSetup.SetUp(ServerType, Compression, WireCrypt);\n\n\t\tvar cs = BuildConnectionString(ServerType, Compression, WireCrypt);\n\t\tif (_insertTestData)\n\t\t{\n\t\t\tawait InsertTestData(cs);\n\t\t}\n\t\tConnection = new FbConnection(cs);\n\t\tawait Connection.OpenAsync();\n\t\tServerVersion = FbServerProperties.ParseServerVersion(Connection.ServerVersion);\n\t}\n\n\t[TearDown]\n\tpublic virtual async Task TearDown()\n\t{\n\t\tvar cs = BuildConnectionString(ServerType, Compression, WireCrypt);\n\t\tConnection.Dispose();\n\t\tif (_insertTestData)\n\t\t{\n\t\t\tawait DeleteAllData(cs);\n\t\t}\n\t\tFbConnection.ClearAllPools();\n\t}\n\n\t#endregion\n\n\t#region\tDatabase Creation Methods\n\n\tprivate static async Task InsertTestData(string connectionString)\n\t{\n\t\tawait using (var connection = new FbConnection(connectionString))\n\t\t{\n\t\t\tawait connection.OpenAsync();\n\n\t\t\tvar commandText = @\"\ninsert 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)\nvalues(@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)\";\n\n\t\t\tawait using (var transaction = await connection.BeginTransactionAsync())\n\t\t\t{\n\t\t\t\tawait using (var command = new FbCommand(commandText, connection, transaction))\n\t\t\t\t{\n\t\t\t\t\tcommand.Parameters.Add(\"@int_field\", FbDbType.Integer);\n\t\t\t\t\tcommand.Parameters.Add(\"@char_field\", FbDbType.Char);\n\t\t\t\t\tcommand.Parameters.Add(\"@varchar_field\", FbDbType.VarChar);\n\t\t\t\t\tcommand.Parameters.Add(\"@bigint_field\", FbDbType.BigInt);\n\t\t\t\t\tcommand.Parameters.Add(\"@smallint_field\", FbDbType.SmallInt);\n\t\t\t\t\tcommand.Parameters.Add(\"@float_field\", FbDbType.Double);\n\t\t\t\t\tcommand.Parameters.Add(\"@double_field\", FbDbType.Double);\n\t\t\t\t\tcommand.Parameters.Add(\"@numeric_field\", FbDbType.Numeric);\n\t\t\t\t\tcommand.Parameters.Add(\"@date_field\", FbDbType.Date);\n\t\t\t\t\tcommand.Parameters.Add(\"@time_Field\", FbDbType.Time);\n\t\t\t\t\tcommand.Parameters.Add(\"@timestamp_field\", FbDbType.TimeStamp);\n\t\t\t\t\tcommand.Parameters.Add(\"@clob_field\", FbDbType.Text);\n\t\t\t\t\tcommand.Parameters.Add(\"@blob_field\", FbDbType.Binary);\n\n\t\t\t\t\tawait command.PrepareAsync();\n\n\t\t\t\t\tfor (var i = 0; i < 100; i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tcommand.Parameters[\"@int_field\"].Value = i;\n\t\t\t\t\t\tcommand.Parameters[\"@char_field\"].Value = \"IRow \" + i.ToString();\n\t\t\t\t\t\tcommand.Parameters[\"@varchar_field\"].Value = \"IRow Number \" + i.ToString();\n\t\t\t\t\t\tcommand.Parameters[\"@bigint_field\"].Value = i;\n\t\t\t\t\t\tcommand.Parameters[\"@smallint_field\"].Value = i;\n\t\t\t\t\t\tcommand.Parameters[\"@float_field\"].Value = (float)(i + 10) / 5;\n\t\t\t\t\t\tcommand.Parameters[\"@double_field\"].Value = (double)(i + 10) / 5;\n\t\t\t\t\t\tcommand.Parameters[\"@numeric_field\"].Value = (decimal)(i + 10) / 5;\n\t\t\t\t\t\tcommand.Parameters[\"@date_field\"].Value = DateTime.Now;\n\t\t\t\t\t\tcommand.Parameters[\"@time_field\"].Value = DateTime.Now;\n\t\t\t\t\t\tcommand.Parameters[\"@timestamp_field\"].Value = DateTime.Now;\n\t\t\t\t\t\tcommand.Parameters[\"@clob_field\"].Value = \"IRow Number \" + i.ToString();\n\t\t\t\t\t\tcommand.Parameters[\"@blob_field\"].Value = Encoding.UTF8.GetBytes(\"IRow Number \" + i.ToString());\n\n\t\t\t\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t\t\t\t}\n\n\t\t\t\t\tawait transaction.CommitAsync();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static async Task DeleteAllData(string connectionString)\n\t{\n\t\tawait using (var connection = new FbConnection(connectionString))\n\t\t{\n\t\t\tawait connection.OpenAsync();\n\n\t\t\tvar commandText = @\"\nexecute block as\ndeclare name type of column rdb$relations.rdb$relation_name;\nbegin\n    for select rdb$relation_name from rdb$relations where coalesce(rdb$system_flag, 0) = 0 into name do\n    begin\n        execute statement 'delete from ' || name;\n    end\nend\";\n\n\t\t\tawait using (var transaction = await connection.BeginTransactionAsync())\n\t\t\t{\n\t\t\t\tawait using (var command = new FbCommand(commandText, connection, transaction))\n\t\t\t\t{\n\t\t\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t\t\t}\n\t\t\t\tawait transaction.CommitAsync();\n\t\t\t}\n\t\t}\n\t}\n\n\t#endregion\n\n\t#region\tConnectionString Building methods\n\n\tpublic static string BuildConnectionString(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t{\n\t\treturn BuildConnectionStringBuilder(serverType, compression, wireCrypt).ToString();\n\t}\n\n\tpublic static string BuildServicesConnectionString(FbServerType serverType, bool compression, FbWireCrypt wireCrypt, bool includeDatabase)\n\t{\n\t\treturn BuildServicesConnectionStringBuilder(serverType, compression, wireCrypt, includeDatabase).ToString();\n\t}\n\n\tpublic static FbConnectionStringBuilder BuildServicesConnectionStringBuilder(FbServerType serverType, bool compression, FbWireCrypt wireCrypt, bool includeDatabase)\n\t{\n\t\tvar builder = new FbConnectionStringBuilder();\n\t\tbuilder.UserID = FbTestsSetup.UserID;\n\t\tbuilder.Password = FbTestsSetup.Password;\n\t\tbuilder.DataSource = FbTestsSetup.DataSource;\n\t\tif (includeDatabase)\n\t\t{\n\t\t\tbuilder.Database = FbTestsSetup.Database(serverType, compression, wireCrypt);\n\t\t}\n\t\tbuilder.Port = FbTestsSetup.Port;\n\t\tbuilder.ServerType = serverType;\n\t\treturn builder;\n\t}\n\n\tpublic static FbConnectionStringBuilder BuildConnectionStringBuilder(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t{\n\t\tvar builder = new FbConnectionStringBuilder();\n\t\tbuilder.UserID = FbTestsSetup.UserID;\n\t\tbuilder.Password = FbTestsSetup.Password;\n\t\tbuilder.DataSource = FbTestsSetup.DataSource;\n\t\tbuilder.Database = FbTestsSetup.Database(serverType, compression, wireCrypt);\n\t\tbuilder.Port = FbTestsSetup.Port;\n\t\tbuilder.Charset = FbTestsSetup.Charset;\n\t\tbuilder.Pooling = FbTestsSetup.Pooling;\n\t\tbuilder.ServerType = serverType;\n\t\tbuilder.Compression = compression;\n\t\tbuilder.WireCrypt = wireCrypt;\n\t\treturn builder;\n\t}\n\n\t#endregion\n\n\t#region\tMethods\n\n\tprotected async Task<int> GetActiveConnections()\n\t{\n\t\tvar csb = BuildConnectionStringBuilder(ServerType, Compression, WireCrypt);\n\t\tcsb.Pooling = false;\n\t\tawait using (var conn = new FbConnection(csb.ToString()))\n\t\t{\n\t\t\tawait conn.OpenAsync();\n\t\t\tawait using (var cmd = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"select count(*) from mon$attachments where mon$attachment_id <> current_connection\";\n\t\t\t\treturn Convert.ToInt32(await cmd.ExecuteScalarAsync());\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected bool EnsureServerVersionAtLeast(Version serverVersion)\n\t{\n\t\tif (FbTestsSetup.ServerVersionAtLeast(ServerVersion, serverVersion))\n\t\t\treturn true;\n\t\tAssert.Inconclusive(\"Not supported on this version.\");\n\t\treturn false;\n\t}\n\tprotected bool EnsureServerVersionAtMost(Version serverVersion)\n\t{\n\t\tif (FbTestsSetup.ServerVersionAtMost(ServerVersion, serverVersion))\n\t\t\treturn true;\n\t\tAssert.Inconclusive(\"Not supported on this version.\");\n\t\treturn false;\n\t}\n\n\tprotected bool EnsureServerType(FbServerType serverType)\n\t{\n\t\tif (ServerType == serverType)\n\t\t\treturn true;\n\t\tAssert.Inconclusive($\"Not supported on this {nameof(FbServerType)}.\");\n\t\treturn false;\n\t}\n\n\tprotected bool EnsureWireCrypt(FbWireCrypt wireCrypt)\n\t{\n\t\tif (WireCrypt == wireCrypt)\n\t\t\treturn true;\n\t\tAssert.Inconclusive($\"Not supported with this {nameof(FbWireCrypt)}.\");\n\t\treturn false;\n\t}\n\n\t#endregion\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.TestsBase/FbTestsSetup.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.FirebirdClient;\nusing FirebirdSql.Data.Services;\nusing FirebirdSql.Data.TestsBase;\nusing NUnit.Framework;\n\n[SetUpFixture]\npublic class FbTestsSetup\n{\n\tprivate const string DatabaseBase = \"netprovider_tests\";\n\tinternal const string UserID = \"SYSDBA\";\n\tinternal const string Password = \"masterkey\";\n\tinternal const string DataSource = \"localhost\";\n\tinternal const int Port = 3050;\n\tinternal const string Charset = \"utf8\";\n\tinternal const bool Pooling = false;\n\tinternal const int PageSize = 16384;\n\tinternal const bool ForcedWrite = false;\n\n\tprivate static HashSet<(FbServerType, bool, FbWireCrypt)> _initalized = new HashSet<(FbServerType, bool, FbWireCrypt)>();\n\n\tpublic static async Task SetUp(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t{\n\t\tvar item = (serverType, compression, wireCrypt);\n\t\tif (!_initalized.Contains(item))\n\t\t{\n\t\t\tvar cs = FbTestsBase.BuildConnectionString(serverType, compression, wireCrypt);\n\t\t\tawait FbConnection.CreateDatabaseAsync(cs, PageSize, ForcedWrite, true);\n\t\t\tawait using (var connection = new FbConnection(cs))\n\t\t\t{\n\t\t\t\tawait connection.OpenAsync();\n\t\t\t\tvar serverVersion = FbServerProperties.ParseServerVersion(connection.ServerVersion);\n\t\t\t\tawait CreateTables(connection, serverVersion);\n\t\t\t\tawait CreateProcedures(connection, serverVersion);\n\t\t\t\tawait CreateFunctions(connection, serverVersion);\n\t\t\t\tawait CreateTriggers(connection, serverVersion);\n\t\t\t}\n\t\t\t_initalized.Add(item);\n\t\t}\n\t}\n\n\tpublic static string Database(FbServerType serverType, bool compression, FbWireCrypt wireCrypt)\n\t{\n\t\treturn $\"{DatabaseBase}_{serverType}_{compression}_{wireCrypt}.fdb\";\n\t}\n\n\t[OneTimeTearDown]\n\tpublic async Task TearDown()\n\t{\n\t\tFbConnection.ClearAllPools();\n\t\tforeach (var item in _initalized)\n\t\t{\n\t\t\tvar cs = FbTestsBase.BuildConnectionString(item.Item1, item.Item2, item.Item3);\n\t\t\tawait FbConnection.DropDatabaseAsync(cs);\n\t\t}\n\t\t_initalized.Clear();\n\t}\n\n\tpublic static bool ServerVersionAtLeast(Version serverVersion, Version minimum) => serverVersion >= minimum;\n\tpublic static bool ServerVersionAtMost(Version serverVersion, Version maximum) => serverVersion < maximum;\n\n\tprivate static async Task CreateTables(FbConnection connection, Version serverVersion)\n\t{\n\t\tvar commandText = new StringBuilder();\n\n\t\tcommandText.Append(\"RECREATE TABLE TEST (\");\n\t\tcommandText.Append(\"INT_FIELD\t\t INTEGER DEFAULT 0 NOT NULL\tPRIMARY\tKEY,\");\n\t\tcommandText.Append(\"CHAR_FIELD\t\t CHAR(30),\");\n\t\tcommandText.Append(\"VARCHAR_FIELD\t VARCHAR(100),\");\n\t\tcommandText.Append(\"BIGINT_FIELD\t BIGINT,\");\n\t\tcommandText.Append(\"SMALLINT_FIELD\t SMALLINT,\");\n\t\tcommandText.Append(\"DOUBLE_FIELD\t DOUBLE\tPRECISION,\");\n\t\tcommandText.Append(\"FLOAT_FIELD\t\t FLOAT,\");\n\t\tcommandText.Append(\"NUMERIC_FIELD\t NUMERIC(15,2),\");\n\t\tcommandText.Append(\"DECIMAL_FIELD\t DECIMAL(15,2),\");\n\t\tcommandText.Append(\"DATE_FIELD\t\t DATE,\");\n\t\tcommandText.Append(\"TIME_FIELD\t\t TIME,\");\n\t\tcommandText.Append(\"TIMESTAMP_FIELD\t TIMESTAMP,\");\n\t\tcommandText.Append(\"CLOB_FIELD\t\t BLOB SUB_TYPE 1 SEGMENT SIZE 80,\");\n\t\tcommandText.Append(\"BLOB_FIELD\t\t BLOB SUB_TYPE 0 SEGMENT SIZE 80,\");\n\t\tcommandText.Append(\"IARRAY_FIELD\t INTEGER [0:3],\");\n\t\tcommandText.Append(\"SARRAY_FIELD\t SMALLINT [0:4],\");\n\t\tcommandText.Append(\"LARRAY_FIELD\t BIGINT\t[0:5],\");\n\t\tcommandText.Append(\"FARRAY_FIELD\t FLOAT [0:3],\");\n\t\tcommandText.Append(\"BARRAY_FIELD\t DOUBLE\tPRECISION [1:4],\");\n\t\tcommandText.Append(\"NARRAY_FIELD\t NUMERIC(10,6) [1:4],\");\n\t\tcommandText.Append(\"DARRAY_FIELD\t DATE [1:4],\");\n\t\tcommandText.Append(\"TARRAY_FIELD\t TIME [1:4],\");\n\t\tcommandText.Append(\"TSARRAY_FIELD\t TIMESTAMP [1:4],\");\n\t\tcommandText.Append(\"CARRAY_FIELD\t CHAR(21) [1:4],\");\n\t\tcommandText.Append(\"VARRAY_FIELD\t VARCHAR(30) [1:4],\");\n\t\tcommandText.Append(\"BIG_ARRAY\t\t INTEGER [1:32767],\");\n\t\tcommandText.Append(\"EXPR_FIELD\t\t COMPUTED BY (smallint_field * 1000),\");\n\t\tcommandText.Append(\"CS_FIELD\t\t CHAR(1) CHARACTER SET UNICODE_FSS COLLATE UNICODE_FSS,\");\n\t\tcommandText.Append(\"UCCHAR_ARRAY\t CHAR(10) [1:10] CHARACTER SET UNICODE_FSS);\");\n\n\t\tawait using (var command = new FbCommand(commandText.ToString(), connection))\n\t\t{\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t}\n\n\t\tawait using (var command = new FbCommand(\"recreate table log(occured timestamp, text varchar(20));\", connection))\n\t\t{\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t}\n\n\t\tawait using (var command = new FbCommand(\"RECREATE TABLE GUID_TEST (INT_FIELD INTEGER, GUID_FIELD CHAR(16) CHARACTER SET OCTETS)\", connection))\n\t\t{\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\tprivate static async Task CreateProcedures(FbConnection connection, Version serverVersion)\n\t{\n\t\tvar commandText = new StringBuilder();\n\n\t\tcommandText.Clear();\n\t\tcommandText.Append(\"RECREATE PROCEDURE SELECT_DATA\\r\\n\");\n\t\tcommandText.Append(\"RETURNS\t(\\r\\n\");\n\t\tcommandText.Append(\"INT_FIELD INTEGER,\\r\\n\");\n\t\tcommandText.Append(\"VARCHAR_FIELD VARCHAR(100),\\r\\n\");\n\t\tcommandText.Append(\"DECIMAL_FIELD DECIMAL(15,2))\\r\\n\");\n\t\tcommandText.Append(\"AS\\r\\n\");\n\t\tcommandText.Append(\"begin\\r\\n\");\n\t\tcommandText.Append(\"FOR\tSELECT INT_FIELD, VARCHAR_FIELD, DECIMAL_FIELD FROM\tTEST INTO :INT_FIELD, :VARCHAR_FIELD, :DECIMAL_FIELD\\r\\n\");\n\t\tcommandText.Append(\"DO\\r\\n\");\n\t\tcommandText.Append(\"SUSPEND;\\r\\n\");\n\t\tcommandText.Append(\"end\\r\\n\");\n\t\tawait using (var command = new FbCommand(commandText.ToString(), connection))\n\t\t{\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t}\n\n\t\tcommandText.Clear();\n\t\tcommandText.Append(\"RECREATE PROCEDURE GETRECORDCOUNT\\r\\n\");\n\t\tcommandText.Append(\"RETURNS\t(\\r\\n\");\n\t\tcommandText.Append(\"RECCOUNT SMALLINT)\\r\\n\");\n\t\tcommandText.Append(\"AS\\r\\n\");\n\t\tcommandText.Append(\"begin\\r\\n\");\n\t\tcommandText.Append(\"for\tselect count(*)\tfrom test into :reccount\\r\\n\");\n\t\tcommandText.Append(\"do\\r\\n\");\n\t\tcommandText.Append(\"suspend;\\r\\n\");\n\t\tcommandText.Append(\"end\\r\\n\");\n\t\tawait using (var command = new FbCommand(commandText.ToString(), connection))\n\t\t{\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t}\n\n\t\tcommandText.Clear();\n\t\tcommandText.Append(\"RECREATE PROCEDURE GETVARCHARFIELD (\\r\\n\");\n\t\tcommandText.Append(\"ID INTEGER)\\r\\n\");\n\t\tcommandText.Append(\"RETURNS\t(\\r\\n\");\n\t\tcommandText.Append(\"VARCHAR_FIELD VARCHAR(100))\\r\\n\");\n\t\tcommandText.Append(\"AS\\r\\n\");\n\t\tcommandText.Append(\"begin\\r\\n\");\n\t\tcommandText.Append(\"for\tselect varchar_field from test where int_field = :id into :varchar_field\\r\\n\");\n\t\tcommandText.Append(\"do\\r\\n\");\n\t\tcommandText.Append(\"suspend;\\r\\n\");\n\t\tcommandText.Append(\"end\\r\\n\");\n\t\tawait using (var command = new FbCommand(commandText.ToString(), connection))\n\t\t{\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t}\n\n\t\tcommandText.Clear();\n\t\tcommandText.Append(\"RECREATE PROCEDURE GETASCIIBLOB (\\r\\n\");\n\t\tcommandText.Append(\"ID INTEGER)\\r\\n\");\n\t\tcommandText.Append(\"RETURNS\t(\\r\\n\");\n\t\tcommandText.Append(\"ASCII_BLOB BLOB\tSUB_TYPE 1)\\r\\n\");\n\t\tcommandText.Append(\"AS\\r\\n\");\n\t\tcommandText.Append(\"begin\\r\\n\");\n\t\tcommandText.Append(\"for\tselect clob_field from test\twhere int_field\t= :id into :ascii_blob\\r\\n\");\n\t\tcommandText.Append(\"do\\r\\n\");\n\t\tcommandText.Append(\"suspend;\\r\\n\");\n\t\tcommandText.Append(\"end\\r\\n\");\n\t\tawait using (var command = new FbCommand(commandText.ToString(), connection))\n\t\t{\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t}\n\n\t\tcommandText.Clear();\n\t\tcommandText.Append(\"RECREATE PROCEDURE DATAREADERTEST\\r\\n\");\n\t\tcommandText.Append(\"RETURNS\t(\\r\\n\");\n\t\tcommandText.Append(\"content\tVARCHAR(128))\\r\\n\");\n\t\tcommandText.Append(\"AS\\r\\n\");\n\t\tcommandText.Append(\"begin\\r\\n\");\n\t\tcommandText.Append(\"content\t= 'test';\\r\\n\");\n\t\tcommandText.Append(\"suspend;\\r\\n\");\n\t\tcommandText.Append(\"end\\r\\n\");\n\t\tawait using (var command = new FbCommand(commandText.ToString(), connection))\n\t\t{\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t}\n\n\t\tcommandText.Clear();\n\t\tcommandText.Append(\"recreate procedure SimpleSP\\r\\n\");\n\t\tcommandText.Append(\"returns (result integer) as\\r\\n\");\n\t\tcommandText.Append(\"begin\\r\\n\");\n\t\tcommandText.Append(\"result = 1000;\\r\\n\");\n\t\tcommandText.Append(\"end \\r\\n\");\n\t\tawait using (var command = new FbCommand(commandText.ToString(), connection))\n\t\t{\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\tprivate static async Task CreateFunctions(FbConnection connection, Version serverVersion)\n\t{\n\t\tif (!ServerVersionAtLeast(serverVersion, new Version(3, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tvar commandText = new StringBuilder();\n\n\t\tcommandText.Append(\"RECREATE FUNCTION TEST_FUNC(\\r\\n\");\n\t\tcommandText.Append(\"I INT)\\r\\n\");\n\t\tcommandText.Append(\"RETURNS\tBIGINT\\r\\n\");\n\t\tcommandText.Append(\"AS\\r\\n\");\n\t\tcommandText.Append(\"BEGIN\\r\\n\");\n\t\tcommandText.Append(\"RETURN I;\\r\\n\");\n\t\tcommandText.Append(\"END\\r\\n\");\n\t\tawait using (var command = new FbCommand(commandText.ToString(), connection))\n\t\t{\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t}\n\t}\n\n\tprivate static async Task CreateTriggers(FbConnection connection, Version serverVersion)\n\t{\n\t\tvar commandText = new StringBuilder();\n\n\t\tcommandText.Clear();\n\t\tcommandText.Append(\"RECREATE TRIGGER new_row FOR test\tACTIVE\\r\\n\");\n\t\tcommandText.Append(\"AFTER INSERT POSITION 0\\r\\n\");\n\t\tcommandText.Append(\"AS\\r\\n\");\n\t\tcommandText.Append(\"BEGIN\\r\\n\");\n\t\tcommandText.Append(\"POST_EVENT 'new\trow';\\r\\n\");\n\t\tcommandText.Append(\"END\");\n\t\tawait using (var command = new FbCommand(commandText.ToString(), connection))\n\t\t{\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t}\n\n\t\tcommandText.Clear();\n\t\tcommandText.Append(\"RECREATE TRIGGER update_row FOR test ACTIVE\\r\\n\");\n\t\tcommandText.Append(\"AFTER UPDATE POSITION 0\\r\\n\");\n\t\tcommandText.Append(\"AS\\r\\n\");\n\t\tcommandText.Append(\"BEGIN\\r\\n\");\n\t\tcommandText.Append(\"POST_EVENT 'updated\trow';\\r\\n\");\n\t\tcommandText.Append(\"END\");\n\t\tawait using (var command = new FbCommand(commandText.ToString(), connection))\n\t\t{\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t}\n\n\t\tcommandText.Clear();\n\t\tcommandText.Append(\"recreate trigger log active on connect\\r\\n\");\n\t\tcommandText.Append(\"as\\r\\n\");\n\t\tcommandText.Append(\"begin\\r\\n\");\n\t\tcommandText.Append(\"insert into log (occured, text) values (current_timestamp, 'on connect');\\r\\n\");\n\t\tcommandText.Append(\"end\");\n\t\tawait using (var command = new FbCommand(commandText.ToString(), connection))\n\t\t{\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.TestsBase/FirebirdSql.Data.TestsBase.projitems",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <PropertyGroup>\n    <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>\n    <HasSharedItems>true</HasSharedItems>\n    <SharedGUID>2f67ff6e-a6fc-44f4-9687-9e5ca05c73a3</SharedGUID>\n  </PropertyGroup>\n  <PropertyGroup Label=\"Configuration\">\n    <Import_RootNamespace>FirebirdSql.Data.TestsBase</Import_RootNamespace>\n  </PropertyGroup>\n  <ItemGroup>\n    <Compile Include=\"$(MSBuildThisFileDirectory)NoServerCategoryAttribute.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)FbServerTypeTestFixtureSource.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)FbTestsBase.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)FbTestsSetup.cs\" />\n    <Compile Include=\"$(MSBuildThisFileDirectory)Program.cs\" />\n  </ItemGroup>\n  <ItemGroup>\n    <None Include=\"$(MSBuildThisFileDirectory)FirebirdSql.Data.TestsBase.snk\" />\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "src/FirebirdSql.Data.TestsBase/FirebirdSql.Data.TestsBase.shproj",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"15.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>2f67ff6e-a6fc-44f4-9687-9e5ca05c73a3</ProjectGuid>\n    <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>\n  </PropertyGroup>\n  <Import Project=\"$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props\" Condition=\"Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')\" />\n  <Import Project=\"$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\CodeSharing\\Microsoft.CodeSharing.Common.Default.props\" />\n  <Import Project=\"$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\CodeSharing\\Microsoft.CodeSharing.Common.props\" />\n  <PropertyGroup />\n  <Import Project=\"FirebirdSql.Data.TestsBase.projitems\" Label=\"Shared\" />\n  <Import Project=\"$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)\\CodeSharing\\Microsoft.CodeSharing.CSharp.targets\" />\n</Project>\n"
  },
  {
    "path": "src/FirebirdSql.Data.TestsBase/NoServerCategoryAttribute.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing NUnit.Framework;\n\nnamespace FirebirdSql.Data.TestsBase;\n\nclass NoServerCategoryAttribute : CategoryAttribute\n{\n\tpublic NoServerCategoryAttribute()\n\t\t: base(\"NoServer\")\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.Data.TestsBase/Program.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Linq;\nusing System.Reflection;\nusing NUnitLite;\n\nnamespace FirebirdSql.Data.TestsBase;\n\npublic static class Program\n{\n\tpublic static int Main(string[] args)\n\t{\n\t\targs = args?.Any() ?? false\n\t\t\t? args\n\t\t\t: new[] { \"--noresult\", \"--labels=All\" };\n\t\treturn new AutoRun(Assembly.GetEntryAssembly()).Execute(args);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Design/Internal/FbDesignTimeServices.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.Scaffolding.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Design;\nusing Microsoft.EntityFrameworkCore.Scaffolding;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Design.Internal;\n\npublic class FbDesignTimeServices : IDesignTimeServices\n{\n\tpublic void ConfigureDesignTimeServices(IServiceCollection serviceCollection)\n\t{\n\t\tserviceCollection.AddEntityFrameworkFirebird();\n\t\tnew EntityFrameworkRelationalDesignServicesBuilder(serviceCollection)\n\t\t\t.TryAdd<IAnnotationCodeGenerator, AnnotationCodeGenerator>()\n\t\t\t.TryAdd<IDatabaseModelFactory, FbDatabaseModelFactory>()\n\t\t\t.TryAdd<IProviderConfigurationCodeGenerator, FbProviderCodeGenerator>()\n\t\t\t.TryAddCoreServices();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Diagnostics/Internal/FbLoggingDefinitions.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Diagnostics;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Diagnostics.Internal;\n\npublic class FbLoggingDefinitions : RelationalLoggingDefinitions\n{ }\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Extensions/FbDatabaseFacadeExtensions.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Extensions;\n\n/// <summary>\n///\t\tFirebirdSQL specific extension methods for <see cref=\"DatabaseFacade\"/>.\n/// </summary>\npublic static class FbDatabaseFacadeExtensions\n{\n\t/// <summary>\n\t///\t\t<para>\n\t///\t\t\tReturns true if the database provider currently in use is the FirebirdSQL provider.\n\t///\t\t</para>\n\t///\t\t<para>\n\t///\t\t\tThis method can only be used after the <see cref=\"DbContext\" /> has been configured because\n\t///\t\t\tit is only then that the provider is known. This means that this method cannot be used\n\t///\t\t\tin <see cref=\"DbContext.OnConfiguring\" /> because this is where application code sets the\n\t///\t\t\tprovider to use as part of configuring the context.\n\t///\t\t</para>\n\t/// </summary>\n\t/// <param name=\"database\">\n\t///\t\tThe facade from <see cref=\"DbContext.Database\" />.\n\t/// </param>\n\t/// <returns>\n\t///\t\tTrue if FirebirdSQL is being used; false otherwise.\n\t/// </returns>\n\tpublic static bool IsFirebird(this DatabaseFacade database)\n\t\t=> database.ProviderName.Equals(typeof(FbOptionsExtension).GetTypeInfo().Assembly.GetName().Name, StringComparison.Ordinal);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Extensions/FbDbContextOptionsBuilderExtensions.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data.Common;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure.Internal;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\n\nnamespace Microsoft.EntityFrameworkCore;\n\npublic static class FbDbContextOptionsBuilderExtensions\n{\n\tpublic static DbContextOptionsBuilder UseFirebird(this DbContextOptionsBuilder optionsBuilder, string connectionString, Action<FbDbContextOptionsBuilder> fbOptionsAction = null)\n\t{\n\t\tvar extension = (FbOptionsExtension)GetOrCreateExtension(optionsBuilder).WithConnectionString(connectionString);\n\t\t((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension);\n\t\tfbOptionsAction?.Invoke(new FbDbContextOptionsBuilder(optionsBuilder));\n\t\treturn optionsBuilder;\n\t}\n\n\tpublic static DbContextOptionsBuilder UseFirebird(this DbContextOptionsBuilder optionsBuilder, DbConnection connection, Action<FbDbContextOptionsBuilder> fbOptionsAction = null)\n\t{\n\t\tvar extension = (FbOptionsExtension)GetOrCreateExtension(optionsBuilder).WithConnection(connection);\n\t\t((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension);\n\t\tfbOptionsAction?.Invoke(new FbDbContextOptionsBuilder(optionsBuilder));\n\t\treturn optionsBuilder;\n\t}\n\n\tpublic static DbContextOptionsBuilder<TContext> UseFirebird<TContext>(this DbContextOptionsBuilder<TContext> optionsBuilder, string connectionString, Action<FbDbContextOptionsBuilder> fbOptionsAction = null)\n\t\twhere TContext : DbContext\n\t{\n\t\treturn (DbContextOptionsBuilder<TContext>)UseFirebird((DbContextOptionsBuilder)optionsBuilder, connectionString, fbOptionsAction);\n\t}\n\n\tpublic static DbContextOptionsBuilder<TContext> UseFirebird<TContext>(this DbContextOptionsBuilder<TContext> optionsBuilder, DbConnection connection, Action<FbDbContextOptionsBuilder> fbOptionsAction = null)\n\t\twhere TContext : DbContext\n\t{\n\t\treturn (DbContextOptionsBuilder<TContext>)UseFirebird((DbContextOptionsBuilder)optionsBuilder, connection, fbOptionsAction);\n\t}\n\n\tstatic FbOptionsExtension GetOrCreateExtension(DbContextOptionsBuilder optionsBuilder)\n\t\t=> optionsBuilder.Options.FindExtension<FbOptionsExtension>()\n\t\t\t?? new FbOptionsExtension();\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Extensions/FbModelBuilderExtensions.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Internal;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\n\nnamespace Microsoft.EntityFrameworkCore;\n\npublic static class FbModelBuilderExtensions\n{\n\tpublic static ModelBuilder UseIdentityColumns(this ModelBuilder modelBuilder)\n\t{\n\t\tvar model = modelBuilder.Model;\n\t\tmodel.SetValueGenerationStrategy(FbValueGenerationStrategy.IdentityColumn);\n\t\treturn modelBuilder;\n\t}\n\n\tpublic static ModelBuilder UseSequenceTriggers(this ModelBuilder modelBuilder)\n\t{\n\t\tvar model = modelBuilder.Model;\n\t\tmodel.SetValueGenerationStrategy(FbValueGenerationStrategy.SequenceTrigger);\n\t\treturn modelBuilder;\n\t}\n\n\tpublic static ModelBuilder UseHiLo(this ModelBuilder modelBuilder, string name = null)\n\t{\n\t\tvar model = modelBuilder.Model;\n\t\tname ??= FbModelExtensions.DefaultHiLoSequenceName;\n\t\tif (model.FindSequence(name) == null)\n\t\t{\n\t\t\tmodelBuilder.HasSequence(name).IncrementsBy(10);\n\t\t}\n\t\tmodel.SetValueGenerationStrategy(FbValueGenerationStrategy.HiLo);\n\t\tmodel.SetHiLoSequenceName(name);\n\t\tmodel.SetSequenceNameSuffix(null);\n\t\treturn modelBuilder;\n\t}\n\n\tpublic static IConventionSequenceBuilder HasHiLoSequence(this IConventionModelBuilder modelBuilder, string name, bool fromDataAnnotation = false)\n\t{\n\t\tif (!modelBuilder.CanSetHiLoSequence(name))\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\tmodelBuilder.Metadata.SetHiLoSequenceName(name, fromDataAnnotation);\n\t\treturn name == null\n\t\t\t? null\n\t\t\t: modelBuilder.HasSequence(name, null, fromDataAnnotation);\n\t}\n\n\tpublic static bool CanSetHiLoSequence(this IConventionModelBuilder modelBuilder, string name, bool fromDataAnnotation = false)\n\t{\n\t\treturn modelBuilder.CanSetAnnotation(FbAnnotationNames.HiLoSequenceName, name, fromDataAnnotation);\n\t}\n\n\tpublic static IConventionModelBuilder HasValueGenerationStrategy(this IConventionModelBuilder modelBuilder, FbValueGenerationStrategy? valueGenerationStrategy, bool fromDataAnnotation = false)\n\t{\n\t\tif (modelBuilder.CanSetAnnotation(FbAnnotationNames.ValueGenerationStrategy, valueGenerationStrategy, fromDataAnnotation))\n\t\t{\n\t\t\tmodelBuilder.Metadata.SetValueGenerationStrategy(valueGenerationStrategy, fromDataAnnotation);\n\t\t\tif (valueGenerationStrategy != FbValueGenerationStrategy.IdentityColumn)\n\t\t\t{\n\t\t\t}\n\t\t\tif (valueGenerationStrategy != FbValueGenerationStrategy.SequenceTrigger)\n\t\t\t{\n\t\t\t}\n\t\t\tif (valueGenerationStrategy != FbValueGenerationStrategy.HiLo)\n\t\t\t{\n\t\t\t}\n\t\t\treturn modelBuilder;\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Extensions/FbModelExtensions.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Internal;\nusing Microsoft.EntityFrameworkCore.Metadata;\n\nnamespace Microsoft.EntityFrameworkCore;\n\npublic static class FbModelExtensions\n{\n\tpublic const string DefaultHiLoSequenceName = \"EntityFrameworkHiLoSequence\";\n\tpublic const string DefaultSequenceNameSuffix = \"Sequence\";\n\n\tpublic static void SetValueGenerationStrategy(this IMutableModel model, FbValueGenerationStrategy? value)\n\t\t=> model.SetOrRemoveAnnotation(FbAnnotationNames.ValueGenerationStrategy, value);\n\n\tpublic static void SetValueGenerationStrategy(this IConventionModel model, FbValueGenerationStrategy? value, bool fromDataAnnotation = false)\n\t\t=> model.SetOrRemoveAnnotation(FbAnnotationNames.ValueGenerationStrategy, value, fromDataAnnotation);\n\n\tpublic static FbValueGenerationStrategy? GetValueGenerationStrategy(this IModel model)\n\t\t=> (FbValueGenerationStrategy?)model[FbAnnotationNames.ValueGenerationStrategy];\n\n\tpublic static FbValueGenerationStrategy? GetValueGenerationStrategy(this IMutableModel model)\n\t\t=> (FbValueGenerationStrategy?)model[FbAnnotationNames.ValueGenerationStrategy];\n\n\tpublic static FbValueGenerationStrategy? GetValueGenerationStrategy(this IConventionModel model)\n\t\t=> (FbValueGenerationStrategy?)model[FbAnnotationNames.ValueGenerationStrategy];\n\n\tpublic static string GetHiLoSequenceName(this IReadOnlyModel model)\n\t\t=> (string)model[FbAnnotationNames.HiLoSequenceName] ?? DefaultHiLoSequenceName;\n\n\tpublic static void SetHiLoSequenceName(this IMutableModel model, string name)\n\t\t=> model.SetOrRemoveAnnotation(FbAnnotationNames.HiLoSequenceName, name);\n\n\tpublic static string SetHiLoSequenceName(this IConventionModel model, string name, bool fromDataAnnotation = false)\n\t\t=> (string)model.SetOrRemoveAnnotation(FbAnnotationNames.HiLoSequenceName, name, fromDataAnnotation)?.Value;\n\n\tpublic static ConfigurationSource? GetHiLoSequenceNameConfigurationSource(this IConventionModel model)\n\t\t=> model.FindAnnotation(FbAnnotationNames.HiLoSequenceName)?.GetConfigurationSource();\n\n\tpublic static string GetHiLoSequenceSchema(this IReadOnlyModel model)\n\t\t=> (string)model[FbAnnotationNames.HiLoSequenceSchema];\n\n\tpublic static void SetHiLoSequenceSchema(this IMutableModel model, string value)\n\t\t=> model.SetOrRemoveAnnotation(FbAnnotationNames.HiLoSequenceSchema, value);\n\n\tpublic static string SetHiLoSequenceSchema(this IConventionModel model, string value, bool fromDataAnnotation = false)\n\t\t=> (string)model.SetOrRemoveAnnotation(FbAnnotationNames.HiLoSequenceSchema, value, fromDataAnnotation)?.Value;\n\n\tpublic static ConfigurationSource? GetHiLoSequenceSchemaConfigurationSource(this IConventionModel model)\n\t\t=> model.FindAnnotation(FbAnnotationNames.HiLoSequenceSchema)?.GetConfigurationSource();\n\n\tpublic static string GetSequenceNameSuffix(this IReadOnlyModel model)\n\t\t=> (string)model[FbAnnotationNames.SequenceNameSuffix] ?? DefaultSequenceNameSuffix;\n\n\tpublic static void SetSequenceNameSuffix(this IMutableModel model, string name)\n\t\t=> model.SetOrRemoveAnnotation(FbAnnotationNames.SequenceNameSuffix, name);\n\n\tpublic static string SetSequenceNameSuffix(this IConventionModel model, string name, bool fromDataAnnotation = false)\n\t\t=> (string)model.SetOrRemoveAnnotation(FbAnnotationNames.SequenceNameSuffix, name, fromDataAnnotation)?.Value;\n\n\tpublic static ConfigurationSource? GetSequenceNameSuffixConfigurationSource(this IConventionModel model)\n\t\t=> model.FindAnnotation(FbAnnotationNames.SequenceNameSuffix)?.GetConfigurationSource();\n\n\tpublic static string GetSequenceSchema(this IReadOnlyModel model)\n\t\t=> (string)model[FbAnnotationNames.SequenceSchema];\n\n\tpublic static void SetSequenceSchema(this IMutableModel model, string value)\n\t\t=> model.SetOrRemoveAnnotation(FbAnnotationNames.SequenceSchema, value);\n\n\tpublic static string SetSequenceSchema(this IConventionModel model, string value, bool fromDataAnnotation = false)\n\t\t=> (string)model.SetOrRemoveAnnotation(FbAnnotationNames.SequenceSchema, value, fromDataAnnotation)?.Value;\n\n\tpublic static ConfigurationSource? GetSequenceSchemaConfigurationSource(this IConventionModel model)\n\t\t=> model.FindAnnotation(FbAnnotationNames.SequenceSchema)?.GetConfigurationSource();\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Extensions/FbPropertyBuilderExtensions.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Internal;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\n\nnamespace Microsoft.EntityFrameworkCore;\n\npublic static class FbPropertyBuilderExtensions\n{\n\tpublic static PropertyBuilder UseIdentityColumn(this PropertyBuilder propertyBuilder)\n\t{\n\t\tvar property = propertyBuilder.Metadata;\n\t\tproperty.SetValueGenerationStrategy(FbValueGenerationStrategy.IdentityColumn);\n\t\treturn propertyBuilder;\n\t}\n\n\tpublic static PropertyBuilder<TProperty> UseIdentityColumn<TProperty>(this PropertyBuilder<TProperty> propertyBuilder)\n\t\t=> (PropertyBuilder<TProperty>)UseIdentityColumn((PropertyBuilder)propertyBuilder);\n\n\tpublic static PropertyBuilder UseSequenceTrigger(this PropertyBuilder propertyBuilder)\n\t{\n\t\tvar property = propertyBuilder.Metadata;\n\t\tproperty.SetValueGenerationStrategy(FbValueGenerationStrategy.SequenceTrigger);\n\t\treturn propertyBuilder;\n\t}\n\n\tpublic static PropertyBuilder<TProperty> UseSequenceTrigger<TProperty>(this PropertyBuilder<TProperty> propertyBuilder)\n\t\t=> (PropertyBuilder<TProperty>)UseSequenceTrigger((PropertyBuilder)propertyBuilder);\n\n\tpublic static PropertyBuilder UseHiLo(this PropertyBuilder propertyBuilder, string name = null)\n\t{\n\t\tvar property = propertyBuilder.Metadata;\n\t\tname ??= FbModelExtensions.DefaultHiLoSequenceName;\n\t\tvar model = property.DeclaringType.Model;\n\t\tif (model.FindSequence(name) == null)\n\t\t{\n\t\t\tmodel.AddSequence(name).IncrementBy = 10;\n\t\t}\n\t\tproperty.SetValueGenerationStrategy(FbValueGenerationStrategy.HiLo);\n\t\tproperty.SetHiLoSequenceName(name);\n\t\treturn propertyBuilder;\n\t}\n\n\tpublic static PropertyBuilder<TProperty> UseHiLo<TProperty>(this PropertyBuilder<TProperty> propertyBuilder, string name = null)\n\t\t=> (PropertyBuilder<TProperty>)UseHiLo((PropertyBuilder)propertyBuilder, name);\n\n\tpublic static IConventionSequenceBuilder HasHiLoSequence(this IConventionPropertyBuilder propertyBuilder, string name, bool fromDataAnnotation = false)\n\t{\n\t\tif (!propertyBuilder.CanSetHiLoSequence(name, fromDataAnnotation))\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\tpropertyBuilder.Metadata.SetHiLoSequenceName(name, fromDataAnnotation);\n\t\treturn name == null\n\t\t\t? null\n\t\t\t: propertyBuilder.Metadata.DeclaringType.Model.Builder.HasSequence(name, null, fromDataAnnotation);\n\t}\n\n\tpublic static bool CanSetHiLoSequence(this IConventionPropertyBuilder propertyBuilder, string name, bool fromDataAnnotation = false)\n\t{\n\t\treturn propertyBuilder.CanSetAnnotation(FbAnnotationNames.HiLoSequenceName, name, fromDataAnnotation);\n\t}\n\n\tpublic static IConventionPropertyBuilder HasValueGenerationStrategy(this IConventionPropertyBuilder propertyBuilder, FbValueGenerationStrategy? valueGenerationStrategy, bool fromDataAnnotation = false)\n\t{\n\t\tif (propertyBuilder.CanSetAnnotation(FbAnnotationNames.ValueGenerationStrategy, valueGenerationStrategy, fromDataAnnotation))\n\t\t{\n\t\t\tpropertyBuilder.Metadata.SetValueGenerationStrategy(valueGenerationStrategy, fromDataAnnotation);\n\t\t\tif (valueGenerationStrategy != FbValueGenerationStrategy.IdentityColumn)\n\t\t\t{\n\t\t\t}\n\t\t\tif (valueGenerationStrategy != FbValueGenerationStrategy.SequenceTrigger)\n\t\t\t{\n\t\t\t}\n\t\t\tif (valueGenerationStrategy != FbValueGenerationStrategy.HiLo)\n\t\t\t{\n\t\t\t}\n\t\t\treturn propertyBuilder;\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Extensions/FbPropertyExtensions.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Internal;\nusing Microsoft.EntityFrameworkCore.Metadata;\n\nnamespace Microsoft.EntityFrameworkCore;\n\npublic static class FbPropertyExtensions\n{\n\tpublic static FbValueGenerationStrategy GetValueGenerationStrategy(this IProperty property)\n\t{\n\t\tvar annotation = property[FbAnnotationNames.ValueGenerationStrategy];\n\t\tif (annotation != null)\n\t\t{\n\t\t\treturn (FbValueGenerationStrategy)annotation;\n\t\t}\n\n\t\tif (property.ValueGenerated != ValueGenerated.OnAdd\n\t\t\t|| property.IsForeignKey()\n\t\t\t|| property.TryGetDefaultValue(out _)\n\t\t\t|| property.GetDefaultValueSql() != null\n\t\t\t|| property.GetComputedColumnSql() != null)\n\t\t{\n\t\t\treturn FbValueGenerationStrategy.None;\n\t\t}\n\n\t\tvar modelStrategy = property.DeclaringType.Model.GetValueGenerationStrategy();\n\n\t\tif (modelStrategy == FbValueGenerationStrategy.SequenceTrigger && IsCompatibleSequenceTrigger(property))\n\t\t{\n\t\t\treturn FbValueGenerationStrategy.SequenceTrigger;\n\t\t}\n\t\tif (modelStrategy == FbValueGenerationStrategy.IdentityColumn)\n\t\t{\n\t\t\tif (property.DeclaringType.GetMappingStrategy() == RelationalAnnotationNames.TpcMappingStrategy)\n\t\t\t{\n\t\t\t\treturn FbValueGenerationStrategy.SequenceTrigger;\n\t\t\t}\n\t\t\telse if (IsCompatibleIdentityColumn(property))\n\t\t\t{\n\t\t\t\treturn FbValueGenerationStrategy.IdentityColumn;\n\t\t\t}\n\t\t}\n\t\tif (modelStrategy == FbValueGenerationStrategy.HiLo && IsCompatibleHiLoColumn(property))\n\t\t{\n\t\t\treturn FbValueGenerationStrategy.HiLo;\n\t\t}\n\n\t\treturn FbValueGenerationStrategy.None;\n\t}\n\n\tpublic static FbValueGenerationStrategy GetValueGenerationStrategy(this IMutableProperty property)\n\t{\n\t\tvar annotation = property[FbAnnotationNames.ValueGenerationStrategy];\n\t\tif (annotation != null)\n\t\t{\n\t\t\treturn (FbValueGenerationStrategy)annotation;\n\t\t}\n\n\t\tif (property.ValueGenerated != ValueGenerated.OnAdd\n\t\t\t|| property.IsForeignKey()\n\t\t\t|| property.TryGetDefaultValue(out _)\n\t\t\t|| property.GetDefaultValueSql() != null\n\t\t\t|| property.GetComputedColumnSql() != null)\n\t\t{\n\t\t\treturn FbValueGenerationStrategy.None;\n\t\t}\n\n\t\tvar modelStrategy = property.DeclaringType.Model.GetValueGenerationStrategy();\n\n\t\tif (modelStrategy == FbValueGenerationStrategy.SequenceTrigger && IsCompatibleSequenceTrigger(property))\n\t\t{\n\t\t\treturn FbValueGenerationStrategy.SequenceTrigger;\n\t\t}\n\t\tif (modelStrategy == FbValueGenerationStrategy.IdentityColumn)\n\t\t{\n\t\t\tif (property.DeclaringType.GetMappingStrategy() == RelationalAnnotationNames.TpcMappingStrategy)\n\t\t\t{\n\t\t\t\treturn FbValueGenerationStrategy.SequenceTrigger;\n\t\t\t}\n\t\t\telse if (IsCompatibleIdentityColumn(property))\n\t\t\t{\n\t\t\t\treturn FbValueGenerationStrategy.IdentityColumn;\n\t\t\t}\n\t\t}\n\t\tif (modelStrategy == FbValueGenerationStrategy.HiLo && IsCompatibleHiLoColumn(property))\n\t\t{\n\t\t\treturn FbValueGenerationStrategy.HiLo;\n\t\t}\n\n\t\treturn FbValueGenerationStrategy.None;\n\t}\n\n\tpublic static FbValueGenerationStrategy GetValueGenerationStrategy(this IConventionProperty property)\n\t{\n\t\tvar annotation = property[FbAnnotationNames.ValueGenerationStrategy];\n\t\tif (annotation != null)\n\t\t{\n\t\t\treturn (FbValueGenerationStrategy)annotation;\n\t\t}\n\n\t\tif (property.ValueGenerated != ValueGenerated.OnAdd\n\t\t\t|| property.IsForeignKey()\n\t\t\t|| property.TryGetDefaultValue(out _)\n\t\t\t|| property.GetDefaultValueSql() != null\n\t\t\t|| property.GetComputedColumnSql() != null)\n\t\t{\n\t\t\treturn FbValueGenerationStrategy.None;\n\t\t}\n\n\t\tvar modelStrategy = property.DeclaringType.Model.GetValueGenerationStrategy();\n\n\t\tif (modelStrategy == FbValueGenerationStrategy.SequenceTrigger && IsCompatibleSequenceTrigger(property))\n\t\t{\n\t\t\treturn FbValueGenerationStrategy.SequenceTrigger;\n\t\t}\n\t\tif (modelStrategy == FbValueGenerationStrategy.IdentityColumn)\n\t\t{\n\t\t\tif (property.DeclaringType.GetMappingStrategy() == RelationalAnnotationNames.TpcMappingStrategy)\n\t\t\t{\n\t\t\t\treturn FbValueGenerationStrategy.SequenceTrigger;\n\t\t\t}\n\t\t\telse if (IsCompatibleIdentityColumn(property))\n\t\t\t{\n\t\t\t\treturn FbValueGenerationStrategy.IdentityColumn;\n\t\t\t}\n\t\t}\n\t\tif (modelStrategy == FbValueGenerationStrategy.HiLo && IsCompatibleHiLoColumn(property))\n\t\t{\n\t\t\treturn FbValueGenerationStrategy.HiLo;\n\t\t}\n\n\t\treturn FbValueGenerationStrategy.None;\n\t}\n\n\tpublic static ConfigurationSource? GetValueGenerationStrategyConfigurationSource(this IConventionProperty property)\n\t{\n\t\treturn property.FindAnnotation(FbAnnotationNames.ValueGenerationStrategy)?.GetConfigurationSource();\n\t}\n\n\tpublic static void SetValueGenerationStrategy(this IMutableProperty property, FbValueGenerationStrategy? value)\n\t{\n\t\tCheckValueGenerationStrategy(property, value);\n\t\tproperty.SetOrRemoveAnnotation(FbAnnotationNames.ValueGenerationStrategy, value);\n\t}\n\n\tpublic static void SetValueGenerationStrategy(this IConventionProperty property, FbValueGenerationStrategy? value, bool fromDataAnnotation = false)\n\t{\n\t\tCheckValueGenerationStrategy(property, value);\n\t\tproperty.SetOrRemoveAnnotation(FbAnnotationNames.ValueGenerationStrategy, value, fromDataAnnotation);\n\t}\n\n\tpublic static string GetHiLoSequenceName(this IReadOnlyProperty property)\n\t{\n\t\treturn (string)property[FbAnnotationNames.HiLoSequenceName];\n\t}\n\n\tpublic static string GetHiLoSequenceName(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject)\n\t{\n\t\tvar annotation = property.FindAnnotation(FbAnnotationNames.HiLoSequenceName);\n\t\tif (annotation != null)\n\t\t{\n\t\t\treturn (string)annotation.Value;\n\t\t}\n\n\t\treturn property.FindSharedStoreObjectRootProperty(storeObject)?.GetHiLoSequenceName(storeObject);\n\t}\n\n\tpublic static void SetHiLoSequenceName(this IMutableProperty property, string name)\n\t{\n\t\tproperty.SetOrRemoveAnnotation(FbAnnotationNames.HiLoSequenceName, name);\n\t}\n\n\tpublic static string SetHiLoSequenceName(this IConventionProperty property, string name, bool fromDataAnnotation = false)\n\t{\n\t\treturn (string)property.SetOrRemoveAnnotation(FbAnnotationNames.HiLoSequenceName, name, fromDataAnnotation)?.Value;\n\t}\n\n\tpublic static ConfigurationSource? GetHiLoSequenceNameConfigurationSource(this IConventionProperty property)\n\t{\n\t\treturn property.FindAnnotation(FbAnnotationNames.HiLoSequenceName)?.GetConfigurationSource();\n\t}\n\n\tpublic static string GetHiLoSequenceSchema(this IReadOnlyProperty property)\n\t{\n\t\treturn (string)property[FbAnnotationNames.HiLoSequenceSchema];\n\t}\n\n\tpublic static string GetHiLoSequenceSchema(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject)\n\t{\n\t\tvar annotation = property.FindAnnotation(FbAnnotationNames.HiLoSequenceSchema);\n\t\tif (annotation != null)\n\t\t{\n\t\t\treturn (string)annotation.Value;\n\t\t}\n\n\t\treturn property.FindSharedStoreObjectRootProperty(storeObject)?.GetHiLoSequenceSchema(storeObject);\n\t}\n\n\tpublic static void SetHiLoSequenceSchema(this IMutableProperty property, string schema)\n\t{\n\t\tproperty.SetOrRemoveAnnotation(FbAnnotationNames.HiLoSequenceSchema, schema);\n\t}\n\n\tpublic static string SetHiLoSequenceSchema(this IConventionProperty property, string schema, bool fromDataAnnotation = false)\n\t{\n\t\treturn (string)property.SetOrRemoveAnnotation(FbAnnotationNames.HiLoSequenceSchema, schema, fromDataAnnotation)?.Value;\n\t}\n\n\tpublic static ConfigurationSource? GetHiLoSequenceSchemaConfigurationSource(this IConventionProperty property)\n\t{\n\t\treturn property.FindAnnotation(FbAnnotationNames.HiLoSequenceSchema)?.GetConfigurationSource();\n\t}\n\n\tpublic static IReadOnlySequence FindHiLoSequence(this IReadOnlyProperty property)\n\t{\n\t\tvar model = property.DeclaringType.Model;\n\n\t\tvar sequenceName = property.GetHiLoSequenceName()\n\t\t\t?? model.GetHiLoSequenceName();\n\n\t\tvar sequenceSchema = property.GetHiLoSequenceSchema()\n\t\t\t?? model.GetHiLoSequenceSchema();\n\n\t\treturn model.FindSequence(sequenceName, sequenceSchema);\n\t}\n\n\tpublic static IReadOnlySequence FindHiLoSequence(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject)\n\t{\n\t\tvar model = property.DeclaringType.Model;\n\n\t\tvar sequenceName = property.GetHiLoSequenceName(storeObject)\n\t\t\t?? model.GetHiLoSequenceName();\n\n\t\tvar sequenceSchema = property.GetHiLoSequenceSchema(storeObject)\n\t\t\t?? model.GetHiLoSequenceSchema();\n\n\t\treturn model.FindSequence(sequenceName, sequenceSchema);\n\t}\n\n\tpublic static ISequence FindHiLoSequence(this IProperty property)\n\t{\n\t\treturn (ISequence)((IReadOnlyProperty)property).FindHiLoSequence();\n\t}\n\n\tpublic static ISequence FindHiLoSequence(this IProperty property, in StoreObjectIdentifier storeObject)\n\t{\n\t\treturn (ISequence)((IReadOnlyProperty)property).FindHiLoSequence(storeObject);\n\t}\n\n\tpublic static string GetSequenceName(this IReadOnlyProperty property)\n\t{\n\t\treturn (string)property[FbAnnotationNames.SequenceName];\n\t}\n\n\tpublic static string GetSequenceName(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject)\n\t{\n\t\tvar annotation = property.FindAnnotation(FbAnnotationNames.SequenceName);\n\t\tif (annotation != null)\n\t\t{\n\t\t\treturn (string)annotation.Value;\n\t\t}\n\n\t\treturn property.FindSharedStoreObjectRootProperty(storeObject)?.GetSequenceName(storeObject);\n\t}\n\n\tpublic static void SetSequenceName(this IMutableProperty property, string name)\n\t{\n\t\tproperty.SetOrRemoveAnnotation(FbAnnotationNames.SequenceName, name);\n\t}\n\n\tpublic static string SetSequenceName(this IConventionProperty property, string name, bool fromDataAnnotation = false)\n\t{\n\t\treturn (string)property.SetOrRemoveAnnotation(FbAnnotationNames.SequenceName, name, fromDataAnnotation)?.Value;\n\t}\n\n\tpublic static ConfigurationSource? GetSequenceNameConfigurationSource(this IConventionProperty property)\n\t{\n\t\treturn property.FindAnnotation(FbAnnotationNames.SequenceName)?.GetConfigurationSource();\n\t}\n\n\tpublic static string GetSequenceSchema(this IReadOnlyProperty property)\n\t{\n\t\treturn (string)property[FbAnnotationNames.SequenceSchema];\n\t}\n\n\tpublic static string GetSequenceSchema(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject)\n\t{\n\t\tvar annotation = property.FindAnnotation(FbAnnotationNames.SequenceSchema);\n\t\tif (annotation != null)\n\t\t{\n\t\t\treturn (string)annotation.Value;\n\t\t}\n\n\t\treturn property.FindSharedStoreObjectRootProperty(storeObject)?.GetSequenceSchema(storeObject);\n\t}\n\n\tpublic static void SetSequenceSchema(this IMutableProperty property, string schema)\n\t{\n\t\tproperty.SetOrRemoveAnnotation(FbAnnotationNames.SequenceSchema, schema);\n\t}\n\n\tpublic static string SetSequenceSchema(this IConventionProperty property, string schema, bool fromDataAnnotation = false)\n\t{\n\t\treturn (string)property.SetOrRemoveAnnotation(FbAnnotationNames.SequenceSchema, schema, fromDataAnnotation)?.Value;\n\t}\n\n\tpublic static ConfigurationSource? GetSequenceSchemaConfigurationSource(this IConventionProperty property)\n\t{\n\t\treturn property.FindAnnotation(FbAnnotationNames.SequenceSchema)?.GetConfigurationSource();\n\t}\n\n\tpublic static IReadOnlySequence FindSequence(this IReadOnlyProperty property)\n\t{\n\t\tvar model = property.DeclaringType.Model;\n\n\t\tvar sequenceName = property.GetSequenceName()\n\t\t\t?? model.GetSequenceNameSuffix();\n\n\t\tvar sequenceSchema = property.GetSequenceSchema()\n\t\t\t?? model.GetSequenceSchema();\n\n\t\treturn model.FindSequence(sequenceName, sequenceSchema);\n\t}\n\n\tpublic static IReadOnlySequence FindSequence(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject)\n\t{\n\t\tvar model = property.DeclaringType.Model;\n\n\t\tvar sequenceName = property.GetSequenceName(storeObject)\n\t\t\t?? model.GetSequenceNameSuffix();\n\n\t\tvar sequenceSchema = property.GetSequenceSchema(storeObject)\n\t\t\t?? model.GetSequenceSchema();\n\n\t\treturn model.FindSequence(sequenceName, sequenceSchema);\n\t}\n\n\tpublic static ISequence FindSequence(this IProperty property)\n\t{\n\t\treturn (ISequence)((IReadOnlyProperty)property).FindSequence();\n\t}\n\n\tpublic static ISequence FindSequence(this IProperty property, in StoreObjectIdentifier storeObject)\n\t{\n\t\treturn (ISequence)((IReadOnlyProperty)property).FindSequence(storeObject);\n\t}\n\n\tstatic void CheckValueGenerationStrategy(IReadOnlyPropertyBase property, FbValueGenerationStrategy? value)\n\t{\n\t\tif (value != null)\n\t\t{\n\t\t\tif (value == FbValueGenerationStrategy.IdentityColumn && !IsCompatibleIdentityColumn(property))\n\t\t\t{\n\t\t\t\tthrow new ArgumentException($\"Incompatible data type for {nameof(FbValueGenerationStrategy.IdentityColumn)} for '{property.Name}'.\");\n\t\t\t}\n\t\t\tif (value == FbValueGenerationStrategy.SequenceTrigger && !IsCompatibleSequenceTrigger(property))\n\t\t\t{\n\t\t\t\tthrow new ArgumentException($\"Incompatible data type for {nameof(FbValueGenerationStrategy.SequenceTrigger)} for '{property.Name}'.\");\n\t\t\t}\n\t\t\tif (value == FbValueGenerationStrategy.HiLo && !IsCompatibleHiLoColumn(property))\n\t\t\t{\n\t\t\t\tthrow new ArgumentException($\"Incompatible data type for {nameof(FbValueGenerationStrategy.HiLo)} for '{property.Name}'.\");\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic bool IsCompatibleIdentityColumn(IReadOnlyPropertyBase property)\n\t{\n\t\treturn property.ClrType.IsInteger() || property.ClrType == typeof(decimal);\n\t}\n\n\tstatic bool IsCompatibleSequenceTrigger(IReadOnlyPropertyBase property)\n\t{\n\t\treturn true;\n\t}\n\n\tstatic bool IsCompatibleHiLoColumn(IReadOnlyPropertyBase property)\n\t{\n\t\treturn property.ClrType.IsInteger() || property.ClrType == typeof(decimal);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Extensions/FbServiceCollectionExtensions.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.EntityFrameworkCore.Firebird;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Diagnostics.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Conventions;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Migrations;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Migrations.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Update.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.ValueGeneration.Internal;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\nusing Microsoft.EntityFrameworkCore.Metadata;\nusing Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;\nusing Microsoft.EntityFrameworkCore.Migrations;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Storage;\nusing Microsoft.EntityFrameworkCore.Update;\nusing Microsoft.EntityFrameworkCore.ValueGeneration;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace Microsoft.EntityFrameworkCore;\n\npublic static class FbServiceCollectionExtensions\n{\n\tpublic static IServiceCollection AddFirebird<TContext>(this IServiceCollection serviceCollection, string connectionString, Action<FbDbContextOptionsBuilder> fbOptionsAction = null, Action<DbContextOptionsBuilder> optionsAction = null)\n\t\twhere TContext : DbContext\n\t{\n\t\treturn serviceCollection.AddDbContext<TContext>(\n\t\t\t(serviceProvider, options) =>\n\t\t\t{\n\t\t\t\toptionsAction?.Invoke(options);\n\t\t\t\toptions.UseFirebird(connectionString, fbOptionsAction);\n\t\t\t});\n\t}\n\n\tpublic static IServiceCollection AddEntityFrameworkFirebird(this IServiceCollection serviceCollection)\n\t{\n\t\tvar builder = new EntityFrameworkRelationalServicesBuilder(serviceCollection)\n\t\t\t.TryAdd<LoggingDefinitions, FbLoggingDefinitions>()\n\t\t\t.TryAdd<IDatabaseProvider, DatabaseProvider<FbOptionsExtension>>()\n\t\t\t.TryAdd<IValueGeneratorCache>(p => p.GetRequiredService<IFbValueGeneratorCache>())\n\t\t\t.TryAdd<IRelationalDatabaseCreator, FbDatabaseCreator>()\n\t\t\t.TryAdd<IRelationalTypeMappingSource, FbTypeMappingSource>()\n\t\t\t.TryAdd<ISqlGenerationHelper, FbSqlGenerationHelper>()\n\t\t\t.TryAdd<IRelationalAnnotationProvider, FbRelationalAnnotationProvider>()\n\t\t\t.TryAdd<IModelValidator, FbModelValidator>()\n\t\t\t.TryAdd<IProviderConventionSetBuilder, FbConventionSetBuilder>()\n\t\t\t.TryAdd<IUpdateSqlGenerator>(p => p.GetService<IFbUpdateSqlGenerator>())\n\t\t\t.TryAdd<IModificationCommandBatchFactory, FbModificationCommandBatchFactory>()\n\t\t\t.TryAdd<IValueGeneratorSelector, FbValueGeneratorSelector>()\n\t\t\t.TryAdd<IRelationalConnection>(p => p.GetService<IFbRelationalConnection>())\n\t\t\t.TryAdd<IRelationalTransactionFactory, FbTransactionFactory>()\n\t\t\t.TryAdd<IMigrationsSqlGenerator, FbMigrationsSqlGenerator>()\n\t\t\t.TryAdd<IHistoryRepository, FbHistoryRepository>()\n\t\t\t.TryAdd<IMemberTranslatorProvider, FbMemberTranslatorProvider>()\n\t\t\t.TryAdd<IMethodCallTranslatorProvider, FbMethodCallTranslatorProvider>()\n\t\t\t.TryAdd<IQuerySqlGeneratorFactory, FbQuerySqlGeneratorFactory>()\n\t\t\t.TryAdd<IQueryTranslationPreprocessorFactory, FbQueryTranslationPreprocessorFactory>()\n\t\t\t.TryAdd<ISqlExpressionFactory, FbSqlExpressionFactory>()\n\t\t\t.TryAdd<ISingletonOptions, IFbOptions>(p => p.GetService<IFbOptions>())\n\t\t\t.TryAdd<IRelationalSqlTranslatingExpressionVisitorFactory, FbSqlTranslatingExpressionVisitorFactory>()\n\t\t\t.TryAddProviderSpecificServices(b => b\n\t\t\t\t.TryAddSingleton<IFbOptions, FbOptions>()\n\t\t\t\t.TryAddSingleton<IFbMigrationSqlGeneratorBehavior, FbMigrationSqlGeneratorBehavior>()\n\t\t\t\t.TryAddSingleton<IFbUpdateSqlGenerator, FbUpdateSqlGenerator>()\n\t\t\t\t.TryAddSingleton<IFbValueGeneratorCache, FbValueGeneratorCache>()\n\t\t\t\t.TryAddSingleton<IFbSequenceValueGeneratorFactory, FbSequenceValueGeneratorFactory>()\n\t\t\t\t.TryAddScoped<IFbRelationalConnection, FbRelationalConnection>()\n\t\t\t\t.TryAddScoped<IFbRelationalTransaction, FbRelationalTransaction>());\n\n\t\tbuilder.TryAddCoreServices();\n\n\t\treturn serviceCollection;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/FirebirdSql.EntityFrameworkCore.Firebird.csproj",
    "content": "﻿<Project Sdk=\"Microsoft.NET.Sdk\">\n\t<PropertyGroup>\n\t\t<TargetFrameworks>net10.0</TargetFrameworks>\n\t\t<AssemblyName>FirebirdSql.EntityFrameworkCore.Firebird</AssemblyName>\n\t\t<RootNamespace>FirebirdSql.EntityFrameworkCore.Firebird</RootNamespace>\n\t\t<SignAssembly>true</SignAssembly>\n\t\t<AssemblyOriginatorKeyFile>Properties\\FirebirdSql.EntityFrameworkCore.Firebird.snk</AssemblyOriginatorKeyFile>\n\t\t<GenerateAssemblyInfo>true</GenerateAssemblyInfo>\n\t\t<GeneratePackageOnBuild>true</GeneratePackageOnBuild>\n\t</PropertyGroup>\n\t<PropertyGroup>\n\t\t<Version>$(EFCoreProviderVersion)</Version>\n\t\t<AssemblyTitle>NETProvider - Entity Framework Core Provider</AssemblyTitle>\n\t\t<Copyright>(c) 2017-$(CopyrightEndYear)</Copyright>\n\t</PropertyGroup>\n\t<PropertyGroup>\n\t\t<PackageId>FirebirdSql.EntityFrameworkCore.Firebird</PackageId>\n\t\t<Title>Firebird Entity Framework Core Provider</Title>\n\t\t<PackageDescription>The Entity Framework Core provider for Firebird enables you to develop .NET applications that connect to the Firebird database using Entity Framework Core.</PackageDescription>\n\t\t<PackageTags>firebird firebirsql firebirdclient entityframeworkcore adonet database</PackageTags>\n\t</PropertyGroup>\n\t<PropertyGroup Condition=\"'$(Configuration)'=='Release'\">\n\t\t<DefineConstants>EFCORE;TRACE</DefineConstants>\n\t</PropertyGroup>\n\t<PropertyGroup Condition=\"'$(Configuration)'=='Debug'\">\n\t\t<DefineConstants>EFCORE;DEBUG;TRACE</DefineConstants>\n\t</PropertyGroup>\n\t<ItemGroup>\n\t\t<None Include=\"..\\..\\license.txt\" Pack=\"true\" PackagePath=\"\" />\n\t\t<None Include=\"..\\..\\firebird-logo.png\" Pack=\"true\" PackagePath=\"\" />\n\t</ItemGroup>\n\t<ItemGroup>\n\t\t<PackageReference Include=\"Microsoft.EntityFrameworkCore.Relational\" Version=\"$(EFCoreReferencePackageVersion)\" />\n\t</ItemGroup>\n\t<ItemGroup Condition=\"'$(Configuration)'!='Debug'\">\n\t\t<PackageReference Include=\"FirebirdSql.Data.FirebirdClient\" Version=\"$(EFCoreReferenceProviderVersion)\" />\n\t</ItemGroup>\n\t<ItemGroup Condition=\"'$(Configuration)'=='Debug'\">\n\t\t<ProjectReference Include=\"..\\FirebirdSql.Data.FirebirdClient\\FirebirdSql.Data.FirebirdClient.csproj\" />\n\t</ItemGroup>\n</Project>\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Infrastructure/FbDbContextOptionsBuilder.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure;\n\npublic class FbDbContextOptionsBuilder : RelationalDbContextOptionsBuilder<FbDbContextOptionsBuilder, FbOptionsExtension>\n{\n\tpublic FbDbContextOptionsBuilder(DbContextOptionsBuilder optionsBuilder)\n\t\t: base(optionsBuilder)\n\t{ }\n\n\tpublic virtual FbDbContextOptionsBuilder WithExplicitParameterTypes(bool explicitParameterTypes = true)\n\t\t=> WithOption(e => e.WithExplicitParameterTypes(explicitParameterTypes));\n\n\tpublic virtual FbDbContextOptionsBuilder WithExplicitStringLiteralTypes(bool explicitStringLiteralTypes = true)\n\t\t=> WithOption(e => e.WithExplicitStringLiteralTypes(explicitStringLiteralTypes));\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Infrastructure/Internal/FbModelValidator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Linq;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\nusing Microsoft.EntityFrameworkCore.Metadata;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure.Internal;\n\npublic class FbModelValidator : RelationalModelValidator\n{\n\tpublic FbModelValidator(ModelValidatorDependencies dependencies, RelationalModelValidatorDependencies relationalDependencies)\n\t\t: base(dependencies, relationalDependencies)\n\t{ }\n\n\tprotected override void ValidateValueGeneration(IEntityType entityType, IKey key, IDiagnosticsLogger<DbLoggerCategory.Model.Validation> logger)\n\t{\n\t\tif (entityType.GetMappingStrategy() == RelationalAnnotationNames.TpcMappingStrategy && entityType.BaseType == null)\n\t\t{\n\t\t\tforeach (var storeGeneratedProperty in key.Properties.Where(p => (p.ValueGenerated & ValueGenerated.OnAdd) != 0 && p.GetValueGenerationStrategy() == FbValueGenerationStrategy.IdentityColumn))\n\t\t\t{\n\t\t\t\tlogger.TpcStoreGeneratedIdentityWarning(storeGeneratedProperty);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Infrastructure/Internal/FbOptionsExtension.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure.Internal;\n\npublic class FbOptionsExtension : RelationalOptionsExtension\n{\n\tDbContextOptionsExtensionInfo _info;\n\tbool? _explicitParameterTypes;\n\tbool? _explicitStringLiteralTypes;\n\n\tpublic FbOptionsExtension()\n\t{ }\n\n\tpublic FbOptionsExtension(FbOptionsExtension copyFrom)\n\t\t: base(copyFrom)\n\t{\n\t\t_explicitParameterTypes = copyFrom._explicitParameterTypes;\n\t\t_explicitStringLiteralTypes = copyFrom._explicitStringLiteralTypes;\n\t}\n\n\tprotected override RelationalOptionsExtension Clone()\n\t\t=> new FbOptionsExtension(this);\n\n\tpublic override void ApplyServices(IServiceCollection services)\n\t\t=> services.AddEntityFrameworkFirebird();\n\n\tpublic override DbContextOptionsExtensionInfo Info => _info ??= new ExtensionInfo(this);\n\tpublic virtual bool? ExplicitParameterTypes => _explicitParameterTypes;\n\tpublic virtual bool? ExplicitStringLiteralTypes => _explicitStringLiteralTypes;\n\n\tpublic virtual FbOptionsExtension WithExplicitParameterTypes(bool explicitParameterTypes)\n\t{\n\t\tvar clone = (FbOptionsExtension)Clone();\n\t\tclone._explicitParameterTypes = explicitParameterTypes;\n\t\treturn clone;\n\t}\n\n\tpublic virtual FbOptionsExtension WithExplicitStringLiteralTypes(bool explicitStringLiteralTypes)\n\t{\n\t\tvar clone = (FbOptionsExtension)Clone();\n\t\tclone._explicitStringLiteralTypes = explicitStringLiteralTypes;\n\t\treturn clone;\n\t}\n\n\tsealed class ExtensionInfo : RelationalExtensionInfo\n\t{\n\t\tint? _serviceProviderHash;\n\n\t\tpublic ExtensionInfo(IDbContextOptionsExtension extension)\n\t\t\t: base(extension)\n\t\t{ }\n\n\t\tnew FbOptionsExtension Extension => (FbOptionsExtension)base.Extension;\n\n\t\tpublic override int GetServiceProviderHashCode()\n\t\t{\n\t\t\treturn _serviceProviderHash ??= HashCode.Combine(base.GetServiceProviderHashCode(), Extension._explicitParameterTypes, Extension._explicitStringLiteralTypes);\n\t\t}\n\n\t\tpublic override void PopulateDebugInfo(IDictionary<string, string> debugInfo)\n\t\t{ }\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Infrastructure/Internal/IFbOptions.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Infrastructure;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure.Internal;\n\npublic interface IFbOptions : ISingletonOptions\n{\n\tbool ExplicitParameterTypes { get; }\n\tbool ExplicitStringLiteralTypes { get; }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Internal/FbOptions.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Internal;\n\npublic class FbOptions : IFbOptions\n{\n\tpublic virtual void Initialize(IDbContextOptions options)\n\t{\n\t\tvar fbOptions = options.FindExtension<FbOptionsExtension>() ?? new FbOptionsExtension();\n\n\t\tExplicitParameterTypes = fbOptions.ExplicitParameterTypes ?? true;\n\t\tExplicitStringLiteralTypes = fbOptions.ExplicitStringLiteralTypes ?? true;\n\t}\n\n\tpublic virtual void Validate(IDbContextOptions options)\n\t{\n\t\tvar fbOptions = options.FindExtension<FbOptionsExtension>() ?? new FbOptionsExtension();\n\n\t\tif (ExplicitParameterTypes != (fbOptions.ExplicitParameterTypes ?? true))\n\t\t{\n\t\t\tthrow new InvalidOperationException($\"A call was made to '{nameof(FbDbContextOptionsBuilder.WithExplicitParameterTypes)}' that changed an option that must be constant within a service provider, but Entity Framework is not building its own internal service provider. Either allow EF to build the service provider by removing the call to '{nameof(DbContextOptionsBuilder.UseInternalServiceProvider)}', or ensure that the configuration for '{nameof(FbDbContextOptionsBuilder.WithExplicitParameterTypes)}' does not change for all uses of a given service provider passed to '{nameof(DbContextOptionsBuilder.UseInternalServiceProvider)}'.\");\n\t\t}\n\t\tif (ExplicitStringLiteralTypes != (fbOptions.ExplicitStringLiteralTypes ?? true))\n\t\t{\n\t\t\tthrow new InvalidOperationException($\"A call was made to '{nameof(FbDbContextOptionsBuilder.WithExplicitStringLiteralTypes)}' that changed an option that must be constant within a service provider, but Entity Framework is not building its own internal service provider. Either allow EF to build the service provider by removing the call to '{nameof(DbContextOptionsBuilder.UseInternalServiceProvider)}', or ensure that the configuration for '{nameof(FbDbContextOptionsBuilder.WithExplicitStringLiteralTypes)}' does not change for all uses of a given service provider passed to '{nameof(DbContextOptionsBuilder.UseInternalServiceProvider)}'.\");\n\t\t}\n\t}\n\n\tpublic virtual bool ExplicitParameterTypes { get; private set; }\n\tpublic virtual bool ExplicitStringLiteralTypes { get; private set; }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Metadata/Conventions/FbConventionSetBuilder.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Conventions;\nusing Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Conventions;\n\npublic class FbConventionSetBuilder : RelationalConventionSetBuilder\n{\n\tpublic FbConventionSetBuilder(ProviderConventionSetBuilderDependencies dependencies, RelationalConventionSetBuilderDependencies relationalDependencies)\n\t\t: base(dependencies, relationalDependencies)\n\t{ }\n\n\tpublic override ConventionSet CreateConventionSet()\n\t{\n\t\tvar conventionSet = base.CreateConventionSet();\n\n\t\tconventionSet.Add(new FbValueGenerationStrategyConvention(Dependencies, RelationalDependencies));\n\t\tconventionSet.Add(new RelationalMaxIdentifierLengthConvention(31, Dependencies, RelationalDependencies));\n\n\t\tconventionSet.Replace<StoreGenerationConvention>(new FbStoreGenerationConvention(Dependencies, RelationalDependencies));\n\t\tconventionSet.Replace<ValueGenerationConvention>(new FbValueGenerationConvention(Dependencies, RelationalDependencies));\n\n\t\treturn conventionSet;\n\n\t}\n\n\tpublic static ConventionSet Build()\n\t{\n\t\tvar serviceProvider = new ServiceCollection()\n\t\t\t.AddEntityFrameworkFirebird()\n\t\t\t.AddDbContext<DbContext>(o => o.UseFirebird(\"database=localhost:_.fdb;user=sysdba;password=masterkey;charset=utf8\"))\n\t\t\t.BuildServiceProvider();\n\n\t\tusing (var serviceScope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope())\n\t\t{\n\t\t\tusing (var context = serviceScope.ServiceProvider.GetService<DbContext>())\n\t\t\t{\n\t\t\t\treturn ConventionSet.CreateConventionSet(context);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Metadata/Conventions/FbStoreGenerationConvention.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Metadata;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing Microsoft.EntityFrameworkCore.Metadata.Conventions;\nusing Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Conventions;\n\npublic class FbStoreGenerationConvention : StoreGenerationConvention\n{\n\tpublic FbStoreGenerationConvention(ProviderConventionSetBuilderDependencies dependencies, RelationalConventionSetBuilderDependencies relationalDependencies)\n\t\t: base(dependencies, relationalDependencies)\n\t{ }\n\n\tpublic override void ProcessPropertyAnnotationChanged(IConventionPropertyBuilder propertyBuilder, string name, IConventionAnnotation annotation, IConventionAnnotation oldAnnotation, IConventionContext<IConventionAnnotation> context)\n\t{\n\t\tif (annotation == null\n\t\t\t|| oldAnnotation?.Value != null)\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tvar configurationSource = annotation.GetConfigurationSource();\n\t\tvar fromDataAnnotation = configurationSource != ConfigurationSource.Convention;\n\t\tswitch (name)\n\t\t{\n\t\t\tcase RelationalAnnotationNames.DefaultValue:\n\t\t\t\tif (propertyBuilder.HasValueGenerationStrategy(null, fromDataAnnotation) == null\n\t\t\t\t\t&& propertyBuilder.HasDefaultValue(null, fromDataAnnotation) != null)\n\t\t\t\t{\n\t\t\t\t\tcontext.StopProcessing();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase RelationalAnnotationNames.DefaultValueSql:\n\t\t\t\tif (propertyBuilder.HasValueGenerationStrategy(null, fromDataAnnotation) == null\n\t\t\t\t\t&& propertyBuilder.HasDefaultValueSql(null, fromDataAnnotation) != null)\n\t\t\t\t{\n\t\t\t\t\tcontext.StopProcessing();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase RelationalAnnotationNames.ComputedColumnSql:\n\t\t\t\tif (propertyBuilder.HasValueGenerationStrategy(null, fromDataAnnotation) == null\n\t\t\t\t\t&& propertyBuilder.HasComputedColumnSql(null, fromDataAnnotation) != null)\n\t\t\t\t{\n\t\t\t\t\tcontext.StopProcessing();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\tcase FbAnnotationNames.ValueGenerationStrategy:\n\t\t\t\tif ((propertyBuilder.HasDefaultValue(null, fromDataAnnotation) == null\n\t\t\t\t\t || propertyBuilder.HasDefaultValueSql(null, fromDataAnnotation) == null\n\t\t\t\t\t || propertyBuilder.HasComputedColumnSql(null, fromDataAnnotation) == null)\n\t\t\t\t\t&& propertyBuilder.HasValueGenerationStrategy(null, fromDataAnnotation) != null)\n\t\t\t\t{\n\t\t\t\t\tcontext.StopProcessing();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t}\n\n\t\tbase.ProcessPropertyAnnotationChanged(propertyBuilder, name, annotation, oldAnnotation, context);\n\t}\n\n\tprotected override void Validate(IConventionProperty property, in StoreObjectIdentifier storeObject)\n\t{\n\t\tif (property.GetValueGenerationStrategyConfigurationSource() != null && property.GetValueGenerationStrategy() != FbValueGenerationStrategy.None)\n\t\t{\n\t\t\tif (property.TryGetDefaultValue(storeObject, out _))\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException(RelationalStrings.ConflictingColumnServerGeneration(nameof(FbValueGenerationStrategy), property.Name, \"DefaultValue\"));\n\t\t\t}\n\t\t\tif (property.GetDefaultValueSql() != null)\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException(RelationalStrings.ConflictingColumnServerGeneration(nameof(FbValueGenerationStrategy), property.Name, \"DefaultValueSql\"));\n\t\t\t}\n\t\t\tif (property.GetComputedColumnSql() != null)\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException(RelationalStrings.ConflictingColumnServerGeneration(nameof(FbValueGenerationStrategy), property.Name, \"ComputedColumnSql\"));\n\t\t\t}\n\t\t}\n\t\tbase.Validate(property, storeObject);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Metadata/Conventions/FbValueGenerationConvention.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing Microsoft.EntityFrameworkCore.Metadata.Conventions;\nusing Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Conventions;\n\npublic class FbValueGenerationConvention : RelationalValueGenerationConvention\n{\n\tpublic FbValueGenerationConvention(ProviderConventionSetBuilderDependencies dependencies, RelationalConventionSetBuilderDependencies relationalDependencies)\n\t\t: base(dependencies, relationalDependencies)\n\t{ }\n\n\tpublic override void ProcessPropertyAnnotationChanged(IConventionPropertyBuilder propertyBuilder, string name, IConventionAnnotation annotation, IConventionAnnotation oldAnnotation, IConventionContext<IConventionAnnotation> context)\n\t{\n\t\tif (name == FbAnnotationNames.ValueGenerationStrategy)\n\t\t{\n\t\t\tpropertyBuilder.ValueGenerated(GetValueGenerated(propertyBuilder.Metadata));\n\t\t\treturn;\n\t\t}\n\t\tbase.ProcessPropertyAnnotationChanged(propertyBuilder, name, annotation, oldAnnotation, context);\n\t}\n\n\tprotected override ValueGenerated? GetValueGenerated(IConventionProperty property)\n\t\t=> RelationalValueGenerationConvention.GetValueGenerated(property)\n\t\t\t?? (property.GetValueGenerationStrategy() != FbValueGenerationStrategy.None\n\t\t\t\t? ValueGenerated.OnAdd\n\t\t\t\t: (ValueGenerated?)null);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Metadata/Conventions/FbValueGenerationStrategyConvention.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata.Builders;\nusing Microsoft.EntityFrameworkCore.Metadata.Conventions;\nusing Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Conventions;\n\npublic class FbValueGenerationStrategyConvention : IModelInitializedConvention, IModelFinalizingConvention\n{\n\tpublic FbValueGenerationStrategyConvention(ProviderConventionSetBuilderDependencies dependencies, RelationalConventionSetBuilderDependencies relationalDependencies)\n\t{\n\t\tDependencies = dependencies;\n\t}\n\n\tprotected virtual ProviderConventionSetBuilderDependencies Dependencies { get; }\n\n\tpublic virtual void ProcessModelInitialized(IConventionModelBuilder modelBuilder, IConventionContext<IConventionModelBuilder> context)\n\t{\n\t\tmodelBuilder.HasValueGenerationStrategy(FbValueGenerationStrategy.IdentityColumn);\n\t}\n\n\tpublic void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext<IConventionModelBuilder> context)\n\t{\n\t\tforeach (var entityType in modelBuilder.Metadata.GetEntityTypes())\n\t\t{\n\t\t\tforeach (var property in entityType.GetDeclaredProperties())\n\t\t\t{\n\t\t\t\t// Needed for the annotation to show up in the model snapshot\n\t\t\t\tvar strategy = property.GetValueGenerationStrategy();\n\t\t\t\tif (strategy != FbValueGenerationStrategy.None)\n\t\t\t\t{\n\t\t\t\t\tproperty.Builder.HasValueGenerationStrategy(strategy);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Metadata/FbIdentityType.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Metadata;\n\npublic enum FbIdentityType\n{\n\tGeneratedAlways = 0,\n\tGeneratedByDefault = 1,\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Metadata/FbValueGenerationStrategy.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net), Jean Ressouche, Rafael Almeida (ralms@ralms.net)\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Metadata;\n\npublic enum FbValueGenerationStrategy\n{\n\tNone,\n\tSequenceTrigger,\n\tIdentityColumn,\n\tHiLo,\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Metadata/Internal/FbAnnotationNames.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net), Jean Ressouche, Rafael Almeida (ralms@ralms.net)\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Internal;\n\npublic static class FbAnnotationNames\n{\n\tpublic const string Prefix = \"Fb:\";\n\tpublic const string ValueGenerationStrategy = Prefix + nameof(ValueGenerationStrategy);\n\tpublic const string HiLoSequenceName = Prefix + nameof(HiLoSequenceName);\n\tpublic const string HiLoSequenceSchema = Prefix + nameof(HiLoSequenceSchema);\n\tpublic const string SequenceName = Prefix + nameof(SequenceName);\n\tpublic const string SequenceSchema = Prefix + nameof(SequenceSchema);\n\tpublic const string SequenceNameSuffix = Prefix + nameof(SequenceNameSuffix);\n\n\tpublic const string BlobSegmentSize = Prefix + nameof(BlobSegmentSize);\n\tpublic const string CharacterSet = Prefix + nameof(CharacterSet);\n\tpublic const string DomainName = Prefix + nameof(DomainName);\n\n\tpublic const string IdentityType = Prefix + nameof(IdentityType);\n\tpublic const string IdentityStart = Prefix + nameof(IdentityStart);\n\tpublic const string IdentityIncrement = Prefix + nameof(IdentityIncrement);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Metadata/Internal/FbRelationalAnnotationProvider.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Linq;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\nusing Microsoft.EntityFrameworkCore.Metadata;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Internal;\n\npublic class FbRelationalAnnotationProvider : RelationalAnnotationProvider\n{\n#pragma warning disable EF1001\n\tpublic FbRelationalAnnotationProvider(RelationalAnnotationProviderDependencies dependencies)\n#pragma warning restore EF1001\n\t\t\t: base(dependencies)\n\t{ }\n\n\tpublic override IEnumerable<IAnnotation> For(IColumn column, bool designTime)\n\t{\n\t\tif (!designTime)\n\t\t{\n\t\t\tyield break;\n\t\t}\n\n\t\tvar property = column.PropertyMappings.Select(x => x.Property)\n\t\t\t.FirstOrDefault(x => x.GetValueGenerationStrategy() != FbValueGenerationStrategy.None);\n\t\tif (property != null)\n\t\t{\n\t\t\tvar valueGenerationStrategy = property.GetValueGenerationStrategy();\n\t\t\tif (valueGenerationStrategy != FbValueGenerationStrategy.None)\n\t\t\t{\n\t\t\t\tyield return new Annotation(FbAnnotationNames.ValueGenerationStrategy, valueGenerationStrategy);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Migrations/FbMigrationSqlGeneratorBehavior.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\nusing Microsoft.EntityFrameworkCore.Migrations;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Migrations;\n\npublic class FbMigrationSqlGeneratorBehavior : IFbMigrationSqlGeneratorBehavior\n{\n\treadonly ISqlGenerationHelper _sqlGenerationHelper;\n\n\tpublic FbMigrationSqlGeneratorBehavior(ISqlGenerationHelper sqlGenerationHelper)\n\t{\n\t\t_sqlGenerationHelper = sqlGenerationHelper;\n\t}\n\n\tpublic virtual void CreateSequenceTriggerForColumn(string columnName, string tableName, string schemaName, MigrationsSqlGenerationOptions options, MigrationCommandListBuilder builder)\n\t{\n\t\tvar identitySequenceName = CreateSequenceTriggerSequenceName(columnName, tableName, schemaName);\n\n\t\tif (options.HasFlag(MigrationsSqlGenerationOptions.Script))\n\t\t{\n\t\t\tbuilder.Append(\"SET TERM \");\n\t\t\tbuilder.Append(((IFbSqlGenerationHelper)_sqlGenerationHelper).AlternativeStatementTerminator);\n\t\t\tbuilder.AppendLine(_sqlGenerationHelper.StatementTerminator);\n\t\t\tbuilder.EndCommand();\n\t\t}\n\n\t\tbuilder.AppendLine(\"EXECUTE BLOCK\");\n\t\tbuilder.AppendLine(\"AS\");\n\t\tbuilder.AppendLine(\"BEGIN\");\n\t\tbuilder.IncrementIndent();\n\t\tbuilder.Append(\"if (not exists(select 1 from rdb$generators where rdb$generator_name = '\");\n\t\tbuilder.Append(identitySequenceName);\n\t\tbuilder.Append(\"')) then\");\n\t\tbuilder.AppendLine();\n\t\tbuilder.AppendLine(\"begin\");\n\t\tbuilder.IncrementIndent();\n\t\tbuilder.Append(\"execute statement 'create sequence \");\n\t\tbuilder.Append(identitySequenceName);\n\t\tbuilder.Append(\"'\");\n\t\tbuilder.Append(_sqlGenerationHelper.StatementTerminator);\n\t\tbuilder.AppendLine();\n\t\tbuilder.DecrementIndent();\n\t\tbuilder.AppendLine(\"end\");\n\t\tbuilder.DecrementIndent();\n\t\tbuilder.Append(\"END\");\n\t\tbuilder.AppendLine();\n\t\tif (options.HasFlag(MigrationsSqlGenerationOptions.Script))\n\t\t{\n\t\t\tbuilder.AppendLine(((IFbSqlGenerationHelper)_sqlGenerationHelper).AlternativeStatementTerminator);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tbuilder.AppendLine(_sqlGenerationHelper.StatementTerminator);\n\t\t}\n\t\tbuilder.EndCommand();\n\n\t\tbuilder.Append(\"CREATE TRIGGER \");\n\t\tbuilder.Append(_sqlGenerationHelper.DelimitIdentifier(CreateSequenceTriggerName(columnName, tableName, schemaName)));\n\t\tbuilder.Append(\" ACTIVE BEFORE INSERT ON \");\n\t\tbuilder.Append(_sqlGenerationHelper.DelimitIdentifier(tableName, schemaName));\n\t\tbuilder.AppendLine();\n\t\tbuilder.AppendLine(\"AS\");\n\t\tbuilder.AppendLine(\"BEGIN\");\n\t\tbuilder.IncrementIndent();\n\t\tbuilder.Append(\"if (new.\");\n\t\tbuilder.Append(_sqlGenerationHelper.DelimitIdentifier(columnName));\n\t\tbuilder.Append(\" is null) then\");\n\t\tbuilder.AppendLine();\n\t\tbuilder.AppendLine(\"begin\");\n\t\tbuilder.IncrementIndent();\n\t\tbuilder.Append(\"new.\");\n\t\tbuilder.Append(_sqlGenerationHelper.DelimitIdentifier(columnName));\n\t\tbuilder.Append(\" = next value for \");\n\t\tbuilder.Append(identitySequenceName);\n\t\tbuilder.Append(_sqlGenerationHelper.StatementTerminator);\n\t\tbuilder.AppendLine();\n\t\tbuilder.DecrementIndent();\n\t\tbuilder.AppendLine(\"end\");\n\t\tbuilder.DecrementIndent();\n\t\tbuilder.Append(\"END\");\n\t\tbuilder.AppendLine();\n\t\tif (options.HasFlag(MigrationsSqlGenerationOptions.Script))\n\t\t{\n\t\t\tbuilder.AppendLine(((IFbSqlGenerationHelper)_sqlGenerationHelper).AlternativeStatementTerminator);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tbuilder.AppendLine(_sqlGenerationHelper.StatementTerminator);\n\t\t}\n\t\tbuilder.EndCommand();\n\n\t\tif (options.HasFlag(MigrationsSqlGenerationOptions.Script))\n\t\t{\n\t\t\tbuilder.Append(\"SET TERM \");\n\t\t\tbuilder.Append(_sqlGenerationHelper.StatementTerminator);\n\t\t\tbuilder.AppendLine(((IFbSqlGenerationHelper)_sqlGenerationHelper).AlternativeStatementTerminator);\n\t\t\tbuilder.EndCommand();\n\t\t}\n\t}\n\n\tpublic virtual void DropSequenceTriggerForColumn(string columnName, string tableName, string schemaName, MigrationsSqlGenerationOptions options, MigrationCommandListBuilder builder)\n\t{\n\t\tvar triggerName = CreateSequenceTriggerName(columnName, tableName, schemaName);\n\n\t\tif (options.HasFlag(MigrationsSqlGenerationOptions.Script))\n\t\t{\n\t\t\tbuilder.Append(\"SET TERM \");\n\t\t\tbuilder.Append(((IFbSqlGenerationHelper)_sqlGenerationHelper).AlternativeStatementTerminator);\n\t\t\tbuilder.AppendLine(_sqlGenerationHelper.StatementTerminator);\n\t\t\tbuilder.EndCommand();\n\t\t}\n\n\t\tbuilder.AppendLine(\"EXECUTE BLOCK\");\n\t\tbuilder.AppendLine(\"AS\");\n\t\tbuilder.AppendLine(\"BEGIN\");\n\t\tbuilder.IncrementIndent();\n\t\tbuilder.Append(\"if (exists(select 1 from rdb$triggers where rdb$trigger_name = '\");\n\t\tbuilder.Append(triggerName);\n\t\tbuilder.Append(\"')) then\");\n\t\tbuilder.AppendLine();\n\t\tbuilder.AppendLine(\"begin\");\n\t\tbuilder.IncrementIndent();\n\t\tbuilder.Append(\"execute statement 'drop trigger \");\n\t\tbuilder.Append(_sqlGenerationHelper.DelimitIdentifier(triggerName));\n\t\tbuilder.Append(\"'\");\n\t\tbuilder.Append(_sqlGenerationHelper.StatementTerminator);\n\t\tbuilder.AppendLine();\n\t\tbuilder.DecrementIndent();\n\t\tbuilder.AppendLine(\"end\");\n\t\tbuilder.DecrementIndent();\n\t\tbuilder.Append(\"END\");\n\t\tbuilder.AppendLine();\n\t\tif (options.HasFlag(MigrationsSqlGenerationOptions.Script))\n\t\t{\n\t\t\tbuilder.AppendLine(((IFbSqlGenerationHelper)_sqlGenerationHelper).AlternativeStatementTerminator);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tbuilder.AppendLine(_sqlGenerationHelper.StatementTerminator);\n\t\t}\n\t\tbuilder.EndCommand();\n\n\t\tif (options.HasFlag(MigrationsSqlGenerationOptions.Script))\n\t\t{\n\t\t\tbuilder.Append(\"SET TERM \");\n\t\t\tbuilder.Append(_sqlGenerationHelper.StatementTerminator);\n\t\t\tbuilder.AppendLine(((IFbSqlGenerationHelper)_sqlGenerationHelper).AlternativeStatementTerminator);\n\t\t\tbuilder.EndCommand();\n\t\t}\n\t}\n\n\tprotected virtual string CreateSequenceTriggerName(string columnName, string tableName, string schemaName)\n\t{\n\t\treturn !string.IsNullOrEmpty(schemaName)\n\t\t\t? $\"ID_{schemaName}_{tableName}_{columnName}\"\n\t\t\t: $\"ID_{tableName}_{columnName}\";\n\t}\n\n\tprotected virtual string CreateSequenceTriggerSequenceName(string columnName, string tableName, string schemaName)\n\t{\n\t\treturn \"GEN_IDENTITY\";\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Migrations/FbMigrationsSqlGenerator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Text;\nusing FirebirdSql.Data.FirebirdClient;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Internal;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\nusing Microsoft.EntityFrameworkCore.Metadata;\nusing Microsoft.EntityFrameworkCore.Migrations;\nusing Microsoft.EntityFrameworkCore.Migrations.Operations;\nusing Microsoft.EntityFrameworkCore.Storage;\nusing Microsoft.EntityFrameworkCore.Update;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Migrations;\n\npublic class FbMigrationsSqlGenerator : MigrationsSqlGenerator\n{\n\treadonly IFbMigrationSqlGeneratorBehavior _behavior;\n\treadonly IFbOptions _options;\n\n\tpublic FbMigrationsSqlGenerator(MigrationsSqlGeneratorDependencies dependencies, IFbMigrationSqlGeneratorBehavior behavior, IFbOptions options)\n\t\t: base(dependencies)\n\t{\n\t\t_behavior = behavior;\n\t\t_options = options;\n\t}\n\n\tprotected override void Generate(MigrationOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t{\n\t\tswitch (operation)\n\t\t{\n\t\t\tdefault:\n\t\t\t\tbase.Generate(operation, model, builder);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tprotected override void Generate(CreateTableOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)\n\t{\n\t\tbase.Generate(operation, model, builder, true);\n\n\t\tvar columns = operation.Columns.Where(p => !p.IsNullable && string.IsNullOrWhiteSpace(p.DefaultValueSql) && p.DefaultValue == null);\n\t\tforeach (var column in columns)\n\t\t{\n\t\t\tvar valueGenerationStrategy = column[FbAnnotationNames.ValueGenerationStrategy] as FbValueGenerationStrategy?;\n\t\t\tif (valueGenerationStrategy == FbValueGenerationStrategy.SequenceTrigger)\n\t\t\t{\n\t\t\t\t_behavior.CreateSequenceTriggerForColumn(column.Name, column.Table, column.Schema, Options, builder);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected override void Generate(RenameTableOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t\t=> throw new NotSupportedException(\"Renaming table is not supported by Firebird.\");\n\n\tprotected override void Generate(DropTableOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)\n\t\t=> base.Generate(operation, model, builder, terminate);\n\n\tprotected override void Generate(AlterTableOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t\t=> base.Generate(operation, model, builder);\n\n\n\tprotected override void Generate(AlterColumnOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t{\n\t\tvar valueGenerationStrategy = operation[FbAnnotationNames.ValueGenerationStrategy] as FbValueGenerationStrategy?;\n\t\tvar oldValueGenerationStrategy = operation.OldColumn[FbAnnotationNames.ValueGenerationStrategy] as FbValueGenerationStrategy?;\n\t\tif (oldValueGenerationStrategy == FbValueGenerationStrategy.IdentityColumn && valueGenerationStrategy != FbValueGenerationStrategy.IdentityColumn)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"Cannot remove identity from column.\");\n\n\t\t\t// will be recreated, if needed, by next statement\n\t\t\t// supported only on FB4\n\t\t\t//builder.Append(\"ALTER TABLE \");\n\t\t\t//builder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Table, operation.Schema));\n\t\t\t//builder.Append(\" ALTER COLUMN \");\n\t\t\t//builder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name));\n\t\t\t//builder.Append(\" DROP IDENTITY\");\n\t\t\t//TerminateStatement(builder);\n\t\t}\n\t\tif (oldValueGenerationStrategy == FbValueGenerationStrategy.SequenceTrigger && valueGenerationStrategy != FbValueGenerationStrategy.SequenceTrigger)\n\t\t{\n\t\t\t_behavior.DropSequenceTriggerForColumn(operation.Name, operation.Table, operation.Schema, Options, builder);\n\t\t}\n\n\t\t// will be recreated, if needed, by next statement\n\t\tbuilder.Append(\"ALTER TABLE \");\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Table, operation.Schema));\n\t\tbuilder.Append(\" ALTER COLUMN \");\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name));\n\t\tbuilder.Append(\" DROP NOT NULL\");\n\t\tTerminateStatement(builder);\n\n\t\tbuilder.Append(\"ALTER TABLE \");\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Table, operation.Schema));\n\t\tbuilder.Append(\" ALTER COLUMN \");\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name));\n\t\tbuilder.Append(\" TYPE \");\n\t\tif (operation.ColumnType != null)\n\t\t{\n\t\t\tbuilder.Append(operation.ColumnType);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tvar type = GetColumnType(operation.Schema, operation.Table, operation.Name, operation, model);\n\t\t\tbuilder.Append(type);\n\t\t}\n\t\tif (operation.Collation != null)\n\t\t{\n\t\t\tbuilder.Append(\" COLLATE \");\n\t\t\tbuilder.Append(operation.Collation);\n\t\t}\n\t\tif (valueGenerationStrategy == FbValueGenerationStrategy.IdentityColumn)\n\t\t{\n\t\t\tbuilder.Append(\" GENERATED BY DEFAULT AS IDENTITY\");\n\t\t}\n\t\tTerminateStatement(builder);\n\n\t\tif (!operation.IsNullable)\n\t\t{\n\t\t\tbuilder.Append(\"ALTER TABLE \");\n\t\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Table, operation.Schema));\n\t\t\tbuilder.Append(\" ALTER COLUMN \");\n\t\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name));\n\t\t\tbuilder.Append(\" SET NOT NULL\");\n\t\t\tTerminateStatement(builder);\n\t\t}\n\n\t\tif (operation.DefaultValue != null || !string.IsNullOrWhiteSpace(operation.DefaultValueSql))\n\t\t{\n\t\t\tbuilder.Append(\"ALTER TABLE \");\n\t\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Table, operation.Schema));\n\t\t\tbuilder.Append(\" ALTER COLUMN \");\n\t\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name));\n\t\t\tbuilder.Append(\" DROP DEFAULT\");\n\t\t\tTerminateStatement(builder);\n\n\t\t\tbuilder.Append(\"ALTER TABLE \");\n\t\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Table, operation.Schema));\n\t\t\tbuilder.Append(\" ALTER COLUMN \");\n\t\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name));\n\t\t\tbuilder.Append(\" SET\");\n\t\t\tDefaultValue(operation.DefaultValue, operation.DefaultValueSql, operation.ColumnType, builder);\n\t\t\tTerminateStatement(builder);\n\t\t}\n\n\t\tif (valueGenerationStrategy == FbValueGenerationStrategy.SequenceTrigger)\n\t\t{\n\t\t\t_behavior.CreateSequenceTriggerForColumn(operation.Name, operation.Table, operation.Schema, Options, builder);\n\t\t}\n\t}\n\n\tprotected override void Generate(AddColumnOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)\n\t\t=> base.Generate(operation, model, builder, terminate);\n\n\tprotected override void Generate(DropColumnOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)\n\t{\n\t\tbuilder.Append(\"ALTER TABLE \");\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Table, operation.Schema));\n\t\tbuilder.Append(\" DROP \");\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name));\n\t\tif (terminate)\n\t\t\tTerminateStatement(builder);\n\t}\n\n\tprotected override void Generate(RenameColumnOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t{\n\t\tbuilder.Append(\"ALTER TABLE \");\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Table, operation.Schema));\n\t\tbuilder.Append(\" ALTER COLUMN \");\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name));\n\t\tbuilder.Append(\" TO \");\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.NewName));\n\t\tTerminateStatement(builder);\n\t}\n\n\n\tprotected override void Generate(CreateIndexOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)\n\t{\n\t\tbuilder.Append(\"CREATE \");\n\t\tif (operation.IsUnique)\n\t\t{\n\t\t\tbuilder.Append(\"UNIQUE \");\n\t\t}\n\n\t\tif (operation.IsDescending is not null && operation.IsDescending.Length > 0)\n\t\t{\n\t\t\tvar isDescending = operation.IsDescending[0];\n\t\t\tif (operation.IsDescending.Any(x => x != isDescending))\n\t\t\t\tthrow new NotSupportedException(\"Mixed order indices are not supported by Firebird.\");\n\n\t\t\tif (isDescending)\n\t\t\t{\n\t\t\t\tbuilder.Append(\"DESC \");\n\t\t\t}\n\t\t}\n\n\t\tIndexTraits(operation, model, builder);\n\t\tbuilder.Append(\"INDEX \");\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name));\n\t\tbuilder.Append(\" ON \");\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Table, operation.Schema));\n\t\tif (!string.IsNullOrEmpty(operation.Filter))\n\t\t{\n\t\t\tbuilder.Append(\" COMPUTED BY (\");\n\t\t\tbuilder.Append(operation.Filter);\n\t\t\tbuilder.Append(\")\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tbuilder.Append(\" (\");\n\t\t\tbuilder.Append(ColumnList(operation.Columns));\n\t\t\tbuilder.Append(\")\");\n\t\t}\n\t\tif (terminate)\n\t\t\tTerminateStatement(builder);\n\t}\n\n\tprotected override void Generate(DropIndexOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)\n\t{\n\t\tbuilder.Append(\"DROP \");\n\t\tIndexTraits(operation, model, builder);\n\t\tbuilder.Append(\"INDEX \");\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name));\n\t\tif (terminate)\n\t\t\tTerminateStatement(builder);\n\t}\n\tprotected override void Generate(RenameIndexOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t\t=> throw new NotSupportedException(\"Renaming index is not supported by Firebird.\");\n\n\n\tprotected override void Generate(CreateSequenceOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t{\n\t\tbuilder.Append(\"CREATE SEQUENCE \");\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name, operation.Schema));\n\t\tbuilder.Append(\" START WITH \");\n\t\tbuilder.Append(operation.StartValue.ToString(CultureInfo.InvariantCulture));\n\t\tbuilder.Append(\" INCREMENT BY \");\n\t\tbuilder.Append(operation.IncrementBy.ToString(CultureInfo.InvariantCulture));\n\t\tTerminateStatement(builder);\n\t}\n\n\tprotected override void Generate(AlterSequenceOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t{\n\t\tbuilder.Append(\"ALTER SEQUENCE \");\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name, operation.Schema));\n\t\tbuilder.Append(\" RESTART INCREMENT BY \");\n\t\tbuilder.Append(operation.IncrementBy.ToString(CultureInfo.InvariantCulture));\n\t\tTerminateStatement(builder);\n\t}\n\n\tprotected override void Generate(RestartSequenceOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t{\n\t\tbuilder.Append(\"ALTER SEQUENCE \");\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name, operation.Schema));\n\t\tbuilder.Append(\" RESTART\");\n\t\tif (operation.StartValue != null)\n\t\t{\n\t\t\tbuilder.Append(\" WITH \");\n\t\t\tbuilder.Append(((long)operation.StartValue).ToString(CultureInfo.InvariantCulture));\n\t\t}\n\t\tTerminateStatement(builder);\n\t}\n\n\tprotected override void Generate(RenameSequenceOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t\t=> throw new NotSupportedException(\"Renaming sequence is not supported by Firebird.\");\n\n\tprotected override void Generate(DropSequenceOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t\t=> base.Generate(operation, model, builder);\n\n\tprotected override void Generate(AddPrimaryKeyOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)\n\t\t=> base.Generate(operation, model, builder, terminate);\n\n\tprotected override void Generate(DropPrimaryKeyOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)\n\t\t=> base.Generate(operation, model, builder, terminate);\n\n\n\tprotected override void Generate(AddForeignKeyOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)\n\t\t=> base.Generate(operation, model, builder, terminate);\n\n\tprotected override void Generate(DropForeignKeyOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)\n\t\t=> base.Generate(operation, model, builder, terminate);\n\n\n\tprotected override void Generate(AddUniqueConstraintOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t\t=> base.Generate(operation, model, builder);\n\n\tprotected override void Generate(DropUniqueConstraintOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t\t=> base.Generate(operation, model, builder);\n\n\n\tprotected override void Generate(AlterDatabaseOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t\t=> base.Generate(operation, model, builder);\n\n\n\tprotected override void Generate(SqlOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t\t=> base.Generate(operation, model, builder);\n\n\n\tprotected override void Generate(DropSchemaOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t\t=> throw new NotSupportedException(\"Schemas are not supported by Firebird.\");\n\n\tprotected override void Generate(EnsureSchemaOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t\t=> throw new NotSupportedException(\"Schemas are not supported by Firebird.\");\n\n\n\tprotected override void ColumnDefinition(string schema, string table, string name, ColumnOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t{\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(name));\n\t\tbuilder.Append(\" \");\n\t\tbuilder.Append(operation.ColumnType ?? GetColumnType(schema, table, name, operation, model));\n\n\t\tif (operation.Collation != null)\n\t\t{\n\t\t\tbuilder.Append(\" COLLATE \");\n\t\t\tbuilder.Append(operation.Collation);\n\t\t}\n\n\t\tvar valueGenerationStrategy = operation[FbAnnotationNames.ValueGenerationStrategy] as FbValueGenerationStrategy?;\n\t\tif (valueGenerationStrategy == FbValueGenerationStrategy.IdentityColumn)\n\t\t{\n\t\t\tbuilder.Append(\" GENERATED BY DEFAULT AS IDENTITY\");\n\t\t}\n\n\t\tDefaultValue(operation.DefaultValue, operation.DefaultValueSql, operation.ColumnType, builder);\n\n\t\tif (!operation.IsNullable)\n\t\t{\n\t\t\tbuilder.Append(\" NOT NULL\");\n\t\t}\n\t}\n\n\tprotected override void DefaultValue(object defaultValue, string defaultValueSql, string columnType, MigrationCommandListBuilder builder)\n\t{\n\t\tif (defaultValueSql != null)\n\t\t{\n\t\t\tbuilder.Append(\" DEFAULT \");\n\t\t\tbuilder.Append(defaultValueSql);\n\t\t}\n\t\telse if (defaultValue != null)\n\t\t{\n\t\t\tbuilder.Append(\" DEFAULT \");\n\t\t\tvar typeMapping = Dependencies.TypeMappingSource.GetMappingForValue(defaultValue);\n\t\t\tbuilder.Append(typeMapping.GenerateSqlLiteral(defaultValue));\n\t\t}\n\t}\n\n\tprotected override void ForeignKeyConstraint(AddForeignKeyOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t{\n\t\tif (operation.Name != null)\n\t\t{\n\t\t\tbuilder.Append(\"CONSTRAINT \");\n\t\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name));\n\t\t\tbuilder.Append(\" \");\n\t\t}\n\t\tbuilder.Append(\"FOREIGN KEY (\");\n\t\tbuilder.Append(ColumnList(operation.Columns));\n\t\tbuilder.Append(\") REFERENCES \");\n\t\tbuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.PrincipalTable, operation.PrincipalSchema));\n\t\tif (operation.PrincipalColumns != null)\n\t\t{\n\t\t\tbuilder.Append(\" (\");\n\t\t\tbuilder.Append(ColumnList(operation.PrincipalColumns));\n\t\t\tbuilder.Append(\")\");\n\t\t}\n\t\tif (operation.OnUpdate != ReferentialAction.Restrict)\n\t\t{\n\t\t\tbuilder.Append(\" ON UPDATE \");\n\t\t\tForeignKeyAction(operation.OnUpdate, builder);\n\t\t}\n\t\tif (operation.OnDelete != ReferentialAction.Restrict)\n\t\t{\n\t\t\tbuilder.Append(\" ON DELETE \");\n\t\t\tForeignKeyAction(operation.OnDelete, builder);\n\t\t}\n\t}\n\n\tprotected override void Generate(InsertDataOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)\n\t{\n\t\tvar sqlBuilder = new StringBuilder();\n\t\tforeach (var modificationCommand in GenerateModificationCommands(operation, model))\n\t\t{\n\t\t\tSqlGenerator.AppendInsertOperation(\n\t\t\t\tsqlBuilder,\n\t\t\t\tmodificationCommand,\n\t\t\t\t0);\n\t\t\tbuilder.Append(sqlBuilder.ToString());\n\t\t\tif (terminate)\n\t\t\t{\n\t\t\t\tEndStatement(builder);\n\t\t\t}\n\t\t\tsqlBuilder.Clear();\n\t\t}\n\t}\n\n\tprotected override void Generate(DeleteDataOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t{\n\t\tvar sqlBuilder = new StringBuilder();\n\t\tforeach (var modificationCommand in GenerateModificationCommands(operation, model))\n\t\t{\n\t\t\tSqlGenerator.AppendDeleteOperation(\n\t\t\t\tsqlBuilder,\n\t\t\t\tmodificationCommand,\n\t\t\t\t0);\n\t\t\tbuilder.Append(sqlBuilder.ToString());\n\t\t\tEndStatement(builder);\n\t\t\tsqlBuilder.Clear();\n\t\t}\n\t}\n\n\tprotected override void Generate(UpdateDataOperation operation, IModel model, MigrationCommandListBuilder builder)\n\t{\n\t\tvar sqlBuilder = new StringBuilder();\n\t\tforeach (var modificationCommand in GenerateModificationCommands(operation, model))\n\t\t{\n\t\t\tSqlGenerator.AppendUpdateOperation(\n\t\t\t\tsqlBuilder,\n\t\t\t\tmodificationCommand,\n\t\t\t\t0);\n\t\t\tbuilder.Append(sqlBuilder.ToString());\n\t\t\tEndStatement(builder);\n\t\t\tsqlBuilder.Clear();\n\t\t}\n\t}\n\n\tprotected override void ForeignKeyAction(ReferentialAction referentialAction, MigrationCommandListBuilder builder)\n\t{\n\t\tswitch (referentialAction)\n\t\t{\n\t\t\tcase ReferentialAction.NoAction:\n\t\t\t\tbuilder.Append(\"NO ACTION\");\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbase.ForeignKeyAction(referentialAction, builder);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tprotected virtual void TerminateStatement(MigrationCommandListBuilder builder)\n\t{\n\t\tbuilder.AppendLine(Dependencies.SqlGenerationHelper.StatementTerminator);\n\t\tEndStatement(builder);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Migrations/IFbMigrationSqlGeneratorBehavior.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Migrations;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird;\n\npublic interface IFbMigrationSqlGeneratorBehavior\n{\n\tvoid CreateSequenceTriggerForColumn(string columnName, string tableName, string schemaName, MigrationsSqlGenerationOptions options, MigrationCommandListBuilder builder);\n\tvoid DropSequenceTriggerForColumn(string columnName, string tableName, string schemaName, MigrationsSqlGenerationOptions options, MigrationCommandListBuilder builder);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Migrations/Internal/FbHistoryRepository.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net), Jean Ressouche, Rafael Almeida (ralms@ralms.net)\n\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Migrations;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Migrations.Internal;\n\npublic class FbHistoryRepository(HistoryRepositoryDependencies dependencies) : HistoryRepository(dependencies)\n{\n\tstatic readonly TimeSpan RetryDelay = TimeSpan.FromSeconds(1);\n\n\tprotected override string ExistsSql\n\t{\n\t\tget\n\t\t{\n\t\t\tvar escapedTableName = Dependencies.TypeMappingSource.GetMapping(typeof(string)).GenerateSqlLiteral(TableName);\n\t\t\treturn $\"\"\"\n\t\t\t\tSELECT COUNT(*) FROM rdb$relations WHERE COALESCE(rdb$system_flag, 0) = 0 AND rdb$view_blr IS NULL AND rdb$relation_name = {escapedTableName}\n\t\t\t\t\"\"\";\n\t\t}\n\t}\n\n\tprotected override bool InterpretExistsResult(object value)\n\t\t=> Convert.ToInt64(value) != 0;\n\n\tpublic override string GetCreateIfNotExistsScript()\n\t{\n\t\tvar script = GetCreateScript();\n\t\treturn BuildIfTableNotExistsBlock(script).CommandText;\n\t}\n\n\tprotected virtual string LockTableName { get; } = \"__EFMigrationsLock\";\n\n\tpublic override LockReleaseBehavior LockReleaseBehavior\n\t\t=> LockReleaseBehavior.Explicit;\n\n\tpublic override IMigrationsDatabaseLock AcquireDatabaseLock()\n\t{\n\t\tDependencies.MigrationsLogger.AcquiringMigrationLock();\n\n\t\tCreateLockTableCommand().ExecuteNonQuery(CreateRelationalCommandParameters());\n\n\t\tvar retryDelay = RetryDelay;\n\t\twhile (true)\n\t\t{\n\t\t\tvar dbLock = CreateMigrationDatabaseLock();\n\t\t\tvar insertCount = CreateInsertLockCommand(DateTime.UtcNow)\n\t\t\t\t.ExecuteScalar(CreateRelationalCommandParameters());\n\t\t\tif ((int)insertCount == 1)\n\t\t\t{\n\t\t\t\treturn dbLock;\n\t\t\t}\n\n\t\t\tThread.Sleep(retryDelay);\n\t\t\tif (retryDelay < TimeSpan.FromMinutes(1))\n\t\t\t{\n\t\t\t\tretryDelay = retryDelay.Add(retryDelay);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override async Task<IMigrationsDatabaseLock> AcquireDatabaseLockAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tDependencies.MigrationsLogger.AcquiringMigrationLock();\n\n\t\tawait CreateLockTableCommand().ExecuteNonQueryAsync(CreateRelationalCommandParameters(), cancellationToken).ConfigureAwait(false);\n\n\t\tvar retryDelay = RetryDelay;\n\t\twhile (true)\n\t\t{\n\t\t\tvar dbLock = CreateMigrationDatabaseLock();\n\t\t\tvar insertCount = await CreateInsertLockCommand(DateTime.UtcNow)\n\t\t\t\t.ExecuteScalarAsync(CreateRelationalCommandParameters(), cancellationToken)\n\t\t\t\t.ConfigureAwait(false);\n\t\t\tif ((int)insertCount == 1)\n\t\t\t{\n\t\t\t\treturn dbLock;\n\t\t\t}\n\n\t\t\tawait Task.Delay(RetryDelay, cancellationToken).ConfigureAwait(true);\n\t\t\tif (retryDelay < TimeSpan.FromMinutes(1))\n\t\t\t{\n\t\t\t\tretryDelay = retryDelay.Add(retryDelay);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override string GetBeginIfExistsScript(string migrationId)\n\t\t=> throw new NotSupportedException(\"Generating idempotent scripts is currently not supported.\");\n\n\tpublic override string GetBeginIfNotExistsScript(string migrationId)\n\t\t=> throw new NotSupportedException(\"Generating idempotent scripts is currently not supported.\");\n\n\tpublic override string GetEndIfScript()\n\t\t=> throw new NotSupportedException(\"Generating idempotent scripts is currently not supported.\");\n\n\tIRelationalCommand CreateLockTableCommand()\n\t{\n\t\treturn BuildIfTableNotExistsBlock($\"\"\"\n\t\t\tCREATE TABLE \"{LockTableName}\" (\n\t\t\t\t\"Id\" INT NOT NULL CONSTRAINT \"PK_{LockTableName}\" PRIMARY KEY,\n\t\t\t\t\"Timestamp\" TIMESTAMP NOT NULL\n\t\t\t)\n\t\t\t\"\"\");\n\t}\n\n\tIRelationalCommand CreateInsertLockCommand(DateTime timestamp)\n\t{\n\t\tvar timestampLiteral = Dependencies.TypeMappingSource.GetMapping(typeof(DateTime)).GenerateSqlLiteral(timestamp);\n\t\treturn Dependencies.RawSqlCommandBuilder.Build($\"\"\"\n\t\t\tEXECUTE BLOCK\n\t\t\tRETURNS (ROWS_AFFECTED INT)\n\t\t\tAS\n\t\t\tBEGIN\n\t\t\t\tROWS_AFFECTED = 1;\n\t\t\t\tBEGIN\n\t\t\t\t\tINSERT INTO \"{LockTableName}\" (\"Id\", \"Timestamp\") VALUES (1, {timestampLiteral});\n\t\t\t\t\tWHEN SQLSTATE '23000' DO\n\t\t\t\t\tBEGIN\n\t\t\t\t\t\tROWS_AFFECTED = 0;\n\t\t\t\t\tEND\n\t\t\t\tEND\n\t\t\t\tSUSPEND;\n\t\t\tEND\n\t\t\t\"\"\");\n\t}\n\n\tIRelationalCommand CreateDeleteLockCommand()\n\t{\n\t\treturn Dependencies.RawSqlCommandBuilder.Build($\"\"\"\n\t\t\tDELETE FROM \"{LockTableName}\" WHERE \"Id\" = 1\n\t\t\t\"\"\");\n\t}\n\n\tFbMigrationDatabaseLock CreateMigrationDatabaseLock()\n\t\t=> new(CreateDeleteLockCommand(), CreateRelationalCommandParameters(), this);\n\n\tRelationalCommandParameterObject CreateRelationalCommandParameters()\n\t\t=> new(\n\t\t\tDependencies.Connection,\n\t\t\tnull,\n\t\t\tnull,\n\t\t\tDependencies.CurrentContext.Context,\n\t\t\tDependencies.CommandLogger, CommandSource.Migrations);\n\n\tIRelationalCommand BuildIfTableNotExistsBlock(string statement)\n\t{\n\t\tvar statementLiteral = Dependencies.TypeMappingSource.GetMapping(typeof(string)).GenerateSqlLiteral(statement);\n\t\treturn Dependencies.RawSqlCommandBuilder.Build($\"\"\"\n\t\t\tEXECUTE BLOCK\n\t\t\tAS\n\t\t\tBEGIN\n\t\t\t\tBEGIN\n\t\t\t\t\tEXECUTE STATEMENT\n\t\t\t\t\t\t{statementLiteral};\n\t\t\t\t\tWHEN SQLSTATE '42S01' DO\n\t\t\t\t\tBEGIN\n\t\t\t\t\tEND\n\t\t\t\tEND\n\t\t\tEND\n\t\t\t\"\"\");\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Migrations/Internal/FbMigrationDatabaseLock.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Microsoft.EntityFrameworkCore.Migrations;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Migrations.Internal;\n\npublic class FbMigrationDatabaseLock(\n\tIRelationalCommand releaseLockCommand,\n\tRelationalCommandParameterObject relationalCommandParameters,\n\tIHistoryRepository historyRepository,\n\tCancellationToken cancellationToken = default)\n\t: IMigrationsDatabaseLock\n{\n\tpublic virtual IHistoryRepository HistoryRepository => historyRepository;\n\n\tpublic void Dispose()\n\t\t=> releaseLockCommand.ExecuteScalar(relationalCommandParameters);\n\n\tpublic async ValueTask DisposeAsync()\n\t\t=> await releaseLockCommand.ExecuteScalarAsync(relationalCommandParameters, cancellationToken).ConfigureAwait(false);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Properties/EntityFrameworkCoreAssemblyInfo.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net), Jean Ressouche, Rafael Almeida (ralms@ralms.net)\n\nusing Microsoft.EntityFrameworkCore.Design;\n\n[assembly: DesignTimeProviderServices(\"FirebirdSql.EntityFrameworkCore.Firebird.Design.Internal.FbDesignTimeServices\")]\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbByteArrayMethodTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbByteArrayMethodTranslator : IMethodCallTranslator\n{\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbByteArrayMethodTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (method.IsGenericMethod\n\t\t\t&& method.GetGenericMethodDefinition().Equals(EnumerableMethods.Contains)\n\t\t\t&& arguments[0].Type == typeof(byte[]))\n\t\t{\n\t\t\tvar value = arguments[1] is SqlConstantExpression constantValue\n\t\t\t\t? _fbSqlExpressionFactory.Function(\"ASCII_CHAR\", new[] { _fbSqlExpressionFactory.Constant((byte)constantValue.Value) }, false, new[] { false }, typeof(string))\n\t\t\t\t: _fbSqlExpressionFactory.Function(\"ASCII_CHAR\", new[] { _fbSqlExpressionFactory.Convert(_fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[1]), typeof(byte)) }, true, new[] { true }, typeof(string));\n\n\t\t\treturn _fbSqlExpressionFactory.GreaterThan(\n\t\t\t\t_fbSqlExpressionFactory.Function(\n\t\t\t\t\t\"POSITION\",\n\t\t\t\t\tnew[] { value, _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]) },\n\t\t\t\t\ttrue,\n\t\t\t\t\tnew[] { true, true },\n\t\t\t\t\ttypeof(int)),\n\t\t\t\t_fbSqlExpressionFactory.Constant(0));\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbConvertTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbConvertTranslator : IMethodCallTranslator\n{\n\tstatic readonly List<string> Mappings = new List<string>\n\t{\n\t\tnameof(Convert.ToByte),\n\t\tnameof(Convert.ToDecimal),\n\t\tnameof(Convert.ToDouble),\n\t\tnameof(Convert.ToInt16),\n\t\tnameof(Convert.ToInt32),\n\t\tnameof(Convert.ToInt64),\n\t\tnameof(Convert.ToString),\n\t\tnameof(Convert.ToBoolean),\n\t};\n\n\tstatic readonly HashSet<Type> SupportedTypes = new HashSet<Type>\n\t{\n\t\ttypeof(bool),\n\t\ttypeof(byte),\n\t\ttypeof(decimal),\n\t\ttypeof(double),\n\t\ttypeof(float),\n\t\ttypeof(int),\n\t\ttypeof(long),\n\t\ttypeof(short),\n\t\ttypeof(string),\n\t\ttypeof(DateTime),\n\t};\n\n\tstatic readonly IEnumerable<MethodInfo> SupportedMethods\n\t\t= Mappings\n\t\t\t.SelectMany(t => typeof(Convert).GetTypeInfo().GetDeclaredMethods(t)\n\t\t\t\t.Where(m => m.GetParameters().Length == 1 && SupportedTypes.Contains(m.GetParameters().First().ParameterType)));\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbConvertTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (!SupportedMethods.Contains(method))\n\t\t\treturn null;\n\n\t\treturn _fbSqlExpressionFactory.ApplyDefaultTypeMapping(\n\t\t\t_fbSqlExpressionFactory.Convert(_fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]), method.ReturnType));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbDateAddTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbDateAddTranslator : IMethodCallTranslator\n{\n\tstatic readonly Dictionary<MethodInfo, string> MethodInfoDatePartMapping = new Dictionary<MethodInfo, string>\n\t\t{\n\t\t\t{  typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddYears), new[] { typeof(int) }), \"YEAR\" },\n\t\t\t{  typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddMonths), new[] { typeof(int) }), \"MONTH\" },\n\t\t\t{  typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddDays), new[] { typeof(double) }), \"DAY\" },\n\t\t\t{  typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddHours), new[] { typeof(double) }), \"HOUR\" },\n\t\t\t{  typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddMinutes), new[] { typeof(double) }), \"MINUTE\" },\n\t\t\t{  typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddSeconds), new[] { typeof(double) }), \"SECOND\" },\n\t\t\t{  typeof(DateTime).GetRuntimeMethod(nameof(DateTime.AddMilliseconds), new[] { typeof(double) }), \"MILLISECOND\" },\n\n\t\t\t{  typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.AddYears), new[] { typeof(int) }), \"YEAR\" },\n\t\t\t{  typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.AddMonths), new[] { typeof(int) }), \"MONTH\" },\n\t\t\t{  typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.AddDays), new[] { typeof(int) }), \"DAY\" },\n\n\t\t\t{  typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.AddHours), new[] { typeof(double) }), \"HOUR\" },\n\t\t\t{  typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.AddMinutes), new[] { typeof(double) }), \"MINUTE\" },\n\t\t};\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbDateAddTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (!MethodInfoDatePartMapping.TryGetValue(method, out var part))\n\t\t\treturn null;\n\n\t\treturn _fbSqlExpressionFactory.ApplyDefaultTypeMapping(_fbSqlExpressionFactory.Function(\n\t\t\t\"DATEADD\",\n\t\t\tnew[] { _fbSqlExpressionFactory.Fragment(part), _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]), instance },\n\t\t\ttrue,\n\t\t\tnew[] { false, true, true },\n\t\t\tinstance.Type));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbDateOnlyMethodTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbDateOnlyMethodTranslator : IMethodCallTranslator\n{\n\treadonly Dictionary<MethodInfo, string> _methodInfoDatePartMapping = new()\n\t{\n\t\t{ typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.AddYears), [typeof(int)]), \"year\" },\n\t\t{ typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.AddMonths), [typeof(int)]), \"month\" },\n\t\t{ typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.AddDays), [typeof(int)]), \"day\" }\n\t};\n\n\treadonly ISqlExpressionFactory _sqlExpressionFactory;\n\n\tpublic FbDateOnlyMethodTranslator(ISqlExpressionFactory sqlExpressionFactory)\n\t{\n\t\t_sqlExpressionFactory = sqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (_methodInfoDatePartMapping.TryGetValue(method, out var datePart) && instance != null)\n\t\t{\n\t\t\tinstance = _sqlExpressionFactory.ApplyDefaultTypeMapping(instance);\n\n\t\t\treturn _sqlExpressionFactory.Function(\n\t\t\t\t\"DATEADD\",\n\t\t\t\tnew[] { _sqlExpressionFactory.Fragment(datePart), _sqlExpressionFactory.Convert(arguments[0], typeof(int)), instance },\n\t\t\t\tnullable: true,\n\t\t\t\targumentsPropagateNullability: new[] { false, true, true },\n\t\t\t\tinstance.Type,\n\t\t\t\tinstance.TypeMapping);\n\t\t}\n\n\t\tif (method.DeclaringType == typeof(DateOnly) && method.Name == nameof(DateOnly.FromDateTime) && arguments.Count == 1)\n\t\t{\n\t\t\treturn _sqlExpressionFactory.Convert(arguments[0], typeof(DateOnly));\n\t\t}\n\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbDateOnlyPartComponentTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Expressions.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbDateOnlyPartComponentTranslator : IMemberTranslator\n{\n\tconst string YearDayPart = \"YEARDAY\";\n\tstatic readonly Dictionary<MemberInfo, string> MemberMapping = new Dictionary<MemberInfo, string>\n\t\t{\n\t\t\t{  typeof(DateOnly).GetProperty(nameof(DateOnly.Year)), \"YEAR\" },\n\t\t\t{  typeof(DateOnly).GetProperty(nameof(DateOnly.Month)), \"MONTH\" },\n\t\t\t{  typeof(DateOnly).GetProperty(nameof(DateOnly.Day)), \"DAY\" },\n\t\t\t{  typeof(DateOnly).GetProperty(nameof(DateOnly.DayOfYear)), YearDayPart },\n\t\t\t{  typeof(DateOnly).GetProperty(nameof(DateOnly.DayOfWeek)), \"WEEKDAY\" },\n\t\t};\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbDateOnlyPartComponentTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (!MemberMapping.TryGetValue(member, out var part))\n\t\t\treturn null;\n\n\t\tvar result = (SqlExpression)_fbSqlExpressionFactory.SpacedFunction(\n\t\t\t\"EXTRACT\",\n\t\t\tnew[] { _fbSqlExpressionFactory.Fragment(part), _fbSqlExpressionFactory.Fragment(\"FROM\"), instance },\n\t\t\ttrue,\n\t\t\tnew[] { false, false, true },\n\t\t\ttypeof(int));\n\t\tif (part == YearDayPart)\n\t\t{\n\t\t\tresult = _fbSqlExpressionFactory.Add(result, _fbSqlExpressionFactory.Constant(1));\n\t\t}\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbDateTimeDateComponentTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbDateTimeDateComponentTranslator : IMemberTranslator\n{\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbDateTimeDateComponentTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (member.DeclaringType == typeof(DateTime) && member.Name == nameof(DateTime.Date))\n\t\t{\n\t\t\treturn _fbSqlExpressionFactory.SpacedFunction(\n\t\t\t\t\"CAST\",\n\t\t\t\tnew[] { instance, _fbSqlExpressionFactory.Fragment(\"AS\"), _fbSqlExpressionFactory.Fragment(\"DATE\") },\n\t\t\t\ttrue,\n\t\t\t\tnew[] { true, false, false },\n\t\t\t\ttypeof(DateTime));\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbDateTimeNowTodayTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbDateTimeNowTodayTranslator : IMemberTranslator\n{\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbDateTimeNowTodayTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (member.DeclaringType == typeof(DateTime) && member.Name == nameof(DateTime.Now))\n\t\t{\n\t\t\treturn _fbSqlExpressionFactory.ApplyDefaultTypeMapping(_fbSqlExpressionFactory.NiladicFunction(\"LOCALTIMESTAMP\", false, typeof(DateTime)));\n\t\t}\n\t\tif (member.DeclaringType == typeof(DateTime) && member.Name == nameof(DateTime.Today))\n\t\t{\n\t\t\treturn _fbSqlExpressionFactory.ApplyDefaultTypeMapping(_fbSqlExpressionFactory.NiladicFunction(\"CURRENT_DATE\", false, typeof(DateTime)));\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbDateTimePartComponentTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Expressions.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbDateTimePartComponentTranslator : IMemberTranslator\n{\n\tconst string YearDayPart = \"YEARDAY\";\n\tconst string SecondPart = \"SECOND\";\n\tconst string MillisecondPart = \"MILLISECOND\";\n\tstatic readonly Dictionary<MemberInfo, string> MemberMapping = new Dictionary<MemberInfo, string>\n\t\t{\n\t\t\t{  typeof(DateTime).GetProperty(nameof(DateTime.Year)), \"YEAR\" },\n\t\t\t{  typeof(DateTime).GetProperty(nameof(DateTime.Month)), \"MONTH\" },\n\t\t\t{  typeof(DateTime).GetProperty(nameof(DateTime.Day)), \"DAY\" },\n\t\t\t{  typeof(DateTime).GetProperty(nameof(DateTime.Hour)), \"HOUR\" },\n\t\t\t{  typeof(DateTime).GetProperty(nameof(DateTime.Minute)), \"MINUTE\" },\n\t\t\t{  typeof(DateTime).GetProperty(nameof(DateTime.Second)), SecondPart },\n\t\t\t{  typeof(DateTime).GetProperty(nameof(DateTime.Millisecond)), MillisecondPart },\n\t\t\t{  typeof(DateTime).GetProperty(nameof(DateTime.DayOfYear)), YearDayPart },\n\t\t\t{  typeof(DateTime).GetProperty(nameof(DateTime.DayOfWeek)), \"WEEKDAY\" },\n\t\t};\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbDateTimePartComponentTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (!MemberMapping.TryGetValue(member, out var part))\n\t\t\treturn null;\n\n\t\tvar result = (SqlExpression)_fbSqlExpressionFactory.SpacedFunction(\n\t\t\t\"EXTRACT\",\n\t\t\tnew[] { _fbSqlExpressionFactory.Fragment(part), _fbSqlExpressionFactory.Fragment(\"FROM\"), instance },\n\t\t\ttrue,\n\t\t\tnew[] { false, false, true },\n\t\t\ttypeof(int));\n\t\tif (part == YearDayPart)\n\t\t{\n\t\t\tresult = _fbSqlExpressionFactory.Add(result, _fbSqlExpressionFactory.Constant(1));\n\t\t}\n\t\telse if (part == SecondPart || part == MillisecondPart)\n\t\t{\n\t\t\tresult = _fbSqlExpressionFactory.Function(\"TRUNC\", new[] { result }, true, new[] { true }, typeof(int));\n\t\t}\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbMathTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbMathTranslator : IMethodCallTranslator\n{\n\tstatic readonly Dictionary<MethodInfo, string> SupportedMethodTranslations = new Dictionary<MethodInfo, string>\n\t\t{\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(decimal) }), \"ABS\" },\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(double) }), \"ABS\" },\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(short) }), \"ABS\" },\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(int) }), \"ABS\" },\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(long) }), \"ABS\" },\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(sbyte) }), \"ABS\" },\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Abs), new[] { typeof(float) }), \"ABS\" },\n\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Ceiling), new[] { typeof(double) }), \"CEILING\" },\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Ceiling), new[] { typeof(decimal) }), \"CEILING\" },\n\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Floor), new[] { typeof(double) }), \"FLOOR\" },\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Floor), new[] { typeof(decimal) }), \"FLOOR\" },\n\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Pow), new[] { typeof(double), typeof(double) }), \"POWER\" },\n\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Exp), new[] { typeof(double) }), \"EXP\" },\n\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Log10), new[] { typeof(double) }), \"LOG10\" },\n\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Log), new[] { typeof(double) }), \"LN\" },\n\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Sqrt), new[] { typeof(double) }), \"SQRT\" },\n\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Acos), new[] { typeof(double) }), \"ACOS\" },\n\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Asin), new[] { typeof(double) }), \"ASIN\" },\n\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Atan), new[] { typeof(double) }), \"ATAN\" },\n\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Atan2), new[] { typeof(double), typeof(double) }), \"ATAN2\" },\n\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Cos), new[] { typeof(double) }), \"COS\" },\n\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Sin), new[] { typeof(double) }), \"SIN\" },\n\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Tan), new[] { typeof(double) }), \"TAN\" },\n\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(float) }), \"SIGN\" },\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(long) }), \"SIGN\" },\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(int) }), \"SIGN\" },\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(sbyte) }), \"SIGN\" },\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(double) }), \"SIGN\" },\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(decimal) }), \"SIGN\" },\n\t\t\t{ typeof(Math).GetRuntimeMethod(nameof(Math.Sign), new[] { typeof(short) }), \"SIGN\" },\n\t\t};\n\n\tstatic readonly HashSet<MethodInfo> TruncateMethodInfos = new HashSet<MethodInfo>\n\t\t{\n\t\t\ttypeof(Math).GetRuntimeMethod(nameof(Math.Truncate), new[] { typeof(decimal) }),\n\t\t\ttypeof(Math).GetRuntimeMethod(nameof(Math.Truncate), new[] { typeof(double) })\n\t\t};\n\n\tstatic readonly HashSet<MethodInfo> RoundMethodInfos = new HashSet<MethodInfo>\n\t\t{\n\t\t\ttypeof(Math).GetRuntimeMethod(nameof(Math.Round), new[] { typeof(decimal) }),\n\t\t\ttypeof(Math).GetRuntimeMethod(nameof(Math.Round), new[] { typeof(double) }),\n\t\t\ttypeof(Math).GetRuntimeMethod(nameof(Math.Round), new[] { typeof(decimal), typeof(int) }),\n\t\t\ttypeof(Math).GetRuntimeMethod(nameof(Math.Round), new[] { typeof(double), typeof(int) })\n\t\t};\n\n\tstatic readonly MethodInfo LogNewBaseMethod = typeof(Math).GetRuntimeMethod(nameof(Math.Log), new[] { typeof(double), typeof(double) });\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbMathTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (SupportedMethodTranslations.TryGetValue(method, out var sqlFunctionName))\n\t\t{\n\t\t\treturn _fbSqlExpressionFactory.Function(sqlFunctionName, arguments, true, arguments.Select(_ => true), method.ReturnType);\n\t\t}\n\t\tif (TruncateMethodInfos.Contains(method))\n\t\t{\n\t\t\treturn _fbSqlExpressionFactory.ApplyDefaultTypeMapping(_fbSqlExpressionFactory.Function(\n\t\t\t\t\"TRUNC\",\n\t\t\t\tnew[] { _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]), _fbSqlExpressionFactory.Constant(0) },\n\t\t\t\ttrue,\n\t\t\t\tnew[] { true, false },\n\t\t\t\tmethod.ReturnType));\n\t\t}\n\t\tif (RoundMethodInfos.Contains(method))\n\t\t{\n\t\t\tvar roundArguments = arguments.Count == 1\n\t\t\t\t? new[] { _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]), _fbSqlExpressionFactory.Constant(0) }\n\t\t\t\t: new[] { _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]), _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[1]) };\n\t\t\tvar nullability = arguments.Count == 1\n\t\t\t\t? new[] { true, false }\n\t\t\t\t: new[] { true, true };\n\t\t\treturn _fbSqlExpressionFactory.ApplyDefaultTypeMapping(_fbSqlExpressionFactory.Function(\n\t\t\t\t\"ROUND\",\n\t\t\t\troundArguments,\n\t\t\t\ttrue,\n\t\t\t\tnullability,\n\t\t\t\tmethod.ReturnType));\n\t\t}\n\t\tif (LogNewBaseMethod == method)\n\t\t{\n\t\t\treturn _fbSqlExpressionFactory.Function(\"LOG\", arguments.Reverse(), true, arguments.Select(_ => true), method.ReturnType);\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbMemberTranslatorProvider.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Utilities;\nusing Microsoft.EntityFrameworkCore.Query;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbMemberTranslatorProvider : RelationalMemberTranslatorProvider\n{\n\tstatic readonly List<Type> Translators = TranslatorsHelper.GetTranslators<IMemberTranslator>().ToList();\n\n\tpublic FbMemberTranslatorProvider(RelationalMemberTranslatorProviderDependencies dependencies)\n\t\t: base(dependencies)\n\t{\n\t\tAddTranslators(Translators.Select(t => (IMemberTranslator)Activator.CreateInstance(t, dependencies.SqlExpressionFactory)));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbMethodCallTranslatorProvider.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Utilities;\nusing Microsoft.EntityFrameworkCore.Query;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbMethodCallTranslatorProvider : RelationalMethodCallTranslatorProvider\n{\n\tstatic readonly List<Type> Translators = TranslatorsHelper.GetTranslators<IMethodCallTranslator>().ToList();\n\n\tpublic FbMethodCallTranslatorProvider(RelationalMethodCallTranslatorProviderDependencies dependencies)\n\t\t: base(dependencies)\n\t{\n\t\tAddTranslators(Translators.Select(t => (IMethodCallTranslator)Activator.CreateInstance(t, dependencies.SqlExpressionFactory)));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbNewGuidTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbNewGuidTranslator : IMethodCallTranslator\n{\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbNewGuidTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (method.DeclaringType == typeof(Guid) && method.Name == nameof(Guid.NewGuid))\n\t\t{\n\t\t\treturn _fbSqlExpressionFactory.Function(\"GEN_UUID\", Array.Empty<SqlExpression>(), false, Array.Empty<bool>(), typeof(Guid));\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbObjectToStringTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbObjectToStringTranslator : IMethodCallTranslator\n{\n\tstatic readonly HashSet<Type> SupportedTypes = new HashSet<Type>\n\t\t{\n\t\t\ttypeof(int),\n\t\t\ttypeof(long),\n\t\t\ttypeof(DateTime),\n\t\t\ttypeof(byte),\n\t\t\ttypeof(byte[]),\n\t\t\ttypeof(double),\n\t\t\ttypeof(char),\n\t\t\ttypeof(short),\n\t\t\ttypeof(float),\n\t\t\ttypeof(decimal),\n\t\t\ttypeof(TimeSpan),\n\t\t\ttypeof(uint),\n\t\t\ttypeof(ushort),\n\t\t\ttypeof(ulong),\n\t\t\ttypeof(sbyte),\n\t\t\ttypeof(DateOnly),\n\t\t\ttypeof(TimeOnly),\n\t\t};\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbObjectToStringTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (instance == null || method.Name != nameof(ToString) || arguments.Count != 0)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\n\t\tif (instance.TypeMapping?.ClrType == typeof(string))\n\t\t{\n\t\t\treturn instance;\n\t\t}\n\n\t\tif (SupportedTypes.Contains(instance.Type))\n\t\t{\n\t\t\treturn _fbSqlExpressionFactory.Convert(instance, typeof(string));\n\t\t}\n\t\telse if (instance.Type == typeof(Guid))\n\t\t{\n\t\t\treturn _fbSqlExpressionFactory.Function(\"UUID_TO_CHAR\", new[] { instance }, true, new[] { true }, typeof(string));\n\t\t}\n\t\telse if (instance.Type == typeof(bool))\n\t\t{\n\t\t\tif (instance is not ColumnExpression { IsNullable: false })\n\t\t\t{\n\t\t\t\treturn _fbSqlExpressionFactory.Case(\n\t\t\t\t\tinstance,\n\t\t\t\t\tnew[]\n\t\t\t\t\t{\n\t\t\t\t\t\tnew CaseWhenClause(\n\t\t\t\t\t\t\t_fbSqlExpressionFactory.Constant(false),\n\t\t\t\t\t\t\t_fbSqlExpressionFactory.Constant(false.ToString())),\n\t\t\t\t\t\tnew CaseWhenClause(\n\t\t\t\t\t\t\t_fbSqlExpressionFactory.Constant(true),\n\t\t\t\t\t\t\t_fbSqlExpressionFactory.Constant(true.ToString()))\n\t\t\t\t\t},\n\t\t\t\t\t_fbSqlExpressionFactory.Constant(string.Empty));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn _fbSqlExpressionFactory.Case(\n\t\t\t\t\tnew[]\n\t\t\t\t\t{\n\t\t\t\t\t\tnew CaseWhenClause(\n\t\t\t\t\t\t\tinstance,\n\t\t\t\t\t\t\t_fbSqlExpressionFactory.Constant(true.ToString()))\n\t\t\t\t\t},\n\t\t\t\t\t_fbSqlExpressionFactory.Constant(false.ToString()));\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbStringContainsTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbStringContainsTranslator : IMethodCallTranslator\n{\n\tstatic readonly MethodInfo MethodInfo = typeof(string).GetRuntimeMethod(nameof(string.Contains), new[] { typeof(string) });\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbStringContainsTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (!method.Equals(MethodInfo))\n\t\t\treturn null;\n\n\t\tvar patternExpression = _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]);\n\t\tvar positionExpression = _fbSqlExpressionFactory.GreaterThan(\n\t\t\t_fbSqlExpressionFactory.Function(\n\t\t\t\t\"POSITION\",\n\t\t\t\tnew[] { patternExpression, instance },\n\t\t\t\ttrue,\n\t\t\t\tnew[] { true, true },\n\t\t\t\ttypeof(int)),\n\t\t\t_fbSqlExpressionFactory.Constant(0));\n\t\tvar matchingExpression = patternExpression is SqlConstantExpression sqlConstantExpression\n\t\t\t? ((string)sqlConstantExpression.Value)?.Length == 0\n\t\t\t\t? (SqlExpression)_fbSqlExpressionFactory.Constant(true)\n\t\t\t\t: (SqlExpression)positionExpression\n\t\t\t: _fbSqlExpressionFactory.OrElse(\n\t\t\t\tpositionExpression,\n\t\t\t\t_fbSqlExpressionFactory.Equal(\n\t\t\t\t\t_fbSqlExpressionFactory.Function(\"CHAR_LENGTH\", new[] { patternExpression }, true, new[] { true }, typeof(int)),\n\t\t\t\t\t_fbSqlExpressionFactory.Constant(0)));\n\t\treturn _fbSqlExpressionFactory.AndAlso(matchingExpression, _fbSqlExpressionFactory.AndAlso(_fbSqlExpressionFactory.IsNotNull(instance), _fbSqlExpressionFactory.IsNotNull(patternExpression)));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbStringEndsWithTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\nclass FbStringEndsWithTranslator : IMethodCallTranslator\n{\n\tstatic readonly MethodInfo MethodInfo = typeof(string).GetRuntimeMethod(nameof(string.EndsWith), new[] { typeof(string) });\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbStringEndsWithTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (!method.Equals(MethodInfo))\n\t\t\treturn null;\n\n\t\tvar patternExpression = _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]);\n\t\tvar endsWithExpression = _fbSqlExpressionFactory.Equal(\n\t\t\t_fbSqlExpressionFactory.ApplyDefaultTypeMapping(_fbSqlExpressionFactory.Function(\n\t\t\t\t\t\"RIGHT\",\n\t\t\t\t\tnew[] {\n\t\t\t\t\t\t\tinstance,\n\t\t\t\t\t\t\t_fbSqlExpressionFactory.Function(\n\t\t\t\t\t\t\t\t\"CHAR_LENGTH\",\n\t\t\t\t\t\t\t\tnew[] { patternExpression },\n\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\tnew[] { true },\n\t\t\t\t\t\t\t\ttypeof(int)) },\n\t\t\t\t\ttrue,\n\t\t\t\t\tnew[] { true, true },\n\t\t\t\t\tinstance.Type)),\n\t\t\tpatternExpression);\n\t\tvar matchingExpression = patternExpression is SqlConstantExpression sqlConstantExpression\n\t\t\t? (SqlExpression)((string)sqlConstantExpression.Value == string.Empty ? (SqlExpression)_fbSqlExpressionFactory.Constant(true) : endsWithExpression)\n\t\t\t: (SqlExpression)_fbSqlExpressionFactory.OrElse(\n\t\t\t\tendsWithExpression,\n\t\t\t\t_fbSqlExpressionFactory.Equal(\n\t\t\t\t\t_fbSqlExpressionFactory.Function(\"CHAR_LENGTH\", new[] { patternExpression }, true, new[] { true }, typeof(int)),\n\t\t\t\t\t_fbSqlExpressionFactory.Constant(0)));\n\t\treturn _fbSqlExpressionFactory.AndAlso(matchingExpression, _fbSqlExpressionFactory.AndAlso(_fbSqlExpressionFactory.IsNotNull(instance), _fbSqlExpressionFactory.IsNotNull(patternExpression)));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbStringFirstOrDefaultTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbStringFirstOrDefaultTranslator : IMethodCallTranslator\n{\n\tstatic readonly MethodInfo MethodInfo = typeof(Enumerable).GetRuntimeMethods()\n\t\t.Single(m => m.Name == nameof(Enumerable.FirstOrDefault) && m.GetParameters().Length == 1)\n\t\t.MakeGenericMethod(typeof(char));\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbStringFirstOrDefaultTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (!method.Equals(MethodInfo))\n\t\t\treturn null;\n\n\t\tvar argument = _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]);\n\t\treturn _fbSqlExpressionFactory.Function(\n\t\t\t\"LEFT\",\n\t\t\tnew[] { argument, _fbSqlExpressionFactory.Constant(1) },\n\t\t\ttrue,\n\t\t\tnew[] { true, false },\n\t\t\tmethod.ReturnType);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbStringIndexOfTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbStringIndexOfTranslator : IMethodCallTranslator\n{\n\tstatic readonly MethodInfo IndexOfMethodInfo\n\t   = typeof(string).GetRuntimeMethod(nameof(string.IndexOf), new[] { typeof(string) });\n\n\tstatic readonly MethodInfo IndexOfMethodInfoWithStartingPosition\n\t\t= typeof(string).GetRuntimeMethod(nameof(string.IndexOf), new[] { typeof(string), typeof(int) });\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbStringIndexOfTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (method.Equals(IndexOfMethodInfo))\n\t\t{\n\t\t\tvar args = new List<SqlExpression>();\n\t\t\targs.Add(_fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]));\n\t\t\targs.Add(instance);\n\t\t\treturn _fbSqlExpressionFactory.Subtract(\n\t\t\t\t_fbSqlExpressionFactory.Function(\"POSITION\", args, true, Enumerable.Repeat(true, args.Count), typeof(int)),\n\t\t\t\t_fbSqlExpressionFactory.Constant(1));\n\t\t}\n\t\tif (method.Equals(IndexOfMethodInfoWithStartingPosition))\n\t\t{\n\t\t\tvar args = new List<SqlExpression>();\n\t\t\targs.Add(_fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]));\n\t\t\targs.Add(instance);\n\t\t\targs.Add(_fbSqlExpressionFactory.Add(arguments[1], _fbSqlExpressionFactory.Constant(1)));\n\t\t\treturn _fbSqlExpressionFactory.Subtract(\n\t\t\t\t_fbSqlExpressionFactory.Function(\"POSITION\", args, true, Enumerable.Repeat(true, args.Count), typeof(int)),\n\t\t\t\t_fbSqlExpressionFactory.Constant(1));\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbStringIsNullOrWhiteSpaceTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbStringIsNullOrWhiteSpaceTranslator : IMethodCallTranslator\n{\n\tstatic readonly MethodInfo IsNullOrWhiteSpaceMethod = typeof(string).GetRuntimeMethod(nameof(string.IsNullOrWhiteSpace), new[] { typeof(string) });\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbStringIsNullOrWhiteSpaceTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (!method.Equals(IsNullOrWhiteSpaceMethod))\n\t\t\treturn null;\n\n\t\tvar argument = _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]);\n\t\treturn _fbSqlExpressionFactory.OrElse(\n\t\t\t_fbSqlExpressionFactory.IsNull(argument),\n\t\t\t_fbSqlExpressionFactory.Equal(\n\t\t\t\t_fbSqlExpressionFactory.Function(\"CHAR_LENGTH\", new[] {\n\t\t\t\t\t\t_fbSqlExpressionFactory.Function(\"TRIM\", new[] { argument }, true, new[] { true }, typeof(string)) }, true, new[] { true }, typeof(int)),\n\t\t\t\t\t_fbSqlExpressionFactory.Constant(0))\n\t\t\t);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbStringLastOrDefaultTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbStringLastOrDefaultTranslator : IMethodCallTranslator\n{\n\tstatic readonly MethodInfo MethodInfo = typeof(Enumerable).GetRuntimeMethods()\n\t\t.Single(m => m.Name == nameof(Enumerable.LastOrDefault) && m.GetParameters().Length == 1)\n\t\t.MakeGenericMethod(typeof(char));\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbStringLastOrDefaultTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (!method.Equals(MethodInfo))\n\t\t\treturn null;\n\n\t\tvar argument = _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]);\n\t\treturn _fbSqlExpressionFactory.Function(\n\t\t\t\"RIGHT\",\n\t\t\tnew[] { argument, _fbSqlExpressionFactory.Constant(1) },\n\t\t\ttrue,\n\t\t\tnew[] { true, false },\n\t\t\tmethod.ReturnType);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbStringLengthTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbStringLengthTranslator : IMemberTranslator\n{\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbStringLengthTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (member.DeclaringType == typeof(string) && member.Name == nameof(string.Length))\n\t\t{\n\t\t\treturn _fbSqlExpressionFactory.Function(\"CHAR_LENGTH\", new[] { instance }, true, new[] { true }, typeof(int));\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbStringReplaceTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbStringReplaceTranslator : IMethodCallTranslator\n{\n\tstatic readonly MethodInfo ReplaceMethod = typeof(string).GetRuntimeMethod(nameof(string.Replace), new[] { typeof(string), typeof(string) });\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbStringReplaceTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (!method.Equals(ReplaceMethod))\n\t\t\treturn null;\n\n\t\tvar args = new List<SqlExpression>();\n\t\targs.Add(instance);\n\t\tforeach (var a in arguments)\n\t\t{\n\t\t\targs.Add(_fbSqlExpressionFactory.ApplyDefaultTypeMapping(a));\n\t\t}\n\t\treturn _fbSqlExpressionFactory.ApplyDefaultTypeMapping(\n\t\t\t_fbSqlExpressionFactory.Function(\"REPLACE\", args, true, Enumerable.Repeat(true, args.Count), instance.Type));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbStringStartsWithTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbStringStartsWithTranslator : IMethodCallTranslator\n{\n\tstatic readonly MethodInfo StartsWithMethod = typeof(string).GetRuntimeMethod(nameof(string.StartsWith), new[] { typeof(string) });\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbStringStartsWithTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (!method.Equals(StartsWithMethod))\n\t\t\treturn null;\n\n\t\tvar patternExpression = _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]);\n\t\tvar patternConstantExpression = patternExpression as SqlConstantExpression;\n\t\tvar likePatternExpression = patternConstantExpression != null\n\t\t\t? (SqlExpression)_fbSqlExpressionFactory.Constant(((string)patternConstantExpression.Value) + \"%\")\n\t\t\t: (SqlExpression)_fbSqlExpressionFactory.Add(patternExpression, _fbSqlExpressionFactory.Constant(\"%\"));\n\t\tvar startsWithExpression = _fbSqlExpressionFactory.AndAlso(\n\t\t\t_fbSqlExpressionFactory.Like(\n\t\t\t\tinstance,\n\t\t\t\tlikePatternExpression),\n\t\t\t_fbSqlExpressionFactory.Equal(\n\t\t\t\t_fbSqlExpressionFactory.ApplyDefaultTypeMapping(_fbSqlExpressionFactory.Function(\n\t\t\t\t\t\"LEFT\",\n\t\t\t\t\tnew[] {\n\t\t\t\t\t\t\tinstance,\n\t\t\t\t\t\t\t_fbSqlExpressionFactory.Function(\n\t\t\t\t\t\t\t\t\"CHAR_LENGTH\",\n\t\t\t\t\t\t\t\tnew[] { patternExpression },\n\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\tnew[] { true },\n\t\t\t\t\t\t\t\ttypeof(int)) },\n\t\t\t\t\ttrue,\n\t\t\t\t\tnew[] { true, true },\n\t\t\t\t\tinstance.Type)),\n\t\t\t\tpatternExpression));\n\t\tvar matchingExpression = patternConstantExpression != null\n\t\t\t? (SqlExpression)((string)patternConstantExpression.Value == string.Empty ? _fbSqlExpressionFactory.Constant(true) : startsWithExpression)\n\t\t\t: (SqlExpression)_fbSqlExpressionFactory.OrElse(\n\t\t\t\tstartsWithExpression,\n\t\t\t\t_fbSqlExpressionFactory.Equal(\n\t\t\t\t\t_fbSqlExpressionFactory.Function(\"CHAR_LENGTH\", new[] { patternExpression }, true, new[] { true }, typeof(int)),\n\t\t\t\t\t_fbSqlExpressionFactory.Constant(0)));\n\t\treturn _fbSqlExpressionFactory.AndAlso(matchingExpression, _fbSqlExpressionFactory.AndAlso(_fbSqlExpressionFactory.IsNotNull(instance), _fbSqlExpressionFactory.IsNotNull(patternExpression)));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbStringSubstringTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbStringSubstringTranslator : IMethodCallTranslator\n{\n\tstatic readonly MethodInfo SubstringOnlyStartMethod = typeof(string).GetRuntimeMethod(nameof(string.Substring), new[] { typeof(int) });\n\tstatic readonly MethodInfo SubstringStartAndLengthMethod = typeof(string).GetRuntimeMethod(nameof(string.Substring), new[] { typeof(int), typeof(int) });\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbStringSubstringTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (!(method.Equals(SubstringOnlyStartMethod) || method.Equals(SubstringStartAndLengthMethod)))\n\t\t\treturn null;\n\n\t\tvar fromExpression = _fbSqlExpressionFactory.ApplyDefaultTypeMapping(_fbSqlExpressionFactory.Add(arguments[0], _fbSqlExpressionFactory.Constant(1)));\n\t\tvar forExpression = arguments.Count == 2 ? _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[1]) : null;\n\t\tvar substringArguments = forExpression != null\n\t\t\t? new[] { instance, _fbSqlExpressionFactory.Fragment(\"FROM\"), fromExpression, _fbSqlExpressionFactory.Fragment(\"FOR\"), forExpression }\n\t\t\t: new[] { instance, _fbSqlExpressionFactory.Fragment(\"FROM\"), fromExpression };\n\t\tvar nullability = forExpression != null\n\t\t\t? new[] { true, false, true, false, true }\n\t\t\t: new[] { true, false, true };\n\t\treturn _fbSqlExpressionFactory.SpacedFunction(\n\t\t\t\"SUBSTRING\",\n\t\t\tsubstringArguments,\n\t\t\ttrue,\n\t\t\tnullability,\n\t\t\ttypeof(string));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbStringToLowerTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbStringToLowerTranslator : IMethodCallTranslator\n{\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbStringToLowerTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (method.DeclaringType == typeof(string) && method.Name == nameof(string.ToLower))\n\t\t{\n\t\t\treturn _fbSqlExpressionFactory.Function(\"LOWER\", new[] { instance }, true, new[] { true }, typeof(string));\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbStringToUpperTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbStringToUpperTranslator : IMethodCallTranslator\n{\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbStringToUpperTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (method.DeclaringType == typeof(string) && method.Name == nameof(string.ToUpper))\n\t\t{\n\t\t\treturn _fbSqlExpressionFactory.Function(\"UPPER\", new[] { instance }, true, new[] { true }, typeof(string));\n\t\t}\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbStringTrimTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbStringTrimTranslator : IMethodCallTranslator\n{\n\tstatic readonly MethodInfo TrimWithoutArgsMethod = typeof(string).GetRuntimeMethod(nameof(string.Trim), new Type[] { });\n\tstatic readonly MethodInfo TrimWithCharArgMethod = typeof(string).GetRuntimeMethod(nameof(string.Trim), new[] { typeof(char) });\n\tstatic readonly MethodInfo TrimEndWithoutArgsMethod = typeof(string).GetRuntimeMethod(nameof(string.TrimEnd), new Type[] { });\n\tstatic readonly MethodInfo TrimEndWithCharArgMethod = typeof(string).GetRuntimeMethod(nameof(string.TrimEnd), new[] { typeof(char) });\n\tstatic readonly MethodInfo TrimStartWithoutArgsMethod = typeof(string).GetRuntimeMethod(nameof(string.TrimStart), new Type[] { });\n\tstatic readonly MethodInfo TrimStartWithCharArgMethod = typeof(string).GetRuntimeMethod(nameof(string.TrimStart), new[] { typeof(char) });\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbStringTrimTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (!TryGetTrimDefinition(instance, method, arguments, out var trimArguments, out var nullability))\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\treturn _fbSqlExpressionFactory.SpacedFunction(\n\t\t\t\"TRIM\",\n\t\t\ttrimArguments,\n\t\t\ttrue,\n\t\t\tnullability,\n\t\t\ttypeof(string));\n\t}\n\n\tbool TryGetTrimDefinition(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, out IEnumerable<SqlExpression> trimArguments, out IEnumerable<bool> nullability)\n\t{\n\t\tif (method.Equals(TrimWithoutArgsMethod))\n\t\t{\n\t\t\ttrimArguments = new[] { _fbSqlExpressionFactory.Fragment(\"BOTH\"), _fbSqlExpressionFactory.Fragment(\"FROM\"), instance };\n\t\t\tnullability = new[] { false, false, true };\n\t\t\treturn true;\n\t\t}\n\t\tif (method.Equals(TrimWithCharArgMethod))\n\t\t{\n\t\t\ttrimArguments = new[] { _fbSqlExpressionFactory.Fragment(\"BOTH\"), _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]), _fbSqlExpressionFactory.Fragment(\"FROM\"), instance };\n\t\t\tnullability = new[] { false, true, false, true };\n\t\t\treturn true;\n\t\t}\n\t\tif (method.Equals(TrimEndWithoutArgsMethod))\n\t\t{\n\t\t\ttrimArguments = new[] { _fbSqlExpressionFactory.Fragment(\"TRAILING\"), _fbSqlExpressionFactory.Fragment(\"FROM\"), instance };\n\t\t\tnullability = new[] { false, false, true };\n\t\t\treturn true;\n\t\t}\n\t\tif (method.Equals(TrimEndWithCharArgMethod))\n\t\t{\n\t\t\ttrimArguments = new[] { _fbSqlExpressionFactory.Fragment(\"TRAILING\"), _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]), _fbSqlExpressionFactory.Fragment(\"FROM\"), instance };\n\t\t\tnullability = new[] { false, true, false, true };\n\t\t\treturn true;\n\t\t}\n\t\tif (method.Equals(TrimStartWithoutArgsMethod))\n\t\t{\n\t\t\ttrimArguments = new[] { _fbSqlExpressionFactory.Fragment(\"LEADING\"), _fbSqlExpressionFactory.Fragment(\"FROM\"), instance };\n\t\t\tnullability = new[] { false, false, true };\n\t\t\treturn true;\n\t\t}\n\t\tif (method.Equals(TrimStartWithCharArgMethod))\n\t\t{\n\t\t\ttrimArguments = new[] { _fbSqlExpressionFactory.Fragment(\"LEADING\"), _fbSqlExpressionFactory.ApplyDefaultTypeMapping(arguments[0]), _fbSqlExpressionFactory.Fragment(\"FROM\"), instance };\n\t\t\tnullability = new[] { false, true, false, true };\n\t\t\treturn true;\n\t\t}\n\t\ttrimArguments = default;\n\t\tnullability = default;\n\t\treturn false;\n\t}\n\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbTimeOnlyMethodTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbTimeOnlyMethodTranslator : IMethodCallTranslator\n{\n\tstatic readonly MethodInfo FromDateTime = typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.FromDateTime), [typeof(DateTime)]);\n\tstatic readonly MethodInfo FromTimeSpan = typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.FromTimeSpan), [typeof(TimeSpan)]);\n\n\treadonly ISqlExpressionFactory _sqlExpressionFactory;\n\n\tpublic FbTimeOnlyMethodTranslator(ISqlExpressionFactory sqlExpressionFactory)\n\t{\n\t\t_sqlExpressionFactory = sqlExpressionFactory;\n\t}\n\n\tpublic virtual SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList<SqlExpression> arguments, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (method.DeclaringType != typeof(TimeOnly))\n\t\t{\n\t\t\treturn null;\n\t\t}\n\n\t\tif ((method == FromDateTime || method == FromTimeSpan) && instance is null && arguments.Count == 1)\n\t\t{\n\t\t\treturn _sqlExpressionFactory.Convert(arguments[0], typeof(TimeOnly));\n\t\t}\n\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbTimeOnlyPartComponentTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Expressions.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbTimeOnlyPartComponentTranslator : IMemberTranslator\n{\n\tconst string SecondPart = \"SECOND\";\n\tconst string MillisecondPart = \"MILLISECOND\";\n\tprivate static readonly Dictionary<MemberInfo, string> MemberMapping = new Dictionary<MemberInfo, string>\n\t\t{\n\t\t\t{  typeof(TimeOnly).GetProperty(nameof(TimeOnly.Hour)), \"HOUR\" },\n\t\t\t{  typeof(TimeOnly).GetProperty(nameof(TimeOnly.Minute)), \"MINUTE\" },\n\t\t\t{  typeof(TimeOnly).GetProperty(nameof(TimeOnly.Second)), SecondPart },\n\t\t\t{  typeof(TimeOnly).GetProperty(nameof(TimeOnly.Millisecond)), MillisecondPart },\n\t\t};\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbTimeOnlyPartComponentTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (!MemberMapping.TryGetValue(member, out var part))\n\t\t\treturn null;\n\n\t\tvar result = (SqlExpression)_fbSqlExpressionFactory.SpacedFunction(\n\t\t\t\"EXTRACT\",\n\t\t\tnew[] { _fbSqlExpressionFactory.Fragment(part), _fbSqlExpressionFactory.Fragment(\"FROM\"), instance },\n\t\t\ttrue,\n\t\t\tnew[] { false, false, true },\n\t\t\ttypeof(int));\n\t\tif (part == SecondPart || part == MillisecondPart)\n\t\t{\n\t\t\tresult = _fbSqlExpressionFactory.Function(\"TRUNC\", new[] { result }, true, new[] { true }, typeof(int));\n\t\t}\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/ExpressionTranslators/Internal/FbTimeSpanPartComponentTranslator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.ExpressionTranslators.Internal;\n\npublic class FbTimeSpanPartComponentTranslator : IMemberTranslator\n{\n\tconst string SecondPart = \"SECOND\";\n\tconst string MillisecondPart = \"MILLISECOND\";\n\tprivate static readonly Dictionary<MemberInfo, string> MemberMapping = new Dictionary<MemberInfo, string>\n\t\t{\n\t\t\t{  typeof(TimeSpan).GetProperty(nameof(TimeSpan.Hours)), \"HOUR\" },\n\t\t\t{  typeof(TimeSpan).GetProperty(nameof(TimeSpan.Minutes)), \"MINUTE\" },\n\t\t\t{  typeof(TimeSpan).GetProperty(nameof(TimeSpan.Seconds)), SecondPart },\n\t\t\t{  typeof(TimeSpan).GetProperty(nameof(TimeSpan.Milliseconds)), MillisecondPart },\n\t\t};\n\n\treadonly FbSqlExpressionFactory _fbSqlExpressionFactory;\n\n\tpublic FbTimeSpanPartComponentTranslator(FbSqlExpressionFactory fbSqlExpressionFactory)\n\t{\n\t\t_fbSqlExpressionFactory = fbSqlExpressionFactory;\n\t}\n\n\tpublic SqlExpression Translate(SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger<DbLoggerCategory.Query> logger)\n\t{\n\t\tif (!MemberMapping.TryGetValue(member, out var part))\n\t\t\treturn null;\n\n\t\tvar result = (SqlExpression)_fbSqlExpressionFactory.SpacedFunction(\n\t\t\t\"EXTRACT\",\n\t\t\tnew[] { _fbSqlExpressionFactory.Fragment(part), _fbSqlExpressionFactory.Fragment(\"FROM\"), instance },\n\t\t\ttrue,\n\t\t\tnew[] { false, false, true },\n\t\t\ttypeof(int));\n\t\tif (part == SecondPart || part == MillisecondPart)\n\t\t{\n\t\t\tresult = _fbSqlExpressionFactory.Function(\"TRUNC\", new[] { result }, true, new[] { true }, typeof(int));\n\t\t}\n\t\treturn result;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/Expressions/Internal/FbSpacedFunctionExpression.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.Expressions.Internal;\n\npublic class FbSpacedFunctionExpression : SqlFunctionExpression, IEquatable<FbSpacedFunctionExpression>\n{\n\tpublic FbSpacedFunctionExpression(string name, IEnumerable<SqlExpression> arguments, bool nullable, IEnumerable<bool> argumentsPropagateNullability, Type type, RelationalTypeMapping typeMapping)\n\t\t: base(name, arguments, nullable, argumentsPropagateNullability, type, typeMapping)\n\t{ }\n\n\tpublic override SqlFunctionExpression ApplyTypeMapping(RelationalTypeMapping typeMapping)\n\t{\n\t\treturn new FbSpacedFunctionExpression(Name, Arguments, IsNullable, ArgumentsPropagateNullability, Type, typeMapping ?? TypeMapping);\n\t}\n\n\tprotected override Expression VisitChildren(ExpressionVisitor visitor)\n\t{\n\t\tvar changed = false;\n\n\t\tvar arguments = new SqlExpression[Arguments.Count];\n\t\tfor (var i = 0; i < arguments.Length; i++)\n\t\t{\n\t\t\targuments[i] = (SqlExpression)visitor.Visit(Arguments[i]);\n\t\t\tchanged |= arguments[i] != Arguments[i];\n\t\t}\n\n\t\treturn changed\n\t\t\t? new FbSpacedFunctionExpression(Name, arguments, IsNullable, ArgumentsPropagateNullability, Type, TypeMapping)\n\t\t\t: this;\n\t}\n\n\tpublic override SqlFunctionExpression Update(SqlExpression instance, IReadOnlyList<SqlExpression> arguments)\n\t{\n\t\tif (instance != null)\n\t\t\tthrow new ArgumentException(\"Instance must be null.\", nameof(instance));\n\n\t\treturn !arguments.SequenceEqual(Arguments)\n\t\t\t? new FbSpacedFunctionExpression(Name, arguments, IsNullable, ArgumentsPropagateNullability, Type, TypeMapping)\n\t\t\t: this;\n\t}\n\n\tpublic override bool Equals(object obj)\n\t{\n\t\treturn obj != null\n\t\t\t&& (ReferenceEquals(this, obj)\n\t\t\t\t|| obj is FbSpacedFunctionExpression fbExtraFunctionExpression\n\t\t\t\t&& Equals(fbExtraFunctionExpression));\n\t}\n\n\tpublic virtual bool Equals(FbSpacedFunctionExpression other)\n\t{\n\t\treturn base.Equals(other);\n\t}\n\n\tpublic override int GetHashCode()\n\t{\n\t\treturn base.GetHashCode();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/Internal/FbQueryRootProcessor.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Linq.Expressions;\nusing Microsoft.EntityFrameworkCore.Query;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\n\npublic class FbQueryRootProcessor : RelationalQueryRootProcessor\n{\n\tpublic FbQueryRootProcessor(QueryTranslationPreprocessorDependencies dependencies, RelationalQueryTranslationPreprocessorDependencies relationalDependencies, QueryCompilationContext queryCompilationContext)\n\t\t: base(dependencies, relationalDependencies, queryCompilationContext)\n\t{ }\n\n\tprotected override bool ShouldConvertToParameterQueryRoot(QueryParameterExpression constantExpression)\n\t{\n\t\treturn false;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/Internal/FbQuerySqlGenerator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Expressions.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\n\npublic class FbQuerySqlGenerator : QuerySqlGenerator\n{\n\treadonly IFbOptions _fbOptions;\n\n\tpublic FbQuerySqlGenerator(QuerySqlGeneratorDependencies dependencies, IFbOptions fbOptions)\n\t\t: base(dependencies)\n\t{\n\t\t_fbOptions = fbOptions;\n\t}\n\n\tprotected override Expression VisitSqlUnary(SqlUnaryExpression sqlUnaryExpression)\n\t{\n\t\tif (sqlUnaryExpression.OperatorType == ExpressionType.Not && sqlUnaryExpression.TypeMapping.ClrType != typeof(bool))\n\t\t{\n\t\t\tSql.Append(\"BIN_NOT(\");\n\t\t\tVisit(sqlUnaryExpression.Operand);\n\t\t\tSql.Append(\")\");\n\t\t\treturn sqlUnaryExpression;\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn base.VisitSqlUnary(sqlUnaryExpression);\n\t\t}\n\t}\n\n\tprotected override Expression VisitSqlBinary(SqlBinaryExpression sqlBinaryExpression)\n\t{\n\t\tif (sqlBinaryExpression.OperatorType == ExpressionType.Modulo)\n\t\t{\n\t\t\tSql.Append(\"MOD(\");\n\t\t\tVisit(sqlBinaryExpression.Left);\n\t\t\tSql.Append(\", \");\n\t\t\tVisit(sqlBinaryExpression.Right);\n\t\t\tSql.Append(\")\");\n\t\t\treturn sqlBinaryExpression;\n\t\t}\n\t\telse if (sqlBinaryExpression.OperatorType == ExpressionType.And)\n\t\t{\n\t\t\tif (sqlBinaryExpression.TypeMapping.ClrType == typeof(bool))\n\t\t\t{\n\t\t\t\tSql.Append(\"IIF(BIN_AND(\");\n\t\t\t\tBooleanToIntegralAndVisit(sqlBinaryExpression.Left);\n\t\t\t\tSql.Append(\", \");\n\t\t\t\tBooleanToIntegralAndVisit(sqlBinaryExpression.Right);\n\t\t\t\tSql.Append(\") = 0, FALSE, TRUE)\");\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tSql.Append(\"BIN_AND(\");\n\t\t\t\tVisit(sqlBinaryExpression.Left);\n\t\t\t\tSql.Append(\", \");\n\t\t\t\tVisit(sqlBinaryExpression.Right);\n\t\t\t\tSql.Append(\")\");\n\t\t\t}\n\t\t\treturn sqlBinaryExpression;\n\t\t}\n\t\telse if (sqlBinaryExpression.OperatorType == ExpressionType.Or)\n\t\t{\n\t\t\tif (sqlBinaryExpression.TypeMapping.ClrType == typeof(bool))\n\t\t\t{\n\t\t\t\tSql.Append(\"IIF(BIN_OR(\");\n\t\t\t\tBooleanToIntegralAndVisit(sqlBinaryExpression.Left);\n\t\t\t\tSql.Append(\", \");\n\t\t\t\tBooleanToIntegralAndVisit(sqlBinaryExpression.Right);\n\t\t\t\tSql.Append(\") = 0, FALSE, TRUE)\");\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tSql.Append(\"BIN_OR(\");\n\t\t\t\tVisit(sqlBinaryExpression.Left);\n\t\t\t\tSql.Append(\", \");\n\t\t\t\tVisit(sqlBinaryExpression.Right);\n\t\t\t\tSql.Append(\")\");\n\t\t\t}\n\t\t\treturn sqlBinaryExpression;\n\t\t}\n\t\telse if (sqlBinaryExpression.OperatorType == ExpressionType.ExclusiveOr)\n\t\t{\n\t\t\tif (sqlBinaryExpression.TypeMapping.ClrType == typeof(bool))\n\t\t\t{\n\t\t\t\tSql.Append(\"IIF(BIN_XOR(\");\n\t\t\t\tBooleanToIntegralAndVisit(sqlBinaryExpression.Left);\n\t\t\t\tSql.Append(\", \");\n\t\t\t\tBooleanToIntegralAndVisit(sqlBinaryExpression.Right);\n\t\t\t\tSql.Append(\") = 0, FALSE, TRUE)\");\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tSql.Append(\"BIN_XOR(\");\n\t\t\t\tVisit(sqlBinaryExpression.Left);\n\t\t\t\tSql.Append(\", \");\n\t\t\t\tVisit(sqlBinaryExpression.Right);\n\t\t\t\tSql.Append(\")\");\n\t\t\t}\n\t\t\treturn sqlBinaryExpression;\n\t\t}\n\t\telse if (sqlBinaryExpression.OperatorType == ExpressionType.LeftShift)\n\t\t{\n\t\t\tSql.Append(\"BIN_SHL(\");\n\t\t\tVisit(sqlBinaryExpression.Left);\n\t\t\tSql.Append(\", \");\n\t\t\tVisit(sqlBinaryExpression.Right);\n\t\t\tSql.Append(\")\");\n\t\t\treturn sqlBinaryExpression;\n\t\t}\n\t\telse if (sqlBinaryExpression.OperatorType == ExpressionType.RightShift)\n\t\t{\n\t\t\tSql.Append(\"BIN_SHR(\");\n\t\t\tVisit(sqlBinaryExpression.Left);\n\t\t\tSql.Append(\", \");\n\t\t\tVisit(sqlBinaryExpression.Right);\n\t\t\tSql.Append(\")\");\n\t\t\treturn sqlBinaryExpression;\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn base.VisitSqlBinary(sqlBinaryExpression);\n\t\t}\n\n\t\tvoid BooleanToIntegralAndVisit(SqlExpression expression)\n\t\t{\n\t\t\tSql.Append(\"IIF(\");\n\t\t\tVisit(expression);\n\t\t\tSql.Append(\", 1, 0)\");\n\t\t}\n\t}\n\n\tprotected override Expression VisitSqlParameter(SqlParameterExpression sqlParameterExpression)\n\t{\n\t\tvar shouldExplicitParameterTypes = _fbOptions.ExplicitParameterTypes;\n\t\tif (shouldExplicitParameterTypes)\n\t\t{\n\t\t\tSql.Append(\"CAST(\");\n\t\t}\n\t\tbase.VisitSqlParameter(sqlParameterExpression);\n\t\tif (shouldExplicitParameterTypes)\n\t\t{\n\t\t\tSql.Append(\" AS \");\n\t\t\tif (sqlParameterExpression.Type == typeof(string))\n\t\t\t{\n\t\t\t\tvar isUnicode = FbTypeMappingSource.IsUnicode(sqlParameterExpression.TypeMapping);\n\t\t\t\tSql.Append(((IFbSqlGenerationHelper)Dependencies.SqlGenerationHelper).StringParameterQueryType(isUnicode));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tSql.Append(sqlParameterExpression.TypeMapping.StoreType);\n\t\t\t}\n\t\t\tSql.Append(\")\");\n\t\t}\n\t\treturn sqlParameterExpression;\n\t}\n\n\tprotected override Expression VisitSqlConstant(SqlConstantExpression sqlConstantExpression)\n\t{\n\t\tvar shouldExplicitStringLiteralTypes = _fbOptions.ExplicitStringLiteralTypes && sqlConstantExpression.Type == typeof(string);\n\t\tif (shouldExplicitStringLiteralTypes)\n\t\t{\n\t\t\tSql.Append(\"CAST(\");\n\t\t}\n\t\tbase.VisitSqlConstant(sqlConstantExpression);\n\t\tif (shouldExplicitStringLiteralTypes)\n\t\t{\n\t\t\tvar isUnicode = FbTypeMappingSource.IsUnicode(sqlConstantExpression.TypeMapping);\n\t\t\tSql.Append(\" AS \");\n\t\t\tSql.Append(((IFbSqlGenerationHelper)Dependencies.SqlGenerationHelper).StringLiteralQueryType(sqlConstantExpression.Value as string, isUnicode));\n\t\t\tSql.Append(\")\");\n\t\t}\n\t\treturn sqlConstantExpression;\n\t}\n\n\tprotected override void GenerateEmptyProjection(SelectExpression selectExpression)\n\t{\n\t\tSql.Append(\"1 AS dummy\");\n\t}\n\n\tprotected override void GenerateTop(SelectExpression selectExpression)\n\t{\n\t\t// handled by GenerateLimitOffset\n\t}\n\n\tprotected override void GenerateLimitOffset(SelectExpression selectExpression)\n\t{\n\t\tif (selectExpression.Limit != null && selectExpression.Offset != null)\n\t\t{\n\t\t\tSql.AppendLine();\n\t\t\tSql.Append(\"ROWS (\");\n\t\t\tVisit(selectExpression.Offset);\n\t\t\tSql.Append(\" + 1) TO (\");\n\t\t\tVisit(selectExpression.Offset);\n\t\t\tSql.Append(\" + \");\n\t\t\tVisit(selectExpression.Limit);\n\t\t\tSql.Append(\")\");\n\t\t}\n\t\telse if (selectExpression.Limit != null && selectExpression.Offset == null)\n\t\t{\n\t\t\tSql.AppendLine();\n\t\t\tSql.Append(\"ROWS (\");\n\t\t\tVisit(selectExpression.Limit);\n\t\t\tSql.Append(\")\");\n\t\t}\n\t\telse if (selectExpression.Limit == null && selectExpression.Offset != null)\n\t\t{\n\t\t\tSql.AppendLine();\n\t\t\tSql.Append(\"ROWS (\");\n\t\t\tVisit(selectExpression.Offset);\n\t\t\tSql.Append(\" + 1) TO (\");\n\t\t\tSql.Append(long.MaxValue.ToString(CultureInfo.InvariantCulture));\n\t\t\tSql.Append(\")\");\n\t\t}\n\t}\n\n\tprotected override string GetOperator(SqlBinaryExpression binaryExpression)\n\t{\n\t\tif (binaryExpression.OperatorType == ExpressionType.Add && binaryExpression.TypeMapping.ClrType == typeof(string))\n\t\t{\n\t\t\treturn \" || \";\n\t\t}\n\t\telse if (binaryExpression.OperatorType == ExpressionType.AndAlso || binaryExpression.OperatorType == ExpressionType.And)\n\t\t{\n\t\t\treturn \" AND \";\n\t\t}\n\t\telse if (binaryExpression.OperatorType == ExpressionType.OrElse || binaryExpression.OperatorType == ExpressionType.Or)\n\t\t{\n\t\t\treturn \" OR \";\n\t\t}\n\t\treturn base.GetOperator(binaryExpression);\n\t}\n\n\t// https://github.com/aspnet/EntityFrameworkCore/issues/19031\n\tprotected override void GenerateOrderings(SelectExpression selectExpression)\n\t{\n\t\tif (selectExpression.Orderings.Any())\n\t\t{\n\t\t\tvar orderings = selectExpression.Orderings.ToList();\n\n\t\t\tif (selectExpression.Limit == null\n\t\t\t\t&& selectExpression.Offset == null)\n\t\t\t{\n\t\t\t\torderings.RemoveAll(oe => oe.Expression is SqlConstantExpression || oe.Expression is SqlParameterExpression);\n\t\t\t}\n\n\t\t\tif (orderings.Count > 0)\n\t\t\t{\n\t\t\t\tSql.AppendLine()\n\t\t\t\t\t.Append(\"ORDER BY \");\n\n\t\t\t\tGenerateList(orderings, e => Visit(e));\n\t\t\t}\n\t\t}\n\t}\n\n\t// Adapted from Npgsql Entity Framework Core provider\n\t// (https://github.com/npgsql/efcore.pg)\n\t// Copyright (c) 2002-2021, Npgsql\n\tprotected override Expression VisitCrossApply(CrossApplyExpression crossApplyExpression)\n\t{\n\t\tSql.Append(\"JOIN LATERAL \");\n\n\t\tif (crossApplyExpression.Table is TableExpression table)\n\t\t{\n\t\t\t// Firebird doesn't support LATERAL JOIN over table, and it doesn't really make sense to do it - but EF Core\n\t\t\t// will sometimes generate that.\n\t\t\tSql\n\t\t\t\t.Append(\"(SELECT * FROM \")\n\t\t\t\t.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(table.Name, table.Schema))\n\t\t\t\t.Append(\")\")\n\t\t\t\t.Append(AliasSeparator)\n\t\t\t\t.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(table.Alias));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVisit(crossApplyExpression.Table);\n\t\t}\n\n\t\tSql.Append(\" ON TRUE\");\n\t\treturn crossApplyExpression;\n\t}\n\n\t// Adapted from Npgsql Entity Framework Core provider\n\t// (https://github.com/npgsql/efcore.pg)\n\t// Copyright (c) 2002-2021, Npgsql\n\tprotected override Expression VisitOuterApply(OuterApplyExpression outerApplyExpression)\n\t{\n\t\tSql.Append(\"LEFT JOIN LATERAL \");\n\n\t\tif (outerApplyExpression.Table is TableExpression table)\n\t\t{\n\t\t\t// Firebird doesn't support LATERAL JOIN over table, and it doesn't really make sense to do it - but EF Core\n\t\t\t// will sometimes generate that.\n\t\t\tSql\n\t\t\t\t.Append(\"(SELECT * FROM \")\n\t\t\t\t.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(table.Name, table.Schema))\n\t\t\t\t.Append(\")\")\n\t\t\t\t.Append(AliasSeparator)\n\t\t\t\t.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(table.Alias));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVisit(outerApplyExpression.Table);\n\t\t}\n\n\t\tSql.Append(\" ON TRUE\");\n\t\treturn outerApplyExpression;\n\t}\n\n\tprotected override void GeneratePseudoFromClause()\n\t{\n\t\tSql.Append(\" FROM RDB$DATABASE\");\n\t}\n\n\tprotected override Expression VisitOrdering(OrderingExpression orderingExpression)\n\t{\n\t\tif (orderingExpression.Expression is SqlConstantExpression\n\t\t\t|| orderingExpression.Expression is SqlParameterExpression\n\t\t\t|| (orderingExpression.Expression is SqlFragmentExpression sqlFragment && sqlFragment.Sql.Equals(\"(SELECT 1)\", StringComparison.Ordinal)))\n\t\t{\n\t\t\tSql.Append(\"(SELECT 1\");\n\t\t\tGeneratePseudoFromClause();\n\t\t\tSql.Append(\")\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tVisit(orderingExpression.Expression);\n\t\t}\n\t\tif (!orderingExpression.IsAscending)\n\t\t{\n\t\t\tSql.Append(\" DESC\");\n\t\t}\n\t\treturn orderingExpression;\n\t}\n\n\tprotected override Expression VisitTableValuedFunction(TableValuedFunctionExpression tableValuedFunctionExpression)\n\t{\n\t\tSql.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(tableValuedFunctionExpression.Name));\n\t\tif (tableValuedFunctionExpression.Arguments.Any())\n\t\t{\n\t\t\tSql.Append(\"(\");\n\t\t\tGenerateList(tableValuedFunctionExpression.Arguments, e => Visit(e));\n\t\t\tSql.Append(\")\");\n\t\t}\n\t\tSql.Append(AliasSeparator);\n\t\tSql.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(tableValuedFunctionExpression.Alias));\n\t\treturn tableValuedFunctionExpression;\n\t}\n\n\tprotected override Expression VisitExtension(Expression extensionExpression)\n\t{\n\t\treturn extensionExpression switch\n\t\t{\n\t\t\tFbSpacedFunctionExpression spacedFunctionExpression => VisitSpacedFunction(spacedFunctionExpression),\n\t\t\t_ => base.VisitExtension(extensionExpression),\n\t\t};\n\t}\n\n\tprotected virtual Expression VisitSpacedFunction(FbSpacedFunctionExpression spacedFunctionExpression)\n\t{\n\t\tSql.Append(spacedFunctionExpression.Name);\n\t\tSql.Append(\"(\");\n\t\tfor (var i = 0; i < spacedFunctionExpression.Arguments.Count; i++)\n\t\t{\n\t\t\tVisit(spacedFunctionExpression.Arguments[i]);\n\t\t\tif (i < spacedFunctionExpression.Arguments.Count - 1)\n\t\t\t{\n\t\t\t\tSql.Append(\" \");\n\t\t\t}\n\t\t}\n\t\tSql.Append(\")\");\n\t\treturn spacedFunctionExpression;\n\t}\n\n\tvoid GenerateList<T>(IReadOnlyList<T> items, Action<T> generationAction, Action<IRelationalCommandBuilder> joinAction = null)\n\t{\n\t\tjoinAction ??= (isb => isb.Append(\", \"));\n\n\t\tfor (var i = 0; i < items.Count; i++)\n\t\t{\n\t\t\tif (i > 0)\n\t\t\t{\n\t\t\t\tjoinAction(Sql);\n\t\t\t}\n\n\t\t\tgenerationAction(items[i]);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/Internal/FbQuerySqlGeneratorFactory.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure.Internal;\nusing Microsoft.EntityFrameworkCore.Query;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\n\npublic class FbQuerySqlGeneratorFactory : IQuerySqlGeneratorFactory\n{\n\treadonly QuerySqlGeneratorDependencies _dependencies;\n\treadonly IFbOptions _fbOptions;\n\n\tpublic FbQuerySqlGeneratorFactory(QuerySqlGeneratorDependencies dependencies, IFbOptions fbOptions)\n\t{\n\t\t_dependencies = dependencies;\n\t\t_fbOptions = fbOptions;\n\t}\n\n\tpublic QuerySqlGenerator Create()\n\t\t  => new FbQuerySqlGenerator(_dependencies, _fbOptions);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/Internal/FbQueryTranslationPreprocessor.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Linq.Expressions;\nusing Microsoft.EntityFrameworkCore.Query;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\n\npublic class FbQueryTranslationPreprocessor : RelationalQueryTranslationPreprocessor\n{\n\tpublic FbQueryTranslationPreprocessor(QueryTranslationPreprocessorDependencies dependencies, RelationalQueryTranslationPreprocessorDependencies relationalDependencies, QueryCompilationContext queryCompilationContext)\n\t\t: base(dependencies, relationalDependencies, queryCompilationContext)\n\t{ }\n\n\tprotected override Expression ProcessQueryRoots(Expression expression)\n\t{\n\t\treturn new FbQueryRootProcessor(Dependencies, RelationalDependencies, QueryCompilationContext)\n\t\t\t.Visit(expression);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/Internal/FbQueryTranslationPreprocessorFactory.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\n\npublic class FbQueryTranslationPreprocessorFactory : IQueryTranslationPreprocessorFactory\n{\n\treadonly QueryTranslationPreprocessorDependencies _dependecies;\n\treadonly RelationalQueryTranslationPreprocessorDependencies _relationalDependencies;\n\n\tpublic FbQueryTranslationPreprocessorFactory(QueryTranslationPreprocessorDependencies dependecies, RelationalQueryTranslationPreprocessorDependencies relationalDependencies)\n\t{\n\t\t_dependecies = dependecies;\n\t\t_relationalDependencies = relationalDependencies;\n\t}\n\n\tpublic QueryTranslationPreprocessor Create(QueryCompilationContext queryCompilationContext)\n\t{\n\t\treturn new FbQueryTranslationPreprocessor(_dependecies, _relationalDependencies, queryCompilationContext);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/Internal/FbSqlExpressionFactory.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Query.Expressions.Internal;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\n\npublic class FbSqlExpressionFactory : SqlExpressionFactory\n{\n\tpublic FbSqlExpressionFactory(SqlExpressionFactoryDependencies dependencies)\n\t\t: base(dependencies)\n\t{ }\n\n\tpublic FbSpacedFunctionExpression SpacedFunction(string name, IEnumerable<SqlExpression> arguments, bool nullable, IEnumerable<bool> argumentsPropagateNullability, Type type, RelationalTypeMapping typeMapping = null)\n\t\t=> (FbSpacedFunctionExpression)ApplyDefaultTypeMapping(new FbSpacedFunctionExpression(name, arguments, nullable, argumentsPropagateNullability, type, typeMapping));\n\n\tpublic override SqlExpression ApplyTypeMapping(SqlExpression sqlExpression, RelationalTypeMapping typeMapping)\n\t\t=> sqlExpression == null || sqlExpression.TypeMapping != null\n\t\t\t? sqlExpression\n\t\t\t: sqlExpression switch\n\t\t\t{\n\t\t\t\tFbSpacedFunctionExpression e => e.ApplyTypeMapping(typeMapping),\n\t\t\t\t_ => base.ApplyTypeMapping(sqlExpression, typeMapping)\n\t\t\t};\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/Internal/FbSqlTranslatingExpressionVisitor.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\n\npublic class FbSqlTranslatingExpressionVisitor : RelationalSqlTranslatingExpressionVisitor\n{\n\tpublic FbSqlTranslatingExpressionVisitor(RelationalSqlTranslatingExpressionVisitorDependencies dependencies, QueryCompilationContext queryCompilationContext, QueryableMethodTranslatingExpressionVisitor queryableMethodTranslatingExpressionVisitor)\n\t\t: base(dependencies, queryCompilationContext, queryableMethodTranslatingExpressionVisitor)\n\t{ }\n\n\tprotected override Expression VisitUnary(UnaryExpression unaryExpression)\n\t{\n\t\tif (unaryExpression.NodeType == ExpressionType.ArrayLength && unaryExpression.Operand.Type == typeof(byte[]))\n\t\t{\n\t\t\tif (!(base.Visit(unaryExpression.Operand) is SqlExpression sqlExpression))\n\t\t\t{\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn Dependencies.SqlExpressionFactory.Function(\"OCTET_LENGTH\", new[] { sqlExpression }, true, new[] { true }, typeof(int));\n\t\t}\n\t\treturn base.VisitUnary(unaryExpression);\n\t}\n\n\tpublic override SqlExpression GenerateGreatest(IReadOnlyList<SqlExpression> expressions, Type resultType)\n\t{\n\t\tvar resultTypeMapping = ExpressionExtensions.InferTypeMapping(expressions);\n\t\treturn Dependencies.SqlExpressionFactory.Function(\n\t\t   \"MAXVALUE\",\n\t\t   expressions,\n\t\t   nullable: true,\n\t\t   Enumerable.Repeat(true, expressions.Count),\n\t\t   resultType,\n\t\t   resultTypeMapping);\n\t}\n\n\tpublic override SqlExpression GenerateLeast(IReadOnlyList<SqlExpression> expressions, Type resultType)\n\t{\n\t\tvar resultTypeMapping = ExpressionExtensions.InferTypeMapping(expressions);\n\t\treturn Dependencies.SqlExpressionFactory.Function(\n\t\t   \"MINVALUE\",\n\t\t   expressions,\n\t\t   nullable: true,\n\t\t   Enumerable.Repeat(true, expressions.Count),\n\t\t   resultType,\n\t\t   resultTypeMapping);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Query/Internal/FbSqlTranslatingExpressionVisitorFactory.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Query.Internal;\n\npublic class FbSqlTranslatingExpressionVisitorFactory : IRelationalSqlTranslatingExpressionVisitorFactory\n{\n\treadonly RelationalSqlTranslatingExpressionVisitorDependencies _dependencies;\n\n\tpublic FbSqlTranslatingExpressionVisitorFactory(RelationalSqlTranslatingExpressionVisitorDependencies dependencies)\n\t{\n\t\t_dependencies = dependencies;\n\t}\n\n\tpublic virtual RelationalSqlTranslatingExpressionVisitor Create(QueryCompilationContext queryCompilationContext, QueryableMethodTranslatingExpressionVisitor queryableMethodTranslatingExpressionVisitor)\n\t\t=> new FbSqlTranslatingExpressionVisitor(_dependencies, queryCompilationContext, queryableMethodTranslatingExpressionVisitor);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Scaffolding/Internal/FbDatabaseModelFactory.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Data;\nusing System.Data.Common;\nusing System.Linq;\nusing FirebirdSql.Data.FirebirdClient;\nusing FirebirdSql.Data.Services;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Internal;\nusing Microsoft.EntityFrameworkCore.Metadata;\nusing Microsoft.EntityFrameworkCore.Migrations;\nusing Microsoft.EntityFrameworkCore.Scaffolding;\nusing Microsoft.EntityFrameworkCore.Scaffolding.Metadata;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Scaffolding.Internal;\n\npublic class FbDatabaseModelFactory : DatabaseModelFactory\n{\n\tpublic int MajorVersionNumber { get; private set; }\n\n\tpublic override DatabaseModel Create(string connectionString, DatabaseModelFactoryOptions options)\n\t{\n\t\tusing (var connection = new FbConnection(connectionString))\n\t\t{\n\t\t\treturn Create(connection, options);\n\t\t};\n\t}\n\n\tpublic override DatabaseModel Create(DbConnection connection, DatabaseModelFactoryOptions options)\n\t{\n\t\tvar databaseModel = new DatabaseModel();\n\n\t\tvar connectionStartedOpen = connection.State == ConnectionState.Open;\n\t\tif (!connectionStartedOpen)\n\t\t{\n\t\t\tconnection.Open();\n\t\t}\n\t\ttry\n\t\t{\n\t\t\tvar serverVersion = FbServerProperties.ParseServerVersion(connection.ServerVersion);\n\t\t\tMajorVersionNumber = serverVersion.Major;\n\n\t\t\tdatabaseModel.DatabaseName = connection.Database;\n\t\t\tdatabaseModel.DefaultSchema = GetDefaultSchema();\n\n\t\t\tvar tableList = options.Tables.ToList();\n\t\t\tvar tableFilter = GenerateTableFilter(tableList);\n\n\t\t\tvar tables = GetTables(connection);\n\t\t\tforeach (var table in tables)\n\t\t\t{\n\t\t\t\ttable.Database = databaseModel;\n\t\t\t\tif (tableFilter.Invoke(table))\n\t\t\t\t{\n\t\t\t\t\tdatabaseModel.Tables.Add(table);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn databaseModel;\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tif (!connectionStartedOpen)\n\t\t\t{\n\t\t\t\tconnection.Close();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static string GetDefaultSchema() => null;\n\n\tprivate static Func<DatabaseTable, bool> GenerateTableFilter(IReadOnlyList<string> tables) =>\n\t\ttables.Any() ? x => tables.Contains(x.Name) : _ => true;\n\n\tprivate const string GetTablesQuery = \"\"\"\n\t\tSELECT\n\t\t\tTRIM(r.rdb$relation_name) relation_name,\n\t\t\tr.rdb$description description,\n\t\t\tr.rdb$relation_type relation_type\n\t\tFROM\n\t\t\trdb$relations r\n\t\tWHERE\n\t\t\tr.rdb$system_flag IS DISTINCT FROM 1\n\t\tORDER BY\n\t\t\tr.rdb$relation_name\n\t\t\"\"\";\n\n\tprivate List<DatabaseTable> GetTables(DbConnection connection)\n\t{\n\t\tusing (var command = connection.CreateCommand())\n\t\t{\n\t\t\tvar tables = new List<DatabaseTable>();\n\t\t\tcommand.CommandText = GetTablesQuery;\n\n\t\t\tusing (var reader = command.ExecuteReader())\n\t\t\t{\n\t\t\t\twhile (reader.Read())\n\t\t\t\t{\n\t\t\t\t\tvar name = reader.GetString(0);\n\t\t\t\t\tvar comment = reader.GetString(1);\n\t\t\t\t\tvar type = reader.GetInt32(2);\n\n\t\t\t\t\tvar table = type == 1\n\t\t\t\t\t\t? new DatabaseView()\n\t\t\t\t\t\t: new DatabaseTable();\n\n\t\t\t\t\ttable.Schema = null;\n\t\t\t\t\ttable.Name = name;\n\t\t\t\t\ttable.Comment = string.IsNullOrEmpty(comment) ? null : comment;\n\n\t\t\t\t\ttables.Add(table);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tGetColumns(connection, tables);\n\t\t\tGetPrimaryKeys(connection, tables);\n\t\t\tGetIndexes(connection, tables);\n\t\t\tGetConstraints(connection, tables);\n\n\t\t\treturn tables;\n\t\t}\n\t}\n\n\tprivate string GetColumnsQuery() => $\"\"\"\n\t\tSELECT\n\t\t\tTRIM(rf.rdb$field_name) column_name,\n\t\t\tCOALESCE(rf.rdb$null_flag, f.rdb$null_flag, 0) column_required,\n\n\t\t\tCASE COALESCE(f.rdb$field_type, 0)\n\t\t\t\tWHEN 7 THEN\n\t\t\t\t\tCASE f.rdb$field_sub_type\n\t\t\t\t\t\tWHEN 0 THEN 'SMALLINT'\n\t\t\t\t\t\tWHEN 1 THEN 'NUMERIC(' || (f.rdb$field_precision) || ',' || ABS(f.rdb$field_scale) || ')'\n\t\t\t\t\t\tWHEN 2 THEN 'DECIMAL(' || (f.rdb$field_precision) || ',' || ABS(f.rdb$field_scale) || ')'\n\t\t\t\t\t\tELSE '?'\n\t\t\t\t\tEND\n\t\t\t\tWHEN 8 THEN\n\t\t\t\t\tCASE f.rdb$field_sub_type\n\t\t\t\t\t\tWHEN 0 THEN 'INTEGER'\n\t\t\t\t\t\tWHEN 1 THEN 'NUMERIC(' || (f.rdb$field_precision) || ',' || ABS(f.rdb$field_scale) || ')'\n\t\t\t\t\t\tWHEN 2 THEN 'DECIMAL(' || (f.rdb$field_precision) || ',' || ABS(f.rdb$field_scale) || ')'\n\t\t\t\t\t\tELSE '?'\n\t\t\t\t\tEND\n\t\t\t\tWHEN 9 THEN 'QUAD'\n\t\t\t\tWHEN 10 THEN 'FLOAT'\n\t\t\t\tWHEN 12 THEN 'DATE'\n\t\t\t\tWHEN 13 THEN 'TIME'\n\t\t\t\tWHEN 14 THEN 'CHAR(' || (TRUNC(f.rdb$field_length / ch.rdb$bytes_per_character)) || ')'\n\t\t\t\tWHEN 16 THEN\n\t\t\t\t\tCASE f.rdb$field_sub_type\n\t\t\t\t\t\tWHEN 0 THEN 'BIGINT'\n\t\t\t\t\t\tWHEN 1 THEN 'NUMERIC(' || (f.rdb$field_precision) || ',' || ABS(f.rdb$field_scale) || ')'\n\t\t\t\t\t\tWHEN 2 THEN 'DECIMAL(' || (f.rdb$field_precision) || ',' || ABS(f.rdb$field_scale) || ')'\n\t\t\t\t\t\tELSE '?'\n\t\t\t\t\tEND\n\t\t\t\tWHEN 23 THEN 'BOOLEAN'\n\t\t\t\tWHEN 24 THEN 'DECFLOAT(' || (f.rdb$field_precision) || ')'\n\t\t\t\tWHEN 25 THEN 'DECFLOAT(' || (f.rdb$field_precision) || ')'\n\t\t\t\tWHEN 26 THEN 'INT128'\n\t\t\t\tWHEN 27 THEN 'DOUBLE PRECISION'\n\t\t\t\tWHEN 28 THEN 'TIME WITH TIME ZONE'\n\t\t\t\tWHEN 29 THEN 'TIMESTAMP WITH TIME ZONE'\n\t\t\t\tWHEN 35 THEN 'TIMESTAMP'\n\t\t\t\tWHEN 37 THEN 'VARCHAR(' || (TRUNC(f.rdb$field_length / ch.rdb$bytes_per_character)) || ')'\n\t\t\t\tWHEN 40 THEN 'CSTRING(' || (TRUNC(f.rdb$field_length / ch.rdb$bytes_per_character)) || ')'\n\t\t\t\tWHEN 45 THEN 'BLOB_ID'\n\t\t\t\tWHEN 261 THEN 'BLOB SUB_TYPE ' ||\n\t\t\t\t\tCASE f.rdb$field_sub_type\n\t\t\t\t\t\tWHEN 0 THEN 'BINARY'\n\t\t\t\t\t\tWHEN 1 THEN 'TEXT'\n\t\t\t\t\t\tELSE f.rdb$field_sub_type\n\t\t\t\t\tEND\n\t\t\t\tELSE 'RDB$FIELD_TYPE: ' || f.rdb$field_type || '?'\n\t\t\tEND column_store_type,\n\n\t\t\trf.rdb$field_source column_domain,\n\n\t\t\tNULLIF(ch.rdb$character_set_name, d.rdb$character_set_name) character_set_name,\n\t\t\tco.rdb$collation_name collation_name,\n\t\t\tCOALESCE(f.rdb$segment_length, 0) segment_length,\n\n\t\t\tCOALESCE(rf.rdb$default_source, f.rdb$default_source) column_default,\n\t\t\tf.rdb$computed_source column_computed_source,\n\t\t\tf.rdb$description column_comment,\n\n\t\t\tCOALESCE({(MajorVersionNumber < 3 ? \"NULL\" : \"rf.rdb$identity_type\")}, -1) identity_type,\n\t\t\tCOALESCE({(MajorVersionNumber < 3 ? \"NULL\" : \"g.rdb$initial_value\")}, 1) identity_start,\n\t\t\tCOALESCE({(MajorVersionNumber < 3 ? \"NULL\" : \"g.rdb$generator_increment\")}, 1) identity_increment\n\t\tFROM\n\t\t\trdb$relation_fields rf\n\t\t\tJOIN rdb$fields f ON f.rdb$field_name = rf.rdb$field_source \n\t\t\tLEFT JOIN rdb$character_sets ch ON ch.rdb$character_set_id = f.rdb$character_set_id\n\t\t\tLEFT JOIN rdb$collations co ON co.rdb$character_set_id = f.rdb$character_set_id AND co.rdb$collation_id = rf.rdb$collation_id\n\t\t\t{(MajorVersionNumber < 3 ? \"\" : \"LEFT JOIN rdb$generators g ON g.rdb$generator_name = rf.rdb$generator_name\")}\n\t\t\tCROSS JOIN rdb$database d\n\t\tWHERE\n\t\t\tTRIM(rf.rdb$relation_name) = @RelationName AND COALESCE(rf.rdb$system_flag, 0) = 0\n\t\tORDER BY\n\t\t\trf.rdb$field_position\n\t\t\"\"\";\n\n\tprivate void GetColumns(DbConnection connection, IReadOnlyList<DatabaseTable> tables)\n\t{\n\t\tforeach (var table in tables)\n\t\t{\n\t\t\tusing (var command = connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcommand.CommandText = GetColumnsQuery();\n\t\t\t\tcommand.Parameters.Add(new FbParameter(\"@RelationName\", table.Name));\n\n\t\t\t\tusing (var reader = command.ExecuteReader())\n\t\t\t\t{\n\t\t\t\t\twhile (reader.Read())\n\t\t\t\t\t{\n\t\t\t\t\t\tvar name = reader[\"COLUMN_NAME\"].ToString();\n\t\t\t\t\t\tvar isNullable = !Convert.ToBoolean(reader[\"COLUMN_REQUIRED\"]);\n\t\t\t\t\t\tvar storeType = reader[\"COLUMN_STORE_TYPE\"].ToString();\n\n\t\t\t\t\t\tvar columnDomain = reader[\"COLUMN_DOMAIN\"].ToString();\n\n\t\t\t\t\t\tvar charset = reader[\"CHARACTER_SET_NAME\"].ToString();\n\t\t\t\t\t\tvar collation = reader[\"COLLATION_NAME\"].ToString();\n\t\t\t\t\t\tvar segmentSize = Convert.ToInt32(reader[\"SEGMENT_LENGTH\"]);\n\n\t\t\t\t\t\tvar defaultValue = reader[\"COLUMN_DEFAULT\"].ToString();\n\t\t\t\t\t\tvar computedSource = reader[\"COLUMN_COMPUTED_SOURCE\"].ToString();\n\t\t\t\t\t\tvar comment = reader[\"COLUMN_COMMENT\"].ToString();\n\n\t\t\t\t\t\tvar identityType = Convert.ToInt32(reader[\"IDENTITY_TYPE\"]);\n\t\t\t\t\t\tvar identityStart = Convert.ToInt32(reader[\"IDENTITY_START\"]);\n\t\t\t\t\t\tvar identityIncrement = Convert.ToInt32(reader[\"IDENTITY_INCREMENT\"]);\n\n\t\t\t\t\t\tvar column = new DatabaseColumn\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tTable = table,\n\t\t\t\t\t\t\tName = name,\n\t\t\t\t\t\t\tStoreType = storeType,\n\t\t\t\t\t\t\tIsNullable = isNullable,\n\n\t\t\t\t\t\t\tDefaultValueSql = string.IsNullOrEmpty(defaultValue) ? null : defaultValue.Remove(0, 8),\n\t\t\t\t\t\t\tValueGenerated = identityType == -1 ? ValueGenerated.Never : ValueGenerated.OnAdd,\n\t\t\t\t\t\t\tComment = string.IsNullOrEmpty(comment) ? null : comment,\n\t\t\t\t\t\t\tCollation = string.IsNullOrEmpty(collation) ? null : collation.Trim(),\n\t\t\t\t\t\t\tComputedColumnSql = string.IsNullOrEmpty(computedSource) ? null : computedSource\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tif (segmentSize > 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcolumn.SetAnnotation(FbAnnotationNames.BlobSegmentSize, segmentSize);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!string.IsNullOrEmpty(charset))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcolumn.SetAnnotation(FbAnnotationNames.CharacterSet, charset.Trim());\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!columnDomain.StartsWith(\"RDB$\"))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcolumn.SetAnnotation(FbAnnotationNames.DomainName, columnDomain.Trim());\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (identityType != -1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcolumn.SetAnnotation(FbAnnotationNames.IdentityType, identityType);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (identityStart != 1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcolumn.SetAnnotation(FbAnnotationNames.IdentityStart, identityStart);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (identityIncrement != 1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcolumn.SetAnnotation(FbAnnotationNames.IdentityIncrement, identityIncrement);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttable.Columns.Add(column);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate const string GetPrimaryKeysQuery = \"\"\"\n\t\tSELECT\n\t\t\tTRIM(i.rdb$index_name) index_name,\n\t\t\tTRIM(sg.rdb$field_name) field_name\n\t\tFROM\n\t\t\trdb$indices i\n\t\t\tLEFT JOIN rdb$index_segments sg ON i.rdb$index_name = sg.rdb$index_name\n\t\t\tLEFT JOIN rdb$relation_constraints rc ON rc.rdb$index_name = i.rdb$index_name\n\t\tWHERE\n\t\t\trc.rdb$constraint_type = 'PRIMARY KEY' AND TRIM(i.rdb$relation_name) = @RelationName\n\t\tORDER BY\n\t\t\tsg.rdb$field_position\n\t\t\"\"\";\n\n\tprivate static void GetPrimaryKeys(DbConnection connection, IReadOnlyList<DatabaseTable> tables)\n\t{\n\t\tforeach (var table in tables)\n\t\t{\n\t\t\tusing (var command = connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcommand.CommandText = GetPrimaryKeysQuery;\n\t\t\t\tcommand.Parameters.Add(new FbParameter(\"@RelationName\", table.Name));\n\n\t\t\t\tusing (var reader = command.ExecuteReader())\n\t\t\t\t{\n\t\t\t\t\tDatabasePrimaryKey index = null;\n\t\t\t\t\twhile (reader.Read())\n\t\t\t\t\t{\n\t\t\t\t\t\tindex ??= new DatabasePrimaryKey\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tTable = table,\n\t\t\t\t\t\t\tName = reader.GetString(0).Trim()\n\t\t\t\t\t\t};\n\t\t\t\t\t\tindex.Columns.Add(table.Columns.Single(y => y.Name == reader.GetString(1).Trim()));\n\t\t\t\t\t\ttable.PrimaryKey = index;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate const string GetIndexesQuery = \"\"\"\n\t\tSELECT\n\t\t\tTRIM(i.rdb$index_name) index_name,\n\t\t\tCOALESCE(i.rdb$unique_flag, 0) is_unique,\n\t\t\tCoalesce(i.rdb$index_type, 0) is_desc,\n\t\t\tLIST(TRIM(sg.rdb$field_name)) columns\n\t\tFROM\n\t\t\tRDB$INDICES i\n\t\t\tLEFT JOIN rdb$index_segments sg ON i.rdb$index_name = sg.rdb$index_name\n\t\t\tLEFT JOIN rdb$relation_constraints rc ON rc.rdb$index_name = i.rdb$index_name\n\t\tWHERE\n\t\t\tTRIM(i.rdb$relation_name) = @RelationName\n\t\t\tAND i.RDB$EXPRESSION_SOURCE IS NULL\n\t\tGROUP BY\n\t\t\tindex_name, is_unique, is_desc\n\t\t\"\"\";\n\n\t/// <remarks>\n\t/// Primary keys are handled as in <see cref=\"GetConstraints\"/>, not here\n\t/// </remarks>\n\tprivate static void GetIndexes(DbConnection connection, IReadOnlyList<DatabaseTable> tables)\n\t{\n\t\tforeach (var table in tables)\n\t\t{\n\t\t\tusing (var command = connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcommand.CommandText = GetIndexesQuery;\n\t\t\t\tcommand.Parameters.Add(new FbParameter(\"@RelationName\", table.Name));\n\n\t\t\t\tusing (var reader = command.ExecuteReader())\n\t\t\t\t{\n\t\t\t\t\twhile (reader.Read())\n\t\t\t\t\t{\n\t\t\t\t\t\tvar columns = reader.IsDBNull(3) ? string.Empty : reader.GetString(3);\n\t\t\t\t\t\tif (string.IsNullOrEmpty(columns))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvar index = new DatabaseIndex\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tTable = table,\n\t\t\t\t\t\t\tName = reader.GetString(0).Trim(),\n\t\t\t\t\t\t\tIsUnique = reader.GetBoolean(1),\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tforeach (var column in columns.Split(','))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tindex.Columns.Add(table.Columns.Single(y => y.Name == column.Trim()));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (reader.GetBoolean(2))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvar isDescending = new bool[index.Columns.Count];\n\t\t\t\t\t\t\tisDescending.AsSpan().Fill(true);\n\t\t\t\t\t\t\tindex.IsDescending = isDescending;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttable.Indexes.Add(index);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate const string GetConstraintsQuery = \"\"\"\n\t\tSELECT\n\t\t\tTRIM(drs.rdb$constraint_name) constraint_name,\n\t\t\tTRIM(drs.rdb$relation_name) table_name,\n\t\t\tTRIM(mrc.rdb$relation_name) referenced_table_name,\n\t\t\t(\n\t\t\t\tSELECT\n\t\t\t\t\tLIST(TRIM(di.rdb$field_name) || '|' || TRIM(mi.rdb$field_name))\n\t\t\t\tFROM\n\t\t\t\t\trdb$index_segments di\n\t\t\t\t\tjoin rdb$index_segments mi ON mi.rdb$field_position = di.rdb$field_position AND mi.rdb$index_name = mrc.rdb$index_name\n\t\t\t\tWHERE\n\t\t\t\t\tdi.rdb$index_name = drs.rdb$index_name\n\t\t\t) paired_columns,\n\t\t\tTRIM(rc.rdb$delete_rule) delete_rule\n\t\tFROM\n\t\t\trdb$relation_constraints drs\n\t\t\tLEFT JOIN rdb$ref_constraints rc ON drs.rdb$constraint_name = rc.rdb$constraint_name\n\t\t\tLEFT JOIN rdb$relation_constraints mrc ON rc.rdb$const_name_uq = mrc.rdb$constraint_name\n\t\tWHERE\n\t\t\tdrs.rdb$constraint_type = 'FOREIGN KEY' AND TRIM(drs.rdb$relation_name) = @RelationName\n\t\t\"\"\";\n\n\tprivate static void GetConstraints(DbConnection connection, IReadOnlyList<DatabaseTable> tables)\n\t{\n\t\tforeach (var table in tables)\n\t\t{\n\t\t\tusing (var command = connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcommand.CommandText = GetConstraintsQuery;\n\t\t\t\tcommand.Parameters.Add(new FbParameter(\"@RelationName\", table.Name));\n\n\t\t\t\tusing (var reader = command.ExecuteReader())\n\t\t\t\t{\n\t\t\t\t\twhile (reader.Read())\n\t\t\t\t\t{\n\t\t\t\t\t\tvar referencedTableName = reader.GetString(2);\n\t\t\t\t\t\tvar referencedTable = tables.First(t => t.Name == referencedTableName);\n\t\t\t\t\t\tvar fkInfo = new DatabaseForeignKey { Name = reader.GetString(0), OnDelete = ConvertToReferentialAction(reader.GetString(4)), Table = table, PrincipalTable = referencedTable };\n\t\t\t\t\t\tforeach (var pair in reader.GetString(3).Split(','))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfkInfo.Columns.Add(table.Columns.Single(y =>\n\t\t\t\t\t\t\t\tstring.Equals(y.Name, pair.Split('|')[0], StringComparison.OrdinalIgnoreCase)));\n\t\t\t\t\t\t\tfkInfo.PrincipalColumns.Add(fkInfo.PrincipalTable.Columns.Single(y =>\n\t\t\t\t\t\t\t\tstring.Equals(y.Name, pair.Split('|')[1], StringComparison.OrdinalIgnoreCase)));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttable.ForeignKeys.Add(fkInfo);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static ReferentialAction? ConvertToReferentialAction(string onDeleteAction) =>\n\t\tonDeleteAction.ToUpperInvariant() switch\n\t\t{\n\t\t\t\"RESTRICT\" => ReferentialAction.Restrict,\n\t\t\t\"CASCADE\" => ReferentialAction.Cascade,\n\t\t\t\"SET NULL\" => ReferentialAction.SetNull,\n\t\t\t\"NO ACTION\" => ReferentialAction.NoAction,\n\t\t\t_ => null,\n\t\t};\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Scaffolding/Internal/FbProviderCodeGenerator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Design;\nusing Microsoft.EntityFrameworkCore.Scaffolding;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Scaffolding.Internal;\n\npublic class FbProviderCodeGenerator : ProviderCodeGenerator\n{\n\tstatic readonly MethodInfo UseFirebirdMethodInfo\n\t\t= typeof(FbDbContextOptionsBuilderExtensions).GetRuntimeMethod(\n\t\t\tnameof(FbDbContextOptionsBuilderExtensions.UseFirebird),\n\t\t\tnew[] { typeof(DbContextOptionsBuilder), typeof(string), typeof(Action<FbDbContextOptionsBuilder>) });\n\n\tpublic FbProviderCodeGenerator(ProviderCodeGeneratorDependencies dependencies)\n\t\t: base(dependencies)\n\t{ }\n\n\tpublic override MethodCallCodeFragment GenerateUseProvider(string connectionString, MethodCallCodeFragment providerOptions)\n\t{\n\t\treturn new MethodCallCodeFragment(\n\t\t\tUseFirebirdMethodInfo,\n\t\t\tproviderOptions == null\n\t\t\t\t? new object[] { connectionString }\n\t\t\t\t: new object[] { connectionString, new NestedClosureCodeFragment(\"x\", providerOptions) });\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbBoolTypeMapping.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\npublic class FbBoolTypeMapping : BoolTypeMapping\n{\n\tpublic FbBoolTypeMapping()\n\t\t: base(\"BOOLEAN\", System.Data.DbType.Boolean)\n\t{ }\n\n\tprotected FbBoolTypeMapping(RelationalTypeMappingParameters parameters)\n\t\t: base(parameters)\n\t{ }\n\n\tprotected override string GenerateNonNullSqlLiteral(object value)\n\t{\n\t\treturn (bool)value ? \"TRUE\" : \"FALSE\";\n\t}\n\n\tprotected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)\n\t\t=> new FbBoolTypeMapping(parameters);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbByteArrayTypeMapping.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.Data.Common;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\npublic class FbByteArrayTypeMapping : ByteArrayTypeMapping\n{\n\tpublic FbByteArrayTypeMapping()\n\t\t: base(\"BLOB SUB_TYPE BINARY\", System.Data.DbType.Binary)\n\t{ }\n\n\tprotected FbByteArrayTypeMapping(RelationalTypeMappingParameters parameters)\n\t\t: base(parameters)\n\t{ }\n\n\tprotected override string GenerateNonNullSqlLiteral(object value)\n\t{\n\t\tvar hex = ((byte[])value).ToHexString();\n\t\treturn $\"x'{hex}'\";\n\t}\n\n\tprotected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)\n\t\t=> new FbByteArrayTypeMapping(parameters);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbDatabaseCreator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net), Jean Ressouche, Rafael Almeida (ralms@ralms.net)\n\nusing System;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.FirebirdClient;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\nusing Microsoft.EntityFrameworkCore.Metadata;\nusing Microsoft.EntityFrameworkCore.Migrations;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\npublic class FbDatabaseCreator : RelationalDatabaseCreator\n{\n\treadonly IFbRelationalConnection _connection;\n\treadonly IRawSqlCommandBuilder _rawSqlCommandBuilder;\n\n\tpublic FbDatabaseCreator(RelationalDatabaseCreatorDependencies dependencies, IFbRelationalConnection connection, IRawSqlCommandBuilder rawSqlCommandBuilder)\n\t\t: base(dependencies)\n\t{\n\t\t_connection = connection;\n\t\t_rawSqlCommandBuilder = rawSqlCommandBuilder;\n\t}\n\n\tpublic override void Create()\n\t{\n\t\tFbConnection.CreateDatabase(_connection.ConnectionString, pageSize: 16384);\n\n\t\tvar designTimeModel = Dependencies.CurrentContext.Context.GetService<IDesignTimeModel>().Model;\n\n\t\tvar collation = designTimeModel.GetCollation();\n\t\tif (collation != null)\n\t\t{\n\t\t\tDependencies.ExecutionStrategy.Execute(\n\t\t\t\t_connection,\n\t\t\t\tconnection => CreateAlterCollationCommand(collation).ExecuteNonQuery(\n\t\t\t\t\tnew RelationalCommandParameterObject(\n\t\t\t\t\t\tconnection,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tDependencies.CurrentContext.Context,\n\t\t\t\t\t\tDependencies.CommandLogger)));\n\t\t}\n\t}\n\tpublic override async Task CreateAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tawait FbConnection.CreateDatabaseAsync(_connection.ConnectionString, pageSize: 16384, cancellationToken: cancellationToken).ConfigureAwait(false);\n\n\t\tvar designTimeModel = Dependencies.CurrentContext.Context.GetService<IDesignTimeModel>().Model;\n\n\t\tvar collation = designTimeModel.GetCollation();\n\t\tif (collation != null)\n\t\t{\n\t\t\tawait Dependencies.ExecutionStrategy.ExecuteAsync(\n\t\t\t\t_connection,\n\t\t\t\tconnection => CreateAlterCollationCommand(collation).ExecuteNonQueryAsync(\n\t\t\t\t\tnew RelationalCommandParameterObject(\n\t\t\t\t\t\tconnection,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tDependencies.CurrentContext.Context,\n\t\t\t\t\t\tDependencies.CommandLogger))).ConfigureAwait(false);\n\t\t}\n\t}\n\n\tpublic override void Delete()\n\t{\n\t\tFbConnection.ClearPool((FbConnection)_connection.DbConnection);\n\t\tFbConnection.DropDatabase(_connection.ConnectionString);\n\t}\n\tpublic override Task DeleteAsync(CancellationToken cancellationToken = default)\n\t{\n\t\tFbConnection.ClearPool((FbConnection)_connection.DbConnection);\n\t\treturn FbConnection.DropDatabaseAsync(_connection.ConnectionString, cancellationToken);\n\t}\n\n\tpublic override bool Exists()\n\t{\n\t\ttry\n\t\t{\n\t\t\t_connection.Open();\n\t\t\treturn true;\n\t\t}\n\t\tcatch (FbException)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\t_connection.Close();\n\t\t}\n\t}\n\tpublic override async Task<bool> ExistsAsync(CancellationToken cancellationToken = default)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait _connection.OpenAsync(cancellationToken).ConfigureAwait(false);\n\t\t\treturn true;\n\t\t}\n\t\tcatch (FbException)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t\tfinally\n\t\t{\n\t\t\tawait _connection.CloseAsync().ConfigureAwait(false);\n\t\t}\n\t}\n\n\tpublic override bool HasTables()\n\t{\n\t\treturn Dependencies.ExecutionStrategy.Execute(\n\t\t\t_connection,\n\t\t\tconnection => Convert.ToInt64(CreateHasTablesCommand().ExecuteScalar(\n\t\t\t\tnew RelationalCommandParameterObject(\n\t\t\t\t\tconnection,\n\t\t\t\t\tnull,\n\t\t\t\t\tnull,\n\t\t\t\t\tDependencies.CurrentContext.Context,\n\t\t\t\t\tDependencies.CommandLogger)))\n\t\t\t\t!= 0);\n\t}\n\tpublic override Task<bool> HasTablesAsync(CancellationToken cancellationToken = default)\n\t{\n\t\treturn Dependencies.ExecutionStrategy.ExecuteAsync(\n\t\t\t_connection,\n\t\t\tasync (connection, ct) => Convert.ToInt64(await CreateHasTablesCommand().ExecuteScalarAsync(\n\t\t\t\tnew RelationalCommandParameterObject(\n\t\t\t\t\tconnection,\n\t\t\t\t\tnull,\n\t\t\t\t\tnull,\n\t\t\t\t\tDependencies.CurrentContext.Context,\n\t\t\t\t\tDependencies.CommandLogger),\n\t\t\t\tct).ConfigureAwait(false))\n\t\t\t\t!= 0,\n\t\t\tcancellationToken);\n\t}\n\n\tIRelationalCommand CreateHasTablesCommand()\n\t   => _rawSqlCommandBuilder\n\t\t   .Build(\"SELECT COUNT(*) FROM rdb$relations WHERE COALESCE(rdb$system_flag, 0) = 0 AND rdb$view_blr IS NULL\");\n\n\tIRelationalCommand CreateAlterCollationCommand(string collation)\n\t\t=> _rawSqlCommandBuilder\n\t\t\t.Build($@\"EXECUTE BLOCK\nAS\nBEGIN\n\texecute statement 'alter character set ' || (select coalesce(trim(rdb$character_set_name), 'NONE') from rdb$database) || ' set default collation {collation}';\nEND\");\n\n\tpublic override void CreateTables()\n\t{\n\t\t// we need to execute commands separately to avoid issues with inserts and transactions after creating a table\n\t\tforeach (var command in GetCreateTablesCommands())\n\t\t{\n\t\t\tDependencies.MigrationCommandExecutor.ExecuteNonQuery([command], Dependencies.Connection, new MigrationExecutionState(), commitTransaction: true);\n\t\t}\n\t}\n\tpublic override async Task CreateTablesAsync(CancellationToken cancellationToken = default)\n\t{\n\t\t// we need to execute commands separately to avoid issues with inserts and transactions after creating a table\n\t\tforeach (var command in GetCreateTablesCommands())\n\t\t{\n\t\t\tawait Dependencies.MigrationCommandExecutor.ExecuteNonQueryAsync([command], Dependencies.Connection, new MigrationExecutionState(), commitTransaction: true, cancellationToken: cancellationToken);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbDateOnlyTypeMapping.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\npublic class FbDateOnlyTypeMapping : DateOnlyTypeMapping\n{\n\tpublic FbDateOnlyTypeMapping(string storeType)\n\t\t: base(storeType)\n\t{ }\n\n\tprotected FbDateOnlyTypeMapping(RelationalTypeMappingParameters parameters)\n\t\t: base(parameters)\n\t{ }\n\n\tprotected override string GenerateNonNullSqlLiteral(object value)\n\t{\n\t\treturn $\"CAST('{value:yyyy-MM-dd}' AS DATE)\";\n\t}\n\n\tprotected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)\n\t\t=> new FbDateOnlyTypeMapping(parameters);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbDateTimeTypeMapping.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\npublic class FbDateTimeTypeMapping : DateTimeTypeMapping\n{\n\treadonly FbDbType _fbDbType;\n\n\tpublic FbDateTimeTypeMapping(string storeType, FbDbType fbDbType)\n\t\t: base(storeType)\n\t{\n\t\t_fbDbType = fbDbType;\n\t}\n\n\tprotected FbDateTimeTypeMapping(RelationalTypeMappingParameters parameters, FbDbType fbDbType)\n\t\t: base(parameters)\n\t{\n\t\t_fbDbType = fbDbType;\n\t}\n\n\tprotected override void ConfigureParameter(DbParameter parameter)\n\t{\n\t\t((FbParameter)parameter).FbDbType = _fbDbType;\n\t}\n\n\tprotected override string GenerateNonNullSqlLiteral(object value)\n\t{\n\t\tswitch (_fbDbType)\n\t\t{\n\t\t\tcase FbDbType.TimeStamp:\n\t\t\t\treturn $\"CAST('{value:yyyy-MM-dd HH\\\\:mm\\\\:ss.ffff}' AS TIMESTAMP)\";\n\t\t\tcase FbDbType.Date:\n\t\t\t\treturn $\"CAST('{value:yyyy-MM-dd}' AS DATE)\";\n\t\t\tcase FbDbType.Time:\n\t\t\t\treturn $\"CAST('{value:HH\\\\:mm\\\\:ss.ffff}' AS TIME)\";\n\t\t\tdefault:\n\t\t\t\tthrow new ArgumentOutOfRangeException(nameof(_fbDbType), $\"{nameof(_fbDbType)}={_fbDbType}\");\n\t\t}\n\t}\n\n\tprotected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)\n\t\t=> new FbDateTimeTypeMapping(parameters, _fbDbType);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbGuidTypeMapping.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\npublic class FbGuidTypeMapping : GuidTypeMapping\n{\n\tpublic FbGuidTypeMapping()\n\t\t: base(\"CHAR(16) CHARACTER SET OCTETS\")\n\t{ }\n\n\tprotected FbGuidTypeMapping(RelationalTypeMappingParameters parameters)\n\t\t: base(parameters)\n\t{ }\n\n\tprotected override void ConfigureParameter(DbParameter parameter)\n\t{\n\t\t((FbParameter)parameter).FbDbType = FbDbType.Guid;\n\t}\n\n\tprotected override string GenerateNonNullSqlLiteral(object value)\n\t{\n\t\treturn $\"CHAR_TO_UUID('{value}')\";\n\t}\n\n\tprotected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)\n\t\t=> new FbGuidTypeMapping(parameters);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbRelationalConnection.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\npublic class FbRelationalConnection : RelationalConnection, IFbRelationalConnection\n{\n\tpublic FbRelationalConnection(RelationalConnectionDependencies dependencies)\n\t\t: base(dependencies)\n\t{ }\n\n\tprotected override DbConnection CreateDbConnection()\n\t\t=> new FbConnection(ConnectionString);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbRelationalTransaction.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data.Common;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\npublic class FbRelationalTransaction : RelationalTransaction, IFbRelationalTransaction\n{\n\tpublic FbRelationalTransaction(IRelationalConnection connection, DbTransaction transaction, Guid transactionId, IDiagnosticsLogger<DbLoggerCategory.Database.Transaction> logger, bool transactionOwned, ISqlGenerationHelper sqlGenerationHelper)\n\t\t: base(connection, transaction, transactionId, logger, transactionOwned, sqlGenerationHelper)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbSqlGenerationHelper.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Text;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\npublic class FbSqlGenerationHelper : RelationalSqlGenerationHelper, IFbSqlGenerationHelper\n{\n\tpublic FbSqlGenerationHelper(RelationalSqlGenerationHelperDependencies dependencies)\n\t\t: base(dependencies)\n\t{ }\n\n\tpublic virtual string StringLiteralQueryType(string s, bool isUnicode = true)\n\t{\n\t\tvar length = MinimumStringQueryTypeLength(s);\n\t\tvar charset = isUnicode ? \" CHARACTER SET UTF8\" : string.Empty;\n\t\treturn $\"VARCHAR({length}){charset}\";\n\t}\n\n\tpublic virtual string StringParameterQueryType(bool isUnicode)\n\t{\n\t\tvar size = isUnicode ? FbTypeMappingSource.UnicodeVarcharMaxSize : FbTypeMappingSource.VarcharMaxSize;\n\t\treturn $\"VARCHAR({size})\";\n\t}\n\n\tpublic virtual void GenerateBlockParameterName(StringBuilder builder, string name)\n\t{\n\t\tbuilder.Append(\":\").Append(name);\n\t}\n\n\tpublic virtual string AlternativeStatementTerminator => \"~\";\n\n\tstatic int MinimumStringQueryTypeLength(string s)\n\t{\n\t\tvar length = s?.Length ?? 0;\n\t\tif (length == 0)\n\t\t\tlength = 1;\n\t\treturn length;\n\t}\n\n\tstatic void EnsureStringLiteralQueryTypeLength(int length)\n\t{\n\t\tif (length > FbTypeMappingSource.UnicodeVarcharMaxSize)\n\t\t\tthrow new ArgumentOutOfRangeException(nameof(length));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbStringTypeMapping.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Data;\nusing System.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\npublic class FbStringTypeMapping : StringTypeMapping\n{\n\treadonly FbDbType _fbDbType;\n\n\tpublic FbStringTypeMapping(string storeType, DbType dbType, FbDbType fbDbType, int? size = null, bool unicode = true)\n\t\t: base(storeType, dbType, unicode: unicode, size: size)\n\t{\n\t\t_fbDbType = fbDbType;\n\t}\n\n\tprotected FbStringTypeMapping(RelationalTypeMappingParameters parameters, FbDbType fbDbType)\n\t\t: base(parameters)\n\t{\n\t\t_fbDbType = fbDbType;\n\t}\n\n\tprotected override void ConfigureParameter(DbParameter parameter)\n\t{\n\t\t((FbParameter)parameter).FbDbType = _fbDbType;\n\t}\n\n\tprotected override string GenerateNonNullSqlLiteral(object value)\n\t{\n\t\tvar svalue = value.ToString();\n\t\treturn IsUnicode\n\t\t\t? $\"_UTF8'{EscapeSqlLiteral(svalue)}'\"\n\t\t\t: $\"'{EscapeSqlLiteral(svalue)}'\";\n\t}\n\n\tprotected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)\n\t\t=> new FbStringTypeMapping(parameters, _fbDbType);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbTimeOnlyTypeMapping.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\npublic class FbTimeOnlyTypeMapping : TimeOnlyTypeMapping\n{\n\tpublic FbTimeOnlyTypeMapping(string storeType)\n\t\t: base(storeType)\n\t{ }\n\n\tprotected FbTimeOnlyTypeMapping(RelationalTypeMappingParameters parameters)\n\t\t: base(parameters)\n\t{ }\n\n\tprotected override string GenerateNonNullSqlLiteral(object value)\n\t{\n\t\treturn $\"CAST('{value:HH\\\\:mm\\\\:ss.ffff}' AS TIME)\";\n\t}\n\n\tprotected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)\n\t\t=> new FbTimeOnlyTypeMapping(parameters);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbTimeSpanTypeMapping.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Siegfried Pammer (siegfried.pammer@gmail.com), Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\npublic class FbTimeSpanTypeMapping : TimeSpanTypeMapping\n{\n\treadonly FbDbType _fbDbType;\n\n\tpublic FbTimeSpanTypeMapping(string storeType, FbDbType fbDbType)\n\t\t: base(storeType)\n\t{\n\t\t_fbDbType = fbDbType;\n\t}\n\n\tprotected FbTimeSpanTypeMapping(RelationalTypeMappingParameters parameters, FbDbType fbDbType)\n\t\t: base(parameters)\n\t{\n\t\t_fbDbType = fbDbType;\n\t}\n\n\tprotected override void ConfigureParameter(DbParameter parameter)\n\t{\n\t\t((FbParameter)parameter).FbDbType = _fbDbType;\n\t}\n\n\tprotected override string GenerateNonNullSqlLiteral(object value)\n\t{\n\t\tswitch (_fbDbType)\n\t\t{\n\t\t\tcase FbDbType.Time:\n\t\t\t\treturn $\"CAST('{value:hh\\\\:mm\\\\:ss.ffff}' AS TIME)\";\n\t\t\tdefault:\n\t\t\t\tthrow new ArgumentOutOfRangeException(nameof(_fbDbType), $\"{nameof(_fbDbType)}={_fbDbType}\");\n\t\t}\n\t}\n\n\tprotected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)\n\t\t=> new FbTimeSpanTypeMapping(parameters, _fbDbType);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbTransactionFactory.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data.Common;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\nclass FbTransactionFactory : IRelationalTransactionFactory\n{\n\tpublic FbTransactionFactory(RelationalTransactionFactoryDependencies dependencies)\n\t{\n\t\tDependencies = dependencies;\n\t}\n\n\tprotected virtual RelationalTransactionFactoryDependencies Dependencies { get; }\n\n\tpublic RelationalTransaction Create(IRelationalConnection connection, DbTransaction transaction, Guid transactionId, IDiagnosticsLogger<DbLoggerCategory.Database.Transaction> logger, bool transactionOwned)\n\t\t=> new FbRelationalTransaction(connection, transaction, transactionId, logger, transactionOwned, Dependencies.SqlGenerationHelper);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbTypeMappingSource.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Data;\nusing FirebirdSql.Data.FirebirdClient;\nusing Microsoft.EntityFrameworkCore.Metadata;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\npublic class FbTypeMappingSource : RelationalTypeMappingSource\n{\n\tpublic const int BinaryMaxSize = Int32.MaxValue;\n\tpublic const int UnicodeVarcharMaxSize = VarcharMaxSize / 4;\n\tpublic const int VarcharMaxSize = 32765;\n\tpublic const int DefaultDecimalPrecision = 18;\n\tpublic const int DefaultDecimalScale = 2;\n\n\treadonly FbBoolTypeMapping _boolean = new FbBoolTypeMapping();\n\n\treadonly ShortTypeMapping _smallint = new ShortTypeMapping(\"SMALLINT\", DbType.Int16);\n\treadonly IntTypeMapping _integer = new IntTypeMapping(\"INTEGER\", DbType.Int32);\n\treadonly LongTypeMapping _bigint = new LongTypeMapping(\"BIGINT\", DbType.Int64);\n\n\treadonly FbStringTypeMapping _char = new FbStringTypeMapping(\"CHAR\", DbType.StringFixedLength, FbDbType.Char);\n\treadonly FbStringTypeMapping _varchar = new FbStringTypeMapping(\"VARCHAR\", DbType.String, FbDbType.VarChar);\n\treadonly FbStringTypeMapping _clob = new FbStringTypeMapping(\"BLOB SUB_TYPE TEXT\", DbType.String, FbDbType.Text);\n\n\treadonly FbByteArrayTypeMapping _binary = new FbByteArrayTypeMapping();\n\n\treadonly FloatTypeMapping _float = new FloatTypeMapping(\"FLOAT\");\n\treadonly DoubleTypeMapping _double = new DoubleTypeMapping(\"DOUBLE PRECISION\");\n\treadonly DecimalTypeMapping _decimal = new DecimalTypeMapping($\"DECIMAL({DefaultDecimalPrecision},{DefaultDecimalScale})\");\n\n\treadonly FbDateTimeTypeMapping _timestamp = new FbDateTimeTypeMapping(\"TIMESTAMP\", FbDbType.TimeStamp);\n\treadonly FbDateTimeTypeMapping _date = new FbDateTimeTypeMapping(\"DATE\", FbDbType.Date);\n\treadonly FbDateOnlyTypeMapping _dateOnly = new FbDateOnlyTypeMapping(\"DATE\");\n\n\treadonly FbTimeSpanTypeMapping _timeSpan = new FbTimeSpanTypeMapping(\"TIME\", FbDbType.Time);\n\treadonly FbTimeOnlyTypeMapping _timeOnly = new FbTimeOnlyTypeMapping(\"TIME\");\n\n\treadonly FbGuidTypeMapping _guid = new FbGuidTypeMapping();\n\n\treadonly Dictionary<string, RelationalTypeMapping> _storeTypeMappings;\n\treadonly Dictionary<Type, RelationalTypeMapping> _clrTypeMappings;\n\treadonly HashSet<string> _disallowedMappings;\n\n\tpublic FbTypeMappingSource(TypeMappingSourceDependencies dependencies, RelationalTypeMappingSourceDependencies relationalDependencies)\n\t\t: base(dependencies, relationalDependencies)\n\t{\n\t\t_storeTypeMappings = new Dictionary<string, RelationalTypeMapping>(StringComparer.OrdinalIgnoreCase)\n\t\t{\n\t\t\t{ \"BOOLEAN\", _boolean },\n\t\t\t{ \"SMALLINT\", _smallint },\n\t\t\t{ \"INTEGER\", _integer },\n\t\t\t{ \"BIGINT\", _bigint },\n\t\t\t{ \"CHAR\", _char },\n\t\t\t{ \"VARCHAR\", _varchar },\n\t\t\t{ \"BLOB SUB_TYPE TEXT\", _clob },\n\t\t\t{ \"BLOB SUB_TYPE BINARY\", _binary },\n\t\t\t{ \"FLOAT\", _float },\n\t\t\t{ \"DOUBLE PRECISION\", _double },\n\t\t\t{ \"DECIMAL\", _decimal },\n\t\t\t{ \"TIMESTAMP\", _timestamp },\n\t\t\t{ \"DATE\", _date },\n\t\t\t{ \"TIME\", _timeSpan },\n\t\t\t{ \"CHAR(16) CHARACTER SET OCTETS\", _guid },\n\t\t};\n\n\t\t_clrTypeMappings = new Dictionary<Type, RelationalTypeMapping>()\n\t\t{\n\t\t\t{ typeof(bool), _boolean },\n\t\t\t{ typeof(short), _smallint },\n\t\t\t{ typeof(int), _integer },\n\t\t\t{ typeof(long), _bigint },\n\t\t\t{ typeof(float), _float },\n\t\t\t{ typeof(double), _double},\n\t\t\t{ typeof(decimal), _decimal },\n\t\t\t{ typeof(DateTime), _timestamp },\n\t\t\t{ typeof(TimeSpan), _timeSpan },\n\t\t\t{ typeof(Guid), _guid },\n\t\t\t{ typeof(DateOnly), _dateOnly },\n\t\t\t{ typeof(TimeOnly), _timeOnly },\n\t\t};\n\n\t\t_disallowedMappings = new HashSet<string>(StringComparer.OrdinalIgnoreCase)\n\t\t{\n\t\t\t\"CHARACTER\",\n\t\t\t\"CHAR\",\n\t\t\t\"VARCHAR\",\n\t\t\t\"CHARACTER VARYING\",\n\t\t\t\"CHAR VARYING\",\n\t\t};\n\t}\n\n\tprotected override RelationalTypeMapping FindMapping(in RelationalTypeMappingInfo mappingInfo)\n\t{\n\t\treturn FindRawMapping(mappingInfo)?.Clone(mappingInfo) ?? base.FindMapping(mappingInfo);\n\t}\n\n\tprotected override void ValidateMapping(CoreTypeMapping mapping, IProperty property)\n\t{\n\t\tvar relationalMapping = mapping as RelationalTypeMapping;\n\n\t\tif (_disallowedMappings.Contains(relationalMapping?.StoreType))\n\t\t{\n\t\t\tif (property == null)\n\t\t\t{\n\t\t\t\tthrow new ArgumentException($\"Data type '{relationalMapping.StoreType}' is not supported in this form. Either specify the length explicitly in the type name or remove the data type and use APIs such as HasMaxLength.\");\n\t\t\t}\n\n\t\t\tthrow new ArgumentException($\"Data type '{relationalMapping.StoreType}' for property '{property}' is not supported in this form. Either specify the length explicitly in the type name or remove the data type and use APIs such as HasMaxLength.\");\n\t\t}\n\t}\n\n\tRelationalTypeMapping FindRawMapping(RelationalTypeMappingInfo mappingInfo)\n\t{\n\t\tvar clrType = mappingInfo.ClrType;\n\t\tvar storeTypeName = mappingInfo.StoreTypeName;\n\t\tvar storeTypeNameBase = mappingInfo.StoreTypeNameBase;\n\t\tvar isUnicode = IsUnicode(mappingInfo.IsUnicode);\n\n\t\tif (storeTypeName != null)\n\t\t{\n\t\t\tif (clrType == typeof(float)\n\t\t\t\t&& mappingInfo.Size != null\n\t\t\t\t&& mappingInfo.Size <= 24\n\t\t\t\t&& (storeTypeNameBase.Equals(\"FLOAT\", StringComparison.OrdinalIgnoreCase)\n\t\t\t\t\t|| storeTypeNameBase.Equals(\"DOUBLE PRECISION\", StringComparison.OrdinalIgnoreCase)))\n\t\t\t{\n\t\t\t\treturn _float;\n\t\t\t}\n\n\t\t\tif (_storeTypeMappings.TryGetValue(storeTypeName, out var mapping) || _storeTypeMappings.TryGetValue(storeTypeNameBase, out mapping))\n\t\t\t{\n\t\t\t\treturn clrType == null || mapping.ClrType == clrType\n\t\t\t\t\t? mapping\n\t\t\t\t\t: null;\n\t\t\t}\n\t\t}\n\n\t\tif (clrType != null)\n\t\t{\n\t\t\tif (_clrTypeMappings.TryGetValue(clrType, out var mapping))\n\t\t\t{\n\t\t\t\treturn mapping;\n\t\t\t}\n\n\t\t\tif (clrType == typeof(string))\n\t\t\t{\n\t\t\t\tvar isFixedLength = mappingInfo.IsFixedLength == true;\n\t\t\t\tvar size = mappingInfo.Size ?? (mappingInfo.IsKeyOrIndex ? 256 : (int?)null);\n\t\t\t\tvar maxSize = isUnicode ? UnicodeVarcharMaxSize : VarcharMaxSize;\n\n\t\t\t\tif (size < 0 || size > maxSize)\n\t\t\t\t{\n\t\t\t\t\tsize = isFixedLength ? maxSize : (int?)null;\n\t\t\t\t}\n\n\t\t\t\tif (size == null)\n\t\t\t\t{\n\t\t\t\t\treturn _clob;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (!isFixedLength)\n\t\t\t\t\t{\n\t\t\t\t\t\treturn new FbStringTypeMapping($\"VARCHAR({size})\", DbType.String, FbDbType.VarChar, size, isUnicode);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\treturn new FbStringTypeMapping($\"CHAR({size})\", DbType.StringFixedLength, FbDbType.Char, size, isUnicode);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (clrType == typeof(byte[]))\n\t\t\t{\n\t\t\t\treturn _binary;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tpublic static bool IsUnicode(RelationalTypeMapping mapping) => IsUnicode(mapping?.IsUnicode);\n\tpublic static bool IsUnicode(RelationalTypeMappingInfo mappingInfo) => IsUnicode(mappingInfo.IsUnicode);\n\tpublic static bool IsUnicode(bool? isUnicode) => isUnicode ?? true;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/IFbSqlGenerationHelper.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Text;\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\npublic interface IFbSqlGenerationHelper : ISqlGenerationHelper\n{\n\tstring StringLiteralQueryType(string s, bool isUnicode);\n\tstring StringParameterQueryType(bool isUnicode);\n\tvoid GenerateBlockParameterName(StringBuilder builder, string name);\n\tstring AlternativeStatementTerminator { get; }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/IRelationalFbConnection.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net), Jean Ressouche, Rafael Almeida (ralms@ralms.net)\n\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\npublic interface IFbRelationalConnection : IRelationalConnection\n{ }\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/IRelationalFbTransaction.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Storage;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\n\npublic interface IFbRelationalTransaction\n{ }\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Update/Internal/FbModificationCommandBatchFactory.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Update;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Update.Internal;\n\npublic class FbModificationCommandBatchFactory : IModificationCommandBatchFactory\n{\n\treadonly ModificationCommandBatchFactoryDependencies _dependencies;\n\n\tpublic FbModificationCommandBatchFactory(ModificationCommandBatchFactoryDependencies dependencies)\n\t{\n\t\t_dependencies = dependencies;\n\t}\n\n\tpublic ModificationCommandBatch Create()\n\t{\n\t\treturn new SingularModificationCommandBatch(_dependencies);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Update/Internal/FbUpdateSqlGenerator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\nusing Microsoft.EntityFrameworkCore.Metadata;\nusing Microsoft.EntityFrameworkCore.Storage;\nusing Microsoft.EntityFrameworkCore.Update;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Update.Internal;\n\npublic class FbUpdateSqlGenerator : UpdateSqlGenerator, IFbUpdateSqlGenerator\n{\n\tpublic FbUpdateSqlGenerator(UpdateSqlGeneratorDependencies dependencies)\n\t\t: base(dependencies)\n\t{ }\n\n\tpublic override ResultSetMapping AppendInsertOperation(StringBuilder commandStringBuilder, IReadOnlyModificationCommand command, int commandPosition, out bool requiresTransaction)\n\t{\n\t\tvar result = default(ResultSetMapping);\n\t\tvar name = command.TableName;\n\t\tvar operations = command.ColumnModifications;\n\t\tvar writeOperations = operations.Where(o => o.IsWrite).ToList();\n\t\tvar readOperations = operations.Where(o => o.IsRead).ToList();\n\t\tvar anyRead = readOperations.Any();\n\t\tAppendInsertCommandHeader(commandStringBuilder, name, null, writeOperations);\n\t\tAppendValuesHeader(commandStringBuilder, writeOperations);\n\t\tAppendValues(commandStringBuilder, name, null, writeOperations);\n\t\tif (anyRead)\n\t\t{\n\t\t\tcommandStringBuilder.AppendLine();\n\t\t\tcommandStringBuilder.Append(\"RETURNING \");\n\t\t\tcommandStringBuilder.AppendJoin(readOperations, (b, e) =>\n\t\t\t{\n\t\t\t\tb.Append(SqlGenerationHelper.DelimitIdentifier(e.ColumnName));\n\t\t\t}, \", \");\n\t\t\tresult = ResultSetMapping.HasResultRow;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tresult = ResultSetMapping.NoResults;\n\t\t}\n\t\tcommandStringBuilder.Append(SqlGenerationHelper.StatementTerminator).AppendLine();\n\n\t\trequiresTransaction = true;\n\t\treturn result;\n\t}\n\n\tpublic override ResultSetMapping AppendUpdateOperation(StringBuilder commandStringBuilder, IReadOnlyModificationCommand command, int commandPosition, out bool requiresTransaction)\n\t{\n\t\tvar result = default(ResultSetMapping);\n\t\tvar name = command.TableName;\n\t\tvar operations = command.ColumnModifications;\n\t\tvar writeOperations = operations.Where(o => o.IsWrite).ToList();\n\t\tvar readOperations = operations.Where(o => o.IsRead).ToList();\n\t\tvar conditionOperations = operations.Where(o => o.IsCondition).ToList();\n\t\tvar inputOperations = GenerateParameters(operations.Where(o => o.IsWrite || o.IsCondition)).ToList();\n\t\tvar anyRead = readOperations.Any();\n\t\tcommandStringBuilder.Append(\"EXECUTE BLOCK (\");\n\t\tcommandStringBuilder.AppendJoin(inputOperations, (b, p) =>\n\t\t{\n\t\t\tb.Append(p.name);\n\t\t\tb.Append(\" \");\n\t\t\tb.Append(p.type);\n\t\t\tb.Append(\" = ?\");\n\t\t}, \", \");\n\t\tcommandStringBuilder.AppendLine(\")\");\n\t\tcommandStringBuilder.Append(\"RETURNS (\");\n\t\tif (anyRead)\n\t\t{\n\t\t\tcommandStringBuilder.AppendJoin(readOperations, (b, e) =>\n\t\t\t{\n\t\t\t\tvar type = GetColumnType(e);\n\t\t\t\tb.Append(SqlGenerationHelper.DelimitIdentifier(e.ColumnName));\n\t\t\t\tb.Append(\" \");\n\t\t\t\tb.Append(type);\n\t\t\t}, \", \");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcommandStringBuilder.Append(\"ROWS_AFFECTED INT\");\n\t\t}\n\t\tcommandStringBuilder.AppendLine(\")\");\n\t\tcommandStringBuilder.AppendLine(\"AS\");\n\t\tcommandStringBuilder.AppendLine(\"BEGIN\");\n\t\tAppendUpdateCommandHeader(commandStringBuilder, name, null, writeOperations);\n\t\tAppendWhereClause(commandStringBuilder, conditionOperations);\n\t\tif (anyRead)\n\t\t{\n\t\t\tcommandStringBuilder.AppendLine();\n\t\t\tcommandStringBuilder.Append(\"RETURNING \");\n\t\t\tcommandStringBuilder.AppendJoin(readOperations, (b, e) =>\n\t\t\t{\n\t\t\t\tb.Append(SqlGenerationHelper.DelimitIdentifier(e.ColumnName));\n\t\t\t}, \", \");\n\t\t\tcommandStringBuilder.Append(\" INTO \");\n\t\t\tcommandStringBuilder.AppendJoin(readOperations, (b, e) =>\n\t\t\t{\n\t\t\t\tb.Append(\":\");\n\t\t\t\tb.Append(SqlGenerationHelper.DelimitIdentifier(e.ColumnName));\n\t\t\t}, \", \");\n\t\t}\n\t\tcommandStringBuilder.Append(SqlGenerationHelper.StatementTerminator).AppendLine();\n\t\tif (!anyRead)\n\t\t{\n\t\t\tcommandStringBuilder.AppendLine(\"ROWS_AFFECTED = ROW_COUNT;\");\n\t\t\tcommandStringBuilder.AppendLine(\"SUSPEND;\");\n\t\t\tresult = ResultSetMapping.ResultSetWithRowsAffectedOnly;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcommandStringBuilder.AppendLine(\"IF (ROW_COUNT > 0) THEN\");\n\t\t\tcommandStringBuilder.AppendLine(\"SUSPEND;\");\n\t\t\tresult = ResultSetMapping.HasResultRow;\n\t\t}\n\t\tcommandStringBuilder.Append(\"END\");\n\t\tcommandStringBuilder.Append(SqlGenerationHelper.StatementTerminator).AppendLine();\n\n\t\trequiresTransaction = true;\n\t\treturn result;\n\t}\n\n\tpublic override ResultSetMapping AppendDeleteOperation(StringBuilder commandStringBuilder, IReadOnlyModificationCommand command, int commandPosition, out bool requiresTransaction)\n\t{\n\t\tvar name = command.TableName;\n\t\tvar operations = command.ColumnModifications;\n\t\tvar conditionOperations = operations.Where(o => o.IsCondition).ToList();\n\t\tvar inputOperations = GenerateParameters(conditionOperations);\n\t\tcommandStringBuilder.Append(\"EXECUTE BLOCK (\");\n\t\tcommandStringBuilder.AppendJoin(inputOperations, (b, p) =>\n\t\t{\n\t\t\tb.Append(p.name);\n\t\t\tb.Append(\" \");\n\t\t\tb.Append(p.type);\n\t\t\tb.Append(\" = ?\");\n\t\t}, \", \");\n\t\tcommandStringBuilder.AppendLine(\")\");\n\t\tcommandStringBuilder.AppendLine(\"RETURNS (ROWS_AFFECTED INT)\");\n\t\tcommandStringBuilder.AppendLine(\"AS\");\n\t\tcommandStringBuilder.AppendLine(\"BEGIN\");\n\t\tAppendDeleteCommandHeader(commandStringBuilder, name, null);\n\t\tAppendWhereClause(commandStringBuilder, conditionOperations);\n\t\tcommandStringBuilder.Append(SqlGenerationHelper.StatementTerminator).AppendLine();\n\t\tcommandStringBuilder.AppendLine();\n\t\tcommandStringBuilder.AppendLine(\"ROWS_AFFECTED = ROW_COUNT;\");\n\t\tcommandStringBuilder.AppendLine(\"SUSPEND;\");\n\t\tcommandStringBuilder.Append(\"END\");\n\t\tcommandStringBuilder.Append(SqlGenerationHelper.StatementTerminator).AppendLine();\n\n\t\trequiresTransaction = true;\n\t\treturn ResultSetMapping.ResultSetWithRowsAffectedOnly;\n\t}\n\n\t// workaround for GenerateBlockParameterName\n\tprotected override void AppendUpdateCommandHeader(StringBuilder commandStringBuilder, string name, string schema, IReadOnlyList<IColumnModification> operations)\n\t{\n\t\tcommandStringBuilder.Append(\"UPDATE \");\n\t\tSqlGenerationHelper.DelimitIdentifier(commandStringBuilder, name, schema);\n\t\tcommandStringBuilder.Append(\" SET \")\n\t\t\t.AppendJoin(\n\t\t\t\toperations,\n\t\t\t\tSqlGenerationHelper,\n\t\t\t\t(sb, o, helper) =>\n\t\t\t\t{\n\t\t\t\t\thelper.DelimitIdentifier(sb, o.ColumnName);\n\t\t\t\t\tsb.Append(\" = \");\n\t\t\t\t\tif (!o.UseCurrentValueParameter)\n\t\t\t\t\t{\n\t\t\t\t\t\tAppendSqlLiteral(sb, o.Value, o.Property);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t((IFbSqlGenerationHelper)helper).GenerateBlockParameterName(sb, o.ParameterName);\n\t\t\t\t\t}\n\t\t\t\t});\n\t}\n\n\t// workaround for GenerateBlockParameterName\n\tprotected override void AppendWhereCondition(StringBuilder commandStringBuilder, IColumnModification columnModification, bool useOriginalValue)\n\t{\n\t\tSqlGenerationHelper.DelimitIdentifier(commandStringBuilder, columnModification.ColumnName);\n\t\tif ((useOriginalValue ? columnModification.OriginalValue : columnModification.Value) == null)\n\t\t{\n\t\t\tcommandStringBuilder.Append(\" IS NULL\");\n\t\t\treturn;\n\t\t}\n\n\t\tcommandStringBuilder.Append(\" = \");\n\t\tif (!columnModification.UseCurrentValueParameter && !columnModification.UseOriginalValueParameter)\n\t\t{\n\t\t\tAppendSqlLiteral(commandStringBuilder, columnModification.Value, columnModification.Property);\n\t\t}\n\t\telse\n\t\t{\n\t\t\t((IFbSqlGenerationHelper)SqlGenerationHelper).GenerateBlockParameterName(commandStringBuilder, useOriginalValue ? columnModification.OriginalParameterName : columnModification.ParameterName);\n\t\t}\n\t}\n\n\tstring GetColumnType(IColumnModification column)\n\t{\n\t\treturn Dependencies.TypeMappingSource.GetMapping(column.Property).StoreType;\n\t}\n\n\tIEnumerable<(string name, string type)> GenerateParameters(IEnumerable<IColumnModification> columns)\n\t{\n\t\tforeach (var item in columns)\n\t\t{\n\t\t\tvar type = GetColumnType(item);\n\t\t\tif (item.UseCurrentValueParameter)\n\t\t\t{\n\t\t\t\tyield return (item.ParameterName, type);\n\t\t\t}\n\t\t\tif (item.UseOriginalValueParameter)\n\t\t\t{\n\t\t\t\tyield return (item.OriginalParameterName, type);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override string GenerateNextSequenceValueOperation(string name, string schema)\n\t{\n\t\tvar builder = new StringBuilder();\n\t\tbuilder.Append(\"SELECT NEXT VALUE FOR \");\n\t\tbuilder.Append(SqlGenerationHelper.DelimitIdentifier(name));\n\t\tbuilder.Append(\" FROM RDB$DATABASE\");\n\t\treturn builder.ToString();\n\t}\n\n\t/*override*/\n\tvoid AppendSqlLiteral(StringBuilder commandStringBuilder, object value, IProperty property)\n\t{\n\t\tvar mapping = property != null\n\t\t\t? Dependencies.TypeMappingSource.FindMapping(property)\n\t\t\t: null;\n\t\tmapping ??= Dependencies.TypeMappingSource.GetMappingForValue(value);\n\t\tcommandStringBuilder.Append(mapping.GenerateProviderValueSqlLiteral(value));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Update/Internal/IFbUpdateSqlGenerator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Update;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Update.Internal;\n\npublic interface IFbUpdateSqlGenerator : IUpdateSqlGenerator\n{ }\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Utilities/EnumerableMethods.cs",
    "content": "﻿// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n\n#nullable enable\n\nusing System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\n\nnamespace Microsoft.EntityFrameworkCore;\n\ninternal static class EnumerableMethods\n{\n\t//public static MethodInfo AggregateWithoutSeed { get; }\n\n\t//public static MethodInfo AggregateWithSeedWithoutSelector { get; }\n\n\t//public static MethodInfo AggregateWithSeedSelector { get; }\n\n\tpublic static MethodInfo All { get; }\n\n\tpublic static MethodInfo AnyWithoutPredicate { get; }\n\n\tpublic static MethodInfo AnyWithPredicate { get; }\n\n\t//public static Append { get; }\n\n\tpublic static MethodInfo AsEnumerable { get; }\n\n\tpublic static MethodInfo Cast { get; }\n\n\tpublic static MethodInfo Concat { get; }\n\n\tpublic static MethodInfo Contains { get; }\n\n\t//public static MethodInfo ContainsWithComparer { get; }\n\n\tpublic static MethodInfo CountWithoutPredicate { get; }\n\n\tpublic static MethodInfo CountWithPredicate { get; }\n\n\tpublic static MethodInfo DefaultIfEmptyWithoutArgument { get; }\n\n\tpublic static MethodInfo DefaultIfEmptyWithArgument { get; }\n\n\tpublic static MethodInfo Distinct { get; }\n\n\t//public static MethodInfo DistinctWithComparer { get; }\n\n\tpublic static MethodInfo ElementAt { get; }\n\n\tpublic static MethodInfo ElementAtOrDefault { get; }\n\n\t//public static MethodInfo Empty { get; }\n\n\tpublic static MethodInfo Except { get; }\n\n\t//public static MethodInfo ExceptWithComparer { get; }\n\n\tpublic static MethodInfo FirstWithoutPredicate { get; }\n\n\tpublic static MethodInfo FirstWithPredicate { get; }\n\n\tpublic static MethodInfo FirstOrDefaultWithoutPredicate { get; }\n\n\tpublic static MethodInfo FirstOrDefaultWithPredicate { get; }\n\n\tpublic static MethodInfo GroupByWithKeySelector { get; }\n\n\tpublic static MethodInfo GroupByWithKeyElementSelector { get; }\n\n\t//public static MethodInfo GroupByWithKeySelectorAndComparer { get; }\n\n\t//public static MethodInfo GroupByWithKeyElementSelectorAndComparer { get; }\n\n\tpublic static MethodInfo GroupByWithKeyElementResultSelector { get; }\n\n\tpublic static MethodInfo GroupByWithKeyResultSelector { get; }\n\n\t//public static MethodInfo GroupByWithKeyResultSelectorAndComparer { get; }\n\n\t//public static MethodInfo GroupByWithKeyElementResultSelectorAndComparer { get; }\n\n\tpublic static MethodInfo GroupJoin { get; }\n\n\t//public static MethodInfo GroupJoinWithComparer { get; }\n\n\tpublic static MethodInfo Intersect { get; }\n\n\t//public static MethodInfo IntersectWithComparer { get; }\n\n\tpublic static MethodInfo Join { get; }\n\n\t//public static MethodInfo JoinWithComparer { get; }\n\n\tpublic static MethodInfo LastWithoutPredicate { get; }\n\n\tpublic static MethodInfo LastWithPredicate { get; }\n\n\tpublic static MethodInfo LastOrDefaultWithoutPredicate { get; }\n\n\tpublic static MethodInfo LastOrDefaultWithPredicate { get; }\n\n\tpublic static MethodInfo LongCountWithoutPredicate { get; }\n\n\tpublic static MethodInfo LongCountWithPredicate { get; }\n\n\tpublic static MethodInfo MaxWithoutSelector { get; }\n\n\tpublic static MethodInfo MaxWithSelector { get; }\n\n\tpublic static MethodInfo MinWithoutSelector { get; }\n\n\tpublic static MethodInfo MinWithSelector { get; }\n\n\tpublic static MethodInfo OfType { get; }\n\n\tpublic static MethodInfo OrderBy { get; }\n\n\t//public static MethodInfo OrderByWithComparer { get; }\n\n\tpublic static MethodInfo OrderByDescending { get; }\n\n\t//public static MethodInfo OrderByDescendingWithComparer { get; }\n\n\t//public static MethodInfo Prepend { get; }\n\n\t//public static MethodInfo Range { get; }\n\n\t//public static MethodInfo Repeat { get; }\n\n\tpublic static MethodInfo Reverse { get; }\n\n\tpublic static MethodInfo Select { get; }\n\n\tpublic static MethodInfo SelectWithOrdinal { get; }\n\n\tpublic static MethodInfo SelectManyWithoutCollectionSelector { get; }\n\n\t//public static MethodInfo SelectManyWithoutCollectionSelectorOrdinal { get; }\n\n\tpublic static MethodInfo SelectManyWithCollectionSelector { get; }\n\n\t//public static MethodInfo SelectManyWithCollectionSelectorOrdinal { get; }\n\n\tpublic static MethodInfo SequenceEqual { get; }\n\n\t//public static MethodInfo SequenceEqualWithComparer { get; }\n\n\tpublic static MethodInfo SingleWithoutPredicate { get; }\n\n\tpublic static MethodInfo SingleWithPredicate { get; }\n\n\tpublic static MethodInfo SingleOrDefaultWithoutPredicate { get; }\n\n\tpublic static MethodInfo SingleOrDefaultWithPredicate { get; }\n\n\tpublic static MethodInfo Skip { get; }\n\n\tpublic static MethodInfo SkipWhile { get; }\n\n\t//public static MethodInfo SkipWhileOrdinal { get; }\n\n\tpublic static MethodInfo Take { get; }\n\n\tpublic static MethodInfo TakeWhile { get; }\n\n\t//public static MethodInfo TakeWhileOrdinal { get; }\n\n\tpublic static MethodInfo ThenBy { get; }\n\n\t//public static MethodInfo ThenByWithComparer { get; }\n\n\tpublic static MethodInfo ThenByDescending { get; }\n\n\t//public static MethodInfo ThenByDescendingWithComparer { get; }\n\n\tpublic static MethodInfo ToArray { get; }\n\n\t//public static MethodInfo ToDictionaryWithKeySelector { get; }\n\t//public static MethodInfo ToDictionaryWithKeySelectorAndComparer { get; }\n\t//public static MethodInfo ToDictionaryWithKeyElementSelector { get; }\n\t//public static MethodInfo ToDictionaryWithKeyElementSelectorAndComparer { get; }\n\n\t//public static MethodInfo ToHashSet { get; }\n\t//public static MethodInfo ToHashSetWithComparer { get; }\n\n\tpublic static MethodInfo ToList { get; }\n\n\t//public static MethodInfo ToLookupWithKeySelector { get; }\n\t//public static MethodInfo ToLookupWithKeySelectorAndComparer { get; }\n\t//public static MethodInfo ToLookupWithKeyElementSelector { get; }\n\t//public static MethodInfo ToLookupWithKeyElementSelectorAndComparer { get; }\n\n\tpublic static MethodInfo Union { get; }\n\n\t//public static MethodInfo UnionWithComparer { get; }\n\n\tpublic static MethodInfo Where { get; }\n\n\t//public static MethodInfo WhereOrdinal { get; }\n\n\t//public static MethodInfo Zip { get; }\n\n\t// private static Dictionary<Type, MethodInfo> SumWithoutSelectorMethods { get; }\n\tprivate static Dictionary<Type, MethodInfo> SumWithSelectorMethods { get; }\n\n\t// private static Dictionary<Type, MethodInfo> AverageWithoutSelectorMethods { get; }\n\tprivate static Dictionary<Type, MethodInfo> AverageWithSelectorMethods { get; }\n\tprivate static Dictionary<Type, MethodInfo> MaxWithoutSelectorMethods { get; }\n\tprivate static Dictionary<Type, MethodInfo> MaxWithSelectorMethods { get; }\n\tprivate static Dictionary<Type, MethodInfo> MinWithoutSelectorMethods { get; }\n\tprivate static Dictionary<Type, MethodInfo> MinWithSelectorMethods { get; }\n\n\t// Not currently used\n\t//\n\t// public static bool IsSumWithoutSelector(MethodInfo methodInfo)\n\t//     => SumWithoutSelectorMethods.Values.Contains(methodInfo);\n\t//\n\t// public static bool IsSumWithSelector(MethodInfo methodInfo)\n\t//     => methodInfo.IsGenericMethod\n\t//         && SumWithSelectorMethods.Values.Contains(methodInfo.GetGenericMethodDefinition());\n\t//\n\t// public static bool IsAverageWithoutSelector(MethodInfo methodInfo)\n\t//     => AverageWithoutSelectorMethods.Values.Contains(methodInfo);\n\t//\n\t// public static bool IsAverageWithSelector(MethodInfo methodInfo)\n\t//     => methodInfo.IsGenericMethod\n\t//         && AverageWithSelectorMethods.Values.Contains(methodInfo.GetGenericMethodDefinition());\n\t//\n\t// public static MethodInfo GetSumWithoutSelector(Type type)\n\t//     => SumWithoutSelectorMethods[type];\n\n\tpublic static MethodInfo GetSumWithSelector(Type type)\n\t\t=> SumWithSelectorMethods[type];\n\n\t// public static MethodInfo GetAverageWithoutSelector(Type type)\n\t//     => AverageWithoutSelectorMethods[type];\n\n\tpublic static MethodInfo GetAverageWithSelector(Type type)\n\t\t=> AverageWithSelectorMethods[type];\n\n\tpublic static MethodInfo GetMaxWithoutSelector(Type type)\n\t\t=> MaxWithoutSelectorMethods.TryGetValue(type, out var method)\n\t\t\t? method\n\t\t\t: MaxWithoutSelector;\n\n\tpublic static MethodInfo GetMaxWithSelector(Type type)\n\t\t=> MaxWithSelectorMethods.TryGetValue(type, out var method)\n\t\t\t? method\n\t\t\t: MaxWithSelector;\n\n\tpublic static MethodInfo GetMinWithoutSelector(Type type)\n\t\t=> MinWithoutSelectorMethods.TryGetValue(type, out var method)\n\t\t\t? method\n\t\t\t: MinWithoutSelector;\n\n\tpublic static MethodInfo GetMinWithSelector(Type type)\n\t\t=> MinWithSelectorMethods.TryGetValue(type, out var method)\n\t\t\t? method\n\t\t\t: MinWithSelector;\n\n\tstatic EnumerableMethods()\n\t{\n\t\tvar queryableMethodGroups = typeof(Enumerable)\n\t\t\t.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly)\n\t\t\t.GroupBy(mi => mi.Name)\n\t\t\t.ToDictionary(e => e.Key, l => l.ToList());\n\n\t\tAll = GetMethod(\n\t\t\tnameof(Enumerable.All), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) });\n\n\t\tAnyWithoutPredicate = GetMethod(\n\t\t\tnameof(Enumerable.Any), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tAnyWithPredicate = GetMethod(\n\t\t\tnameof(Enumerable.Any), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) });\n\n\t\tAsEnumerable = GetMethod(\n\t\t\tnameof(Enumerable.AsEnumerable), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tCast = GetMethod(nameof(Enumerable.Cast), 1, _ => new[] { typeof(IEnumerable) });\n\n\t\tConcat = GetMethod(\n\t\t\tnameof(Enumerable.Concat), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tContains = GetMethod(\n\t\t\tnameof(Enumerable.Contains), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), types[0] });\n\n\t\tCountWithoutPredicate = GetMethod(\n\t\t\tnameof(Enumerable.Count), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tCountWithPredicate = GetMethod(\n\t\t\tnameof(Enumerable.Count), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) });\n\n\t\tDefaultIfEmptyWithoutArgument = GetMethod(\n\t\t\tnameof(Enumerable.DefaultIfEmpty), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tDefaultIfEmptyWithArgument = GetMethod(\n\t\t\tnameof(Enumerable.DefaultIfEmpty), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), types[0] });\n\n\t\tDistinct = GetMethod(nameof(Enumerable.Distinct), 1, types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tElementAt = GetMethod(\n\t\t\tnameof(Enumerable.ElementAt), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(int) });\n\n\t\tElementAtOrDefault = GetMethod(\n\t\t\tnameof(Enumerable.ElementAtOrDefault), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(int) });\n\n\t\tExcept = GetMethod(\n\t\t\tnameof(Enumerable.Except), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tFirstWithoutPredicate = GetMethod(\n\t\t\tnameof(Enumerable.First), 1, types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tFirstWithPredicate = GetMethod(\n\t\t\tnameof(Enumerable.First), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) });\n\n\t\tFirstOrDefaultWithoutPredicate = GetMethod(\n\t\t\tnameof(Enumerable.FirstOrDefault), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tFirstOrDefaultWithPredicate = GetMethod(\n\t\t\tnameof(Enumerable.FirstOrDefault), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) });\n\n\t\tGroupByWithKeySelector = GetMethod(\n\t\t\tnameof(Enumerable.GroupBy), 2,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], types[1]) });\n\n\t\tGroupByWithKeyElementSelector = GetMethod(\n\t\t\tnameof(Enumerable.GroupBy), 3,\n\t\t\ttypes => new[]\n\t\t\t{\n\t\t\t\ttypeof(IEnumerable<>).MakeGenericType(types[0]),\n\t\t\t\ttypeof(Func<,>).MakeGenericType(types[0], types[1]),\n\t\t\t\ttypeof(Func<,>).MakeGenericType(types[0], types[2])\n\t\t\t});\n\n\t\tGroupByWithKeyElementResultSelector = GetMethod(\n\t\t\tnameof(Enumerable.GroupBy), 4,\n\t\t\ttypes => new[]\n\t\t\t{\n\t\t\t\ttypeof(IEnumerable<>).MakeGenericType(types[0]),\n\t\t\t\ttypeof(Func<,>).MakeGenericType(types[0], types[1]),\n\t\t\t\ttypeof(Func<,>).MakeGenericType(types[0], types[2]),\n\t\t\t\ttypeof(Func<,,>).MakeGenericType(\n\t\t\t\t\ttypes[1], typeof(IEnumerable<>).MakeGenericType(types[2]), types[3])\n\t\t\t});\n\n\t\tGroupByWithKeyResultSelector = GetMethod(\n\t\t\tnameof(Enumerable.GroupBy), 3,\n\t\t\ttypes => new[]\n\t\t\t{\n\t\t\t\ttypeof(IEnumerable<>).MakeGenericType(types[0]),\n\t\t\t\ttypeof(Func<,>).MakeGenericType(types[0], types[1]),\n\t\t\t\ttypeof(Func<,,>).MakeGenericType(\n\t\t\t\t\ttypes[1], typeof(IEnumerable<>).MakeGenericType(types[0]), types[2])\n\t\t\t});\n\n\t\tGroupJoin = GetMethod(\n\t\t\tnameof(Enumerable.GroupJoin), 4,\n\t\t\ttypes => new[]\n\t\t\t{\n\t\t\t\ttypeof(IEnumerable<>).MakeGenericType(types[0]),\n\t\t\t\ttypeof(IEnumerable<>).MakeGenericType(types[1]),\n\t\t\t\ttypeof(Func<,>).MakeGenericType(types[0], types[2]),\n\t\t\t\ttypeof(Func<,>).MakeGenericType(types[1], types[2]),\n\t\t\t\ttypeof(Func<,,>).MakeGenericType(\n\t\t\t\t\ttypes[0], typeof(IEnumerable<>).MakeGenericType(types[1]), types[3])\n\t\t\t});\n\n\t\tIntersect = GetMethod(\n\t\t\tnameof(Enumerable.Intersect), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tJoin = GetMethod(\n\t\t\tnameof(Enumerable.Join), 4,\n\t\t\ttypes => new[]\n\t\t\t{\n\t\t\t\ttypeof(IEnumerable<>).MakeGenericType(types[0]),\n\t\t\t\ttypeof(IEnumerable<>).MakeGenericType(types[1]),\n\t\t\t\ttypeof(Func<,>).MakeGenericType(types[0], types[2]),\n\t\t\t\ttypeof(Func<,>).MakeGenericType(types[1], types[2]),\n\t\t\t\ttypeof(Func<,,>).MakeGenericType(types[0], types[1], types[3])\n\t\t\t});\n\n\t\tLastWithoutPredicate = GetMethod(\n\t\t\tnameof(Enumerable.Last), 1, types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tLastWithPredicate = GetMethod(\n\t\t\tnameof(Enumerable.Last), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) });\n\n\t\tLastOrDefaultWithoutPredicate = GetMethod(\n\t\t\tnameof(Enumerable.LastOrDefault), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tLastOrDefaultWithPredicate = GetMethod(\n\t\t\tnameof(Enumerable.LastOrDefault), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) });\n\n\t\tLongCountWithoutPredicate = GetMethod(\n\t\t\tnameof(Enumerable.LongCount), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tLongCountWithPredicate = GetMethod(\n\t\t\tnameof(Enumerable.LongCount), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) });\n\n\t\tMaxWithoutSelector = GetMethod(nameof(Enumerable.Max), 1, types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tMaxWithSelector = GetMethod(\n\t\t\tnameof(Enumerable.Max), 2,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], types[1]) });\n\n\t\tMinWithoutSelector = GetMethod(nameof(Enumerable.Min), 1, types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tMinWithSelector = GetMethod(\n\t\t\tnameof(Enumerable.Min), 2,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], types[1]) });\n\n\t\tOfType = GetMethod(nameof(Enumerable.OfType), 1, _ => new[] { typeof(IEnumerable) });\n\n\t\tOrderBy = GetMethod(\n\t\t\tnameof(Enumerable.OrderBy), 2,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], types[1]) });\n\n\t\tOrderByDescending = GetMethod(\n\t\t\tnameof(Enumerable.OrderByDescending), 2,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], types[1]) });\n\n\t\tReverse = GetMethod(nameof(Enumerable.Reverse), 1, types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tSelect = GetMethod(\n\t\t\tnameof(Enumerable.Select), 2,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], types[1]) });\n\n\t\tSelectWithOrdinal = GetMethod(\n\t\t\tnameof(Enumerable.Select), 2,\n\t\t\ttypes => new[]\n\t\t\t{\n\t\t\t\ttypeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,,>).MakeGenericType(types[0], typeof(int), types[1])\n\t\t\t});\n\n\t\tSelectManyWithoutCollectionSelector = GetMethod(\n\t\t\tnameof(Enumerable.SelectMany), 2,\n\t\t\ttypes => new[]\n\t\t\t{\n\t\t\t\ttypeof(IEnumerable<>).MakeGenericType(types[0]),\n\t\t\t\ttypeof(Func<,>).MakeGenericType(\n\t\t\t\t\ttypes[0], typeof(IEnumerable<>).MakeGenericType(types[1]))\n\t\t\t});\n\n\t\tSelectManyWithCollectionSelector = GetMethod(\n\t\t\tnameof(Enumerable.SelectMany), 3,\n\t\t\ttypes => new[]\n\t\t\t{\n\t\t\t\ttypeof(IEnumerable<>).MakeGenericType(types[0]),\n\t\t\t\ttypeof(Func<,>).MakeGenericType(\n\t\t\t\t\ttypes[0], typeof(IEnumerable<>).MakeGenericType(types[1])),\n\t\t\t\ttypeof(Func<,,>).MakeGenericType(types[0], types[1], types[2])\n\t\t\t});\n\n\t\tSequenceEqual = GetMethod(\n\t\t\tnameof(Enumerable.SequenceEqual), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tSingleWithoutPredicate = GetMethod(\n\t\t\tnameof(Enumerable.Single), 1, types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tSingleWithPredicate = GetMethod(\n\t\t\tnameof(Enumerable.Single), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) });\n\n\t\tSingleOrDefaultWithoutPredicate = GetMethod(\n\t\t\tnameof(Enumerable.SingleOrDefault), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tSingleOrDefaultWithPredicate = GetMethod(\n\t\t\tnameof(Enumerable.SingleOrDefault), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) });\n\n\t\tSkip = GetMethod(\n\t\t\tnameof(Enumerable.Skip), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(int) });\n\n\t\tSkipWhile = GetMethod(\n\t\t\tnameof(Enumerable.SkipWhile), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) });\n\n\t\tToArray = GetMethod(nameof(Enumerable.ToArray), 1, types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tToList = GetMethod(nameof(Enumerable.ToList), 1, types => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tTake = GetMethod(\n\t\t\tnameof(Enumerable.Take), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(int) });\n\n\t\tTakeWhile = GetMethod(\n\t\t\tnameof(Enumerable.TakeWhile), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) });\n\n\t\tThenBy = GetMethod(\n\t\t\tnameof(Enumerable.ThenBy), 2,\n\t\t\ttypes => new[] { typeof(IOrderedEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], types[1]) });\n\n\t\tThenByDescending = GetMethod(\n\t\t\tnameof(Enumerable.ThenByDescending), 2,\n\t\t\ttypes => new[] { typeof(IOrderedEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], types[1]) });\n\n\t\tUnion = GetMethod(\n\t\t\tnameof(Enumerable.Union), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(IEnumerable<>).MakeGenericType(types[0]) });\n\n\t\tWhere = GetMethod(\n\t\t\tnameof(Enumerable.Where), 1,\n\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], typeof(bool)) });\n\n\t\tvar numericTypes = new[]\n\t\t{\n\t\t\ttypeof(int),\n\t\t\ttypeof(int?),\n\t\t\ttypeof(long),\n\t\t\ttypeof(long?),\n\t\t\ttypeof(float),\n\t\t\ttypeof(float?),\n\t\t\ttypeof(double),\n\t\t\ttypeof(double?),\n\t\t\ttypeof(decimal),\n\t\t\ttypeof(decimal?)\n\t\t};\n\n\t\t// AverageWithoutSelectorMethods = new Dictionary<Type, MethodInfo>();\n\t\tAverageWithSelectorMethods = new Dictionary<Type, MethodInfo>();\n\t\tMaxWithoutSelectorMethods = new Dictionary<Type, MethodInfo>();\n\t\tMaxWithSelectorMethods = new Dictionary<Type, MethodInfo>();\n\t\tMinWithoutSelectorMethods = new Dictionary<Type, MethodInfo>();\n\t\tMinWithSelectorMethods = new Dictionary<Type, MethodInfo>();\n\t\t// SumWithoutSelectorMethods = new Dictionary<Type, MethodInfo>();\n\t\tSumWithSelectorMethods = new Dictionary<Type, MethodInfo>();\n\n\t\tforeach (var type in numericTypes)\n\t\t{\n\t\t\t// AverageWithoutSelectorMethods[type] = GetMethod(\n\t\t\t//     nameof(Enumerable.Average), 0, types => new[] { typeof(IEnumerable<>).MakeGenericType(type) });\n\t\t\tAverageWithSelectorMethods[type] = GetMethod(\n\t\t\t\tnameof(Enumerable.Average), 1,\n\t\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], type) });\n\t\t\tMaxWithoutSelectorMethods[type] = GetMethod(\n\t\t\t\tnameof(Enumerable.Max), 0, _ => new[] { typeof(IEnumerable<>).MakeGenericType(type) });\n\t\t\tMaxWithSelectorMethods[type] = GetMethod(\n\t\t\t\tnameof(Enumerable.Max), 1,\n\t\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], type) });\n\t\t\tMinWithoutSelectorMethods[type] = GetMethod(\n\t\t\t\tnameof(Enumerable.Min), 0, _ => new[] { typeof(IEnumerable<>).MakeGenericType(type) });\n\t\t\tMinWithSelectorMethods[type] = GetMethod(\n\t\t\t\tnameof(Enumerable.Min), 1,\n\t\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], type) });\n\t\t\t// SumWithoutSelectorMethods[type] = GetMethod(\n\t\t\t//     nameof(Enumerable.Sum), 0, types => new[] { typeof(IEnumerable<>).MakeGenericType(type) });\n\t\t\tSumWithSelectorMethods[type] = GetMethod(\n\t\t\t\tnameof(Enumerable.Sum), 1,\n\t\t\t\ttypes => new[] { typeof(IEnumerable<>).MakeGenericType(types[0]), typeof(Func<,>).MakeGenericType(types[0], type) });\n\t\t}\n\n\t\tMethodInfo GetMethod(string name, int genericParameterCount, Func<Type[], Type[]> parameterGenerator)\n\t\t\t=> queryableMethodGroups[name].Single(\n\t\t\t\tmi => ((genericParameterCount == 0 && !mi.IsGenericMethod)\n\t\t\t\t\t\t|| (mi.IsGenericMethod && mi.GetGenericArguments().Length == genericParameterCount))\n\t\t\t\t\t&& mi.GetParameters().Select(e => e.ParameterType).SequenceEqual(\n\t\t\t\t\t\tparameterGenerator(mi.IsGenericMethod ? mi.GetGenericArguments() : Array.Empty<Type>())));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Utilities/SharedTypeExtensions.cs",
    "content": "﻿// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n\n#nullable enable\n\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Text;\n\n// ReSharper disable once CheckNamespace\nnamespace System;\n\n[DebuggerStepThrough]\ninternal static class SharedTypeExtensions\n{\n\tprivate static readonly Dictionary<Type, string> BuiltInTypeNames = new()\n\t{\n\t\t{ typeof(bool), \"bool\" },\n\t\t{ typeof(byte), \"byte\" },\n\t\t{ typeof(char), \"char\" },\n\t\t{ typeof(decimal), \"decimal\" },\n\t\t{ typeof(double), \"double\" },\n\t\t{ typeof(float), \"float\" },\n\t\t{ typeof(int), \"int\" },\n\t\t{ typeof(long), \"long\" },\n\t\t{ typeof(object), \"object\" },\n\t\t{ typeof(sbyte), \"sbyte\" },\n\t\t{ typeof(short), \"short\" },\n\t\t{ typeof(string), \"string\" },\n\t\t{ typeof(uint), \"uint\" },\n\t\t{ typeof(ulong), \"ulong\" },\n\t\t{ typeof(ushort), \"ushort\" },\n\t\t{ typeof(void), \"void\" }\n\t};\n\n\tpublic static Type UnwrapNullableType(this Type type)\n\t\t=> Nullable.GetUnderlyingType(type) ?? type;\n\n\tpublic static bool IsNullableValueType(this Type type)\n\t\t=> type.IsConstructedGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);\n\n\tpublic static bool IsNullableType(this Type type)\n\t\t=> !type.IsValueType || type.IsNullableValueType();\n\n\tpublic static bool IsValidEntityType(this Type type)\n\t\t=> type.IsClass\n\t\t\t&& !type.IsArray;\n\n\tpublic static bool IsPropertyBagType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] this Type type)\n\t{\n\t\tif (type.IsGenericTypeDefinition)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\n\t\tvar types = GetGenericTypeImplementations(type, typeof(IDictionary<,>));\n\t\treturn types.Any(\n\t\t\tt => t.GetGenericArguments()[0] == typeof(string)\n\t\t\t\t&& t.GetGenericArguments()[1] == typeof(object));\n\t}\n\n\tpublic static Type MakeNullable(this Type type, bool nullable = true)\n\t\t=> type.IsNullableType() == nullable\n\t\t\t? type\n\t\t\t: nullable\n\t\t\t\t? typeof(Nullable<>).MakeGenericType(type)\n\t\t\t\t: type.UnwrapNullableType();\n\n\tpublic static bool IsNumeric(this Type type)\n\t{\n\t\ttype = type.UnwrapNullableType();\n\n\t\treturn type.IsInteger()\n\t\t\t|| type == typeof(decimal)\n\t\t\t|| type == typeof(float)\n\t\t\t|| type == typeof(double);\n\t}\n\n\tpublic static bool IsInteger(this Type type)\n\t{\n\t\ttype = type.UnwrapNullableType();\n\n\t\treturn type == typeof(int)\n\t\t\t|| type == typeof(long)\n\t\t\t|| type == typeof(short)\n\t\t\t|| type == typeof(byte)\n\t\t\t|| type == typeof(uint)\n\t\t\t|| type == typeof(ulong)\n\t\t\t|| type == typeof(ushort)\n\t\t\t|| type == typeof(sbyte)\n\t\t\t|| type == typeof(char);\n\t}\n\n\tpublic static bool IsSignedInteger(this Type type)\n\t\t=> type == typeof(int)\n\t\t\t|| type == typeof(long)\n\t\t\t|| type == typeof(short)\n\t\t\t|| type == typeof(sbyte);\n\n\tpublic static bool IsAnonymousType(this Type type)\n\t\t=> type.Name.StartsWith(\"<>\", StringComparison.Ordinal)\n\t\t\t&& type.GetCustomAttributes(typeof(CompilerGeneratedAttribute), inherit: false).Length > 0\n\t\t\t&& type.Name.Contains(\"AnonymousType\");\n\n\tpublic static PropertyInfo? GetAnyProperty(\n\t\t[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.NonPublicProperties)]\n\t\tthis Type type,\n\t\tstring name)\n\t{\n\t\tvar props = type.GetRuntimeProperties().Where(p => p.Name == name).ToList();\n\t\tif (props.Count > 1)\n\t\t{\n\t\t\tthrow new AmbiguousMatchException();\n\t\t}\n\n\t\treturn props.SingleOrDefault();\n\t}\n\n\tpublic static bool IsInstantiable(this Type type)\n\t\t=> !type.IsAbstract\n\t\t\t&& !type.IsInterface\n\t\t\t&& (!type.IsGenericType || !type.IsGenericTypeDefinition);\n\n\tpublic static Type UnwrapEnumType(this Type type)\n\t{\n\t\tvar isNullable = type.IsNullableType();\n\t\tvar underlyingNonNullableType = isNullable ? type.UnwrapNullableType() : type;\n\t\tif (!underlyingNonNullableType.IsEnum)\n\t\t{\n\t\t\treturn type;\n\t\t}\n\n\t\tvar underlyingEnumType = Enum.GetUnderlyingType(underlyingNonNullableType);\n\t\treturn isNullable ? MakeNullable(underlyingEnumType) : underlyingEnumType;\n\t}\n\n\tpublic static Type GetSequenceType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] this Type type)\n\t{\n\t\tvar sequenceType = TryGetSequenceType(type);\n\t\tif (sequenceType == null)\n\t\t{\n\t\t\tthrow new ArgumentException($\"The type {type.Name} does not represent a sequence\");\n\t\t}\n\n\t\treturn sequenceType;\n\t}\n\n\tpublic static Type? TryGetSequenceType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] this Type type)\n\t\t=> type.TryGetElementType(typeof(IEnumerable<>))\n\t\t\t?? type.TryGetElementType(typeof(IAsyncEnumerable<>));\n\n\tpublic static Type? TryGetElementType(\n\t\t[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] this Type type,\n\t\tType interfaceOrBaseType)\n\t{\n\t\tif (type.IsGenericTypeDefinition)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\n\t\tvar types = GetGenericTypeImplementations(type, interfaceOrBaseType);\n\n\t\tType? singleImplementation = null;\n\t\tforeach (var implementation in types)\n\t\t{\n\t\t\tif (singleImplementation == null)\n\t\t\t{\n\t\t\t\tsingleImplementation = implementation;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tsingleImplementation = null;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn singleImplementation?.GenericTypeArguments.FirstOrDefault();\n\t}\n\n\tpublic static bool IsCompatibleWith(this Type propertyType, Type fieldType)\n\t{\n\t\tif (propertyType.IsAssignableFrom(fieldType)\n\t\t\t|| fieldType.IsAssignableFrom(propertyType))\n\t\t{\n\t\t\treturn true;\n\t\t}\n\n\t\tvar propertyElementType = propertyType.TryGetSequenceType();\n\t\tvar fieldElementType = fieldType.TryGetSequenceType();\n\n\t\treturn propertyElementType != null\n\t\t\t&& fieldElementType != null\n\t\t\t&& IsCompatibleWith(propertyElementType, fieldElementType);\n\t}\n\n\tpublic static IEnumerable<Type> GetGenericTypeImplementations(this Type type, Type interfaceOrBaseType)\n\t{\n\t\tvar typeInfo = type.GetTypeInfo();\n\t\tif (!typeInfo.IsGenericTypeDefinition)\n\t\t{\n\t\t\tvar baseTypes = interfaceOrBaseType.GetTypeInfo().IsInterface\n\t\t\t\t? typeInfo.ImplementedInterfaces\n\t\t\t\t: type.GetBaseTypes();\n\t\t\tforeach (var baseType in baseTypes)\n\t\t\t{\n\t\t\t\tif (baseType.IsGenericType\n\t\t\t\t\t&& baseType.GetGenericTypeDefinition() == interfaceOrBaseType)\n\t\t\t\t{\n\t\t\t\t\tyield return baseType;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (type.IsGenericType\n\t\t\t\t&& type.GetGenericTypeDefinition() == interfaceOrBaseType)\n\t\t\t{\n\t\t\t\tyield return type;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static IEnumerable<Type> GetBaseTypes(this Type type)\n\t{\n\t\tvar currentType = type.BaseType;\n\n\t\twhile (currentType != null)\n\t\t{\n\t\t\tyield return currentType;\n\n\t\t\tcurrentType = currentType.BaseType;\n\t\t}\n\t}\n\n\tpublic static List<Type> GetBaseTypesAndInterfacesInclusive(this Type type)\n\t{\n\t\tvar baseTypes = new List<Type>();\n\t\tvar typesToProcess = new Queue<Type>();\n\t\ttypesToProcess.Enqueue(type);\n\n\t\twhile (typesToProcess.Count > 0)\n\t\t{\n\t\t\ttype = typesToProcess.Dequeue();\n\t\t\tbaseTypes.Add(type);\n\n\t\t\tif (type.IsNullableValueType())\n\t\t\t{\n\t\t\t\ttypesToProcess.Enqueue(Nullable.GetUnderlyingType(type)!);\n\t\t\t}\n\n\t\t\tif (type.IsConstructedGenericType)\n\t\t\t{\n\t\t\t\ttypesToProcess.Enqueue(type.GetGenericTypeDefinition());\n\t\t\t}\n\n\t\t\tif (!type.IsGenericTypeDefinition\n\t\t\t\t&& !type.IsInterface)\n\t\t\t{\n\t\t\t\tif (type.BaseType != null)\n\t\t\t\t{\n\t\t\t\t\ttypesToProcess.Enqueue(type.BaseType);\n\t\t\t\t}\n\n\t\t\t\tforeach (var @interface in GetDeclaredInterfaces(type))\n\t\t\t\t{\n\t\t\t\t\ttypesToProcess.Enqueue(@interface);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn baseTypes;\n\t}\n\n\tpublic static IEnumerable<Type> GetTypesInHierarchy(this Type type)\n\t{\n\t\tvar currentType = type;\n\n\t\twhile (currentType != null)\n\t\t{\n\t\t\tyield return currentType;\n\n\t\t\tcurrentType = currentType.BaseType;\n\t\t}\n\t}\n\n\tpublic static IEnumerable<Type> GetDeclaredInterfaces(\n\t\t[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Interfaces)] this Type type)\n\t{\n\t\tvar interfaces = type.GetInterfaces();\n\t\tif (type.BaseType == typeof(object)\n\t\t\t|| type.BaseType == null)\n\t\t{\n\t\t\treturn interfaces;\n\t\t}\n\n\t\treturn interfaces.Except(GetInterfacesSuppressed(type.BaseType));\n\n\t\t[UnconditionalSuppressMessage(\"ReflectionAnalysis\", \"IL2070\", Justification = \"https://github.com/dotnet/linker/issues/2473\")]\n\t\tstatic IEnumerable<Type> GetInterfacesSuppressed(Type type)\n\t\t\t=> type.GetInterfaces();\n\t}\n\n\tpublic static ConstructorInfo? GetDeclaredConstructor(\n\t\t[DynamicallyAccessedMembers(\n\t\t\tDynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)]\n\t\tthis Type type,\n\t\tType[]? types)\n\t{\n\t\ttypes ??= Array.Empty<Type>();\n\n\t\treturn type.GetTypeInfo().DeclaredConstructors\n\t\t\t.SingleOrDefault(\n\t\t\t\tc => !c.IsStatic\n\t\t\t\t\t&& c.GetParameters().Select(p => p.ParameterType).SequenceEqual(types))!;\n\t}\n\n\tpublic static IEnumerable<PropertyInfo> GetPropertiesInHierarchy(this Type type, string name)\n\t{\n\t\tvar currentType = type;\n\t\tdo\n\t\t{\n\t\t\tvar typeInfo = currentType.GetTypeInfo();\n\t\t\tforeach (var propertyInfo in typeInfo.DeclaredProperties)\n\t\t\t{\n\t\t\t\tif (propertyInfo.Name.Equals(name, StringComparison.Ordinal)\n\t\t\t\t\t&& !(propertyInfo.GetMethod ?? propertyInfo.SetMethod)!.IsStatic)\n\t\t\t\t{\n\t\t\t\t\tyield return propertyInfo;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcurrentType = typeInfo.BaseType;\n\t\t}\n\t\twhile (currentType != null);\n\t}\n\n\t// Looking up the members through the whole hierarchy allows to find inherited private members.\n\tpublic static IEnumerable<MemberInfo> GetMembersInHierarchy(this Type type)\n\t{\n\t\tvar currentType = type;\n\n\t\tdo\n\t\t{\n\t\t\t// Do the whole hierarchy for properties first since looking for fields is slower.\n\t\t\tforeach (var propertyInfo in currentType.GetRuntimeProperties().Where(pi => !(pi.GetMethod ?? pi.SetMethod)!.IsStatic))\n\t\t\t{\n\t\t\t\tyield return propertyInfo;\n\t\t\t}\n\n\t\t\tforeach (var fieldInfo in currentType.GetRuntimeFields().Where(f => !f.IsStatic))\n\t\t\t{\n\t\t\t\tyield return fieldInfo;\n\t\t\t}\n\n\t\t\tcurrentType = currentType.BaseType;\n\t\t}\n\t\twhile (currentType != null);\n\t}\n\n\tpublic static IEnumerable<MemberInfo> GetMembersInHierarchy(\n\t\t[DynamicallyAccessedMembers(\n\t\t\tDynamicallyAccessedMemberTypes.PublicProperties\n\t\t\t| DynamicallyAccessedMemberTypes.NonPublicProperties\n\t\t\t| DynamicallyAccessedMemberTypes.PublicFields\n\t\t\t| DynamicallyAccessedMemberTypes.NonPublicFields)]\n\t\tthis Type type,\n\t\tstring name)\n\t\t=> type.GetMembersInHierarchy().Where(m => m.Name == name);\n\n\tprivate static readonly Dictionary<Type, object> CommonTypeDictionary = new()\n\t{\n#pragma warning disable IDE0034 // Simplify 'default' expression - default causes default(object)\n        { typeof(int), default(int) },\n\t\t{ typeof(Guid), default(Guid) },\n\t\t{ typeof(DateOnly), default(DateOnly) },\n\t\t{ typeof(DateTime), default(DateTime) },\n\t\t{ typeof(DateTimeOffset), default(DateTimeOffset) },\n\t\t{ typeof(TimeOnly), default(TimeOnly) },\n\t\t{ typeof(long), default(long) },\n\t\t{ typeof(bool), default(bool) },\n\t\t{ typeof(double), default(double) },\n\t\t{ typeof(short), default(short) },\n\t\t{ typeof(float), default(float) },\n\t\t{ typeof(byte), default(byte) },\n\t\t{ typeof(char), default(char) },\n\t\t{ typeof(uint), default(uint) },\n\t\t{ typeof(ushort), default(ushort) },\n\t\t{ typeof(ulong), default(ulong) },\n\t\t{ typeof(sbyte), default(sbyte) }\n#pragma warning restore IDE0034 // Simplify 'default' expression\n    };\n\n\tpublic static object? GetDefaultValue(\n\t\t[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] this Type type)\n\t{\n\t\tif (!type.IsValueType)\n\t\t{\n\t\t\treturn null;\n\t\t}\n\n\t\t// A bit of perf code to avoid calling Activator.CreateInstance for common types and\n\t\t// to avoid boxing on every call. This is about 50% faster than just calling CreateInstance\n\t\t// for all value types.\n\t\treturn CommonTypeDictionary.TryGetValue(type, out var value)\n\t\t\t? value\n\t\t\t: Activator.CreateInstance(type);\n\t}\n\n\t[RequiresUnreferencedCode(\"Gets all types from the given assembly - unsafe for trimming\")]\n\tpublic static IEnumerable<TypeInfo> GetConstructibleTypes(this Assembly assembly)\n\t\t=> assembly.GetLoadableDefinedTypes().Where(\n\t\t\tt => !t.IsAbstract\n\t\t\t\t&& !t.IsGenericTypeDefinition);\n\n\t[RequiresUnreferencedCode(\"Gets all types from the given assembly - unsafe for trimming\")]\n\tpublic static IEnumerable<TypeInfo> GetLoadableDefinedTypes(this Assembly assembly)\n\t{\n\t\ttry\n\t\t{\n\t\t\treturn assembly.DefinedTypes;\n\t\t}\n\t\tcatch (ReflectionTypeLoadException ex)\n\t\t{\n\t\t\treturn ex.Types.Where(t => t != null).Select(IntrospectionExtensions.GetTypeInfo!);\n\t\t}\n\t}\n\n\t/// <summary>\n\t///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to\n\t///     the same compatibility standards as public APIs. It may be changed or removed without notice in\n\t///     any release. You should only use it directly in your code with extreme caution and knowing that\n\t///     doing so can result in application failures when updating to a new Entity Framework Core release.\n\t/// </summary>\n\tpublic static string DisplayName(this Type type, bool fullName = true, bool compilable = false)\n\t{\n\t\tvar stringBuilder = new StringBuilder();\n\t\tProcessType(stringBuilder, type, fullName, compilable);\n\t\treturn stringBuilder.ToString();\n\t}\n\n\tprivate static void ProcessType(StringBuilder builder, Type type, bool fullName, bool compilable)\n\t{\n\t\tif (type.IsGenericType)\n\t\t{\n\t\t\tvar genericArguments = type.GetGenericArguments();\n\t\t\tProcessGenericType(builder, type, genericArguments, genericArguments.Length, fullName, compilable);\n\t\t}\n\t\telse if (type.IsArray)\n\t\t{\n\t\t\tProcessArrayType(builder, type, fullName, compilable);\n\t\t}\n\t\telse if (BuiltInTypeNames.TryGetValue(type, out var builtInName))\n\t\t{\n\t\t\tbuilder.Append(builtInName);\n\t\t}\n\t\telse if (!type.IsGenericParameter)\n\t\t{\n\t\t\tif (compilable)\n\t\t\t{\n\t\t\t\tif (type.IsNested)\n\t\t\t\t{\n\t\t\t\t\tProcessType(builder, type.DeclaringType!, fullName, compilable);\n\t\t\t\t\tbuilder.Append('.');\n\t\t\t\t}\n\t\t\t\telse if (fullName)\n\t\t\t\t{\n\t\t\t\t\tbuilder.Append(type.Namespace).Append('.');\n\t\t\t\t}\n\n\t\t\t\tbuilder.Append(type.Name);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tbuilder.Append(fullName ? type.FullName : type.Name);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static void ProcessArrayType(StringBuilder builder, Type type, bool fullName, bool compilable)\n\t{\n\t\tvar innerType = type;\n\t\twhile (innerType.IsArray)\n\t\t{\n\t\t\tinnerType = innerType.GetElementType()!;\n\t\t}\n\n\t\tProcessType(builder, innerType, fullName, compilable);\n\n\t\twhile (type.IsArray)\n\t\t{\n\t\t\tbuilder.Append('[');\n\t\t\tbuilder.Append(',', type.GetArrayRank() - 1);\n\t\t\tbuilder.Append(']');\n\t\t\ttype = type.GetElementType()!;\n\t\t}\n\t}\n\n\tprivate static void ProcessGenericType(\n\t\tStringBuilder builder,\n\t\tType type,\n\t\tType[] genericArguments,\n\t\tint length,\n\t\tbool fullName,\n\t\tbool compilable)\n\t{\n\t\tif (type.IsConstructedGenericType\n\t\t\t&& type.GetGenericTypeDefinition() == typeof(Nullable<>))\n\t\t{\n\t\t\tProcessType(builder, type.UnwrapNullableType(), fullName, compilable);\n\t\t\tbuilder.Append('?');\n\t\t\treturn;\n\t\t}\n\n\t\tvar offset = type.IsNested ? type.DeclaringType!.GetGenericArguments().Length : 0;\n\n\t\tif (compilable)\n\t\t{\n\t\t\tif (type.IsNested)\n\t\t\t{\n\t\t\t\tProcessType(builder, type.DeclaringType!, fullName, compilable);\n\t\t\t\tbuilder.Append('.');\n\t\t\t}\n\t\t\telse if (fullName)\n\t\t\t{\n\t\t\t\tbuilder.Append(type.Namespace);\n\t\t\t\tbuilder.Append('.');\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (fullName)\n\t\t\t{\n\t\t\t\tif (type.IsNested)\n\t\t\t\t{\n\t\t\t\t\tProcessGenericType(builder, type.DeclaringType!, genericArguments, offset, fullName, compilable);\n\t\t\t\t\tbuilder.Append('+');\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tbuilder.Append(type.Namespace);\n\t\t\t\t\tbuilder.Append('.');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tvar genericPartIndex = type.Name.IndexOf('`');\n\t\tif (genericPartIndex <= 0)\n\t\t{\n\t\t\tbuilder.Append(type.Name);\n\t\t\treturn;\n\t\t}\n\n\t\tbuilder.Append(type.Name, 0, genericPartIndex);\n\t\tbuilder.Append('<');\n\n\t\tfor (var i = offset; i < length; i++)\n\t\t{\n\t\t\tProcessType(builder, genericArguments[i], fullName, compilable);\n\t\t\tif (i + 1 == length)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tbuilder.Append(',');\n\t\t\tif (!genericArguments[i + 1].IsGenericParameter)\n\t\t\t{\n\t\t\t\tbuilder.Append(' ');\n\t\t\t}\n\t\t}\n\n\t\tbuilder.Append('>');\n\t}\n\n\tpublic static IEnumerable<string> GetNamespaces(this Type type)\n\t{\n\t\tif (BuiltInTypeNames.ContainsKey(type))\n\t\t{\n\t\t\tyield break;\n\t\t}\n\n\t\tif (type.IsArray)\n\t\t{\n\t\t\tforeach (var ns in type.GetElementType()!.GetNamespaces())\n\t\t\t{\n\t\t\t\tyield return ns;\n\t\t\t}\n\n\t\t\tyield break;\n\t\t}\n\n\t\tyield return type.Namespace!;\n\n\t\tif (type.IsGenericType)\n\t\t{\n\t\t\tforeach (var typeArgument in type.GenericTypeArguments)\n\t\t\t{\n\t\t\t\tforeach (var ns in typeArgument.GetNamespaces())\n\t\t\t\t{\n\t\t\t\t\tyield return ns;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static ConstantExpression GetDefaultValueConstant(this Type type)\n\t\t=> (ConstantExpression)GenerateDefaultValueConstantMethod\n\t\t\t.MakeGenericMethod(type).Invoke(null, Array.Empty<object>())!;\n\n\tprivate static readonly MethodInfo GenerateDefaultValueConstantMethod =\n\t\ttypeof(SharedTypeExtensions).GetTypeInfo().GetDeclaredMethod(nameof(GenerateDefaultValueConstant))!;\n\n\tprivate static ConstantExpression GenerateDefaultValueConstant<TDefault>()\n\t\t=> Expression.Constant(default(TDefault), typeof(TDefault));\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Utilities/StringBuilderExtensions.cs",
    "content": "// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n\n#nullable enable\n\nusing System.Collections.Generic;\nusing System.Globalization;\n\nnamespace System.Text;\n\ninternal static class StringBuilderExtensions\n{\n\tpublic static StringBuilder AppendJoin(\n\t\tthis StringBuilder stringBuilder,\n\t\tIEnumerable<string> values,\n\t\tstring separator = \", \")\n\t\t=> stringBuilder.AppendJoin(values, (sb, value) => sb.Append(value), separator);\n\n\tpublic static StringBuilder AppendJoin(\n\t\tthis StringBuilder stringBuilder,\n\t\tstring separator,\n\t\tparams string[] values)\n\t\t=> stringBuilder.AppendJoin(values, (sb, value) => sb.Append(value), separator);\n\n\tpublic static StringBuilder AppendJoin<T>(\n\t\tthis StringBuilder stringBuilder,\n\t\tIEnumerable<T> values,\n\t\tAction<StringBuilder, T> joinAction,\n\t\tstring separator = \", \")\n\t{\n\t\tvar appended = false;\n\n\t\tforeach (var value in values)\n\t\t{\n\t\t\tjoinAction(stringBuilder, value);\n\t\t\tstringBuilder.Append(separator);\n\t\t\tappended = true;\n\t\t}\n\n\t\tif (appended)\n\t\t{\n\t\t\tstringBuilder.Length -= separator.Length;\n\t\t}\n\n\t\treturn stringBuilder;\n\t}\n\n\tpublic static StringBuilder AppendJoin<T>(\n\t\tthis StringBuilder stringBuilder,\n\t\tIEnumerable<T> values,\n\t\tFunc<StringBuilder, T, bool> joinFunc,\n\t\tstring separator = \", \")\n\t{\n\t\tvar appended = false;\n\n\t\tforeach (var value in values)\n\t\t{\n\t\t\tif (joinFunc(stringBuilder, value))\n\t\t\t{\n\t\t\t\tstringBuilder.Append(separator);\n\t\t\t\tappended = true;\n\t\t\t}\n\t\t}\n\n\t\tif (appended)\n\t\t{\n\t\t\tstringBuilder.Length -= separator.Length;\n\t\t}\n\n\t\treturn stringBuilder;\n\t}\n\n\tpublic static StringBuilder AppendJoin<T, TParam>(\n\t\tthis StringBuilder stringBuilder,\n\t\tIEnumerable<T> values,\n\t\tTParam param,\n\t\tAction<StringBuilder, T, TParam> joinAction,\n\t\tstring separator = \", \")\n\t{\n\t\tvar appended = false;\n\n\t\tforeach (var value in values)\n\t\t{\n\t\t\tjoinAction(stringBuilder, value, param);\n\t\t\tstringBuilder.Append(separator);\n\t\t\tappended = true;\n\t\t}\n\n\t\tif (appended)\n\t\t{\n\t\t\tstringBuilder.Length -= separator.Length;\n\t\t}\n\n\t\treturn stringBuilder;\n\t}\n\n\tpublic static void AppendBytes(this StringBuilder builder, byte[] bytes)\n\t{\n\t\tbuilder.Append(\"'0x\");\n\n\t\tfor (var i = 0; i < bytes.Length; i++)\n\t\t{\n\t\t\tif (i > 31)\n\t\t\t{\n\t\t\t\tbuilder.Append(\"...\");\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tbuilder.Append(bytes[i].ToString(\"X2\", CultureInfo.InvariantCulture));\n\t\t}\n\n\t\tbuilder.Append('\\'');\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/Utilities/TranslatorsHelper.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Reflection;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Utilities;\n\npublic class TranslatorsHelper\n{\n\tpublic static IEnumerable<Type> GetTranslators<TInterface>()\n\t{\n\t\treturn Assembly.GetExecutingAssembly().GetTypes()\n\t\t\t.Where(t => t.GetInterfaces().Any(i => i == typeof(TInterface)));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/ValueGeneration/Internal/FbSequenceHiLoValueGenerator.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Globalization;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Update.Internal;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Metadata;\nusing Microsoft.EntityFrameworkCore.Storage;\nusing Microsoft.EntityFrameworkCore.ValueGeneration;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.ValueGeneration.Internal;\n\npublic class FbSequenceHiLoValueGenerator<TValue> : HiLoValueGenerator<TValue>\n{\n\treadonly IRawSqlCommandBuilder _rawSqlCommandBuilder;\n\treadonly IFbUpdateSqlGenerator _sqlGenerator;\n\treadonly IFbRelationalConnection _connection;\n\treadonly ISequence _sequence;\n\treadonly IRelationalCommandDiagnosticsLogger _commandLogger;\n\n\tpublic FbSequenceHiLoValueGenerator(IRawSqlCommandBuilder rawSqlCommandBuilder, IFbUpdateSqlGenerator sqlGenerator, FbSequenceValueGeneratorState generatorState, IFbRelationalConnection connection, IRelationalCommandDiagnosticsLogger commandLogger)\n\t\t: base(generatorState)\n\t{\n\t\t_sequence = generatorState.Sequence;\n\t\t_rawSqlCommandBuilder = rawSqlCommandBuilder;\n\t\t_sqlGenerator = sqlGenerator;\n\t\t_connection = connection;\n\t\t_commandLogger = commandLogger;\n\t}\n\n\tprotected override long GetNewLowValue()\n\t\t=> (long)Convert.ChangeType(\n\t\t\t_rawSqlCommandBuilder\n\t\t\t\t.Build(_sqlGenerator.GenerateNextSequenceValueOperation(_sequence.Name, _sequence.Schema))\n\t\t\t\t.ExecuteScalar(\n\t\t\t\t\tnew RelationalCommandParameterObject(\n\t\t\t\t\t\t_connection,\n\t\t\t\t\t\tparameterValues: null,\n\t\t\t\t\t\treaderColumns: null,\n\t\t\t\t\t\tcontext: null,\n\t\t\t\t\t\t_commandLogger, CommandSource.ValueGenerator)),\n\t\t\ttypeof(long),\n\t\t\tCultureInfo.InvariantCulture)!;\n\n\tprotected override async Task<long> GetNewLowValueAsync(CancellationToken cancellationToken = default)\n\t\t=> (long)Convert.ChangeType(\n\t\t\tawait _rawSqlCommandBuilder\n\t\t\t\t.Build(_sqlGenerator.GenerateNextSequenceValueOperation(_sequence.Name, _sequence.Schema))\n\t\t\t\t.ExecuteScalarAsync(\n\t\t\t\t\tnew RelationalCommandParameterObject(\n\t\t\t\t\t\t_connection,\n\t\t\t\t\t\tparameterValues: null,\n\t\t\t\t\t\treaderColumns: null,\n\t\t\t\t\t\tcontext: null,\n\t\t\t\t\t\t_commandLogger, CommandSource.ValueGenerator),\n\t\t\t\t\tcancellationToken)\n\t\t\t\t.ConfigureAwait(false),\n\t\t\ttypeof(long),\n\t\t\tCultureInfo.InvariantCulture)!;\n\n\tpublic override bool GeneratesTemporaryValues\n\t\t=> false;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/ValueGeneration/Internal/FbSequenceValueGeneratorFactory.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Update.Internal;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Metadata;\nusing Microsoft.EntityFrameworkCore.Storage;\nusing Microsoft.EntityFrameworkCore.ValueGeneration;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.ValueGeneration.Internal;\n\npublic class FbSequenceValueGeneratorFactory : IFbSequenceValueGeneratorFactory\n{\n\treadonly IFbUpdateSqlGenerator _sqlGenerator;\n\n\tpublic FbSequenceValueGeneratorFactory(IFbUpdateSqlGenerator sqlGenerator)\n\t{\n\t\t_sqlGenerator = sqlGenerator;\n\t}\n\n\tpublic virtual ValueGenerator TryCreate(IProperty property, Type type, FbSequenceValueGeneratorState generatorState, IFbRelationalConnection connection, IRawSqlCommandBuilder rawSqlCommandBuilder, IRelationalCommandDiagnosticsLogger commandLogger)\n\t{\n\t\tif (type == typeof(long))\n\t\t{\n\t\t\treturn new FbSequenceHiLoValueGenerator<long>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger);\n\t\t}\n\n\t\tif (type == typeof(int))\n\t\t{\n\t\t\treturn new FbSequenceHiLoValueGenerator<int>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger);\n\t\t}\n\n\t\tif (type == typeof(decimal))\n\t\t{\n\t\t\treturn new FbSequenceHiLoValueGenerator<decimal>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger);\n\t\t}\n\n\t\tif (type == typeof(short))\n\t\t{\n\t\t\treturn new FbSequenceHiLoValueGenerator<short>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger);\n\t\t}\n\n\t\tif (type == typeof(byte))\n\t\t{\n\t\t\treturn new FbSequenceHiLoValueGenerator<byte>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger);\n\t\t}\n\n\t\tif (type == typeof(char))\n\t\t{\n\t\t\treturn new FbSequenceHiLoValueGenerator<char>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger);\n\t\t}\n\n\t\tif (type == typeof(ulong))\n\t\t{\n\t\t\treturn new FbSequenceHiLoValueGenerator<ulong>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger);\n\t\t}\n\n\t\tif (type == typeof(uint))\n\t\t{\n\t\t\treturn new FbSequenceHiLoValueGenerator<uint>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger);\n\t\t}\n\n\t\tif (type == typeof(ushort))\n\t\t{\n\t\t\treturn new FbSequenceHiLoValueGenerator<ushort>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger);\n\t\t}\n\n\t\tif (type == typeof(sbyte))\n\t\t{\n\t\t\treturn new FbSequenceHiLoValueGenerator<sbyte>(rawSqlCommandBuilder, _sqlGenerator, generatorState, connection, commandLogger);\n\t\t}\n\n\t\treturn null;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/ValueGeneration/Internal/FbSequenceValueGeneratorState.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Metadata;\nusing Microsoft.EntityFrameworkCore.ValueGeneration;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.ValueGeneration.Internal;\n\npublic class FbSequenceValueGeneratorState : HiLoValueGeneratorState\n{\n\tpublic FbSequenceValueGeneratorState(ISequence sequence)\n\t\t: base(sequence.IncrementBy)\n\t{\n\t\tSequence = sequence;\n\t}\n\n\tpublic virtual ISequence Sequence { get; }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/ValueGeneration/Internal/FbValueGeneratorCache.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Concurrent;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata;\nusing Microsoft.EntityFrameworkCore.Storage;\nusing Microsoft.EntityFrameworkCore.ValueGeneration;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.ValueGeneration.Internal;\n\npublic class FbValueGeneratorCache : ValueGeneratorCache, IFbValueGeneratorCache\n{\n\treadonly ConcurrentDictionary<string, FbSequenceValueGeneratorState> _sequenceGeneratorCache = new ConcurrentDictionary<string, FbSequenceValueGeneratorState>();\n\n\tpublic FbValueGeneratorCache(ValueGeneratorCacheDependencies dependencies)\n\t\t: base(dependencies)\n\t{ }\n\n\tpublic virtual FbSequenceValueGeneratorState GetOrAddSequenceState(IProperty property, IRelationalConnection connection)\n\t{\n\t\tvar tableIdentifier = StoreObjectIdentifier.Create(property.DeclaringType, StoreObjectType.Table);\n\t\tvar sequence = tableIdentifier != null\n\t\t\t? property.FindHiLoSequence(tableIdentifier.Value)\n\t\t\t: property.FindHiLoSequence();\n\n\t\treturn _sequenceGeneratorCache.GetOrAdd(\n\t\t\tGetSequenceName(sequence, connection),\n\t\t\t_ => new FbSequenceValueGeneratorState(sequence));\n\t}\n\n\tstatic string GetSequenceName(ISequence sequence, IRelationalConnection connection)\n\t{\n\t\tvar dbConnection = connection.DbConnection;\n\n\t\treturn dbConnection.Database.ToUpperInvariant()\n\t\t\t+ \"::\"\n\t\t\t+ dbConnection.DataSource.ToUpperInvariant()\n\t\t\t+ \"::\"\n\t\t\t+ (sequence.Schema == null ? \"\" : sequence.Schema + \".\")\n\t\t\t+ sequence.Name;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/ValueGeneration/Internal/FbValueGeneratorSelector.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Metadata;\nusing Microsoft.EntityFrameworkCore.Storage;\nusing Microsoft.EntityFrameworkCore.ValueGeneration;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.ValueGeneration.Internal;\n\npublic class FbValueGeneratorSelector : RelationalValueGeneratorSelector\n{\n\treadonly IFbSequenceValueGeneratorFactory _sequenceFactory;\n\treadonly IFbRelationalConnection _connection;\n\treadonly IRawSqlCommandBuilder _rawSqlCommandBuilder;\n\treadonly IRelationalCommandDiagnosticsLogger _commandLogger;\n\n\tpublic FbValueGeneratorSelector(ValueGeneratorSelectorDependencies dependencies, IFbSequenceValueGeneratorFactory sequenceFactory, IFbRelationalConnection connection, IRawSqlCommandBuilder rawSqlCommandBuilder, IRelationalCommandDiagnosticsLogger commandLogger)\n\t\t: base(dependencies)\n\t{\n\t\t_sequenceFactory = sequenceFactory;\n\t\t_connection = connection;\n\t\t_rawSqlCommandBuilder = rawSqlCommandBuilder;\n\t\t_commandLogger = commandLogger;\n\t}\n\n\tpublic new virtual IFbValueGeneratorCache Cache => (IFbValueGeneratorCache)base.Cache;\n\n\t[Obsolete(\"Use TrySelect and throw if needed when the generator is not found.\")]\n\tpublic override ValueGenerator Select(IProperty property, ITypeBase entityType)\n\t{\n\t\tif (TrySelect(property, entityType, out var generator))\n\t\t{\n\t\t\treturn generator;\n\t\t}\n\n\t\tthrow new ArgumentException(\n\t\t\tCoreStrings.InvalidValueGeneratorFactoryProperty(\n\t\t\t\tnameof(FbSequenceValueGeneratorFactory), property.Name, property.DeclaringType.DisplayName()));\n\t}\n\n\tpublic override bool TrySelect(IProperty property, ITypeBase entityType, out ValueGenerator valueGenerator)\n\t{\n\t\tif (property.GetValueGeneratorFactory() != null\n\t\t\t|| property.GetValueGenerationStrategy() != FbValueGenerationStrategy.HiLo)\n\t\t{\n\t\t\treturn base.TrySelect(property, entityType, out valueGenerator);\n\t\t}\n\n\t\tvar propertyType = property.ClrType.UnwrapNullableType().UnwrapEnumType();\n\n\t\tvalueGenerator = _sequenceFactory.TryCreate(\n\t\t\tproperty,\n\t\t\tpropertyType,\n\t\t\tCache.GetOrAddSequenceState(property, _connection),\n\t\t\t_connection,\n\t\t\t_rawSqlCommandBuilder,\n\t\t\t_commandLogger);\n\n\t\tif (valueGenerator != null)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\n\t\tvar converter = property.GetTypeMapping().Converter;\n\t\tif (converter != null\n\t\t\t&& converter.ProviderClrType != propertyType)\n\t\t{\n\t\t\tvalueGenerator = _sequenceFactory.TryCreate(\n\t\t\t\tproperty,\n\t\t\t\tconverter.ProviderClrType,\n\t\t\t\tCache.GetOrAddSequenceState(property, _connection),\n\t\t\t\t_connection,\n\t\t\t\t_rawSqlCommandBuilder,\n\t\t\t\t_commandLogger);\n\n\t\t\tif (valueGenerator != null)\n\t\t\t{\n\t\t\t\tvalueGenerator = valueGenerator.WithConverter(converter);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprotected override ValueGenerator FindForType(IProperty property, ITypeBase entityType, Type clrType)\n\t\t=> property.ClrType.UnwrapNullableType() == typeof(Guid)\n\t\t\t? property.ValueGenerated == ValueGenerated.Never || property.GetDefaultValueSql() != null\n\t\t\t\t? new TemporaryGuidValueGenerator()\n\t\t\t\t: new SequentialGuidValueGenerator()\n\t\t\t: base.FindForType(property, entityType, clrType);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/ValueGeneration/Internal/IFbSequenceValueGeneratorFactory.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Metadata;\nusing Microsoft.EntityFrameworkCore.Storage;\nusing Microsoft.EntityFrameworkCore.ValueGeneration;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.ValueGeneration.Internal;\n\npublic interface IFbSequenceValueGeneratorFactory\n{\n\tValueGenerator TryCreate(IProperty property, Type clrType, FbSequenceValueGeneratorState generatorState, IFbRelationalConnection connection, IRawSqlCommandBuilder rawSqlCommandBuilder, IRelationalCommandDiagnosticsLogger commandLogger);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird/ValueGeneration/Internal/IFbValueGeneratorCache.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Metadata;\nusing Microsoft.EntityFrameworkCore.Storage;\nusing Microsoft.EntityFrameworkCore.ValueGeneration;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.ValueGeneration.Internal;\n\npublic interface IFbValueGeneratorCache : IValueGeneratorCache\n{\n\tFbSequenceValueGeneratorState GetOrAddSequenceState(IProperty property, IRelationalConnection connection);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/ComplianceFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Reflection;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests;\n\npublic class ComplianceFbTest : Microsoft.EntityFrameworkCore.RelationalComplianceTestBase\n{\n\tprotected override ICollection<Type> IgnoredTestBases { get; } =\n\t[\n\t\ttypeof(Microsoft.EntityFrameworkCore.ApiConsistencyTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.BadDataJsonDeserializationTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.BuiltInDataTypesTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ComplexTypesTrackingRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ComplexTypesTrackingTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.CompositeKeyEndToEndTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ConcurrencyDetectorDisabledTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ConcurrencyDetectorEnabledTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ConcurrencyDetectorTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ConferencePlannerTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ConvertToProviderTypesTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.CustomConvertersTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.DataAnnotationTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.DataBindingTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.EntityFrameworkServiceCollectionExtensionsTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.FieldMappingTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.FieldsOnlyLoadTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.FindTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.GraphUpdatesTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ProxyGraphUpdatesTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.InterceptionTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.JsonTypesTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.KeysWithConvertersTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.LazyLoadProxyRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.LazyLoadProxyTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.LoadTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.LoggingTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ManyToManyFieldsLoadTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ManyToManyLoadTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ManyToManyTrackingTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.MaterializationInterceptionTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding101TestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.MonsterFixupTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.MusicStoreTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.NotificationEntitiesTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.OptimisticConcurrencyTestBase<,>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.OverzealousInitializationTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.PropertyValuesRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.PropertyValuesTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.QueryExpressionInterceptionTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.AdHocManyToManyQueryTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.SaveChangesInterceptionTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.SeedingTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.SerializationTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.SingletonInterceptorsTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.SpatialTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.StoreGeneratedFixupTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.StoreGeneratedTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ValueConvertersEndToEndTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.WithConstructorsTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.CommandInterceptionTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ConcurrencyDetectorDisabledRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ConcurrencyDetectorEnabledRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ConnectionInterceptionTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.DataAnnotationRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.DesignTimeTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.EntitySplittingTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.JsonTypesRelationalTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.LoggingRelationalTestBase<,>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ManyToManyTrackingRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding101RelationalTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.OptimisticConcurrencyRelationalTestBase<,>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.RelationalServiceCollectionExtensionsTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.StoreGeneratedFixupRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.TableSplittingTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.TPTTableSplittingTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.TransactionInterceptionTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.TransactionTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.TwoDatabasesTestBase),\n\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.ModelBuilderTest.ComplexCollectionTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.ModelBuilderTest.ComplexTypeTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.ModelBuilderTest.ModelBuilderTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.ModelBuilderTest.InheritanceTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.ModelBuilderTest.ManyToManyTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.ModelBuilderTest.ManyToOneTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.ModelBuilderTest.NonRelationshipTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.ModelBuilderTest.OneToManyTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.ModelBuilderTest.OneToOneTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.ModelBuilderTest.OwnedTypesTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.RelationalModelBuilderTest.RelationalNonRelationshipTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.RelationalModelBuilderTest.RelationalComplexCollectionTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.RelationalModelBuilderTest.RelationalComplexTypeTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.RelationalModelBuilderTest.RelationalInheritanceTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.RelationalModelBuilderTest.RelationalOneToManyTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.RelationalModelBuilderTest.RelationalManyToOneTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.RelationalModelBuilderTest.RelationalOneToOneTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.RelationalModelBuilderTest.RelationalManyToManyTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.ModelBuilding.RelationalModelBuilderTest.RelationalOwnedTypesTestBase),\n\n\t\ttypeof(Microsoft.EntityFrameworkCore.BulkUpdates.BulkUpdatesTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.BulkUpdates.FiltersInheritanceBulkUpdatesTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.BulkUpdates.InheritanceBulkUpdatesTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.BulkUpdates.NonSharedModelBulkUpdatesTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.BulkUpdates.NorthwindBulkUpdatesTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.BulkUpdates.FiltersInheritanceBulkUpdatesRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.BulkUpdates.InheritanceBulkUpdatesRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.BulkUpdates.NonSharedModelBulkUpdatesRelationalTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.BulkUpdates.NorthwindBulkUpdatesRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.BulkUpdates.TPCFiltersInheritanceBulkUpdatesTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.BulkUpdates.TPCInheritanceBulkUpdatesTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.BulkUpdates.TPHInheritanceBulkUpdatesTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.BulkUpdates.TPTFiltersInheritanceBulkUpdatesTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.BulkUpdates.TPTInheritanceBulkUpdatesTestBase<>),\n\n\t\ttypeof(Microsoft.EntityFrameworkCore.Update.ComplexCollectionJsonUpdateTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Update.JsonUpdateTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Update.NonSharedModelUpdatesTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Update.StoredProcedureUpdateTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Update.StoreValueGenerationTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Update.UpdateSqlGeneratorTestBase),\n\n\t\ttypeof(Microsoft.EntityFrameworkCore.Scaffolding.CompiledModelTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Scaffolding.CompiledModelRelationalTestBase),\n\n\t\ttypeof(Microsoft.EntityFrameworkCore.Migrations.MigrationsInfrastructureTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGeneratorTestBase),\n\n\t\t// JSON not supported on FB\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.JsonQueryTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.JsonQueryRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.AdHocJsonQueryRelationalTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.AdHocJsonQueryTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.ComplexJson.ComplexJsonBulkUpdateRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.ComplexJson.ComplexJsonCollectionRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.ComplexJson.ComplexJsonMiscellaneousRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.ComplexJson.ComplexJsonPrimitiveCollectionRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.ComplexJson.ComplexJsonProjectionRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.ComplexJson.ComplexJsonSetOperationsRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.ComplexJson.ComplexJsonStructuralEqualityRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.OwnedJson.OwnedJsonBulkUpdateRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.OwnedJson.OwnedJsonCollectionRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.OwnedJson.OwnedJsonMiscellaneousRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.OwnedJson.OwnedJsonPrimitiveCollectionRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.OwnedJson.OwnedJsonProjectionRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.OwnedJson.OwnedJsonStructuralEqualityRelationalTestBase<>),\n\n\t\t// Spatial not supported on FB\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.SpatialQueryTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.SpatialQueryRelationalTestBase<>),\n\n\t\t// Uses some JSON\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.AdHocPrecompiledQueryRelationalTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.PrecompiledQueryRelationalTestBase),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.PrecompiledSqlPregenerationQueryRelationalTestBase),\n\n\t\t// Tests for JSON Types in queries\n\t\ttypeof(Microsoft.EntityFrameworkCore.Types.RelationalTypeTestBase<,>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Types.TypeTestBase<,>),\n\n\t\t// Uses Complex Types with collections (JSON Arrays)\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.ComplexProperties.ComplexPropertiesPrimitiveCollectionTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.ComplexProperties.ComplexPropertiesCollectionTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.ComplexProperties.ComplexPropertiesSetOperationsTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.ComplexTableSplitting.ComplexTableSplittingPrimitiveCollectionRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.OwnedNavigations.OwnedNavigationsPrimitiveCollectionTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.OwnedNavigations.OwnedNavigationsPrimitiveCollectionRelationalTestBase<>),\n\t\ttypeof(Microsoft.EntityFrameworkCore.Query.Associations.OwnedTableSplitting.OwnedTableSplittingPrimitiveCollectionRelationalTestBase<>),\n\t];\n\n\tprotected override Assembly TargetAssembly { get; } = typeof(ComplianceFbTest).Assembly;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.csproj",
    "content": "﻿<Project Sdk=\"Microsoft.NET.Sdk\">\n\t<PropertyGroup>\n\t\t<TargetFramework>net10.0</TargetFramework>\n\t\t<GenerateAssemblyInfo>false</GenerateAssemblyInfo>\n\t\t<GeneratePackageOnBuild>false</GeneratePackageOnBuild>\n\t\t<SkipSourceLink>true</SkipSourceLink>\n\t\t<AssemblyName>FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests</AssemblyName>\n\t\t<RootNamespace>FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests</RootNamespace>\n\t\t<SignAssembly>true</SignAssembly>\n\t\t<AssemblyOriginatorKeyFile>..\\FirebirdSql.Data.TestsBase\\FirebirdSql.Data.TestsBase.snk</AssemblyOriginatorKeyFile>\n\t\t<PreserveCompilationContext>true</PreserveCompilationContext>\n\t</PropertyGroup>\n\t<ItemGroup>\n\t\t<PackageReference Include=\"Microsoft.EntityFrameworkCore.Relational.Specification.Tests\" Version=\"$(EFCoreReferencePackageVersion)\" />\n\t\t<PackageReference Include=\"Microsoft.NET.Test.Sdk\" Version=\"17.12.0\" />\n\t\t<PackageReference Include=\"xunit\" Version=\"2.9.3\" />\n\t\t<PackageReference Include=\"xunit.runner.visualstudio\" Version=\"3.1.5\">\n\t\t  <PrivateAssets>all</PrivateAssets>\n\t\t  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>\n\t\t</PackageReference>\n\t</ItemGroup>\n\t<ItemGroup>\n\t\t<ProjectReference Include=\"..\\FirebirdSql.EntityFrameworkCore.Firebird\\FirebirdSql.EntityFrameworkCore.Firebird.csproj\" />\n\t</ItemGroup>\n\t<ItemGroup>\n\t\t<Service Include=\"{82a7f48d-3b50-4b1e-b82e-3ada8210c358}\" />\n\t</ItemGroup>\n</Project>\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Helpers/ModelHelpers.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Metadata;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\n\npublic static class ModelHelpers\n{\n\tpublic static void SetStringLengths(ModelBuilder modelBuilder)\n\t{\n\t\tforeach (var entityType in modelBuilder.Model.GetEntityTypes())\n\t\t{\n\t\t\tHandleProperties(entityType.GetProperties());\n\t\t\tHandleComplexProperties(entityType.GetComplexProperties());\n\t\t}\n\n\t\tvoid HandleProperties(IEnumerable<IMutableProperty> properties)\n\t\t{\n\t\t\tforeach (var property in properties)\n\t\t\t{\n\t\t\t\tSetStringLength(property);\n\t\t\t}\n\t\t}\n\t\tvoid HandleComplexProperties(IEnumerable<IMutableComplexProperty> complexProperties)\n\t\t{\n\t\t\tforeach (var cp in complexProperties)\n\t\t\t{\n\t\t\t\tHandleProperties(cp.ComplexType.GetProperties());\n\t\t\t\tHandleComplexProperties(cp.ComplexType.GetComplexProperties());\n\t\t\t}\n\t\t}\n\t\tvoid SetStringLength(IMutableProperty property)\n\t\t{\n\t\t\tif (property.ClrType == typeof(string) && property.GetMaxLength() == null)\n\t\t\t{\n\t\t\t\tproperty.SetMaxLength(500);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static void SimpleTableNames(ModelBuilder modelBuilder)\n\t{\n\t\tvar names = new HashSet<string>(StringComparer.InvariantCulture);\n\t\tforeach (var entityType in modelBuilder.Model.GetEntityTypes())\n\t\t{\n\t\t\tif (entityType.BaseType != null)\n\t\t\t\tcontinue;\n\t\t\tentityType.SetTableName(Simplify(entityType.GetTableName()));\n\t\t\tforeach (var property in entityType.GetProperties())\n\t\t\t{\n\t\t\t\tproperty.SetColumnName(Simplify(property.Name));\n\t\t\t}\n\t\t}\n\n\t\tstring Simplify(string name)\n\t\t{\n\t\t\tname = new string(name.Where(char.IsUpper).ToArray());\n\t\t\tvar cnt = 1;\n\t\t\twhile (names.Contains(name + cnt))\n\t\t\t{\n\t\t\t\tcnt++;\n\t\t\t}\n\t\t\tname += cnt;\n\t\t\tnames.Add(name);\n\t\t\treturn name;\n\t\t}\n\t}\n\n\tpublic static void SetPrimaryKeyGeneration(ModelBuilder modelBuilder, FbValueGenerationStrategy valueGenerationStrategy = FbValueGenerationStrategy.SequenceTrigger, Func<IMutableEntityType, bool> filter = null)\n\t{\n\t\tfilter ??= _ => true;\n\t\tforeach (var entityType in modelBuilder.Model.GetEntityTypes().Where(filter))\n\t\t{\n\t\t\tvar pk = entityType.FindPrimaryKey();\n\t\t\tif (pk == null)\n\t\t\t\tcontinue;\n\t\t\tvar properties = pk.Properties;\n\t\t\tif (properties.Count() != 1)\n\t\t\t\tcontinue;\n\t\t\tvar property = properties[0];\n\t\t\tif (property.GetValueGenerationStrategy() == FbValueGenerationStrategy.None)\n\t\t\t{\n\t\t\t\tproperty.SetValueGenerationStrategy(valueGenerationStrategy);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static void ShortenMM(ModelBuilder modelBuilder)\n\t{\n\t\tforeach (var entityType in modelBuilder.Model.GetEntityTypes())\n\t\t{\n\t\t\tentityType.SetTableName(Shorten(entityType.ShortName()));\n\t\t\tforeach (var property in entityType.GetProperties())\n\t\t\t{\n\t\t\t\tproperty.SetColumnName(Shorten(property.Name));\n\t\t\t}\n\t\t}\n\n\t\tstatic string Shorten(string s)\n\t\t{\n\t\t\treturn s\n\t\t\t\t.Replace(\"UnidirectionalEntity\", \"UE\")\n\t\t\t\t.Replace(\"Unidirectional\", \"U\")\n\t\t\t\t.Replace(\"JoinOneToThree\", \"J1_3\")\n\t\t\t\t.Replace(\"EntityTableSharing\", \"ETS\")\n\t\t\t\t.Replace(\"GeneratedKeys\", \"GK\")\n\t\t\t\t.Replace(\"ImplicitManyToMany\", \"IMM\");\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Helpers/SkippingAttributes.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\n\npublic class HasDataInTheSameTransactionAsDDLFactAttribute : FactAttribute\n{\n\tpublic HasDataInTheSameTransactionAsDDLFactAttribute()\n\t{\n\t\tSkip = \"HasData is called in the same transaction as DDL commands.\";\n\t}\n}\npublic class HasDataInTheSameTransactionAsDDLTheoryAttribute : TheoryAttribute\n{\n\tpublic HasDataInTheSameTransactionAsDDLTheoryAttribute()\n\t{\n\t\tSkip = \"HasData is called in the same transaction as DDL commands.\";\n\t}\n}\n\npublic class GeneratedNameTooLongFactAttribute : FactAttribute\n{\n\tpublic GeneratedNameTooLongFactAttribute()\n\t{\n\t\tSkip = \"Generated name in the query is too long.\";\n\t}\n}\npublic class GeneratedNameTooLongTheoryAttribute : TheoryAttribute\n{\n\tpublic GeneratedNameTooLongTheoryAttribute()\n\t{\n\t\tSkip = \"Generated name in the query is too long.\";\n\t}\n}\n\npublic class NotSupportedOnFirebirdFactAttribute : FactAttribute\n{\n\tpublic NotSupportedOnFirebirdFactAttribute()\n\t{\n\t\tSkip = \"Not supported on Firebird.\";\n\t}\n}\npublic class NotSupportedOnFirebirdTheoryAttribute : TheoryAttribute\n{\n\tpublic NotSupportedOnFirebirdTheoryAttribute()\n\t{\n\t\tSkip = \"Not supported on Firebird.\";\n\t}\n}\n\npublic class DoesNotHaveTheDataFactAttribute : FactAttribute\n{\n\tpublic DoesNotHaveTheDataFactAttribute()\n\t{\n\t\tSkip = \"Does not have the data.\";\n\t}\n}\npublic class DoesNotHaveTheDataTheoryAttribute : TheoryAttribute\n{\n\tpublic DoesNotHaveTheDataTheoryAttribute()\n\t{\n\t\tSkip = \"Does not have the data.\";\n\t}\n}\n\npublic class LongExecutionFactAttribute : FactAttribute\n{\n\tpublic LongExecutionFactAttribute()\n\t{\n\t\tSkip = \"Long execution.\";\n\t}\n}\npublic class LongExecutionTheoryAttribute : TheoryAttribute\n{\n\tpublic LongExecutionTheoryAttribute()\n\t{\n\t\tSkip = \"Long execution.\";\n\t}\n}\n\npublic class NotSupportedByProviderFactAttribute : FactAttribute\n{\n\tpublic NotSupportedByProviderFactAttribute()\n\t{\n\t\tSkip = \"Not supported by provider.\";\n\t}\n}\npublic class NotSupportedByProviderTheoryAttribute : TheoryAttribute\n{\n\tpublic NotSupportedByProviderTheoryAttribute()\n\t{\n\t\tSkip = \"Not supported by provider.\";\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Helpers/Xunit.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Xunit;\n\n[assembly: CollectionBehavior(DisableTestParallelization = true)]\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/MigrationsFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Scaffolding.Internal;\nusing Microsoft.EntityFrameworkCore.Migrations;\nusing Microsoft.EntityFrameworkCore.Scaffolding;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests;\n\npublic class MigrationsFbTest : MigrationsTestBase<MigrationsFbTest.MigrationsFbFixture>\n{\n\tconst string SkipReason = \"Assumptions in model differ too much between base tests and Firebird.\";\n\n\tpublic MigrationsFbTest(MigrationsFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\tprotected override string NonDefaultCollation => \"WIN1250\";\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_table() => base.Create_table();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_table_all_settings() => base.Create_table_all_settings();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_table_no_key() => base.Create_table_no_key();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_table_with_comments() => base.Create_table_with_comments();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_table_with_multiline_comments() => base.Create_table_with_multiline_comments();\n\n\t[Theory(Skip = SkipReason)]\n\t[InlineData(true)]\n\t[InlineData(false)]\n\t[InlineData(null)]\n\tpublic override Task Create_table_with_computed_column(bool? stored) => base.Create_table_with_computed_column(stored);\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_table_add_comment() => base.Alter_table_add_comment();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_table_add_comment_non_default_schema() => base.Alter_table_add_comment_non_default_schema();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_table_change_comment() => base.Alter_table_change_comment();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_table_remove_comment() => base.Alter_table_remove_comment();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Drop_table() => base.Drop_table();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Rename_table() => base.Rename_table();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Rename_table_with_primary_key() => base.Rename_table_with_primary_key();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Move_table() => base.Move_table();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_schema() => base.Create_schema();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_column_with_defaultValue_string() => base.Add_column_with_defaultValue_string();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_column_with_defaultValue_datetime() => base.Add_column_with_defaultValue_datetime();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_column_with_defaultValueSql() => base.Add_column_with_defaultValueSql();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_column_with_defaultValueSql_unspecified() => base.Add_column_with_defaultValueSql_unspecified();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_column_with_defaultValue_unspecified() => base.Add_column_with_defaultValue_unspecified();\n\n\t[Theory(Skip = SkipReason)]\n\t[InlineData(true)]\n\t[InlineData(false)]\n\t[InlineData(null)]\n\tpublic override Task Add_column_with_computedSql(bool? stored) => base.Add_column_with_computedSql(stored);\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_column_with_computedSql_unspecified() => base.Add_column_with_computedSql_unspecified();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_column_with_required() => base.Add_column_with_required();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_column_with_ansi() => base.Add_column_with_ansi();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_column_with_max_length() => base.Add_column_with_max_length();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_column_with_max_length_on_derived() => base.Add_column_with_max_length_on_derived();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_column_with_fixed_length() => base.Add_column_with_fixed_length();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_column_with_comment() => base.Add_column_with_comment();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_column_with_collation() => base.Add_column_with_collation();\n\n\t[Theory(Skip = SkipReason)]\n\t[InlineData(true)]\n\t[InlineData(false)]\n\tpublic override Task Add_column_computed_with_collation(bool stored) => base.Add_column_computed_with_collation(stored);\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_column_shared() => base.Add_column_shared();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_column_with_check_constraint() => base.Add_column_with_check_constraint();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_column_change_type() => base.Alter_column_change_type();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_column_make_required() => base.Alter_column_make_required();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_column_make_required_with_index() => base.Alter_column_make_required_with_index();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_column_make_required_with_composite_index() => base.Alter_column_make_required_with_composite_index();\n\n\t[Theory(Skip = SkipReason)]\n\t[InlineData(true)]\n\t[InlineData(false)]\n\t[InlineData(null)]\n\tpublic override Task Alter_column_make_computed(bool? stored) => base.Alter_column_make_computed(stored);\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_column_change_computed() => base.Alter_column_change_computed();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_column_change_computed_type() => base.Alter_column_change_computed_type();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_column_add_comment() => base.Alter_column_add_comment();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_column_change_comment() => base.Alter_column_change_comment();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_column_remove_comment() => base.Alter_column_remove_comment();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_column_set_collation() => base.Alter_column_set_collation();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_column_reset_collation() => base.Alter_column_reset_collation();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Drop_column() => base.Drop_column();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Drop_column_primary_key() => base.Drop_column_primary_key();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Rename_column() => base.Rename_column();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_index() => base.Create_index();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_index_unique() => base.Create_index_unique();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_index_with_filter() => base.Create_index_with_filter();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_unique_index_with_filter() => base.Create_unique_index_with_filter();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Drop_index() => base.Drop_index();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Rename_index() => base.Rename_index();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_primary_key_with_name() => base.Add_primary_key_with_name();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_primary_key_composite_with_name() => base.Add_primary_key_composite_with_name();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_foreign_key() => base.Add_foreign_key();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_foreign_key_with_name() => base.Add_foreign_key_with_name();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Drop_foreign_key() => base.Drop_foreign_key();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_unique_constraint() => base.Add_unique_constraint();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_unique_constraint_composite_with_name() => base.Add_unique_constraint_composite_with_name();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Drop_unique_constraint() => base.Drop_unique_constraint();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_check_constraint_with_name() => base.Add_check_constraint_with_name();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_check_constraint() => base.Alter_check_constraint();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Drop_check_constraint() => base.Drop_check_constraint();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_sequence() => base.Create_sequence();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_sequence_all_settings() => base.Create_sequence_all_settings();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_sequence_all_settings() => base.Alter_sequence_all_settings();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_sequence_increment_by() => base.Alter_sequence_increment_by();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Drop_sequence() => base.Drop_sequence();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Rename_sequence() => base.Rename_sequence();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Move_sequence() => base.Move_sequence();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task InsertDataOperation() => base.InsertDataOperation();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task DeleteDataOperation_simple_key() => base.DeleteDataOperation_simple_key();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task DeleteDataOperation_composite_key() => base.DeleteDataOperation_composite_key();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task UpdateDataOperation_simple_key() => base.UpdateDataOperation_simple_key();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task UpdateDataOperation_composite_key() => base.UpdateDataOperation_composite_key();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_table_with_complex_properties_mapped_to_json() => base.Create_table_with_complex_properties_mapped_to_json();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_table_with_complex_properties_with_nested_collection_mapped_to_json() => base.Create_table_with_complex_properties_with_nested_collection_mapped_to_json();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_table_with_optional_complex_type_with_required_properties() => base.Create_table_with_optional_complex_type_with_required_properties();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Multiop_create_table_and_drop_it_in_one_migration() => base.Multiop_create_table_and_drop_it_in_one_migration();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Multiop_drop_table_and_create_the_same_table_in_one_migration() => base.Multiop_drop_table_and_create_the_same_table_in_one_migration();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Multiop_rename_table_and_create_new_table_with_the_old_name() => base.Multiop_rename_table_and_create_new_table_with_the_old_name();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Multiop_rename_table_and_drop() => base.Multiop_rename_table_and_drop();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task UpdateDataOperation_multiple_columns() => base.UpdateDataOperation_multiple_columns();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_column_make_non_computed() => base.Alter_column_make_non_computed();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_computed_column_add_comment() => base.Alter_computed_column_add_comment();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Drop_column_computed_and_non_computed_with_dependency() => base.Drop_column_computed_and_non_computed_with_dependency();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task SqlOperation() => base.SqlOperation();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_primary_key_int() => base.Add_primary_key_int();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_primary_key_string() => base.Add_primary_key_string();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_column_change_computed_recreates_indexes() => base.Alter_column_change_computed_recreates_indexes();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_column_make_required_with_null_data() => base.Alter_column_make_required_with_null_data();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_index_change_sort_order() => base.Alter_index_change_sort_order();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_index_make_unique() => base.Alter_index_make_unique();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_index_descending() => base.Create_index_descending();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_index_descending_mixed() => base.Create_index_descending_mixed();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_sequence_long() => base.Create_sequence_long();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_sequence_short() => base.Create_sequence_short();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Drop_primary_key_int() => base.Drop_primary_key_int();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Drop_primary_key_string() => base.Drop_primary_key_string();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Alter_sequence_restart_with() => base.Alter_sequence_restart_with();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_column_with_unbounded_max_length() => base.Add_column_with_unbounded_max_length();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_optional_primitive_collection_to_existing_table() => base.Add_optional_primitive_collection_to_existing_table();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_required_primitve_collection_to_existing_table() => base.Add_required_primitve_collection_to_existing_table();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_required_primitve_collection_with_custom_converter_and_custom_default_value_to_existing_table() => base.Add_required_primitve_collection_with_custom_converter_and_custom_default_value_to_existing_table();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_required_primitve_collection_with_custom_default_value_to_existing_table() => base.Add_required_primitve_collection_with_custom_default_value_to_existing_table();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_table_with_complex_type_with_required_properties_on_derived_entity_in_TPH() => base.Create_table_with_complex_type_with_required_properties_on_derived_entity_in_TPH();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_table_with_optional_primitive_collection() => base.Create_table_with_optional_primitive_collection();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_table_with_required_primitive_collection() => base.Create_table_with_required_primitive_collection();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_required_primitve_collection_with_custom_default_value_sql_to_existing_table() => Task.CompletedTask;\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_required_primitive_collection_with_custom_default_value_sql_to_existing_table() => Task.CompletedTask;\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_json_columns_to_existing_table() => base.Add_json_columns_to_existing_table();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_required_primitive_collection_to_existing_table() => base.Add_required_primitive_collection_to_existing_table();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_required_primitive_collection_with_custom_converter_and_custom_default_value_to_existing_table() => base.Add_required_primitive_collection_with_custom_converter_and_custom_default_value_to_existing_table();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_required_primitive_collection_with_custom_converter_to_existing_table() => base.Add_required_primitive_collection_with_custom_converter_to_existing_table();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_required_primitive_collection_with_custom_default_value_to_existing_table() => base.Add_required_primitive_collection_with_custom_default_value_to_existing_table();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Add_required_primitve_collection_with_custom_converter_to_existing_table() => base.Add_required_primitve_collection_with_custom_converter_to_existing_table();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Convert_json_entities_to_regular_owned() => base.Convert_json_entities_to_regular_owned();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Convert_regular_owned_entities_to_json() => base.Convert_regular_owned_entities_to_json();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Convert_string_column_to_a_json_column_containing_collection() => base.Convert_string_column_to_a_json_column_containing_collection();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Convert_string_column_to_a_json_column_containing_reference() => base.Convert_string_column_to_a_json_column_containing_reference();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Convert_string_column_to_a_json_column_containing_required_reference() => base.Convert_string_column_to_a_json_column_containing_required_reference();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_table_with_json_column() => base.Create_table_with_json_column();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Create_table_with_json_column_explicit_json_column_names() => base.Create_table_with_json_column_explicit_json_column_names();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Drop_json_columns_from_existing_table() => base.Drop_json_columns_from_existing_table();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Rename_json_column() => base.Rename_json_column();\n\n\t[Fact(Skip = SkipReason)]\n\tpublic override Task Rename_table_with_json_column() => base.Rename_table_with_json_column();\n\n\tpublic class MigrationsFbFixture : MigrationsFixtureBase\n\t{\n\t\tprotected override string StoreName => nameof(MigrationsFbTest);\n\n\t\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\t\tpublic override RelationalTestHelpers TestHelpers => FbTestHelpers.Instance;\n\n\t\tprotected override IServiceCollection AddServices(IServiceCollection serviceCollection)\n#pragma warning disable EF1001\n\t\t\t\t => base.AddServices(serviceCollection)\n\t\t\t\t.AddScoped<IDatabaseModelFactory, FbDatabaseModelFactory>();\n#pragma warning restore EF1001\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/AdHocAdvancedMappingsQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class AdHocAdvancedMappingsQueryFbTest(NonSharedFixture fixture) : AdHocAdvancedMappingsQueryRelationalTestBase(fixture)\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/AdHocComplexTypeQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class AdHocComplexTypeQueryFbTest(NonSharedFixture fixture) : AdHocComplexTypeQueryTestBase(fixture)\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\t// Uses a custom type mapping DateTime to \"datetime\" which doesn't exist in Firebird.\n\t[NotSupportedByProviderFact]\n\tpublic override Task Complex_type_equality_with_non_default_type_mapping()\n\t{\n\t\treturn base.Complex_type_equality_with_non_default_type_mapping();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/AdHocManyToManyQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class AdHocManyToManyQueryFbTest(NonSharedFixture fixture) : AdHocManyToManyQueryRelationalTestBase(fixture)\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/AdHocMiscellaneousQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Linq;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class AdHocMiscellaneousQueryFbTest(NonSharedFixture fixture) : AdHocMiscellaneousQueryRelationalTestBase(fixture)\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\tprotected override DbContextOptionsBuilder SetParameterizedCollectionMode(DbContextOptionsBuilder optionsBuilder,\n\t\tParameterTranslationMode parameterizedCollectionMode)\n\t{\n\t\tnew FbDbContextOptionsBuilder(optionsBuilder).UseParameterizedCollectionMode(parameterizedCollectionMode);\n\t\treturn optionsBuilder;\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task StoreType_for_UDF_used(bool async)\n\t{\n\t\treturn base.StoreType_for_UDF_used(async);\n\t}\n\n\t[Theory(Skip = \"Not interesting for Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multiple_different_entity_type_from_different_namespaces(bool async)\n\t{\n\t\treturn base.Multiple_different_entity_type_from_different_namespaces(async);\n\t}\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Comparing_byte_column_to_enum_in_vb_creating_double_cast(bool async)\n\t{\n\t\treturn base.Comparing_byte_column_to_enum_in_vb_creating_double_cast(async);\n\t}\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Comparing_enum_casted_to_byte_with_int_constant(bool async)\n\t{\n\t\treturn base.Comparing_enum_casted_to_byte_with_int_constant(async);\n\t}\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Comparing_enum_casted_to_byte_with_int_parameter(bool async)\n\t{\n\t\treturn base.Comparing_enum_casted_to_byte_with_int_parameter(async);\n\t}\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Null_check_removal_in_ternary_maintain_appropriate_cast(bool async)\n\t{\n\t\treturn base.Null_check_removal_in_ternary_maintain_appropriate_cast(async);\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Operators_combine_nullability_of_entity_shapers()\n\t{\n\t\treturn base.Operators_combine_nullability_of_entity_shapers();\n\t}\n\n\t[NotSupportedByProviderTheory]\n\t[MemberData(nameof(InlinedRedactingData))]\n\tpublic override Task Check_inlined_constants_redacting(bool async, bool enableSensitiveDataLogging)\n\t{\n\t\treturn base.Check_inlined_constants_redacting(async, enableSensitiveDataLogging);\n\t}\n\n\tprotected override async Task Seed2951(Context2951 context)\n\t{\n\t\tawait context.Database.ExecuteSqlRawAsync(\"\"\"CREATE TABLE \"ZeroKey\" (\"Id\" INT)\"\"\");\n\t\tawait context.Database.ExecuteSqlRawAsync(\"\"\"INSERT INTO \"ZeroKey\" VALUES (NULL)\"\"\");\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/AdHocNavigationsQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Linq;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class AdHocNavigationsQueryFbTest(NonSharedFixture fixture) : AdHocNavigationsQueryRelationalTestBase(fixture)\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Let_multiple_references_with_reference_to_outer()\n\t{\n\t\treturn base.Let_multiple_references_with_reference_to_outer();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Projection_with_multiple_includes_and_subquery_with_set_operation()\n\t{\n\t\treturn base.Projection_with_multiple_includes_and_subquery_with_set_operation();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task SelectMany_and_collection_in_projection_in_FirstOrDefault()\n\t{\n\t\treturn base.SelectMany_and_collection_in_projection_in_FirstOrDefault();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Correlated_collection_correctly_associates_entities_with_byte_array_keys()\n\t{\n\t\treturn base.Correlated_collection_correctly_associates_entities_with_byte_array_keys();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/AdHocQueryFiltersQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class AdHocQueryFiltersQueryFbTest(NonSharedFixture fixture) : AdHocQueryFiltersQueryRelationalTestBase(fixture)\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\t[Fact(Skip = \"PK name collision and not easy way to override model.\")]\n\tpublic override Task Self_reference_in_query_filter_works()\n\t{\n\t\treturn base.Self_reference_in_query_filter_works();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/AdHocQuerySplittingQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Reflection;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class AdHocQuerySplittingQueryFbTest(NonSharedFixture fixture) : AdHocQuerySplittingQueryTestBase(fixture)\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\tstatic readonly FieldInfo _querySplittingBehaviorFieldInfo = typeof(RelationalOptionsExtension).GetField(\"_querySplittingBehavior\", BindingFlags.NonPublic | BindingFlags.Instance);\n\n\tprotected override DbContextOptionsBuilder SetQuerySplittingBehavior(DbContextOptionsBuilder optionsBuilder, QuerySplittingBehavior splittingBehavior)\n\t{\n\t\tnew FbDbContextOptionsBuilder(optionsBuilder).UseQuerySplittingBehavior(splittingBehavior);\n\t\treturn optionsBuilder;\n\t}\n\n\tprotected override DbContextOptionsBuilder ClearQuerySplittingBehavior(DbContextOptionsBuilder optionsBuilder)\n\t{\n#pragma warning disable EF1001\n\t\tvar extension = optionsBuilder.Options.FindExtension<FbOptionsExtension>();\n\t\tif (extension == null)\n\t\t{\n\t\t\textension = new FbOptionsExtension();\n\t\t}\n\t\telse\n\t\t{\n\t\t\t_querySplittingBehaviorFieldInfo.SetValue(extension, null);\n\t\t}\n\t\t((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension);\n\t\treturn optionsBuilder;\n#pragma warning restore EF1001\n\t}\n\n\t[Fact(Skip = \"Not supported because of current test initialization setup.\")]\n\tpublic override Task Can_query_with_nav_collection_in_projection_with_split_query_in_parallel_async()\n\t{\n\t\treturn base.Can_query_with_nav_collection_in_projection_with_split_query_in_parallel_async();\n\t}\n\n\t[Fact(Skip = \"Not supported because of current test initialization setup.\")]\n\tpublic override Task Can_query_with_nav_collection_in_projection_with_split_query_in_parallel_sync()\n\t{\n\t\treturn base.Can_query_with_nav_collection_in_projection_with_split_query_in_parallel_sync();\n\t}\n}\n\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingBulkUpdateFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query.Associations.ComplexTableSplitting;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.ComplexTableSplitting;\n\npublic class ComplexTableSplittingBulkUpdateFbTest(ComplexTableSplittingFbFixture fixture, ITestOutputHelper testOutputHelper) : ComplexTableSplittingBulkUpdateRelationalTestBase<ComplexTableSplittingFbFixture>(fixture, testOutputHelper)\n{\n\t[NotSupportedByProviderFact]\n\tpublic override Task Update_inside_primitive_collection()\n\t{\n\t\treturn base.Update_inside_primitive_collection();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Query.Associations.ComplexTableSplitting;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.ComplexTableSplitting;\n\npublic class ComplexTableSplittingFbFixture : ComplexTableSplittingRelationalFixtureBase\n{\n\tprotected override ITestStoreFactory TestStoreFactory\n\t\t=> FbTestStoreFactory.Instance;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingMiscellaneousFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing Microsoft.EntityFrameworkCore.Query.Associations.ComplexTableSplitting;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.ComplexTableSplitting;\n\npublic class ComplexTableSplittingMiscellaneousFbTest : ComplexTableSplittingMiscellaneousRelationalTestBase<ComplexTableSplittingFbFixture>\n{\n\tpublic ComplexTableSplittingMiscellaneousFbTest(ComplexTableSplittingFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingProjectionFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query.Associations.ComplexTableSplitting;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.ComplexTableSplitting;\n\npublic class ComplexTableSplittingProjectionFbTest : ComplexTableSplittingProjectionRelationalTestBase<ComplexTableSplittingFbFixture>\n{\n\tpublic ComplexTableSplittingProjectionFbTest(ComplexTableSplittingFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\t// Users OUTER join\n\t[NotSupportedByProviderTheory]\n\t[MemberData(nameof(TrackingData))]\n\tpublic override Task Select_subquery_optional_related_FirstOrDefault(QueryTrackingBehavior queryTrackingBehavior)\n\t{\n\t\treturn base.Select_subquery_optional_related_FirstOrDefault(queryTrackingBehavior);\n\t}\n\n\t// Users OUTER join\n\t[NotSupportedByProviderTheory]\n\t[MemberData(nameof(TrackingData))]\n\tpublic override Task Select_subquery_required_related_FirstOrDefault(QueryTrackingBehavior queryTrackingBehavior)\n\t{\n\t\treturn base.Select_subquery_required_related_FirstOrDefault(queryTrackingBehavior);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/ComplexTableSplitting/ComplexTableSplittingStructuralEqualityFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing Microsoft.EntityFrameworkCore.Query.Associations.ComplexTableSplitting;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.ComplexTableSplitting;\n\npublic class ComplexTableSplittingStructuralEqualityFbTest : ComplexTableSplittingStructuralEqualityRelationalTestBase<ComplexTableSplittingFbFixture>\n{\n\tpublic ComplexTableSplittingStructuralEqualityFbTest(ComplexTableSplittingFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/Navigations/NavigationsCollectionFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query.Associations.Navigations;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.Navigations;\n\npublic class NavigationsCollectionFbTest : NavigationsCollectionRelationalTestBase<NavigationsFbFixture>\n{\n\tpublic NavigationsCollectionFbTest(NavigationsFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture,\n\t\ttestOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(TrackingData))]\n\tpublic override Task Distinct_projected(QueryTrackingBehavior queryTrackingBehavior)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Distinct_projected(queryTrackingBehavior);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/Navigations/NavigationsFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Query.Associations.Navigations;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.Navigations;\n\npublic class NavigationsFbFixture : NavigationsRelationalFixtureBase\n{\n\tprotected override ITestStoreFactory TestStoreFactory\n\t\t=> FbTestStoreFactory.Instance;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/Navigations/NavigationsIncludeFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing Microsoft.EntityFrameworkCore.Query.Associations.Navigations;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.Navigations;\n\npublic class NavigationsIncludeFbTest : NavigationsIncludeRelationalTestBase<NavigationsFbFixture>\n{\n\tpublic NavigationsIncludeFbTest(NavigationsFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/Navigations/NavigationsMiscellaneousFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing Microsoft.EntityFrameworkCore.Query.Associations.Navigations;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.Navigations;\n\npublic class NavigationsMiscellaneousFbTest : NavigationsMiscellaneousRelationalTestBase<NavigationsFbFixture>\n{\n\tpublic NavigationsMiscellaneousFbTest(NavigationsFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/Navigations/NavigationsPrimitiveCollectionFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query.Associations.Navigations;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.Navigations;\n\npublic class NavigationsPrimitiveCollectionFbTest : NavigationsPrimitiveCollectionRelationalTestBase<NavigationsFbFixture>\n{\n\tpublic NavigationsPrimitiveCollectionFbTest(NavigationsFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Any_predicate()\n\t{\n\t\treturn base.Any_predicate();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Contains()\n\t{\n\t\treturn base.Contains();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Count()\n\t{\n\t\treturn base.Count();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Index()\n\t{\n\t\treturn base.Index();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Nested_Count()\n\t{\n\t\treturn base.Nested_Count();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Select_Sum()\n\t{\n\t\treturn base.Select_Sum();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/Navigations/NavigationsProjectionFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query.Associations.Navigations;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.Navigations;\n\npublic class NavigationsProjectionFbTest : NavigationsProjectionRelationalTestBase<NavigationsFbFixture>\n{\n\tpublic NavigationsProjectionFbTest(NavigationsFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\t\n\t[Theory]\n\t[MemberData(nameof(TrackingData))]\n\tpublic override Task Select_subquery_optional_related_FirstOrDefault(QueryTrackingBehavior queryTrackingBehavior)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Select_subquery_optional_related_FirstOrDefault(queryTrackingBehavior);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(TrackingData))]\n\tpublic override Task Select_subquery_required_related_FirstOrDefault(QueryTrackingBehavior queryTrackingBehavior)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Select_subquery_required_related_FirstOrDefault(queryTrackingBehavior);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/Navigations/NavigationsSetOperationsFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing Microsoft.EntityFrameworkCore.Query.Associations.Navigations;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.Navigations;\n\npublic class NavigationsSetOperationsFbTest : NavigationsSetOperationsRelationalTestBase<NavigationsFbFixture>\n{\n\tpublic NavigationsSetOperationsFbTest(NavigationsFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/Navigations/NavigationsStructuralEqualityFbTest.cs",
    "content": "﻿using Microsoft.EntityFrameworkCore.Query.Associations.Navigations;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.Navigations;\n\npublic class NavigationsStructuralEqualityFbTest : NavigationsStructuralEqualityRelationalTestBase<NavigationsFbFixture>\n{\n\tpublic NavigationsStructuralEqualityFbTest(NavigationsFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsCollectionFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query.Associations.OwnedNavigations;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.OwnedNavigations;\n\npublic class OwnedNavigationsCollectionFbTest : OwnedNavigationsCollectionRelationalTestBase<OwnedNavigationsFbFixture>\n{\n\tpublic OwnedNavigationsCollectionFbTest(OwnedNavigationsFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(TrackingData))]\n\tpublic override Task Distinct_projected(QueryTrackingBehavior queryTrackingBehavior)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Distinct_projected(queryTrackingBehavior);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsFbFixture.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query.Associations.OwnedNavigations;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.OwnedNavigations;\n\npublic class OwnedNavigationsFbFixture : OwnedNavigationsRelationalFixtureBase\n{\n\tprotected override ITestStoreFactory TestStoreFactory\n\t\t=> FbTestStoreFactory.Instance;\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t{\n\t\tbase.OnModelCreating(modelBuilder, context);\n\n\t\tModelHelpers.SimpleTableNames(modelBuilder);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsMiscellaneousFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing Microsoft.EntityFrameworkCore.Query.Associations.OwnedNavigations;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.OwnedNavigations;\n\npublic class OwnedNavigationsMiscellaneousFbTest : OwnedNavigationsMiscellaneousRelationalTestBase<OwnedNavigationsFbFixture>\n{\n\tpublic OwnedNavigationsMiscellaneousFbTest(OwnedNavigationsFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsProjectionFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query.Associations.OwnedNavigations;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.OwnedNavigations;\n\npublic class OwnedNavigationsProjectionFbTest : OwnedNavigationsProjectionRelationalTestBase<OwnedNavigationsFbFixture>\n{\n\tpublic OwnedNavigationsProjectionFbTest(OwnedNavigationsFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(TrackingData))]\n\tpublic override Task Select_subquery_optional_related_FirstOrDefault(QueryTrackingBehavior queryTrackingBehavior)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Select_subquery_optional_related_FirstOrDefault(queryTrackingBehavior);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(TrackingData))]\n\tpublic override Task Select_subquery_required_related_FirstOrDefault(QueryTrackingBehavior queryTrackingBehavior)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Select_subquery_required_related_FirstOrDefault(queryTrackingBehavior);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsSetOperationsFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query.Associations.OwnedNavigations;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.OwnedNavigations;\n\npublic class OwnedNavigationsSetOperationsFbTest : OwnedNavigationsSetOperationsRelationalTestBase<OwnedNavigationsFbFixture>\n{\n\tpublic OwnedNavigationsSetOperationsFbTest(OwnedNavigationsFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\t[NotSupportedByProviderTheory]\n\t[MemberData(nameof(TrackingData))]\n\tpublic override Task Over_associate_collection_projected(QueryTrackingBehavior queryTrackingBehavior)\n\t{\n\t\treturn base.Over_associate_collection_projected(queryTrackingBehavior);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/OwnedNavigations/OwnedNavigationsStructuralEqualityFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing Microsoft.EntityFrameworkCore.Query.Associations.OwnedNavigations;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.OwnedNavigations;\n\npublic class OwnedNavigationsStructuralEqualityFbTest : OwnedNavigationsStructuralEqualityRelationalTestBase<OwnedNavigationsFbFixture>\n{\n\tpublic OwnedNavigationsStructuralEqualityFbTest(OwnedNavigationsFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingFbFixture.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query.Associations;\nusing Microsoft.EntityFrameworkCore.Query.Associations.OwnedTableSplitting;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.OwnedTableSplitting;\n\npublic class OwnedTableSplittingFbFixture : OwnedTableSplittingRelationalFixtureBase\n{\n\tprotected override ITestStoreFactory TestStoreFactory\n\t\t=> FbTestStoreFactory.Instance;\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n    {\n        base.OnModelCreating(modelBuilder, context);\n\n        modelBuilder.Entity<RootEntity>(b =>\n        {\n            b.OwnsOne(\n                e => e.RequiredAssociate, rrb =>\n                {\n                    rrb.OwnsMany(\n                        r => r.NestedCollection, rcb =>\n                        {\n                            rcb.Property(x => x.Id).ValueGeneratedNever();\n                            rcb.ToTable(\"RR_NC\"); // RequiredRelated_NestedCollection\n                        });\n                });\n            b.Navigation(x => x.RequiredAssociate).IsRequired();\n\n            b.OwnsOne(\n                e => e.OptionalAssociate, orb =>\n                {\n                    orb.OwnsMany(\n                        r => r.NestedCollection, rcb =>\n                        {\n                            rcb.Property(x => x.Id).ValueGeneratedNever();\n                            rcb.ToTable(\"OR_NC\"); // OptionalRelated_NestedCollection\n                        });\n                });\n            b.Navigation(x => x.OptionalAssociate).IsRequired(false);\n\n            b.OwnsMany(\n                e => e.AssociateCollection, rcb =>\n                {\n                    rcb.OwnsMany(\n                        r => r.NestedCollection, rcb =>\n                        {\n                            rcb.Property(x => x.Id).ValueGeneratedNever();\n                            rcb.ToTable(\"RC_NC\"); // RelatedCollection_NestedCollection\n                        });\n                });\n        });\n    }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingMiscellaneousFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing Microsoft.EntityFrameworkCore.Query.Associations.OwnedTableSplitting;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.OwnedTableSplitting;\n\npublic class OwnedTableSplittingMiscellaneousFbTest : OwnedTableSplittingMiscellaneousRelationalTestBase<OwnedTableSplittingFbFixture>\n{\n\tpublic OwnedTableSplittingMiscellaneousFbTest(OwnedTableSplittingFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingProjectionFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query.Associations.OwnedTableSplitting;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.OwnedTableSplitting;\n\npublic class OwnedTableSplittingProjectionFbTest : OwnedTableSplittingProjectionRelationalTestBase<OwnedTableSplittingFbFixture>\n{\n\tpublic OwnedTableSplittingProjectionFbTest(OwnedTableSplittingFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(TrackingData))]\n\tpublic override Task Select_subquery_optional_related_FirstOrDefault(QueryTrackingBehavior queryTrackingBehavior)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Select_subquery_optional_related_FirstOrDefault(queryTrackingBehavior);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(TrackingData))]\n\tpublic override Task Select_subquery_required_related_FirstOrDefault(QueryTrackingBehavior queryTrackingBehavior)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Select_subquery_required_related_FirstOrDefault(queryTrackingBehavior);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Associations/OwnedTableSplitting/OwnedTableSplittingStructuralEqualityFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing Microsoft.EntityFrameworkCore.Query.Associations.OwnedTableSplitting;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Associations.OwnedTableSplitting;\n\npublic class OwnedTableSplittingStructuralEqualityFbTest : OwnedTableSplittingStructuralEqualityRelationalTestBase<OwnedTableSplittingFbFixture>\n{\n\tpublic OwnedTableSplittingStructuralEqualityFbTest(OwnedTableSplittingFbFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, testOutputHelper)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/ComplexNavigationsCollectionsQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class ComplexNavigationsCollectionsQueryFbTest : ComplexNavigationsCollectionsQueryRelationalTestBase<ComplexNavigationsQueryFbFixture>\n{\n\tpublic ComplexNavigationsCollectionsQueryFbTest(ComplexNavigationsQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_query_issue_21665(bool async)\n\t{\n\t\treturn base.Complex_query_issue_21665(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async)\n\t{\n\t\treturn base.Complex_query_with_let_collection_projection_FirstOrDefault(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(bool async)\n\t{\n\t\treturn base.Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_after_different_filtered_include_different_level(bool async)\n\t{\n\t\treturn base.Filtered_include_after_different_filtered_include_different_level(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async)\n\t{\n\t\treturn base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async)\n\t{\n\t\treturn base.Filtered_include_complex_three_level_with_middle_having_filter1(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async)\n\t{\n\t\treturn base.Filtered_include_complex_three_level_with_middle_having_filter2(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async)\n\t{\n\t\treturn base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_outer_parameter_used_inside_filter(bool async)\n\t{\n\t\treturn base.Filtered_include_outer_parameter_used_inside_filter(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async)\n\t{\n\t\treturn base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(bool async)\n\t{\n\t\treturn base.Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_with_Take_without_order_by_followed_by_ThenInclude_and_FirstOrDefault_on_top_level(bool async)\n\t{\n\t\treturn base.Filtered_include_with_Take_without_order_by_followed_by_ThenInclude_and_FirstOrDefault_on_top_level(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_inside_subquery(bool async)\n\t{\n\t\treturn base.Include_inside_subquery(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Projecting_collection_after_optional_reference_correlated_with_parent(bool async)\n\t{\n\t\treturn base.Projecting_collection_after_optional_reference_correlated_with_parent(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Projecting_collection_with_group_by_after_optional_reference_correlated_with_parent(bool async)\n\t{\n\t\treturn base.Projecting_collection_with_group_by_after_optional_reference_correlated_with_parent(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_predicate_and_DefaultIfEmpty_projecting_root_collection_element_and_another_collection(bool async)\n\t{\n\t\treturn base.SelectMany_with_predicate_and_DefaultIfEmpty_projecting_root_collection_element_and_another_collection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_Distinct_on_grouping_element(bool async)\n\t{\n\t\treturn base.Skip_Take_Distinct_on_grouping_element(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_on_grouping_element_inside_collection_projection(bool async)\n\t{\n\t\treturn base.Skip_Take_on_grouping_element_inside_collection_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_on_grouping_element_with_collection_include(bool async)\n\t{\n\t\treturn base.Skip_Take_on_grouping_element_with_collection_include(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_on_grouping_element_with_reference_include(bool async)\n\t{\n\t\treturn base.Skip_Take_on_grouping_element_with_reference_include(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_Select_collection_Skip_Take(bool async)\n\t{\n\t\treturn base.Skip_Take_Select_collection_Skip_Take(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Take_Select_collection_Take(bool async)\n\t{\n\t\treturn base.Take_Select_collection_Take(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_with_Take_without_order_by_followed_by_ThenInclude_and_unordered_Take_on_top_level(bool async)\n\t{\n\t\treturn base.Filtered_include_with_Take_without_order_by_followed_by_ThenInclude_and_unordered_Take_on_top_level(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_Take_with_another_Take_on_top_level(bool async)\n\t{\n\t\treturn base.Filtered_include_Take_with_another_Take_on_top_level(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class ComplexNavigationsCollectionsSharedTypeQueryFbTest : ComplexNavigationsCollectionsSharedTypeQueryRelationalTestBase<ComplexNavigationsSharedTypeQueryFbFixture>\n{\n\tpublic ComplexNavigationsCollectionsSharedTypeQueryFbTest(ComplexNavigationsSharedTypeQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Theory(Skip = \"Should fail, but not failing.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(bool async)\n\t{\n\t\treturn base.SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async)\n\t{\n\t\treturn base.Complex_query_with_let_collection_projection_FirstOrDefault(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(bool async)\n\t{\n\t\treturn base.Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_after_different_filtered_include_different_level(bool async)\n\t{\n\t\treturn base.Filtered_include_after_different_filtered_include_different_level(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async)\n\t{\n\t\treturn base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async)\n\t{\n\t\treturn base.Filtered_include_complex_three_level_with_middle_having_filter1(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async)\n\t{\n\t\treturn base.Filtered_include_complex_three_level_with_middle_having_filter2(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async)\n\t{\n\t\treturn base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async)\n\t{\n\t\treturn base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(bool async)\n\t{\n\t\treturn base.Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_Take_with_another_Take_on_top_level(bool async)\n\t{\n\t\treturn base.Filtered_include_Take_with_another_Take_on_top_level(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_with_Take_without_order_by_followed_by_ThenInclude_and_FirstOrDefault_on_top_level(bool async)\n\t{\n\t\treturn base.Filtered_include_with_Take_without_order_by_followed_by_ThenInclude_and_FirstOrDefault_on_top_level(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_with_Take_without_order_by_followed_by_ThenInclude_and_unordered_Take_on_top_level(bool async)\n\t{\n\t\treturn base.Filtered_include_with_Take_without_order_by_followed_by_ThenInclude_and_unordered_Take_on_top_level(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Projecting_collection_after_optional_reference_correlated_with_parent(bool async)\n\t{\n\t\treturn base.Projecting_collection_after_optional_reference_correlated_with_parent(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Projecting_collection_with_group_by_after_optional_reference_correlated_with_parent(bool async)\n\t{\n\t\treturn base.Projecting_collection_with_group_by_after_optional_reference_correlated_with_parent(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_predicate_and_DefaultIfEmpty_projecting_root_collection_element_and_another_collection(bool async)\n\t{\n\t\treturn base.SelectMany_with_predicate_and_DefaultIfEmpty_projecting_root_collection_element_and_another_collection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_Distinct_on_grouping_element(bool async)\n\t{\n\t\treturn base.Skip_Take_Distinct_on_grouping_element(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_on_grouping_element_inside_collection_projection(bool async)\n\t{\n\t\treturn base.Skip_Take_on_grouping_element_inside_collection_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_on_grouping_element_with_collection_include(bool async)\n\t{\n\t\treturn base.Skip_Take_on_grouping_element_with_collection_include(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_on_grouping_element_with_reference_include(bool async)\n\t{\n\t\treturn base.Skip_Take_on_grouping_element_with_reference_include(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_Select_collection_Skip_Take(bool async)\n\t{\n\t\treturn base.Skip_Take_Select_collection_Skip_Take(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Take_Select_collection_Take(bool async)\n\t{\n\t\treturn base.Take_Select_collection_Take(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing System.Threading.Tasks;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class ComplexNavigationsCollectionsSplitQueryFbTest : ComplexNavigationsCollectionsSplitQueryRelationalTestBase<ComplexNavigationsQueryFbFixture>\n{\n\tpublic ComplexNavigationsCollectionsSplitQueryFbTest(ComplexNavigationsQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_query_issue_21665(bool async)\n\t{\n\t\treturn base.Complex_query_issue_21665(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async)\n\t{\n\t\treturn base.Complex_query_with_let_collection_projection_FirstOrDefault(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(bool async)\n\t{\n\t\treturn base.Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_after_different_filtered_include_different_level(bool async)\n\t{\n\t\treturn base.Filtered_include_after_different_filtered_include_different_level(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async)\n\t{\n\t\treturn base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async)\n\t{\n\t\treturn base.Filtered_include_complex_three_level_with_middle_having_filter1(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async)\n\t{\n\t\treturn base.Filtered_include_complex_three_level_with_middle_having_filter2(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async)\n\t{\n\t\treturn base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_outer_parameter_used_inside_filter(bool async)\n\t{\n\t\treturn base.Filtered_include_outer_parameter_used_inside_filter(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async)\n\t{\n\t\treturn base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(bool async)\n\t{\n\t\treturn base.Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_with_Take_without_order_by_followed_by_ThenInclude_and_FirstOrDefault_on_top_level(bool async)\n\t{\n\t\treturn base.Filtered_include_with_Take_without_order_by_followed_by_ThenInclude_and_FirstOrDefault_on_top_level(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_inside_subquery(bool async)\n\t{\n\t\treturn base.Include_inside_subquery(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Projecting_collection_after_optional_reference_correlated_with_parent(bool async)\n\t{\n\t\treturn base.Projecting_collection_after_optional_reference_correlated_with_parent(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Projecting_collection_with_group_by_after_optional_reference_correlated_with_parent(bool async)\n\t{\n\t\treturn base.Projecting_collection_with_group_by_after_optional_reference_correlated_with_parent(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_predicate_and_DefaultIfEmpty_projecting_root_collection_element_and_another_collection(bool async)\n\t{\n\t\treturn base.SelectMany_with_predicate_and_DefaultIfEmpty_projecting_root_collection_element_and_another_collection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_Distinct_on_grouping_element(bool async)\n\t{\n\t\treturn base.Skip_Take_Distinct_on_grouping_element(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_on_grouping_element_inside_collection_projection(bool async)\n\t{\n\t\treturn base.Skip_Take_on_grouping_element_inside_collection_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_on_grouping_element_with_collection_include(bool async)\n\t{\n\t\treturn base.Skip_Take_on_grouping_element_with_collection_include(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_on_grouping_element_with_reference_include(bool async)\n\t{\n\t\treturn base.Skip_Take_on_grouping_element_with_reference_include(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_Select_collection_Skip_Take(bool async)\n\t{\n\t\treturn base.Skip_Take_Select_collection_Skip_Take(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Take_Select_collection_Take(bool async)\n\t{\n\t\treturn base.Take_Select_collection_Take(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_with_Take_without_order_by_followed_by_ThenInclude_and_unordered_Take_on_top_level(bool async)\n\t{\n\t\treturn base.Filtered_include_with_Take_without_order_by_followed_by_ThenInclude_and_unordered_Take_on_top_level(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_Take_with_another_Take_on_top_level(bool async)\n\t{\n\t\treturn base.Filtered_include_Take_with_another_Take_on_top_level(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/ComplexNavigationsCollectionsSplitSharedTypeQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class ComplexNavigationsCollectionsSplitSharedTypeQueryFbTest : ComplexNavigationsCollectionsSplitSharedTypeQueryRelationalTestBase<ComplexNavigationsSharedTypeQueryFbFixture>\n{\n\tpublic ComplexNavigationsCollectionsSplitSharedTypeQueryFbTest(ComplexNavigationsSharedTypeQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Theory(Skip = \"Should fail, but not failing.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(bool async)\n\t{\n\t\treturn base.SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async)\n\t{\n\t\treturn base.Complex_query_with_let_collection_projection_FirstOrDefault(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(bool async)\n\t{\n\t\treturn base.Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async)\n\t{\n\t\treturn base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async)\n\t{\n\t\treturn base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async)\n\t{\n\t\treturn base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_Take_with_another_Take_on_top_level(bool async)\n\t{\n\t\treturn base.Filtered_include_Take_with_another_Take_on_top_level(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_with_Take_without_order_by_followed_by_ThenInclude_and_FirstOrDefault_on_top_level(bool async)\n\t{\n\t\treturn base.Filtered_include_with_Take_without_order_by_followed_by_ThenInclude_and_FirstOrDefault_on_top_level(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_with_Take_without_order_by_followed_by_ThenInclude_and_unordered_Take_on_top_level(bool async)\n\t{\n\t\treturn base.Filtered_include_with_Take_without_order_by_followed_by_ThenInclude_and_unordered_Take_on_top_level(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Projecting_collection_after_optional_reference_correlated_with_parent(bool async)\n\t{\n\t\treturn base.Projecting_collection_after_optional_reference_correlated_with_parent(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Projecting_collection_with_group_by_after_optional_reference_correlated_with_parent(bool async)\n\t{\n\t\treturn base.Projecting_collection_with_group_by_after_optional_reference_correlated_with_parent(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_predicate_and_DefaultIfEmpty_projecting_root_collection_element_and_another_collection(bool async)\n\t{\n\t\treturn base.SelectMany_with_predicate_and_DefaultIfEmpty_projecting_root_collection_element_and_another_collection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_Distinct_on_grouping_element(bool async)\n\t{\n\t\treturn base.Skip_Take_Distinct_on_grouping_element(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_on_grouping_element_inside_collection_projection(bool async)\n\t{\n\t\treturn base.Skip_Take_on_grouping_element_inside_collection_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_on_grouping_element_with_reference_include(bool async)\n\t{\n\t\treturn base.Skip_Take_on_grouping_element_with_reference_include(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_Take_Select_collection_Skip_Take(bool async)\n\t{\n\t\treturn base.Skip_Take_Select_collection_Skip_Take(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Take_Select_collection_Take(bool async)\n\t{\n\t\treturn base.Take_Select_collection_Take(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(bool async)\n\t{\n\t\treturn base.Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/ComplexNavigationsQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class ComplexNavigationsQueryFbFixture : ComplexNavigationsQueryRelationalFixtureBase\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t{\n\t\tbase.OnModelCreating(modelBuilder, context);\n\t\tModelHelpers.SimpleTableNames(modelBuilder);\n\t\tModelHelpers.SetStringLengths(modelBuilder);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/ComplexNavigationsQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class ComplexNavigationsQueryFbTest : ComplexNavigationsQueryRelationalTestBase<ComplexNavigationsQueryFbFixture>\n{\n\tpublic ComplexNavigationsQueryFbTest(ComplexNavigationsQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_navigations_with_predicate_projected_into_anonymous_type(bool isAsync)\n\t{\n\t\treturn base.Complex_navigations_with_predicate_projected_into_anonymous_type(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_navigations_with_predicate_projected_into_anonymous_type2(bool isAsync)\n\t{\n\t\treturn base.Complex_navigations_with_predicate_projected_into_anonymous_type2(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_query_with_optional_navigations_and_client_side_evaluation(bool isAsync)\n\t{\n\t\treturn base.Complex_query_with_optional_navigations_and_client_side_evaluation(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_navigation_in_outer_selector_translated_to_extra_join_nested(bool isAsync)\n\t{\n\t\treturn base.Join_navigation_in_outer_selector_translated_to_extra_join_nested(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_navigation_in_outer_selector_translated_to_extra_join_nested2(bool isAsync)\n\t{\n\t\treturn base.Join_navigation_in_outer_selector_translated_to_extra_join_nested2(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Level4_Include(bool isAsync)\n\t{\n\t\treturn base.Level4_Include(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Manually_created_left_join_propagates_nullability_to_navigations(bool isAsync)\n\t{\n\t\treturn base.Manually_created_left_join_propagates_nullability_to_navigations(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multiple_required_navigations_with_Include(bool isAsync)\n\t{\n\t\treturn base.Multiple_required_navigations_with_Include(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multiple_required_navigation_using_multiple_selects_with_Include(bool isAsync)\n\t{\n\t\treturn base.Multiple_required_navigation_using_multiple_selects_with_Include(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multiple_required_navigation_using_multiple_selects_with_string_based_Include(bool isAsync)\n\t{\n\t\treturn base.Multiple_required_navigation_using_multiple_selects_with_string_based_Include(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multiple_required_navigation_with_string_based_Include(bool isAsync)\n\t{\n\t\treturn base.Multiple_required_navigation_with_string_based_Include(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multiple_SelectMany_calls(bool isAsync)\n\t{\n\t\treturn base.Multiple_SelectMany_calls(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multiple_SelectMany_with_navigation_and_explicit_DefaultIfEmpty(bool isAsync)\n\t{\n\t\treturn base.Multiple_SelectMany_with_navigation_and_explicit_DefaultIfEmpty(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multiple_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_joined_together(bool isAsync)\n\t{\n\t\treturn base.Multiple_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_joined_together(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multiple_SelectMany_with_string_based_Include(bool isAsync)\n\t{\n\t\treturn base.Multiple_SelectMany_with_string_based_Include(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multi_include_with_groupby_in_subquery(bool isAsync)\n\t{\n\t\treturn base.Multi_include_with_groupby_in_subquery(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multi_level_navigation_with_same_navigation_compared_to_null(bool isAsync)\n\t{\n\t\treturn base.Multi_level_navigation_with_same_navigation_compared_to_null(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Navigation_inside_method_call_translated_to_join2(bool isAsync)\n\t{\n\t\treturn base.Navigation_inside_method_call_translated_to_join2(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Optional_navigation_take_optional_navigation(bool isAsync)\n\t{\n\t\treturn base.Optional_navigation_take_optional_navigation(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Optional_navigation_with_Include(bool isAsync)\n\t{\n\t\treturn base.Optional_navigation_with_Include(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Order_by_key_of_anonymous_type_projected_navigation_doesnt_get_optimized_into_FK_access_subquery(bool isAsync)\n\t{\n\t\treturn base.Order_by_key_of_anonymous_type_projected_navigation_doesnt_get_optimized_into_FK_access_subquery(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Order_by_key_of_navigation_similar_to_projected_gets_optimized_into_FK_access(bool isAsync)\n\t{\n\t\treturn base.Order_by_key_of_navigation_similar_to_projected_gets_optimized_into_FK_access(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Order_by_key_of_projected_navigation_doesnt_get_optimized_into_FK_access1(bool isAsync)\n\t{\n\t\treturn base.Order_by_key_of_projected_navigation_doesnt_get_optimized_into_FK_access1(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Order_by_key_of_projected_navigation_doesnt_get_optimized_into_FK_access2(bool isAsync)\n\t{\n\t\treturn base.Order_by_key_of_projected_navigation_doesnt_get_optimized_into_FK_access2(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Order_by_key_of_projected_navigation_doesnt_get_optimized_into_FK_access3(bool isAsync)\n\t{\n\t\treturn base.Order_by_key_of_projected_navigation_doesnt_get_optimized_into_FK_access3(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Order_by_key_of_projected_navigation_doesnt_get_optimized_into_FK_access_subquery(bool isAsync)\n\t{\n\t\treturn base.Order_by_key_of_projected_navigation_doesnt_get_optimized_into_FK_access_subquery(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Projection_select_correct_table_from_subquery_when_materialization_is_not_required(bool isAsync)\n\t{\n\t\treturn base.Projection_select_correct_table_from_subquery_when_materialization_is_not_required(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Required_navigation_on_a_subquery_with_complex_projection_and_First(bool isAsync)\n\t{\n\t\treturn base.Required_navigation_on_a_subquery_with_complex_projection_and_First(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Required_navigation_on_a_subquery_with_First_in_predicate(bool isAsync)\n\t{\n\t\treturn base.Required_navigation_on_a_subquery_with_First_in_predicate(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Required_navigation_on_a_subquery_with_First_in_projection(bool isAsync)\n\t{\n\t\treturn base.Required_navigation_on_a_subquery_with_First_in_projection(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_nested_navigation_property_optional_and_projection(bool isAsync)\n\t{\n\t\treturn base.SelectMany_nested_navigation_property_optional_and_projection(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_nested_navigation_property_required(bool isAsync)\n\t{\n\t\treturn base.SelectMany_nested_navigation_property_required(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_nested_navigations_and_additional_joins_outside_of_SelectMany(bool isAsync)\n\t{\n\t\treturn base.SelectMany_with_nested_navigations_and_additional_joins_outside_of_SelectMany(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_followed_by_Select_required_navigation_using_different_navs(bool isAsync)\n\t{\n\t\treturn base.SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_followed_by_Select_required_navigation_using_different_navs(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_followed_by_Select_required_navigation_using_same_navs(bool isAsync)\n\t{\n\t\treturn base.SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_followed_by_Select_required_navigation_using_same_navs(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany(bool isAsync)\n\t{\n\t\treturn base.SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany2(bool isAsync)\n\t{\n\t\treturn base.SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany2(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany3(bool isAsync)\n\t{\n\t\treturn base.SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany3(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany4(bool isAsync)\n\t{\n\t\treturn base.SelectMany_with_nested_navigations_explicit_DefaultIfEmpty_and_additional_joins_outside_of_SelectMany4(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_nested_navigation_and_explicit_DefaultIfEmpty(bool isAsync)\n\t{\n\t\treturn base.SelectMany_with_nested_navigation_and_explicit_DefaultIfEmpty(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_nested_navigation_filter_and_explicit_DefaultIfEmpty(bool isAsync)\n\t{\n\t\treturn base.SelectMany_with_nested_navigation_filter_and_explicit_DefaultIfEmpty(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_nested_required_navigation_filter_and_explicit_DefaultIfEmpty(bool isAsync)\n\t{\n\t\treturn base.SelectMany_with_nested_required_navigation_filter_and_explicit_DefaultIfEmpty(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_string_based_Include1(bool isAsync)\n\t{\n\t\treturn base.SelectMany_with_string_based_Include1(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_string_based_Include2(bool isAsync)\n\t{\n\t\treturn base.SelectMany_with_string_based_Include2(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Select_multiple_nav_prop_optional_required(bool isAsync)\n\t{\n\t\treturn base.Select_multiple_nav_prop_optional_required(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Select_multiple_nav_prop_reference_optional(bool isAsync)\n\t{\n\t\treturn base.Select_multiple_nav_prop_reference_optional(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Select_multiple_nav_prop_reference_required(bool isAsync)\n\t{\n\t\treturn base.Select_multiple_nav_prop_reference_required(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Select_multiple_nav_prop_reference_required2(bool isAsync)\n\t{\n\t\treturn base.Select_multiple_nav_prop_reference_required2(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Select_subquery_with_client_eval_and_navigation1(bool isAsync)\n\t{\n\t\treturn base.Select_subquery_with_client_eval_and_navigation1(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Select_subquery_with_client_eval_and_navigation2(bool isAsync)\n\t{\n\t\treturn base.Select_subquery_with_client_eval_and_navigation2(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Simple_level1_level2_GroupBy_Count(bool isAsync)\n\t{\n\t\treturn base.Simple_level1_level2_GroupBy_Count(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Simple_level1_level2_GroupBy_Having_Count(bool isAsync)\n\t{\n\t\treturn base.Simple_level1_level2_GroupBy_Having_Count(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Simple_level1_level2_include(bool isAsync)\n\t{\n\t\treturn base.Simple_level1_level2_include(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Simple_level1_level2_level3_include(bool isAsync)\n\t{\n\t\treturn base.Simple_level1_level2_level3_include(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task String_include_multiple_derived_collection_navigation_with_same_name_and_different_type_nested_also_includes_partially_matching_navigation_chains(bool isAsync)\n\t{\n\t\treturn base.String_include_multiple_derived_collection_navigation_with_same_name_and_different_type_nested_also_includes_partially_matching_navigation_chains(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task String_include_multiple_derived_navigations_complex(bool isAsync)\n\t{\n\t\treturn base.String_include_multiple_derived_navigations_complex(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task String_include_multiple_derived_navigation_with_same_name_and_different_type_nested_also_includes_partially_matching_navigation_chains(bool isAsync)\n\t{\n\t\treturn base.String_include_multiple_derived_navigation_with_same_name_and_different_type_nested_also_includes_partially_matching_navigation_chains(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_complex_predicate_with_with_nav_prop_and_OrElse1(bool isAsync)\n\t{\n\t\treturn base.Where_complex_predicate_with_with_nav_prop_and_OrElse1(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_complex_predicate_with_with_nav_prop_and_OrElse2(bool isAsync)\n\t{\n\t\treturn base.Where_complex_predicate_with_with_nav_prop_and_OrElse2(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_complex_predicate_with_with_nav_prop_and_OrElse3(bool isAsync)\n\t{\n\t\treturn base.Where_complex_predicate_with_with_nav_prop_and_OrElse3(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_complex_predicate_with_with_nav_prop_and_OrElse4(bool isAsync)\n\t{\n\t\treturn base.Where_complex_predicate_with_with_nav_prop_and_OrElse4(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_multiple_nav_prop_optional_required(bool isAsync)\n\t{\n\t\treturn base.Where_multiple_nav_prop_optional_required(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_multiple_nav_prop_reference_optional_compared_to_null1(bool isAsync)\n\t{\n\t\treturn base.Where_multiple_nav_prop_reference_optional_compared_to_null1(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_multiple_nav_prop_reference_optional_compared_to_null2(bool isAsync)\n\t{\n\t\treturn base.Where_multiple_nav_prop_reference_optional_compared_to_null2(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_multiple_nav_prop_reference_optional_compared_to_null3(bool isAsync)\n\t{\n\t\treturn base.Where_multiple_nav_prop_reference_optional_compared_to_null3(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_multiple_nav_prop_reference_optional_compared_to_null4(bool isAsync)\n\t{\n\t\treturn base.Where_multiple_nav_prop_reference_optional_compared_to_null4(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_multiple_nav_prop_reference_optional_compared_to_null5(bool isAsync)\n\t{\n\t\treturn base.Where_multiple_nav_prop_reference_optional_compared_to_null5(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_multiple_nav_prop_reference_optional_member_compared_to_null(bool isAsync)\n\t{\n\t\treturn base.Where_multiple_nav_prop_reference_optional_member_compared_to_null(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_multiple_nav_prop_reference_optional_member_compared_to_value(bool isAsync)\n\t{\n\t\treturn base.Where_multiple_nav_prop_reference_optional_member_compared_to_value(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_navigation_property_to_collection2(bool isAsync)\n\t{\n\t\treturn base.Where_navigation_property_to_collection2(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_on_multilevel_reference_in_subquery_with_outer_projection(bool isAsync)\n\t{\n\t\treturn base.Where_on_multilevel_reference_in_subquery_with_outer_projection(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_subquery_doesnt_project_unnecessary_columns_in_top_level_join(bool isAsync)\n\t{\n\t\treturn base.Correlated_subquery_doesnt_project_unnecessary_columns_in_top_level_join(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task GroupJoin_with_complex_subquery_with_joins_does_not_get_flattened(bool isAsync)\n\t{\n\t\treturn base.GroupJoin_with_complex_subquery_with_joins_does_not_get_flattened(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task GroupJoin_with_complex_subquery_with_joins_does_not_get_flattened2(bool isAsync)\n\t{\n\t\treturn base.GroupJoin_with_complex_subquery_with_joins_does_not_get_flattened2(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task GroupJoin_with_complex_subquery_with_joins_does_not_get_flattened3(bool isAsync)\n\t{\n\t\treturn base.GroupJoin_with_complex_subquery_with_joins_does_not_get_flattened3(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include18_1_1(bool isAsync)\n\t{\n\t\treturn base.Include18_1_1(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include19(bool isAsync)\n\t{\n\t\treturn base.Include19(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_navigation_deeply_nested_non_key_join(bool isAsync)\n\t{\n\t\treturn base.Join_navigation_deeply_nested_non_key_join(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_navigation_deeply_nested_required(bool isAsync)\n\t{\n\t\treturn base.Join_navigation_deeply_nested_required(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_navigation_in_inner_selector(bool isAsync)\n\t{\n\t\treturn base.Join_navigation_in_inner_selector(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_navigation_key_access_optional(bool isAsync)\n\t{\n\t\treturn base.Join_navigation_key_access_optional(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_navigation_key_access_required(bool isAsync)\n\t{\n\t\treturn base.Join_navigation_key_access_required(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_navigation_nested(bool isAsync)\n\t{\n\t\treturn base.Join_navigation_nested(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_navigation_nested2(bool isAsync)\n\t{\n\t\treturn base.Join_navigation_nested2(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_navigation_non_key_join(bool isAsync)\n\t{\n\t\treturn base.Join_navigation_non_key_join(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_navigation_self_ref(bool isAsync)\n\t{\n\t\treturn base.Join_navigation_self_ref(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_navigations_in_inner_selector_translated_without_collision(bool isAsync)\n\t{\n\t\treturn base.Join_navigations_in_inner_selector_translated_without_collision(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_with_orderby_on_inner_sequence_navigation_non_key_join(bool isAsync)\n\t{\n\t\treturn base.Join_with_orderby_on_inner_sequence_navigation_non_key_join(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Null_reference_protection_complex(bool isAsync)\n\t{\n\t\treturn base.Null_reference_protection_complex(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Null_reference_protection_complex_client_eval(bool isAsync)\n\t{\n\t\treturn base.Null_reference_protection_complex_client_eval(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Null_reference_protection_complex_materialization(bool isAsync)\n\t{\n\t\treturn base.Null_reference_protection_complex_materialization(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Optional_navigation_propagates_nullability_to_manually_created_left_join2(bool isAsync)\n\t{\n\t\treturn base.Optional_navigation_propagates_nullability_to_manually_created_left_join2(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Union_over_entities_with_different_nullability(bool isAsync)\n\t{\n\t\treturn base.Union_over_entities_with_different_nullability(isAsync);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_with_groupby_in_subquery(bool async)\n\t{\n\t\treturn base.Include_reference_with_groupby_in_subquery(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_shadow_properties1(bool async)\n\t{\n\t\treturn base.Project_shadow_properties1(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_shadow_properties2(bool async)\n\t{\n\t\treturn base.Project_shadow_properties2(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_shadow_properties3(bool async)\n\t{\n\t\treturn base.Project_shadow_properties3(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_shadow_properties4(bool async)\n\t{\n\t\treturn base.Project_shadow_properties4(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_shadow_properties9(bool async)\n\t{\n\t\treturn base.Project_shadow_properties9(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_shadow_properties10(bool async)\n\t{\n\t\treturn base.Project_shadow_properties10(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_outside_reference_to_joined_table_correctly_translated_to_apply(bool isAsync)\n\t{\n\t\treturn base.SelectMany_with_outside_reference_to_joined_table_correctly_translated_to_apply(isAsync);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Let_let_contains_from_outer_let(bool async)\n\t{\n\t\treturn base.Let_let_contains_from_outer_let(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Prune_does_not_throw_null_ref(bool async)\n\t{\n\t\treturn base.Prune_does_not_throw_null_ref(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task GroupJoin_with_subquery_on_inner(bool async)\n\t{\n\t\treturn base.GroupJoin_with_subquery_on_inner(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task GroupJoin_with_subquery_on_inner_and_no_DefaultIfEmpty(bool async)\n\t{\n\t\treturn base.GroupJoin_with_subquery_on_inner_and_no_DefaultIfEmpty(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Nested_SelectMany_correlated_with_join_table_correctly_translated_to_apply(bool async)\n\t{\n\t\treturn base.Nested_SelectMany_correlated_with_join_table_correctly_translated_to_apply(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_projection_with_first(bool async)\n\t{\n\t\treturn base.Correlated_projection_with_first(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multiple_select_many_in_projection(bool async)\n\t{\n\t\treturn base.Multiple_select_many_in_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Single_select_many_in_projection_with_take(bool async)\n\t{\n\t\treturn base.Single_select_many_in_projection_with_take(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task GroupJoin_client_method_in_OrderBy(bool async)\n\t{\n\t\treturn AssertTranslationFailed(() => base.GroupJoin_client_method_in_OrderBy(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_with_result_selector_returning_queryable_throws_validation_error(bool async)\n\t{\n\t\treturn Assert.ThrowsAsync<ArgumentException>(() => base.Join_with_result_selector_returning_queryable_throws_validation_error(async));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/ComplexNavigationsSharedTypeQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class ComplexNavigationsSharedTypeQueryFbFixture : ComplexNavigationsSharedTypeQueryRelationalFixtureBase\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t{\n\t\tbase.OnModelCreating(modelBuilder, context);\n\t\tModelHelpers.SimpleTableNames(modelBuilder);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/ComplexNavigationsSharedTypeQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class ComplexNavigationsSharedTypeQueryFbTest : ComplexNavigationsSharedTypeQueryRelationalTestBase<ComplexNavigationsSharedTypeQueryFbFixture>\n{\n\tpublic ComplexNavigationsSharedTypeQueryFbTest(ComplexNavigationsSharedTypeQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_with_result_selector_returning_queryable_throws_validation_error(bool async)\n\t{\n\t\treturn Assert.ThrowsAsync<ArgumentException>(() => base.Join_with_result_selector_returning_queryable_throws_validation_error(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task GroupJoin_client_method_in_OrderBy(bool async)\n\t{\n\t\treturn AssertTranslationFailed(() => base.GroupJoin_client_method_in_OrderBy(async));\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task GroupJoin_with_subquery_on_inner(bool async)\n\t{\n\t\treturn base.GroupJoin_with_subquery_on_inner(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task GroupJoin_with_subquery_on_inner_and_no_DefaultIfEmpty(bool async)\n\t{\n\t\treturn base.GroupJoin_with_subquery_on_inner_and_no_DefaultIfEmpty(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Let_let_contains_from_outer_let(bool async)\n\t{\n\t\treturn base.Let_let_contains_from_outer_let(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Nested_SelectMany_correlated_with_join_table_correctly_translated_to_apply(bool async)\n\t{\n\t\treturn base.Nested_SelectMany_correlated_with_join_table_correctly_translated_to_apply(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Prune_does_not_throw_null_ref(bool async)\n\t{\n\t\treturn base.Prune_does_not_throw_null_ref(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_projection_with_first(bool async)\n\t{\n\t\treturn base.Correlated_projection_with_first(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multiple_select_many_in_projection(bool async)\n\t{\n\t\treturn base.Multiple_select_many_in_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Single_select_many_in_projection_with_take(bool async)\n\t{\n\t\treturn base.Single_select_many_in_projection_with_take(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_shadow_properties10(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Project_shadow_properties10(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/ComplexTypeQueryFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestModels.ComplexTypeModel;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class ComplexTypeQueryFbTest : ComplexTypeQueryRelationalTestBase<ComplexTypeQueryFbTest.ComplexTypeQueryFbFixture>\n{\n\tpublic ComplexTypeQueryFbTest(ComplexTypeQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Union_property_in_complex_type(bool async)\n\t{\n\t\treturn AssertQuery(\n\t\t\tasync,\n\t\t\tss => ss.Set<Customer>().Select(c => c.ShippingAddress.AddressLine1)\n\t\t\t\t.Union(ss.Set<Customer>().Select(c => c.BillingAddress.AddressLine1)));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_same_entity_with_nested_complex_type_twice_with_pushdown(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Project_same_entity_with_nested_complex_type_twice_with_pushdown(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_same_entity_with_nested_complex_type_twice_with_double_pushdown(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Project_same_entity_with_nested_complex_type_twice_with_double_pushdown(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_same_entity_with_struct_nested_complex_type_twice_with_double_pushdown(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Project_same_entity_with_struct_nested_complex_type_twice_with_double_pushdown(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_same_entity_with_struct_nested_complex_type_twice_with_pushdown(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Project_same_entity_with_struct_nested_complex_type_twice_with_pushdown(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_same_nested_complex_type_twice_with_double_pushdown(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Project_same_nested_complex_type_twice_with_double_pushdown(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_same_nested_complex_type_twice_with_pushdown(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Project_same_nested_complex_type_twice_with_pushdown(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_same_struct_nested_complex_type_twice_with_double_pushdown(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Project_same_struct_nested_complex_type_twice_with_double_pushdown(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_same_struct_nested_complex_type_twice_with_pushdown(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Project_same_struct_nested_complex_type_twice_with_pushdown(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Union_of_same_entity_with_nested_complex_type_projected_twice_with_double_pushdown(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Union_of_same_entity_with_nested_complex_type_projected_twice_with_double_pushdown(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Union_of_same_entity_with_nested_complex_type_projected_twice_with_pushdown(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Union_of_same_entity_with_nested_complex_type_projected_twice_with_pushdown(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Union_of_same_nested_complex_type_projected_twice_with_double_pushdown(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Union_of_same_nested_complex_type_projected_twice_with_double_pushdown(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Union_of_same_nested_complex_type_projected_twice_with_pushdown(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Union_of_same_nested_complex_type_projected_twice_with_pushdown(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Same_entity_with_complex_type_projected_twice_with_pushdown_as_part_of_another_projection(bool async)\n\t{\n\t\treturn base.Same_entity_with_complex_type_projected_twice_with_pushdown_as_part_of_another_projection(async);\n\t}\n\n\tpublic class ComplexTypeQueryFbFixture : ComplexTypeQueryRelationalFixtureBase\n\t{\n\t\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\t\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t\t{\n\t\t\tbase.OnModelCreating(modelBuilder, context);\n\t\t\tModelHelpers.SetStringLengths(modelBuilder);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/CompositeKeysQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class CompositeKeysQueryFbFixture : CompositeKeysQueryRelationalFixtureBase\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t{\n\t\tbase.OnModelCreating(modelBuilder, context);\n\t\tModelHelpers.SimpleTableNames(modelBuilder);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/CompositeKeysQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class CompositeKeysQueryFbTest : CompositeKeysQueryRelationalTestBase<CompositeKeysQueryFbFixture>\n{\n\tpublic CompositeKeysQueryFbTest(CompositeKeysQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/CompositeKeysSplitQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class CompositeKeysSplitQueryFbTest : CompositeKeysSplitQueryRelationalTestBase<CompositeKeysQueryFbFixture>\n{\n\tpublic CompositeKeysSplitQueryFbTest(CompositeKeysQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Ef6GroupByFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class Ef6GroupByFbTest : Ef6GroupByTestBase<Ef6GroupByFbTest.Ef6GroupByFbFixture>\n{\n\tpublic Ef6GroupByFbTest(Ef6GroupByFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Group_Join_from_LINQ_101(bool async)\n\t{\n\t\treturn base.Group_Join_from_LINQ_101(async);\n\t}\n\n\t[Theory(Skip = \"Different math on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Average_Grouped_from_LINQ_101(bool async)\n\t{\n\t\treturn base.Average_Grouped_from_LINQ_101(async);\n\t}\n\n\tpublic class Ef6GroupByFbFixture : Ef6GroupByFixtureBase, ITestSqlLoggerFactory\n\t{\n\t\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\t\tpublic TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory;\n\n\t\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t\t{\n\t\t\tbase.OnModelCreating(modelBuilder, context);\n\t\t\tModelHelpers.SetStringLengths(modelBuilder);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/EntitySplittingQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class EntitySplittingQueryFbTest(NonSharedFixture fixture) : EntitySplittingQueryTestBase(fixture)\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/FromSqlQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data.Common;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.FirebirdClient;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestModels.Northwind;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class FromSqlQueryFbTest : FromSqlQueryTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic FromSqlQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override async Task FromSql_Count_used_twice_without_parameters(bool async)\n\t{\n\t\tusing var context = CreateContext();\n\n\t\tvar query = context.Set<OrderQuery>()\n\t\t\t.FromSqlRaw(NormalizeDelimitersInRawString(\"SELECT 'ALFKI' AS [CustomerID] FROM RDB$DATABASE\"))\n\t\t\t.IgnoreQueryFilters();\n\n\t\tvar result1 = async\n\t\t\t? await query.CountAsync() > 0\n\t\t\t: query.Count() > 0;\n\n\t\tvar result2 = async\n\t\t\t? await query.CountAsync() > 0\n\t\t\t: query.Count() > 0;\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override async Task FromSql_Count_used_twice_with_parameters(bool async)\n\t{\n\t\tusing var context = CreateContext();\n\n\t\tvar query = context.Set<OrderQuery>()\n\t\t\t.FromSqlRaw(NormalizeDelimitersInRawString(\"SELECT CAST({0} AS CHAR(5)) AS [CustomerID] FROM RDB$DATABASE\"), \"ALFKI\")\n\t\t\t.IgnoreQueryFilters();\n\n\t\tvar result1 = async\n\t\t\t? await query.CountAsync() > 0\n\t\t\t: query.Count() > 0;\n\n\t\tvar result2 = async\n\t\t\t? await query.CountAsync() > 0\n\t\t\t: query.Count() > 0;\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override async Task FromSql_used_twice_without_parameters(bool async)\n\t{\n\t\tusing var context = CreateContext();\n\n\t\tvar query = context.Set<OrderQuery>()\n\t\t\t.FromSqlRaw(NormalizeDelimitersInRawString(\"SELECT 'ALFKI' AS [CustomerID] FROM RDB$DATABASE\"))\n\t\t\t.IgnoreQueryFilters();\n\n\t\tvar result1 = async\n\t\t\t? await query.AnyAsync()\n\t\t\t: query.Any();\n\n\t\tvar result2 = async\n\t\t\t? await query.AnyAsync()\n\t\t\t: query.Any();\n\n\t\tAssert.Equal(result1, result2);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override async Task FromSql_used_twice_with_parameters(bool async)\n\t{\n\t\tusing var context = CreateContext();\n\n\t\tvar query = context.Set<OrderQuery>()\n\t\t\t.FromSqlRaw(NormalizeDelimitersInRawString(\"SELECT CAST({0} AS CHAR(5)) AS [CustomerID] FROM RDB$DATABASE\"), \"ALFKI\")\n\t\t\t.IgnoreQueryFilters();\n\n\t\tvar result1 = async\n\t\t\t? await query.AnyAsync()\n\t\t\t: query.Any();\n\n\t\tvar result2 = async\n\t\t\t? await query.AnyAsync()\n\t\t\t: query.Any();\n\n\t\tAssert.Equal(result1, result2);\n\t}\n\n\t[Theory(Skip = \"Provider does the casting.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Bad_data_error_handling_invalid_cast(bool async)\n\t{\n\t\treturn base.Bad_data_error_handling_invalid_cast(async);\n\t}\n\n\t[Theory(Skip = \"Provider does the casting.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Bad_data_error_handling_invalid_cast_key(bool async)\n\t{\n\t\treturn base.Bad_data_error_handling_invalid_cast_key(async);\n\t}\n\n\t[Theory(Skip = \"Provider does the casting.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Bad_data_error_handling_invalid_cast_no_tracking(bool async)\n\t{\n\t\treturn base.Bad_data_error_handling_invalid_cast_no_tracking(async);\n\t}\n\n\t[Theory(Skip = \"Provider does the casting.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Bad_data_error_handling_invalid_cast_projection(bool async)\n\t{\n\t\treturn base.Bad_data_error_handling_invalid_cast_projection(async);\n\t}\n\n\t[Theory(Skip = \"Provider does the casting.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task FromSqlRaw_queryable_simple_projection_composed(bool async)\n\t{\n\t\treturn base.FromSqlRaw_queryable_simple_projection_composed(async);\n\t}\n\n\t[Theory(Skip = \"Firebird matches the casing exactly. Frankly the test is weird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task FromSqlRaw_queryable_simple_different_cased_columns_and_not_enough_columns_throws(bool async)\n\t{\n\t\treturn base.FromSqlRaw_queryable_simple_different_cased_columns_and_not_enough_columns_throws(async);\n\t}\n\n\t[Theory(Skip = \"Provider doesn't support INTERSECT\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multiple_occurrences_of_FromSql_with_db_parameter_adds_two_parameters(bool async)\n\t{\n\t\treturn base.Multiple_occurrences_of_FromSql_with_db_parameter_adds_two_parameters(async);\n\t}\n\n\tprotected override DbParameter CreateDbParameter(string name, object value)\n\t\t=> new FbParameter { ParameterName = name, Value = value };\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/FromSqlSprocQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class FromSqlSprocQueryFbTest : FromSqlSprocQueryTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic FromSqlSprocQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\tprotected override string TenMostExpensiveProductsSproc => throw new NotSupportedException();\n\tprotected override string CustomerOrderHistorySproc => throw new NotSupportedException();\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_select_and_stored_procedure(bool async)\n\t{\n\t\treturn base.From_sql_queryable_select_and_stored_procedure(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_select_and_stored_procedure_on_client(bool async)\n\t{\n\t\treturn base.From_sql_queryable_select_and_stored_procedure_on_client(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_and_select(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_and_select(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_and_select_on_client(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_and_select_on_client(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_composed(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_composed(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_composed_on_client(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_composed_on_client(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_min(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_min(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_min_on_client(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_min_on_client(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_projection(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_projection(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_re_projection(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_re_projection(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_re_projection_on_client(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_re_projection_on_client(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_take(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_take(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_take_on_client(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_take_on_client(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_with_include_throws(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_with_include_throws(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_with_parameter(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_with_parameter(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_with_parameter_composed(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_with_parameter_composed(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_with_parameter_composed_on_client(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_with_parameter_composed_on_client(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_with_tag(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_with_tag(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_with_multiple_stored_procedures(bool async)\n\t{\n\t\treturn base.From_sql_queryable_with_multiple_stored_procedures(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_with_multiple_stored_procedures_on_client(bool async)\n\t{\n\t\treturn base.From_sql_queryable_with_multiple_stored_procedures_on_client(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_with_caller_info_tag(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_with_caller_info_tag(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_with_caller_info_tag_and_other_tags(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_with_caller_info_tag_and_other_tags(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task From_sql_queryable_stored_procedure_with_tags(bool async)\n\t{\n\t\treturn base.From_sql_queryable_stored_procedure_with_tags(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/FunkyDataQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class FunkyDataQueryFbTest : FunkyDataQueryTestBase<FunkyDataQueryFbTest.FunkyDataQueryFbFixture>\n{\n\tpublic FunkyDataQueryFbTest(FunkyDataQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task String_contains_on_argument_with_wildcard_column(bool async)\n\t{\n\t\treturn base.String_contains_on_argument_with_wildcard_column(async);\n\t}\n\n\tpublic class FunkyDataQueryFbFixture : FunkyDataQueryFixtureBase, ITestSqlLoggerFactory\n\t{\n\t\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\t\tpublic TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory;\n\n\t\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t\t{\n\t\t\tbase.OnModelCreating(modelBuilder, context);\n\t\t\tModelHelpers.SetStringLengths(modelBuilder);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/GearsOfWarFromSqlQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class GearsOfWarFromSqlQueryFbTest : GearsOfWarFromSqlQueryTestBase<GearsOfWarQueryFbFixture>\n{\n\tpublic GearsOfWarFromSqlQueryFbTest(GearsOfWarQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/GearsOfWarQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class GearsOfWarQueryFbFixture : GearsOfWarQueryRelationalFixture\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t{\n\t\tbase.OnModelCreating(modelBuilder, context);\n\t\tModelHelpers.SetStringLengths(modelBuilder);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/GearsOfWarQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class GearsOfWarQueryFbTest : GearsOfWarQueryRelationalTestBase<GearsOfWarQueryFbFixture>\n{\n\tpublic GearsOfWarQueryFbTest(GearsOfWarQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task DateTimeOffsetNow_minus_timespan(bool async)\n\t{\n\t\treturn base.DateTimeOffsetNow_minus_timespan(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collections_inner_subquery_predicate_references_outer_qsre(bool isAsync)\n\t{\n\t\treturn base.Correlated_collections_inner_subquery_predicate_references_outer_qsre(isAsync);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collections_inner_subquery_selector_references_outer_qsre(bool isAsync)\n\t{\n\t\treturn base.Correlated_collections_inner_subquery_selector_references_outer_qsre(isAsync);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(bool isAsync)\n\t{\n\t\treturn base.Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(isAsync);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(bool isAsync)\n\t{\n\t\treturn base.Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(isAsync);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task DateTimeOffset_Contains_Less_than_Greater_than(bool isAsync)\n\t{\n\t\treturn base.DateTimeOffset_Contains_Less_than_Greater_than(isAsync);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Outer_parameter_in_group_join_with_DefaultIfEmpty(bool isAsync)\n\t{\n\t\treturn base.Outer_parameter_in_group_join_with_DefaultIfEmpty(isAsync);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Outer_parameter_in_join_key(bool isAsync)\n\t{\n\t\treturn base.Outer_parameter_in_join_key(isAsync);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Outer_parameter_in_join_key_inner_and_outer(bool isAsync)\n\t{\n\t\treturn base.Outer_parameter_in_join_key_inner_and_outer(isAsync);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_collection_navigation_nested_with_take_composite_key(bool isAsync)\n\t{\n\t\treturn base.Project_collection_navigation_nested_with_take_composite_key(isAsync);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Take_without_orderby_followed_by_orderBy_is_pushed_down1(bool isAsync)\n\t{\n\t\treturn base.Take_without_orderby_followed_by_orderBy_is_pushed_down1(isAsync);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Take_without_orderby_followed_by_orderBy_is_pushed_down2(bool isAsync)\n\t{\n\t\treturn base.Take_without_orderby_followed_by_orderBy_is_pushed_down2(isAsync);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task DateTimeOffset_Date_returns_datetime(bool isAsync)\n\t{\n\t\treturn base.DateTimeOffset_Date_returns_datetime(isAsync);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(bool async)\n\t{\n\t\treturn base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(bool async)\n\t{\n\t\treturn base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(bool async)\n\t{\n\t\treturn base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(bool async)\n\t{\n\t\treturn base.SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(bool async)\n\t{\n\t\treturn base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_after_distinct_3_levels(bool async)\n\t{\n\t\treturn base.Correlated_collection_after_distinct_3_levels(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(bool async)\n\t{\n\t\treturn base.Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task ToString_boolean_property_non_nullable(bool async)\n\t{\n\t\treturn AssertQuery(async, ss => ss.Set<Weapon>().Select(w => w.IsAutomatic.ToString()), elementAsserter: (lhs, rhs) => { Assert.True(lhs.Equals(rhs, System.StringComparison.InvariantCultureIgnoreCase)); });\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task ToString_boolean_property_nullable(bool async)\n\t{\n\t\treturn AssertQuery(async, ss => ss.Set<LocustHorde>().Select(lh => lh.Eradicated.ToString()), elementAsserter: (lhs, rhs) => { Assert.True(lhs.Equals(rhs, System.StringComparison.InvariantCultureIgnoreCase)); });\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_inner_collection_references_element_two_levels_up(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_inner_collection_references_element_two_levels_up(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection_multiple_grouping_keys(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection_multiple_grouping_keys(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_groupby_not_projecting_identifier_column_but_only_grouping_key_in_final_projection(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_groupby_not_projecting_identifier_column_but_only_grouping_key_in_final_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_distinct_projecting_identifier_column(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_distinct_projecting_identifier_column(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_distinct_not_projecting_identifier_column(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_distinct_not_projecting_identifier_column(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collections_with_Distinct(bool async)\n\t{\n\t\treturn base.Correlated_collections_with_Distinct(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_groupby_with_complex_grouping_key_not_projecting_identifier_column_with_group_aggregate_in_final_projection(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_groupby_with_complex_grouping_key_not_projecting_identifier_column_with_group_aggregate_in_final_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Subquery_inside_Take_argument(bool async)\n\t{\n\t\treturn base.Subquery_inside_Take_argument(async);\n\t}\n\n\t[NotSupportedByProviderTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Non_string_concat_uses_appropriate_type_mapping(bool async)\n\t{\n\t\treturn base.Non_string_concat_uses_appropriate_type_mapping(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task String_concat_with_null_conditional_argument(bool async)\n\t{\n\t\treturn base.String_concat_with_null_conditional_argument(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/IncludeOneToOneFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class IncludeOneToOneFbTest : IncludeOneToOneTestBase<IncludeOneToOneFbTest.OneToOneQueryFbFixture>\n{\n\tpublic IncludeOneToOneFbTest(OneToOneQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\tpublic class OneToOneQueryFbFixture : OneToOneQueryFixtureBase\n\t{\n\t\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\t\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t\t{\n\t\t\tbase.OnModelCreating(modelBuilder, context);\n\t\t\tModelHelpers.SetPrimaryKeyGeneration(modelBuilder);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/IncompleteMappingInheritanceQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class IncompleteMappingInheritanceQueryFbFixture : TPHInheritanceQueryFbFixture\n{\n\tpublic override bool IsDiscriminatorMappingComplete => false;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/IncompleteMappingInheritanceQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class IncompleteMappingInheritanceQueryFbTest : TPHInheritanceQueryTestBase<IncompleteMappingInheritanceQueryFbFixture>\n{\n\tpublic IncompleteMappingInheritanceQueryFbTest(IncompleteMappingInheritanceQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture, testOutputHelper)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/InheritanceRelationshipsQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class InheritanceRelationshipsQueryFbTest : InheritanceRelationshipsQueryTestBase<InheritanceRelationshipsQueryFbTest.InheritanceRelationshipsQueryFbFixture>\n{\n\tpublic InheritanceRelationshipsQueryFbTest(InheritanceRelationshipsQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_without_inheritance_on_derived1(bool async)\n\t{\n\t\treturn base.Include_reference_without_inheritance_on_derived1(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_without_inheritance_with_filter_reverse(bool async)\n\t{\n\t\treturn base.Include_collection_without_inheritance_with_filter_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Nested_include_with_inheritance_reference_reference_reverse(bool async)\n\t{\n\t\treturn base.Nested_include_with_inheritance_reference_reference_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Nested_include_with_inheritance_reference_collection(bool async)\n\t{\n\t\treturn base.Nested_include_with_inheritance_reference_collection(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_with_inheritance_with_filter(bool async)\n\t{\n\t\treturn base.Include_reference_with_inheritance_with_filter(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_with_inheritance_on_derived2(bool async)\n\t{\n\t\treturn base.Include_reference_with_inheritance_on_derived2(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_without_inheritance_on_derived_reverse(bool async)\n\t{\n\t\treturn base.Include_reference_without_inheritance_on_derived_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_with_inheritance_on_derived_with_filter_reverse(bool async)\n\t{\n\t\treturn base.Include_reference_with_inheritance_on_derived_with_filter_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_inheritance_reverse(bool async)\n\t{\n\t\treturn base.Include_collection_with_inheritance_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongFact]\n\tpublic override void Entity_can_make_separate_relationships_with_base_type_and_derived_type_both()\n\t{\n\t\tbase.Entity_can_make_separate_relationships_with_base_type_and_derived_type_both();\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Nested_include_with_inheritance_collection_reference(bool async)\n\t{\n\t\treturn base.Nested_include_with_inheritance_collection_reference(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_without_inheritance_reverse(bool async)\n\t{\n\t\treturn base.Include_reference_without_inheritance_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Nested_include_with_inheritance_reference_collection_on_base(bool async)\n\t{\n\t\treturn base.Nested_include_with_inheritance_reference_collection_on_base(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_with_inheritance_reverse(bool async)\n\t{\n\t\treturn base.Include_reference_with_inheritance_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_inheritance_on_derived1(bool async)\n\t{\n\t\treturn base.Include_collection_with_inheritance_on_derived1(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_self_reference_with_inheritance(bool async)\n\t{\n\t\treturn base.Include_self_reference_with_inheritance(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_with_inheritance_on_derived_with_filter1(bool async)\n\t{\n\t\treturn base.Include_reference_with_inheritance_on_derived_with_filter1(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Nested_include_with_inheritance_collection_reference_reverse(bool async)\n\t{\n\t\treturn base.Nested_include_with_inheritance_collection_reference_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_inheritance_on_derived3(bool async)\n\t{\n\t\treturn base.Include_collection_with_inheritance_on_derived3(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_without_inheritance_reverse(bool async)\n\t{\n\t\treturn base.Include_collection_without_inheritance_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongFact]\n\tpublic override void Changes_in_derived_related_entities_are_detected()\n\t{\n\t\tbase.Changes_in_derived_related_entities_are_detected();\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_inheritance_with_filter(bool async)\n\t{\n\t\treturn base.Include_collection_with_inheritance_with_filter(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_without_inheritance_on_derived2(bool async)\n\t{\n\t\treturn base.Include_reference_without_inheritance_on_derived2(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_with_inheritance_on_derived4(bool async)\n\t{\n\t\treturn base.Include_reference_with_inheritance_on_derived4(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Nested_include_with_inheritance_reference_reference(bool async)\n\t{\n\t\treturn base.Nested_include_with_inheritance_reference_reference(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_with_inheritance_on_derived_with_filter2(bool async)\n\t{\n\t\treturn base.Include_reference_with_inheritance_on_derived_with_filter2(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_with_inheritance_with_filter_reverse(bool async)\n\t{\n\t\treturn base.Include_reference_with_inheritance_with_filter_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_with_inheritance_on_derived_reverse(bool async)\n\t{\n\t\treturn base.Include_reference_with_inheritance_on_derived_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_self_reference_with_inheritance_reverse(bool async)\n\t{\n\t\treturn base.Include_self_reference_with_inheritance_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_without_inheritance(bool async)\n\t{\n\t\treturn base.Include_collection_without_inheritance(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_without_inheritance_with_filter(bool async)\n\t{\n\t\treturn base.Include_reference_without_inheritance_with_filter(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Nested_include_with_inheritance_collection_collection(bool async)\n\t{\n\t\treturn base.Nested_include_with_inheritance_collection_collection(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Nested_include_with_inheritance_reference_reference_on_base(bool async)\n\t{\n\t\treturn base.Nested_include_with_inheritance_reference_reference_on_base(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_without_inheritance_with_filter_reverse(bool async)\n\t{\n\t\treturn base.Include_reference_without_inheritance_with_filter_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_inheritance(bool async)\n\t{\n\t\treturn base.Include_collection_with_inheritance(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Nested_include_with_inheritance_reference_collection_reverse(bool async)\n\t{\n\t\treturn base.Nested_include_with_inheritance_reference_collection_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_inheritance_on_derived_reverse(bool async)\n\t{\n\t\treturn base.Include_collection_with_inheritance_on_derived_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_inheritance_with_filter_reverse(bool async)\n\t{\n\t\treturn base.Include_collection_with_inheritance_with_filter_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Collection_projection_on_base_type(bool async)\n\t{\n\t\treturn base.Collection_projection_on_base_type(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_inheritance_on_derived2(bool async)\n\t{\n\t\treturn base.Include_collection_with_inheritance_on_derived2(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Nested_include_collection_reference_on_non_entity_base(bool async)\n\t{\n\t\treturn base.Nested_include_collection_reference_on_non_entity_base(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_without_inheritance(bool async)\n\t{\n\t\treturn base.Include_reference_without_inheritance(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_with_inheritance_on_derived_with_filter4(bool async)\n\t{\n\t\treturn base.Include_reference_with_inheritance_on_derived_with_filter4(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_with_inheritance_on_derived1(bool async)\n\t{\n\t\treturn base.Include_reference_with_inheritance_on_derived1(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Nested_include_with_inheritance_collection_collection_reverse(bool async)\n\t{\n\t\treturn base.Nested_include_with_inheritance_collection_collection_reverse(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_reference_with_inheritance(bool async)\n\t{\n\t\treturn base.Include_reference_with_inheritance(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_without_inheritance_with_filter(bool async)\n\t{\n\t\treturn base.Include_collection_without_inheritance_with_filter(async);\n\t}\n\n\t[GeneratedNameTooLongTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_on_derived_type_with_queryable_Cast(bool async)\n\t{\n\t\treturn base.Include_on_derived_type_with_queryable_Cast(async);\n\t}\n\n\tpublic class InheritanceRelationshipsQueryFbFixture : InheritanceRelationshipsQueryRelationalFixture\n\t{\n\t\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\t\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t\t{\n\t\t\tbase.OnModelCreating(modelBuilder, context);\n\t\t\tModelHelpers.SetPrimaryKeyGeneration(modelBuilder);\n\t\t\tModelHelpers.SimpleTableNames(modelBuilder);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/ManyToManyNoTrackingQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class ManyToManyNoTrackingQueryFbTest : ManyToManyNoTrackingQueryRelationalTestBase<ManyToManyQueryFbFixture>\n{\n\tpublic ManyToManyNoTrackingQueryFbTest(ManyToManyQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(bool async)\n\t{\n\t\treturn base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_navigation_order_by_single_or_default(bool async)\n\t{\n\t\treturn base.Skip_navigation_order_by_single_or_default(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where_EF_Property(bool async)\n\t{\n\t\treturn base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where_EF_Property(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/ManyToManyQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class ManyToManyQueryFbFixture : ManyToManyQueryRelationalFixture\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t{\n\t\tbase.OnModelCreating(modelBuilder, context);\n\t\tModelHelpers.ShortenMM(modelBuilder);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/ManyToManyQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class ManyToManyQueryFbTest : ManyToManyQueryRelationalTestBase<ManyToManyQueryFbFixture>\n{\n\tpublic ManyToManyQueryFbTest(ManyToManyQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(bool async)\n\t{\n\t\treturn base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_navigation_order_by_single_or_default(bool async)\n\t{\n\t\treturn base.Skip_navigation_order_by_single_or_default(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where_EF_Property(bool async)\n\t{\n\t\treturn base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where_EF_Property(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/MappingQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class MappingQueryFbTest : MappingQueryTestBase<MappingQueryFbTest.MappingQueryFbFixture>\n{\n\tpublic MappingQueryFbTest(MappingQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[DoesNotHaveTheDataFact]\n\tpublic override void All_customers()\n\t{\n\t\tbase.All_customers();\n\t}\n\n\t[DoesNotHaveTheDataFact]\n\tpublic override void All_employees()\n\t{\n\t\tbase.All_employees();\n\t}\n\n\t[DoesNotHaveTheDataFact]\n\tpublic override void All_orders()\n\t{\n\t\tbase.All_orders();\n\t}\n\n\t[DoesNotHaveTheDataFact]\n\tpublic override void Project_nullable_enum()\n\t{\n\t\tbase.Project_nullable_enum();\n\t}\n\n\tpublic class MappingQueryFbFixture : MappingQueryFixtureBase\n\t{\n\t\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\t\tprotected override string DatabaseSchema { get; } = null;\n\n\t\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t\t{\n\t\t\tbase.OnModelCreating(modelBuilder, context);\n\n\t\t\tmodelBuilder.Entity<MappedCustomer>(\n\t\t\t\te =>\n\t\t\t\t{\n\t\t\t\t\te.Property(c => c.CompanyName2).Metadata.SetColumnName(\"CompanyName\");\n\t\t\t\t\te.Metadata.SetTableName(\"Customers\");\n\t\t\t\t});\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NonSharedPrimitiveCollectionsQueryFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NonSharedPrimitiveCollectionsQueryFbTest(NonSharedFixture fixture) : NonSharedPrimitiveCollectionsQueryRelationalTestBase(fixture)\n{\n\tprotected override DbContextOptionsBuilder SetParameterizedCollectionMode(DbContextOptionsBuilder optionsBuilder,\n\t\tParameterTranslationMode parameterizedCollectionMode)\n\t{\n\t\tnew FbDbContextOptionsBuilder(optionsBuilder).UseParameterizedCollectionMode(parameterizedCollectionMode);\n\t\treturn optionsBuilder;\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Array_of_string()\n\t{\n\t\treturn base.Array_of_string();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Array_of_int()\n\t{\n\t\treturn base.Array_of_int();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Array_of_long()\n    {\n        return base.Array_of_long();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Array_of_short()\n    {\n        return base.Array_of_short();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Array_of_byte()\n\t{\n\t\treturn base.Array_of_byte();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Array_of_double()\n    {\n        return base.Array_of_double();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Array_of_float()\n    {\n        return base.Array_of_float();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Array_of_decimal()\n    {\n        return base.Array_of_decimal();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Array_of_DateTime()\n    {\n        return base.Array_of_DateTime();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Array_of_DateTime_with_milliseconds()\n    {\n        return base.Array_of_DateTime_with_milliseconds();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Array_of_DateTime_with_microseconds()\n    {\n        return base.Array_of_DateTime_with_microseconds();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Array_of_DateOnly()\n    {\n        return base.Array_of_DateOnly();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Array_of_TimeOnly()\n    {\n        return base.Array_of_TimeOnly();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Array_of_TimeOnly_with_milliseconds()\n    {\n        return base.Array_of_TimeOnly_with_milliseconds();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Array_of_TimeOnly_with_microseconds()\n    {\n        return base.Array_of_TimeOnly_with_microseconds();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Array_of_DateTimeOffset()\n    {\n        return base.Array_of_DateTimeOffset();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Array_of_bool()\n    {\n        return base.Array_of_bool();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Array_of_Guid()\n    {\n        return base.Array_of_Guid();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Array_of_byte_array()\n    {\n        return base.Array_of_byte_array();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Array_of_enum()\n\t{\n\t\treturn base.Array_of_enum();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Multidimensional_array_is_not_supported()\n    {\n        return base.Multidimensional_array_is_not_supported();\n    }\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_with_custom_converter()\n\t{\n\t\treturn base.Column_with_custom_converter();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Parameter_with_inferred_value_converter()\n\t{\n\t\treturn base.Parameter_with_inferred_value_converter();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Constant_with_inferred_value_converter()\n\t{\n\t\treturn base.Constant_with_inferred_value_converter();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Inline_collection_in_query_filter()\n\t{\n\t\treturn base.Inline_collection_in_query_filter();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n    public override Task Column_collection_inside_json_owned_entity()\n    {\n        return base.Column_collection_inside_json_owned_entity();\n    }\n\n\t[NotSupportedByProviderTheory]\n#pragma warning disable xUnit1016\n\t[MemberData(nameof(ParameterTranslationModeValues))]\n#pragma warning restore xUnit1016\n\tpublic override Task Parameter_collection_Count_with_column_predicate_with_default_mode(ParameterTranslationMode mode)\n\t{\n\t\treturn base.Parameter_collection_Count_with_column_predicate_with_default_mode(mode);\n\t}\n\n\t[NotSupportedByProviderTheory]\n#pragma warning disable xUnit1016\n\t[MemberData(nameof(ParameterTranslationModeValues))]\n#pragma warning restore xUnit1016\n\tpublic override Task Parameter_collection_Count_with_column_predicate_with_default_mode_EF_Constant(ParameterTranslationMode mode)\n\t{\n\t\treturn base.Parameter_collection_Count_with_column_predicate_with_default_mode_EF_Constant(mode);\n\t}\n\n\t[NotSupportedByProviderTheory]\n#pragma warning disable xUnit1016\n\t[MemberData(nameof(ParameterTranslationModeValues))]\n#pragma warning restore xUnit1016\n\tpublic override Task Parameter_collection_Contains_with_default_mode_EF_Constant(ParameterTranslationMode mode)\n\t{\n\t\treturn base.Parameter_collection_Contains_with_default_mode_EF_Constant(mode);\n\t}\n\n\t[NotSupportedByProviderTheory]\n#pragma warning disable xUnit1016\n\t[MemberData(nameof(ParameterTranslationModeValues))]\n#pragma warning restore xUnit1016\n\tpublic override Task Parameter_collection_Count_with_column_predicate_with_default_mode_EF_Parameter(ParameterTranslationMode mode)\n\t{\n\t\treturn base.Parameter_collection_Count_with_column_predicate_with_default_mode_EF_Parameter(mode);\n\t}\n\n\t[NotSupportedByProviderTheory]\n#pragma warning disable xUnit1016\n\t[MemberData(nameof(ParameterTranslationModeValues))]\n#pragma warning restore xUnit1016\n\tpublic override Task Parameter_collection_Count_with_column_predicate_with_default_mode_EF_MultipleParameters(ParameterTranslationMode mode)\n\t{\n\t\treturn base.Parameter_collection_Count_with_column_predicate_with_default_mode_EF_MultipleParameters(mode);\n\t}\n\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindAggregateOperatorsQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindAggregateOperatorsQueryFbTest : NorthwindAggregateOperatorsQueryRelationalTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindAggregateOperatorsQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multiple_collection_navigation_with_FirstOrDefault_chained(bool async)\n\t{\n\t\treturn base.Multiple_collection_navigation_with_FirstOrDefault_chained(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override async Task Contains_with_local_enumerable_inline(bool async)\n\t{\n\t\tawait Assert.ThrowsAsync<InvalidOperationException>(\n\t\t\tasync () =>\n\t\t\t\tawait base.Contains_with_local_enumerable_inline(async));\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override async Task Contains_with_local_enumerable_inline_closure_mix(bool async)\n\t{\n\t\tawait Assert.ThrowsAsync<InvalidOperationException>(\n\t\t\tasync () =>\n\t\t\t\tawait base.Contains_with_local_enumerable_inline_closure_mix(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Contains_with_local_anonymous_type_array_closure(bool async)\n\t{\n\t\treturn AssertTranslationFailed(() => base.Contains_with_local_anonymous_type_array_closure(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Contains_with_local_tuple_array_closure(bool async)\n\t{\n\t\treturn AssertTranslationFailed(() => base.Contains_with_local_tuple_array_closure(async));\n\t}\n\n\t[Theory(Skip = \"Different math on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Sum_with_division_on_decimal(bool async)\n\t{\n\t\treturn base.Sum_with_division_on_decimal(async);\n\t}\n\n\t[Theory(Skip = \"Different math on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Contains_inside_Average_without_GroupBy(bool async)\n\t{\n\t\treturn base.Contains_inside_Average_without_GroupBy(async);\n\t}\n\n\t[Theory(Skip = \"Different math on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Average_over_max_subquery(bool async)\n\t{\n\t\treturn base.Average_over_max_subquery(async);\n\t}\n\n\t[Theory(Skip = \"Different math on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Average_over_nested_subquery(bool async)\n\t{\n\t\treturn base.Average_over_nested_subquery(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindAsNoTrackingQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindAsNoTrackingQueryFbTest : NorthwindAsNoTrackingQueryTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindAsNoTrackingQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindAsTrackingQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindAsTrackingQueryFbTest : NorthwindAsTrackingQueryTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindAsTrackingQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindChangeTrackingQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestModels.Northwind;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestModels.Northwind;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindChangeTrackingQueryFbTest : NorthwindChangeTrackingQueryTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindChangeTrackingQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\tprotected override NorthwindContext CreateNoTrackingContext()\n\t\t=> new NorthwindFbContext(\n\t\t\tnew DbContextOptionsBuilder(Fixture.CreateOptions())\n\t\t\t\t.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking).Options);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindCompiledQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindCompiledQueryFbTest : NorthwindCompiledQueryTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindCompiledQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override void Query_with_array_parameter()\n\t{\n\t\tbase.Query_with_array_parameter();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Query_with_array_parameter_async()\n\t{\n\t\treturn base.Query_with_array_parameter_async();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindDbFunctionsQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindDbFunctionsQueryFbTest : NorthwindDbFunctionsQueryRelationalTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindDbFunctionsQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\tprotected override string CaseInsensitiveCollation => \"UNICODE_CI\";\n\tprotected override string CaseSensitiveCollation => \"UNICODE\";\n\n\tpublic override Task Like_literal(bool async)\n\t{\n\t\t// fix wrong assumptions on collate\n\t\treturn AssertCount(\n\t\t\tasync,\n\t\t\tss => ss.Set<Microsoft.EntityFrameworkCore.TestModels.Northwind.Customer>(),\n\t\t\tss => ss.Set<Microsoft.EntityFrameworkCore.TestModels.Northwind.Customer>(),\n\t\t\tc => EF.Functions.Like(c.ContactName, \"%M%\"),\n\t\t\tc => c.ContactName.Contains(\"M\"));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindEFPropertyIncludeQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindEFPropertyIncludeQueryFbTest : NorthwindEFPropertyIncludeQueryTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindEFPropertyIncludeQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_OrderBy_empty_list_contains(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Include_collection_OrderBy_empty_list_contains(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_OrderBy_empty_list_does_not_contains(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Include_collection_OrderBy_empty_list_does_not_contains(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_OrderBy_list_contains(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Include_collection_OrderBy_list_contains(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_duplicate_collection_result_operator(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Include_duplicate_collection_result_operator(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_duplicate_collection_result_operator2(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Include_duplicate_collection_result_operator2(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_with_multiple_ordering(bool async)\n\t{\n\t\treturn base.Filtered_include_with_multiple_ordering(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_outer_apply_with_filter(bool async)\n\t{\n\t\treturn base.Include_collection_with_outer_apply_with_filter(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_outer_apply_with_filter_non_equality(bool async)\n\t{\n\t\treturn base.Include_collection_with_outer_apply_with_filter_non_equality(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_cross_apply_with_filter(bool async)\n\t{\n\t\treturn base.Include_collection_with_cross_apply_with_filter(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_last_no_orderby(bool async)\n\t{\n\t\treturn Assert.ThrowsAsync<InvalidOperationException>(() => base.Include_collection_with_last_no_orderby(async));\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Repro9735(bool async)\n\t{\n\t\treturn base.Repro9735(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_Include_reference_GroupBy_Select(bool async)\n\t{\n\t\treturn base.SelectMany_Include_reference_GroupBy_Select(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_Include_collection_GroupBy_Select(bool async)\n\t{\n\t\treturn base.SelectMany_Include_collection_GroupBy_Select(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_Include_reference_GroupBy_Select(bool async)\n\t{\n\t\treturn base.Join_Include_reference_GroupBy_Select(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindFunctionsQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindFunctionsQueryFbTest : NorthwindFunctionsQueryRelationalTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindFunctionsQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindGroupByQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindGroupByQueryFbTest : NorthwindGroupByQueryRelationalTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindGroupByQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Select_uncorrelated_collection_with_groupby_works(bool async)\n\t{\n\t\treturn base.Select_uncorrelated_collection_with_groupby_works(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Select_uncorrelated_collection_with_groupby_multiple_collections_work(bool async)\n\t{\n\t\treturn base.Select_uncorrelated_collection_with_groupby_multiple_collections_work(async);\n\t}\n\n\t[Theory(Skip = \"efcore#19027\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task GroupBy_scalar_subquery(bool async)\n\t{\n\t\treturn base.GroupBy_scalar_subquery(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task AsEnumerable_in_subquery_for_GroupBy(bool async)\n\t{\n\t\treturn base.AsEnumerable_in_subquery_for_GroupBy(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_query_with_group_by_in_subquery5(bool async)\n\t{\n\t\treturn base.Complex_query_with_group_by_in_subquery5(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_query_with_groupBy_in_subquery1(bool async)\n\t{\n\t\treturn base.Complex_query_with_groupBy_in_subquery1(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_query_with_groupBy_in_subquery2(bool async)\n\t{\n\t\treturn base.Complex_query_with_groupBy_in_subquery2(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_query_with_groupBy_in_subquery3(bool async)\n\t{\n\t\treturn base.Complex_query_with_groupBy_in_subquery3(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_query_with_groupBy_in_subquery4(bool async)\n\t{\n\t\treturn base.Complex_query_with_groupBy_in_subquery4(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Select_nested_collection_with_groupby(bool async)\n\t{\n\t\treturn base.Select_nested_collection_with_groupby(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Select_uncorrelated_collection_with_groupby_when_outer_is_distinct(bool async)\n\t{\n\t\treturn base.Select_uncorrelated_collection_with_groupby_when_outer_is_distinct(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override async Task Select_correlated_collection_after_GroupBy_aggregate_when_identifier_changes_to_complex(bool async)\n\t{\n\t\tvar message = (await Assert.ThrowsAsync<InvalidOperationException>(\n\t\t\t() => base.Select_correlated_collection_after_GroupBy_aggregate_when_identifier_changes_to_complex(async))).Message;\n\n\t\tAssert.Equal(RelationalStrings.InsufficientInformationToIdentifyElementOfCollectionJoin, message);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task GroupBy_aggregate_from_multiple_query_in_same_projection(bool async)\n\t{\n\t\treturn base.GroupBy_aggregate_from_multiple_query_in_same_projection(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindIncludeNoTrackingQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing System.Threading.Tasks;\nusing System;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindIncludeNoTrackingQueryFbTest : NorthwindIncludeNoTrackingQueryTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindIncludeNoTrackingQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_with_multiple_ordering(bool async)\n\t{\n\t\treturn base.Filtered_include_with_multiple_ordering(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_outer_apply_with_filter(bool async)\n\t{\n\t\treturn base.Include_collection_with_outer_apply_with_filter(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_outer_apply_with_filter_non_equality(bool async)\n\t{\n\t\treturn base.Include_collection_with_outer_apply_with_filter_non_equality(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_cross_apply_with_filter(bool async)\n\t{\n\t\treturn base.Include_collection_with_cross_apply_with_filter(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_last_no_orderby(bool async)\n\t{\n\t\treturn Assert.ThrowsAsync<InvalidOperationException>(() => base.Include_collection_with_last_no_orderby(async));\n\t}\n\n\t[Theory(Skip = \"Different ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_OrderBy_list_contains(bool async)\n\t{\n\t\treturn base.Include_collection_OrderBy_list_contains(async);\n\t}\n\n\t[Theory(Skip = \"Different ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_multiple_conditional_order_by(bool async)\n\t{\n\t\treturn base.Include_collection_with_multiple_conditional_order_by(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_duplicate_collection_result_operator2(bool async)\n\t{\n\t\treturn base.Include_duplicate_collection_result_operator2(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_take_no_order_by(bool async)\n\t{\n\t\treturn base.Include_collection_take_no_order_by(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_skip_no_order_by(bool async)\n\t{\n\t\treturn base.Include_collection_skip_no_order_by(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_skip_take_no_order_by(bool async)\n\t{\n\t\treturn base.Include_collection_skip_take_no_order_by(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_duplicate_collection_result_operator(bool async)\n\t{\n\t\treturn base.Include_duplicate_collection_result_operator(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Repro9735(bool async)\n\t{\n\t\treturn base.Repro9735(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_OrderBy_empty_list_contains(bool async)\n\t{\n\t\treturn base.Include_collection_OrderBy_empty_list_contains(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_OrderBy_empty_list_does_not_contains(bool async)\n\t{\n\t\treturn base.Include_collection_OrderBy_empty_list_does_not_contains(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_Include_reference_GroupBy_Select(bool async)\n\t{\n\t\treturn base.SelectMany_Include_reference_GroupBy_Select(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_Include_collection_GroupBy_Select(bool async)\n\t{\n\t\treturn base.SelectMany_Include_collection_GroupBy_Select(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_Include_reference_GroupBy_Select(bool async)\n\t{\n\t\treturn base.Join_Include_reference_GroupBy_Select(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindIncludeQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindIncludeQueryFbTest : NorthwindIncludeQueryRelationalTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindIncludeQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_with_multiple_ordering(bool async)\n\t{\n\t\treturn base.Filtered_include_with_multiple_ordering(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_outer_apply_with_filter(bool async)\n\t{\n\t\treturn base.Include_collection_with_outer_apply_with_filter(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_outer_apply_with_filter_non_equality(bool async)\n\t{\n\t\treturn base.Include_collection_with_outer_apply_with_filter_non_equality(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_cross_apply_with_filter(bool async)\n\t{\n\t\treturn base.Include_collection_with_cross_apply_with_filter(async);\n\t}\n\n\t[Theory(Skip = \"Different ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_OrderBy_list_contains(bool async)\n\t{\n\t\treturn base.Include_collection_OrderBy_list_contains(async);\n\t}\n\n\t[Theory(Skip = \"Different ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_multiple_conditional_order_by(bool async)\n\t{\n\t\treturn base.Include_collection_with_multiple_conditional_order_by(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_duplicate_collection_result_operator2(bool async)\n\t{\n\t\treturn base.Include_duplicate_collection_result_operator2(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_take_no_order_by(bool async)\n\t{\n\t\treturn base.Include_collection_take_no_order_by(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_skip_no_order_by(bool async)\n\t{\n\t\treturn base.Include_collection_skip_no_order_by(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_skip_take_no_order_by(bool async)\n\t{\n\t\treturn base.Include_collection_skip_take_no_order_by(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_duplicate_collection_result_operator(bool async)\n\t{\n\t\treturn base.Include_duplicate_collection_result_operator(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Repro9735(bool async)\n\t{\n\t\treturn base.Repro9735(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_OrderBy_empty_list_contains(bool async)\n\t{\n\t\treturn base.Include_collection_OrderBy_empty_list_contains(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_OrderBy_empty_list_does_not_contains(bool async)\n\t{\n\t\treturn base.Include_collection_OrderBy_empty_list_does_not_contains(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_Include_reference_GroupBy_Select(bool async)\n\t{\n\t\treturn base.SelectMany_Include_reference_GroupBy_Select(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_Include_collection_GroupBy_Select(bool async)\n\t{\n\t\treturn base.SelectMany_Include_collection_GroupBy_Select(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_Include_reference_GroupBy_Select(bool async)\n\t{\n\t\treturn base.Join_Include_reference_GroupBy_Select(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindJoinQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindJoinQueryFbTest : NorthwindJoinQueryRelationalTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindJoinQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task GroupJoin_as_final_operator(bool async)\n\t{\n\t\treturn base.GroupJoin_as_final_operator(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task GroupJoin_SelectMany_subquery_with_filter_orderby(bool async)\n\t{\n\t\treturn base.GroupJoin_SelectMany_subquery_with_filter_orderby(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task GroupJoin_SelectMany_subquery_with_filter_orderby_and_DefaultIfEmpty(bool async)\n\t{\n\t\treturn base.GroupJoin_SelectMany_subquery_with_filter_orderby_and_DefaultIfEmpty(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_client_eval(bool async)\n\t{\n\t\treturn base.SelectMany_with_client_eval(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_client_eval_with_collection_shaper(bool async)\n\t{\n\t\treturn base.SelectMany_with_client_eval_with_collection_shaper(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_client_eval_with_collection_shaper_ignored(bool async)\n\t{\n\t\treturn base.SelectMany_with_client_eval_with_collection_shaper_ignored(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_selecting_outer_element(bool async)\n\t{\n\t\treturn base.SelectMany_with_selecting_outer_element(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_selecting_outer_entity(bool async)\n\t{\n\t\treturn base.SelectMany_with_selecting_outer_entity(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_selecting_outer_entity_column_and_inner_column(bool async)\n\t{\n\t\treturn base.SelectMany_with_selecting_outer_entity_column_and_inner_column(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Take_in_collection_projection_with_FirstOrDefault_on_top_level(bool async)\n\t{\n\t\treturn base.Take_in_collection_projection_with_FirstOrDefault_on_top_level(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Unflattened_GroupJoin_composed(bool async)\n\t{\n\t\treturn base.Unflattened_GroupJoin_composed(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Unflattened_GroupJoin_composed_2(bool async)\n\t{\n\t\treturn base.Unflattened_GroupJoin_composed_2(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_local_collection_int_closure_is_cached_correctly(bool async)\n\t{\n\t\treturn base.Join_local_collection_int_closure_is_cached_correctly(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindKeylessEntitiesQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\nusing Xunit.Sdk;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindKeylessEntitiesQueryFbTest : NorthwindKeylessEntitiesQueryRelationalTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindKeylessEntitiesQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task KeylessEntity_by_database_view(bool async)\n\t{\n\t\treturn base.KeylessEntity_by_database_view(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Entity_mapped_to_view_on_right_side_of_join(bool async)\n\t{\n\t\treturn base.Entity_mapped_to_view_on_right_side_of_join(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override async Task KeylessEntity_with_nav_defining_query(bool async)\n\t{\n\t\tawait Assert.ThrowsAsync<EqualException>(() => base.KeylessEntity_with_nav_defining_query(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Count_over_keyless_entity_with_pushdown_empty_projection(bool async)\n\t{\n\t\treturn base.Count_over_keyless_entity_with_pushdown_empty_projection(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindMiscellaneousQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindMiscellaneousQueryFbTest : NorthwindMiscellaneousQueryRelationalTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindMiscellaneousQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Select_DTO_constructor_distinct_with_collection_projection_translated_to_server_with_binding_after_client_eval(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Select_DTO_constructor_distinct_with_collection_projection_translated_to_server_with_binding_after_client_eval(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override async Task Client_code_unknown_method(bool async)\n\t{\n\t\tawait AssertTranslationFailed(() => base.Client_code_unknown_method(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override async Task Client_code_using_instance_in_anonymous_type(bool async)\n\t{\n\t\tawait Assert.ThrowsAsync<InvalidOperationException>(() => base.Client_code_using_instance_in_anonymous_type(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override async Task Client_code_using_instance_in_static_method(bool async)\n\t{\n\t\tawait Assert.ThrowsAsync<InvalidOperationException>(() => base.Client_code_using_instance_in_static_method(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override async Task Client_code_using_instance_method_throws(bool async)\n\t{\n\t\tawait Assert.ThrowsAsync<InvalidOperationException>(() => base.Client_code_using_instance_method_throws(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override async Task Entity_equality_through_subquery_composite_key(bool async)\n\t{\n\t\tawait Assert.ThrowsAsync<InvalidOperationException>(() => base.Entity_equality_through_subquery_composite_key(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override async Task Max_on_empty_sequence_throws(bool async)\n\t{\n\t\tawait Assert.ThrowsAsync<InvalidOperationException>(() => base.Max_on_empty_sequence_throws(async));\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Complex_nested_query_doesnt_try_binding_to_grandparent_when_parent_returns_complex_result(bool async)\n\t{\n\t\treturn base.Complex_nested_query_doesnt_try_binding_to_grandparent_when_parent_returns_complex_result(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_distinct_without_default_identifiers_projecting_columns(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_distinct_without_default_identifiers_projecting_columns(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_distinct_without_default_identifiers_projecting_columns_with_navigation(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_distinct_without_default_identifiers_projecting_columns_with_navigation(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task DefaultIfEmpty_in_subquery_nested_filter_order_comparison(bool async)\n\t{\n\t\treturn base.DefaultIfEmpty_in_subquery_nested_filter_order_comparison(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Select_correlated_subquery_ordered(bool async)\n\t{\n\t\treturn base.Select_correlated_subquery_ordered(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Select_subquery_recursive_trivial(bool async)\n\t{\n\t\treturn base.Select_subquery_recursive_trivial(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_correlated_subquery_hard(bool async)\n\t{\n\t\treturn base.SelectMany_correlated_subquery_hard(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Entity_equality_orderby_subquery(bool async)\n\t{\n\t\treturn base.Entity_equality_orderby_subquery(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Subquery_with_navigation_inside_inline_collection(bool async)\n\t{\n\t\treturn base.Subquery_with_navigation_inside_inline_collection(async);\n\t}\n\n\t[NotSupportedByProviderTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_correlated_with_Select_value_type_and_DefaultIfEmpty_in_selector(bool async)\n\t{\n\t\treturn base.SelectMany_correlated_with_Select_value_type_and_DefaultIfEmpty_in_selector(async);\n\t}\n\n\t[NotSupportedByProviderTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_nanosecond_and_microsecond_component(bool async)\n\t{\n\t\treturn base.Where_nanosecond_and_microsecond_component(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindNavigationsQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindNavigationsQueryFbTest : NorthwindNavigationsQueryRelationalTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindNavigationsQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestModels.Northwind;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindQueryFbFixture<TModelCustomizer> : NorthwindQueryRelationalFixture<TModelCustomizer>\n\twhere TModelCustomizer : ITestModelCustomizer, new()\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\tprotected override Type ContextType => typeof(NorthwindFbContext);\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindQueryFiltersQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindQueryFiltersQueryFbTest : NorthwindQueryFiltersQueryTestBase<NorthwindQueryFbFixture<NorthwindQueryFiltersCustomizer>>\n{\n\tpublic NorthwindQueryFiltersQueryFbTest(NorthwindQueryFbFixture<NorthwindQueryFiltersCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindQueryTaggingQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindQueryTaggingQueryFbTest : NorthwindQueryTaggingQueryTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindQueryTaggingQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindSelectQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindSelectQueryFbTest : NorthwindSelectQueryRelationalTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindSelectQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Member_binding_after_ctor_arguments_fails_with_client_eval(bool async)\n\t{\n\t\treturn AssertTranslationFailed(() => base.Member_binding_after_ctor_arguments_fails_with_client_eval(async));\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Projection_containing_DateTime_subtraction(bool async)\n\t{\n\t\treturn base.Projection_containing_DateTime_subtraction(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_single_element_from_collection_with_OrderBy_over_navigation_Take_and_FirstOrDefault_2(bool async)\n\t{\n\t\treturn base.Project_single_element_from_collection_with_OrderBy_over_navigation_Take_and_FirstOrDefault_2(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Select_nested_collection_deep(bool async)\n\t{\n\t\treturn base.Select_nested_collection_deep(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_correlated_with_outer_1(bool async)\n\t{\n\t\treturn base.SelectMany_correlated_with_outer_1(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_correlated_with_outer_2(bool async)\n\t{\n\t\treturn base.SelectMany_correlated_with_outer_1(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_correlated_with_outer_3(bool async)\n\t{\n\t\treturn base.SelectMany_correlated_with_outer_1(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_correlated_with_outer_4(bool async)\n\t{\n\t\treturn base.SelectMany_correlated_with_outer_1(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_correlated_with_outer_5(bool async)\n\t{\n\t\treturn base.SelectMany_correlated_with_outer_1(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_correlated_with_outer_6(bool async)\n\t{\n\t\treturn base.SelectMany_correlated_with_outer_1(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_correlated_with_outer_7(bool async)\n\t{\n\t\treturn base.SelectMany_correlated_with_outer_1(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_collection_being_correlated_subquery_which_references_inner_and_outer_entity(bool async)\n\t{\n\t\treturn base.SelectMany_with_collection_being_correlated_subquery_which_references_inner_and_outer_entity(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_whose_selector_references_outer_source(bool async)\n\t{\n\t\treturn base.SelectMany_whose_selector_references_outer_source(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Collection_projection_selecting_outer_element_followed_by_take(bool async)\n\t{\n\t\treturn base.Collection_projection_selecting_outer_element_followed_by_take(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_after_distinct_not_containing_original_identifier(bool async)\n\t{\n\t\treturn base.Correlated_collection_after_distinct_not_containing_original_identifier(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_after_distinct_with_complex_projection_containing_original_identifier(bool async)\n\t{\n\t\treturn base.Correlated_collection_after_distinct_with_complex_projection_containing_original_identifier(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_after_groupby_with_complex_projection_containing_original_identifier(bool async)\n\t{\n\t\treturn base.Correlated_collection_after_groupby_with_complex_projection_containing_original_identifier(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Projecting_after_navigation_and_distinct(bool async)\n\t{\n\t\treturn base.Projecting_after_navigation_and_distinct(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Select_nested_collection_deep_distinct_no_identifiers(bool async)\n\t{\n\t\treturn base.Select_nested_collection_deep_distinct_no_identifiers(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Take_on_correlated_collection_in_first(bool async)\n\t{\n\t\treturn base.Take_on_correlated_collection_in_first(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Take_on_top_level_and_on_collection_projection_with_outer_apply(bool async)\n\t{\n\t\treturn base.Take_on_top_level_and_on_collection_projection_with_outer_apply(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_after_groupby_with_complex_projection_not_containing_original_identifier(bool async)\n\t{\n\t\treturn base.Correlated_collection_after_groupby_with_complex_projection_not_containing_original_identifier(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Reverse_in_projection_subquery(bool async)\n\t{\n\t\treturn base.Reverse_in_projection_subquery(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Reverse_in_projection_subquery_single_result(bool async)\n\t{\n\t\treturn base.Reverse_in_projection_subquery_single_result(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Reverse_in_SelectMany_with_Take(bool async)\n\t{\n\t\treturn base.Reverse_in_SelectMany_with_Take(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Set_operation_in_pending_collection(bool async)\n\t{\n\t\treturn base.Set_operation_in_pending_collection(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override async Task Correlated_collection_after_distinct_with_complex_projection_not_containing_original_identifier(bool async)\n\t{\n\t\tAssert.Equal(\n\t\t\tRelationalStrings.InsufficientInformationToIdentifyElementOfCollectionJoin,\n\t\t\t(await Assert.ThrowsAsync<InvalidOperationException>(\n\t\t\t\t() => base.Correlated_collection_after_distinct_with_complex_projection_not_containing_original_identifier(async)))\n\t\t\t.Message);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_with_collection_being_correlated_subquery_which_references_non_mapped_properties_from_inner_and_outer_entity(bool async)\n\t{\n\t\treturn AssertUnableToTranslateEFProperty(\n\t\t\t() => base\n\t\t\t\t.SelectMany_with_collection_being_correlated_subquery_which_references_non_mapped_properties_from_inner_and_outer_entity(\n\t\t\t\t\tasync));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindSetOperationsQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindSetOperationsQueryFbTest : NorthwindSetOperationsQueryRelationalTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindSetOperationsQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Union_Select_scalar(bool async)\n\t{\n\t\treturn base.Union_Select_scalar(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Union_inside_Concat(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan5())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Union_inside_Concat(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Select_Except_reference_projection(bool async)\n\t{\n\t\treturn base.Select_Except_reference_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Except(bool async)\n\t{\n\t\treturn base.Except(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Except_nested(bool async)\n\t{\n\t\treturn base.Except_nested(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Except_non_entity(bool async)\n\t{\n\t\treturn base.Except_non_entity(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Except_simple_followed_by_projecting_constant(bool async)\n\t{\n\t\treturn base.Except_simple_followed_by_projecting_constant(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Intersect(bool async)\n\t{\n\t\treturn base.Intersect(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Intersect_nested(bool async)\n\t{\n\t\treturn base.Intersect_nested(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Intersect_non_entity(bool async)\n\t{\n\t\treturn base.Intersect_non_entity(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Union_Intersect(bool async)\n\t{\n\t\treturn base.Union_Intersect(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Except_on_distinct(bool async)\n\t{\n\t\treturn base.Except_on_distinct(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Intersect_on_distinct(bool async)\n\t{\n\t\treturn base.Intersect_on_distinct(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Client_eval_Union_FirstOrDefault(bool async)\n\t{\n\t\treturn Assert.ThrowsAsync<InvalidOperationException>(() => base.Client_eval_Union_FirstOrDefault(async));\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Except_nested2(bool async)\n\t{\n\t\treturn base.Except_nested2(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing System.Threading.Tasks;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindSplitIncludeNoTrackingQueryFbTest : NorthwindSplitIncludeNoTrackingQueryTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindSplitIncludeNoTrackingQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Repro9735(bool async)\n\t{\n\t\treturn base.Repro9735(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_SelectMany_GroupBy_Select(bool async)\n\t{\n\t\treturn base.Include_collection_SelectMany_GroupBy_Select(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_OrderBy_list_contains(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Include_collection_OrderBy_list_contains(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_with_multiple_ordering(bool async)\n\t{\n\t\treturn base.Filtered_include_with_multiple_ordering(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_cross_apply_with_filter(bool async)\n\t{\n\t\treturn base.Include_collection_with_cross_apply_with_filter(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_outer_apply_with_filter_non_equality(bool async)\n\t{\n\t\treturn base.Include_collection_with_outer_apply_with_filter_non_equality(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_outer_apply_with_filter(bool async)\n\t{\n\t\treturn base.Include_collection_with_outer_apply_with_filter(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_Include_reference_GroupBy_Select(bool async)\n\t{\n\t\treturn base.Join_Include_reference_GroupBy_Select(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_Include_collection_GroupBy_Select(bool async)\n\t{\n\t\treturn base.SelectMany_Include_collection_GroupBy_Select(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_Include_reference_GroupBy_Select(bool async)\n\t{\n\t\treturn base.SelectMany_Include_reference_GroupBy_Select(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindSplitIncludeQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindSplitIncludeQueryFbTest : NorthwindSplitIncludeQueryTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindSplitIncludeQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Repro9735(bool async)\n\t{\n\t\treturn base.Repro9735(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_SelectMany_GroupBy_Select(bool async)\n\t{\n\t\treturn base.Include_collection_SelectMany_GroupBy_Select(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_OrderBy_list_contains(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Include_collection_OrderBy_list_contains(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_with_multiple_ordering(bool async)\n\t{\n\t\treturn base.Filtered_include_with_multiple_ordering(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_cross_apply_with_filter(bool async)\n\t{\n\t\treturn base.Include_collection_with_cross_apply_with_filter(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_outer_apply_with_filter_non_equality(bool async)\n\t{\n\t\treturn base.Include_collection_with_outer_apply_with_filter_non_equality(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_outer_apply_with_filter(bool async)\n\t{\n\t\treturn base.Include_collection_with_outer_apply_with_filter(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_Include_reference_GroupBy_Select(bool async)\n\t{\n\t\treturn base.Join_Include_reference_GroupBy_Select(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_Include_collection_GroupBy_Select(bool async)\n\t{\n\t\treturn base.SelectMany_Include_collection_GroupBy_Select(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_Include_reference_GroupBy_Select(bool async)\n\t{\n\t\treturn base.SelectMany_Include_reference_GroupBy_Select(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindSqlQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Data.Common;\nusing FirebirdSql.Data.FirebirdClient;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindSqlQueryFbTest : NorthwindSqlQueryTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindSqlQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\tprotected override DbParameter CreateDbParameter(string name, object value)\n\t\t=> new FbParameter { ParameterName = name, Value = value };\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindStringIncludeQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindStringIncludeQueryFbTest : NorthwindStringIncludeQueryTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindStringIncludeQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Repro9735(bool async)\n\t{\n\t\treturn base.Repro9735(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_OrderBy_empty_list_contains(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Include_collection_OrderBy_empty_list_contains(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_OrderBy_empty_list_does_not_contains(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Include_collection_OrderBy_empty_list_does_not_contains(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_OrderBy_list_contains(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Include_collection_OrderBy_list_contains(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_duplicate_collection_result_operator(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Include_duplicate_collection_result_operator(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_duplicate_collection_result_operator2(bool async)\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn Task.CompletedTask;\n\t\treturn base.Include_duplicate_collection_result_operator2(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_cross_apply_with_filter(bool async)\n\t{\n\t\treturn base.Include_collection_with_cross_apply_with_filter(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_outer_apply_with_filter_non_equality(bool async)\n\t{\n\t\treturn base.Include_collection_with_outer_apply_with_filter_non_equality(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Include_collection_with_outer_apply_with_filter(bool async)\n\t{\n\t\treturn base.Include_collection_with_outer_apply_with_filter(async);\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override async Task Include_collection_with_last_no_orderby(bool async)\n\t{\n\t\tAssert.Equal(\n\t\t\tRelationalStrings.LastUsedWithoutOrderBy(nameof(Enumerable.Last)),\n\t\t\t(await Assert.ThrowsAsync<InvalidOperationException>(\n\t\t\t\t() => base.Include_collection_with_last_no_orderby(async))).Message);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Join_Include_reference_GroupBy_Select(bool async)\n\t{\n\t\treturn base.Join_Include_reference_GroupBy_Select(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_Include_collection_GroupBy_Select(bool async)\n\t{\n\t\treturn base.SelectMany_Include_collection_GroupBy_Select(async);\n\t}\n\n\t[LongExecutionTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_Include_reference_GroupBy_Select(bool async)\n\t{\n\t\treturn base.SelectMany_Include_reference_GroupBy_Select(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NorthwindWhereQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NorthwindWhereQueryFbTest : NorthwindWhereQueryRelationalTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic NorthwindWhereQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_compare_constructed_equal(bool async)\n\t{\n\t\treturn AssertTranslationFailed(() => base.Where_compare_constructed_equal(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_compare_constructed_multi_value_equal(bool async)\n\t{\n\t\treturn AssertTranslationFailed(() => base.Where_compare_constructed_multi_value_equal(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_compare_constructed_multi_value_not_equal(bool async)\n\t{\n\t\treturn AssertTranslationFailed(() => base.Where_compare_constructed_multi_value_not_equal(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_compare_tuple_constructed_equal(bool async)\n\t{\n\t\treturn AssertTranslationFailed(() => base.Where_compare_tuple_constructed_equal(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_compare_tuple_constructed_multi_value_equal(bool async)\n\t{\n\t\treturn AssertTranslationFailed(() => base.Where_compare_tuple_constructed_multi_value_equal(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_compare_tuple_constructed_multi_value_not_equal(bool async)\n\t{\n\t\treturn AssertTranslationFailed(() => base.Where_compare_tuple_constructed_multi_value_not_equal(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_compare_tuple_create_constructed_equal(bool async)\n\t{\n\t\treturn AssertTranslationFailed(() => base.Where_compare_tuple_create_constructed_equal(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_compare_tuple_create_constructed_multi_value_equal(bool async)\n\t{\n\t\treturn AssertTranslationFailed(() => base.Where_compare_tuple_create_constructed_multi_value_equal(async));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_compare_tuple_create_constructed_multi_value_not_equal(bool async)\n\t{\n\t\treturn AssertTranslationFailed(() => base.Where_compare_tuple_create_constructed_multi_value_not_equal(async));\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NullKeysFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NullKeysFbTest : NullKeysTestBase<NullKeysFbTest.NullKeysFbFixture>\n{\n\tpublic NullKeysFbTest(NullKeysFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\tpublic class NullKeysFbFixture : NullKeysFixtureBase\n\t{\n\t\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NullSemanticsQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NullSemanticsQueryFbFixture : NullSemanticsQueryFixtureBase\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/NullSemanticsQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestModels.NullSemanticsModel;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class NullSemanticsQueryFbTest : NullSemanticsQueryTestBase<NullSemanticsQueryFbFixture>\n{\n\tpublic NullSemanticsQueryFbTest(NullSemanticsQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\tprotected override NullSemanticsContext CreateContext(bool useRelationalNulls = false)\n\t{\n\t\tvar options = new DbContextOptionsBuilder(Fixture.CreateOptions());\n\t\tif (useRelationalNulls)\n\t\t{\n\t\t\tnew FbDbContextOptionsBuilder(options).UseRelationalNulls();\n\t\t}\n\t\tvar context = new NullSemanticsContext(options.Options);\n\t\tcontext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;\n\t\treturn context;\n\t}\n\n\t[Theory(Skip = \"efcore#34906\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task CaseOpWhen_predicate(bool async)\n\t{\n\t\treturn base.CaseOpWhen_predicate(async);\n\t}\n\n\t[Theory(Skip = \"efcore#34906\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task CaseOpWhen_projection(bool async)\n\t{\n\t\treturn base.CaseOpWhen_projection(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/OperatorsProceduralFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class OperatorsProceduralFbTest(NonSharedFixture fixture) : OperatorsProceduralQueryTestBase(fixture)\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/OperatorsQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Microsoft.Extensions.DependencyInjection;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class OperatorsQueryFbTest(NonSharedFixture fixture) : OperatorsQueryTestBase(fixture)\n{\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Concat_and_json_scalar(bool async)\n\t{\n\t\treturn base.Concat_and_json_scalar(async);\n\t}\n\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/OptionalDependentQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class OptionalDependentQueryFbFixture : OptionalDependentQueryFixtureBase\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/OptionalDependentQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class OptionalDependentQueryFbTest : OptionalDependentQueryTestBase<OptionalDependentQueryFbFixture>\n{\n\tpublic OptionalDependentQueryFbTest(OptionalDependentQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Basic_projection_entity_with_all_optional(bool async)\n\t{\n\t\treturn base.Basic_projection_entity_with_all_optional(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Basic_projection_entity_with_some_required(bool async)\n\t{\n\t\treturn base.Basic_projection_entity_with_some_required(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filter_nested_optional_dependent_with_all_optional_compared_to_not_null(bool async)\n\t{\n\t\treturn base.Filter_nested_optional_dependent_with_all_optional_compared_to_not_null(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filter_nested_optional_dependent_with_all_optional_compared_to_null(bool async)\n\t{\n\t\treturn base.Filter_nested_optional_dependent_with_all_optional_compared_to_null(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filter_nested_optional_dependent_with_some_required_compared_to_not_null(bool async)\n\t{\n\t\treturn base.Filter_nested_optional_dependent_with_some_required_compared_to_not_null(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filter_nested_optional_dependent_with_some_required_compared_to_null(bool async)\n\t{\n\t\treturn base.Filter_nested_optional_dependent_with_some_required_compared_to_null(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filter_optional_dependent_with_all_optional_compared_to_not_null(bool async)\n\t{\n\t\treturn base.Filter_optional_dependent_with_all_optional_compared_to_not_null(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filter_optional_dependent_with_all_optional_compared_to_null(bool async)\n\t{\n\t\treturn base.Filter_optional_dependent_with_all_optional_compared_to_null(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filter_optional_dependent_with_some_required_compared_to_not_null(bool async)\n\t{\n\t\treturn base.Filter_optional_dependent_with_some_required_compared_to_not_null(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filter_optional_dependent_with_some_required_compared_to_null(bool async)\n\t{\n\t\treturn base.Filter_optional_dependent_with_some_required_compared_to_null(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/OwnedEntityQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class OwnedEntityQueryFbTest(NonSharedFixture fixture) : OwnedEntityQueryRelationalTestBase(fixture)\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multiple_owned_reference_mapped_to_own_table_containing_owned_collection_in_split_query(bool async)\n\t{\n\t\treturn base.Multiple_owned_reference_mapped_to_own_table_containing_owned_collection_in_split_query(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/OwnedQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class OwnedQueryFbTest : OwnedQueryRelationalTestBase<OwnedQueryFbTest.OwnedQueryFbFixture>\n{\n\tpublic OwnedQueryFbTest(OwnedQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Navigation_rewrite_on_owned_collection(bool isAsync) => base.Navigation_rewrite_on_owned_collection(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Navigation_rewrite_on_owned_reference_followed_by_regular_entity(bool isAsync) => base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference(bool isAsync) => base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference_and_scalar(bool isAsync) => base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference_and_scalar(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference_in_predicate_and_projection(bool isAsync) => base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_another_reference_in_predicate_and_projection(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_collection(bool isAsync) => base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_collection(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_collection_count(bool isAsync) => base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_collection_count(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_property(bool isAsync) => base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_property(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task No_ignored_include_warning_when_implicit_load(bool isAsync) => base.No_ignored_include_warning_when_implicit_load(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Query_for_base_type_loads_all_owned_navs(bool isAsync) => base.Query_for_base_type_loads_all_owned_navs(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Query_for_branch_type_loads_all_owned_navs(bool isAsync) => base.Query_for_branch_type_loads_all_owned_navs(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Query_for_leaf_type_loads_all_owned_navs(bool isAsync) => base.Query_for_leaf_type_loads_all_owned_navs(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Query_when_subquery(bool isAsync) => base.Query_when_subquery(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Query_with_OfType_eagerly_loads_correct_owned_navigations(bool isAsync) => base.Query_with_OfType_eagerly_loads_correct_owned_navigations(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Query_with_owned_entity_equality_method(bool isAsync) => base.Query_with_owned_entity_equality_method(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Query_with_owned_entity_equality_object_method(bool isAsync) => base.Query_with_owned_entity_equality_object_method(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Query_with_owned_entity_equality_operator(bool isAsync) => base.Query_with_owned_entity_equality_operator(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_on_owned_reference_followed_by_regular_entity_and_collection(bool isAsync) => base.SelectMany_on_owned_reference_followed_by_regular_entity_and_collection(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_on_owned_reference_with_entity_in_between_ending_in_owned_collection(bool isAsync) => base.SelectMany_on_owned_reference_with_entity_in_between_ending_in_owned_collection(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Navigation_rewrite_on_owned_collection_with_composition(bool isAsync) => base.Navigation_rewrite_on_owned_collection_with_composition(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filter_owned_entity_chained_with_regular_entity_followed_by_projecting_owned_collection(bool isAsync) => base.Filter_owned_entity_chained_with_regular_entity_followed_by_projecting_owned_collection(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Navigation_rewrite_on_owned_collection_with_composition_complex(bool isAsync) => base.Navigation_rewrite_on_owned_collection_with_composition_complex(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Navigation_rewrite_on_owned_reference_followed_by_regular_entity_filter(bool isAsync) => base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity_filter(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Navigation_rewrite_on_owned_reference_projecting_entity(bool isAsync) => base.Navigation_rewrite_on_owned_reference_projecting_entity(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Navigation_rewrite_on_owned_reference_projecting_scalar(bool isAsync) => base.Navigation_rewrite_on_owned_reference_projecting_scalar(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Preserve_includes_when_applying_skip_take_after_anonymous_type_select(bool isAsync) => base.Preserve_includes_when_applying_skip_take_after_anonymous_type_select(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_multiple_owned_navigations(bool isAsync) => base.Project_multiple_owned_navigations(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_multiple_owned_navigations_with_expansion_on_owned_collections(bool isAsync) => base.Project_multiple_owned_navigations_with_expansion_on_owned_collections(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Query_for_branch_type_loads_all_owned_navs_tracking(bool isAsync) => base.Query_for_branch_type_loads_all_owned_navs_tracking(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Query_loads_reference_nav_automatically_in_projection(bool isAsync) => base.Query_loads_reference_nav_automatically_in_projection(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_on_owned_collection(bool isAsync) => base.SelectMany_on_owned_collection(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Set_throws_for_owned_type(bool isAsync) => base.Set_throws_for_owned_type(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Throw_for_owned_entities_without_owner_in_tracking_query(bool isAsync) => base.Throw_for_owned_entities_without_owner_in_tracking_query(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Unmapped_property_projection_loads_owned_navigations(bool isAsync) => base.Unmapped_property_projection_loads_owned_navigations(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Client_method_take_loads_owned_navigations_variation_2(bool isAsync) => base.Client_method_take_loads_owned_navigations_variation_2(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Trying_to_access_non_existent_indexer_property_throws_meaningful_exception(bool isAsync) => base.Trying_to_access_non_existent_indexer_property_throws_meaningful_exception(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Client_method_skip_loads_owned_navigations(bool isAsync) => base.Client_method_skip_loads_owned_navigations(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Indexer_property_is_pushdown_into_subquery(bool isAsync) => base.Indexer_property_is_pushdown_into_subquery(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Query_with_OfType_eagerly_loads_correct_owned_navigations_split(bool isAsync) => base.Query_with_OfType_eagerly_loads_correct_owned_navigations_split(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_OrderBy_owned_indexer_properties(bool isAsync) => base.Can_OrderBy_owned_indexer_properties(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_query_on_indexer_property_when_property_name_from_closure(bool isAsync) => base.Can_query_on_indexer_property_when_property_name_from_closure(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_group_by_converted_indexer_property(bool isAsync) => base.Can_group_by_converted_indexer_property(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_collection_navigation_AsEnumerable_Count(bool isAsync) => base.Where_collection_navigation_AsEnumerable_Count(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_project_owned_indexer_properties_converted(bool isAsync) => base.Can_project_owned_indexer_properties_converted(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_group_by_owned_indexer_property(bool isAsync) => base.Can_group_by_owned_indexer_property(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Project_multiple_owned_navigations_split(bool isAsync) => base.Project_multiple_owned_navigations_split(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_project_owned_indexer_properties(bool isAsync) => base.Can_project_owned_indexer_properties(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task NoTracking_Include_with_cycles_throws(bool isAsync) => base.NoTracking_Include_with_cycles_throws(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Projecting_indexer_property_ignores_include(bool isAsync) => base.Projecting_indexer_property_ignores_include(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task GroupBy_with_multiple_aggregates_on_owned_navigation_properties(bool isAsync) => base.GroupBy_with_multiple_aggregates_on_owned_navigation_properties(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Using_from_sql_on_owner_generates_join_with_table_for_owned_shared_dependents(bool isAsync) => base.Using_from_sql_on_owner_generates_join_with_table_for_owned_shared_dependents(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Query_when_subquery_split(bool isAsync) => base.Query_when_subquery_split(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_group_by_converted_owned_indexer_property(bool isAsync) => base.Can_group_by_converted_owned_indexer_property(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_project_indexer_properties_converted(bool isAsync) => base.Can_project_indexer_properties_converted(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Query_for_base_type_loads_all_owned_navs_split(bool isAsync) => base.Query_for_base_type_loads_all_owned_navs_split(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_query_on_indexer_properties(bool isAsync) => base.Can_query_on_indexer_properties(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Non_nullable_property_through_optional_navigation(bool isAsync) => base.Non_nullable_property_through_optional_navigation(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_collection_navigation_ToArray_Count(bool isAsync) => base.Where_collection_navigation_ToArray_Count(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_OrderBy_indexer_properties_converted(bool isAsync) => base.Can_OrderBy_indexer_properties_converted(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_join_on_indexer_property_on_query(bool isAsync) => base.Can_join_on_indexer_property_on_query(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_collection_navigation_ToList_Count_member(bool isAsync) => base.Where_collection_navigation_ToList_Count_member(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_query_on_owned_indexer_properties(bool isAsync) => base.Can_query_on_owned_indexer_properties(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Projecting_indexer_property_ignores_include_converted(bool isAsync) => base.Projecting_indexer_property_ignores_include_converted(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Client_method_skip_loads_owned_navigations_variation_2(bool isAsync) => base.Client_method_skip_loads_owned_navigations_variation_2(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Client_method_skip_take_loads_owned_navigations_variation_2(bool isAsync) => base.Client_method_skip_take_loads_owned_navigations_variation_2(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Projecting_collection_correlated_with_keyless_entity_after_navigation_works_using_parent_identifiers(bool isAsync) => base.Projecting_collection_correlated_with_keyless_entity_after_navigation_works_using_parent_identifiers(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_query_on_indexer_properties_split(bool isAsync) => base.Can_query_on_indexer_properties_split(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_collection_split(bool isAsync) => base.Navigation_rewrite_on_owned_reference_followed_by_regular_entity_and_collection_split(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_collection_navigation_ToArray_Length_member(bool isAsync) => base.Where_collection_navigation_ToArray_Length_member(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_OrderBy_indexer_properties(bool isAsync) => base.Can_OrderBy_indexer_properties(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Where_owned_collection_navigation_ToList_Count(bool isAsync) => base.Where_owned_collection_navigation_ToList_Count(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Query_on_collection_entry_works_for_owned_collection(bool isAsync) => base.Query_on_collection_entry_works_for_owned_collection(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Client_method_take_loads_owned_navigations(bool isAsync) => base.Client_method_take_loads_owned_navigations(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_group_by_indexer_property(bool isAsync) => base.Can_group_by_indexer_property(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Query_for_branch_type_loads_all_owned_navs_split(bool isAsync) => base.Query_for_branch_type_loads_all_owned_navs_split(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_query_indexer_property_on_owned_collection(bool isAsync) => base.Can_query_indexer_property_on_owned_collection(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Client_method_skip_take_loads_owned_navigations(bool isAsync) => base.Client_method_skip_take_loads_owned_navigations(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Unmapped_property_projection_loads_owned_navigations_split(bool isAsync) => base.Unmapped_property_projection_loads_owned_navigations_split(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_project_indexer_properties(bool isAsync) => base.Can_project_indexer_properties(isAsync);\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Ordering_by_identifying_projection(bool isAsync) => base.Ordering_by_identifying_projection(isAsync);\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filter_on_indexer_using_closure(bool async)\n\t{\n\t\treturn base.Filter_on_indexer_using_closure(async);\n\t}\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filter_on_indexer_using_function_argument(bool async)\n\t{\n\t\treturn base.Filter_on_indexer_using_function_argument(async);\n\t}\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[InlineData(false, false)]\n\t[InlineData(false, true)]\n\t[InlineData(true, false)]\n\t[InlineData(true, true)]\n\tpublic override Task NoTracking_Include_with_cycles_does_not_throw_when_performing_identity_resolution(bool async, bool useAsTracking)\n\t{\n\t\treturn base.NoTracking_Include_with_cycles_does_not_throw_when_performing_identity_resolution(async, useAsTracking);\n\t}\n\n\t[HasDataInTheSameTransactionAsDDLTheory]\n\t[InlineData(false, false)]\n\t[InlineData(false, true)]\n\t[InlineData(true, false)]\n\t[InlineData(true, true)]\n\tpublic override Task Owned_entity_without_owner_does_not_throw_for_identity_resolution(bool async, bool useAsTracking)\n\t{\n\t\treturn base.Owned_entity_without_owner_does_not_throw_for_identity_resolution(async, useAsTracking);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Can_query_owner_with_different_owned_types_having_same_property_name_in_hierarchy(bool async)\n\t{\n\t\treturn base.Can_query_owner_with_different_owned_types_having_same_property_name_in_hierarchy(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task GroupBy_aggregate_on_owned_navigation_in_aggregate_selector(bool async)\n\t{\n\t\treturn base.GroupBy_aggregate_on_owned_navigation_in_aggregate_selector(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Left_join_on_entity_with_owned_navigations(bool async)\n\t{\n\t\treturn base.Left_join_on_entity_with_owned_navigations(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Left_join_on_entity_with_owned_navigations_complex(bool async)\n\t{\n\t\treturn base.Left_join_on_entity_with_owned_navigations_complex(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Simple_query_entity_with_owned_collection(bool async)\n\t{\n\t\treturn base.Simple_query_entity_with_owned_collection(async);\n\t}\n\n\tpublic class OwnedQueryFbFixture : RelationalOwnedQueryFixture\n\t{\n\t\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/PrimitiveCollectionsQueryFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class PrimitiveCollectionsQueryFbTest : PrimitiveCollectionsQueryRelationalTestBase<PrimitiveCollectionsQueryFbTest.PrimitiveCollectionsQueryFbFixture>\n{\n\tpublic PrimitiveCollectionsQueryFbTest(PrimitiveCollectionsQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[ConditionalFact]\n\tpublic virtual async Task Json_representation_of_bool_array()\n\t{\n\t\tawait using var context = Fixture.CreateContext();\n\n\t\tAssert.Equal(\n\t\t\t\"[true,false]\",\n\t\t\tawait context.Database.SqlQuery<string>($@\"SELECT \"\"Bools\"\" AS \"\"Value\"\" FROM \"\"PrimitiveCollectionsEntity\"\" WHERE \"\"Id\"\" = 1\")\n\t\t\t\t.SingleAsync());\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override void Parameter_collection_in_subquery_and_Convert_as_compiled_query()\n\t{\n\t\tbase.Parameter_collection_in_subquery_and_Convert_as_compiled_query();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query()\n\t{\n\t\treturn base.Parameter_collection_in_subquery_Union_another_parameter_collection_as_compiled_query();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Any()\n\t{\n\t\treturn base.Column_collection_Any();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Contains_over_subquery()\n\t{\n\t\treturn base.Column_collection_Contains_over_subquery();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Count_method()\n\t{\n\t\treturn base.Column_collection_Count_method();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Count_with_predicate()\n\t{\n\t\treturn base.Column_collection_Count_with_predicate();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Distinct()\n\t{\n\t\treturn base.Column_collection_Distinct();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_ElementAt()\n\t{\n\t\treturn base.Column_collection_ElementAt();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_First()\n\t{\n\t\treturn base.Column_collection_First();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_FirstOrDefault()\n\t{\n\t\treturn base.Column_collection_FirstOrDefault();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_in_subquery_Union_parameter_collection()\n\t{\n\t\treturn base.Column_collection_in_subquery_Union_parameter_collection();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_index_beyond_end()\n\t{\n\t\treturn base.Column_collection_index_beyond_end();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_index_datetime()\n\t{\n\t\treturn base.Column_collection_index_datetime();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_index_int()\n\t{\n\t\treturn base.Column_collection_index_int();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_index_string()\n\t{\n\t\treturn base.Column_collection_index_string();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Intersect_inline_collection()\n\t{\n\t\treturn base.Column_collection_Intersect_inline_collection();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Join_parameter_collection()\n\t{\n\t\treturn base.Column_collection_Join_parameter_collection();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Length()\n\t{\n\t\treturn base.Column_collection_Length();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_of_bools_Contains()\n\t{\n\t\treturn base.Column_collection_of_bools_Contains();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_of_ints_Contains()\n\t{\n\t\treturn base.Column_collection_of_ints_Contains();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_of_nullable_ints_Contains()\n\t{\n\t\treturn base.Column_collection_of_nullable_ints_Contains();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_of_nullable_ints_Contains_null()\n\t{\n\t\treturn base.Column_collection_of_nullable_ints_Contains_null();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_of_nullable_strings_contains_null()\n\t{\n\t\treturn base.Column_collection_of_nullable_strings_contains_null();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_of_strings_contains_null()\n\t{\n\t\treturn base.Column_collection_of_strings_contains_null();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_OrderByDescending_ElementAt()\n\t{\n\t\treturn base.Column_collection_OrderByDescending_ElementAt();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_SelectMany()\n\t{\n\t\treturn base.Column_collection_SelectMany();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_SelectMany_with_filter()\n\t{\n\t\treturn base.Column_collection_SelectMany_with_filter();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_SelectMany_with_Select_to_anonymous_type()\n\t{\n\t\treturn base.Column_collection_SelectMany_with_Select_to_anonymous_type();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Single()\n\t{\n\t\treturn base.Column_collection_Single();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_SingleOrDefault()\n\t{\n\t\treturn base.Column_collection_SingleOrDefault();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Skip()\n\t{\n\t\treturn base.Column_collection_Skip();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Skip_Take()\n\t{\n\t\treturn base.Column_collection_Skip_Take();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Take()\n\t{\n\t\treturn base.Column_collection_Take();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Union_parameter_collection()\n\t{\n\t\treturn base.Column_collection_Union_parameter_collection();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Where_Count()\n\t{\n\t\treturn base.Column_collection_Where_Count();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Where_ElementAt()\n\t{\n\t\treturn base.Column_collection_Where_ElementAt();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Where_Skip()\n\t{\n\t\treturn base.Column_collection_Where_Skip();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Where_Skip_Take()\n\t{\n\t\treturn base.Column_collection_Where_Skip_Take();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Where_Take()\n\t{\n\t\treturn base.Column_collection_Where_Take();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Column_collection_Where_Union()\n\t{\n\t\treturn base.Column_collection_Where_Union();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Inline_collection_Count_with_column_predicate_with_EF_Parameter()\n\t{\n\t\treturn base.Inline_collection_Count_with_column_predicate_with_EF_Parameter();\n\t}\n\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Inline_collection_Count_with_one_value()\n\t{\n\t\treturn base.Inline_collection_Count_with_one_value();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Inline_collection_Count_with_two_values()\n\t{\n\t\treturn base.Inline_collection_Count_with_two_values();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Inline_collection_Count_with_three_values()\n\t{\n\t\treturn base.Inline_collection_Count_with_three_values();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Inline_collection_Except_column_collection()\n\t{\n\t\treturn base.Inline_collection_Except_column_collection();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Inline_collection_index_Column()\n\t{\n\t\treturn base.Inline_collection_index_Column();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Inline_collection_index_Column_with_EF_Constant()\n\t{\n\t\treturn base.Inline_collection_index_Column_with_EF_Constant();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Inline_collection_Join_ordered_column_collection()\n\t{\n\t\treturn base.Inline_collection_Join_ordered_column_collection();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Inline_collection_List_value_index_Column()\n\t{\n\t\treturn base.Inline_collection_List_value_index_Column();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Inline_collection_of_nullable_value_type_Max()\n\t{\n\t\treturn base.Inline_collection_of_nullable_value_type_Max();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Inline_collection_of_nullable_value_type_Min()\n\t{\n\t\treturn base.Inline_collection_of_nullable_value_type_Min();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Inline_collection_of_nullable_value_type_with_null_Max()\n\t{\n\t\treturn base.Inline_collection_of_nullable_value_type_with_null_Max();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Inline_collection_of_nullable_value_type_with_null_Min()\n\t{\n\t\treturn base.Inline_collection_of_nullable_value_type_with_null_Min();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Inline_collection_value_index_Column()\n\t{\n\t\treturn base.Inline_collection_value_index_Column();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Inline_collection_with_single_parameter_element_Count()\n\t{\n\t\treturn base.Inline_collection_with_single_parameter_element_Count();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Non_nullable_reference_column_collection_index_equals_nullable_column()\n\t{\n\t\treturn base.Non_nullable_reference_column_collection_index_equals_nullable_column();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Nullable_reference_column_collection_index_equals_nullable_column()\n\t{\n\t\treturn base.Nullable_reference_column_collection_index_equals_nullable_column();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Parameter_collection_Concat_column_collection()\n\t{\n\t\treturn base.Parameter_collection_Concat_column_collection();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Parameter_collection_Count()\n\t{\n\t\treturn base.Parameter_collection_Count();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Parameter_collection_Count_with_column_predicate_with_EF_Constant()\n\t{\n\t\treturn base.Parameter_collection_Count_with_column_predicate_with_EF_Constant();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Parameter_collection_ImmutableArray_of_ints_Contains_int()\n\t{\n\t\treturn base.Parameter_collection_ImmutableArray_of_ints_Contains_int();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Parameter_collection_in_subquery_Count_as_compiled_query()\n\t{\n\t\treturn base.Parameter_collection_in_subquery_Count_as_compiled_query();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Parameter_collection_in_subquery_Union_column_collection()\n\t{\n\t\treturn base.Parameter_collection_in_subquery_Union_column_collection();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Parameter_collection_in_subquery_Union_column_collection_as_compiled_query()\n\t{\n\t\treturn base.Parameter_collection_in_subquery_Union_column_collection_as_compiled_query();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Parameter_collection_in_subquery_Union_column_collection_nested()\n\t{\n\t\treturn base.Parameter_collection_in_subquery_Union_column_collection_nested();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Parameter_collection_index_Column_equal_Column()\n\t{\n\t\treturn base.Parameter_collection_index_Column_equal_Column();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Parameter_collection_index_Column_equal_constant()\n\t{\n\t\treturn base.Parameter_collection_index_Column_equal_constant();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Parameter_collection_Where_with_EF_Constant_Where_Any()\n\t{\n\t\treturn base.Parameter_collection_Where_with_EF_Constant_Where_Any();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Project_collection_of_datetimes_filtered()\n\t{\n\t\treturn base.Project_collection_of_datetimes_filtered();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Project_collection_of_ints_ordered()\n\t{\n\t\treturn base.Project_collection_of_ints_ordered();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Project_collection_of_nullable_ints_with_paging2()\n\t{\n\t\treturn base.Project_collection_of_nullable_ints_with_paging2();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Project_empty_collection_of_nullables_and_collection_only_containing_nulls()\n\t{\n\t\treturn base.Project_empty_collection_of_nullables_and_collection_only_containing_nulls();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Project_inline_collection_with_Union()\n\t{\n\t\treturn base.Project_inline_collection_with_Union();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Project_multiple_collections()\n\t{\n\t\treturn base.Project_multiple_collections();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Values_of_enum_casted_to_underlying_value()\n\t{\n\t\treturn base.Values_of_enum_casted_to_underlying_value();\n\t}\n\n\tpublic class PrimitiveCollectionsQueryFbFixture : PrimitiveCollectionsQueryFixtureBase, ITestSqlLoggerFactory\n\t{\n\t\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\t\tpublic TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/QueryFilterFuncletizationFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class QueryFilterFuncletizationFbTest : QueryFilterFuncletizationTestBase<QueryFilterFuncletizationFbTest.QueryFilterFuncletizationFbFixture>\n{\n\tpublic QueryFilterFuncletizationFbTest(QueryFilterFuncletizationFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Fact]\n\tpublic override void DbContext_complex_expression_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.DbContext_complex_expression_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void DbContext_field_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.DbContext_field_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void DbContext_list_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.DbContext_list_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void DbContext_method_call_chain_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.DbContext_method_call_chain_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void DbContext_method_call_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.DbContext_method_call_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void DbContext_property_based_filter_does_not_short_circuit()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.DbContext_property_based_filter_does_not_short_circuit();\n\t}\n\n\t[Fact]\n\tpublic override void DbContext_property_chain_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.DbContext_property_chain_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void DbContext_property_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.DbContext_property_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void DbContext_property_method_call_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.DbContext_property_method_call_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void DbContext_property_parameter_does_not_clash_with_closure_parameter_name()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.DbContext_property_parameter_does_not_clash_with_closure_parameter_name();\n\t}\n\n\t[Fact]\n\tpublic override void EntityTypeConfiguration_DbContext_field_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.EntityTypeConfiguration_DbContext_field_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void EntityTypeConfiguration_DbContext_method_call_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.EntityTypeConfiguration_DbContext_method_call_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void EntityTypeConfiguration_DbContext_property_chain_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.EntityTypeConfiguration_DbContext_property_chain_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void EntityTypeConfiguration_DbContext_property_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.EntityTypeConfiguration_DbContext_property_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void Extension_method_DbContext_field_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.Extension_method_DbContext_field_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void Extension_method_DbContext_property_chain_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.Extension_method_DbContext_property_chain_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void Local_method_DbContext_field_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.Local_method_DbContext_field_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void Local_static_method_DbContext_property_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.Local_static_method_DbContext_property_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void Local_variable_from_OnModelCreating_can_throw_exception()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.Local_variable_from_OnModelCreating_can_throw_exception();\n\t}\n\n\t[Fact]\n\tpublic override void Local_variable_from_OnModelCreating_is_inlined()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.Local_variable_from_OnModelCreating_is_inlined();\n\t}\n\n\t[Fact]\n\tpublic override void Method_parameter_is_inlined()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.Method_parameter_is_inlined();\n\t}\n\n\t[Fact]\n\tpublic override void Remote_method_DbContext_property_method_call_is_parameterized()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.Remote_method_DbContext_property_method_call_is_parameterized();\n\t}\n\n\t[Fact]\n\tpublic override void Static_member_from_dbContext_is_inlined()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.Static_member_from_dbContext_is_inlined();\n\t}\n\n\t[Fact]\n\tpublic override void Static_member_from_non_dbContext_is_inlined()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.Static_member_from_non_dbContext_is_inlined();\n\t}\n\n\t[Fact]\n\tpublic override void Using_Context_set_method_in_filter_works()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.Using_Context_set_method_in_filter_works();\n\t}\n\n\t[Fact]\n\tpublic override void Using_DbSet_in_filter_works()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.Using_DbSet_in_filter_works();\n\t}\n\n\t[Fact]\n\tpublic override void Using_multiple_context_in_filter_parametrize_only_current_context()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.Using_multiple_context_in_filter_parametrize_only_current_context();\n\t}\n\n\t[Fact]\n\tpublic override void Using_multiple_entities_with_filters_reuses_parameters()\n\t{\n\t\tvar fbTestStore = (FbTestStore)Fixture.TestStore;\n\t\tif (fbTestStore.ServerLessThan4())\n\t\t\treturn;\n\t\tbase.Using_multiple_entities_with_filters_reuses_parameters();\n\t}\n\n\tpublic class QueryFilterFuncletizationFbFixture : QueryFilterFuncletizationRelationalFixture\n\t{\n\t\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\t\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t\t{\n\t\t\tbase.OnModelCreating(modelBuilder, context);\n\t\t\tModelHelpers.SimpleTableNames(modelBuilder);\n\t\t\tModelHelpers.SetPrimaryKeyGeneration(modelBuilder, FbValueGenerationStrategy.IdentityColumn);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/QueryNoClientEvalFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class QueryNoClientEvalFbTest : QueryNoClientEvalTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic QueryNoClientEvalFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/SharedTypeQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class SharedTypeQueryFbTest(NonSharedFixture fixture) : SharedTypeQueryRelationalTestBase(fixture)\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/SqlExecutorFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data.Common;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.FirebirdClient;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class SqlExecutorFbTest : SqlExecutorTestBase<NorthwindQueryFbFixture<SqlExecutorModelCustomizer>>\n{\n\tpublic SqlExecutorFbTest(NorthwindQueryFbFixture<SqlExecutorModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\tprotected override DbParameter CreateDbParameter(string name, object value)\n\t\t=> new FbParameter { ParameterName = name, Value = value };\n\n\tprotected override string TenMostExpensiveProductsSproc => throw new NotSupportedException();\n\tprotected override string CustomerOrderHistorySproc => throw new NotSupportedException();\n\tprotected override string CustomerOrderHistoryWithGeneratedParameterSproc => throw new NotSupportedException();\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task Executes_stored_procedure(bool async)\n\t{\n\t\treturn base.Executes_stored_procedure(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task Executes_stored_procedure_with_generated_parameter(bool async)\n\t{\n\t\treturn base.Executes_stored_procedure_with_generated_parameter(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[InlineData(false)]\n\t[InlineData(true)]\n\tpublic override Task Executes_stored_procedure_with_parameter(bool async)\n\t{\n\t\treturn base.Executes_stored_procedure_with_parameter(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/SqlQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Data.Common;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.FirebirdClient;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class SqlQueryFbTest : SqlQueryTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic SqlQueryFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t// Uses INTERSECT\n\t[NotSupportedByProviderTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Multiple_occurrences_of_SqlQuery_with_db_parameter_adds_two_parameters(bool async)\n\t{\n\t\treturn base.Multiple_occurrences_of_SqlQuery_with_db_parameter_adds_two_parameters(async);\n\t}\n\n\t[Theory(Skip = \"Provider does the casting.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Bad_data_error_handling_invalid_cast(bool async)\n\t{\n\t\treturn base.Bad_data_error_handling_invalid_cast(async);\n\t}\n\n\t[Theory(Skip = \"Provider does the casting.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Bad_data_error_handling_invalid_cast_key(bool async)\n\t{\n\t\treturn base.Bad_data_error_handling_invalid_cast_key(async);\n\t}\n\n\t[Theory(Skip = \"Provider does the casting.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Bad_data_error_handling_invalid_cast_no_tracking(bool async)\n\t{\n\t\treturn base.Bad_data_error_handling_invalid_cast_no_tracking(async);\n\t}\n\n\t[Theory(Skip = \"Provider does the casting.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Bad_data_error_handling_invalid_cast_projection(bool async)\n\t{\n\t\treturn base.Bad_data_error_handling_invalid_cast_projection(async);\n\t}\n\n\t[Theory(Skip = \"Provider does the casting.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SqlQueryRaw_queryable_simple_projection_composed(bool async)\n\t{\n\t\treturn base.SqlQueryRaw_queryable_simple_projection_composed(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SqlQueryRaw_with_dbParameter_mixed_in_subquery(bool async)\n\t{\n\t\treturn base.SqlQueryRaw_with_dbParameter_mixed_in_subquery(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SqlQueryRaw_queryable_multiple_composed_with_parameters_and_closure_parameters(bool async)\n\t{\n\t\treturn base.SqlQueryRaw_queryable_multiple_composed_with_parameters_and_closure_parameters(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SqlQueryRaw_queryable_multiple_composed_with_closure_parameters(bool async)\n\t{\n\t\treturn base.SqlQueryRaw_queryable_multiple_composed_with_closure_parameters(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SqlQueryRaw_queryable_multiple_composed(bool async)\n\t{\n\t\treturn base.SqlQueryRaw_queryable_multiple_composed(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SqlQueryRaw_in_subquery_with_positional_dbParameter_without_name(bool async)\n\t{\n\t\treturn base.SqlQueryRaw_in_subquery_with_positional_dbParameter_without_name(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SqlQueryRaw_in_subquery_with_positional_dbParameter_with_name(bool async)\n\t{\n\t\treturn base.SqlQueryRaw_in_subquery_with_positional_dbParameter_with_name(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SqlQueryRaw_in_subquery_with_dbParameter(bool async)\n\t{\n\t\treturn base.SqlQueryRaw_in_subquery_with_dbParameter(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SqlQueryRaw_does_not_parameterize_interpolated_string(bool async)\n\t{\n\t\treturn base.SqlQueryRaw_does_not_parameterize_interpolated_string(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SqlQueryRaw_queryable_with_null_parameter(bool async)\n\t{\n\t\treturn base.SqlQueryRaw_queryable_with_null_parameter(async);\n\t}\n\n\t[DoesNotHaveTheDataTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SqlQuery_queryable_multiple_composed_with_parameters_and_closure_parameters_interpolated(bool async)\n\t{\n\t\treturn base.SqlQuery_queryable_multiple_composed_with_parameters_and_closure_parameters_interpolated(async);\n\t}\n\n\t[Theory(Skip = \"Firebird matches the casing exactly. Frankly the test is weird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SqlQueryRaw_queryable_simple_different_cased_columns_and_not_enough_columns_throws(bool async)\n\t{\n\t\treturn base.SqlQueryRaw_queryable_simple_different_cased_columns_and_not_enough_columns_throws(async);\n\t}\n\n\tprotected override DbParameter CreateDbParameter(string name, object value)\n\t\t=> new FbParameter { ParameterName = name, Value = value };\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPCFiltersInheritanceQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPCFiltersInheritanceQueryFbFixture : TPCInheritanceQueryFbFixture\n{\n    public override bool EnableFilters => true;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPCFiltersInheritanceQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing Microsoft.EntityFrameworkCore.Query;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPCFiltersInheritanceQueryFbTest : TPCFiltersInheritanceQueryTestBase<TPCFiltersInheritanceQueryFbFixture>\n{\n\tpublic TPCFiltersInheritanceQueryFbTest(TPCFiltersInheritanceQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPCGearsOfWarQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPCGearsOfWarQueryFbFixture : TPCGearsOfWarQueryRelationalFixture\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t{\n\t\tbase.OnModelCreating(modelBuilder, context);\n\t\tModelHelpers.SetStringLengths(modelBuilder);\n\n\t\tmodelBuilder.Entity<City>().Property(g => g.Location).HasColumnType(\"varchar(100)\");\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPCGearsOfWarQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Linq;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPCGearsOfWarQueryFbTest : TPCGearsOfWarQueryRelationalTestBase<TPCGearsOfWarQueryFbFixture>\n{\n\tpublic TPCGearsOfWarQueryFbTest(TPCGearsOfWarQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task ToString_boolean_property_non_nullable(bool async)\n\t{\n\t\treturn AssertQuery(\n\t\t\tasync,\n\t\t\tss => ss.Set<Weapon>().Select(w => w.IsAutomatic.ToString()));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task ToString_boolean_property_nullable(bool async)\n\t{\n\t\treturn AssertQuery(\n\t\t\tasync,\n\t\t\tss => ss.Set<LocustHorde>().Select(lh => lh.Eradicated.ToString()));\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Group_by_on_StartsWith_with_null_parameter_as_argument(bool async)\n\t{\n\t\treturn base.Group_by_on_StartsWith_with_null_parameter_as_argument(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_after_distinct_3_levels(bool async)\n\t{\n\t\treturn base.Correlated_collection_after_distinct_3_levels(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(bool async)\n\t{\n\t\treturn base.Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_distinct_not_projecting_identifier_column(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_distinct_not_projecting_identifier_column(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_distinct_projecting_identifier_column(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_distinct_projecting_identifier_column(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_groupby_not_projecting_identifier_column_but_only_grouping_key_in_final_projection(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_groupby_not_projecting_identifier_column_but_only_grouping_key_in_final_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection_multiple_grouping_keys(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection_multiple_grouping_keys(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_groupby_with_complex_grouping_key_not_projecting_identifier_column_with_group_aggregate_in_final_projection(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_groupby_with_complex_grouping_key_not_projecting_identifier_column_with_group_aggregate_in_final_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_inner_collection_references_element_two_levels_up(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_inner_collection_references_element_two_levels_up(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collections_inner_subquery_predicate_references_outer_qsre(bool async)\n\t{\n\t\treturn base.Correlated_collections_inner_subquery_predicate_references_outer_qsre(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collections_inner_subquery_selector_references_outer_qsre(bool async)\n\t{\n\t\treturn base.Correlated_collections_inner_subquery_selector_references_outer_qsre(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(bool async)\n\t{\n\t\treturn base.Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(bool async)\n\t{\n\t\treturn base.Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collections_with_Distinct(bool async)\n\t{\n\t\treturn base.Correlated_collections_with_Distinct(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task DateTimeOffset_Contains_Less_than_Greater_than(bool async)\n\t{\n\t\treturn base.DateTimeOffset_Contains_Less_than_Greater_than(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task DateTimeOffset_Date_returns_datetime(bool async)\n\t{\n\t\treturn base.DateTimeOffset_Date_returns_datetime(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task DateTimeOffsetNow_minus_timespan(bool async)\n\t{\n\t\treturn base.DateTimeOffsetNow_minus_timespan(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Outer_parameter_in_group_join_with_DefaultIfEmpty(bool async)\n\t{\n\t\treturn base.Outer_parameter_in_group_join_with_DefaultIfEmpty(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Outer_parameter_in_join_key(bool async)\n\t{\n\t\treturn base.Outer_parameter_in_join_key(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Outer_parameter_in_join_key_inner_and_outer(bool async)\n\t{\n\t\treturn base.Outer_parameter_in_join_key_inner_and_outer(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(bool async)\n\t{\n\t\treturn base.SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(bool async)\n\t{\n\t\treturn base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(bool async)\n\t{\n\t\treturn base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(bool async)\n\t{\n\t\treturn base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(bool async)\n\t{\n\t\treturn base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Subquery_inside_Take_argument(bool async)\n\t{\n\t\treturn base.Subquery_inside_Take_argument(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Non_string_concat_uses_appropriate_type_mapping(bool async)\n\t{\n\t\treturn base.Non_string_concat_uses_appropriate_type_mapping(async);\n\t}\n\n\t[NotSupportedByProviderTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Take_without_orderby_followed_by_orderBy_is_pushed_down1(bool async)\n\t{\n\t\treturn base.Take_without_orderby_followed_by_orderBy_is_pushed_down1(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Take_without_orderby_followed_by_orderBy_is_pushed_down2(bool async)\n\t{\n\t\treturn base.Take_without_orderby_followed_by_orderBy_is_pushed_down2(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPCInheritanceQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPCInheritanceQueryFbFixture : TPCInheritanceQueryFbFixtureBase\n{\n\tpublic override bool UseGeneratedKeys => true;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPCInheritanceQueryFbFixtureBase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic abstract class TPCInheritanceQueryFbFixtureBase : TPCInheritanceQueryFixture\n{\n    protected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPCInheritanceQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPCInheritanceQueryFbTest : TPCInheritanceQueryFbTestBase<TPCInheritanceQueryFbFixture>\n{\n    public TPCInheritanceQueryFbTest(TPCInheritanceQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n        : base(fixture, testOutputHelper)\n    { }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPCInheritanceQueryFbTestBase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic abstract class TPCInheritanceQueryFbTestBase<TFixture> : TPCInheritanceQueryTestBase<TFixture>\n    where TFixture : TPCInheritanceQueryFbFixtureBase, new()\n{\n\tprotected TPCInheritanceQueryFbTestBase(TFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture, testOutputHelper)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPCInheritanceQueryHiLoFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPCInheritanceQueryHiLoFbFixture : TPCInheritanceQueryFbFixtureBase\n{\n\tprotected override string StoreName => \"TPCHiLoInheritanceTest\";\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t{\n\t\tmodelBuilder.UseHiLo();\n\n\t\tbase.OnModelCreating(modelBuilder, context);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPCInheritanceQueryHiLoFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPCInheritanceQueryHiLoFbTest : TPCInheritanceQueryFbTestBase<TPCInheritanceQueryHiLoFbFixture>\n{\n\tpublic TPCInheritanceQueryHiLoFbTest(TPCInheritanceQueryHiLoFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture, testOutputHelper)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPCManyToManyNoTrackingQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPCManyToManyNoTrackingQueryFbTest : TPCManyToManyNoTrackingQueryRelationalTestBase<TPCManyToManyQueryFbFixture>\n{\n\tpublic TPCManyToManyNoTrackingQueryFbTest(TPCManyToManyQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(bool async)\n\t{\n\t\treturn base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_navigation_order_by_single_or_default(bool async)\n\t{\n\t\treturn base.Skip_navigation_order_by_single_or_default(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where_EF_Property(bool async)\n\t{\n\t\treturn base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where_EF_Property(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPCManyToManyQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPCManyToManyQueryFbFixture : TPCManyToManyQueryRelationalFixture\n{\n    protected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t{\n\t\tbase.OnModelCreating(modelBuilder, context);\n\t\tModelHelpers.ShortenMM(modelBuilder);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPCManyToManyQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPCManyToManyQueryFbTest : TPCManyToManyQueryRelationalTestBase<TPCManyToManyQueryFbFixture>\n{\n\tpublic TPCManyToManyQueryFbTest(TPCManyToManyQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(bool async)\n\t{\n\t\treturn base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_navigation_order_by_single_or_default(bool async)\n\t{\n\t\treturn base.Skip_navigation_order_by_single_or_default(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where_EF_Property(bool async)\n\t{\n\t\treturn base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where_EF_Property(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPCRelationshipsQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPCRelationshipsQueryFbTest : TPCRelationshipsQueryTestBase<TPCRelationshipsQueryFbTest.TPCRelationshipsQueryFbFixture>\n{\n\tpublic TPCRelationshipsQueryFbTest(TPCRelationshipsQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\tpublic class TPCRelationshipsQueryFbFixture : TPCRelationshipsQueryRelationalFixture\n\t{\n\t\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPHFiltersInheritanceQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPHFiltersInheritanceQueryFbFixture : TPHInheritanceQueryFbFixture\n{\n\tpublic override bool EnableFilters => true;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPHFiltersInheritanceQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPHFiltersInheritanceQueryFbTest : FiltersInheritanceQueryTestBase<TPHFiltersInheritanceQueryFbFixture>\n{\n\tpublic TPHFiltersInheritanceQueryFbTest(TPHFiltersInheritanceQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPHInheritanceQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestModels.InheritanceModel;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPHInheritanceQueryFbFixture : TPHInheritanceQueryFixture\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t{\n\t\tbase.OnModelCreating(modelBuilder, context);\n\t\tmodelBuilder.Entity<AnimalQuery>().ToSqlQuery(@\"SELECT * FROM \"\"Animals\"\"\");\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPHInheritanceQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPHInheritanceQueryFbTest : TPHInheritanceQueryTestBase<TPHInheritanceQueryFbFixture>\n{\n\tpublic TPHInheritanceQueryFbTest(TPHInheritanceQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture, testOutputHelper)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPTFiltersInheritanceQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.TestModels.InheritanceModel;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPTFiltersInheritanceQueryFbFixture : TPTInheritanceQueryFbFixture\n{\n\tpublic override bool EnableFilters => true;\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t{\n\t\tbase.OnModelCreating(modelBuilder, context);\n\t\tmodelBuilder.Entity<Drink>().Property(x => x.Id).UseSequenceTrigger();\n\t\tmodelBuilder.Entity<Animal>().Property(x => x.Id).UseSequenceTrigger();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPTFiltersInheritanceQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPTFiltersInheritanceQueryFbTest : TPTFiltersInheritanceQueryTestBase<TPTFiltersInheritanceQueryFbFixture>\n{\n\tpublic TPTFiltersInheritanceQueryFbTest(TPTFiltersInheritanceQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPTGearsOfWarQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPTGearsOfWarQueryFbFixture : TPTGearsOfWarQueryRelationalFixture\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t{\n\t\tbase.OnModelCreating(modelBuilder, context);\n\t\tModelHelpers.SetStringLengths(modelBuilder);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPTGearsOfWarQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Linq;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPTGearsOfWarQueryFbTest : TPTGearsOfWarQueryRelationalTestBase<TPTGearsOfWarQueryFbFixture>\n{\n\tpublic TPTGearsOfWarQueryFbTest(TPTGearsOfWarQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task ToString_boolean_property_non_nullable(bool async)\n\t{\n\t\treturn AssertQuery(\n\t\t\tasync,\n\t\t\tss => ss.Set<Weapon>().Select(w => w.IsAutomatic.ToString()));\n\t}\n\n\t[Theory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task ToString_boolean_property_nullable(bool async)\n\t{\n\t\treturn AssertQuery(\n\t\t\tasync,\n\t\t\tss => ss.Set<LocustHorde>().Select(lh => lh.Eradicated.ToString()));\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Group_by_on_StartsWith_with_null_parameter_as_argument(bool async)\n\t{\n\t\treturn base.Group_by_on_StartsWith_with_null_parameter_as_argument(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collections_inner_subquery_predicate_references_outer_qsre(bool async)\n\t{\n\t\treturn base.Correlated_collections_inner_subquery_predicate_references_outer_qsre(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collections_inner_subquery_selector_references_outer_qsre(bool async)\n\t{\n\t\treturn base.Correlated_collections_inner_subquery_selector_references_outer_qsre(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(bool async)\n\t{\n\t\treturn base.Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(bool async)\n\t{\n\t\treturn base.Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task DateTimeOffset_Contains_Less_than_Greater_than(bool isAsync)\n\t{\n\t\treturn base.DateTimeOffset_Contains_Less_than_Greater_than(isAsync);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task DateTimeOffset_Date_returns_datetime(bool async)\n\t{\n\t\treturn base.DateTimeOffset_Date_returns_datetime(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Outer_parameter_in_group_join_with_DefaultIfEmpty(bool async)\n\t{\n\t\treturn base.Outer_parameter_in_group_join_with_DefaultIfEmpty(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Outer_parameter_in_join_key(bool async)\n\t{\n\t\treturn base.Outer_parameter_in_join_key(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Outer_parameter_in_join_key_inner_and_outer(bool async)\n\t{\n\t\treturn base.Outer_parameter_in_join_key_inner_and_outer(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(bool async)\n\t{\n\t\treturn base.SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(bool async)\n\t{\n\t\treturn base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(bool async)\n\t{\n\t\treturn base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(bool async)\n\t{\n\t\treturn base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(bool async)\n\t{\n\t\treturn base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Take_without_orderby_followed_by_orderBy_is_pushed_down1(bool async)\n\t{\n\t\treturn base.Take_without_orderby_followed_by_orderBy_is_pushed_down1(async);\n\t}\n\n\t[Theory(Skip = \"Different implicit ordering on Firebird.\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Take_without_orderby_followed_by_orderBy_is_pushed_down2(bool async)\n\t{\n\t\treturn base.Take_without_orderby_followed_by_orderBy_is_pushed_down2(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_after_distinct_3_levels(bool async)\n\t{\n\t\treturn base.Correlated_collection_after_distinct_3_levels(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(bool async)\n\t{\n\t\treturn base.Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_distinct_not_projecting_identifier_column(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_distinct_not_projecting_identifier_column(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_distinct_projecting_identifier_column(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_distinct_projecting_identifier_column(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_groupby_not_projecting_identifier_column_but_only_grouping_key_in_final_projection(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_groupby_not_projecting_identifier_column_but_only_grouping_key_in_final_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection_multiple_grouping_keys(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection_multiple_grouping_keys(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_inner_collection_references_element_two_levels_up(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_inner_collection_references_element_two_levels_up(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collections_with_Distinct(bool async)\n\t{\n\t\treturn base.Correlated_collections_with_Distinct(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Correlated_collection_with_groupby_with_complex_grouping_key_not_projecting_identifier_column_with_group_aggregate_in_final_projection(bool async)\n\t{\n\t\treturn base.Correlated_collection_with_groupby_with_complex_grouping_key_not_projecting_identifier_column_with_group_aggregate_in_final_projection(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task DateTimeOffsetNow_minus_timespan(bool async)\n\t{\n\t\treturn base.DateTimeOffsetNow_minus_timespan(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Subquery_inside_Take_argument(bool async)\n\t{\n\t\treturn base.Subquery_inside_Take_argument(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Non_string_concat_uses_appropriate_type_mapping(bool async)\n\t{\n\t\treturn base.Non_string_concat_uses_appropriate_type_mapping(async);\n\t}\n\n\t[Theory(Skip = \"NETProvider#1008\")]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task String_concat_with_null_conditional_argument(bool async)\n\t{\n\t\treturn base.String_concat_with_null_conditional_argument(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPTInheritanceQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestModels.InheritanceModel;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPTInheritanceQueryFbFixture : TPTInheritanceQueryFixture\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t{\n\t\tbase.OnModelCreating(modelBuilder, context);\n\t\tmodelBuilder.Entity<Drink>().Property(x => x.Id).UseSequenceTrigger();\n\t\tmodelBuilder.Entity<Animal>().Property(x => x.Id).UseSequenceTrigger();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPTInheritanceQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPTInheritanceQueryFbTest : TPTInheritanceQueryTestBase<TPTInheritanceQueryFbFixture>\n{\n\tpublic TPTInheritanceQueryFbTest(TPTInheritanceQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture, testOutputHelper)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPTManyToManyNoTrackingQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPTManyToManyNoTrackingQueryFbTest : TPTManyToManyNoTrackingQueryRelationalTestBase<TPTManyToManyQueryFbFixture>\n{\n\tpublic TPTManyToManyNoTrackingQueryFbTest(TPTManyToManyQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(bool async)\n\t{\n\t\treturn base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_navigation_order_by_single_or_default(bool async)\n\t{\n\t\treturn base.Skip_navigation_order_by_single_or_default(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where_EF_Property(bool async)\n\t{\n\t\treturn base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where_EF_Property(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPTManyToManyQueryFbFixture.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPTManyToManyQueryFbFixture : TPTManyToManyQueryRelationalFixture\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t{\n\t\tbase.OnModelCreating(modelBuilder, context);\n\t\tModelHelpers.ShortenMM(modelBuilder);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPTManyToManyQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPTManyToManyQueryFbTest : TPTManyToManyQueryRelationalTestBase<TPTManyToManyQueryFbFixture>\n{\n\tpublic TPTManyToManyQueryFbTest(TPTManyToManyQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(bool async)\n\t{\n\t\treturn base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Skip_navigation_order_by_single_or_default(bool async)\n\t{\n\t\treturn base.Skip_navigation_order_by_single_or_default(async);\n\t}\n\n\t[NotSupportedOnFirebirdTheory]\n\t[MemberData(nameof(IsAsyncData))]\n\tpublic override Task Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where_EF_Property(bool async)\n\t{\n\t\treturn base.Filtered_include_skip_navigation_order_by_skip_take_then_include_skip_navigation_where_EF_Property(async);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/TPTRelationshipsQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class TPTRelationshipsQueryFbTest : TPTRelationshipsQueryTestBase<TPTRelationshipsQueryFbTest.TPTRelationshipsQueryFbFixture>\n{\n\tpublic TPTRelationshipsQueryFbTest(TPTRelationshipsQueryFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\tpublic class TPTRelationshipsQueryFbFixture : TPTRelationshipsQueryRelationalFixture\n\t{\n\t\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/ToSqlQueryFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Linq;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class ToSqlQueryFbTest(NonSharedFixture fixture) : ToSqlQueryTestBase(fixture)\n{\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\tpublic override async Task Entity_type_with_navigation_mapped_to_SqlQuery(bool async)\n\t{\n\t\tvar contextFactory = await InitializeAsync<Context27629>(\n\t\t\tseed: async c =>\n\t\t\t{\n\t\t\t\tvar author = new Author { Name = \"Toast\", Posts = { new Post { Title = \"Sausages of the world!\" } } };\n\t\t\t\tc.Add(author);\n\t\t\t\tawait c.SaveChangesAsync();\n\n\t\t\t\tvar postStat = new PostStat { Count = 10, Author = author };\n\t\t\t\tauthor.PostStat = postStat;\n\t\t\t\tc.Add(postStat);\n\t\t\t\tawait c.SaveChangesAsync();\n\t\t\t});\n\n\t\tusing var context = contextFactory.CreateContext();\n\n\t\tvar authors = await\n\t\t\t(from o in context.Authors\n\t\t\t select new { Author = o, PostCount = o.PostStat!.Count }).ToListAsync();\n\n\t\tAssert.Single(authors);\n\t\tAssert.Equal(\"Toast\", authors[0].Author.Name);\n\t\tAssert.Equal(10, authors[0].PostCount);\n\t}\n\n\tprotected new class Context27629 : DbContext\n\t{\n\t\tpublic Context27629(DbContextOptions options)\n\t\t\t: base(options)\n\t\t{ }\n\n\t\tpublic DbSet<Author> Authors\n\t\t\t=> Set<Author>();\n\n\t\tpublic DbSet<Post> Posts\n\t\t\t=> Set<Post>();\n\n\t\tpublic DbSet<PostStat> PostStats\n\t\t\t=> Set<PostStat>();\n\n\t\tprotected override void OnModelCreating(ModelBuilder modelBuilder)\n\t\t{\n\t\t\tmodelBuilder.Entity<Author>(\n\t\t\t\tbuilder =>\n\t\t\t\t{\n\t\t\t\t\tbuilder.ToTable(\"Authors\");\n\t\t\t\t\tbuilder.Property(o => o.Name).HasMaxLength(50);\n\t\t\t\t});\n\n\t\t\tmodelBuilder.Entity<Post>(\n\t\t\t\tbuilder =>\n\t\t\t\t{\n\t\t\t\t\tbuilder.ToTable(\"Posts\");\n\t\t\t\t\tbuilder.Property(o => o.Title).HasMaxLength(50);\n\t\t\t\t\tbuilder.Property(o => o.Content).HasMaxLength(500);\n\n\t\t\t\t\tbuilder\n\t\t\t\t\t\t.HasOne(o => o.Author)\n\t\t\t\t\t\t.WithMany(o => o.Posts)\n\t\t\t\t\t\t.HasForeignKey(o => o.AuthorId)\n\t\t\t\t\t\t.OnDelete(DeleteBehavior.ClientCascade);\n\t\t\t\t});\n\n\t\t\tmodelBuilder.Entity<PostStat>(\n\t\t\t\tbuilder =>\n\t\t\t\t{\n\t\t\t\t\tbuilder\n\t\t\t\t\t\t.ToSqlQuery(\"SELECT * FROM \\\"PostStats\\\"\")\n\t\t\t\t\t\t.HasKey(o => o.AuthorId);\n\n\t\t\t\t\tbuilder\n\t\t\t\t\t\t.HasOne(o => o.Author)\n\t\t\t\t\t\t.WithOne().HasForeignKey<PostStat>(o => o.AuthorId)\n\t\t\t\t\t\t.OnDelete(DeleteBehavior.ClientCascade);\n\t\t\t\t});\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/BasicTypesQueryFbFixture.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.Translations;\nusing Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations;\n\npublic class BasicTypesQueryFbFixture : BasicTypesQueryFixtureBase, ITestSqlLoggerFactory\n{\n\tprivate BasicTypesData _expectedData;\n\n\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\tpublic TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory;\n\n\tprotected override Task SeedAsync(BasicTypesContext context)\n\t{\n\t\t_expectedData ??= CreateExpectedData();\n\t\tcontext.AddRange(_expectedData.BasicTypesEntities);\n\t\tcontext.AddRange(_expectedData.NullableBasicTypesEntities);\n\t\treturn context.SaveChangesAsync();\n\t}\n\n\tpublic override ISetSource GetExpectedData()\n\t\t=> _expectedData ??= CreateExpectedData();\n\n\tprivate BasicTypesData CreateExpectedData()\n\t{\n\t\tvar expectedData = (BasicTypesData)base.GetExpectedData();\n\t\tforeach (var entry in expectedData.BasicTypesEntities)\n\t\t{\n\t\t\t// For all Temporal types Firebird supports up to 1/10ths of a millisecond precision\n\t\t\tentry.DateTime = RoundToFirebirdPrecision(entry.DateTime);\n\t\t\tentry.TimeOnly = RoundToFirebirdPrecision(entry.TimeOnly);\n\t\t\tentry.TimeSpan = RoundToFirebirdPrecision(entry.TimeSpan);\n\t\t\tentry.DateTimeOffset = RoundToFirebirdPrecision(entry.DateTimeOffset);\n\t\t}\n\n\t\t// Do the same for the nullable counterparts\n\t\tforeach (var entry in expectedData.NullableBasicTypesEntities)\n\t\t{\n\t\t\tif (entry.DateTime.HasValue)\n\t\t\t{\n\t\t\t\tentry.DateTime = RoundToFirebirdPrecision(entry.DateTime.Value);\n\t\t\t}\n\n\t\t\tif (entry.TimeOnly.HasValue)\n\t\t\t{\n\t\t\t\tentry.TimeOnly = RoundToFirebirdPrecision(entry.TimeOnly.Value);\n\t\t\t}\n\n\t\t\tif (entry.TimeSpan.HasValue)\n\t\t\t{\n\t\t\t\tentry.TimeSpan = RoundToFirebirdPrecision(entry.TimeSpan.Value);\n\t\t\t}\n\n\t\t\tif (entry.DateTimeOffset.HasValue)\n\t\t\t{\n\t\t\t\tentry.DateTimeOffset = RoundToFirebirdPrecision(entry.DateTimeOffset.Value);\n\t\t\t}\n\t\t}\n\n\t\treturn expectedData;\n\t}\n\n\tprivate static DateTime RoundToFirebirdPrecision(DateTime dateTime)\n\t\t=> new (StripSubDeciMillisecond(dateTime.Ticks), dateTime.Kind);\n\n\tprivate static DateTimeOffset RoundToFirebirdPrecision(DateTimeOffset dateTimeOffset)\n\t\t=> new (StripSubDeciMillisecond(dateTimeOffset.Ticks), TimeSpan.Zero);\n\n\tprivate static TimeOnly RoundToFirebirdPrecision(TimeOnly timeOnly)\n\t\t=> new (StripSubDeciMillisecond(timeOnly.Ticks));\n\n\tprivate static TimeSpan RoundToFirebirdPrecision(TimeSpan timeOnly)\n\t\t=> new (StripSubDeciMillisecond(timeOnly.Ticks));\n\n\tstatic long StripSubDeciMillisecond(long ticks) => ticks - (ticks % (TimeSpan.TicksPerMillisecond / 10));\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/ByteArrayTranslationsFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query.Translations;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations;\n\npublic class ByteArrayTranslationsFbTest : ByteArrayTranslationsTestBase<BasicTypesQueryFbFixture>\n{\n\tpublic ByteArrayTranslationsFbTest(BasicTypesQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task First()\n\t{\n\t\treturn base.First();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Index()\n\t{\n\t\treturn base.Index();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/EnumTranslationsFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing Microsoft.EntityFrameworkCore.Query.Translations;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations;\n\npublic class EnumTranslationsFbTest : EnumTranslationsTestBase<BasicTypesQueryFbFixture>\n{\n\tpublic EnumTranslationsFbTest(BasicTypesQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\tprotected override void ClearLog()\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/GuidTranslationsFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing Microsoft.EntityFrameworkCore.Query.Translations;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations;\n\npublic class GuidTranslationsFbTest : GuidTranslationsTestBase<BasicTypesQueryFbFixture>\n{\n\tpublic GuidTranslationsFbTest(BasicTypesQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/MathTranslationsFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query.Translations;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations;\n\npublic class MathTranslationsFbTest : MathTranslationsTestBase<BasicTypesQueryFbFixture>\n{\n\tpublic MathTranslationsFbTest(BasicTypesQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Acos_float()\n\t{\n\t\treturn base.Acos_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Acosh()\n\t{\n\t\treturn base.Acosh();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Asin_float()\n\t{\n\t\treturn base.Asin_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Asinh()\n\t{\n\t\treturn base.Asinh();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Atan_float()\n\t{\n\t\treturn base.Atan_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Atanh()\n\t{\n\t\treturn base.Atanh();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Atan2_float()\n\t{\n\t\treturn base.Atan2_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Ceiling_float()\n\t{\n\t\treturn base.Ceiling_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Cos_float()\n\t{\n\t\treturn base.Cos_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Cosh()\n\t{\n\t\treturn base.Cosh();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Degrees()\n\t{\n\t\treturn base.Degrees();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Degrees_float()\n\t{\n\t\treturn base.Degrees_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Exp_float()\n\t{\n\t\treturn base.Exp_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Floor_float()\n\t{\n\t\treturn base.Floor_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Log_float()\n\t{\n\t\treturn base.Log_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Log_with_newBase_float()\n\t{\n\t\treturn base.Log_with_newBase_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Log10_float()\n\t{\n\t\treturn base.Log10_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Log2()\n\t{\n\t\treturn base.Log2();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Power_float()\n\t{\n\t\treturn base.Power_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Radians()\n\t{\n\t\treturn base.Radians();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Radians_float()\n\t{\n\t\treturn base.Radians_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Round_float()\n\t{\n\t\treturn base.Round_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Round_with_digits_float()\n\t{\n\t\treturn base.Round_with_digits_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Sign_float()\n\t{\n\t\treturn base.Sign_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Sin_float()\n\t{\n\t\treturn base.Sin_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Sinh()\n\t{\n\t\treturn base.Sinh();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Sqrt_float()\n\t{\n\t\treturn base.Sqrt_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Tan_float()\n\t{\n\t\treturn base.Tan_float();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Tanh()\n\t{\n\t\treturn base.Tanh();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Truncate_float()\n\t{\n\t\treturn base.Truncate_float();\n\t}\n\n\t// Round itself works here, but the where clause (255.1) is not translated correctly (255.09999) due to floating point error\n\t[NotSupportedByProviderFact]\n\tpublic override Task Round_with_digits_double()\n\t{\n\t\treturn base.Round_with_digits_double();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/MiscellaneousTranslationsFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query.Translations;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations;\n\npublic class MiscellaneousTranslationsFbTest : MiscellaneousTranslationsRelationalTestBase<BasicTypesQueryFbFixture>\n{\n\tpublic MiscellaneousTranslationsFbTest(BasicTypesQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Convert_ToBoolean()\n\t{\n\t\treturn base.Convert_ToBoolean();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Convert_ToByte()\n\t{\n\t\treturn base.Convert_ToByte();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Convert_ToDecimal()\n\t{\n\t\treturn base.Convert_ToDecimal();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Convert_ToDouble()\n\t{\n\t\treturn base.Convert_ToDouble();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Convert_ToInt16()\n\t{\n\t\treturn base.Convert_ToInt16();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Convert_ToInt32()\n\t{\n\t\treturn base.Convert_ToInt32();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Convert_ToInt64()\n\t{\n\t\treturn base.Convert_ToInt64();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Convert_ToString()\n\t{\n\t\treturn base.Convert_ToString();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/Operators/ArithmeticOperatorTranslationsFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing Microsoft.EntityFrameworkCore.Query.Translations.Operators;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations.Operators;\n\npublic class ArithmeticOperatorTranslationsFbTest : ArithmeticOperatorTranslationsTestBase<BasicTypesQueryFbFixture>\n{\n\tpublic ArithmeticOperatorTranslationsFbTest(BasicTypesQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/Operators/BitwiseOperatorTranslationsFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query.Translations.Operators;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations.Operators;\n\npublic class BitwiseOperatorTranslationsFbTest : BitwiseOperatorTranslationsTestBase<BasicTypesQueryFbFixture>\n{\n\tpublic BitwiseOperatorTranslationsFbTest(BasicTypesQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Left_shift()\n\t\t=> base.Left_shift();\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Right_shift()\n\t\t=> base.Right_shift();\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/Operators/ComparisonOperatorTranslationsFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing Microsoft.EntityFrameworkCore.Query.Translations.Operators;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations.Operators;\n\npublic class ComparisonOperatorTranslationsFbTest : ComparisonOperatorTranslationsTestBase<BasicTypesQueryFbFixture>\n{\n\tpublic ComparisonOperatorTranslationsFbTest(BasicTypesQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/Operators/LogicalOperatorTranslationsFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing Microsoft.EntityFrameworkCore.Query.Translations.Operators;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations.Operators;\n\npublic class LogicalOperatorTranslationsFbTest : LogicalOperatorTranslationsTestBase<BasicTypesQueryFbFixture>\n{\n\tpublic LogicalOperatorTranslationsFbTest(BasicTypesQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/Operators/MiscellaneousOperatorTranslationsFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing Microsoft.EntityFrameworkCore.Query.Translations.Operators;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations.Operators;\n\npublic class MiscellaneousOperatorTranslationsFbTest : MiscellaneousOperatorTranslationsTestBase<BasicTypesQueryFbFixture>\n{\n\tpublic MiscellaneousOperatorTranslationsFbTest(BasicTypesQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/StringTranslationsFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query.Translations;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations;\n\npublic class StringTranslationsFbTest : StringTranslationsRelationalTestBase<BasicTypesQueryFbFixture>\n{\n\tpublic StringTranslationsFbTest(BasicTypesQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\tprotected override void ClearLog()\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task TrimStart_with_char_array_argument()\n\t{\n\t\treturn base.TrimStart_with_char_array_argument();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task TrimEnd_with_char_array_argument()\n\t{\n\t\treturn base.TrimEnd_with_char_array_argument();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Trim_with_char_array_argument_in_predicate()\n\t{\n\t\treturn base.Trim_with_char_array_argument_in_predicate();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Regex_IsMatch()\n\t{\n\t\treturn base.Regex_IsMatch();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Regex_IsMatch_constant_input()\n\t{\n\t\treturn base.Regex_IsMatch_constant_input();\n\t}\n\n\t[ConditionalFact]\n\tpublic override Task Join_non_aggregate()\n\t{\n\t\treturn AssertTranslationFailed(() => base.Join_non_aggregate());\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Contains_Literal_Char()\n\t{\n\t\treturn base.Contains_Literal_Char();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Contains_with_StringComparison_Ordinal()\n\t{\n\t\treturn base.Contains_with_StringComparison_Ordinal();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Contains_with_StringComparison_OrdinalIgnoreCase()\n\t{\n\t\treturn base.Contains_with_StringComparison_OrdinalIgnoreCase();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task EndsWith_Literal_Char()\n\t{\n\t\treturn base.EndsWith_Literal_Char();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task EndsWith_Parameter_Char()\n\t{\n\t\treturn base.EndsWith_Parameter_Char();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task EndsWith_with_StringComparison_Ordinal()\n\t{\n\t\treturn base.EndsWith_with_StringComparison_Ordinal();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task EndsWith_with_StringComparison_OrdinalIgnoreCase()\n\t{\n\t\treturn base.EndsWith_with_StringComparison_OrdinalIgnoreCase();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Equals_with_Ordinal()\n\t{\n\t\treturn base.Equals_with_Ordinal();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Equals_with_OrdinalIgnoreCase()\n\t{\n\t\treturn base.Equals_with_OrdinalIgnoreCase();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task IndexOf_Char()\n\t{\n\t\treturn base.IndexOf_Char();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task IndexOf_with_constant_starting_position_char()\n\t{\n\t\treturn base.IndexOf_with_constant_starting_position_char();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task IndexOf_with_one_parameter_arg_char()\n\t{\n\t\treturn base.IndexOf_with_one_parameter_arg_char();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task IndexOf_with_parameter_starting_position_char()\n\t{\n\t\treturn base.IndexOf_with_parameter_starting_position_char();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Replace_Char()\n\t{\n\t\treturn base.Replace_Char();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task StartsWith_Literal_Char()\n\t{\n\t\treturn base.StartsWith_Literal_Char();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task StartsWith_Parameter_Char()\n\t{\n\t\treturn base.StartsWith_Parameter_Char();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task StartsWith_with_StringComparison_Ordinal()\n\t{\n\t\treturn base.StartsWith_with_StringComparison_Ordinal();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task StartsWith_with_StringComparison_OrdinalIgnoreCase()\n\t{\n\t\treturn base.StartsWith_with_StringComparison_OrdinalIgnoreCase();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Static_Equals_with_Ordinal()\n\t{\n\t\treturn base.Static_Equals_with_Ordinal();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Static_Equals_with_OrdinalIgnoreCase()\n\t{\n\t\treturn base.Static_Equals_with_OrdinalIgnoreCase();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/Temporal/DateOnlyTranslationsFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query.Translations.Temporal;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations.Temporal;\n\npublic class DateOnlyTranslationsFbTest : DateOnlyTranslationsTestBase<BasicTypesQueryFbFixture>\n{\n\tpublic DateOnlyTranslationsFbTest(BasicTypesQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task DayNumber()\n\t{\n\t\treturn base.DayNumber();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task DayNumber_subtraction()\n\t{\n\t\treturn base.DayNumber_subtraction();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task ToDateTime_constant_DateTime_with_property_TimeOnly()\n\t{\n\t\treturn base.ToDateTime_constant_DateTime_with_property_TimeOnly();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task ToDateTime_property_with_constant_TimeOnly()\n\t{\n\t\treturn base.ToDateTime_property_with_constant_TimeOnly();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task ToDateTime_property_with_property_TimeOnly()\n\t{\n\t\treturn base.ToDateTime_property_with_property_TimeOnly();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task ToDateTime_with_complex_DateTime()\n\t{\n\t\treturn base.ToDateTime_with_complex_DateTime();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task ToDateTime_with_complex_TimeOnly()\n\t{\n\t\treturn base.ToDateTime_with_complex_TimeOnly();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/Temporal/DateTimeOffsetTranslationsFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query.Translations.Temporal;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations.Temporal;\n\npublic class DateTimeOffsetTranslationsFbTest : DateTimeOffsetTranslationsTestBase<BasicTypesQueryFbFixture>\n{\n\tpublic DateTimeOffsetTranslationsFbTest(BasicTypesQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Now()\n\t{\n\t\treturn base.Now();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task UtcNow()\n\t{\n\t\treturn base.UtcNow();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task AddMilliseconds()\n\t{\n\t\treturn base.AddMilliseconds();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task AddMinutes()\n\t{\n\t\treturn base.AddMinutes();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Date()\n\t{\n\t\treturn base.Date();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Day()\n\t{\n\t\treturn base.Day();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task DayOfYear()\n\t{\n\t\treturn base.DayOfYear();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Hour()\n\t{\n\t\treturn base.Hour();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Microsecond()\n\t{\n\t\treturn base.Microsecond();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Millisecond()\n\t{\n\t\treturn base.Millisecond();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Minute()\n\t{\n\t\treturn base.Minute();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Month()\n\t{\n\t\treturn base.Month();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Nanosecond()\n\t{\n\t\treturn base.Nanosecond();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Second()\n\t{\n\t\treturn base.Second();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task ToUnixTimeMilliseconds()\n\t{\n\t\treturn base.ToUnixTimeMilliseconds();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task ToUnixTimeSecond()\n\t{\n\t\treturn base.ToUnixTimeSecond();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Year()\n\t{\n\t\treturn base.Year();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/Temporal/DateTimeTranslationsFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query.Translations.Temporal;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations.Temporal;\n\npublic class DateTimeTranslationsFbTest : DateTimeTranslationsTestBase<BasicTypesQueryFbFixture>\n{\n\tpublic DateTimeTranslationsFbTest(BasicTypesQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task UtcNow()\n\t{\n\t\treturn base.UtcNow();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task subtract_and_TotalDays()\n\t{\n\t \treturn base.subtract_and_TotalDays();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task TimeOfDay()\n\t{\n\t\treturn base.TimeOfDay();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/Temporal/TimeOnlyTranslationsFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query.Translations.Temporal;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations.Temporal;\n\npublic class TimeOnlyTranslationsFbTest : TimeOnlyTranslationsTestBase<BasicTypesQueryFbFixture>\n{\n\tpublic TimeOnlyTranslationsFbTest(BasicTypesQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Add_TimeSpan()\n\t{\n\t\treturn base.Add_TimeSpan();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task IsBetween()\n\t{\n\t\treturn base.IsBetween();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Microsecond()\n\t{\n\t\treturn base.Microsecond();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Nanosecond()\n\t{\n\t\treturn base.Nanosecond();\n\t}\n\n\t[NotSupportedByProviderFact]\n\tpublic override Task Subtract()\n\t{\n\t\treturn base.Subtract();\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/Translations/Temporal/TimeSpanTranslationsFbTest.cs",
    "content": "/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Niek Schoemaker (@niekschoemaker)\n\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore.Query.Translations.Temporal;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\nusing Xunit.Abstractions;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query.Translations.Temporal;\n\npublic class TimeSpanTranslationsFbTest : TimeSpanTranslationsTestBase<BasicTypesQueryFbFixture>\n{\n\tpublic TimeSpanTranslationsFbTest(BasicTypesQueryFbFixture fixture, ITestOutputHelper testOutputHelper)\n\t\t: base(fixture)\n\t{\n\t\tFixture.TestSqlLoggerFactory.Clear();\n\t\tFixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Microseconds()\n\t{\n\t\treturn base.Microseconds();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override Task Nanoseconds()\n\t{\n\t\treturn base.Nanoseconds();\n\t}\n\n\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/UdfDbFunctionFbTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.Query.SqlExpressions;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class UdfDbFunctionFbTests : UdfDbFunctionTestBase<UdfDbFunctionFbTests.Fb>\n{\n\tpublic UdfDbFunctionFbTests(Fb fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override void QF_CrossApply_Correlated_Select_Anonymous()\n\t{\n\t\tbase.QF_CrossApply_Correlated_Select_Anonymous();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override void QF_OuterApply_Correlated_Select_QF()\n\t{\n\t\tbase.QF_OuterApply_Correlated_Select_QF();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override void Udf_with_argument_being_comparison_of_nullable_columns()\n\t{\n\t\tbase.Udf_with_argument_being_comparison_of_nullable_columns();\n\t}\n\n\t[Fact]\n\tpublic override void QF_Select_Correlated_Subquery_In_Anonymous_MultipleCollections()\n\t{\n\t\tbase.QF_Select_Correlated_Subquery_In_Anonymous_MultipleCollections();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override void QF_CrossApply_Correlated_Select_Result()\n\t{\n\t\tbase.QF_CrossApply_Correlated_Select_Result();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override void QF_Select_Correlated_Subquery_In_Anonymous()\n\t{\n\t\tbase.QF_Select_Correlated_Subquery_In_Anonymous();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override void QF_Correlated_Func_Call_With_Navigation()\n\t{\n\t\tbase.QF_Correlated_Func_Call_With_Navigation();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override void QF_Select_Correlated_Direct_With_Function_Query_Parameter_Correlated_In_Anonymous()\n\t{\n\t\tbase.QF_Select_Correlated_Direct_With_Function_Query_Parameter_Correlated_In_Anonymous();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override void QF_OuterApply_Correlated_Select_Entity()\n\t{\n\t\tbase.QF_OuterApply_Correlated_Select_Entity();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override void QF_Correlated_Nested_Func_Call()\n\t{\n\t\tbase.QF_Correlated_Nested_Func_Call();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override void QF_OuterApply_Correlated_Select_Anonymous()\n\t{\n\t\tbase.QF_OuterApply_Correlated_Select_Anonymous();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override void QF_Select_Correlated_Subquery_In_Anonymous_Nested_With_QF()\n\t{\n\t\tbase.QF_Select_Correlated_Subquery_In_Anonymous_Nested_With_QF();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override void QF_Correlated_Select_In_Anonymous()\n\t{\n\t\tbase.QF_Correlated_Select_In_Anonymous();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override void QF_CrossApply_Correlated_Select_QF_Type()\n\t{\n\t\tbase.QF_CrossApply_Correlated_Select_QF_Type();\n\t}\n\n\t[NotSupportedOnFirebirdFact]\n\tpublic override void Udf_with_argument_being_comparison_to_null_parameter()\n\t{\n\t\tbase.Udf_with_argument_being_comparison_to_null_parameter();\n\t}\n\n\t[DoesNotHaveTheDataFact]\n\tpublic override void QF_CrossJoin_Not_Correlated()\n\t{\n\t\tbase.QF_CrossJoin_Not_Correlated();\n\t}\n\n\t[DoesNotHaveTheDataFact]\n\tpublic override void DbSet_mapped_to_function()\n\t{\n\t\tbase.DbSet_mapped_to_function();\n\t}\n\n\t[DoesNotHaveTheDataFact]\n\tpublic override void QF_LeftJoin_Select_Result()\n\t{\n\t\tbase.QF_LeftJoin_Select_Result();\n\t}\n\n\t[DoesNotHaveTheDataFact]\n\tpublic override void QF_Join()\n\t{\n\t\tbase.QF_Join();\n\t}\n\n\t[DoesNotHaveTheDataFact]\n\tpublic override void QF_LeftJoin_Select_Anonymous()\n\t{\n\t\tbase.QF_LeftJoin_Select_Anonymous();\n\t}\n\n\t[DoesNotHaveTheDataFact]\n\tpublic override void QF_Stand_Alone_Parameter()\n\t{\n\t\tbase.QF_Stand_Alone_Parameter();\n\t}\n\n\t[DoesNotHaveTheDataFact]\n\tpublic override void QF_Stand_Alone()\n\t{\n\t\tbase.QF_Stand_Alone();\n\t}\n\n\t[DoesNotHaveTheDataFact]\n\tpublic override void QF_Nested()\n\t{\n\t\tbase.QF_Nested();\n\t}\n\n\t[DoesNotHaveTheDataFact]\n\tpublic override void QF_CrossJoin_Parameter()\n\t{\n\t\tbase.QF_CrossJoin_Parameter();\n\t}\n\n\tprotected class FbUDFSqlContext : UDFSqlContext\n\t{\n\t\tpublic FbUDFSqlContext(DbContextOptions options)\n\t\t\t: base(options)\n\t\t{ }\n\n\t\tprotected override void OnModelCreating(ModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnModelCreating(modelBuilder);\n\n\t\t\tvar isDateMethodInfo = typeof(UDFSqlContext).GetMethod(nameof(IsDateStatic));\n\t\t\tmodelBuilder.HasDbFunction(isDateMethodInfo)\n\t\t\t\t.HasTranslation(args => new SqlFunctionExpression(null, \"IsDate\", args, true, new[] { true }, isDateMethodInfo.ReturnType, null));\n\t\t\tvar isDateMethodInfo2 = typeof(UDFSqlContext).GetMethod(nameof(IsDateInstance));\n\t\t\tmodelBuilder.HasDbFunction(isDateMethodInfo2)\n\t\t\t\t.HasTranslation(args => new SqlFunctionExpression(null, \"IsDate\", args, true, new[] { true }, isDateMethodInfo2.ReturnType, null));\n\n\t\t\tvar methodInfo = typeof(UDFSqlContext).GetMethod(nameof(MyCustomLengthStatic));\n\t\t\tmodelBuilder.HasDbFunction(methodInfo)\n\t\t\t\t.HasTranslation(args => new SqlFunctionExpression(\"char_length\", args, true, new[] { true }, methodInfo.ReturnType, null));\n\t\t\tvar methodInfo2 = typeof(UDFSqlContext).GetMethod(nameof(MyCustomLengthInstance));\n\t\t\tmodelBuilder.HasDbFunction(methodInfo2)\n\t\t\t\t.HasTranslation(args => new SqlFunctionExpression(\"char_length\", args, true, new[] { true }, methodInfo2.ReturnType, null));\n\t\t\tvar methodInfo3 = typeof(UDFSqlContext).GetMethod(nameof(StringLength));\n\t\t\tmodelBuilder.HasDbFunction(methodInfo3)\n\t\t\t\t.HasTranslation(args => new SqlFunctionExpression(\"char_length\", args, true, new[] { true }, methodInfo3.ReturnType, null));\n\n\t\t\tmodelBuilder.HasDbFunction(typeof(UDFSqlContext).GetMethod(nameof(GetCustomerWithMostOrdersAfterDateStatic)))\n\t\t\t\t.HasName(\"GetCustWithMostOrdersAfterDate\");\n\t\t\tmodelBuilder.HasDbFunction(typeof(UDFSqlContext).GetMethod(nameof(GetCustomerWithMostOrdersAfterDateInstance)))\n\t\t\t\t.HasName(\"GetCustWithMostOrdersAfterDate\");\n\n\t\t\tmodelBuilder.HasDbFunction(typeof(UDFSqlContext).GetMethod(nameof(IdentityString)))\n\t\t\t\t.HasSchema(null);\n\n\t\t\tModelHelpers.SetPrimaryKeyGeneration(modelBuilder);\n\t\t}\n\t}\n\n\n\tpublic class Fb : UdfFixtureBase\n\t{\n\t\tprotected override string StoreName { get; } = nameof(UdfDbFunctionFbTests);\n\t\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\t\tprotected override Type ContextType { get; } = typeof(FbUDFSqlContext);\n\n\t\tprotected override async Task SeedAsync(DbContext context)\n\t\t{\n\t\t\tawait base.SeedAsync(context);\n\n\t\t\tawait context.Database.ExecuteSqlRawAsync(\n\t\t\t\t@\"create function \"\"CustomerOrderCount\"\" (customerId int)\n                                                    returns int\n                                                    as\n                                                    begin\n                                                        return (select count(\"\"Id\"\") from \"\"Orders\"\" where \"\"CustomerId\"\" = :customerId);\n                                                    end\");\n\n\t\t\tawait context.Database.ExecuteSqlRawAsync(\n\t\t\t\t@\"create function \"\"StarValue\"\" (starCount int, val varchar(1000))\n                                                    returns varchar(1000)\n                                                    as\n                                                    begin\n                                                        return rpad('', :starCount, '*') || :val;\n                                                    end\");\n\n\t\t\tawait context.Database.ExecuteSqlRawAsync(\n\t\t\t\t@\"create function \"\"DollarValue\"\" (starCount int, val varchar(1000))\n                                                    returns varchar(1000)\n                                                    as\n                                                    begin\n                                                        return rpad('', :starCount, '$') || :val;\n                                                    end\");\n\n\t\t\tawait context.Database.ExecuteSqlRawAsync(\n\t\t\t\t@\"create function \"\"GetReportingPeriodStartDate\"\" (period int)\n                                                    returns timestamp\n                                                    as\n                                                    begin\n                                                        return cast('1998-01-01' as timestamp);\n                                                    end\");\n\n\t\t\tawait context.Database.ExecuteSqlRawAsync(\n\t\t\t\t@\"create function \"\"GetCustWithMostOrdersAfterDate\"\" (searchDate Date)\n                                                    returns int\n                                                    as\n                                                    begin\n                                                        return (select first 1 \"\"CustomerId\"\"\n                                                                from \"\"Orders\"\"\n                                                                where \"\"OrderDate\"\" > :searchDate\n                                                                group by \"\"CustomerId\"\"\n                                                                order by count(\"\"Id\"\") desc);\n                                                    end\");\n\n\t\t\tawait context.Database.ExecuteSqlRawAsync(\n\t\t\t\t@\"create function \"\"IsTopCustomer\"\" (customerId int)\n                                                    returns boolean\n                                                    as\n                                                    begin\n                                                        if (:customerId = 1) then\n                                                            return true;\n\n                                                        return false;\n                                                    end\");\n\n\t\t\tawait context.Database.ExecuteSqlRawAsync(\n\t\t\t\t@\"create function \"\"IdentityString\"\" (customerName varchar(1000))\n                                                    returns varchar(1000)\n                                                    as\n                                                    begin\n                                                        return :customerName;\n                                                    end\");\n\n\t\t\tawait context.Database.ExecuteSqlRawAsync(\n\t\t\t\t@\"create function \"\"IsDate\"\" (val varchar(1000))\n                                                    returns boolean\n                                                    as\n                                                    declare dummy date;\n                                                    begin\n                                                        begin\n                                                            begin\n                                                                dummy = cast(val as date);\n                                                            end\n                                                            when any do\n                                                            begin\n                                                                return false;\n                                                            end\n                                                        end\n                                                        return true;\n                                                    end\");\n\n\t\t\tawait context.Database.ExecuteSqlRawAsync(\n\t\t\t\t@\"create procedure \"\"GetTopTwoSellingProducts\"\"\n                                                    returns\n                                                    (\n                                                        \"\"ProductId\"\" int not null,\n                                                        \"\"AmountSold\"\" int\n                                                    )\n                                                    as\n                                                    begin\n                                                        for select first 2 \"\"ProductId\"\", sum(\"\"Quantity\"\") as \"\"TotalSold\"\"\n                                                        from \"\"LineItem\"\"\n                                                        group by \"\"ProductId\"\"\n                                                        order by \"\"TotalSold\"\" desc\n                                                        into :\"\"ProductId\"\", :\"\"AmountSold\"\" do\n                                                        begin\n                                                            suspend;\n                                                        end\n                                                    end\");\n\n\t\t\tawait context.Database.ExecuteSqlRawAsync(\n\t\t\t\t@\"create procedure \"\"GetOrdersWithMultipleProducts\"\"(customerId int)\n                                                    returns\n                                                    (\n                                                        \"\"OrderId\"\" int not null,\n                                                        \"\"CustomerId\"\" int not null,\n                                                        \"\"OrderDate\"\" timestamp\n                                                    )\n                                                    as\n                                                    begin\n                                                        for select o.\"\"Id\"\", :customerId, \"\"OrderDate\"\"\n                                                        from \"\"Orders\"\" o\n                                                        join \"\"LineItem\"\" li on o.\"\"Id\"\" = li.\"\"OrderId\"\"\n                                                        where o.\"\"CustomerId\"\" = :customerId\n                                                        group by o.\"\"Id\"\", \"\"OrderDate\"\"\n                                                        having count(\"\"ProductId\"\") > 1\n                                                        into :\"\"OrderId\"\", :\"\"CustomerId\"\", :\"\"OrderDate\"\" do\n                                                        begin\n                                                            suspend;\n                                                        end\n                                                    end\");\n\n\t\t\tawait context.SaveChangesAsync();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/Query/WarningsFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing Microsoft.EntityFrameworkCore.Query;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Query;\n\npublic class WarningsFbTest : WarningsTestBase<NorthwindQueryFbFixture<NoopModelCustomizer>>\n{\n\tpublic WarningsFbTest(NorthwindQueryFbFixture<NoopModelCustomizer> fixture)\n\t\t: base(fixture)\n\t{ }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/TestModels/Northwind/NorthwindFbContext.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.TestModels.Northwind;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestModels.Northwind;\n\npublic class NorthwindFbContext : NorthwindRelationalContext\n{\n\tpublic NorthwindFbContext(DbContextOptions options)\n\t\t: base(options)\n\t{ }\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder)\n\t{\n\t\tbase.OnModelCreating(modelBuilder);\n\t\tModelHelpers.SetStringLengths(modelBuilder);\n\n\t\tmodelBuilder.Entity<CustomerQuery>().ToSqlQuery(\n\t\t\t@\"SELECT \"\"c\"\".\"\"CustomerID\"\", \"\"c\"\".\"\"Address\"\", \"\"c\"\".\"\"City\"\", \"\"c\"\".\"\"CompanyName\"\", \"\"c\"\".\"\"ContactName\"\", \"\"c\"\".\"\"ContactTitle\"\", \"\"c\"\".\"\"Country\"\", \"\"c\"\".\"\"Fax\"\", \"\"c\"\".\"\"Phone\"\", \"\"c\"\".\"\"PostalCode\"\", \"\"c\"\".\"\"Region\"\" FROM \"\"Customers\"\" AS \"\"c\"\"\");\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/TestUtilities/FbPrecompiledQueryTestHelpers.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Collections.Generic;\nusing System.Reflection;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Infrastructure.Internal;\nusing Microsoft.CodeAnalysis;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\n\npublic class FbPrecompiledQueryTestHelpers : PrecompiledQueryTestHelpers\n{\n\tpublic static readonly FbPrecompiledQueryTestHelpers Instance = new();\n\n\tprotected override IEnumerable<MetadataReference> BuildProviderMetadataReferences()\n\t{\n#pragma warning disable EF1001\n\t\tyield return MetadataReference.CreateFromFile(typeof(FbOptionsExtension).Assembly.Location);\n#pragma warning restore EF1001\n\t\tyield return MetadataReference.CreateFromFile(Assembly.GetExecutingAssembly().Location);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/TestUtilities/FbTestHelpers.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing FirebirdSql.Data.FirebirdClient;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Diagnostics.Internal;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\n\npublic class FbTestHelpers : RelationalTestHelpers\n{\n\tprotected FbTestHelpers()\n\t{ }\n\n\tpublic static FbTestHelpers Instance { get; } = new();\n\n\tpublic override IServiceCollection AddProviderServices(IServiceCollection services)\n\t\t=> services.AddEntityFrameworkFirebird();\n\n\tpublic override DbContextOptionsBuilder UseProviderOptions(DbContextOptionsBuilder optionsBuilder)\n\t\t=> optionsBuilder.UseFirebird(new FbConnection(\"database=localhost:_.fdb;user=sysdba;password=masterkey;charset=utf8\"));\n\n#pragma warning disable EF1001\n\tpublic override LoggingDefinitions LoggingDefinitions { get; } = new FbLoggingDefinitions();\n#pragma warning restore EF1001\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/TestUtilities/FbTestStore.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.FirebirdClient;\nusing FirebirdSql.Data.Services;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\n\npublic class FbTestStore : RelationalTestStore\n{\n\tpublic static FbTestStore Create(string name)\n\t\t=> new FbTestStore(name, shared: false);\n\n\tpublic static FbTestStore GetOrCreate(string name)\n\t\t=> new FbTestStore(name, shared: true);\n\n\tpublic FbTestStore(string name, bool shared)\n\t\t: base(name, shared, CreateConnection(name, shared))\n\t{ }\n\n\tprotected override string OpenDelimiter => \"\\\"\";\n\tprotected override string CloseDelimiter => \"\\\"\";\n\n\tpublic Version ServerVersion { get; private set; }\n\tpublic bool ServerLessThan4() => ServerVersion < new Version(4, 0, 0, 0);\n\n\tpublic bool ServerLessThan5() => ServerVersion < new Version(5, 0, 0, 0);\n\n\tprotected override async Task InitializeAsync(Func<DbContext> createContext, Func<DbContext, Task> seed, Func<DbContext, Task> clean)\n\t{\n\t\tif (Connection.State != ConnectionState.Closed)\n\t\t{\n\t\t\t// Connections are maintained between tests, they have to be closed to create a new database\n\t\t\tawait Connection.CloseAsync();\n\t\t}\n\t\t// create database explicitly to specify Page Size and Forced Writes\n\t\tawait FbConnection.CreateDatabaseAsync(ConnectionString, pageSize: 16384, forcedWrites: false, overwrite: true);\n\t\tawait using (var context = createContext())\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tawait context.Database.EnsureCreatedAsync();\n\t\t\t}\n\t\t\tcatch (FbException ex) when (ServerLessThan4() && ex.Message.EndsWith(\"Name longer than database column size\", StringComparison.Ordinal))\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (clean != null)\n\t\t\t{\n\t\t\t\tawait clean(context);\n\t\t\t}\n\t\t\tif (seed != null)\n\t\t\t{\n\t\t\t\tawait seed(context);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override void OpenConnection()\n\t{\n\t\tbase.OpenConnection();\n\t\tServerVersion = FbServerProperties.ParseServerVersion(Connection.ServerVersion);\n\t\tif (ServerVersion >= new Version(4, 0, 0, 0))\n\t\t{\n\t\t\tusing (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"set bind of decfloat to legacy\";\n\t\t\t\tcmd.ExecuteNonQuery();\n\t\t\t\tcmd.CommandText = \"set bind of int128 to legacy\";\n\t\t\t\tcmd.ExecuteNonQuery();\n\t\t\t\tcmd.CommandText = \"set bind of time zone to legacy\";\n\t\t\t\tcmd.ExecuteNonQuery();\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override async Task OpenConnectionAsync()\n\t{\n\t\tawait base.OpenConnectionAsync();\n\t\tif (FbServerProperties.ParseServerVersion(Connection.ServerVersion) >= new Version(4, 0, 0, 0))\n\t\t{\n\t\t\tawait using (var cmd = Connection.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"set bind of decfloat to legacy\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t\tcmd.CommandText = \"set bind of int128 to legacy\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t\tcmd.CommandText = \"set bind of time zone to legacy\";\n\t\t\t\tawait cmd.ExecuteNonQueryAsync();\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic override DbContextOptionsBuilder AddProviderOptions(DbContextOptionsBuilder builder)\n\t\t=> builder.UseFirebird(Connection,\n\t\t\tx => x.UseQuerySplittingBehavior(QuerySplittingBehavior.SingleQuery));\n\n\tstatic FbConnection CreateConnection(string name, bool shared)\n\t{\n\t\tvar csb = new FbConnectionStringBuilder\n\t\t{\n\t\t\tDatabase = $\"EFCore_{name}.fdb\",\n\t\t\tDataSource = \"localhost\",\n\t\t\tUserID = \"sysdba\",\n\t\t\tPassword = \"masterkey\",\n\t\t\tPooling = false,\n\t\t\tCharset = \"utf8\"\n\t\t};\n\t\treturn new FbConnection(csb.ToString());\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/TestUtilities/FbTestStoreFactory.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Globalization;\nusing System.Threading;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Microsoft.Extensions.DependencyInjection;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\n\npublic class FbTestStoreFactory : RelationalTestStoreFactory\n{\n\tpublic static FbTestStoreFactory Instance { get; } = new FbTestStoreFactory();\n\n\tstatic FbTestStoreFactory()\n\t{\n\t\t// See #14847 on EntityFrameworkCore.\n\t\tCultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;\n\t\tThread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;\n\t}\n\n\tpublic override TestStore Create(string storeName)\n\t\t=> FbTestStore.Create(storeName);\n\n\tpublic override TestStore GetOrCreate(string storeName)\n\t\t=> FbTestStore.GetOrCreate(storeName);\n\n\tpublic override IServiceCollection AddProviderServices(IServiceCollection serviceCollection)\n\t\t=> serviceCollection.AddEntityFrameworkFirebird();\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/UpdatesFbTest.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.Helpers;\nusing FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.TestUtilities;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.TestModels.UpdatesModel;\nusing Microsoft.EntityFrameworkCore.TestUtilities;\nusing Microsoft.EntityFrameworkCore.Update;\nusing Xunit;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests;\n\npublic class UpdatesFbTest : UpdatesRelationalTestBase<UpdatesFbTest.UpdatesFbFixture>\n{\n\tpublic UpdatesFbTest(UpdatesFbFixture fixture)\n\t\t: base(fixture)\n\t{ }\n\n\t[Fact]\n\tpublic override void Identifiers_are_generated_correctly()\n\t{\n\t\tusing (var context = CreateContext())\n\t\t{\n\t\t\tvar entityType = context.Model.FindEntityType(typeof(LoginEntityTypeWithAnExtremelyLongAndOverlyConvolutedNameThatIsUsedToVerifyThatTheStoreIdentifierGenerationLengthLimitIsWorkingCorrectly));\n\t\t\tAssert.Equal(\n\t\t\t\t\"LoginEntityTypeWithAnExtremely~\",\n\t\t\t\tentityType.GetTableName());\n\t\t\tAssert.Equal(\n\t\t\t\t\"PK_LoginEntityTypeWithAnExtrem~\",\n\t\t\t\tentityType.GetKeys().Single().GetName());\n\t\t\tAssert.Equal(\n\t\t\t\t\"FK_LoginEntityTypeWithAnExtrem~\",\n\t\t\t\tentityType.GetForeignKeys().Single().GetConstraintName());\n\t\t\tAssert.Equal(\n\t\t\t\t\"IX_LoginEntityTypeWithAnExtrem~\",\n\t\t\t\tentityType.GetIndexes().Single().GetDatabaseName());\n\t\t}\n\t}\n\n\t[Fact(Skip = \"Uses type of filtered index that is not supported on Firebird.\")]\n\tpublic override Task Swap_filtered_unique_index_values() => base.Swap_filtered_unique_index_values();\n\n\tpublic class UpdatesFbFixture : UpdatesRelationalFixture\n\t{\n\t\tprotected override ITestStoreFactory TestStoreFactory => FbTestStoreFactory.Instance;\n\n\t\tprotected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context)\n\t\t{\n\t\t\tbase.OnModelCreating(modelBuilder, context);\n\t\t\tModelHelpers.SetStringLengths(modelBuilder);\n\t\t\tModelHelpers.SetPrimaryKeyGeneration(modelBuilder, FbValueGenerationStrategy.IdentityColumn, x => x.ClrType == typeof(Person));\n\t\t\tmodelBuilder.Entity<ProductBase>();\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.Tests/EndToEnd/DeleteTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing Microsoft.EntityFrameworkCore;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Tests.EndToEnd;\n\npublic class DeleteTests : EntityFrameworkCoreTestsBase\n{\n\tclass DeleteContext : FbTestDbContext\n\t{\n\t\tpublic DeleteContext(string connectionString)\n\t\t\t: base(connectionString)\n\t\t{ }\n\n\t\tprotected override void OnTestModelCreating(ModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnTestModelCreating(modelBuilder);\n\n\t\t\tvar insertEntityConf = modelBuilder.Entity<DeleteEntity>();\n\t\t\tinsertEntityConf.Property(x => x.Id).HasColumnName(\"ID\");\n\t\t\tinsertEntityConf.Property(x => x.Name).HasColumnName(\"NAME\");\n\t\t\tinsertEntityConf.ToTable(\"TEST_DELETE\");\n\t\t}\n\t}\n\tclass DeleteEntity\n\t{\n\t\tpublic int Id { get; set; }\n\t\tpublic string Name { get; set; }\n\t}\n\t[Test]\n\tpublic async Task Delete()\n\t{\n\t\tawait using (var db = await GetDbContext<DeleteContext>())\n\t\t{\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"create table test_delete (id int primary key, name varchar(20))\");\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"insert into test_delete values (65, 'test')\");\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"insert into test_delete values (66, 'test')\");\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"insert into test_delete values (67, 'test')\");\n\t\t\tvar entity = new DeleteEntity() { Id = 66 };\n\t\t\tvar entry = db.Attach(entity);\n\t\t\tentry.State = EntityState.Deleted;\n\t\t\tawait db.SaveChangesAsync();\n\t\t\tvar values = await db.Set<DeleteEntity>()\n\t\t\t\t .FromSqlRaw(\"select * from test_delete\")\n\t\t\t\t .AsNoTracking()\n\t\t\t\t .OrderBy(x => x.Id)\n\t\t\t\t .ToListAsync();\n\t\t\tAssert.AreEqual(2, values.Count());\n\t\t\tAssert.AreEqual(65, values[0].Id);\n\t\t\tAssert.AreEqual(67, values[1].Id);\n\t\t}\n\t}\n\n\tclass ConcurrencyDeleteContext : FbTestDbContext\n\t{\n\t\tpublic ConcurrencyDeleteContext(string connectionString)\n\t\t\t: base(connectionString)\n\t\t{ }\n\n\t\tprotected override void OnTestModelCreating(ModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnTestModelCreating(modelBuilder);\n\n\t\t\tvar insertEntityConf = modelBuilder.Entity<ConcurrencyDeleteEntity>();\n\t\t\tinsertEntityConf.Property(x => x.Id).HasColumnName(\"ID\");\n\t\t\tinsertEntityConf.Property(x => x.Name).HasColumnName(\"NAME\");\n\t\t\tinsertEntityConf.Property(x => x.Stamp).HasColumnName(\"STAMP\")\n\t\t\t\t.ValueGeneratedOnAddOrUpdate()\n\t\t\t\t.IsConcurrencyToken();\n\t\t\tinsertEntityConf.ToTable(\"TEST_DELETE_CONCURRENCY\");\n\t\t}\n\t}\n\tclass ConcurrencyDeleteEntity\n\t{\n\t\tpublic int Id { get; set; }\n\t\tpublic string Name { get; set; }\n\t\tpublic DateTime Stamp { get; set; }\n\t}\n\t[Test]\n\tpublic async Task ConcurrencyDelete()\n\t{\n\t\tawait using (var db = await GetDbContext<ConcurrencyDeleteContext>())\n\t\t{\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"create table test_delete_concurrency (id int primary key, name varchar(20), stamp timestamp)\");\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"insert into test_delete_concurrency values (65, 'test', current_timestamp)\");\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"insert into test_delete_concurrency values (66, 'test', current_timestamp)\");\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"insert into test_delete_concurrency values (67, 'test', current_timestamp)\");\n\t\t\tvar entity = new ConcurrencyDeleteEntity() { Id = 66, Stamp = new DateTime(1970, 1, 1) };\n\t\t\tvar entry = db.Attach(entity);\n\t\t\tentry.State = EntityState.Deleted;\n\t\t\tAssert.ThrowsAsync<DbUpdateConcurrencyException>(() => db.SaveChangesAsync());\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.Tests/EndToEnd/InsertTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing Microsoft.EntityFrameworkCore;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Tests.EndToEnd;\n\npublic class InsertTests : EntityFrameworkCoreTestsBase\n{\n\tclass InsertContext : FbTestDbContext\n\t{\n\t\tpublic InsertContext(string connectionString)\n\t\t\t: base(connectionString)\n\t\t{ }\n\n\t\tprotected override void OnTestModelCreating(ModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnTestModelCreating(modelBuilder);\n\n\t\t\tvar insertEntityConf = modelBuilder.Entity<InsertEntity>();\n\t\t\tinsertEntityConf.Property(x => x.Id).HasColumnName(\"ID\");\n\t\t\tinsertEntityConf.Property(x => x.Name).HasColumnName(\"NAME\");\n\t\t\tinsertEntityConf.ToTable(\"TEST_INSERT\");\n\t\t}\n\t}\n\tclass InsertEntity\n\t{\n\t\tpublic int Id { get; set; }\n\t\tpublic string Name { get; set; }\n\t}\n\t[Test]\n\tpublic async Task Insert()\n\t{\n\t\tawait using (var db = await GetDbContext<InsertContext>())\n\t\t{\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"create table test_insert (id int primary key, name varchar(20))\");\n\t\t\tvar entity = new InsertEntity() { Id = -6, Name = \"foobar\" };\n\t\t\tawait db.AddAsync(entity);\n\t\t\tawait db.SaveChangesAsync();\n\t\t\tAssert.AreEqual(-6, entity.Id);\n\t\t}\n\t}\n\n\tclass IdentityInsertContext : FbTestDbContext\n\t{\n\t\tpublic IdentityInsertContext(string connectionString)\n\t\t\t: base(connectionString)\n\t\t{ }\n\n\t\tprotected override void OnTestModelCreating(ModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnTestModelCreating(modelBuilder);\n\n\t\t\tvar insertEntityConf = modelBuilder.Entity<IdentityInsertEntity>();\n\t\t\tinsertEntityConf.Property(x => x.Id).HasColumnName(\"ID\")\n\t\t\t\t.UseIdentityColumn();\n\t\t\tinsertEntityConf.Property(x => x.Name).HasColumnName(\"NAME\");\n\t\t\tinsertEntityConf.ToTable(\"TEST_INSERT_IDENTITY\");\n\t\t}\n\t}\n\tclass IdentityInsertEntity\n\t{\n\t\tpublic int Id { get; set; }\n\t\tpublic string Name { get; set; }\n\t}\n\t[Test]\n\tpublic async Task IdentityInsert()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(3, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tvar id = ServerVersion >= new Version(4, 0, 0, 0) ? 26 : 27;\n\n\t\tawait using (var db = await GetDbContext<IdentityInsertContext>())\n\t\t{\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"create table test_insert_identity (id int generated by default as identity (start with 26) primary key, name varchar(20))\");\n\t\t\tvar entity = new IdentityInsertEntity() { Name = \"foobar\" };\n\t\t\tawait db.AddAsync(entity);\n\t\t\tawait db.SaveChangesAsync();\n\t\t\tAssert.AreEqual(id, entity.Id);\n\t\t}\n\t}\n\n\tclass SequenceInsertContext : FbTestDbContext\n\t{\n\t\tpublic SequenceInsertContext(string connectionString)\n\t\t\t: base(connectionString)\n\t\t{ }\n\n\t\tprotected override void OnTestModelCreating(ModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnTestModelCreating(modelBuilder);\n\n\t\t\tvar insertEntityConf = modelBuilder.Entity<SequenceInsertEntity>();\n\t\t\tinsertEntityConf.Property(x => x.Id).HasColumnName(\"ID\")\n\t\t\t\t.UseSequenceTrigger();\n\t\t\tinsertEntityConf.Property(x => x.Name).HasColumnName(\"NAME\");\n\t\t\tinsertEntityConf.ToTable(\"TEST_INSERT_SEQUENCE\");\n\t\t}\n\t}\n\tclass SequenceInsertEntity\n\t{\n\t\tpublic int Id { get; set; }\n\t\tpublic string Name { get; set; }\n\t}\n\t[Test]\n\tpublic async Task SequenceInsert()\n\t{\n\t\tvar id = ServerVersion >= new Version(4, 0, 0, 0) ? 30 : 31;\n\n\t\tawait using (var db = await GetDbContext<SequenceInsertContext>())\n\t\t{\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"create table test_insert_sequence (id int primary key, name varchar(20))\");\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"create sequence seq_test_insert_sequence\");\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"alter sequence seq_test_insert_sequence restart with 30\");\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"create trigger test_insert_sequence_id before insert on test_insert_sequence as begin if (new.id is null) then begin new.id = next value for seq_test_insert_sequence; end end\");\n\t\t\tvar entity = new SequenceInsertEntity() { Name = \"foobar\" };\n\t\t\tawait db.AddAsync(entity);\n\t\t\tawait db.SaveChangesAsync();\n\t\t\tAssert.AreEqual(id, entity.Id);\n\t\t}\n\t}\n\n\tclass DefaultValuesInsertContext : FbTestDbContext\n\t{\n\t\tpublic DefaultValuesInsertContext(string connectionString)\n\t\t\t: base(connectionString)\n\t\t{ }\n\n\t\tprotected override void OnTestModelCreating(ModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnTestModelCreating(modelBuilder);\n\n\t\t\tvar insertEntityConf = modelBuilder.Entity<DefaultValuesInsertEntity>();\n\t\t\tinsertEntityConf.Property(x => x.Id).HasColumnName(\"ID\")\n\t\t\t\t.ValueGeneratedOnAdd();\n\t\t\tinsertEntityConf.Property(x => x.Name).HasColumnName(\"NAME\")\n\t\t\t\t.ValueGeneratedOnAdd();\n\t\t\tinsertEntityConf.ToTable(\"TEST_INSERT_DEVAULTVALUES\");\n\t\t}\n\t}\n\tclass DefaultValuesInsertEntity\n\t{\n\t\tpublic int Id { get; set; }\n\t\tpublic string Name { get; set; }\n\t}\n\t[Test]\n\tpublic async Task DefaultValuesInsert()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(3, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tvar id = ServerVersion >= new Version(4, 0, 0, 0) ? 26 : 27;\n\n\t\tawait using (var db = await GetDbContext<DefaultValuesInsertContext>())\n\t\t{\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"create table test_insert_devaultvalues (id int generated by default as identity (start with 26) primary key, name generated always as (id || 'foobar'))\");\n\t\t\tvar entity = new DefaultValuesInsertEntity() { };\n\t\t\tawait db.AddAsync(entity);\n\t\t\tawait db.SaveChangesAsync();\n\t\t\tAssert.AreEqual(id, entity.Id);\n\t\t\tAssert.AreEqual($\"{id}foobar\", entity.Name);\n\t\t}\n\t}\n\n\tclass TwoComputedInsertContext : FbTestDbContext\n\t{\n\t\tpublic TwoComputedInsertContext(string connectionString)\n\t\t\t: base(connectionString)\n\t\t{ }\n\n\t\tprotected override void OnTestModelCreating(ModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnTestModelCreating(modelBuilder);\n\n\t\t\tvar insertEntityConf = modelBuilder.Entity<TwoComputedInsertEntity>();\n\t\t\tinsertEntityConf.Property(x => x.Id).HasColumnName(\"ID\")\n\t\t\t\t.UseIdentityColumn();\n\t\t\tinsertEntityConf.Property(x => x.Name).HasColumnName(\"NAME\");\n\t\t\tinsertEntityConf.Property(x => x.Computed1).HasColumnName(\"COMPUTED1\")\n\t\t\t\t.ValueGeneratedOnAddOrUpdate();\n\t\t\tinsertEntityConf.Property(x => x.Computed2).HasColumnName(\"COMPUTED2\")\n\t\t\t\t.ValueGeneratedOnAddOrUpdate();\n\t\t\tinsertEntityConf.ToTable(\"TEST_INSERT_2COMPUTED\");\n\t\t}\n\t}\n\tclass TwoComputedInsertEntity\n\t{\n\t\tpublic int Id { get; set; }\n\t\tpublic string Name { get; set; }\n\t\tpublic string Computed1 { get; set; }\n\t\tpublic string Computed2 { get; set; }\n\t}\n\t[Test]\n\tpublic async Task TwoComputedInsert()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(3, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tawait using (var db = await GetDbContext<TwoComputedInsertContext>())\n\t\t{\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"create table test_insert_2computed (id int generated by default as identity (start with 26) primary key, name varchar(20), computed1 generated always as ('1' || name), computed2 generated always as ('2' || name))\");\n\t\t\tvar entity = new TwoComputedInsertEntity() { Name = \"foobar\" };\n\t\t\tawait db.AddAsync(entity);\n\t\t\tawait db.SaveChangesAsync();\n\t\t\tAssert.AreEqual(\"1foobar\", entity.Computed1);\n\t\t\tAssert.AreEqual(\"2foobar\", entity.Computed2);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.Tests/EndToEnd/UpdateTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing Microsoft.EntityFrameworkCore;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Tests.EndToEnd;\n\npublic class UpdateTests : EntityFrameworkCoreTestsBase\n{\n\tclass UpdateContext : FbTestDbContext\n\t{\n\t\tpublic UpdateContext(string connectionString)\n\t\t\t: base(connectionString)\n\t\t{ }\n\n\t\tprotected override void OnTestModelCreating(ModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnTestModelCreating(modelBuilder);\n\n\t\t\tvar insertEntityConf = modelBuilder.Entity<UpdateEntity>();\n\t\t\tinsertEntityConf.Property(x => x.Id).HasColumnName(\"ID\");\n\t\t\tinsertEntityConf.Property(x => x.Foo).HasColumnName(\"FOO\");\n\t\t\tinsertEntityConf.Property(x => x.Bar).HasColumnName(\"BAR\");\n\t\t\tinsertEntityConf.ToTable(\"TEST_UPDATE\");\n\t\t}\n\t}\n\tclass UpdateEntity\n\t{\n\t\tpublic int Id { get; set; }\n\t\tpublic string Foo { get; set; }\n\t\tpublic string Bar { get; set; }\n\t}\n\t[Test]\n\tpublic async Task Update()\n\t{\n\t\tawait using (var db = await GetDbContext<UpdateContext>())\n\t\t{\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"create table test_update (id int primary key, foo varchar(20), bar varchar(20))\");\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"update or insert into test_update values (66, 'foo', 'bar')\");\n\t\t\tvar entity = new UpdateEntity() { Id = 66, Foo = \"test\", Bar = \"test\" };\n\t\t\tvar entry = db.Attach(entity);\n\t\t\tentry.Property(x => x.Foo).IsModified = true;\n\t\t\tawait db.SaveChangesAsync();\n\t\t\tvar value = await db.Set<UpdateEntity>()\n\t\t\t\t.FromSqlRaw(\"select * from test_update where id = 66\")\n\t\t\t\t.AsNoTracking()\n\t\t\t\t.FirstAsync();\n\t\t\tAssert.AreEqual(\"test\", value.Foo);\n\t\t\tAssert.AreNotEqual(\"test\", value.Bar);\n\t\t}\n\t}\n\n\tclass ComputedUpdateContext : FbTestDbContext\n\t{\n\t\tpublic ComputedUpdateContext(string connectionString)\n\t\t\t: base(connectionString)\n\t\t{ }\n\n\t\tprotected override void OnTestModelCreating(ModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnTestModelCreating(modelBuilder);\n\n\t\t\tvar insertEntityConf = modelBuilder.Entity<ComputedUpdateEntity>();\n\t\t\tinsertEntityConf.Property(x => x.Id).HasColumnName(\"ID\");\n\t\t\tinsertEntityConf.Property(x => x.Foo).HasColumnName(\"FOO\");\n\t\t\tinsertEntityConf.Property(x => x.Bar).HasColumnName(\"BAR\");\n\t\t\tinsertEntityConf.Property(x => x.Computed).HasColumnName(\"COMPUTED\")\n\t\t\t\t.ValueGeneratedOnAddOrUpdate();\n\t\t\tinsertEntityConf.ToTable(\"TEST_UPDATE_COMPUTED\");\n\t\t}\n\t}\n\tclass ComputedUpdateEntity\n\t{\n\t\tpublic int Id { get; set; }\n\t\tpublic string Foo { get; set; }\n\t\tpublic string Bar { get; set; }\n\t\tpublic string Computed { get; set; }\n\t}\n\t[Test]\n\tpublic async Task ComputedUpdate()\n\t{\n\t\tawait using (var db = await GetDbContext<ComputedUpdateContext>())\n\t\t{\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"create table test_update_computed (id int primary key, foo varchar(20), bar varchar(20), computed generated always as (foo || bar))\");\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"update or insert into test_update_computed values (66, 'foo', 'bar')\");\n\t\t\tvar entity = new ComputedUpdateEntity() { Id = 66, Foo = \"test\", Bar = \"test\" };\n\t\t\tvar entry = db.Attach(entity);\n\t\t\tentry.Property(x => x.Foo).IsModified = true;\n\t\t\tawait db.SaveChangesAsync();\n\t\t\tAssert.AreEqual(\"testbar\", entity.Computed);\n\t\t}\n\t}\n\n\tclass ConcurrencyUpdateContext : FbTestDbContext\n\t{\n\t\tpublic ConcurrencyUpdateContext(string connectionString)\n\t\t\t: base(connectionString)\n\t\t{ }\n\n\t\tprotected override void OnTestModelCreating(ModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnTestModelCreating(modelBuilder);\n\n\t\t\tvar insertEntityConf = modelBuilder.Entity<ConcurrencyUpdateEntity>();\n\t\t\tinsertEntityConf.Property(x => x.Id).HasColumnName(\"ID\");\n\t\t\tinsertEntityConf.Property(x => x.Foo).HasColumnName(\"FOO\");\n\t\t\tinsertEntityConf.Property(x => x.Stamp).HasColumnName(\"STAMP\")\n\t\t\t\t.ValueGeneratedOnAddOrUpdate()\n\t\t\t\t.IsConcurrencyToken();\n\t\t\tinsertEntityConf.ToTable(\"TEST_UPDATE_CONCURRENCY\");\n\t\t}\n\t}\n\tclass ConcurrencyUpdateEntity\n\t{\n\t\tpublic int Id { get; set; }\n\t\tpublic string Foo { get; set; }\n\t\tpublic DateTime Stamp { get; set; }\n\t}\n\t[Test]\n\tpublic async Task ConcurrencyUpdate()\n\t{\n\t\tawait using (var db = await GetDbContext<ConcurrencyUpdateContext>())\n\t\t{\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"create table test_update_concurrency (id int primary key, foo varchar(20), stamp timestamp)\");\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"update or insert into test_update_concurrency values (66, 'foo', current_timestamp)\");\n\t\t\tvar entity = new ConcurrencyUpdateEntity() { Id = 66, Foo = \"test\", Stamp = new DateTime(1970, 1, 1) };\n\t\t\tvar entry = db.Attach(entity);\n\t\t\tentry.Property(x => x.Foo).IsModified = true;\n\t\t\tAssert.ThrowsAsync<DbUpdateConcurrencyException>(() => db.SaveChangesAsync());\n\t\t}\n\t}\n\n\tclass ConcurrencyUpdateNoGeneratedContext : FbTestDbContext\n\t{\n\t\tpublic ConcurrencyUpdateNoGeneratedContext(string connectionString)\n\t\t\t: base(connectionString)\n\t\t{ }\n\n\t\tprotected override void OnTestModelCreating(ModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnTestModelCreating(modelBuilder);\n\n\t\t\tvar insertEntityConf = modelBuilder.Entity<ConcurrencyUpdateNoGeneratedEntity>();\n\t\t\tinsertEntityConf.Property(x => x.Id).HasColumnName(\"ID\");\n\t\t\tinsertEntityConf.Property(x => x.Foo).HasColumnName(\"FOO\");\n\t\t\tinsertEntityConf.Property(x => x.Stamp).HasColumnName(\"STAMP\")\n\t\t\t\t.IsConcurrencyToken();\n\t\t\tinsertEntityConf.ToTable(\"TEST_UPDATE_CONCURRENCY_NG\");\n\t\t}\n\t}\n\tclass ConcurrencyUpdateNoGeneratedEntity\n\t{\n\t\tpublic int Id { get; set; }\n\t\tpublic string Foo { get; set; }\n\t\tpublic DateTime Stamp { get; set; }\n\t}\n\t[Test]\n\tpublic async Task ConcurrencyUpdateNoGenerated()\n\t{\n\t\tawait using (var db = await GetDbContext<ConcurrencyUpdateNoGeneratedContext>())\n\t\t{\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"create table test_update_concurrency_ng (id int primary key, foo varchar(20), stamp timestamp)\");\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"update or insert into test_update_concurrency_ng values (66, 'foo', current_timestamp)\");\n\t\t\tvar entity = new ConcurrencyUpdateNoGeneratedEntity() { Id = 66, Foo = \"test\", Stamp = new DateTime(1970, 1, 1) };\n\t\t\tvar entry = db.Attach(entity);\n\t\t\tentry.Property(x => x.Foo).IsModified = true;\n\t\t\tentry.Property(x => x.Stamp).IsModified = true;\n\t\t\tAssert.ThrowsAsync<DbUpdateConcurrencyException>(() => db.SaveChangesAsync());\n\t\t}\n\t}\n\n\tclass TwoComputedUpdateContext : FbTestDbContext\n\t{\n\t\tpublic TwoComputedUpdateContext(string connectionString)\n\t\t\t: base(connectionString)\n\t\t{ }\n\n\t\tprotected override void OnTestModelCreating(ModelBuilder modelBuilder)\n\t\t{\n\t\t\tbase.OnTestModelCreating(modelBuilder);\n\n\t\t\tvar insertEntityConf = modelBuilder.Entity<TwoComputedUpdateEntity>();\n\t\t\tinsertEntityConf.Property(x => x.Id).HasColumnName(\"ID\");\n\t\t\tinsertEntityConf.Property(x => x.Foo).HasColumnName(\"FOO\");\n\t\t\tinsertEntityConf.Property(x => x.Bar).HasColumnName(\"BAR\");\n\t\t\tinsertEntityConf.Property(x => x.Computed1).HasColumnName(\"COMPUTED1\")\n\t\t\t\t.ValueGeneratedOnAddOrUpdate();\n\t\t\tinsertEntityConf.Property(x => x.Computed2).HasColumnName(\"COMPUTED2\")\n\t\t\t\t.ValueGeneratedOnAddOrUpdate();\n\t\t\tinsertEntityConf.ToTable(\"TEST_UPDATE_2COMPUTED\");\n\t\t}\n\t}\n\tclass TwoComputedUpdateEntity\n\t{\n\t\tpublic int Id { get; set; }\n\t\tpublic string Foo { get; set; }\n\t\tpublic string Bar { get; set; }\n\t\tpublic string Computed1 { get; set; }\n\t\tpublic string Computed2 { get; set; }\n\t}\n\t[Test]\n\tpublic async Task TwoComputedUpdate()\n\t{\n\t\tawait using (var db = await GetDbContext<TwoComputedUpdateContext>())\n\t\t{\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"create table test_update_2computed (id int primary key, foo varchar(20), bar varchar(20), computed1 generated always as (foo || bar), computed2 generated always as (bar || bar))\");\n\t\t\tawait db.Database.ExecuteSqlRawAsync(\"update or insert into test_update_2computed values (66, 'foo', 'bar')\");\n\t\t\tvar entity = new TwoComputedUpdateEntity() { Id = 66, Foo = \"test\", Bar = \"test\" };\n\t\t\tvar entry = db.Attach(entity);\n\t\t\tentry.Property(x => x.Foo).IsModified = true;\n\t\t\tawait db.SaveChangesAsync();\n\t\t\tAssert.AreEqual(\"testbar\", entity.Computed1);\n\t\t\tAssert.AreEqual(\"barbar\", entity.Computed2);\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.Tests/EntityFrameworkCoreTestsBase.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.FirebirdClient;\nusing FirebirdSql.Data.TestsBase;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Tests;\n\npublic abstract class EntityFrameworkCoreTestsBase : FbTestsBase\n{\n\tpublic EntityFrameworkCoreTestsBase()\n\t\t: base(FbServerType.Default, false, FbWireCrypt.Enabled, false)\n\t{ }\n\n\tpublic async Task<TContext> GetDbContext<TContext>() where TContext : FbTestDbContext\n\t{\n\t\tawait Connection.CloseAsync();\n\t\treturn (TContext)Activator.CreateInstance(typeof(TContext), Connection.ConnectionString);\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.Tests/FbTestDbContext.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Linq;\nusing Microsoft.EntityFrameworkCore;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Tests;\n\npublic class FbTestDbContext : DbContext\n{\n\treadonly string _connectionString;\n\n\tpublic FbTestDbContext(string connectionString)\n\t\t: base()\n\t{\n\t\t_connectionString = connectionString;\n\t}\n\n\tprotected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)\n\t{\n\t\tbase.OnConfiguring(optionsBuilder);\n\n\t\toptionsBuilder.UseFirebird(_connectionString);\n\t}\n\n\tprotected override void OnModelCreating(ModelBuilder modelBuilder)\n\t{\n\t\tbase.OnModelCreating(modelBuilder);\n\t\tOnTestModelCreating(modelBuilder);\n\t\tAfterModelCreated(modelBuilder);\n\t}\n\n\tprotected virtual void OnTestModelCreating(ModelBuilder modelBuilder)\n\t{ }\n\n\tprotected virtual void AfterModelCreated(ModelBuilder modelBuilder)\n\t{\n\t\tforeach (var entity in modelBuilder.Model.GetEntityTypes())\n\t\t{\n\t\t\tforeach (var property in entity.GetProperties().Where(x => x.ClrType == typeof(string)))\n\t\t\t{\n\t\t\t\tproperty.SetMaxLength(100);\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.Tests/FirebirdSql.EntityFrameworkCore.Firebird.Tests.csproj",
    "content": "﻿<Project Sdk=\"Microsoft.NET.Sdk\">\n\t<PropertyGroup>\n\t\t<TargetFramework>net10.0</TargetFramework>\n\t\t<GenerateAssemblyInfo>false</GenerateAssemblyInfo>\n\t\t<GeneratePackageOnBuild>false</GeneratePackageOnBuild>\n\t\t<SkipSourceLink>true</SkipSourceLink>\n\t\t<AssemblyName>FirebirdSql.EntityFrameworkCore.Firebird.Tests</AssemblyName>\n\t\t<RootNamespace>FirebirdSql.EntityFrameworkCore.Firebird.Tests</RootNamespace>\n\t\t<SignAssembly>true</SignAssembly>\n\t\t<AssemblyOriginatorKeyFile>..\\FirebirdSql.Data.TestsBase\\FirebirdSql.Data.TestsBase.snk</AssemblyOriginatorKeyFile>\n\t\t<OutputType>Exe</OutputType>\n\t\t<StartupObject>FirebirdSql.Data.TestsBase.Program</StartupObject>\n\t</PropertyGroup>\n\t<ItemGroup>\n\t\t<Using Include=\"NUnit.Framework.Legacy.ClassicAssert\" Alias=\"Assert\" />\n\t\t<Using Include=\"NUnit.Framework.Legacy.CollectionAssert\" Alias=\"CollectionAssert\" />\n\t\t<Using Include=\"NUnit.Framework.Legacy.StringAssert\" Alias=\"StringAssert\" />\n\t</ItemGroup>\n\t<ItemGroup>\n\t\t<PackageReference Include=\"Microsoft.NET.Test.Sdk\" Version=\"17.12.0\" />\n\t\t<PackageReference Include=\"NUnit\" Version=\"4.2.2\" />\n\t\t<PackageReference Include=\"NUnit3TestAdapter\" Version=\"4.6.0\" />\n\t\t<PackageReference Include=\"NUnitLite\" Version=\"4.2.2\" />\n\t</ItemGroup>\n\t<ItemGroup>\n\t\t<ProjectReference Include=\"..\\FirebirdSql.EntityFrameworkCore.Firebird\\FirebirdSql.EntityFrameworkCore.Firebird.csproj\" />\n\t</ItemGroup>\n\t<ItemGroup>\n\t\t<Service Include=\"{82a7f48d-3b50-4b1e-b82e-3ada8210c358}\" />\n\t</ItemGroup>\n\t<Import Project=\"..\\FirebirdSql.Data.TestsBase\\FirebirdSql.Data.TestsBase.projitems\" Label=\"Shared\" />\n</Project>\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.Tests/Migrations/MigrationsTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Internal;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\nusing Microsoft.EntityFrameworkCore.Migrations;\nusing Microsoft.EntityFrameworkCore.Migrations.Operations;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Tests.Migrations;\n#pragma warning disable EF1001\npublic class MigrationsTests : EntityFrameworkCoreTestsBase\n{\n\t[Test]\n\tpublic async Task CreateTable()\n\t{\n\t\tvar operation = new CreateTableOperation\n\t\t{\n\t\t\tName = \"People\",\n\t\t\tColumns =\n\t\t\t\t{\n\t\t\t\t\t\tnew AddColumnOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"Id\",\n\t\t\t\t\t\t\tTable = \"People\",\n\t\t\t\t\t\t\tClrType = typeof(int),\n\t\t\t\t\t\t\tIsNullable = false,\n\t\t\t\t\t\t\t[FbAnnotationNames.ValueGenerationStrategy] = FbValueGenerationStrategy.None,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnew AddColumnOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"Id_Identity\",\n\t\t\t\t\t\t\tTable = \"People\",\n\t\t\t\t\t\t\tClrType = typeof(int),\n\t\t\t\t\t\t\tIsNullable = false,\n\t\t\t\t\t\t\t[FbAnnotationNames.ValueGenerationStrategy] = FbValueGenerationStrategy.IdentityColumn,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnew AddColumnOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"Id_Sequence\",\n\t\t\t\t\t\t\tTable = \"People\",\n\t\t\t\t\t\t\tClrType = typeof(int),\n\t\t\t\t\t\t\tIsNullable = false,\n\t\t\t\t\t\t\t[FbAnnotationNames.ValueGenerationStrategy] = FbValueGenerationStrategy.SequenceTrigger,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnew AddColumnOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"EmployerId\",\n\t\t\t\t\t\t\tTable = \"People\",\n\t\t\t\t\t\t\tClrType = typeof(int),\n\t\t\t\t\t\t\tIsNullable = true,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnew AddColumnOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"SSN\",\n\t\t\t\t\t\t\tTable = \"People\",\n\t\t\t\t\t\t\tClrType = typeof(string),\n\t\t\t\t\t\t\tColumnType = \"char(11)\",\n\t\t\t\t\t\t\tIsNullable = true,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnew AddColumnOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"DEF_O\",\n\t\t\t\t\t\t\tTable = \"People\",\n\t\t\t\t\t\t\tClrType = typeof(string),\n\t\t\t\t\t\t\tMaxLength = 20,\n\t\t\t\t\t\t\tDefaultValue = \"test\",\n\t\t\t\t\t\t\tIsNullable = true,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnew AddColumnOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"DEF_S\",\n\t\t\t\t\t\t\tTable = \"People\",\n\t\t\t\t\t\t\tClrType = typeof(string),\n\t\t\t\t\t\t\tMaxLength = 20,\n\t\t\t\t\t\t\tDefaultValueSql = \"'x'\",\n\t\t\t\t\t\t\tIsNullable = true,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnew AddColumnOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"COLLA\",\n\t\t\t\t\t\t\tTable = \"People\",\n\t\t\t\t\t\t\tClrType = typeof(string),\n\t\t\t\t\t\t\tMaxLength = 20,\n\t\t\t\t\t\t\tIsNullable = true,\n\t\t\t\t\t\t\tCollation = \"UNICODE_CI_AI\"\n\t\t\t\t\t\t},\n\t\t\t\t},\n\t\t\tPrimaryKey = new AddPrimaryKeyOperation\n\t\t\t{\n\t\t\t\tColumns = new[] { \"Id\" },\n\t\t\t},\n\t\t\tUniqueConstraints =\n\t\t\t\t{\n\t\t\t\t\t\tnew AddUniqueConstraintOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tColumns = new[] { \"SSN\" },\n\t\t\t\t\t\t},\n\t\t\t\t},\n\t\t\tForeignKeys =\n\t\t\t\t{\n\t\t\t\t\t\tnew AddForeignKeyOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tColumns = new[] { \"EmployerId\" },\n\t\t\t\t\t\t\tPrincipalTable = \"Companies\",\n\t\t\t\t\t\t\tPrincipalColumns = new[] { \"Id\" },\n\t\t\t\t\t\t},\n\t\t\t\t},\n\t\t};\n\t\tvar expectedCreateTable = @\"CREATE TABLE \"\"People\"\" (\n    \"\"Id\"\" INTEGER NOT NULL,\n    \"\"Id_Identity\"\" INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL,\n    \"\"Id_Sequence\"\" INTEGER NOT NULL,\n    \"\"EmployerId\"\" INTEGER,\n    \"\"SSN\"\" char(11),\n    \"\"DEF_O\"\" VARCHAR(20) DEFAULT _UTF8'test',\n    \"\"DEF_S\"\" VARCHAR(20) DEFAULT 'x',\n    \"\"COLLA\"\" VARCHAR(20) COLLATE UNICODE_CI_AI,\n    PRIMARY KEY (\"\"Id\"\"),\n    UNIQUE (\"\"SSN\"\"),\n    FOREIGN KEY (\"\"EmployerId\"\") REFERENCES \"\"Companies\"\" (\"\"Id\"\") ON UPDATE NO ACTION ON DELETE NO ACTION\n);\";\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(3, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(expectedCreateTable), batch[0].CommandText);\n\t\tStringAssert.Contains(\"rdb$generator_name = \", batch[1].CommandText);\n\t\tStringAssert.StartsWith(\"CREATE TRIGGER \", batch[2].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task CreateTableScript()\n\t{\n\t\tvar operation = new CreateTableOperation\n\t\t{\n\t\t\tName = \"People\",\n\t\t\tColumns =\n\t\t\t\t{\n\t\t\t\t\t\tnew AddColumnOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"Id\",\n\t\t\t\t\t\t\tTable = \"People\",\n\t\t\t\t\t\t\tClrType = typeof(int),\n\t\t\t\t\t\t\tIsNullable = false,\n\t\t\t\t\t\t\t[FbAnnotationNames.ValueGenerationStrategy] = FbValueGenerationStrategy.None,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnew AddColumnOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"Id_Identity\",\n\t\t\t\t\t\t\tTable = \"People\",\n\t\t\t\t\t\t\tClrType = typeof(int),\n\t\t\t\t\t\t\tIsNullable = false,\n\t\t\t\t\t\t\t[FbAnnotationNames.ValueGenerationStrategy] = FbValueGenerationStrategy.IdentityColumn,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnew AddColumnOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"Id_Sequence\",\n\t\t\t\t\t\t\tTable = \"People\",\n\t\t\t\t\t\t\tClrType = typeof(int),\n\t\t\t\t\t\t\tIsNullable = false,\n\t\t\t\t\t\t\t[FbAnnotationNames.ValueGenerationStrategy] = FbValueGenerationStrategy.SequenceTrigger,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnew AddColumnOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"EmployerId\",\n\t\t\t\t\t\t\tTable = \"People\",\n\t\t\t\t\t\t\tClrType = typeof(int),\n\t\t\t\t\t\t\tIsNullable = true,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnew AddColumnOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"SSN\",\n\t\t\t\t\t\t\tTable = \"People\",\n\t\t\t\t\t\t\tClrType = typeof(string),\n\t\t\t\t\t\t\tColumnType = \"char(11)\",\n\t\t\t\t\t\t\tIsNullable = true,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnew AddColumnOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"DEF_O\",\n\t\t\t\t\t\t\tTable = \"People\",\n\t\t\t\t\t\t\tClrType = typeof(string),\n\t\t\t\t\t\t\tMaxLength = 20,\n\t\t\t\t\t\t\tDefaultValue = \"test\",\n\t\t\t\t\t\t\tIsNullable = true,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnew AddColumnOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"DEF_S\",\n\t\t\t\t\t\t\tTable = \"People\",\n\t\t\t\t\t\t\tClrType = typeof(string),\n\t\t\t\t\t\t\tMaxLength = 20,\n\t\t\t\t\t\t\tDefaultValueSql = \"'x'\",\n\t\t\t\t\t\t\tIsNullable = true,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnew AddColumnOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tName = \"COLLA\",\n\t\t\t\t\t\t\tTable = \"People\",\n\t\t\t\t\t\t\tClrType = typeof(string),\n\t\t\t\t\t\t\tMaxLength = 20,\n\t\t\t\t\t\t\tIsNullable = true,\n\t\t\t\t\t\t\tCollation = \"UNICODE_CI_AI\"\n\t\t\t\t\t\t},\n\t\t\t\t},\n\t\t\tPrimaryKey = new AddPrimaryKeyOperation\n\t\t\t{\n\t\t\t\tColumns = new[] { \"Id\" },\n\t\t\t},\n\t\t\tUniqueConstraints =\n\t\t\t\t{\n\t\t\t\t\t\tnew AddUniqueConstraintOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tColumns = new[] { \"SSN\" },\n\t\t\t\t\t\t},\n\t\t\t\t},\n\t\t\tForeignKeys =\n\t\t\t\t{\n\t\t\t\t\t\tnew AddForeignKeyOperation\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tColumns = new[] { \"EmployerId\" },\n\t\t\t\t\t\t\tPrincipalTable = \"Companies\",\n\t\t\t\t\t\t\tPrincipalColumns = new[] { \"Id\" },\n\t\t\t\t\t\t},\n\t\t\t\t},\n\t\t};\n\t\tvar expectedCreateTable = @\"CREATE TABLE \"\"People\"\" (\n    \"\"Id\"\" INTEGER NOT NULL,\n    \"\"Id_Identity\"\" INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL,\n    \"\"Id_Sequence\"\" INTEGER NOT NULL,\n    \"\"EmployerId\"\" INTEGER,\n    \"\"SSN\"\" char(11),\n    \"\"DEF_O\"\" VARCHAR(20) DEFAULT _UTF8'test',\n    \"\"DEF_S\"\" VARCHAR(20) DEFAULT 'x',\n    \"\"COLLA\"\" VARCHAR(20) COLLATE UNICODE_CI_AI,\n    PRIMARY KEY (\"\"Id\"\"),\n    UNIQUE (\"\"SSN\"\"),\n    FOREIGN KEY (\"\"EmployerId\"\") REFERENCES \"\"Companies\"\" (\"\"Id\"\") ON UPDATE NO ACTION ON DELETE NO ACTION\n);\";\n\t\tvar batch = await Generate(new[] { operation }, MigrationsSqlGenerationOptions.Script);\n\t\tAssert.AreEqual(5, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(expectedCreateTable), batch[0].CommandText);\n\t\tAssert.AreEqual(NewLineEnd(\"SET TERM ~;\"), batch[1].CommandText);\n\t\tStringAssert.Contains(\"rdb$generator_name = \", batch[2].CommandText);\n\t\tStringAssert.StartsWith(\"CREATE TRIGGER \", batch[3].CommandText);\n\t\tAssert.AreEqual(NewLineEnd(\"SET TERM ;~\"), batch[4].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task DropTable()\n\t{\n\t\tvar operation = new DropTableOperation()\n\t\t{\n\t\t\tName = \"People\",\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"DROP TABLE \"\"People\"\";\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddColumn()\n\t{\n\t\tvar operation = new AddColumnOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"NewColumn\",\n\t\t\tClrType = typeof(decimal),\n\t\t\tSchema = \"schema\",\n\t\t\tIsNullable = false,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"schema\"\".\"\"People\"\" ADD \"\"NewColumn\"\" DECIMAL(18,2) NOT NULL;\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddColumnWithCollation()\n\t{\n\t\tvar operation = new AddColumnOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"NewColumn\",\n\t\t\tClrType = typeof(string),\n\t\t\tMaxLength = 10,\n\t\t\tIsNullable = false,\n\t\t\tCollation = \"UNICODE_CI_AI\",\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD \"\"NewColumn\"\" VARCHAR(10) COLLATE UNICODE_CI_AI NOT NULL;\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task DropColumn()\n\t{\n\t\tvar operation = new DropColumnOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"DropMe\",\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" DROP \"\"DropMe\"\";\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AlterColumnLength()\n\t{\n\t\tvar operation = new AlterColumnOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"Col\",\n\t\t\tClrType = typeof(string),\n\t\t\tIsNullable = true,\n\t\t\tMaxLength = 200,\n\t\t\tOldColumn = new AddColumnOperation()\n\t\t\t{\n\t\t\t\tClrType = typeof(string),\n\t\t\t\tIsNullable = true,\n\t\t\t\tMaxLength = 100,\n\t\t\t},\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(2, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ALTER COLUMN \"\"Col\"\" TYPE VARCHAR(200);\"), batch[1].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AlterColumnNullableToNotNull()\n\t{\n\t\tvar operation = new AlterColumnOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"Col\",\n\t\t\tClrType = typeof(string),\n\t\t\tIsNullable = false,\n\t\t\tMaxLength = 100,\n\t\t\tOldColumn = new AddColumnOperation()\n\t\t\t{\n\t\t\t\tClrType = typeof(string),\n\t\t\t\tIsNullable = true,\n\t\t\t\tMaxLength = 100,\n\t\t\t},\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(3, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ALTER COLUMN \"\"Col\"\" DROP NOT NULL;\"), batch[0].CommandText);\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ALTER COLUMN \"\"Col\"\" TYPE VARCHAR(100);\"), batch[1].CommandText);\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ALTER COLUMN \"\"Col\"\" SET NOT NULL;\"), batch[2].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AlterColumnNotNullToNullable()\n\t{\n\t\tvar operation = new AlterColumnOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"Col\",\n\t\t\tClrType = typeof(string),\n\t\t\tIsNullable = true,\n\t\t\tMaxLength = 100,\n\t\t\tOldColumn = new AddColumnOperation()\n\t\t\t{\n\t\t\t\tClrType = typeof(string),\n\t\t\t\tIsNullable = false,\n\t\t\t\tMaxLength = 100,\n\t\t\t},\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(2, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ALTER COLUMN \"\"Col\"\" DROP NOT NULL;\"), batch[0].CommandText);\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ALTER COLUMN \"\"Col\"\" TYPE VARCHAR(100);\"), batch[1].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AlterColumnType()\n\t{\n\t\tvar operation = new AlterColumnOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"Col\",\n\t\t\tClrType = typeof(long),\n\t\t\tIsNullable = false,\n\t\t\tOldColumn = new AddColumnOperation()\n\t\t\t{\n\t\t\t\tClrType = typeof(int),\n\t\t\t\tIsNullable = false,\n\t\t\t},\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(3, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ALTER COLUMN \"\"Col\"\" TYPE BIGINT;\"), batch[1].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AlterColumnDefault()\n\t{\n\t\tvar operation = new AlterColumnOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"Col\",\n\t\t\tClrType = typeof(int),\n\t\t\tDefaultValue = 20,\n\t\t\tOldColumn = new AddColumnOperation()\n\t\t\t{\n\t\t\t\tClrType = typeof(int),\n\t\t\t\tDefaultValue = 10,\n\t\t\t},\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(5, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ALTER COLUMN \"\"Col\"\" TYPE INTEGER;\"), batch[1].CommandText);\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ALTER COLUMN \"\"Col\"\" DROP DEFAULT;\"), batch[3].CommandText);\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ALTER COLUMN \"\"Col\"\" SET DEFAULT 20;\"), batch[4].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AlterColumnAddIdentityColumn()\n\t{\n\t\tvar operation = new AlterColumnOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"Col\",\n\t\t\tClrType = typeof(int),\n\t\t\t[FbAnnotationNames.ValueGenerationStrategy] = FbValueGenerationStrategy.IdentityColumn,\n\t\t\tOldColumn = new AddColumnOperation()\n\t\t\t{\n\t\t\t\tClrType = typeof(int),\n\t\t\t},\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(3, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ALTER COLUMN \"\"Col\"\" TYPE INTEGER GENERATED BY DEFAULT AS IDENTITY;\"), batch[1].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AlterColumnAddSequenceTrigger()\n\t{\n\t\tvar operation = new AlterColumnOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"Col\",\n\t\t\tClrType = typeof(int),\n\t\t\t[FbAnnotationNames.ValueGenerationStrategy] = FbValueGenerationStrategy.SequenceTrigger,\n\t\t\tOldColumn = new AddColumnOperation()\n\t\t\t{\n\t\t\t\tClrType = typeof(int),\n\t\t\t},\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(5, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ALTER COLUMN \"\"Col\"\" TYPE INTEGER;\"), batch[1].CommandText);\n\t\tStringAssert.Contains(\"rdb$generator_name = \", batch[3].CommandText);\n\t\tStringAssert.StartsWith(\"CREATE TRIGGER \", batch[4].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AlterColumnRemoveSequenceTrigger()\n\t{\n\t\tvar operation = new AlterColumnOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"Col\",\n\t\t\tClrType = typeof(int),\n\t\t\tOldColumn = new AddColumnOperation()\n\t\t\t{\n\t\t\t\tClrType = typeof(int),\n\t\t\t\t[FbAnnotationNames.ValueGenerationStrategy] = FbValueGenerationStrategy.SequenceTrigger,\n\t\t\t},\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(4, batch.Count());\n\t\tStringAssert.Contains(\"drop trigger\", batch[0].CommandText);\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ALTER COLUMN \"\"Col\"\" TYPE INTEGER;\"), batch[2].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AlterColumnCollation()\n\t{\n\t\tvar operation = new AlterColumnOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"Col\",\n\t\t\tClrType = typeof(string),\n\t\t\tMaxLength = 10,\n\t\t\tIsNullable = false,\n\t\t\tCollation = \"UNICODE_CI_AI\",\n\t\t\tOldColumn = new AddColumnOperation()\n\t\t\t{\n\t\t\t\tClrType = typeof(string),\n\t\t\t\tMaxLength = 10,\n\t\t\t\tIsNullable = false,\n\t\t\t},\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(3, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ALTER COLUMN \"\"Col\"\" TYPE VARCHAR(10) COLLATE UNICODE_CI_AI;\"), batch[1].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task RenameColumn()\n\t{\n\t\tvar operation = new RenameColumnOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"OldCol\",\n\t\t\tNewName = \"NewCol\",\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ALTER COLUMN \"\"OldCol\"\" TO \"\"NewCol\"\";\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task CreateIndexOneColumn()\n\t{\n\t\tvar operation = new CreateIndexOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"MyIndex\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"CREATE INDEX \"\"MyIndex\"\" ON \"\"People\"\" (\"\"Foo\"\");\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task CreateIndexThreeColumn()\n\t{\n\t\tvar operation = new CreateIndexOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"MyIndex\",\n\t\t\tColumns = new[] { \"Foo\", \"Bar\", \"Baz\" },\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"CREATE INDEX \"\"MyIndex\"\" ON \"\"People\"\" (\"\"Foo\"\", \"\"Bar\"\", \"\"Baz\"\");\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task CreateIndexUnique()\n\t{\n\t\tvar operation = new CreateIndexOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"MyIndex\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t\tIsUnique = true,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"CREATE UNIQUE INDEX \"\"MyIndex\"\" ON \"\"People\"\" (\"\"Foo\"\");\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task CreateIndexFilter()\n\t{\n\t\tvar operation = new CreateIndexOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"MyIndex\",\n\t\t\tFilter = \"xxx\",\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"CREATE INDEX \"\"MyIndex\"\" ON \"\"People\"\" COMPUTED BY (xxx);\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task CreateSequence()\n\t{\n\t\tvar operation = new CreateSequenceOperation()\n\t\t{\n\t\t\tName = \"MySequence\",\n\t\t\tStartValue = 34,\n\t\t\tIncrementBy = 56,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"CREATE SEQUENCE \"\"MySequence\"\" START WITH 34 INCREMENT BY 56;\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AlterSequence()\n\t{\n\t\tvar operation = new AlterSequenceOperation()\n\t\t{\n\t\t\tName = \"MySequence\",\n\t\t\tIncrementBy = 12,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER SEQUENCE \"\"MySequence\"\" RESTART INCREMENT BY 12;\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task RestartSequence()\n\t{\n\t\tvar operation = new RestartSequenceOperation()\n\t\t{\n\t\t\tName = \"MySequence\",\n\t\t\tStartValue = 23,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER SEQUENCE \"\"MySequence\"\" RESTART WITH 23;\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task RestartSequenceNoValue()\n\t{\n\t\tvar operation = new RestartSequenceOperation()\n\t\t{\n\t\t\tName = \"MySequence\",\n\t\t\tStartValue = null,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER SEQUENCE \"\"MySequence\"\" RESTART;\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task DropSequence()\n\t{\n\t\tvar operation = new DropSequenceOperation()\n\t\t{\n\t\t\tName = \"MySequence\",\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"DROP SEQUENCE \"\"MySequence\"\";\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddPrimaryKey()\n\t{\n\t\tvar operation = new AddPrimaryKeyOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"PK_People\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD CONSTRAINT \"\"PK_People\"\" PRIMARY KEY (\"\"Foo\"\");\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddPrimaryKeyNoName()\n\t{\n\t\tvar operation = new AddPrimaryKeyOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD PRIMARY KEY (\"\"Foo\"\");\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task DropPrimaryKey()\n\t{\n\t\tvar operation = new DropPrimaryKeyOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"PK_People\",\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" DROP CONSTRAINT \"\"PK_People\"\";\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddForeignKey()\n\t{\n\t\tvar operation = new AddForeignKeyOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"FK_People_Principal\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t\tPrincipalTable = \"Principal\",\n\t\t\tPrincipalColumns = new[] { \"Bar\" },\n\t\t\tOnDelete = ReferentialAction.Restrict,\n\t\t\tOnUpdate = ReferentialAction.Restrict,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD CONSTRAINT \"\"FK_People_Principal\"\" FOREIGN KEY (\"\"Foo\"\") REFERENCES \"\"Principal\"\" (\"\"Bar\"\");\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddForeignKeyNoName()\n\t{\n\t\tvar operation = new AddForeignKeyOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t\tPrincipalTable = \"Principal\",\n\t\t\tPrincipalColumns = new[] { \"Bar\" },\n\t\t\tOnDelete = ReferentialAction.Restrict,\n\t\t\tOnUpdate = ReferentialAction.Restrict,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD FOREIGN KEY (\"\"Foo\"\") REFERENCES \"\"Principal\"\" (\"\"Bar\"\");\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddForeignKeyDeleteCascade()\n\t{\n\t\tvar operation = new AddForeignKeyOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"FK_People_Principal\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t\tPrincipalTable = \"Principal\",\n\t\t\tPrincipalColumns = new[] { \"Bar\" },\n\t\t\tOnDelete = ReferentialAction.Cascade,\n\t\t\tOnUpdate = ReferentialAction.Restrict,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD CONSTRAINT \"\"FK_People_Principal\"\" FOREIGN KEY (\"\"Foo\"\") REFERENCES \"\"Principal\"\" (\"\"Bar\"\") ON DELETE CASCADE;\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddForeignKeyDeleteNoAction()\n\t{\n\t\tvar operation = new AddForeignKeyOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"FK_People_Principal\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t\tPrincipalTable = \"Principal\",\n\t\t\tPrincipalColumns = new[] { \"Bar\" },\n\t\t\tOnDelete = ReferentialAction.NoAction,\n\t\t\tOnUpdate = ReferentialAction.Restrict,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD CONSTRAINT \"\"FK_People_Principal\"\" FOREIGN KEY (\"\"Foo\"\") REFERENCES \"\"Principal\"\" (\"\"Bar\"\") ON DELETE NO ACTION;\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddForeignKeyDeleteRestrict()\n\t{\n\t\tvar operation = new AddForeignKeyOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"FK_People_Principal\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t\tPrincipalTable = \"Principal\",\n\t\t\tPrincipalColumns = new[] { \"Bar\" },\n\t\t\tOnDelete = ReferentialAction.Restrict,\n\t\t\tOnUpdate = ReferentialAction.Restrict,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD CONSTRAINT \"\"FK_People_Principal\"\" FOREIGN KEY (\"\"Foo\"\") REFERENCES \"\"Principal\"\" (\"\"Bar\"\");\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddForeignKeyDeleteSetDefault()\n\t{\n\t\tvar operation = new AddForeignKeyOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"FK_People_Principal\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t\tPrincipalTable = \"Principal\",\n\t\t\tPrincipalColumns = new[] { \"Bar\" },\n\t\t\tOnDelete = ReferentialAction.SetDefault,\n\t\t\tOnUpdate = ReferentialAction.Restrict,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD CONSTRAINT \"\"FK_People_Principal\"\" FOREIGN KEY (\"\"Foo\"\") REFERENCES \"\"Principal\"\" (\"\"Bar\"\") ON DELETE SET DEFAULT;\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddForeignKeyDeleteSetNull()\n\t{\n\t\tvar operation = new AddForeignKeyOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"FK_People_Principal\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t\tPrincipalTable = \"Principal\",\n\t\t\tPrincipalColumns = new[] { \"Bar\" },\n\t\t\tOnDelete = ReferentialAction.SetNull,\n\t\t\tOnUpdate = ReferentialAction.Restrict,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD CONSTRAINT \"\"FK_People_Principal\"\" FOREIGN KEY (\"\"Foo\"\") REFERENCES \"\"Principal\"\" (\"\"Bar\"\") ON DELETE SET NULL;\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddForeignKeyUpdateCascade()\n\t{\n\t\tvar operation = new AddForeignKeyOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"FK_People_Principal\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t\tPrincipalTable = \"Principal\",\n\t\t\tPrincipalColumns = new[] { \"Bar\" },\n\t\t\tOnDelete = ReferentialAction.Restrict,\n\t\t\tOnUpdate = ReferentialAction.Cascade,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD CONSTRAINT \"\"FK_People_Principal\"\" FOREIGN KEY (\"\"Foo\"\") REFERENCES \"\"Principal\"\" (\"\"Bar\"\") ON UPDATE CASCADE;\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddForeignKeyUpdateNoAction()\n\t{\n\t\tvar operation = new AddForeignKeyOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"FK_People_Principal\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t\tPrincipalTable = \"Principal\",\n\t\t\tPrincipalColumns = new[] { \"Bar\" },\n\t\t\tOnDelete = ReferentialAction.Restrict,\n\t\t\tOnUpdate = ReferentialAction.NoAction,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD CONSTRAINT \"\"FK_People_Principal\"\" FOREIGN KEY (\"\"Foo\"\") REFERENCES \"\"Principal\"\" (\"\"Bar\"\") ON UPDATE NO ACTION;\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddForeignKeyUpdateRestrict()\n\t{\n\t\tvar operation = new AddForeignKeyOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"FK_People_Principal\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t\tPrincipalTable = \"Principal\",\n\t\t\tPrincipalColumns = new[] { \"Bar\" },\n\t\t\tOnDelete = ReferentialAction.Restrict,\n\t\t\tOnUpdate = ReferentialAction.Restrict,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD CONSTRAINT \"\"FK_People_Principal\"\" FOREIGN KEY (\"\"Foo\"\") REFERENCES \"\"Principal\"\" (\"\"Bar\"\");\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddForeignKeyUpdateSetDefault()\n\t{\n\t\tvar operation = new AddForeignKeyOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"FK_People_Principal\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t\tPrincipalTable = \"Principal\",\n\t\t\tPrincipalColumns = new[] { \"Bar\" },\n\t\t\tOnDelete = ReferentialAction.Restrict,\n\t\t\tOnUpdate = ReferentialAction.SetDefault,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD CONSTRAINT \"\"FK_People_Principal\"\" FOREIGN KEY (\"\"Foo\"\") REFERENCES \"\"Principal\"\" (\"\"Bar\"\") ON UPDATE SET DEFAULT;\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddForeignKeyUpdateSetNull()\n\t{\n\t\tvar operation = new AddForeignKeyOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"FK_People_Principal\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t\tPrincipalTable = \"Principal\",\n\t\t\tPrincipalColumns = new[] { \"Bar\" },\n\t\t\tOnDelete = ReferentialAction.Restrict,\n\t\t\tOnUpdate = ReferentialAction.SetNull,\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD CONSTRAINT \"\"FK_People_Principal\"\" FOREIGN KEY (\"\"Foo\"\") REFERENCES \"\"Principal\"\" (\"\"Bar\"\") ON UPDATE SET NULL;\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task DropForeignKey()\n\t{\n\t\tvar operation = new DropForeignKeyOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"FK_People_Principal\",\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" DROP CONSTRAINT \"\"FK_People_Principal\"\";\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddUniqueConstraintOneColumn()\n\t{\n\t\tvar operation = new AddUniqueConstraintOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"UNQ_People_Foo\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD CONSTRAINT \"\"UNQ_People_Foo\"\" UNIQUE (\"\"Foo\"\");\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddUniqueConstraintTwoColumns()\n\t{\n\t\tvar operation = new AddUniqueConstraintOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"UNQ_People_Foo_Bar\",\n\t\t\tColumns = new[] { \"Foo\", \"Bar\" },\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD CONSTRAINT \"\"UNQ_People_Foo_Bar\"\" UNIQUE (\"\"Foo\"\", \"\"Bar\"\");\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task AddUniqueConstraintNoName()\n\t{\n\t\tvar operation = new AddUniqueConstraintOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tColumns = new[] { \"Foo\" },\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" ADD UNIQUE (\"\"Foo\"\");\"), batch[0].CommandText);\n\t}\n\n\t[Test]\n\tpublic async Task DropUniqueConstraint()\n\t{\n\t\tvar operation = new DropUniqueConstraintOperation()\n\t\t{\n\t\t\tTable = \"People\",\n\t\t\tName = \"UNQ_People_Foo\",\n\t\t};\n\t\tvar batch = await Generate(new[] { operation });\n\t\tAssert.AreEqual(1, batch.Count());\n\t\tAssert.AreEqual(NewLineEnd(@\"ALTER TABLE \"\"People\"\" DROP CONSTRAINT \"\"UNQ_People_Foo\"\";\"), batch[0].CommandText);\n\t}\n\n\tasync Task<IReadOnlyList<MigrationCommand>> Generate(IReadOnlyList<MigrationOperation> operations, MigrationsSqlGenerationOptions options = MigrationsSqlGenerationOptions.Default)\n\t{\n\t\tawait using (var db = await GetDbContext<FbTestDbContext>())\n\t\t{\n\t\t\tvar generator = db.GetService<IMigrationsSqlGenerator>();\n\t\t\treturn generator.Generate(operations, db.Model, options);\n\t\t}\n\t}\n\n\tstatic string NewLineEnd(string s) => s + Environment.NewLine;\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.Tests/Query/ElementaryTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Data.Common;\nusing System.Linq;\nusing System.Threading;\nusing System.Threading.Tasks;\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Diagnostics;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Tests.Query;\n\npublic class ElementaryTests : EntityFrameworkCoreTestsBase\n{\n\t[Test]\n\tpublic async Task SimpleSelect()\n\t{\n\t\tawait using (var db = await GetDbContext<SelectContext>())\n\t\t{\n\t\t\tvar data = await db.Set<MonAttachment>().ToListAsync();\n\t\t\tAssert.IsNotEmpty(data);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectWithWhere()\n\t{\n\t\tawait using (var db = await GetDbContext<SelectContext>())\n\t\t{\n\t\t\tvar query = db.Set<MonAttachment>()\n\t\t\t\t.Where(x => x.AttachmentName.Trim() != string.Empty);\n\t\t\tAssert.DoesNotThrowAsync(() => query.LoadAsync());\n\t\t\tvar sql = db.LastCommandText;\n\t\t\tStringAssert.Contains(\"TRIM(\", sql);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectWithWhereExtract()\n\t{\n\t\tawait using (var db = await GetDbContext<SelectContext>())\n\t\t{\n\t\t\tvar query = db.Set<MonAttachment>()\n\t\t\t\t.Where(x => x.Timestamp.Second > -1 && x.Timestamp.DayOfYear == 1);\n\t\t\tAssert.DoesNotThrowAsync(() => query.LoadAsync());\n\t\t\tvar sql = db.LastCommandText;\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectWithWhereSubstring()\n\t{\n\t\tawait using (var db = await GetDbContext<SelectContext>())\n\t\t{\n\t\t\tvar query = db.Set<MonAttachment>()\n\t\t\t\t.Where(x => x.AttachmentName.Substring(1) == string.Empty && x.AttachmentName.Substring(1, 1) == string.Empty || x.AttachmentName.Substring(x.AttachmentId) != string.Empty || x.AttachmentName.Substring(x.AttachmentId, x.AttachmentId) != string.Empty);\n\t\t\tAssert.DoesNotThrowAsync(() => query.LoadAsync());\n\t\t\tvar sql = db.LastCommandText;\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectWithWhereDateMember()\n\t{\n\t\tawait using (var db = await GetDbContext<SelectContext>())\n\t\t{\n\t\t\tvar query = db.Set<MonAttachment>()\n\t\t\t\t.Where(x => x.Timestamp.Date == DateTime.Now.Date);\n\t\t\tAssert.DoesNotThrowAsync(() => query.LoadAsync());\n\t\t\tvar sql = db.LastCommandText;\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectWithNewGuid()\n\t{\n\t\tawait using (var db = await GetDbContext<SelectContext>())\n\t\t{\n\t\t\tvar query = db.Set<MonAttachment>()\n\t\t\t\t.Where(x => x.AttachmentName == Guid.NewGuid().ToString());\n\t\t\tAssert.DoesNotThrowAsync(() => query.LoadAsync());\n\t\t\tvar sql = db.LastCommandText;\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectTake()\n\t{\n\t\tawait using (var db = await GetDbContext<SelectContext>())\n\t\t{\n\t\t\tvar query = db.Set<MonAttachment>()\n\t\t\t\t.Take(3);\n\t\t\tAssert.DoesNotThrowAsync(() => query.LoadAsync());\n\t\t\tvar sql = db.LastCommandText;\n\t\t\tStringAssert.IsMatch(@\"ROWS \\(.+\\)\", sql);\n\t\t\tStringAssert.DoesNotMatch(@\" TO \\(\", sql);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectSkipTake()\n\t{\n\t\tawait using (var db = await GetDbContext<SelectContext>())\n\t\t{\n\t\t\tvar query = db.Set<MonAttachment>()\n\t\t\t\t.Skip(1)\n\t\t\t\t.Take(3);\n\t\t\tAssert.DoesNotThrowAsync(() => query.LoadAsync());\n\t\t\tvar sql = db.LastCommandText;\n\t\t\tStringAssert.IsMatch(@\"ROWS \\((.+) \\+ 1\\) TO \\(\\1 \\+ .+\\)\", sql);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectSkip()\n\t{\n\t\tawait using (var db = await GetDbContext<SelectContext>())\n\t\t{\n\t\t\tvar query = db.Set<MonAttachment>()\n\t\t\t\t.Skip(1);\n\t\t\tAssert.DoesNotThrowAsync(() => query.LoadAsync());\n\t\t\tvar sql = db.LastCommandText;\n\t\t\tStringAssert.IsMatch(@\"ROWS \\(.+ \\+ 1\\) TO \\(9223372036854775807\\)\", sql);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectTopLevelAny()\n\t{\n\t\tawait using (var db = await GetDbContext<SelectContext>())\n\t\t{\n\t\t\tAssert.DoesNotThrowAsync(() => db.Set<MonAttachment>().AnyAsync(x => x.AttachmentId != 0));\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectableProcedureSimple()\n\t{\n\t\tawait using (var db = await GetDbContext<SelectContext>())\n\t\t{\n\t\t\tdb.CreateProcedures();\n\t\t\tvar query = db.Set<SelectableProcedure>();\n\t\t\tAssert.DoesNotThrowAsync(() => query.LoadAsync());\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectableProcedureWithTable()\n\t{\n\t\tawait using (var db = await GetDbContext<SelectContext>())\n\t\t{\n\t\t\tdb.CreateProcedures();\n\t\t\tvar query = db.Set<MonAttachment>()\n\t\t\t\t.Where(x => db.Set<SelectableProcedure>().Select(y => y.Value).Contains(x.AttachmentId));\n\t\t\tAssert.DoesNotThrowAsync(() => query.LoadAsync());\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectableProcedureWithParam()\n\t{\n\t\tawait using (var db = await GetDbContext<SelectContext>())\n\t\t{\n\t\t\tdb.CreateProcedures();\n\t\t\tvar query = db.SelectableProcedureWithParam(10).Where(x => x.Value > 10);\n\t\t\tAssert.DoesNotThrowAsync(() => query.LoadAsync());\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectStartsWithConstant()\n\t{\n\t\tawait using (var db = await GetDbContext<SelectContext>())\n\t\t{\n\t\t\tvar query = db.Set<MonAttachment>()\n\t\t\t\t.Where(x => x.AttachmentName.StartsWith(\"Jiri\"));\n\t\t\tAssert.DoesNotThrowAsync(() => query.LoadAsync());\n\t\t\tvar sql = db.LastCommandText;\n\t\t\tStringAssert.Contains(\"'Jiri%'\", sql);\n\t\t}\n\t}\n\n\t[Test]\n\tpublic async Task SelectWithCollate()\n\t{\n\t\tawait using (var db = await GetDbContext<SelectContext>())\n\t\t{\n\t\t\tvar query = db.Set<MonAttachment>()\n\t\t\t\t.Where(x => x.AttachmentName == EF.Functions.Collate(\"test\", \"UNICODE_CI_AI\"));\n\t\t\tAssert.DoesNotThrowAsync(() => query.LoadAsync());\n\t\t\tvar sql = db.LastCommandText;\n\t\t\tStringAssert.Contains(@\"CAST(_UTF8'test' AS VARCHAR(4) CHARACTER SET UTF8) COLLATE UNICODE_CI_AI\", sql);\n\t\t}\n\t}\n}\n\nclass SelectContext : FbTestDbContext\n{\n\tclass LastCommandTextCommandInterceptor : DbCommandInterceptor\n\t{\n\t\tpublic string LastCommandText { get; private set; }\n\n\t\tpublic override int NonQueryExecuted(DbCommand command, CommandExecutedEventData eventData, int result)\n\t\t{\n\t\t\tLastCommandText = command.CommandText;\n\t\t\treturn base.NonQueryExecuted(command, eventData, result);\n\t\t}\n\n\t\tpublic override ValueTask<int> NonQueryExecutedAsync(DbCommand command, CommandExecutedEventData eventData, int result, CancellationToken cancellationToken = default)\n\t\t{\n\t\t\tLastCommandText = command.CommandText;\n\t\t\treturn base.NonQueryExecutedAsync(command, eventData, result, cancellationToken);\n\t\t}\n\n\t\tpublic override DbDataReader ReaderExecuted(DbCommand command, CommandExecutedEventData eventData, DbDataReader result)\n\t\t{\n\t\t\tLastCommandText = command.CommandText;\n\t\t\treturn base.ReaderExecuted(command, eventData, result);\n\t\t}\n\n\t\tpublic override ValueTask<DbDataReader> ReaderExecutedAsync(DbCommand command, CommandExecutedEventData eventData, DbDataReader result, CancellationToken cancellationToken = default)\n\t\t{\n\t\t\tLastCommandText = command.CommandText;\n\t\t\treturn base.ReaderExecutedAsync(command, eventData, result, cancellationToken);\n\t\t}\n\n\t\tpublic override object ScalarExecuted(DbCommand command, CommandExecutedEventData eventData, object result)\n\t\t{\n\t\t\tLastCommandText = command.CommandText;\n\t\t\treturn base.ScalarExecuted(command, eventData, result);\n\t\t}\n\n\t\tpublic override ValueTask<object> ScalarExecutedAsync(DbCommand command, CommandExecutedEventData eventData, object result, CancellationToken cancellationToken = default)\n\t\t{\n\t\t\tLastCommandText = command.CommandText;\n\t\t\treturn base.ScalarExecutedAsync(command, eventData, result, cancellationToken);\n\t\t}\n\t}\n\n\tLastCommandTextCommandInterceptor _lastCommandTextInterceptor;\n\n\tpublic SelectContext(string connectionString)\n\t\t: base(connectionString)\n\t{\n\t\t_lastCommandTextInterceptor = new LastCommandTextCommandInterceptor();\n\t}\n\n\tprotected override void OnTestModelCreating(ModelBuilder modelBuilder)\n\t{\n\t\tbase.OnTestModelCreating(modelBuilder);\n\n\t\tvar monAttachmentConf = modelBuilder.Entity<MonAttachment>();\n\t\tmonAttachmentConf.HasKey(x => x.AttachmentId);\n\t\tmonAttachmentConf.Property(x => x.AttachmentId).HasColumnName(\"MON$ATTACHMENT_ID\");\n\t\tmonAttachmentConf.Property(x => x.AttachmentName).HasColumnName(\"MON$ATTACHMENT_NAME\");\n\t\tmonAttachmentConf.Property(x => x.Timestamp).HasColumnName(\"MON$TIMESTAMP\");\n\t\tmonAttachmentConf.ToTable(\"MON$ATTACHMENTS\");\n\n\t\tvar selectableProcedureConf = modelBuilder.Entity<SelectableProcedure>();\n\t\tselectableProcedureConf.HasNoKey();\n\t\tselectableProcedureConf.Property(x => x.Value).HasColumnName(\"VAL\");\n\t\tselectableProcedureConf.ToFunction(\"SELECTABLE_PROCEDURE\");\n\n\t\tvar selectableProcedureWithParamConf = modelBuilder.Entity<SelectableProcedureWithParam>();\n\t\tselectableProcedureWithParamConf.HasNoKey();\n\t\tselectableProcedureWithParamConf.Property(x => x.Value).HasColumnName(\"VAL\");\n\t\tmodelBuilder.HasDbFunction(typeof(SelectContext).GetMethod(nameof(SelectableProcedureWithParam)),\n\t\t\tc => c.HasName(\"SELECTABLE_PROCEDURE\"));\n\n\t}\n\n\tprotected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)\n\t{\n\t\tbase.OnConfiguring(optionsBuilder);\n\n\n\t\toptionsBuilder.AddInterceptors(_lastCommandTextInterceptor);\n\t}\n\n\tpublic string LastCommandText => _lastCommandTextInterceptor.LastCommandText;\n\n\tpublic IQueryable<SelectableProcedureWithParam> SelectableProcedureWithParam(int i) => FromExpression(() => SelectableProcedureWithParam(i));\n\n\tpublic void CreateProcedures()\n\t{\n\t\tDatabase.ExecuteSqlRaw(\n@\"recreate procedure selectable_procedure (i int = 6)\nreturns (val int)\nas\nbegin\n\tval = i;\n\tsuspend;\n\tval = i + 1;\n\tsuspend;\nend\");\n\t}\n}\n\nclass MonAttachment\n{\n\tpublic int AttachmentId { get; set; }\n\tpublic string AttachmentName { get; set; }\n\tpublic DateTime Timestamp { get; set; }\n}\n\nclass SelectableProcedure\n{\n\tpublic int Value { get; set; }\n}\nclass SelectableProcedureWithParam\n{\n\tpublic int Value { get; set; }\n}\n"
  },
  {
    "path": "src/FirebirdSql.EntityFrameworkCore.Firebird.Tests/Scaffolding/ScaffoldingTests.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing FirebirdSql.Data.FirebirdClient;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Metadata.Internal;\nusing FirebirdSql.EntityFrameworkCore.Firebird.Scaffolding.Internal;\nusing Microsoft.EntityFrameworkCore.Scaffolding;\nusing Microsoft.EntityFrameworkCore.Scaffolding.Metadata;\nusing NUnit.Framework;\n\nnamespace FirebirdSql.EntityFrameworkCore.Firebird.Tests.Scaffolding;\n#pragma warning disable EF1001\npublic class ScaffoldingTests : EntityFrameworkCoreTestsBase\n{\n\tpublic override async Task SetUp()\n\t{\n\t\tawait base.SetUp();\n\n\t\tawait CreateScaffoldingObjectsAsync();\n\t}\n\n\t[Test]\n\tpublic void JustCanRun()\n\t{\n\t\tvar modelFactory = GetModelFactory();\n\t\tAssert.DoesNotThrow(() => modelFactory.Create(Connection, new DatabaseModelFactoryOptions()));\n\t}\n\n\t[Test]\n\tpublic async Task ReadsNullableCorrect()\n\t{\n\t\tvar tableName = \"TEST_READS_IS_NULL_FROM_DOMAIN\";\n\t\tvar columnNameNoDomainNull = \"NO_DOMAIN_NULL\";\n\t\tvar columnNameNoDomainNotNull = \"NO_DOMAIN_NOT_NULL\";\n\t\tvar columnNameDomainNull = \"DOMAIN_NULL\";\n\t\tvar columnNameDomainNotNull = \"DOMAIN_NOT_NUL\";\n\n\t\tusing var commandDomainNull = Connection.CreateCommand();\n\t\tcommandDomainNull.CommandText = \"create domain DOMAIN_NULL as INTEGER\";\n\t\tawait commandDomainNull.ExecuteNonQueryAsync();\n\n\t\tusing var commandDomainNotNull = Connection.CreateCommand();\n\t\tcommandDomainNotNull.CommandText = \"create domain DOMAIN_NOT_NULL as INTEGER NOT NULL\";\n\t\tawait commandDomainNotNull.ExecuteNonQueryAsync();\n\n\t\tusing var commandTable = Connection.CreateCommand();\n\t\tcommandTable.CommandText = $\"create table {tableName} ({columnNameNoDomainNull} INTEGER, {columnNameNoDomainNotNull} INTEGER NOT NULL, {columnNameDomainNull} DOMAIN_NULL, {columnNameDomainNotNull} DOMAIN_NOT_NULL)\";\n\t\tawait commandTable.ExecuteNonQueryAsync();\n\n\t\tvar modelFactory = GetModelFactory();\n\t\tvar model = modelFactory.Create(Connection.ConnectionString, new DatabaseModelFactoryOptions(new string[] { tableName }));\n\t\tvar table = model.Tables.Single(x => x.Name == tableName);\n\t\tvar columnNoDomainNull = table.Columns.Single(x => x.Name == columnNameNoDomainNull);\n\t\tvar columnNoDomainNotNull = table.Columns.Single(x => x.Name == columnNameNoDomainNotNull);\n\t\tvar columnDomainNull = table.Columns.Single(x => x.Name == columnNameDomainNull);\n\t\tvar columnDomainNotNull = table.Columns.Single(x => x.Name == columnNameDomainNotNull);\n\n\t\tAssert.Multiple(() =>\n\t\t{\n\t\t\tAssert.That(columnNoDomainNull.IsNullable, Is.True);\n\t\t\tAssert.That(columnNoDomainNotNull.IsNullable, Is.False);\n\t\t\tAssert.That(columnDomainNull.IsNullable, Is.True);\n\t\t\tAssert.That(columnDomainNotNull.IsNullable, Is.False);\n\t\t});\n\n\t}\n\n\t[TestCase(\"SMALLINT\")]\n\t[TestCase(\"INTEGER\")]\n\t[TestCase(\"FLOAT\")]\n\t[TestCase(\"DATE\")]\n\t[TestCase(\"TIME\")]\n\t[TestCase(\"CHAR(12)\")]\n\t[TestCase(\"BIGINT\")]\n\t[TestCase(\"BOOLEAN\")]\n\t[TestCase(\"DOUBLE PRECISION\")]\n\t[TestCase(\"TIMESTAMP\")]\n\t[TestCase(\"VARCHAR(24)\")]\n\t[TestCase(\"BLOB SUB_TYPE TEXT\")]\n\t[TestCase(\"BLOB SUB_TYPE BINARY\")]\n\t[TestCase(\"DECIMAL(4,1)\")]\n\t[TestCase(\"DECIMAL(9,1)\")]\n\t[TestCase(\"DECIMAL(18,1)\")]\n\t[TestCase(\"NUMERIC(4,1)\")]\n\t[TestCase(\"NUMERIC(9,1)\")]\n\t[TestCase(\"NUMERIC(18,1)\")]\n\tpublic async Task ReadsCorrectFieldType(string dataType)\n\t{\n\t\tvar tableName = $\"TEST_READS_FIELD_TYPE_CORRECT\";\n\t\tvar columnName = \"FIELD\";\n\n\t\tusing var commandTable = Connection.CreateCommand();\n\t\tcommandTable.CommandText = $\"recreate table {tableName} ({columnName} {dataType})\";\n\t\tawait commandTable.ExecuteNonQueryAsync();\n\n\t\tvar modelFactory = GetModelFactory();\n\t\tvar model = modelFactory.Create(Connection.ConnectionString, new DatabaseModelFactoryOptions(new string[] { tableName }));\n\t\tvar table = model.Tables.Single(x => x.Name == tableName);\n\t\tvar column = table.Columns.Single(x => x.Name == columnName);\n\n\t\tAssert.That(column.StoreType, Is.EqualTo(dataType));\n\t}\n\n\t[Test]\n\tpublic void CanScaffoldPrimaryKey()\n\t{\n\t\tvar modelFactory = GetModelFactory();\n\t\tvar databaseModel = modelFactory.Create(Connection, new DatabaseModelFactoryOptions());\n\t\tvar testTable = databaseModel.Tables.Where(t => t.Name.Equals(\"TEST\")).First();\n\n\t\tAssert.NotNull(testTable.PrimaryKey);\n\t\tAssert.AreEqual(\"INT_FIELD\", testTable.PrimaryKey.Columns[0].Name);\n\t}\n\n\t[Test]\n\tpublic void CanScaffoldGeneratedByIdentities()\n\t{\n\t\tvar modelFactory = GetModelFactory();\n\t\tvar databaseModel = modelFactory.Create(Connection, new DatabaseModelFactoryOptions());\n\t\tvar testTable = databaseModel.Tables.Where(t => t.Name == \"SCAFFOLD_TEST\").First();\n\t\tAssert.NotNull(testTable);\n\n\t\tvar idDefaultColumn = testTable.Columns.Where(c => c.Name == \"ID_DEFAULT\").First();\n\t\tAssert.AreEqual(FbIdentityType.GeneratedByDefault, (FbIdentityType)(idDefaultColumn.GetAnnotation(FbAnnotationNames.IdentityType).Value));\n\t\tif (FbTestsSetup.ServerVersionAtLeast(ServerVersion, new Version(4, 0, 0, 0)))\n\t\t{\n\t\t\tAssert.IsNull(idDefaultColumn.FindAnnotation(FbAnnotationNames.IdentityStart));\n\t\t\tAssert.IsNull(idDefaultColumn.FindAnnotation(FbAnnotationNames.IdentityIncrement));\n\n\t\t\tvar testTableFirebird4 = databaseModel.Tables.Where(t => t.Name == \"SCAFFOLD_NEW_FB4_TYPES\").First();\n\t\t\tAssert.NotNull(testTableFirebird4);\n\n\t\t\tvar idAlwaysColumn = testTableFirebird4.Columns.Where(c => c.Name == \"ID_ALWAYS\").First();\n\t\t\tAssert.AreEqual(FbIdentityType.GeneratedAlways, (FbIdentityType)idAlwaysColumn.GetAnnotation(FbAnnotationNames.IdentityType).Value);\n\t\t\tAssert.AreEqual(2, Convert.ToInt32(idAlwaysColumn.GetAnnotation(FbAnnotationNames.IdentityStart).Value));\n\t\t\tAssert.AreEqual(3, Convert.ToInt32(idAlwaysColumn.GetAnnotation(FbAnnotationNames.IdentityIncrement).Value));\n\t\t}\n\t}\n\n\t[Test]\n\tpublic void CanScaffoldColumns()\n\t{\n\t\tvar modelFactory = GetModelFactory();\n\t\tvar databaseModel = modelFactory.Create(Connection, new DatabaseModelFactoryOptions());\n\t\tvar testTable = databaseModel.Tables.Where(t => t.Name == \"TEST\").First();\t\n\t\tAssert.NotNull(testTable);\n\n\t\tvar intColumn = testTable.Columns.Where(c => c.Name == \"INT_FIELD\").First();\n\t\tAssert.AreEqual(\"INTEGER\", intColumn.StoreType);\n\t\tAssert.AreEqual(\"0\", intColumn.DefaultValueSql);\n\t\tAssert.IsNull(intColumn.FindAnnotation(FbAnnotationNames.IdentityType));\n\n\t\tvar charColumn = testTable.Columns.Where(c => c.Name == \"CHAR_FIELD\").First();\n\t\tAssert.AreEqual(\"CHAR(30)\", charColumn.StoreType);\n\n\t\tvar varcharColumn = testTable.Columns.Where(c => c.Name == \"VARCHAR_FIELD\").First();\n\t\tAssert.AreEqual(\"VARCHAR(100)\", varcharColumn.StoreType);\n\n\t\tvar numericColumn = testTable.Columns.Where(c => c.Name == \"NUMERIC_FIELD\").First();\n\t\tAssert.AreEqual(\"NUMERIC(15,2)\", numericColumn.StoreType);\n\n\t\tvar decimalColumn = testTable.Columns.Where(c => c.Name == \"DECIMAL_FIELD\").First();\n\t\tAssert.AreEqual(\"DECIMAL(15,2)\", decimalColumn.StoreType);\n\n\t\tvar blobColumn = testTable.Columns.Where(c => c.Name == \"BLOB_FIELD\").First();\n\t\tAssert.AreEqual(\"BLOB SUB_TYPE BINARY\", blobColumn.StoreType);\n\t\tAssert.AreEqual(80, Convert.ToInt32(blobColumn.GetAnnotation(FbAnnotationNames.BlobSegmentSize).Value));\n\n\t\tvar clobColumn = testTable.Columns.Where(c => c.Name == \"CLOB_FIELD\").First();\n\t\tAssert.AreEqual(\"BLOB SUB_TYPE TEXT\", clobColumn.StoreType);\n\t\tAssert.AreEqual(80, Convert.ToInt32(clobColumn.GetAnnotation(FbAnnotationNames.BlobSegmentSize).Value));\n\n\t\tvar exprColumn = testTable.Columns.Where(c => c.Name == \"EXPR_FIELD\").First();\n\t\tAssert.AreEqual(\"(smallint_field * 1000)\", exprColumn.ComputedColumnSql);\n\n\t\tvar csColumn = testTable.Columns.Where(c => c.Name == \"CS_FIELD\").First();\n\t\tAssert.AreEqual(\"CHAR(1)\", csColumn.StoreType);\n\t\tAssert.AreEqual(\"UNICODE_FSS\", csColumn.Collation);\n\t\tAssert.AreEqual(\"UNICODE_FSS\", csColumn.GetAnnotation(FbAnnotationNames.CharacterSet).Value.ToString());\n\t}\n\n\t[Test]\n\tpublic void CanScaffoldFirebird4DataTypes()\n\t{\n\t\tif (!EnsureServerVersionAtLeast(new Version(4, 0, 0, 0)))\n\t\t\treturn;\n\n\t\tvar modelFactory = GetModelFactory();\n\t\tvar databaseModel = modelFactory.Create(Connection, new DatabaseModelFactoryOptions());\n\t\tvar testTable = databaseModel.Tables.Where(t => t.Name == \"SCAFFOLD_NEW_FB4_TYPES\").First();\n\t\tAssert.NotNull(testTable);\n\n\t\tvar int128Column = testTable.Columns.Where(c => c.Name == \"INT128_FIELD\").First();\n\t\tAssert.AreEqual(\"INT128\", int128Column.StoreType);\n\n\t\tvar decFloat16Column = testTable.Columns.Where(c => c.Name == \"DECFLOAT_16_FIELD\").First();\n\t\tAssert.AreEqual(\"DECFLOAT(16)\", decFloat16Column.StoreType);\n\n\t\tvar decFloat34Column = testTable.Columns.Where(c => c.Name == \"DECFLOAT_34_FIELD\").First();\n\t\tAssert.AreEqual(\"DECFLOAT(34)\", decFloat34Column.StoreType);\n\n\t\tvar timeWithTimeZoneColumn = testTable.Columns.Where(c => c.Name == \"TWTZ_FIELD\").First();\n\t\tAssert.AreEqual(\"TIME WITH TIME ZONE\", timeWithTimeZoneColumn.StoreType);\n\n\t\tvar timestampWithTimeZoneColumn = testTable.Columns.Where(c => c.Name == \"TSWTZ_FIELD\").First();\n\t\tAssert.AreEqual(\"TIMESTAMP WITH TIME ZONE\", timestampWithTimeZoneColumn.StoreType);\n\t}\n\n\tasync Task CreateScaffoldingObjectsAsync()\n\t{\n\t\tawait ExecuteDdlAsync(Connection, \"DROP TABLE SCAFFOLD_NEW_FB4_TYPES\", true);\n\n\t\tawait ExecuteDdlAsync(Connection, \"DROP TABLE SCAFFOLD_TEST\", true);\n\n\t\tif (FbTestsSetup.ServerVersionAtLeast(ServerVersion, new Version(4, 0, 0, 0)))\n\t\t{\n\t\t\tawait ExecuteDdlAsync(Connection, \"\"\"\n\t\t\t\tCREATE TABLE SCAFFOLD_TEST (\n\t\t\t\t\tID_DEFAULT INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1)\n\t\t\t\t)\n\t\t\t\t\"\"\"\n\t\t\t);\n\n\t\t\tawait ExecuteDdlAsync(Connection, \"\"\"\n\t\t\t\tCREATE TABLE SCAFFOLD_NEW_FB4_TYPES (\n\t\t\t\t\tID_ALWAYS INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 2 INCREMENT BY 3),\n\t\t\t\t\tINT128_FIELD INT128,\n\t\t\t\t\tDECFLOAT_16_FIELD DECFLOAT(16),\n\t\t\t\t\tDECFLOAT_34_FIELD DECFLOAT(34),\n\t\t\t\t\tTWTZ_FIELD TIME WITH TIME ZONE,\n\t\t\t\t\tTSWTZ_FIELD TIMESTAMP WITH TIME ZONE\n\t\t\t\t)\n\t\t\t\t\"\"\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tawait ExecuteDdlAsync(Connection, \"\"\"\n\t\t\t\tCREATE TABLE SCAFFOLD_TEST (\n\t\t\t\t\tID_DEFAULT INTEGER GENERATED BY DEFAULT AS IDENTITY\n\t\t\t\t)\n\t\t\t\t\"\"\"\n\t\t\t);\n\t\t}\n\t}\n\n\tstatic async Task ExecuteDdlAsync(FbConnection connection, string ddlScript, bool ignoreErrors = false)\n\t{\n\t\ttry\n\t\t{\n\t\t\tawait using var command = new FbCommand(ddlScript, connection);\n\t\t\tawait command.ExecuteNonQueryAsync();\n\t\t}\n\t\tcatch when (ignoreErrors)\n\t\t{\n\t\t}\n  }\n\n  [Test]\n\tpublic async Task ExpressionIndexDoesNotBreakScaffolding()\n\t{\n\t\tvar tableName = \"TEST_EXPR_IDX\";\n\n\t\tusing var commandTable = Connection.CreateCommand();\n\t\tcommandTable.CommandText = $\"recreate table {tableName} (ID INTEGER NOT NULL, DATA VARCHAR(100))\";\n\t\tawait commandTable.ExecuteNonQueryAsync();\n\n\t\tusing var commandIndex = Connection.CreateCommand();\n\t\tcommandIndex.CommandText = $\"create index IDX_EXPR on {tableName} computed by (upper(DATA))\";\n\t\tawait commandIndex.ExecuteNonQueryAsync();\n\n\t\tvar modelFactory = GetModelFactory();\n\t\tvar model = modelFactory.Create(Connection.ConnectionString, new DatabaseModelFactoryOptions(new string[] { tableName }));\n\t\tvar table = model.Tables.Single(x => x.Name == tableName);\n\n\t\tAssert.That(table.Indexes, Has.None.Matches<Microsoft.EntityFrameworkCore.Scaffolding.Metadata.DatabaseIndex>(x => x.Name == \"IDX_EXPR\"));\n\t}\n\n\t[Test]\n\tpublic async Task RegularIndexScaffoldedAlongsideExpressionIndex()\n\t{\n\t\tvar tableName = \"TEST_MIX_IDX\";\n\n\t\tusing var commandTable = Connection.CreateCommand();\n\t\tcommandTable.CommandText = $\"recreate table {tableName} (ID INTEGER NOT NULL, DATA VARCHAR(100))\";\n\t\tawait commandTable.ExecuteNonQueryAsync();\n\n\t\tusing var commandRegularIndex = Connection.CreateCommand();\n\t\tcommandRegularIndex.CommandText = $\"create index IDX_REGULAR on {tableName} (DATA)\";\n\t\tawait commandRegularIndex.ExecuteNonQueryAsync();\n\n\t\tusing var commandExprIndex = Connection.CreateCommand();\n\t\tcommandExprIndex.CommandText = $\"create index IDX_EXPR_MIX on {tableName} computed by (upper(DATA))\";\n\t\tawait commandExprIndex.ExecuteNonQueryAsync();\n\n\t\tvar modelFactory = GetModelFactory();\n\t\tvar model = modelFactory.Create(Connection.ConnectionString, new DatabaseModelFactoryOptions(new string[] { tableName }));\n\t\tvar table = model.Tables.Single(x => x.Name == tableName);\n\n\t\tAssert.Multiple(() =>\n\t\t{\n\t\t\tAssert.That(table.Indexes, Has.Some.Matches<Microsoft.EntityFrameworkCore.Scaffolding.Metadata.DatabaseIndex>(x => x.Name == \"IDX_REGULAR\"));\n\t\t\tAssert.That(table.Indexes, Has.None.Matches<Microsoft.EntityFrameworkCore.Scaffolding.Metadata.DatabaseIndex>(x => x.Name == \"IDX_EXPR_MIX\"));\n\t\t});\n\t}\n\n\tstatic IDatabaseModelFactory GetModelFactory()\n\t{\n\t\treturn new FbDatabaseModelFactory();\n\t}\n}\n"
  },
  {
    "path": "src/NETProvider.slnx",
    "content": "<Solution>\n  <Folder Name=\"/EF6/\">\n    <Project Path=\"EntityFramework.Firebird.Tests/EntityFramework.Firebird.Tests.csproj\" />\n    <Project Path=\"EntityFramework.Firebird/EntityFramework.Firebird.csproj\" />\n  </Folder>\n  <Folder Name=\"/EFCore/\">\n    <Project Path=\"FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests/FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests.csproj\" />\n    <Project Path=\"FirebirdSql.EntityFrameworkCore.Firebird.Tests/FirebirdSql.EntityFrameworkCore.Firebird.Tests.csproj\" />\n    <Project Path=\"FirebirdSql.EntityFrameworkCore.Firebird/FirebirdSql.EntityFrameworkCore.Firebird.csproj\" />\n  </Folder>\n  <Folder Name=\"/Provider/\">\n    <Project Path=\"FirebirdSql.Data.External/FirebirdSql.Data.External.shproj\" />\n    <Project Path=\"FirebirdSql.Data.FirebirdClient.Tests/FirebirdSql.Data.FirebirdClient.Tests.csproj\" />\n    <Project Path=\"FirebirdSql.Data.FirebirdClient/FirebirdSql.Data.FirebirdClient.csproj\" />\n  </Folder>\n  <Folder Name=\"/Provider/Perf/\">\n    <Project Path=\"Perf/Perf.csproj\" />\n  </Folder>\n  <Folder Name=\"/Provider/Scratchpad/\">\n    <Project Path=\"Scratchpad/Scratchpad.csproj\" />\n  </Folder>\n  <Folder Name=\"/Solution Items/\">\n    <File Path=\"Directory.Build.props\" />\n    <File Path=\"Versions.props\" />\n  </Folder>\n  <Folder Name=\"/TestsBase/\">\n    <Project Path=\"FirebirdSql.Data.TestsBase/FirebirdSql.Data.TestsBase.shproj\" />\n  </Folder>\n  <Properties Name=\"TextTemplating\" Scope=\"PostLoad\">\n    <Property Name=\"TextTemplating\" Value=\"1\" />\n  </Properties>\n</Solution>\n"
  },
  {
    "path": "src/Perf/CommandBenchmark.Execute.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing BenchmarkDotNet.Attributes;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace Perf;\n\npartial class CommandBenchmark\n{\n\t[GlobalSetup(Target = nameof(Execute))]\n\tpublic void ExecuteGlobalSetup()\n\t{\n\t\tGlobalSetupBase();\n\t\tusing (var conn = new FbConnection(ConnectionString))\n\t\t{\n\t\t\tconn.Open();\n\t\t\tusing (var cmd = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = $\"create table foobar (x {DataType})\";\n\t\t\t\tcmd.ExecuteNonQuery();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Benchmark]\n\tpublic void Execute()\n\t{\n\t\tusing (var conn = new FbConnection(ConnectionString))\n\t\t{\n\t\t\tconn.Open();\n\t\t\tusing (var cmd = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = @\"insert into foobar values (@cnt)\";\n\t\t\t\tvar p = new FbParameter() { ParameterName = \"@cnt\" };\n\t\t\t\tcmd.Parameters.Add(p);\n\t\t\t\tfor (var i = 0; i < Count; i++)\n\t\t\t\t{\n\t\t\t\t\tp.Value = i;\n\t\t\t\t\tcmd.ExecuteNonQuery();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/Perf/CommandBenchmark.Fetch.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing BenchmarkDotNet.Attributes;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace Perf;\n\npartial class CommandBenchmark\n{\n\t[GlobalSetup(Target = nameof(Fetch))]\n\tpublic void FetchGlobalSetup()\n\t{\n\t\tGlobalSetupBase();\n\t\tusing (var conn = new FbConnection(ConnectionString))\n\t\t{\n\t\t\tconn.Open();\n\t\t\tusing (var cmd = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = $\"create table foobar (x {DataType})\";\n\t\t\t\tcmd.ExecuteNonQuery();\n\t\t\t}\n\t\t\tusing (var cmd = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = $@\"execute block as\ndeclare cnt int;\nbegin\n\tcnt = {Count};\n\twhile (cnt > 0) do\n\tbegin\n\t\tinsert into foobar values (:cnt);\n\t\tcnt = cnt - 1;\n\tend\nend\";\n\t\t\t\tcmd.ExecuteNonQuery();\n\t\t\t}\n\t\t}\n\t}\n\n\t[Benchmark]\n\tpublic void Fetch()\n\t{\n\t\tusing (var conn = new FbConnection(ConnectionString))\n\t\t{\n\t\t\tconn.Open();\n\t\t\tusing (var cmd = conn.CreateCommand())\n\t\t\t{\n\t\t\t\tcmd.CommandText = \"select x from foobar\";\n\t\t\t\tusing (var reader = cmd.ExecuteReader())\n\t\t\t\t{\n\t\t\t\t\twhile (reader.Read())\n\t\t\t\t\t{\n\t\t\t\t\t\tvar dummy = reader[0];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "src/Perf/CommandBenchmark.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing BenchmarkDotNet.Attributes;\nusing BenchmarkDotNet.Configs;\nusing BenchmarkDotNet.Diagnosers;\nusing BenchmarkDotNet.Environments;\nusing BenchmarkDotNet.Jobs;\nusing BenchmarkDotNet.Toolchains.CsProj;\nusing FirebirdSql.Data.FirebirdClient;\n\nnamespace Perf;\n\n[Config(typeof(Config))]\npublic partial class CommandBenchmark\n{\n\tclass Config : ManualConfig\n\t{\n\t\tpublic Config()\n\t\t{\n\t\t\tvar baseJob = Job.Default\n\t\t\t\t.WithWarmupCount(3)\n\t\t\t\t.WithToolchain(CsProjCoreToolchain.NetCoreApp60)\n\t\t\t\t.WithPlatform(Platform.X64)\n\t\t\t\t.WithJit(Jit.RyuJit);\n\t\t\tAddDiagnoser(MemoryDiagnoser.Default);\n\t\t\tAddJob(baseJob.WithCustomBuildConfiguration(\"Release\").WithId(\"Project\"));\n\t\t\tAddJob(baseJob.WithCustomBuildConfiguration(\"ReleaseNuGet\").WithId(\"NuGet\").AsBaseline());\n\t\t}\n\t}\n\n\tprotected const string ConnectionString = \"database=localhost:benchmark.fdb;user=sysdba;password=masterkey\";\n\n\t[Params(\"bigint\", \"varchar(10) character set utf8\")]\n\tpublic string DataType { get; set; }\n\n\t[Params(100)]\n\tpublic int Count { get; set; }\n\n\tvoid GlobalSetupBase()\n\t{\n\t\tFbConnection.CreateDatabase(ConnectionString, 16 * 1024, false, true);\n\t}\n\n\t[GlobalCleanup]\n\tpublic void GlobalCleanup()\n\t{\n\t\tFbConnection.ClearAllPools();\n\t\tFbConnection.DropDatabase(ConnectionString);\n\t}\n}\n"
  },
  {
    "path": "src/Perf/Perf.csproj",
    "content": "﻿<Project Sdk=\"Microsoft.NET.Sdk\">\n\t<PropertyGroup>\n\t\t<OutputType>Exe</OutputType>\n\t\t<TargetFramework>net10.0</TargetFramework>\n\t\t<SkipSourceLink>true</SkipSourceLink>\n\t</PropertyGroup>\n\t<ItemGroup>\n\t\t<PackageReference Include=\"BenchmarkDotNet\" Version=\"0.14.0\" />\n\t</ItemGroup>\n\n\t<ItemGroup>\n\t\t<Compile Update=\"CommandBenchmark.*.cs\">\n\t\t\t<DependentUpon>CommandBenchmark.cs</DependentUpon>\n\t\t</Compile>\n\t</ItemGroup>\n\n\t<ItemGroup Condition=\"!$(Configuration.EndsWith('NuGet'))\">\n\t\t<ProjectReference Include=\"..\\FirebirdSql.Data.FirebirdClient\\FirebirdSql.Data.FirebirdClient.csproj\" />\n\t</ItemGroup>\n\n\t<ItemGroup Condition=\"$(Configuration.EndsWith('NuGet'))\">\n\t\t<PackageReference Include=\"FirebirdSql.Data.FirebirdClient\" Version=\"8.5.4\" />\n\t</ItemGroup>\n</Project>\n"
  },
  {
    "path": "src/Perf/Program.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nusing System.Reflection;\nusing BenchmarkDotNet.Running;\n\nnamespace Perf;\n\nclass Program\n{\n\tstatic void Main(string[] args)\n\t{\n\t\tBenchmarkRunner.Run(Assembly.GetExecutingAssembly());\n\t}\n}\n"
  },
  {
    "path": "src/Scratchpad/Program.cs",
    "content": "﻿/*\n *    The contents of this file are subject to the Initial\n *    Developer's Public License Version 1.0 (the \"License\");\n *    you may not use this file except in compliance with the\n *    License. You may obtain a copy of the License at\n *    https://github.com/FirebirdSQL/NETProvider/raw/master/license.txt.\n *\n *    Software distributed under the License is distributed on\n *    an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either\n *    express or implied. See the License for the specific\n *    language governing rights and limitations under the License.\n *\n *    All Rights Reserved.\n */\n\n//$Authors = Jiri Cincura (jiri@cincura.net)\n\nnamespace Scratchpad;\n\nclass Program\n{\n\tstatic void Main(string[] args)\n\t{\n\t\t// Scratchpad\n\t}\n}\n"
  },
  {
    "path": "src/Scratchpad/Scratchpad.csproj",
    "content": "﻿<Project Sdk=\"Microsoft.NET.Sdk\">\n\t<PropertyGroup>\n\t\t<OutputType>Exe</OutputType>\n\t\t<TargetFramework>net10.0</TargetFramework>\n\t\t<SkipSourceLink>true</SkipSourceLink>\n\t\t<SignAssembly>true</SignAssembly>\n\t\t<AssemblyOriginatorKeyFile>..\\FirebirdSql.Data.TestsBase\\FirebirdSql.Data.TestsBase.snk</AssemblyOriginatorKeyFile>\n\t</PropertyGroup>\n\t<ItemGroup>\n\t  <ProjectReference Include=\"..\\FirebirdSql.Data.FirebirdClient\\FirebirdSql.Data.FirebirdClient.csproj\" />\n\t  <ProjectReference Include=\"..\\FirebirdSql.EntityFrameworkCore.Firebird\\FirebirdSql.EntityFrameworkCore.Firebird.csproj\" />\n\t</ItemGroup>\n</Project>\n"
  },
  {
    "path": "src/Versions.props",
    "content": "<Project>\n\t<!-- Provider -->\n\t<PropertyGroup>\n\t\t<ProviderVersion>11.0.0-alpha1</ProviderVersion>\n\t</PropertyGroup>\n\t<!-- EFCore -->\n\t<PropertyGroup>\n\t\t<EFCoreProviderVersion>13.0.0</EFCoreProviderVersion>\n\t\t<EFCoreReferenceProviderVersion>10.3.4</EFCoreReferenceProviderVersion>\n\t\t<EFCoreReferencePackageVersion>10.0.0</EFCoreReferencePackageVersion>\n\t</PropertyGroup>\n\t<!-- EF6 -->\n\t<PropertyGroup>\n\t\t<EF6ProviderVersion>10.1.0</EF6ProviderVersion>\n\t\t<EF6ReferenceProviderVersion>10.3.2</EF6ReferenceProviderVersion>\n\t\t<EF6ReferencePackageVersion>6.5.1</EF6ReferencePackageVersion>\n\t</PropertyGroup>\n</Project>\n"
  },
  {
    "path": "tests.ps1",
    "content": "param(\n\t[Parameter(Mandatory=$True)]$Configuration,\n\t[Parameter(Mandatory=$True)]$FirebirdSelection,\n\t[Parameter(Mandatory=$True)]$TestSuite)\n\n$ErrorActionPreference = 'Stop'\n$ProgressPreference = 'SilentlyContinue' # Faster downloads with Invoke-RestMethod -- https://stackoverflow.com/a/43477248/33244\n\n$baseDir = Split-Path -Parent $PSCommandPath\n\n. \"$baseDir\\include.ps1\"\n\n$FirebirdConfiguration = @{\n\tFB50 = @{\n\t\tDownload = 'https://github.com/FirebirdSQL/NETProvider-tests-infrastructure/raw/master/fb50.7z'\n\t\tExecutable = '.\\firebird.exe'\n\t\tArgs = @('-a')\n\t}\n\tFB40 = @{\n\t\tDownload = 'https://github.com/FirebirdSQL/NETProvider-tests-infrastructure/raw/master/fb40.7z'\n\t\tExecutable = '.\\firebird.exe'\n\t\tArgs = @('-a')\n\t}\n\tFB30 = @{\n\t\tDownload = 'https://github.com/FirebirdSQL/NETProvider-tests-infrastructure/raw/master/fb30.7z'\n\t\tExecutable = '.\\firebird.exe'\n\t\tArgs = @('-a')\n\t}\n}\n\n$frameworkVersion = 'net10.0'\n$testsBaseDir = \"$baseDir\\src\\FirebirdSql.Data.FirebirdClient.Tests\"\n$testsProviderDir = \"$testsBaseDir\\bin\\$Configuration\\$frameworkVersion\"\n\n$firebirdProcess = $null\n\nif ($env:tests_firebird_dir) {\n\t$firebirdDir = $env:tests_firebird_dir\n}\nelse {\n\t$firebirdDir = \"$env:TEMP\\fb_tests\\$FirebirdSelection\\\"\n}\n\nfunction Prepare() {\n\techo \"=== $($MyInvocation.MyCommand.Name) ===\"\n\n\t$selectedConfiguration = $FirebirdConfiguration[$FirebirdSelection]\n\t$fbDownload = $selectedConfiguration.Download\n\t$fbDownloadName = $fbDownload -Replace '.+/(.+)$','$1'\n\tif (Test-Path $firebirdDir) {\n\t\trm -Force -Recurse $firebirdDir\n\t}\n\tmkdir $firebirdDir | Out-Null\n\n\tpushd $firebirdDir\n\ttry {\n\t\techo \"Downloading $fbDownload\"\n\t\tInvoke-RestMethod -Uri $fbDownload -OutFile $fbDownloadName \n\t\techo \"Extracting $fbDownloadName\"\n\t\t7z x -bsp0 -bso0 $fbDownloadName\n\t\trm $fbDownloadName\n\t\tcp -Recurse -Force .\\* $testsProviderDir\n\n\t\tni firebird.log -ItemType File | Out-Null\n\n\t\techo \"Starting Firebird\"\n\t\t$process = Start-Process -FilePath $selectedConfiguration.Executable -ArgumentList $selectedConfiguration.Args -PassThru\n\t\techo \"Version: $($process.MainModule.FileVersionInfo.FileVersion)\"\n\t\t$script:firebirdProcess = $process\n\n\t\techo \"=== END ===\"\n\t}\n\tfinally {\n\t\tpopd\n\t}\n}\n\nfunction Cleanup() {\n\t# Do not write to output (Write-Output, echo) here. Write-Host is ok.\n\t# -- https://stackoverflow.com/a/45105609\n\n\tWrite-Host \"=== $($MyInvocation.MyCommand.Name) ===\"\n\n\t$process = $script:firebirdProcess\n\tif ($process) {\n\t\t$process.Kill()\n\t\t$process.WaitForExit()\n\t\t# give OS time to release all files\n\t\tsleep -Milliseconds 100\n\t}\n\trm -Force -Recurse $firebirdDir\n\n\tWrite-Host \"=== END ===\"\n}\n\nfunction Tests-All() {\n\tTests-FirebirdClient-Default-Compression-CryptRequired\n\tTests-FirebirdClient-Default-NoCompression-CryptRequired\n\tTests-FirebirdClient-Default-Compression-CryptDisabled\n\tTests-FirebirdClient-Default-NoCompression-CryptDisabled\n\tTests-FirebirdClient-Embedded\n\tTests-EFCore\n\tTests-EFCore-Functional\n\tTests-EF6\n}\n\nfunction Tests-FirebirdClient-Default-Compression-CryptRequired() {\n\tTests-FirebirdClient 'Default' $True 'Required'\n}\nfunction Tests-FirebirdClient-Default-NoCompression-CryptRequired() {\n\tTests-FirebirdClient 'Default' $False 'Required'\n}\nfunction Tests-FirebirdClient-Default-Compression-CryptDisabled() {\n\tTests-FirebirdClient 'Default' $True 'Disabled'\n}\nfunction Tests-FirebirdClient-Default-NoCompression-CryptDisabled() {\n\tTests-FirebirdClient 'Default' $False 'Disabled'\n}\nfunction Tests-FirebirdClient-Embedded() {\n\tTests-FirebirdClient 'Embedded' $False 'Disabled'\n}\nfunction Tests-FirebirdClient($serverType, $compression, $wireCrypt) {\n\tpushd $testsProviderDir\n\ttry {\n\t\t.\\FirebirdSql.Data.FirebirdClient.Tests.exe --labels=All \"--where=(ServerType==$serverType && Compression==$compression && WireCrypt==$wireCrypt) || Category==NoServer\"\n\t\tCheck-ExitCode\n\t}\n\tfinally {\n\t\tpopd\n\t}\n}\n\nfunction Tests-EF6() {\n\tpushd \"$baseDir\\src\\EntityFramework.Firebird.Tests\\bin\\$Configuration\\$frameworkVersion\"\n\ttry {\n\t\t.\\EntityFramework.Firebird.Tests.exe --labels=All\n\t\tCheck-ExitCode\n\t}\n\tfinally {\n\t\tpopd\n\t}\n}\n\nfunction Tests-EFCore() {\n\tpushd \"$baseDir\\src\\FirebirdSql.EntityFrameworkCore.Firebird.Tests\\bin\\$Configuration\\$frameworkVersion\"\n\ttry {\n\t\t.\\FirebirdSql.EntityFrameworkCore.Firebird.Tests.exe --labels=All\n\t\tCheck-ExitCode\n\t}\n\tfinally {\n\t\tpopd\n\t}\n}\nfunction Tests-EFCore-Functional() {\n\tpushd \"$baseDir\\src\\FirebirdSql.EntityFrameworkCore.Firebird.FunctionalTests\"\n\ttry {\n\t\tdotnet test --no-build -c $Configuration\n\t\tCheck-ExitCode\n\t}\n\tfinally {\n\t\tpopd\n\t}\n}\n\ntry {\n\tPrepare\n\t& $TestSuite\n}\nfinally {\n\tCleanup\n}\n"
  }
]