From 4b75f33012cb382d91e396bbe3821a65e131c753 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Wed, 9 Jan 2008 01:36:25 -0700 Subject: [PATCH] msi: Actually delete the row data instead of blanking it out. --- dlls/msi/delete.c | 11 ++--------- dlls/msi/table.c | 7 +++++++ dlls/msi/tests/db.c | 14 ++++---------- dlls/msi/where.c | 22 +++++++++++++++++++++- 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/dlls/msi/delete.c b/dlls/msi/delete.c index d315f27e0f..8d37324b20 100644 --- a/dlls/msi/delete.c +++ b/dlls/msi/delete.c @@ -77,7 +77,6 @@ static UINT DELETE_execute( struct tagMSIVIEW *view, MSIRECORD *record ) { MSIDELETEVIEW *dv = (MSIDELETEVIEW*)view; UINT r, i, rows = 0, cols = 0; - MSIRECORD *empty; TRACE("%p %p\n", dv, record); @@ -92,17 +91,11 @@ static UINT DELETE_execute( struct tagMSIVIEW *view, MSIRECORD *record ) if( r != ERROR_SUCCESS ) return r; - TRACE("blanking %d rows\n", rows); - - empty = MSI_CreateRecord( cols ); - if (!empty) - return ERROR_FUNCTION_FAILED; + TRACE("deleting %d rows\n", rows); /* blank out all the rows that match */ for ( i=0; itable->ops->set_row( dv->table, i, empty, (1<hdr ); + dv->table->ops->delete_row( dv->table, i ); return ERROR_SUCCESS; } diff --git a/dlls/msi/table.c b/dlls/msi/table.c index 2da9d2c2d9..97f0298104 100644 --- a/dlls/msi/table.c +++ b/dlls/msi/table.c @@ -1572,6 +1572,13 @@ static UINT TABLE_delete_row( struct tagMSIVIEW *view, UINT row ) data = tv->table->nonpersistent_data; } + /* reset the hash tables */ + for (i = 0; i < tv->num_cols; i++) + { + msi_free( tv->columns[i].hash_table ); + tv->columns[i].hash_table = NULL; + } + if ( row == num_rows - 1 ) return ERROR_SUCCESS; diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c index 719ea9e66a..a327ceda1c 100644 --- a/dlls/msi/tests/db.c +++ b/dlls/msi/tests/db.c @@ -4991,7 +4991,7 @@ static void test_viewmodify_delete_temporary(void) DeleteFileA(msifile); } -static void test_msidatabasecommit() +static void test_deleterow() { MSIHANDLE hdb, hview, hrec; const char *query; @@ -5040,18 +5040,12 @@ static void test_msidatabasecommit() size = MAX_PATH; r = MsiRecordGetStringA(hrec, 1, buf, &size); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); - todo_wine - { - ok(!lstrcmpA(buf, "two"), "Expected two, got %s\n", buf); - } + ok(!lstrcmpA(buf, "two"), "Expected two, got %s\n", buf); MsiCloseHandle(hrec); r = MsiViewFetch(hview, &hrec); - todo_wine - { - ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r); - } + ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r); MsiViewClose(hview); MsiCloseHandle(hview); @@ -5089,5 +5083,5 @@ START_TEST(db) test_defaultdatabase(); test_order(); test_viewmodify_delete_temporary(); - test_msidatabasecommit(); + test_deleterow(); } diff --git a/dlls/msi/where.c b/dlls/msi/where.c index 98eaa62ce4..e4d00c07d7 100644 --- a/dlls/msi/where.c +++ b/dlls/msi/where.c @@ -200,6 +200,26 @@ static UINT WHERE_set_row( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UI return wv->table->ops->set_row( wv->table, row, rec, mask ); } +static UINT WHERE_delete_row(struct tagMSIVIEW *view, UINT row) +{ + MSIWHEREVIEW *wv = (MSIWHEREVIEW *)view; + UINT r; + + TRACE("(%p %d)\n", view, row); + + if ( !wv->table ) + return ERROR_FUNCTION_FAILED; + + if ( row > wv->row_count ) + return ERROR_NO_MORE_ITEMS; + + r = find_entry_in_hash( wv->reorder, row, &row ); + if ( r != ERROR_SUCCESS ) + return r; + + return wv->table->ops->delete_row( wv->table, row ); +} + static INT INT_evaluate_binary( INT lval, UINT op, INT rval ) { switch( op ) @@ -549,7 +569,7 @@ static const MSIVIEWOPS where_ops = WHERE_get_row, WHERE_set_row, NULL, - NULL, + WHERE_delete_row, WHERE_execute, WHERE_close, WHERE_get_dimensions,