Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 4 additions & 69 deletions src/libraries/System.Data.OleDb/src/SafeHandles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using static System.Data.Common.UnsafeNativeMethods;

namespace System.Data.OleDb
{
Expand Down Expand Up @@ -166,75 +167,6 @@ protected override bool ReleaseHandle()
}
}

[Guid("0fb15084-af41-11ce-bd2b-204c4f4f5020")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
internal interface ITransaction
{
[PreserveSig]
int Commit
(
[In] bool fRetaining,
[In] uint grfTC,
[In] uint grfRM
);

[PreserveSig]
int Abort
(
[In] IntPtr pboidReason,
[In] bool fRetaining,
[In] bool fAsync
);

[PreserveSig]
int GetTransactionInfo
(
[Out] IntPtr pinfo
);
}

[Guid("0c733a93-2a1c-11ce-ade5-00aa0044773d")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
internal unsafe interface ITransactionLocal : ITransaction
{
[PreserveSig]
new int Commit
(
[In] bool fRetaining,
[In] uint grfTC,
[In] uint grfRM
);

[PreserveSig]
new int Abort
(
[In] IntPtr pboidReason,
[In] bool fRetaining,
[In] bool fAsync
);

[PreserveSig]
new int GetTransactionInfo
(
[Out] IntPtr pinfo
);

[PreserveSig]
int GetOptionsObject(
[Out, Optional] IntPtr ppOptions
);

[PreserveSig]
int StartTransaction(
[In] int isoLevel,
[In] uint isoFlags,
[In, Optional] IntPtr pOtherOptions,
[Out, Optional] uint* pulTransactionLevel
);
}

internal enum XACTTC
{
XACTTC_NONE = 0x0000,
Expand Down Expand Up @@ -746,6 +678,7 @@ internal static unsafe OleDbHResult IChapteredRowsetReleaseChapter(System.IntPtr
{
chapteredRowset = (System.Data.Common.UnsafeNativeMethods.IChapteredRowset)Marshal.GetObjectForIUnknown(pChapteredRowset);
hr = (OleDbHResult)chapteredRowset.ReleaseChapter(hchapter, out var refcount);
Marshal.ReleaseComObject(chapteredRowset);
Marshal.Release(pChapteredRowset);
}
}
Expand All @@ -767,6 +700,7 @@ internal static unsafe OleDbHResult ITransactionAbort(System.IntPtr ptr)
{
transactionLocal = (ITransactionLocal)Marshal.GetObjectForIUnknown(pTransaction);
hr = (OleDbHResult)transactionLocal.Abort(IntPtr.Zero, false, false);
Marshal.ReleaseComObject(transactionLocal);
Marshal.Release(pTransaction);
}
}
Expand All @@ -788,6 +722,7 @@ internal static unsafe OleDbHResult ITransactionCommit(System.IntPtr ptr)
{
transactionLocal = (ITransactionLocal)Marshal.GetObjectForIUnknown(pTransaction);
hr = (OleDbHResult)transactionLocal.Commit(false, (uint)XACTTC.XACTTC_SYNC_PHASETWO, 0);
Marshal.ReleaseComObject(transactionLocal);
Marshal.Release(pTransaction);
}
}
Expand Down
16 changes: 14 additions & 2 deletions src/libraries/System.Data.OleDb/src/UnsafeNativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,21 @@ int GetSQLInfo(
[Guid("0C733A5F-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport, SuppressUnmanagedCodeSecurity]
internal interface ITransactionLocal
{
[Obsolete("not used", true)] void Commit(/*deleted parameter signature*/);
[PreserveSig]
int Commit
(
[In] bool fRetaining,
[In] uint grfTC,
[In] uint grfRM
);

[Obsolete("not used", true)] void Abort(/*deleted parameter signature*/);
[PreserveSig]
int Abort
(
[In] IntPtr pboidReason,
[In] bool fRetaining,
[In] bool fAsync
);

[Obsolete("not used", true)] void GetTransactionInfo(/*deleted parameter signature*/);

Expand Down
12 changes: 12 additions & 0 deletions src/libraries/System.Data.OleDb/tests/OleDbConnectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,5 +357,17 @@ public void OleDbConnectionStringBuilder_Success()
Assert.True(connectionStringBuilder.Remove("Provider"));
Assert.Empty(connectionStringBuilder.Provider);
}

[ConditionalFact(Helpers.IsDriverAvailable)]
public void TransactionRollBackTest()
{
using (OleDbConnection connection = new OleDbConnection(ConnectionString))
{
connection.Open();
OleDbTransaction transaction = connection.BeginTransaction();
// This call shouldn't throw
transaction.Rollback();
}
}
}
}