msi: Make sure there's a value for each column when inserting data.
This commit is contained in:
parent
533833b4e1
commit
5699936cf1
|
@ -234,6 +234,14 @@ static const MSIVIEWOPS insert_ops =
|
||||||
INSERT_find_matching_rows
|
INSERT_find_matching_rows
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static UINT count_column_info( column_info *ci )
|
||||||
|
{
|
||||||
|
UINT n = 0;
|
||||||
|
for ( ; ci; ci = ci->next )
|
||||||
|
n++;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
UINT INSERT_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
|
UINT INSERT_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
|
||||||
column_info *columns, column_info *values, BOOL temp )
|
column_info *columns, column_info *values, BOOL temp )
|
||||||
{
|
{
|
||||||
|
@ -243,6 +251,10 @@ UINT INSERT_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
|
||||||
|
|
||||||
TRACE("%p\n", iv );
|
TRACE("%p\n", iv );
|
||||||
|
|
||||||
|
/* there should be one value for each column */
|
||||||
|
if ( count_column_info( columns ) != count_column_info(values) )
|
||||||
|
return ERROR_BAD_QUERY_SYNTAX;
|
||||||
|
|
||||||
r = TABLE_CreateView( db, table, &tv );
|
r = TABLE_CreateView( db, table, &tv );
|
||||||
if( r != ERROR_SUCCESS )
|
if( r != ERROR_SUCCESS )
|
||||||
return r;
|
return r;
|
||||||
|
@ -254,7 +266,7 @@ UINT INSERT_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
|
||||||
tv->ops->delete( tv );
|
tv->ops->delete( tv );
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
iv = msi_alloc_zero( sizeof *iv );
|
iv = msi_alloc_zero( sizeof *iv );
|
||||||
if( !iv )
|
if( !iv )
|
||||||
return ERROR_FUNCTION_FAILED;
|
return ERROR_FUNCTION_FAILED;
|
||||||
|
|
|
@ -162,17 +162,12 @@ static void test_msiinsert(void)
|
||||||
r = do_query(hdb, query, &hrec);
|
r = do_query(hdb, query, &hrec);
|
||||||
ok(r == ERROR_NO_MORE_ITEMS, "MsiViewFetch failed\n");
|
ok(r == ERROR_NO_MORE_ITEMS, "MsiViewFetch failed\n");
|
||||||
|
|
||||||
todo_wine {
|
|
||||||
/* now try a few bad INSERT xqueries */
|
/* now try a few bad INSERT xqueries */
|
||||||
query = "INSERT INTO `phone` ( `id`, `name`, `number` )"
|
query = "INSERT INTO `phone` ( `id`, `name`, `number` )"
|
||||||
"VALUES(?, ?)";
|
"VALUES(?, ?)";
|
||||||
r = MsiDatabaseOpenView(hdb, query, &hview);
|
r = MsiDatabaseOpenView(hdb, query, &hview);
|
||||||
ok(r == ERROR_BAD_QUERY_SYNTAX, "MsiDatabaseOpenView failed\n");
|
ok(r == ERROR_BAD_QUERY_SYNTAX, "MsiDatabaseOpenView failed\n");
|
||||||
|
|
||||||
if (r == ERROR_SUCCESS)
|
|
||||||
r = MsiCloseHandle(hview);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* construct a record to insert */
|
/* construct a record to insert */
|
||||||
hrec = MsiCreateRecord(4);
|
hrec = MsiCreateRecord(4);
|
||||||
r = MsiRecordSetInteger(hrec, 1, 2);
|
r = MsiRecordSetInteger(hrec, 1, 2);
|
||||||
|
|
Loading…
Reference in New Issue