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

Alexandre Julliard julliard at winehq.org
Thu Feb 26 09:05:04 CST 2009


Module: wine
Branch: master
Commit: 241933e13ccc07ea32165f6f728ddbda865b6389
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=241933e13ccc07ea32165f6f728ddbda865b6389

Author: James Hawkins <truiken at gmail.com>
Date:   Wed Feb 25 19:45:22 2009 -0800

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

---

 dlls/msi/create.c   |    9 +++++++++
 dlls/msi/sql.y      |   10 ++++++++--
 dlls/msi/tests/db.c |    2 --
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/dlls/msi/create.c b/dlls/msi/create.c
index 571d006..0d4d9cf 100644
--- a/dlls/msi/create.c
+++ b/dlls/msi/create.c
@@ -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 */
diff --git a/dlls/msi/sql.y b/dlls/msi/sql.y
index 0ddbc64..2c87884 100644
--- a/dlls/msi/sql.y
+++ b/dlls/msi/sql.y
@@ -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;
diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c
index 91426ca..5a9f7b1 100644
--- a/dlls/msi/tests/db.c
+++ b/dlls/msi/tests/db.c
@@ -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);




More information about the wine-cvs mailing list