From: Piotr Caban piotr@codeweavers.com
--- dlls/msi/table.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/dlls/msi/table.c b/dlls/msi/table.c index ea4ef3b0d0e..263f0778460 100644 --- a/dlls/msi/table.c +++ b/dlls/msi/table.c @@ -1680,12 +1680,29 @@ static int compare_record( struct table_view *tv, UINT row, MSIRECORD *rec ) return 1; }
-static int find_insert_index( struct table_view *tv, MSIRECORD *rec ) +static int find_insert_index( struct table_view *tv, MSIRECORD *rec, BOOL temporary ) { int idx, c, low = 0, high = tv->table->row_count - 1;
TRACE("%p %p\n", tv, rec);
+ for (c = 0; c < tv->num_cols; c++) + { + UINT ival; + + if (!(tv->columns[c].type & MSITYPE_KEY)) continue; + + /* Add primary key string - its index affects row index. */ + if (tv->columns[c].type & MSITYPE_STRING && + (get_table_value_from_record( tv, rec, c + 1, &ival ) == ERROR_NOT_FOUND)) + { + int len; + const WCHAR *sval = msi_record_get_string( rec, c + 1, &len ); + msi_add_string( tv->db->strings, sval, len, !temporary ); + } + break; + } + while (low <= high) { idx = (low + high) / 2; @@ -1718,7 +1735,7 @@ static UINT TABLE_insert_row( struct tagMSIVIEW *view, MSIRECORD *rec, UINT row, return ERROR_FUNCTION_FAILED;
if (row == -1) - row = find_insert_index( tv, rec ); + row = find_insert_index( tv, rec, temporary );
r = table_create_new_row( view, &row, temporary ); TRACE("insert_row returned %08x\n", r);