Hans Leidekker : msi: Open the database storage in transacted mode when MSIDBOPEN_CREATE or MSIDBOPEN_TRANSACT is specified .

Alexandre Julliard julliard at winehq.org
Fri Aug 27 11:11:20 CDT 2010


Module: wine
Branch: master
Commit: eef54ffe6bcda7a17a62af432f6386e6967e795a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=eef54ffe6bcda7a17a62af432f6386e6967e795a

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Fri Aug 27 10:50:20 2010 +0200

msi: Open the database storage in transacted mode when MSIDBOPEN_CREATE or MSIDBOPEN_TRANSACT is specified.

---

 dlls/msi/database.c |   28 ++++++++++++++++++++--------
 dlls/msi/table.c    |    9 ++++++++-
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/dlls/msi/database.c b/dlls/msi/database.c
index 01c3249..986dcbb 100644
--- a/dlls/msi/database.c
+++ b/dlls/msi/database.c
@@ -300,26 +300,38 @@ UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb)
     }
     else if( szPersist == MSIDBOPEN_CREATE || szPersist == MSIDBOPEN_CREATEDIRECT )
     {
-        /* FIXME: MSIDBOPEN_CREATE should case STGM_TRANSACTED flag to be
-         * used here: */
-        r = StgCreateDocfile( szDBPath,
-              STGM_CREATE|STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, &stg);
-        if( r == ERROR_SUCCESS )
+        if ( szPersist == MSIDBOPEN_CREATE )
+        {
+            r = StgCreateDocfile( szDBPath,
+                STGM_CREATE|STGM_TRANSACTED|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, &stg);
+        }
+        else
+        {
+            r = StgCreateDocfile( szDBPath,
+                STGM_CREATE|STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, &stg);
+        }
+        if( SUCCEEDED(r) )
         {
             IStorage_SetClass( stg, patch ? &CLSID_MsiPatch : &CLSID_MsiDatabase );
             /* create the _Tables stream */
             r = write_stream_data(stg, szTables, NULL, 0, TRUE);
             if (SUCCEEDED(r))
+            {
                 r = msi_init_string_table( stg );
+                if (SUCCEEDED(r))
+                {
+                    r = IStorage_Commit( stg, 0 );
+                    if (FAILED(r))
+                        WARN("failed to commit changes 0x%08x\n", r);
+                }
+            }
         }
         created = TRUE;
     }
     else if( szPersist == MSIDBOPEN_TRANSACT )
     {
-        /* FIXME: MSIDBOPEN_TRANSACT should case STGM_TRANSACTED flag to be
-         * used here: */
         r = StgOpenStorage( szDBPath, NULL,
-              STGM_DIRECT|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, NULL, 0, &stg);
+              STGM_TRANSACTED|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, NULL, 0, &stg);
     }
     else if( szPersist == MSIDBOPEN_DIRECT )
     {
diff --git a/dlls/msi/table.c b/dlls/msi/table.c
index 72d1f21..6755496 100644
--- a/dlls/msi/table.c
+++ b/dlls/msi/table.c
@@ -2319,6 +2319,7 @@ UINT TABLE_CreateView( MSIDATABASE *db, LPCWSTR name, MSIVIEW **view )
 UINT MSI_CommitTables( MSIDATABASE *db )
 {
     UINT r;
+    HRESULT hr;
     MSITABLE *table = NULL;
 
     TRACE("%p\n",db);
@@ -2344,7 +2345,13 @@ UINT MSI_CommitTables( MSIDATABASE *db )
     /* force everything to reload next time */
     free_cached_tables( db );
 
-    return ERROR_SUCCESS;
+    hr = IStorage_Commit( db->storage, 0 );
+    if (FAILED( hr ))
+    {
+        WARN("failed to commit changes 0x%08x\n", hr);
+        r = ERROR_FUNCTION_FAILED;
+    }
+    return r;
 }
 
 MSICONDITION MSI_DatabaseIsTablePersistent( MSIDATABASE *db, LPCWSTR table )




More information about the wine-cvs mailing list