-
-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathUdfExceptionStore.cs
More file actions
44 lines (37 loc) · 1.37 KB
/
Copy pathUdfExceptionStore.cs
File metadata and controls
44 lines (37 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.Collections.Concurrent;
namespace DuckDB.NET.Data.Connection;
internal static class UdfExceptionStore
{
private static readonly ConcurrentDictionary<ulong, Exception> Exceptions = new();
internal static void Store(ulong connectionId, Exception exception) => Exceptions[connectionId] = exception;
internal static Exception? Retrieve(DuckDBNativeConnection nativeConnection)
{
var connectionId = GetConnectionId(nativeConnection);
_ = Exceptions.TryRemove(connectionId, out var exception);
return exception;
}
private static ulong GetConnectionId(DuckDBNativeConnection nativeConnection)
{
NativeMethods.Startup.DuckDBConnectionGetClientContext(nativeConnection, out var context);
using (context)
{
return context.ConnectionId;
}
}
internal static ulong GetTableFunctionBindConnectionId(IntPtr bindInfo)
{
NativeMethods.TableFunction.DuckDBTableFunctionGetClientContext(bindInfo, out var context);
using (context)
{
return context.ConnectionId;
}
}
internal static ulong GetScalarFunctionBindConnectionId(IntPtr bindInfo)
{
NativeMethods.ScalarFunction.DuckDBScalarFunctionGetClientContext(bindInfo, out var context);
using (context)
{
return context.ConnectionId;
}
}
}