msi: Check that column names are unique when creating a table.
This commit is contained in:
parent
bd9891ffed
commit
2924501a68
|
@ -221,13 +221,31 @@ static const MSIVIEWOPS create_ops =
|
|||
CREATE_delete
|
||||
};
|
||||
|
||||
static UINT check_columns( column_info *col_info )
|
||||
{
|
||||
column_info *c1, *c2;
|
||||
|
||||
/* check for two columns with the same name */
|
||||
for( c1 = col_info; c1; c1 = c1->next )
|
||||
for( c2 = c1->next; c2; c2 = c2->next )
|
||||
if (!lstrcmpW(c1->column, c2->column))
|
||||
return ERROR_BAD_QUERY_SYNTAX;
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
|
||||
column_info *col_info, BOOL temp )
|
||||
{
|
||||
MSICREATEVIEW *cv = NULL;
|
||||
UINT r;
|
||||
|
||||
TRACE("%p\n", cv );
|
||||
|
||||
r = check_columns( col_info );
|
||||
if( r != ERROR_SUCCESS )
|
||||
return r;
|
||||
|
||||
cv = msi_alloc_zero( sizeof *cv );
|
||||
if( !cv )
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
|
|
|
@ -1203,6 +1203,13 @@ static void test_markers(void)
|
|||
r = run_query(hdb, rec, query);
|
||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||
|
||||
/* verify that we just created a table called '?', not 'Fable' */
|
||||
r = try_query(hdb, "SELECT * from `Fable`");
|
||||
ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
|
||||
|
||||
r = try_query(hdb, "SELECT * from `?`");
|
||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||
|
||||
/* try table name as marker without backticks */
|
||||
MsiRecordSetString(rec, 1, "Mable");
|
||||
query = "CREATE TABLE ? ( `One` SHORT NOT NULL, `Two` CHAR(255) PRIMARY KEY `One`)";
|
||||
|
@ -1232,10 +1239,7 @@ static void test_markers(void)
|
|||
MsiRecordSetString(rec, 3, "One");
|
||||
query = "CREATE TABLE `Mable` ( `?` SHORT NOT NULL, `?` CHAR(255) PRIMARY KEY `?`)";
|
||||
r = run_query(hdb, rec, query);
|
||||
todo_wine
|
||||
{
|
||||
ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
|
||||
}
|
||||
ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
|
||||
|
||||
/* try names with backticks, minus definitions */
|
||||
query = "CREATE TABLE `Mable` ( `?`, `?` PRIMARY KEY `?`)";
|
||||
|
@ -1271,6 +1275,9 @@ static void test_markers(void)
|
|||
r = run_query(hdb, 0, query);
|
||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||
|
||||
r = try_query(hdb, "SELECT * from `Table`");
|
||||
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
|
||||
|
||||
/* try values as markers */
|
||||
MsiCloseHandle(rec);
|
||||
rec = MsiCreateRecord(2);
|
||||
|
|
Loading…
Reference in New Issue