Commit f6ae2507 authored by Hib Eris's avatar Hib Eris Committed by Alexandre Julliard

msi: Fix table rows order.

parent efacff81
......@@ -1657,6 +1657,41 @@ static UINT table_validate_new( MSITABLEVIEW *tv, MSIRECORD *rec )
return ERROR_SUCCESS;
}
static UINT find_insert_index( MSITABLEVIEW *tv, MSIRECORD *rec, UINT *pidx )
{
UINT r, idx, j, ivalue, x;
TRACE("%p %p %p\n", tv, rec, pidx);
for (idx = 0; idx < tv->table->row_count; idx++)
{
for (j = 0; j < tv->num_cols; j++ )
{
r = get_table_value_from_record (tv, rec, j+1, &ivalue);
if (r != ERROR_SUCCESS)
break;
r = TABLE_fetch_int(&tv->view, idx, j + 1, &x);
if (r != ERROR_SUCCESS)
return r;
if (ivalue > x)
break;
else if (ivalue == x)
continue;
else {
TRACE("Found %d.\n", idx);
*pidx = idx;
return ERROR_SUCCESS;
}
}
}
TRACE("Found %d.\n", idx);
*pidx = idx;
return ERROR_SUCCESS;
}
static UINT TABLE_insert_row( struct tagMSIVIEW *view, MSIRECORD *rec, UINT row, BOOL temporary )
{
MSITABLEVIEW *tv = (MSITABLEVIEW*)view;
......@@ -1669,6 +1704,13 @@ static UINT TABLE_insert_row( struct tagMSIVIEW *view, MSIRECORD *rec, UINT row,
if( r != ERROR_SUCCESS )
return ERROR_FUNCTION_FAILED;
if (row == -1)
{
r = find_insert_index(tv, rec, &row);
if( r != ERROR_SUCCESS )
return ERROR_FUNCTION_FAILED;
}
r = table_create_new_row( view, &row, temporary );
TRACE("insert_row returned %08x\n", r);
if( r != ERROR_SUCCESS )
......
......@@ -4527,11 +4527,11 @@ static void test_rows_order(void)
sz = sizeof(buffer);
r = MsiRecordGetString(hrec, 1, buffer, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine ok(!lstrcmp(buffer, "A"), "Expected A, got %s\n", buffer);
ok(!lstrcmp(buffer, "A"), "Expected A, got %s\n", buffer);
sz = sizeof(buffer);
r = MsiRecordGetString(hrec, 2, buffer, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine ok(!lstrcmp(buffer, "B"), "Expected B, got %s\n", buffer);
ok(!lstrcmp(buffer, "B"), "Expected B, got %s\n", buffer);
r = MsiCloseHandle(hrec);
ok(r == ERROR_SUCCESS, "failed to close record\n");
......@@ -4540,11 +4540,11 @@ static void test_rows_order(void)
sz = sizeof(buffer);
r = MsiRecordGetString(hrec, 1, buffer, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine ok(!lstrcmp(buffer, "C"), "Expected E, got %s\n", buffer);
ok(!lstrcmp(buffer, "C"), "Expected E, got %s\n", buffer);
sz = sizeof(buffer);
r = MsiRecordGetString(hrec, 2, buffer, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine ok(!lstrcmp(buffer, "E"), "Expected E, got %s\n", buffer);
ok(!lstrcmp(buffer, "E"), "Expected E, got %s\n", buffer);
r = MsiCloseHandle(hrec);
ok(r == ERROR_SUCCESS, "failed to close record\n");
......@@ -4553,11 +4553,11 @@ static void test_rows_order(void)
sz = sizeof(buffer);
r = MsiRecordGetString(hrec, 1, buffer, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine ok(!lstrcmp(buffer, "D"), "Expected D, got %s\n", buffer);
ok(!lstrcmp(buffer, "D"), "Expected D, got %s\n", buffer);
sz = sizeof(buffer);
r = MsiRecordGetString(hrec, 2, buffer, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine ok(!lstrcmp(buffer, "E"), "Expected E, got %s\n", buffer);
ok(!lstrcmp(buffer, "E"), "Expected E, got %s\n", buffer);
r = MsiCloseHandle(hrec);
ok(r == ERROR_SUCCESS, "failed to close record\n");
......@@ -4566,11 +4566,11 @@ static void test_rows_order(void)
sz = sizeof(buffer);
r = MsiRecordGetString(hrec, 1, buffer, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine ok(!lstrcmp(buffer, "F"), "Expected F, got %s\n", buffer);
ok(!lstrcmp(buffer, "F"), "Expected F, got %s\n", buffer);
sz = sizeof(buffer);
r = MsiRecordGetString(hrec, 2, buffer, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine ok(!lstrcmp(buffer, "A"), "Expected A, got %s\n", buffer);
ok(!lstrcmp(buffer, "A"), "Expected A, got %s\n", buffer);
r = MsiCloseHandle(hrec);
ok(r == ERROR_SUCCESS, "failed to close record\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment