Skip to content

Commit 5faf28b

Browse files
committed
Do not release logical type
1 parent 5c49b25 commit 5faf28b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

DuckDB.NET.Bindings/DuckDBWrapperObjects.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,13 @@ internal void SetChildValues(DuckDBValue[] values)
113113

114114
public T GetValue<T>()
115115
{
116-
return (T)(object)NativeMethods.Value.DuckDBGetInt32(this);
117-
var type = typeof(T);
118116
var logicalType = NativeMethods.Value.DuckDBGetValueType(this);
117+
118+
//Logical type is part of the duckdb_value object and it shouldn't be released separately
119+
//It will get released when the duckdb_value object is destroyed below.
120+
var add = false;
121+
logicalType.DangerousAddRef(ref add);
122+
119123
var duckDBType = NativeMethods.LogicalType.DuckDBGetTypeId(logicalType);
120124

121125
return duckDBType switch
@@ -145,7 +149,7 @@ public T GetValue<T>()
145149
DuckDBType.Varchar => ReadValue<string>(NativeMethods.Value.DuckDBGetVarchar(this)),
146150
//DuckDBType.Decimal => ReadValue<T>(),
147151
//DuckDBType.Uuid => expr,
148-
_ => throw new NotImplementedException($"Cannot read value of type {type.FullName}")
152+
_ => throw new NotImplementedException($"Cannot read value of type {typeof(T).FullName}")
149153
};
150154

151155
T ReadValue<TSource>(TSource value)

0 commit comments

Comments
 (0)