msi: Implement MSIMODIFY_MERGE function in TABLE_modify.

This commit is contained in:
Andoni Morales Alastruey 2012-03-19 23:19:17 +01:00 committed by Alexandre Julliard
parent e08a7a6131
commit 342fcb6198
2 changed files with 36 additions and 2 deletions

View File

@ -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:

View File

@ -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");