msi: A non-temporary table cannot have a temporary primary key.

oldstable
James Hawkins 2009-02-25 19:45:22 -08:00 committed by Alexandre Julliard
parent 74aa053485
commit 241933e13c
3 changed files with 17 additions and 4 deletions

View File

@ -161,6 +161,7 @@ UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
UINT r;
column_info *col;
BOOL temp = TRUE;
BOOL tempprim = FALSE;
TRACE("%p\n", cv );
@ -179,6 +180,14 @@ UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
if( !col->temporary )
temp = FALSE;
else if ( col->type & MSITYPE_KEY )
tempprim = TRUE;
}
if ( !temp && tempprim )
{
msi_free( cv );
return ERROR_FUNCTION_FAILED;
}
/* fill the structure */

View File

@ -45,6 +45,7 @@ typedef struct tag_SQL_input
MSIDATABASE *db;
LPCWSTR command;
DWORD n, len;
UINT r;
MSIVIEW **view; /* view structure for the resulting query */
struct list *mem;
} SQL_input;
@ -166,12 +167,16 @@ onecreate:
{
SQL_input* sql = (SQL_input*) info;
MSIVIEW *create = NULL;
UINT r;
if( !$5 )
YYABORT;
CREATE_CreateView( sql->db, &create, $3, $5, FALSE );
r = CREATE_CreateView( sql->db, &create, $3, $5, FALSE );
if( !create )
{
sql->r = r;
YYABORT;
}
$$ = create;
}
| TK_CREATE TK_TABLE table TK_LP table_def TK_RP TK_HOLD
@ -914,6 +919,7 @@ UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview,
sql.command = command;
sql.n = 0;
sql.len = 0;
sql.r = ERROR_BAD_QUERY_SYNTAX;
sql.view = phview;
sql.mem = mem;
@ -923,7 +929,7 @@ UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview,
if( r )
{
*sql.view = NULL;
return ERROR_BAD_QUERY_SYNTAX;
return sql.r;
}
return ERROR_SUCCESS;

View File

@ -3286,14 +3286,12 @@ static void test_temporary_table(void)
cond = MsiDatabaseIsTablePersistent(hdb, "T3");
ok( cond == MSICONDITION_TRUE, "wrong return condition\n");
todo_wine {
query = "CREATE TABLE `T4` ( `B` SHORT NOT NULL, `C` CHAR(255) TEMPORARY PRIMARY KEY `C`)";
r = run_query(hdb, 0, query);
ok(r == ERROR_FUNCTION_FAILED, "failed to add table\n");
cond = MsiDatabaseIsTablePersistent(hdb, "T4");
ok( cond == MSICONDITION_NONE, "wrong return condition\n");
}
query = "CREATE TABLE `T5` ( `B` SHORT NOT NULL TEMP, `C` CHAR(255) TEMP PRIMARY KEY `C`) HOLD";
r = run_query(hdb, 0, query);