-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(csharp): Implement support for transactions, isolation level and…
… read-only flag (#1784) Implements support for transactions, isolation level and read-only flags on imported and exported drivers. Closes #1782
- Loading branch information
1 parent
7402f9a
commit 9afc04c
Showing
10 changed files
with
536 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using System; | ||
|
||
namespace Apache.Arrow.Adbc | ||
{ | ||
public static class AdbcOptions | ||
{ | ||
public const string Enabled = "true"; | ||
public const string Disabled = "false"; | ||
|
||
public const string Autocommit = "adbc.connection.autocommit"; | ||
public const string ReadOnly = "adbc.connection.readonly"; | ||
public const string IsolationLevel = "adbc.connection.transaction.isolation_level"; | ||
|
||
public static class IsolationLevels | ||
{ | ||
public const string Default = "adbc.connection.transaction.isolation.default"; | ||
public const string ReadUncommitted = "adbc.connection.transaction.isolation.read_uncommitted"; | ||
public const string ReadCommitted = "adbc.connection.transaction.isolation.read_committed"; | ||
public const string RepeatableRead = "adbc.connection.transaction.isolation.repeatable_read"; | ||
public const string Snapshot = "adbc.connection.transaction.isolation.snapshot"; | ||
public const string Serializable = "adbc.connection.transaction.isolation.serializable"; | ||
public const string Linearizable = "adbc.connection.transaction.isolation.linearizable"; | ||
} | ||
|
||
public static string GetEnabled(bool value) => value ? Enabled : Disabled; | ||
public static bool GetEnabled(string value) | ||
{ | ||
if (StringComparer.OrdinalIgnoreCase.Equals(value, Enabled)) { return true; } | ||
if (StringComparer.OrdinalIgnoreCase.Equals(value, Disabled)) { return false; } | ||
throw new NotSupportedException("unknown enabled flag"); | ||
} | ||
|
||
public static string GetIsolationLevel(IsolationLevel value) | ||
{ | ||
return value switch | ||
{ | ||
Adbc.IsolationLevel.Default => IsolationLevels.Default, | ||
Adbc.IsolationLevel.ReadUncommitted => IsolationLevels.ReadUncommitted, | ||
Adbc.IsolationLevel.ReadCommitted => IsolationLevels.ReadCommitted, | ||
Adbc.IsolationLevel.RepeatableRead => IsolationLevels.RepeatableRead, | ||
Adbc.IsolationLevel.Snapshot => IsolationLevels.Snapshot, | ||
Adbc.IsolationLevel.Serializable => IsolationLevels.Serializable, | ||
Adbc.IsolationLevel.Linearizable => IsolationLevels.Linearizable, | ||
_ => throw new NotSupportedException("unknown isolation level"), | ||
}; | ||
} | ||
|
||
public static IsolationLevel GetIsolationLevel(string value) | ||
{ | ||
if (StringComparer.OrdinalIgnoreCase.Equals(value, IsolationLevels.Default)) { return Adbc.IsolationLevel.Default; } | ||
if (StringComparer.OrdinalIgnoreCase.Equals(value, IsolationLevels.ReadUncommitted)) { return Adbc.IsolationLevel.ReadUncommitted; } | ||
if (StringComparer.OrdinalIgnoreCase.Equals(value, IsolationLevels.ReadCommitted)) { return Adbc.IsolationLevel.ReadCommitted; } | ||
if (StringComparer.OrdinalIgnoreCase.Equals(value, IsolationLevels.RepeatableRead)) { return Adbc.IsolationLevel.RepeatableRead; } | ||
if (StringComparer.OrdinalIgnoreCase.Equals(value, IsolationLevels.Snapshot)) { return Adbc.IsolationLevel.Snapshot; } | ||
if (StringComparer.OrdinalIgnoreCase.Equals(value, IsolationLevels.Serializable)) { return Adbc.IsolationLevel.Serializable; } | ||
if (StringComparer.OrdinalIgnoreCase.Equals(value, IsolationLevels.Linearizable)) { return Adbc.IsolationLevel.Linearizable; } | ||
throw new NotSupportedException("unknown isolation level"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("Apache.Arrow.Adbc.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100e504183f6d470d6b67b6d19212be3e1f598f70c246a120194bc38130101d0c1853e4a0f2232cb12e37a7a90e707aabd38511dac4f25fcb0d691b2aa265900bf42de7f70468fc997551a40e1e0679b605aa2088a4a69e07c117e988f5b1738c570ee66997fba02485e7856a49eca5fd0706d09899b8312577cbb9034599fc92d4")] |
Oops, something went wrong.