Commit 241933e1 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

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

parent 74aa0534
...@@ -161,6 +161,7 @@ UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table, ...@@ -161,6 +161,7 @@ UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
UINT r; UINT r;
column_info *col; column_info *col;
BOOL temp = TRUE; BOOL temp = TRUE;
BOOL tempprim = FALSE;
TRACE("%p\n", cv ); TRACE("%p\n", cv );
...@@ -179,6 +180,14 @@ UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table, ...@@ -179,6 +180,14 @@ UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
if( !col->temporary ) if( !col->temporary )
temp = FALSE; temp = FALSE;
else if ( col->type & MSITYPE_KEY )
tempprim = TRUE;
}
if ( !temp && tempprim )
{
msi_free( cv );
return ERROR_FUNCTION_FAILED;
} }
/* fill the structure */ /* fill the structure */
......
...@@ -45,6 +45,7 @@ typedef struct tag_SQL_input ...@@ -45,6 +45,7 @@ typedef struct tag_SQL_input
MSIDATABASE *db; MSIDATABASE *db;
LPCWSTR command; LPCWSTR command;
DWORD n, len; DWORD n, len;
UINT r;
MSIVIEW **view; /* view structure for the resulting query */ MSIVIEW **view; /* view structure for the resulting query */
struct list *mem; struct list *mem;
} SQL_input; } SQL_input;
...@@ -166,12 +167,16 @@ onecreate: ...@@ -166,12 +167,16 @@ onecreate:
{ {
SQL_input* sql = (SQL_input*) info; SQL_input* sql = (SQL_input*) info;
MSIVIEW *create = NULL; MSIVIEW *create = NULL;
UINT r;
if( !$5 ) if( !$5 )
YYABORT; YYABORT;
CREATE_CreateView( sql->db, &create, $3, $5, FALSE ); r = CREATE_CreateView( sql->db, &create, $3, $5, FALSE );
if( !create ) if( !create )
{
sql->r = r;
YYABORT; YYABORT;
}
$$ = create; $$ = create;
} }
| TK_CREATE TK_TABLE table TK_LP table_def TK_RP TK_HOLD | 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, ...@@ -914,6 +919,7 @@ UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview,
sql.command = command; sql.command = command;
sql.n = 0; sql.n = 0;
sql.len = 0; sql.len = 0;
sql.r = ERROR_BAD_QUERY_SYNTAX;
sql.view = phview; sql.view = phview;
sql.mem = mem; sql.mem = mem;
...@@ -923,7 +929,7 @@ UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview, ...@@ -923,7 +929,7 @@ UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview,
if( r ) if( r )
{ {
*sql.view = NULL; *sql.view = NULL;
return ERROR_BAD_QUERY_SYNTAX; return sql.r;
} }
return ERROR_SUCCESS; return ERROR_SUCCESS;
......
...@@ -3286,14 +3286,12 @@ static void test_temporary_table(void) ...@@ -3286,14 +3286,12 @@ static void test_temporary_table(void)
cond = MsiDatabaseIsTablePersistent(hdb, "T3"); cond = MsiDatabaseIsTablePersistent(hdb, "T3");
ok( cond == MSICONDITION_TRUE, "wrong return condition\n"); 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`)"; query = "CREATE TABLE `T4` ( `B` SHORT NOT NULL, `C` CHAR(255) TEMPORARY PRIMARY KEY `C`)";
r = run_query(hdb, 0, query); r = run_query(hdb, 0, query);
ok(r == ERROR_FUNCTION_FAILED, "failed to add table\n"); ok(r == ERROR_FUNCTION_FAILED, "failed to add table\n");
cond = MsiDatabaseIsTablePersistent(hdb, "T4"); cond = MsiDatabaseIsTablePersistent(hdb, "T4");
ok( cond == MSICONDITION_NONE, "wrong return condition\n"); 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"; query = "CREATE TABLE `T5` ( `B` SHORT NOT NULL TEMP, `C` CHAR(255) TEMP PRIMARY KEY `C`) HOLD";
r = run_query(hdb, 0, query); r = run_query(hdb, 0, query);
......
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