Andoni Morales Alastruey : msi: Implement MSIMODIFY_MERGE function in TABLE_modify.

Alexandre Julliard julliard at winehq.org
Wed Mar 28 12:47:06 CDT 2012


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

Author: Andoni Morales Alastruey <ylatuya at gmail.com>
Date:   Mon Mar 19 23:19:17 2012 +0100

msi: Implement MSIMODIFY_MERGE function in TABLE_modify.

---

 dlls/msi/table.c    |   14 ++++++++++++--
 dlls/msi/tests/db.c |   24 ++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/dlls/msi/table.c b/dlls/msi/table.c
index d37947e..54743bd 100644
--- a/dlls/msi/table.c
+++ b/dlls/msi/table.c
@@ -1766,7 +1766,7 @@ static UINT TABLE_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode,
                           MSIRECORD *rec, UINT row)
 {
     MSITABLEVIEW *tv = (MSITABLEVIEW*)view;
-    UINT r, column;
+    UINT r, frow, column;
 
     TRACE("%p %d %p\n", view, eModifyMode, rec );
 
@@ -1811,8 +1811,18 @@ static UINT TABLE_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode,
         r = msi_table_assign( view, rec );
         break;
 
-    case MSIMODIFY_REPLACE:
     case MSIMODIFY_MERGE:
+        /* check row that matches this record */
+        r = msi_table_find_row( tv, rec, &frow, &column );
+        if (r != ERROR_SUCCESS)
+        {
+            r = table_validate_new( tv, rec, NULL );
+            if (r == ERROR_SUCCESS)
+                r = TABLE_insert_row( view, rec, -1, FALSE );
+        }
+        break;
+
+    case MSIMODIFY_REPLACE:
     case MSIMODIFY_VALIDATE:
     case MSIMODIFY_VALIDATE_FIELD:
     case MSIMODIFY_VALIDATE_DELETE:
diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c
index d33eb0c..4c91bd8 100644
--- a/dlls/msi/tests/db.c
+++ b/dlls/msi/tests/db.c
@@ -923,6 +923,30 @@ static void test_viewmodify(void)
     r = MsiViewModify(hview, MSIMODIFY_INSERT_TEMPORARY, hrec );
     ok(r == ERROR_FUNCTION_FAILED, "MsiViewModify failed\n");
 
+    /* try to merge the same record */
+    r = MsiViewExecute(hview, 0);
+    ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
+    r = MsiViewModify(hview, MSIMODIFY_MERGE, hrec );
+    ok(r == ERROR_SUCCESS, "MsiViewModify failed\n");
+
+    r = MsiCloseHandle(hrec);
+    ok(r == ERROR_SUCCESS, "failed to close record\n");
+
+    /* try merging a new record */
+    hrec = MsiCreateRecord(3);
+
+    r = MsiRecordSetInteger(hrec, 1, 10);
+    ok(r == ERROR_SUCCESS, "failed to set integer\n");
+    r = MsiRecordSetString(hrec, 2, "pepe");
+    ok(r == ERROR_SUCCESS, "failed to set string\n");
+    r = MsiRecordSetString(hrec, 3, "7654321");
+    ok(r == ERROR_SUCCESS, "failed to set string\n");
+
+    r = MsiViewModify(hview, MSIMODIFY_MERGE, hrec );
+    ok(r == ERROR_SUCCESS, "MsiViewModify failed\n");
+    r = MsiViewExecute(hview, 0);
+    ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
+
     r = MsiCloseHandle(hrec);
     ok(r == ERROR_SUCCESS, "failed to close record\n");
 




More information about the wine-cvs mailing list