[3/4] msi: Clean up the database queries.

Hans Leidekker hans at codeweavers.com
Wed Jul 27 03:53:26 CDT 2011


---
 dlls/msi/action.c    |  558 +++++++++++++++++++++-----------------------------
 dlls/msi/alter.c     |    6 +-
 dlls/msi/appsearch.c |   12 +-
 dlls/msi/classes.c   |  133 +++++--------
 dlls/msi/custom.c    |   16 +-
 dlls/msi/database.c  |    9 +-
 dlls/msi/dialog.c    |   76 +++----
 dlls/msi/files.c     |   38 ++--
 dlls/msi/font.c      |   24 +--
 dlls/msi/install.c   |    8 +-
 dlls/msi/msipriv.h   |    2 +-
 dlls/msi/package.c   |  102 ++++-----
 dlls/msi/patch.c     |   12 +-
 dlls/msi/table.c     |   17 +-
 dlls/msi/upgrade.c   |   12 +-
 15 files changed, 432 insertions(+), 593 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 0ac6dba..acc624b 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -406,25 +406,20 @@ WCHAR **msi_split_string( const WCHAR *str, WCHAR sep )
 
 static BOOL ui_sequence_exists( MSIPACKAGE *package )
 {
+    static const WCHAR query [] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','I','n','s','t','a','l','l','U','I','S','e','q','u','e','n','c','e','`',' ',
+        'W','H','E','R','E',' ','`','S','e','q','u','e','n','c','e','`',' ','>',' ','0',' ',
+        'O','R','D','E','R',' ','B','Y',' ','`','S','e','q','u','e','n','c','e','`',0};
     MSIQUERY *view;
     UINT rc;
 
-    static const WCHAR ExecSeqQuery [] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','I','n','s','t','a','l','l',
-         'U','I','S','e','q','u','e','n','c','e','`',
-         ' ','W','H','E','R','E',' ',
-         '`','S','e','q','u','e','n','c','e','`',' ',
-         '>',' ','0',' ','O','R','D','E','R',' ','B','Y',' ',
-         '`','S','e','q','u','e','n','c','e','`',0};
-
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc == ERROR_SUCCESS)
     {
         msiobj_release(&view->hdr);
         return TRUE;
     }
-
     return FALSE;
 }
 
@@ -546,49 +541,44 @@ static UINT ITERATE_Actions(MSIRECORD *row, LPVOID param)
     return rc;
 }
 
-UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable, INT iSequenceMode )
+UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR table )
 {
-    MSIQUERY * view;
-    UINT r;
-    static const WCHAR query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','%','s','`',
-         ' ','W','H','E','R','E',' ', 
-         '`','S','e','q','u','e','n','c','e','`',' ',
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','`','%','s','`',
+         ' ','W','H','E','R','E',' ','`','S','e','q','u','e','n','c','e','`',' ',
          '>',' ','0',' ','O','R','D','E','R',' ','B','Y',' ',
          '`','S','e','q','u','e','n','c','e','`',0};
+    MSIQUERY *view;
+    UINT r;
 
-    TRACE("%p %s %i\n", package, debugstr_w(szTable), iSequenceMode );
+    TRACE("%p %s\n", package, debugstr_w(table));
 
-    r = MSI_OpenQuery( package->db, &view, query, szTable );
+    r = MSI_OpenQuery( package->db, &view, query, table );
     if (r == ERROR_SUCCESS)
     {
         r = MSI_IterateRecords( view, NULL, ITERATE_Actions, package );
         msiobj_release(&view->hdr);
     }
-
     return r;
 }
 
 static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package, BOOL UIran)
 {
-    MSIQUERY * view;
-    UINT rc;
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
-         '`','I','n','s','t','a','l','l','E','x','e','c','u','t','e',
-         'S','e','q','u','e','n','c','e','`',' ', 'W','H','E','R','E',' ',
-         '`','S','e','q','u','e','n','c','e','`',' ', '>',' ','%','i',' ',
-         'O','R','D','E','R',' ', 'B','Y',' ',
-         '`','S','e','q','u','e','n','c','e','`',0 };
-    static const WCHAR IVQuery[] =
-        {'S','E','L','E','C','T',' ','`','S','e','q','u','e','n','c','e','`',
-         ' ', 'F','R','O','M',' ','`','I','n','s','t','a','l','l',
-         'E','x','e','c','u','t','e','S','e','q','u','e','n','c','e','`',' ',
-         'W','H','E','R','E',' ','`','A','c','t','i','o','n','`',' ','=',
-         ' ','\'', 'I','n','s','t','a','l','l',
-         'V','a','l','i','d','a','t','e','\'', 0};
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
+        '`','I','n','s','t','a','l','l','E','x','e','c','u','t','e',
+        'S','e','q','u','e','n','c','e','`',' ', 'W','H','E','R','E',' ',
+        '`','S','e','q','u','e','n','c','e','`',' ', '>',' ','%','i',' ',
+        'O','R','D','E','R',' ', 'B','Y',' ','`','S','e','q','u','e','n','c','e','`',0};
+    static const WCHAR query_validate[] = {
+        'S','E','L','E','C','T',' ','`','S','e','q','u','e','n','c','e','`',
+        ' ', 'F','R','O','M',' ','`','I','n','s','t','a','l','l',
+        'E','x','e','c','u','t','e','S','e','q','u','e','n','c','e','`',' ',
+        'W','H','E','R','E',' ','`','A','c','t','i','o','n','`',' ','=',
+        ' ','\'', 'I','n','s','t','a','l','l','V','a','l','i','d','a','t','e','\'',0};
+    MSIQUERY *view;
     INT seq = 0;
+    UINT rc;
 
     if (package->script->ExecuteSequenceRun)
     {
@@ -601,49 +591,40 @@ static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package, BOOL UIran)
     /* get the sequence number */
     if (UIran)
     {
-        MSIRECORD *row = MSI_QueryGetRecord(package->db, IVQuery);
-        if( !row )
-            return ERROR_FUNCTION_FAILED;
+        MSIRECORD *row = MSI_QueryGetRecord(package->db, query_validate);
+        if (!row) return ERROR_FUNCTION_FAILED;
         seq = MSI_RecordGetInteger(row,1);
         msiobj_release(&row->hdr);
     }
-
-    rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, seq);
+    rc = MSI_OpenQuery(package->db, &view, query, seq);
     if (rc == ERROR_SUCCESS)
     {
         TRACE("Running the actions\n");
 
         msi_set_property(package->db, szSourceDir, NULL);
-
         rc = MSI_IterateRecords(view, NULL, ITERATE_Actions, package);
         msiobj_release(&view->hdr);
     }
-
     return rc;
 }
 
 static UINT ACTION_ProcessUISequence(MSIPACKAGE *package)
 {
-    MSIQUERY * view;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','I','n','s','t','a','l','l','U','I','S','e','q','u','e','n','c','e','`',' ',
+        'W','H','E','R','E',' ','`','S','e','q','u','e','n','c','e','`',' ','>',' ','0',' ',
+        'O','R','D','E','R',' ','B','Y',' ','`','S','e','q','u','e','n','c','e','`',0};
+    MSIQUERY *view;
     UINT rc;
-    static const WCHAR ExecSeqQuery [] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','I','n','s','t','a','l','l',
-         'U','I','S','e','q','u','e','n','c','e','`',
-         ' ','W','H','E','R','E',' ', 
-         '`','S','e','q','u','e','n','c','e','`',' ',
-         '>',' ','0',' ','O','R','D','E','R',' ','B','Y',' ',
-         '`','S','e','q','u','e','n','c','e','`',0};
 
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc == ERROR_SUCCESS)
     {
         TRACE("Running the actions\n"); 
-
         rc = MSI_IterateRecords(view, NULL, ITERATE_Actions, package);
         msiobj_release(&view->hdr);
     }
-
     return rc;
 }
 
@@ -884,20 +865,18 @@ static UINT ITERATE_CreateFolders(MSIRECORD *row, LPVOID param)
 
 static UINT ACTION_CreateFolders(MSIPACKAGE *package)
 {
-    static const WCHAR query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','C','r','e','a','t','e','F','o','l','d','e','r','`',0};
-    UINT rc;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','C','r','e','a','t','e','F','o','l','d','e','r','`',0};
     MSIQUERY *view;
+    UINT rc;
 
-    /* create all the empty folders specified in the CreateFolder table */
-    rc = MSI_DatabaseOpenViewW(package->db, query, &view );
+    rc = MSI_DatabaseOpenViewW( package->db, query, &view );
     if (rc != ERROR_SUCCESS)
         return ERROR_SUCCESS;
 
     rc = MSI_IterateRecords(view, NULL, ITERATE_CreateFolders, package);
     msiobj_release(&view->hdr);
-
     return rc;
 }
 
@@ -952,10 +931,9 @@ static UINT ITERATE_RemoveFolders( MSIRECORD *row, LPVOID param )
 
 static UINT ACTION_RemoveFolders( MSIPACKAGE *package )
 {
-    static const WCHAR query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','C','r','e','a','t','e','F','o','l','d','e','r','`',0};
-
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','C','r','e','a','t','e','F','o','l','d','e','r','`',0};
     MSIQUERY *view;
     UINT rc;
 
@@ -965,7 +943,6 @@ static UINT ACTION_RemoveFolders( MSIPACKAGE *package )
 
     rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveFolders, package );
     msiobj_release( &view->hdr );
-
     return rc;
 }
 
@@ -1002,8 +979,8 @@ static UINT load_component( MSIRECORD *row, LPVOID param )
 UINT msi_load_all_components( MSIPACKAGE *package )
 {
     static const WCHAR query[] = {
-        'S','E','L','E','C','T',' ','*',' ','F','R', 'O','M',' ', 
-         '`','C','o','m','p','o','n','e','n','t','`',0 };
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','C','o','m','p','o','n','e','n','t','`',0};
     MSIQUERY *view;
     UINT r;
 
@@ -1023,7 +1000,6 @@ UINT msi_load_all_components( MSIPACKAGE *package )
 
     r = MSI_IterateRecords(view, NULL, load_component, package);
     msiobj_release(&view->hdr);
-
     msi_destroy_assembly_caches( package );
     return r;
 }
@@ -1083,18 +1059,16 @@ static UINT iterate_load_featurecomponents(MSIRECORD *row, LPVOID param)
 
 static UINT load_feature(MSIRECORD * row, LPVOID param)
 {
-    MSIPACKAGE* package = param;
-    MSIFEATURE* feature;
-    static const WCHAR Query1[] = 
-        {'S','E','L','E','C','T',' ',
-         '`','C','o','m','p','o','n','e','n','t','_','`',
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','`','C','o','m','p','o','n','e','n','t','_','`',
          ' ','F','R','O','M',' ','`','F','e','a','t','u','r','e',
-         'C','o','m','p','o','n','e','n','t','s','`',' ',
-         'W','H','E','R','E',' ',
+         'C','o','m','p','o','n','e','n','t','s','`',' ','W','H','E','R','E',' ',
          '`','F','e', 'a','t','u','r','e','_','`',' ','=','\'','%','s','\'',0};
-    MSIQUERY * view;
-    UINT    rc;
+    MSIPACKAGE *package = param;
+    MSIFEATURE *feature;
+    MSIQUERY *view;
     _ilfs ilfs;
+    UINT rc;
 
     /* fill in the data */
 
@@ -1128,7 +1102,7 @@ static UINT load_feature(MSIRECORD * row, LPVOID param)
 
     /* load feature components */
 
-    rc = MSI_OpenQuery( package->db, &view, Query1, feature->Feature );
+    rc = MSI_OpenQuery( package->db, &view, query, feature->Feature );
     if (rc != ERROR_SUCCESS)
         return ERROR_SUCCESS;
 
@@ -1137,7 +1111,6 @@ static UINT load_feature(MSIRECORD * row, LPVOID param)
 
     MSI_IterateRecords(view, NULL, iterate_load_featurecomponents , &ilfs);
     msiobj_release(&view->hdr);
-
     return ERROR_SUCCESS;
 }
 
@@ -1164,9 +1137,9 @@ static UINT find_feature_children(MSIRECORD * row, LPVOID param)
 UINT msi_load_all_features( MSIPACKAGE *package )
 {
     static const WCHAR query[] = {
-        'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
-        '`','F','e','a','t','u','r','e','`',' ','O','R','D','E','R',
-        ' ','B','Y',' ','`','D','i','s','p','l','a','y','`',0};
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','F','e','a','t','u','r','e','`',' ','O','R','D','E','R',' ','B','Y',' ',
+        '`','D','i','s','p','l','a','y','`',0};
     MSIQUERY *view;
     UINT r;
 
@@ -1179,11 +1152,12 @@ UINT msi_load_all_features( MSIPACKAGE *package )
 
     r = MSI_IterateRecords( view, NULL, load_feature, package );
     if (r != ERROR_SUCCESS)
+    {
+        msiobj_release( &view->hdr );
         return r;
-
+    }
     r = MSI_IterateRecords( view, NULL, find_feature_children, package );
     msiobj_release( &view->hdr );
-
     return r;
 }
 
@@ -1326,23 +1300,22 @@ static UINT load_file(MSIRECORD *row, LPVOID param)
 
 static UINT load_all_files(MSIPACKAGE *package)
 {
-    MSIQUERY * view;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
+        '`','F','i','l','e','`',' ', 'O','R','D','E','R',' ','B','Y',' ',
+        '`','S','e','q','u','e','n','c','e','`', 0};
+    MSIQUERY *view;
     UINT rc;
-    static const WCHAR Query[] =
-        {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
-         '`','F','i','l','e','`',' ', 'O','R','D','E','R',' ','B','Y',' ',
-         '`','S','e','q','u','e','n','c','e','`', 0};
 
     if (!list_empty(&package->files))
         return ERROR_SUCCESS;
 
-    rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return ERROR_SUCCESS;
 
     rc = MSI_IterateRecords(view, NULL, load_file, package);
     msiobj_release(&view->hdr);
-
     return ERROR_SUCCESS;
 }
 
@@ -1360,14 +1333,16 @@ static UINT load_media( MSIRECORD *row, LPVOID param )
 
 static UINT load_all_media( MSIPACKAGE *package )
 {
-    static const WCHAR query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','`','M','e','d','i','a','`',' ',
-         'O','R','D','E','R',' ','B','Y',' ','`','D','i','s','k','I','d','`',0};
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','`',
+        'M','e','d','i','a','`',' ','O','R','D','E','R',' ','B','Y',' ',
+        '`','D','i','s','k','I','d','`',0};
     MSIQUERY *view;
     UINT r;
 
     r = MSI_DatabaseOpenViewW( package->db, query, &view );
-    if (r != ERROR_SUCCESS) return ERROR_SUCCESS;
+    if (r != ERROR_SUCCESS)
+        return ERROR_SUCCESS;
 
     MSI_IterateRecords( view, NULL, load_media, package );
     msiobj_release( &view->hdr );
@@ -1418,23 +1393,22 @@ static UINT load_patch(MSIRECORD *row, LPVOID param)
 
 static UINT load_all_patches(MSIPACKAGE *package)
 {
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','P','a','t','c','h','`',' ','O','R','D','E','R',' ','B','Y',' ',
+        '`','S','e','q','u','e','n','c','e','`',0};
     MSIQUERY *view;
     UINT rc;
-    static const WCHAR Query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','P','a','t','c','h','`',' ','O','R','D','E','R',' ','B','Y',' ',
-         '`','S','e','q','u','e','n','c','e','`',0};
 
     if (!list_empty(&package->filepatches))
         return ERROR_SUCCESS;
 
-    rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return ERROR_SUCCESS;
 
     rc = MSI_IterateRecords(view, NULL, load_patch, package);
     msiobj_release(&view->hdr);
-
     return ERROR_SUCCESS;
 }
 
@@ -1549,8 +1523,8 @@ static UINT find_folder_children( MSIRECORD *row, LPVOID param )
 static UINT load_all_folders( MSIPACKAGE *package )
 {
     static const WCHAR query[] = {
-        'S','E','L','E','C','T',' ','*',' ','F','R', 'O','M',' ',
-         '`','D','i','r','e','c','t','o','r','y','`',0 };
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','D','i','r','e','c','t','o','r','y','`',0};
     MSIQUERY *view;
     UINT r;
 
@@ -2335,14 +2309,15 @@ void msi_resolve_target_folder( MSIPACKAGE *package, const WCHAR *name, BOOL loa
 
 static UINT ACTION_CostFinalize(MSIPACKAGE *package)
 {
-    static const WCHAR condition_query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','`','C','o','n','d','i','t','i','o','n','`',0};
-    static const WCHAR szOutOfDiskSpace[] =
-        {'O','u','t','O','f','D','i','s','k','S','p','a','c','e',0};
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','C','o','n','d','i','t','i','o','n','`',0};
+    static const WCHAR szOutOfDiskSpace[] = {
+        'O','u','t','O','f','D','i','s','k','S','p','a','c','e',0};
     MSICOMPONENT *comp;
-    UINT rc = ERROR_SUCCESS;
-    MSIQUERY * view;
+    MSIQUERY *view;
     LPWSTR level;
+    UINT rc;
 
     TRACE("Building directory properties\n");
     msi_resolve_target_folder( package, szTargetDir, TRUE );
@@ -2367,7 +2342,7 @@ static UINT ACTION_CostFinalize(MSIPACKAGE *package)
     {
         TRACE("Evaluating feature conditions\n");
 
-        rc = MSI_DatabaseOpenViewW( package->db, condition_query, &view );
+        rc = MSI_DatabaseOpenViewW( package->db, query, &view );
         if (rc == ERROR_SUCCESS)
         {
             rc = MSI_IterateRecords( view, NULL, ITERATE_CostFinalizeConditions, package );
@@ -2697,13 +2672,13 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param)
 
 static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package)
 {
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','R','e','g','i','s','t','r','y','`',0};
+    MSIQUERY *view;
     UINT rc;
-    MSIQUERY * view;
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','R','e','g','i','s','t','r','y','`',0 };
 
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return ERROR_SUCCESS;
 
@@ -2882,14 +2857,14 @@ static UINT ITERATE_RemoveRegistryValuesOnInstall( MSIRECORD *row, LPVOID param
 
 static UINT ACTION_RemoveRegistryValues( MSIPACKAGE *package )
 {
-    UINT rc;
+    static const WCHAR registry_query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','R','e','g','i','s','t','r','y','`',0};
+    static const WCHAR remove_registry_query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','R','e','m','o','v','e','R','e','g','i','s','t','r','y','`',0};
     MSIQUERY *view;
-    static const WCHAR registry_query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','R','e','g','i','s','t','r','y','`',0 };
-    static const WCHAR remove_registry_query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','R','e','m','o','v','e','R','e','g','i','s','t','r','y','`',0 };
+    UINT rc;
 
     rc = MSI_DatabaseOpenViewW( package->db, registry_query, &view );
     if (rc == ERROR_SUCCESS)
@@ -2899,7 +2874,6 @@ static UINT ACTION_RemoveRegistryValues( MSIPACKAGE *package )
         if (rc != ERROR_SUCCESS)
             return rc;
     }
-
     rc = MSI_DatabaseOpenViewW( package->db, remove_registry_query, &view );
     if (rc == ERROR_SUCCESS)
     {
@@ -2908,7 +2882,6 @@ static UINT ACTION_RemoveRegistryValues( MSIPACKAGE *package )
         if (rc != ERROR_SUCCESS)
             return rc;
     }
-
     return ERROR_SUCCESS;
 }
 
@@ -2922,19 +2895,19 @@ static UINT ACTION_InstallInitialize(MSIPACKAGE *package)
 
 static UINT ACTION_InstallValidate(MSIPACKAGE *package)
 {
+    static const WCHAR query[]= {
+        'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
+        '`','R','e','g','i','s','t','r','y','`',0};
     MSICOMPONENT *comp;
     DWORD total = 0, count = 0;
-    static const WCHAR q1[]=
-        {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
-         '`','R','e','g','i','s','t','r','y','`',0};
-    UINT rc;
-    MSIQUERY * view;
+    MSIQUERY *view;
     MSIFEATURE *feature;
     MSIFILE *file;
+    UINT rc;
 
     TRACE("InstallValidate\n");
 
-    rc = MSI_DatabaseOpenViewW(package->db, q1, &view);
+    rc = MSI_DatabaseOpenViewW( package->db, query, &view );
     if (rc == ERROR_SUCCESS)
     {
         MSI_IterateRecords( view, &count, NULL, package );
@@ -2955,7 +2928,6 @@ static UINT ACTION_InstallValidate(MSIPACKAGE *package)
               debugstr_w(feature->Feature), feature->Installed,
               feature->ActionRequest, feature->Action);
     }
-    
     return ERROR_SUCCESS;
 }
 
@@ -2991,21 +2963,20 @@ static UINT ITERATE_LaunchConditions(MSIRECORD *row, LPVOID param)
 
 static UINT ACTION_LaunchConditions(MSIPACKAGE *package)
 {
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','L','a','u','n','c','h','C','o','n','d','i','t','i','o','n','`',0};
+    MSIQUERY *view;
     UINT rc;
-    MSIQUERY * view = NULL;
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','L','a','u','n','c','h','C','o','n','d','i','t','i','o','n','`',0};
 
     TRACE("Checking launch conditions\n");
 
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return ERROR_SUCCESS;
 
     rc = MSI_IterateRecords(view, NULL, ITERATE_LaunchConditions, package);
     msiobj_release(&view->hdr);
-
     return rc;
 }
 
@@ -3017,20 +2988,18 @@ static LPWSTR resolve_keypath( MSIPACKAGE* package, MSICOMPONENT *cmp )
 
     if (cmp->Attributes & msidbComponentAttributesRegistryKeyPath)
     {
-        MSIRECORD * row = 0;
-        UINT root,len;
-        LPWSTR deformated,buffer,deformated_name;
-        LPCWSTR key,name;
-        static const WCHAR ExecSeqQuery[] =
-            {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-             '`','R','e','g','i','s','t','r','y','`',' ',
-             'W','H','E','R','E',' ', '`','R','e','g','i','s','t','r','y','`',
-             ' ','=',' ' ,'\'','%','s','\'',0 };
-        static const WCHAR fmt[]={'%','0','2','i',':','\\','%','s','\\',0};
-        static const WCHAR fmt2[]=
-            {'%','0','2','i',':','\\','%','s','\\','%','s',0};
-
-        row = MSI_QueryGetRecord(package->db, ExecSeqQuery,cmp->KeyPath);
+        static const WCHAR query[] = {
+            'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+            '`','R','e','g','i','s','t','r','y','`',' ','W','H','E','R','E',' ',
+            '`','R','e','g','i','s','t','r','y','`',' ','=',' ' ,'\'','%','s','\'',0};
+        static const WCHAR fmt[] = {'%','0','2','i',':','\\','%','s','\\',0};
+        static const WCHAR fmt2[]= {'%','0','2','i',':','\\','%','s','\\','%','s',0};
+        MSIRECORD *row;
+        UINT root, len;
+        LPWSTR deformated, buffer, deformated_name;
+        LPCWSTR key, name;
+
+        row = MSI_QueryGetRecord(package->db, query, cmp->KeyPath);
         if (!row)
             return NULL;
 
@@ -3460,19 +3429,13 @@ static UINT ITERATE_RegisterTypeLibraries(MSIRECORD *row, LPVOID param)
 
 static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package)
 {
-    /* 
-     * OK this is a bit confusing.. I am given a _Component key and I believe
-     * that the file that is being registered as a type library is the "key file
-     * of that component" which I interpret to mean "The file in the KeyPath of
-     * that component".
-     */
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','T','y','p','e','L','i','b','`',0};
+    MSIQUERY *view;
     UINT rc;
-    MSIQUERY * view;
-    static const WCHAR Query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','T','y','p','e','L','i','b','`',0};
 
-    rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return ERROR_SUCCESS;
 
@@ -3527,11 +3490,11 @@ static UINT ITERATE_UnregisterTypeLibraries( MSIRECORD *row, LPVOID param )
 
 static UINT ACTION_UnregisterTypeLibraries( MSIPACKAGE *package )
 {
-    UINT rc;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','T','y','p','e','L','i','b','`',0};
     MSIQUERY *view;
-    static const WCHAR query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','T','y','p','e','L','i','b','`',0};
+    UINT rc;
 
     rc = MSI_DatabaseOpenViewW( package->db, query, &view );
     if (rc != ERROR_SUCCESS)
@@ -3703,14 +3666,14 @@ err:
 
 static UINT ACTION_CreateShortcuts(MSIPACKAGE *package)
 {
-    UINT rc;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','S','h','o','r','t','c','u','t','`',0};
+    MSIQUERY *view;
     HRESULT res;
-    MSIQUERY * view;
-    static const WCHAR Query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','S','h','o','r','t','c','u','t','`',0};
+    UINT rc;
 
-    rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return ERROR_SUCCESS;
 
@@ -3719,9 +3682,7 @@ static UINT ACTION_CreateShortcuts(MSIPACKAGE *package)
     rc = MSI_IterateRecords(view, NULL, ITERATE_CreateShortcuts, package);
     msiobj_release(&view->hdr);
 
-    if (SUCCEEDED(res))
-        CoUninitialize();
-
+    if (SUCCEEDED(res)) CoUninitialize();
     return rc;
 }
 
@@ -3759,11 +3720,11 @@ static UINT ITERATE_RemoveShortcuts( MSIRECORD *row, LPVOID param )
 
 static UINT ACTION_RemoveShortcuts( MSIPACKAGE *package )
 {
-    UINT rc;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','S','h','o','r','t','c','u','t','`',0};
     MSIQUERY *view;
-    static const WCHAR query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','S','h','o','r','t','c','u','t','`',0};
+    UINT rc;
 
     rc = MSI_DatabaseOpenViewW( package->db, query, &view );
     if (rc != ERROR_SUCCESS)
@@ -3771,7 +3732,6 @@ static UINT ACTION_RemoveShortcuts( MSIPACKAGE *package )
 
     rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveShortcuts, package );
     msiobj_release( &view->hdr );
-
     return rc;
 }
 
@@ -3829,12 +3789,11 @@ static UINT ITERATE_PublishIcon(MSIRECORD *row, LPVOID param)
 
 static UINT msi_publish_icons(MSIPACKAGE *package)
 {
-    UINT r;
-    MSIQUERY *view;
-
     static const WCHAR query[]= {
-        'S','E','L','E','C','T',' ','*',' ',
-        'F','R','O','M',' ','`','I','c','o','n','`',0};
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','I','c','o','n','`',0};
+    MSIQUERY *view;
+    UINT r;
 
     r = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (r == ERROR_SUCCESS)
@@ -3842,7 +3801,6 @@ static UINT msi_publish_icons(MSIPACKAGE *package)
         MSI_IterateRecords(view, NULL, ITERATE_PublishIcon, package);
         msiobj_release(&view->hdr);
     }
-
     return ERROR_SUCCESS;
 }
 
@@ -4178,7 +4136,6 @@ end:
 
     RegCloseKey(hukey);
     RegCloseKey(hudkey);
-
     return rc;
 }
 
@@ -4292,18 +4249,15 @@ static UINT ITERATE_WriteIniValues(MSIRECORD *row, LPVOID param)
 
 static UINT ACTION_WriteIniValues(MSIPACKAGE *package)
 {
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','I','n','i','F','i','l','e','`',0};
+    MSIQUERY *view;
     UINT rc;
-    MSIQUERY * view;
-    static const WCHAR ExecSeqQuery[] = 
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','I','n','i','F','i','l','e','`',0};
 
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
-    {
-        TRACE("no IniFile table\n");
         return ERROR_SUCCESS;
-    }
 
     rc = MSI_IterateRecords(view, NULL, ITERATE_WriteIniValues, package);
     msiobj_release(&view->hdr);
@@ -4435,14 +4389,14 @@ static UINT ITERATE_RemoveIniValuesOnInstall( MSIRECORD *row, LPVOID param )
 
 static UINT ACTION_RemoveIniValues( MSIPACKAGE *package )
 {
-    UINT rc;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','I','n','i','F','i','l','e','`',0};
+    static const WCHAR remove_query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','R','e','m','o','v','e','I','n','i','F','i','l','e','`',0};
     MSIQUERY *view;
-    static const WCHAR query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','I','n','i','F','i','l','e','`',0};
-    static const WCHAR remove_query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','R','e','m','o','v','e','I','n','i','F','i','l','e','`',0};
+    UINT rc;
 
     rc = MSI_DatabaseOpenViewW( package->db, query, &view );
     if (rc == ERROR_SUCCESS)
@@ -4452,7 +4406,6 @@ static UINT ACTION_RemoveIniValues( MSIPACKAGE *package )
         if (rc != ERROR_SUCCESS)
             return rc;
     }
-
     rc = MSI_DatabaseOpenViewW( package->db, remove_query, &view );
     if (rc == ERROR_SUCCESS)
     {
@@ -4461,7 +4414,6 @@ static UINT ACTION_RemoveIniValues( MSIPACKAGE *package )
         if (rc != ERROR_SUCCESS)
             return rc;
     }
-
     return ERROR_SUCCESS;
 }
 
@@ -4525,22 +4477,18 @@ static UINT ITERATE_SelfRegModules(MSIRECORD *row, LPVOID param)
 
 static UINT ACTION_SelfRegModules(MSIPACKAGE *package)
 {
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','S','e','l','f','R','e','g','`',0};
+    MSIQUERY *view;
     UINT rc;
-    MSIQUERY * view;
-    static const WCHAR ExecSeqQuery[] = 
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','S','e','l','f','R','e','g','`',0};
 
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
-    {
-        TRACE("no SelfReg table\n");
         return ERROR_SUCCESS;
-    }
 
     MSI_IterateRecords(view, NULL, ITERATE_SelfRegModules, package);
     msiobj_release(&view->hdr);
-
     return ERROR_SUCCESS;
 }
 
@@ -4579,22 +4527,18 @@ static UINT ITERATE_SelfUnregModules( MSIRECORD *row, LPVOID param )
 
 static UINT ACTION_SelfUnregModules( MSIPACKAGE *package )
 {
-    UINT rc;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','S','e','l','f','R','e','g','`',0};
     MSIQUERY *view;
-    static const WCHAR query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','S','e','l','f','R','e','g','`',0};
+    UINT rc;
 
     rc = MSI_DatabaseOpenViewW( package->db, query, &view );
     if (rc != ERROR_SUCCESS)
-    {
-        TRACE("no SelfReg table\n");
         return ERROR_SUCCESS;
-    }
 
     MSI_IterateRecords( view, NULL, ITERATE_SelfUnregModules, package );
     msiobj_release( &view->hdr );
-
     return ERROR_SUCCESS;
 }
 
@@ -5375,20 +5319,18 @@ end:
  */
 static UINT ACTION_PublishComponents(MSIPACKAGE *package)
 {
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','P','u','b','l','i','s','h','C','o','m','p','o','n','e','n','t','`',0};
+    MSIQUERY *view;
     UINT rc;
-    MSIQUERY * view;
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','P','u','b','l','i','s','h',
-         'C','o','m','p','o','n','e','n','t','`',0};
     
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return ERROR_SUCCESS;
 
     rc = MSI_IterateRecords(view, NULL, ITERATE_PublishComponent, package);
     msiobj_release(&view->hdr);
-
     return rc;
 }
 
@@ -5449,12 +5391,11 @@ static UINT ITERATE_UnpublishComponent( MSIRECORD *rec, LPVOID param )
 
 static UINT ACTION_UnpublishComponents( MSIPACKAGE *package )
 {
-    UINT rc;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','P','u','b','l','i','s','h','C','o','m','p','o','n','e','n','t','`',0};
     MSIQUERY *view;
-    static const WCHAR query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','P','u','b','l','i','s','h',
-         'C','o','m','p','o','n','e','n','t','`',0};
+    UINT rc;
 
     rc = MSI_DatabaseOpenViewW( package->db, query, &view );
     if (rc != ERROR_SUCCESS)
@@ -5462,7 +5403,6 @@ static UINT ACTION_UnpublishComponents( MSIPACKAGE *package )
 
     rc = MSI_IterateRecords( view, NULL, ITERATE_UnpublishComponent, package );
     msiobj_release( &view->hdr );
-
     return rc;
 }
 
@@ -5578,19 +5518,18 @@ done:
 
 static UINT ACTION_InstallServices( MSIPACKAGE *package )
 {
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        'S','e','r','v','i','c','e','I','n','s','t','a','l','l',0};
+    MSIQUERY *view;
     UINT rc;
-    MSIQUERY * view;
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         'S','e','r','v','i','c','e','I','n','s','t','a','l','l',0};
     
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return ERROR_SUCCESS;
 
     rc = MSI_IterateRecords(view, NULL, ITERATE_InstallService, package);
     msiobj_release(&view->hdr);
-
     return rc;
 }
 
@@ -5723,12 +5662,11 @@ done:
 
 static UINT ACTION_StartServices( MSIPACKAGE *package )
 {
-    UINT rc;
-    MSIQUERY *view;
-
     static const WCHAR query[] = {
         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-        'S','e','r','v','i','c','e','C','o','n','t','r','o','l',0 };
+        'S','e','r','v','i','c','e','C','o','n','t','r','o','l',0};
+    MSIQUERY *view;
+    UINT rc;
 
     rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
@@ -5736,7 +5674,6 @@ static UINT ACTION_StartServices( MSIPACKAGE *package )
 
     rc = MSI_IterateRecords(view, NULL, ITERATE_StartService, package);
     msiobj_release(&view->hdr);
-
     return rc;
 }
 
@@ -5885,12 +5822,11 @@ done:
 
 static UINT ACTION_StopServices( MSIPACKAGE *package )
 {
-    UINT rc;
-    MSIQUERY *view;
-
     static const WCHAR query[] = {
         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-        'S','e','r','v','i','c','e','C','o','n','t','r','o','l',0 };
+        'S','e','r','v','i','c','e','C','o','n','t','r','o','l',0};
+    MSIQUERY *view;
+    UINT rc;
 
     rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
@@ -5898,7 +5834,6 @@ static UINT ACTION_StopServices( MSIPACKAGE *package )
 
     rc = MSI_IterateRecords(view, NULL, ITERATE_StopService, package);
     msiobj_release(&view->hdr);
-
     return rc;
 }
 
@@ -5973,12 +5908,11 @@ done:
 
 static UINT ACTION_DeleteServices( MSIPACKAGE *package )
 {
-    UINT rc;
-    MSIQUERY *view;
-
     static const WCHAR query[] = {
         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-        'S','e','r','v','i','c','e','C','o','n','t','r','o','l',0 };
+        'S','e','r','v','i','c','e','C','o','n','t','r','o','l',0};
+    MSIQUERY *view;
+    UINT rc;
 
     rc = MSI_DatabaseOpenViewW( package->db, query, &view );
     if (rc != ERROR_SUCCESS)
@@ -5986,7 +5920,6 @@ static UINT ACTION_DeleteServices( MSIPACKAGE *package )
 
     rc = MSI_IterateRecords( view, NULL, ITERATE_DeleteService, package );
     msiobj_release( &view->hdr );
-
     return rc;
 }
 
@@ -6234,20 +6167,17 @@ static UINT ITERATE_InstallODBCDataSource( MSIRECORD *rec, LPVOID param )
 
 static UINT ACTION_InstallODBC( MSIPACKAGE *package )
 {
-    UINT rc;
-    MSIQUERY *view;
-
     static const WCHAR driver_query[] = {
         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-        'O','D','B','C','D','r','i','v','e','r',0 };
-
+        'O','D','B','C','D','r','i','v','e','r',0};
     static const WCHAR translator_query[] = {
         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-        'O','D','B','C','T','r','a','n','s','l','a','t','o','r',0 };
-
+        'O','D','B','C','T','r','a','n','s','l','a','t','o','r',0};
     static const WCHAR source_query[] = {
         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-        'O','D','B','C','D','a','t','a','S','o','u','r','c','e',0 };
+        'O','D','B','C','D','a','t','a','S','o','u','r','c','e',0};
+    MSIQUERY *view;
+    UINT rc;
 
     rc = MSI_DatabaseOpenViewW(package->db, driver_query, &view);
     if (rc != ERROR_SUCCESS)
@@ -6269,7 +6199,6 @@ static UINT ACTION_InstallODBC( MSIPACKAGE *package )
 
     rc = MSI_IterateRecords(view, NULL, ITERATE_InstallODBCDataSource, package);
     msiobj_release(&view->hdr);
-
     return rc;
 }
 
@@ -6412,20 +6341,17 @@ static UINT ITERATE_RemoveODBCDataSource( MSIRECORD *rec, LPVOID param )
 
 static UINT ACTION_RemoveODBC( MSIPACKAGE *package )
 {
-    UINT rc;
-    MSIQUERY *view;
-
     static const WCHAR driver_query[] = {
         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-        'O','D','B','C','D','r','i','v','e','r',0 };
-
+        'O','D','B','C','D','r','i','v','e','r',0};
     static const WCHAR translator_query[] = {
         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-        'O','D','B','C','T','r','a','n','s','l','a','t','o','r',0 };
-
+        'O','D','B','C','T','r','a','n','s','l','a','t','o','r',0};
     static const WCHAR source_query[] = {
         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-        'O','D','B','C','D','a','t','a','S','o','u','r','c','e',0 };
+        'O','D','B','C','D','a','t','a','S','o','u','r','c','e',0};
+    MSIQUERY *view;
+    UINT rc;
 
     rc = MSI_DatabaseOpenViewW( package->db, driver_query, &view );
     if (rc != ERROR_SUCCESS)
@@ -6447,7 +6373,6 @@ static UINT ACTION_RemoveODBC( MSIPACKAGE *package )
 
     rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveODBCDataSource, package );
     msiobj_release( &view->hdr );
-
     return rc;
 }
 
@@ -6744,18 +6669,18 @@ done:
 
 static UINT ACTION_WriteEnvironmentStrings( MSIPACKAGE *package )
 {
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','E','n','v','i','r','o','n','m','e','n','t','`',0};
+    MSIQUERY *view;
     UINT rc;
-    MSIQUERY * view;
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','E','n','v','i','r','o','n','m','e','n','t','`',0};
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return ERROR_SUCCESS;
 
     rc = MSI_IterateRecords(view, NULL, ITERATE_WriteEnvironmentString, package);
     msiobj_release(&view->hdr);
-
     return rc;
 }
 
@@ -6837,11 +6762,11 @@ done:
 
 static UINT ACTION_RemoveEnvironmentStrings( MSIPACKAGE *package )
 {
-    UINT rc;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','E','n','v','i','r','o','n','m','e','n','t','`',0};
     MSIQUERY *view;
-    static const WCHAR query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','E','n','v','i','r','o','n','m','e','n','t','`',0};
+    UINT rc;
 
     rc = MSI_DatabaseOpenViewW( package->db, query, &view );
     if (rc != ERROR_SUCCESS)
@@ -6849,7 +6774,6 @@ static UINT ACTION_RemoveEnvironmentStrings( MSIPACKAGE *package )
 
     rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveEnvironmentString, package );
     msiobj_release( &view->hdr );
-
     return rc;
 }
 
@@ -6917,16 +6841,14 @@ static UINT ACTION_InstallAdminPackage( MSIPACKAGE *package )
 
 static UINT ACTION_SetODBCFolders( MSIPACKAGE *package )
 {
-    UINT r, count;
-    MSIQUERY *view;
-
     static const WCHAR driver_query[] = {
         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-        'O','D','B','C','D','r','i','v','e','r',0 };
-
+        'O','D','B','C','D','r','i','v','e','r',0};
     static const WCHAR translator_query[] = {
         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-        'O','D','B','C','T','r','a','n','s','l','a','t','o','r',0 };
+        'O','D','B','C','T','r','a','n','s','l','a','t','o','r',0};
+    MSIQUERY *view;
+    UINT r, count;
 
     r = MSI_DatabaseOpenViewW( package->db, driver_query, &view );
     if (r == ERROR_SUCCESS)
@@ -6936,7 +6858,6 @@ static UINT ACTION_SetODBCFolders( MSIPACKAGE *package )
         msiobj_release( &view->hdr );
         if (count) FIXME("ignored %u rows in ODBCDriver table\n", count);
     }
-
     r = MSI_DatabaseOpenViewW( package->db, translator_query, &view );
     if (r == ERROR_SUCCESS)
     {
@@ -6945,7 +6866,6 @@ static UINT ACTION_SetODBCFolders( MSIPACKAGE *package )
         msiobj_release( &view->hdr );
         if (count) FIXME("ignored %u rows in ODBCTranslator table\n", count);
     }
-
     return ERROR_SUCCESS;
 }
 
@@ -6965,12 +6885,11 @@ static UINT ITERATE_RemoveExistingProducts( MSIRECORD *rec, LPVOID param )
 
 static UINT ACTION_RemoveExistingProducts( MSIPACKAGE *package )
 {
-    UINT r;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','A','c','t','i','o','n','P','r','o','p','e','r','t','y',' ',
+        'F','R','O','M',' ','U','p','g','r','a','d','e',0};
     MSIQUERY *view;
-
-    static const WCHAR query[] =
-        {'S','E','L','E','C','T',' ','A','c','t','i','o','n','P','r','o','p','e','r','t','y',
-         ' ','F','R','O','M',' ','U','p','g','r','a','d','e',0};
+    UINT r;
 
     r = MSI_DatabaseOpenViewW( package->db, query, &view );
     if (r == ERROR_SUCCESS)
@@ -7019,10 +6938,11 @@ static UINT ITERATE_MigrateFeatureStates( MSIRECORD *rec, LPVOID param )
 
 static UINT ACTION_MigrateFeatureStates( MSIPACKAGE *package )
 {
-    UINT r;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        'U','p','g','r','a','d','e',0};
     MSIQUERY *view;
-    static const WCHAR query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','U','p','g','r','a','d','e',0};
+    UINT r;
 
     if (msi_get_property_int( package->db, szInstalled, 0 ))
     {
@@ -7034,7 +6954,6 @@ static UINT ACTION_MigrateFeatureStates( MSIPACKAGE *package )
         TRACE("Preselected property is set, not migrating feature states\n");
         return ERROR_SUCCESS;
     }
-
     r = MSI_DatabaseOpenViewW( package->db, query, &view );
     if (r == ERROR_SUCCESS)
     {
@@ -7090,10 +7009,11 @@ static UINT ITERATE_BindImage( MSIRECORD *rec, LPVOID param )
 
 static UINT ACTION_BindImage( MSIPACKAGE *package )
 {
-    UINT r;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        'B','i','n','d','I','m','a','g','e',0};
     MSIQUERY *view;
-    static const WCHAR query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','B','i','n','d','I','m','a','g','e',0};
+    UINT r;
 
     r = MSI_DatabaseOpenViewW( package->db, query, &view );
     if (r == ERROR_SUCCESS)
@@ -7104,13 +7024,11 @@ static UINT ACTION_BindImage( MSIPACKAGE *package )
     return ERROR_SUCCESS;
 }
 
-static UINT msi_unimplemented_action_stub( MSIPACKAGE *package,
-                                           LPCSTR action, LPCWSTR table )
+static UINT msi_unimplemented_action_stub( MSIPACKAGE *package, LPCSTR action, LPCWSTR table )
 {
     static const WCHAR query[] = {
-        'S','E','L','E','C','T',' ','*',' ',
-        'F','R','O','M',' ','`','%','s','`',0 };
-    MSIQUERY *view = NULL;
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','`','%','s','`',0};
+    MSIQUERY *view;
     DWORD count = 0;
     UINT r;
     
@@ -7120,11 +7038,7 @@ static UINT msi_unimplemented_action_stub( MSIPACKAGE *package,
         r = MSI_IterateRecords(view, &count, NULL, package);
         msiobj_release(&view->hdr);
     }
-
-    if (count)
-        FIXME("%s -> %u ignored %s table values\n",
-              action, count, debugstr_w(table));
-
+    if (count) FIXME("%s: ignored %u rows from %s\n", action, count, debugstr_w(table));
     return ERROR_SUCCESS;
 }
 
@@ -7331,21 +7245,21 @@ static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq)
     UINT rc = ERROR_SUCCESS;
     MSIRECORD *row;
 
-    static const WCHAR ExecSeqQuery[] =
+    static const WCHAR query[] =
         {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
          '`','I','n','s','t','a','l','l','E','x','e','c','u','t','e',
          'S','e','q','u','e','n','c','e','`',' ', 'W','H','E','R','E',' ',
          '`','S','e','q','u','e','n','c','e','`',' ', '=',' ','%','i',0};
-    static const WCHAR UISeqQuery[] =
+    static const WCHAR ui_query[] =
         {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
      '`','I','n','s','t','a','l','l','U','I','S','e','q','u','e','n','c','e',
      '`', ' ', 'W','H','E','R','E',' ','`','S','e','q','u','e','n','c','e','`',
 	 ' ', '=',' ','%','i',0};
 
     if (needs_ui_sequence(package))
-        row = MSI_QueryGetRecord(package->db, UISeqQuery, seq);
+        row = MSI_QueryGetRecord(package->db, ui_query, seq);
     else
-        row = MSI_QueryGetRecord(package->db, ExecSeqQuery, seq);
+        row = MSI_QueryGetRecord(package->db, query, seq);
 
     if (row)
     {
diff --git a/dlls/msi/alter.c b/dlls/msi/alter.c
index 9daab59..8b11351 100644
--- a/dlls/msi/alter.c
+++ b/dlls/msi/alter.c
@@ -135,8 +135,12 @@ static UINT alter_add_column(MSIALTERVIEW *av)
     {
         r = MSI_IterateRecords(view, NULL, ITERATE_columns, &colnum);
         msiobj_release(&view->hdr);
+        if (r != ERROR_SUCCESS)
+        {
+            columns->ops->delete(columns);
+            return r;
+        }
     }
-
     r = columns->ops->add_column(columns, av->colinfo->table,
                                  colnum, av->colinfo->column,
                                  av->colinfo->type, (av->hold == 1));
diff --git a/dlls/msi/appsearch.c b/dlls/msi/appsearch.c
index f128d95..3e0607f 100644
--- a/dlls/msi/appsearch.c
+++ b/dlls/msi/appsearch.c
@@ -1072,10 +1072,9 @@ static UINT iterate_appsearch(MSIRECORD *row, LPVOID param)
 UINT ACTION_AppSearch(MSIPACKAGE *package)
 {
     static const WCHAR query[] =  {
-        's','e','l','e','c','t',' ','*',' ',
-        'f','r','o','m',' ',
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
         'A','p','p','S','e','a','r','c','h',0};
-    MSIQUERY *view = NULL;
+    MSIQUERY *view;
     UINT r;
 
     if (msi_action_is_unique(package, szAppSearch))
@@ -1092,7 +1091,6 @@ UINT ACTION_AppSearch(MSIPACKAGE *package)
 
     r = MSI_IterateRecords( view, NULL, iterate_appsearch, package );
     msiobj_release( &view->hdr );
-
     return r;
 }
 
@@ -1127,10 +1125,9 @@ static UINT ITERATE_CCPSearch(MSIRECORD *row, LPVOID param)
 UINT ACTION_CCPSearch(MSIPACKAGE *package)
 {
     static const WCHAR query[] =  {
-        's','e','l','e','c','t',' ','*',' ',
-        'f','r','o','m',' ',
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
         'C','C','P','S','e','a','r','c','h',0};
-    MSIQUERY *view = NULL;
+    MSIQUERY *view;
     UINT r;
 
     if (msi_action_is_unique(package, szCCPSearch))
@@ -1147,6 +1144,5 @@ UINT ACTION_CCPSearch(MSIPACKAGE *package)
 
     r = MSI_IterateRecords(view, NULL, ITERATE_CCPSearch, package);
     msiobj_release(&view->hdr);
-
     return r;
 }
diff --git a/dlls/msi/classes.c b/dlls/msi/classes.c
index cd73389..a021ccd 100644
--- a/dlls/msi/classes.c
+++ b/dlls/msi/classes.c
@@ -74,12 +74,12 @@ static MSIAPPID *load_appid( MSIPACKAGE* package, MSIRECORD *row )
 
 static MSIAPPID *load_given_appid( MSIPACKAGE *package, LPCWSTR name )
 {
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','A','p','p','I','d','`',' ','W','H','E','R','E',' ',
+        '`','A','p','p','I','d','`',' ','=',' ','\'','%','s','\'',0};
     MSIRECORD *row;
     MSIAPPID *appid;
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','A','p','p','I','d','`',' ','W','H','E','R','E',' ',
-         '`','A','p','p','I','d','`',' ','=',' ','\'','%','s','\'',0};
 
     if (!name)
         return NULL;
@@ -94,13 +94,12 @@ static MSIAPPID *load_given_appid( MSIPACKAGE *package, LPCWSTR name )
         }
     }
     
-    row = MSI_QueryGetRecord(package->db, ExecSeqQuery, name);
+    row = MSI_QueryGetRecord(package->db, query, name);
     if (!row)
         return NULL;
 
     appid = load_appid(package, row);
     msiobj_release(&row->hdr);
-
     return appid;
 }
 
@@ -179,12 +178,12 @@ static MSIPROGID *load_progid( MSIPACKAGE* package, MSIRECORD *row )
 
 static MSIPROGID *load_given_progid(MSIPACKAGE *package, LPCWSTR name)
 {
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','P','r','o','g','I','d','`',' ','W','H','E','R','E',' ',
+        '`','P','r','o','g','I','d','`',' ','=',' ','\'','%','s','\'',0};
     MSIPROGID *progid;
     MSIRECORD *row;
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','P','r','o','g','I','d','`',' ','W','H','E','R','E',' ',
-         '`','P','r','o','g','I','d','`',' ','=',' ','\'','%','s','\'',0};
 
     if (!name)
         return NULL;
@@ -199,13 +198,12 @@ static MSIPROGID *load_given_progid(MSIPACKAGE *package, LPCWSTR name)
         }
     }
     
-    row = MSI_QueryGetRecord( package->db, ExecSeqQuery, name );
+    row = MSI_QueryGetRecord( package->db, query, name );
     if (!row)
         return NULL;
 
     progid = load_progid(package, row);
     msiobj_release(&row->hdr);
-
     return progid;
 }
 
@@ -310,12 +308,12 @@ static MSICLASS *load_class( MSIPACKAGE* package, MSIRECORD *row )
  */
 static MSICLASS *load_given_class(MSIPACKAGE *package, LPCWSTR classid)
 {
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','C','l','a','s','s','`',' ','W','H','E','R','E',' ',
+        '`','C','L','S','I','D','`',' ','=',' ','\'','%','s','\'',0};
     MSICLASS *cls;
     MSIRECORD *row;
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','C','l','a','s','s','`',' ','W','H','E','R','E',' ',
-         '`','C','L','S','I','D','`',' ','=',' ','\'','%','s','\'',0};
 
     if (!classid)
         return NULL;
@@ -330,13 +328,12 @@ static MSICLASS *load_given_class(MSIPACKAGE *package, LPCWSTR classid)
         }
     }
 
-    row = MSI_QueryGetRecord(package->db, ExecSeqQuery, classid);
+    row = MSI_QueryGetRecord(package->db, query, classid);
     if (!row)
         return NULL;
 
     cls = load_class(package, row);
     msiobj_release(&row->hdr);
-
     return cls;
 }
 
@@ -370,12 +367,11 @@ static MSIMIME *load_mime( MSIPACKAGE* package, MSIRECORD *row )
 
 static MSIMIME *load_given_mime( MSIPACKAGE *package, LPCWSTR mime )
 {
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','M','I','M','E','`',' ','W','H','E','R','E',' ',
+        '`','C','o','n','t','e','n','t','T','y','p','e','`',' ','=',' ','\'','%','s','\'',0};
     MSIRECORD *row;
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','M','I','M','E','`',' ','W','H','E','R','E',' ',
-         '`','C','o','n','t','e','n','t','T','y','p','e','`',' ','=',' ',
-         '\'','%','s','\'',0};
     MSIMIME *mt;
 
     if (!mime)
@@ -391,13 +387,12 @@ static MSIMIME *load_given_mime( MSIPACKAGE *package, LPCWSTR mime )
         }
     }
     
-    row = MSI_QueryGetRecord(package->db, ExecSeqQuery, mime);
+    row = MSI_QueryGetRecord(package->db, query, mime);
     if (!row)
         return NULL;
 
     mt = load_mime(package, row);
     msiobj_release(&row->hdr);
-
     return mt;
 }
 
@@ -440,14 +435,12 @@ static MSIEXTENSION *load_extension( MSIPACKAGE* package, MSIRECORD *row )
  */
 static MSIEXTENSION *load_given_extension( MSIPACKAGE *package, LPCWSTR name )
 {
-    MSIRECORD *row;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','E','x','t','e','n','s','i','o','n','`',' ','W','H','E','R','E',' ',
+        '`','E','x','t','e','n','s','i','o','n','`',' ','=',' ','\'','%','s','\'',0};
     MSIEXTENSION *ext;
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','E','x','t','e','n','s','i','o','n','`',' ',
-         'W','H','E','R','E',' ',
-         '`','E','x','t','e','n','s','i','o','n','`',' ','=',' ',
-         '\'','%','s','\'',0};
+    MSIRECORD *row;
 
     if (!name)
         return NULL;
@@ -465,13 +458,12 @@ static MSIEXTENSION *load_given_extension( MSIPACKAGE *package, LPCWSTR name )
         }
     }
     
-    row = MSI_QueryGetRecord( package->db, ExecSeqQuery, name );
+    row = MSI_QueryGetRecord( package->db, query, name );
     if (!row)
         return NULL;
 
     ext = load_extension(package, row);
     msiobj_release(&row->hdr);
-
     return ext;
 }
 
@@ -548,14 +540,12 @@ static UINT iterate_all_classes(MSIRECORD *rec, LPVOID param)
 
 static VOID load_all_classes(MSIPACKAGE *package)
 {
-    UINT rc = ERROR_SUCCESS;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ','`','C','l','a','s','s','`',0};
     MSIQUERY *view;
+    UINT rc;
 
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
-         '`','C','l','a','s','s','`',0};
-
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return;
 
@@ -595,14 +585,12 @@ static UINT iterate_all_extensions(MSIRECORD *rec, LPVOID param)
 
 static VOID load_all_extensions(MSIPACKAGE *package)
 {
-    UINT rc = ERROR_SUCCESS;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','`','E','x','t','e','n','s','i','o','n','`',0};
     MSIQUERY *view;
+    UINT rc;
 
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','E','x','t','e','n','s','i','o','n','`',0};
-
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    rc = MSI_DatabaseOpenViewW( package->db, query, &view );
     if (rc != ERROR_SUCCESS)
         return;
 
@@ -622,14 +610,13 @@ static UINT iterate_all_progids(MSIRECORD *rec, LPVOID param)
 
 static VOID load_all_progids(MSIPACKAGE *package)
 {
-    UINT rc = ERROR_SUCCESS;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','`','P','r','o','g','I','d','`',' ','F','R','O','M',' ',
+        '`','P','r','o','g','I','d','`',0};
     MSIQUERY *view;
+    UINT rc;
 
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','`','P','r','o','g','I','d','`',' ',
-         'F','R','O','M',' ', '`','P','r','o','g','I','d','`',0};
-
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return;
 
@@ -639,14 +626,12 @@ static VOID load_all_progids(MSIPACKAGE *package)
 
 static VOID load_all_verbs(MSIPACKAGE *package)
 {
-    UINT rc = ERROR_SUCCESS;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','`','V','e','r','b','`',0};
     MSIQUERY *view;
+    UINT rc;
 
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','V','e','r','b','`',0};
-
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return;
 
@@ -666,16 +651,13 @@ static UINT iterate_all_mimes(MSIRECORD *rec, LPVOID param)
 
 static VOID load_all_mimes(MSIPACKAGE *package)
 {
-    UINT rc = ERROR_SUCCESS;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','`','C','o','n','t','e','n','t','T','y','p','e','`',' ',
+        'F','R','O','M',' ','`','M','I','M','E','`',0};
     MSIQUERY *view;
+    UINT rc;
 
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ',
-         '`','C','o','n','t','e','n','t','T','y','p','e','`',
-         ' ','F','R','O','M',' ',
-         '`','M','I','M','E','`',0};
-
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return;
 
@@ -960,7 +942,6 @@ UINT ACTION_RegisterClassInfo(MSIPACKAGE *package)
         msi_ui_actiondata( package, szRegisterClassInfo, uirow );
         msiobj_release(&uirow->hdr);
     }
-
     RegCloseKey(hkey);
     return ERROR_SUCCESS;
 }
@@ -1051,7 +1032,6 @@ UINT ACTION_UnregisterClassInfo( MSIPACKAGE *package )
         msi_ui_actiondata( package, szUnregisterClassInfo, uirow );
         msiobj_release( &uirow->hdr );
     }
-
     RegCloseKey( hkey );
     return ERROR_SUCCESS;
 }
@@ -1132,7 +1112,6 @@ UINT ACTION_RegisterProgIdInfo(MSIPACKAGE *package)
         msi_ui_actiondata( package, szRegisterProgIdInfo, uirow );
         msiobj_release( &uirow->hdr );
     }
-
     return ERROR_SUCCESS;
 }
 
@@ -1167,7 +1146,6 @@ UINT ACTION_UnregisterProgIdInfo( MSIPACKAGE *package )
         msi_ui_actiondata( package, szUnregisterProgIdInfo, uirow );
         msiobj_release( &uirow->hdr );
     }
-
     return ERROR_SUCCESS;
 }
 
@@ -1249,8 +1227,7 @@ static UINT register_verb(MSIPACKAGE *package, LPCWSTR progid,
 
 UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package)
 {
-    static const WCHAR szContentType[] = 
-        {'C','o','n','t','e','n','t',' ','T','y','p','e',0 };
+    static const WCHAR szContentType[] = {'C','o','n','t','e','n','t',' ','T','y','p','e',0};
     HKEY hkey = NULL;
     MSIEXTENSION *ext;
     MSIRECORD *uirow;
@@ -1361,7 +1338,6 @@ UINT ACTION_RegisterExtensionInfo(MSIPACKAGE *package)
         msi_ui_actiondata( package, szRegisterExtensionInfo, uirow );
         msiobj_release(&uirow->hdr);
     }
-
     return ERROR_SUCCESS;
 }
 
@@ -1447,14 +1423,12 @@ UINT ACTION_UnregisterExtensionInfo( MSIPACKAGE *package )
         msi_ui_actiondata( package, szUnregisterExtensionInfo, uirow );
         msiobj_release( &uirow->hdr );
     }
-
     return ERROR_SUCCESS;
 }
 
 UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package)
 {
-    static const WCHAR szExten[] = 
-        {'E','x','t','e','n','s','i','o','n',0 };
+    static const WCHAR szExtension[] = {'E','x','t','e','n','s','i','o','n',0};
     MSIRECORD *uirow;
     MSIMIME *mt;
 
@@ -1462,8 +1436,7 @@ UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package)
 
     LIST_FOR_EACH_ENTRY( mt, &package->mimes, MSIMIME, entry )
     {
-        LPWSTR extension;
-        LPWSTR key;
+        LPWSTR extension, key;
 
         /* 
          * check if the MIME is to be installed. Either as requested by an
@@ -1491,7 +1464,7 @@ UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package)
 
             strcpyW( key, szMIMEDatabase );
             strcatW( key, mt->ContentType );
-            msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, key, szExten, extension );
+            msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, key, szExtension, extension );
 
             if (mt->clsid)
                 msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, key, szCLSID, mt->clsid );
@@ -1505,7 +1478,6 @@ UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package)
         msi_ui_actiondata( package, szRegisterMIMEInfo, uirow );
         msiobj_release( &uirow->hdr );
     }
-
     return ERROR_SUCCESS;
 }
 
@@ -1550,6 +1522,5 @@ UINT ACTION_UnregisterMIMEInfo( MSIPACKAGE *package )
         msi_ui_actiondata( package, szUnregisterMIMEInfo, uirow );
         msiobj_release( &uirow->hdr );
     }
-
     return ERROR_SUCCESS;
 }
diff --git a/dlls/msi/custom.c b/dlls/msi/custom.c
index 5032cfc..16a44c3 100644
--- a/dlls/msi/custom.c
+++ b/dlls/msi/custom.c
@@ -1186,18 +1186,16 @@ static UINT HANDLE_CustomType53_54(MSIPACKAGE *package, LPCWSTR source,
 
 UINT ACTION_CustomAction(MSIPACKAGE *package, LPCWSTR action, UINT script, BOOL execute)
 {
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','C','u','s','t','o','m','A','c','t','i','o','n','`',' ','W','H','E','R','E',' ',
+        '`','A','c','t','i' ,'o','n','`',' ','=',' ','\'','%','s','\'',0};
     UINT rc = ERROR_SUCCESS;
-    MSIRECORD * row = 0;
-    static const WCHAR ExecSeqQuery[] =
-    {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-     '`','C','u','s','t','o' ,'m','A','c','t','i','o','n','`',
-     ' ','W','H','E','R','E',' ','`','A','c','t','i' ,'o','n','`',' ',
-     '=',' ','\'','%','s','\'',0};
+    MSIRECORD *row;
     UINT type;
     LPCWSTR source, target;
     LPWSTR ptr, deferred_data = NULL;
-    LPWSTR action_copy = strdupW(action);
-    WCHAR *deformated=NULL;
+    LPWSTR deformated = NULL, action_copy = strdupW(action);
 
     /* deferred action: [properties]Action */
     if ((ptr = strrchrW(action_copy, ']')))
@@ -1206,7 +1204,7 @@ UINT ACTION_CustomAction(MSIPACKAGE *package, LPCWSTR action, UINT script, BOOL
         action = ptr + 1;
     }
 
-    row = MSI_QueryGetRecord( package->db, ExecSeqQuery, action );
+    row = MSI_QueryGetRecord( package->db, query, action );
     if (!row)
     {
         msi_free(action_copy);
diff --git a/dlls/msi/database.c b/dlls/msi/database.c
index 549cb16..a3e61d9 100644
--- a/dlls/msi/database.c
+++ b/dlls/msi/database.c
@@ -1877,12 +1877,12 @@ done:
 static UINT gather_merge_data(MSIDATABASE *db, MSIDATABASE *merge,
                               struct list *tabledata)
 {
-    UINT r;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','_','T','a','b','l','e','s','`',0};
     MSIQUERY *view;
     MERGEDATA data;
-
-    static const WCHAR query[] = {'S','E','L','E','C','T',' ','*',' ',
-        'F','R','O','M',' ','`','_','T','a','b','l','e','s','`',0};
+    UINT r;
 
     r = MSI_DatabaseOpenViewW(merge, query, &view);
     if (r != ERROR_SUCCESS)
@@ -1892,7 +1892,6 @@ static UINT gather_merge_data(MSIDATABASE *db, MSIDATABASE *merge,
     data.merge = merge;
     data.tabledata = tabledata;
     r = MSI_IterateRecords(view, NULL, merge_diff_tables, &data);
-
     msiobj_release(&view->hdr);
     return r;
 }
diff --git a/dlls/msi/dialog.c b/dlls/msi/dialog.c
index e2a1aac..2210f17 100644
--- a/dlls/msi/dialog.c
+++ b/dlls/msi/dialog.c
@@ -369,11 +369,10 @@ static UINT msi_dialog_set_font( msi_dialog *dialog, HWND hwnd, LPCWSTR name )
 static UINT msi_dialog_build_font_list( msi_dialog *dialog )
 {
     static const WCHAR query[] = {
-      'S','E','L','E','C','T',' ','*',' ',
-      'F','R','O','M',' ','`','T','e','x','t','S','t','y','l','e','`',' ',0
-    };
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','T','e','x','t','S','t','y','l','e','`',0};
+    MSIQUERY *view;
     UINT r;
-    MSIQUERY *view = NULL;
 
     TRACE("dialog %p\n", dialog );
 
@@ -938,12 +937,12 @@ static UINT msi_dialog_control_event( MSIRECORD *rec, LPVOID param )
 static UINT msi_dialog_button_handler( msi_dialog *dialog, msi_control *control, WPARAM param )
 {
     static const WCHAR query[] = {
-      'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-      'C','o','n','t','r','o','l','E','v','e','n','t',' ','W','H','E','R','E',' ',
-      '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',' ','A','N','D',' ',
-      '`','C','o','n','t','r','o','l','_','`',' ','=',' ','\'','%','s','\'',' ',
-      'O','R','D','E','R',' ','B','Y',' ','`','O','r','d','e','r','i','n','g','`',0};
-    MSIQUERY *view = NULL;
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        'C','o','n','t','r','o','l','E','v','e','n','t',' ','W','H','E','R','E',' ',
+        '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',' ','A','N','D',' ',
+        '`','C','o','n','t','r','o','l','_','`',' ','=',' ','\'','%','s','\'',' ',
+        'O','R','D','E','R',' ','B','Y',' ','`','O','r','d','e','r','i','n','g','`',0};
+    MSIQUERY *view;
     UINT r;
 
     if (HIWORD(param) != BN_CLICKED)
@@ -953,9 +952,8 @@ static UINT msi_dialog_button_handler( msi_dialog *dialog, msi_control *control,
     if (r != ERROR_SUCCESS)
     {
         ERR("query failed\n");
-        return 0;
+        return ERROR_SUCCESS;
     }
-
     r = MSI_IterateRecords( view, 0, msi_dialog_control_event, dialog );
     msiobj_release( &view->hdr );
     return r;
@@ -1472,17 +1470,14 @@ static UINT msi_combobox_add_item( MSIRECORD *rec, LPVOID param )
 
 static UINT msi_combobox_add_items( struct msi_combobox_info *info, LPCWSTR property )
 {
-    UINT r;
-    MSIQUERY *view = NULL;
-    DWORD count;
-
     static const WCHAR query[] = {
-        'S','E','L','E','C','T',' ','*',' ',
-        'F','R','O','M',' ','`','C','o','m','b','o','B','o','x','`',' ',
-        'W','H','E','R','E',' ',
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','C','o','m','b','o','B','o','x','`',' ','W','H','E','R','E',' ',
         '`','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',' ',
-        'O','R','D','E','R',' ','B','Y',' ','`','O','r','d','e','r','`',0
-    };
+        'O','R','D','E','R',' ','B','Y',' ','`','O','r','d','e','r','`',0};
+    MSIQUERY *view;
+    DWORD count;
+    UINT r;
 
     r = MSI_OpenQuery( info->dialog->package->db, &view, query, property );
     if (r != ERROR_SUCCESS)
@@ -1545,11 +1540,11 @@ static UINT msi_dialog_set_control_condition( MSIRECORD *rec, LPVOID param )
 static UINT msi_dialog_evaluate_control_conditions( msi_dialog *dialog )
 {
     static const WCHAR query[] = {
-      'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
         'C','o','n','t','r','o','l','C','o','n','d','i','t','i','o','n',' ',
-      'W','H','E','R','E',' ','`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',0};
+        'W','H','E','R','E',' ','`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',0};
     UINT r;
-    MSIQUERY *view = NULL;
+    MSIQUERY *view;
     MSIPACKAGE *package = dialog->package;
 
     TRACE("%p %s\n", dialog, debugstr_w(dialog->name));
@@ -2274,14 +2269,13 @@ static LRESULT WINAPI MSIRadioGroup_WndProc( HWND hWnd, UINT msg, WPARAM wParam,
 static UINT msi_dialog_radiogroup_control( msi_dialog *dialog, MSIRECORD *rec )
 {
     static const WCHAR query[] = {
-        'S','E','L','E','C','T',' ','*',' ',
-        'F','R','O','M',' ','R','a','d','i','o','B','u','t','t','o','n',' ',
-        'W','H','E','R','E',' ',
-           '`','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        'R','a','d','i','o','B','u','t','t','o','n',' ','W','H','E','R','E',' ',
+        '`','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
     UINT r;
     LPCWSTR prop;
     msi_control *control;
-    MSIQUERY *view = NULL;
+    MSIQUERY *view;
     radio_button_group_descr group;
     MSIPACKAGE *package = dialog->package;
     WNDPROC oldproc;
@@ -2760,17 +2754,14 @@ static UINT msi_listbox_add_item( MSIRECORD *rec, LPVOID param )
 
 static UINT msi_listbox_add_items( struct msi_listbox_info *info, LPCWSTR property )
 {
-    UINT r;
-    MSIQUERY *view = NULL;
-    DWORD count;
-
     static const WCHAR query[] = {
-        'S','E','L','E','C','T',' ','*',' ',
-        'F','R','O','M',' ','`','L','i','s','t','B','o','x','`',' ',
-        'W','H','E','R','E',' ',
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','L','i','s','t','B','o','x','`',' ','W','H','E','R','E',' ',
         '`','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',' ',
-        'O','R','D','E','R',' ','B','Y',' ','`','O','r','d','e','r','`',0
-    };
+        'O','R','D','E','R',' ','B','Y',' ','`','O','r','d','e','r','`',0};
+    MSIQUERY *view;
+    DWORD count;
+    UINT r;
 
     r = MSI_OpenQuery( info->dialog->package->db, &view, query, property );
     if ( r != ERROR_SUCCESS )
@@ -3359,12 +3350,11 @@ static UINT msi_dialog_create_controls( MSIRECORD *rec, LPVOID param )
 static UINT msi_dialog_fill_controls( msi_dialog *dialog )
 {
     static const WCHAR query[] = {
-        'S','E','L','E','C','T',' ','*',' ',
-        'F','R','O','M',' ','C','o','n','t','r','o','l',' ',
-        'W','H','E','R','E',' ',
-           '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',0};
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        'C','o','n','t','r','o','l',' ','W','H','E','R','E',' ',
+        '`','D','i','a','l','o','g','_','`',' ','=',' ','\'','%','s','\'',0};
     UINT r;
-    MSIQUERY *view = NULL;
+    MSIQUERY *view;
     MSIPACKAGE *package = dialog->package;
 
     TRACE("%p %s\n", dialog, debugstr_w(dialog->name) );
diff --git a/dlls/msi/files.c b/dlls/msi/files.c
index 5749c69..348ff14 100644
--- a/dlls/msi/files.c
+++ b/dlls/msi/files.c
@@ -880,20 +880,18 @@ done:
 
 UINT ACTION_MoveFiles( MSIPACKAGE *package )
 {
-    UINT rc;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','M','o','v','e','F','i','l','e','`',0};
     MSIQUERY *view;
+    UINT rc;
 
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','M','o','v','e','F','i','l','e','`',0};
-
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return ERROR_SUCCESS;
 
     rc = MSI_IterateRecords(view, NULL, ITERATE_MoveFiles, package);
     msiobj_release(&view->hdr);
-
     return rc;
 }
 
@@ -1014,19 +1012,18 @@ static UINT ITERATE_DuplicateFiles(MSIRECORD *row, LPVOID param)
 
 UINT ACTION_DuplicateFiles(MSIPACKAGE *package)
 {
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','D','u','p','l','i','c','a','t','e','F','i','l','e','`',0};
+    MSIQUERY *view;
     UINT rc;
-    MSIQUERY * view;
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','D','u','p','l','i','c','a','t','e','F','i','l','e','`',0};
 
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return ERROR_SUCCESS;
 
     rc = MSI_IterateRecords(view, NULL, ITERATE_DuplicateFiles, package);
     msiobj_release(&view->hdr);
-
     return rc;
 }
 
@@ -1091,11 +1088,11 @@ static UINT ITERATE_RemoveDuplicateFiles( MSIRECORD *row, LPVOID param )
 
 UINT ACTION_RemoveDuplicateFiles( MSIPACKAGE *package )
 {
-    UINT rc;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','D','u','p','l','i','c','a','t','e','F','i','l','e','`',0};
     MSIQUERY *view;
-    static const WCHAR query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','D','u','p','l','i','c','a','t','e','F','i','l','e','`',0};
+    UINT rc;
 
     rc = MSI_DatabaseOpenViewW( package->db, query, &view );
     if (rc != ERROR_SUCCESS)
@@ -1103,7 +1100,6 @@ UINT ACTION_RemoveDuplicateFiles( MSIPACKAGE *package )
 
     rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveDuplicateFiles, package );
     msiobj_release( &view->hdr );
-
     return rc;
 }
 
@@ -1228,9 +1224,9 @@ static void remove_folder( MSIFOLDER *folder )
 
 UINT ACTION_RemoveFiles( MSIPACKAGE *package )
 {
-    static const WCHAR query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','R','e','m','o','v','e','F','i','l','e','`',0};
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','R','e','m','o','v','e','F','i','l','e','`',0};
     MSIQUERY *view;
     MSICOMPONENT *comp;
     MSIFILE *file;
diff --git a/dlls/msi/font.c b/dlls/msi/font.c
index 1ffe946..fcb9f2d 100644
--- a/dlls/msi/font.c
+++ b/dlls/msi/font.c
@@ -266,22 +266,17 @@ static UINT ITERATE_RegisterFonts(MSIRECORD *row, LPVOID param)
 
 UINT ACTION_RegisterFonts(MSIPACKAGE *package)
 {
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','`','F','o','n','t','`',0};
+    MSIQUERY *view;
     UINT rc;
-    MSIQUERY * view;
-    static const WCHAR ExecSeqQuery[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','F','o','n','t','`',0};
 
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
-    {
-        TRACE("MSI_DatabaseOpenViewW failed: %d\n", rc);
         return ERROR_SUCCESS;
-    }
 
     MSI_IterateRecords(view, NULL, ITERATE_RegisterFonts, package);
     msiobj_release(&view->hdr);
-
     return ERROR_SUCCESS;
 }
 
@@ -351,21 +346,16 @@ static UINT ITERATE_UnregisterFonts( MSIRECORD *row, LPVOID param )
 
 UINT ACTION_UnregisterFonts( MSIPACKAGE *package )
 {
-    UINT r;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','`','F','o','n','t','`',0};
     MSIQUERY *view;
-    static const WCHAR query[] =
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','F','o','n','t','`',0};
+    UINT r;
 
     r = MSI_DatabaseOpenViewW( package->db, query, &view );
     if (r != ERROR_SUCCESS)
-    {
-        TRACE("MSI_DatabaseOpenViewW failed: %u\n", r);
         return ERROR_SUCCESS;
-    }
 
     MSI_IterateRecords( view, NULL, ITERATE_UnregisterFonts, package );
     msiobj_release( &view->hdr );
-
     return ERROR_SUCCESS;
 }
diff --git a/dlls/msi/install.c b/dlls/msi/install.c
index 2be4c6c..d281098 100644
--- a/dlls/msi/install.c
+++ b/dlls/msi/install.c
@@ -119,7 +119,7 @@ UINT WINAPI MsiSequenceA( MSIHANDLE hInstall, LPCSTR szTable, INT iSequenceMode
     LPWSTR szwTable;
     UINT ret;
 
-    TRACE("%s\n", debugstr_a(szTable));
+    TRACE("%s, %d\n", debugstr_a(szTable), iSequenceMode);
 
     szwTable = strdupAtoW(szTable);
     if (szTable && !szwTable)
@@ -138,7 +138,7 @@ UINT WINAPI MsiSequenceW( MSIHANDLE hInstall, LPCWSTR szTable, INT iSequenceMode
     MSIPACKAGE *package;
     UINT ret;
 
-    TRACE("%s\n", debugstr_w(szTable));
+    TRACE("%s, %d\n", debugstr_w(szTable), iSequenceMode);
 
     package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
     if (!package)
@@ -173,10 +173,8 @@ UINT WINAPI MsiSequenceW( MSIHANDLE hInstall, LPCWSTR szTable, INT iSequenceMode
 
         return ERROR_SUCCESS;
     }
-
-    ret = MSI_Sequence( package, szTable, iSequenceMode );
+    ret = MSI_Sequence( package, szTable );
     msiobj_release( &package->hdr );
- 
     return ret;
 }
 
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index bd95660..ce926d3 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -774,7 +774,7 @@ extern UINT msi_apply_registered_patch( MSIPACKAGE *package, LPCWSTR patch_code
 extern UINT MSI_InstallPackage( MSIPACKAGE *, LPCWSTR, LPCWSTR ) DECLSPEC_HIDDEN;
 extern UINT ACTION_DialogBox( MSIPACKAGE*, LPCWSTR) DECLSPEC_HIDDEN;
 extern UINT ACTION_ForceReboot(MSIPACKAGE *package) DECLSPEC_HIDDEN;
-extern UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable, INT iSequenceMode ) DECLSPEC_HIDDEN;
+extern UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable ) DECLSPEC_HIDDEN;
 extern UINT MSI_SetFeatureStates( MSIPACKAGE *package ) DECLSPEC_HIDDEN;
 extern UINT msi_parse_command_line( MSIPACKAGE *package, LPCWSTR szCommandLine, BOOL preserve_case ) DECLSPEC_HIDDEN;
 extern UINT msi_schedule_action( MSIPACKAGE *package, UINT script, const WCHAR *action ) DECLSPEC_HIDDEN;
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index c5094b5..560fde3 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -367,21 +367,20 @@ static void MSI_FreePackage( MSIOBJECTHDR *arg)
 
 static UINT create_temp_property_table(MSIPACKAGE *package)
 {
-    MSIQUERY *view = NULL;
+    static const WCHAR query[] = {
+        'C','R','E','A','T','E',' ','T','A','B','L','E',' ',
+        '`','_','P','r','o','p','e','r','t','y','`',' ','(',' ',
+        '`','_','P','r','o','p','e','r','t','y','`',' ',
+        'C','H','A','R','(','5','6',')',' ','N','O','T',' ','N','U','L','L',' ',
+        'T','E','M','P','O','R','A','R','Y',',',' ',
+        '`','V','a','l','u','e','`',' ','C','H','A','R','(','9','8',')',' ',
+        'N','O','T',' ','N','U','L','L',' ','T','E','M','P','O','R','A','R','Y',
+        ' ','P','R','I','M','A','R','Y',' ','K','E','Y',' ',
+        '`','_','P','r','o','p','e','r','t','y','`',')',' ','H','O','L','D',0};
+    MSIQUERY *view;
     UINT rc;
 
-    static const WCHAR CreateSql[] = {
-       'C','R','E','A','T','E',' ','T','A','B','L','E',' ',
-       '`','_','P','r','o','p','e','r','t','y','`',' ','(',' ',
-       '`','_','P','r','o','p','e','r','t','y','`',' ',
-       'C','H','A','R','(','5','6',')',' ','N','O','T',' ','N','U','L','L',' ',
-       'T','E','M','P','O','R','A','R','Y',',',' ',
-       '`','V','a','l','u','e','`',' ','C','H','A','R','(','9','8',')',' ',
-       'N','O','T',' ','N','U','L','L',' ','T','E','M','P','O','R','A','R','Y',
-       ' ','P','R','I','M','A','R','Y',' ','K','E','Y',' ',
-       '`','_','P','r','o','p','e','r','t','y','`',')',' ','H','O','L','D',0};
-
-    rc = MSI_DatabaseOpenViewW(package->db, CreateSql, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return rc;
 
@@ -393,22 +392,20 @@ static UINT create_temp_property_table(MSIPACKAGE *package)
 
 UINT msi_clone_properties(MSIPACKAGE *package)
 {
-    MSIQUERY *view_select = NULL;
-    UINT rc;
-
     static const WCHAR query_select[] = {
-       'S','E','L','E','C','T',' ','*',' ',
-       'F','R','O','M',' ','`','P','r','o','p','e','r','t','y','`',0};
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','P','r','o','p','e','r','t','y','`',0};
     static const WCHAR query_insert[] = {
-       'I','N','S','E','R','T',' ','i','n','t','o',' ',
-       '`','_','P','r','o','p','e','r','t','y','`',' ',
-       '(','`','_','P','r','o','p','e','r','t','y','`',',',
-       '`','V','a','l','u','e','`',')',' ',
-       'V','A','L','U','E','S',' ','(','?',',','?',')',0};
+        'I','N','S','E','R','T',' ','I','N','T','O',' ',
+        '`','_','P','r','o','p','e','r','t','y','`',' ',
+        '(','`','_','P','r','o','p','e','r','t','y','`',',','`','V','a','l','u','e','`',')',' ',
+        'V','A','L','U','E','S',' ','(','?',',','?',')',0};
     static const WCHAR query_update[] = {
         'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ',
         'S','E','T',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ',
         'W','H','E','R','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','?',0};
+    MSIQUERY *view_select;
+    UINT rc;
 
     rc = MSI_DatabaseOpenViewW( package->db, query_select, &view_select );
     if (rc != ERROR_SUCCESS)
@@ -1934,27 +1931,24 @@ void msi_reset_folders( MSIPACKAGE *package, BOOL source )
 
 UINT msi_set_property( MSIDATABASE *db, LPCWSTR szName, LPCWSTR szValue )
 {
-    MSIQUERY *view;
-    MSIRECORD *row = NULL;
-    UINT rc;
-    DWORD sz = 0;
-    WCHAR Query[1024];
-
-    static const WCHAR Insert[] = {
-        'I','N','S','E','R','T',' ','i','n','t','o',' ',
-        '`','_','P','r','o','p','e','r','t','y','`',' ','(',
-        '`','_','P','r','o','p','e','r','t','y','`',',',
-        '`','V','a','l','u','e','`',')',' ','V','A','L','U','E','S'
-        ,' ','(','?',',','?',')',0};
-    static const WCHAR Update[] = {
-        'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',
-        ' ','s','e','t',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ',
-        'w','h','e','r','e',' ','`','_','P','r','o','p','e','r','t','y','`',
-        ' ','=',' ','\'','%','s','\'',0};
-    static const WCHAR Delete[] = {
+    static const WCHAR insert_query[] = {
+        'I','N','S','E','R','T',' ','I','N','T','O',' ',
+        '`','_','P','r','o','p','e','r','t','y','`',' ',
+        '(','`','_','P','r','o','p','e','r','t','y','`',',','`','V','a','l','u','e','`',')',' ',
+        'V','A','L','U','E','S',' ','(','?',',','?',')',0};
+    static const WCHAR update_query[] = {
+        'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',' ',
+        'S','E','T',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ','W','H','E','R','E',' ',
+        '`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
+    static const WCHAR delete_query[] = {
         'D','E','L','E','T','E',' ','F','R','O','M',' ',
         '`','_','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
         '`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
+    MSIQUERY *view;
+    MSIRECORD *row = NULL;
+    DWORD sz = 0;
+    WCHAR query[1024];
+    UINT rc;
 
     TRACE("%p %s %s\n", db, debugstr_w(szName), debugstr_w(szValue));
 
@@ -1968,35 +1962,32 @@ UINT msi_set_property( MSIDATABASE *db, LPCWSTR szName, LPCWSTR szValue )
     rc = msi_get_property(db, szName, 0, &sz);
     if (!szValue || !*szValue)
     {
-        sprintfW(Query, Delete, szName);
+        sprintfW(query, delete_query, szName);
     }
     else if (rc == ERROR_MORE_DATA || rc == ERROR_SUCCESS)
     {
-        sprintfW(Query, Update, szName);
+        sprintfW(query, update_query, szName);
 
         row = MSI_CreateRecord(1);
         MSI_RecordSetStringW(row, 1, szValue);
     }
     else
     {
-        strcpyW(Query, Insert);
+        strcpyW(query, insert_query);
 
         row = MSI_CreateRecord(2);
         MSI_RecordSetStringW(row, 1, szName);
         MSI_RecordSetStringW(row, 2, szValue);
     }
 
-    rc = MSI_DatabaseOpenViewW(db, Query, &view);
+    rc = MSI_DatabaseOpenViewW(db, query, &view);
     if (rc == ERROR_SUCCESS)
     {
         rc = MSI_ViewExecute(view, row);
         MSI_ViewClose(view);
         msiobj_release(&view->hdr);
     }
-
-    if (row)
-      msiobj_release(&row->hdr);
-
+    if (row) msiobj_release(&row->hdr);
     return rc;
 }
 
@@ -2053,15 +2044,13 @@ UINT WINAPI MsiSetPropertyW( MSIHANDLE hInstall, LPCWSTR szName, LPCWSTR szValue
 
 static MSIRECORD *msi_get_property_row( MSIDATABASE *db, LPCWSTR name )
 {
-    MSIQUERY *view;
-    MSIRECORD *rec, *row = NULL;
-    UINT r;
-
     static const WCHAR query[]= {
         'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ',
-        'F','R','O','M',' ' ,'`','_','P','r','o','p','e','r','t','y','`',
-        ' ','W','H','E','R','E',' ' ,'`','_','P','r','o','p','e','r','t','y','`',
-        '=','?',0};
+        'F','R','O','M',' ' ,'`','_','P','r','o','p','e','r','t','y','`',' ',
+        'W','H','E','R','E',' ' ,'`','_','P','r','o','p','e','r','t','y','`','=','?',0};
+    MSIRECORD *rec, *row = NULL;
+    MSIQUERY *view;
+    UINT r;
 
     if (!name || !*name)
         return NULL;
@@ -2080,7 +2069,6 @@ static MSIRECORD *msi_get_property_row( MSIDATABASE *db, LPCWSTR name )
         MSI_ViewClose(view);
         msiobj_release(&view->hdr);
     }
-
     msiobj_release(&rec->hdr);
     return row;
 }
diff --git a/dlls/msi/patch.c b/dlls/msi/patch.c
index feceabf..1aad85f 100644
--- a/dlls/msi/patch.c
+++ b/dlls/msi/patch.c
@@ -266,7 +266,7 @@ static void patch_offset_list_free( struct patch_offset_list *pos )
 
 static void patch_offset_get_patches( MSIDATABASE *db, UINT last_sequence, struct patch_offset_list *pos )
 {
-    static const WCHAR query_patch[] = {
+    static const WCHAR query[] = {
         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','P','a','t','c','h',' ',
         'W','H','E','R','E',' ','S','e','q','u','e','n','c','e',' ','<','=',' ','?',' ',
         'O','R','D','E','R',' ','B','Y',' ','S','e','q','u','e','n','c','e',0};
@@ -274,7 +274,7 @@ static void patch_offset_get_patches( MSIDATABASE *db, UINT last_sequence, struc
     MSIRECORD *rec;
     UINT r;
 
-    r = MSI_DatabaseOpenViewW( db, query_patch, &view );
+    r = MSI_DatabaseOpenViewW( db, query, &view );
     if (r != ERROR_SUCCESS)
         return;
 
@@ -301,7 +301,7 @@ static void patch_offset_get_patches( MSIDATABASE *db, UINT last_sequence, struc
 
 static void patch_offset_get_files( MSIDATABASE *db, UINT last_sequence, struct patch_offset_list *pos )
 {
-    static const WCHAR query_files[] = {
+    static const WCHAR query[] = {
         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','F','i','l','e',' ',
         'W','H','E','R','E',' ','S','e','q','u','e','n','c','e',' ','<','=',' ','?',' ',
         'O','R','D','E','R',' ','B','Y',' ','S','e','q','u','e','n','c','e',0};
@@ -309,7 +309,7 @@ static void patch_offset_get_files( MSIDATABASE *db, UINT last_sequence, struct
     MSIRECORD *rec;
     UINT r;
 
-    r = MSI_DatabaseOpenViewW( db, query_files, &view );
+    r = MSI_DatabaseOpenViewW( db, query, &view );
     if (r != ERROR_SUCCESS)
         return;
 
@@ -342,7 +342,7 @@ static void patch_offset_get_files( MSIDATABASE *db, UINT last_sequence, struct
 
 static UINT patch_offset_modify_db( MSIDATABASE *db, struct patch_offset_list *pos )
 {
-    static const WCHAR query_files[] = {
+    static const WCHAR query[] = {
         'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','F','i','l','e',' ',
         'W','H','E','R','E',' ','S','e','q','u','e','n','c','e',' ','>','=',' ','?',' ',
         'A','N','D',' ','S','e','q','u','e','n','c','e',' ','<','=',' ','?',' ',
@@ -352,7 +352,7 @@ static UINT patch_offset_modify_db( MSIDATABASE *db, struct patch_offset_list *p
     MSIQUERY *view;
     UINT r;
 
-    r = MSI_DatabaseOpenViewW( db, query_files, &view );
+    r = MSI_DatabaseOpenViewW( db, query, &view );
     if (r != ERROR_SUCCESS)
         return ERROR_SUCCESS;
 
diff --git a/dlls/msi/table.c b/dlls/msi/table.c
index 99a72c6..0ea0727 100644
--- a/dlls/msi/table.c
+++ b/dlls/msi/table.c
@@ -1237,16 +1237,14 @@ static UINT TABLE_get_row( struct tagMSIVIEW *view, UINT row, MSIRECORD **rec )
 
 static UINT msi_addstreamW( MSIDATABASE *db, LPCWSTR name, IStream *data )
 {
-    UINT r;
-    MSIQUERY *query = NULL;
-    MSIRECORD *rec = NULL;
-
     static const WCHAR insert[] = {
-       'I','N','S','E','R','T',' ','I','N','T','O',' ',
-          '`','_','S','t','r','e','a','m','s','`',' ',
-         '(','`','N','a','m','e','`',',',
-             '`','D','a','t','a','`',')',' ',
-         'V','A','L','U','E','S',' ','(','?',',','?',')',0};
+        'I','N','S','E','R','T',' ','I','N','T','O',' ',
+        '`','_','S','t','r','e','a','m','s','`',' ',
+        '(','`','N','a','m','e','`',',','`','D','a','t','a','`',')',' ',
+        'V','A','L','U','E','S',' ','(','?',',','?',')',0};
+    MSIQUERY *query = NULL;
+    MSIRECORD *rec;
+    UINT r;
 
     TRACE("%p %s %p\n", db, debugstr_w(name), data);
 
@@ -1271,7 +1269,6 @@ static UINT msi_addstreamW( MSIDATABASE *db, LPCWSTR name, IStream *data )
 err:
     msiobj_release( &query->hdr );
     msiobj_release( &rec->hdr );
-
     return r;
 }
 
diff --git a/dlls/msi/upgrade.c b/dlls/msi/upgrade.c
index cae5af6..8e843aa 100644
--- a/dlls/msi/upgrade.c
+++ b/dlls/msi/upgrade.c
@@ -205,18 +205,17 @@ static UINT ITERATE_FindRelatedProducts(MSIRECORD *rec, LPVOID param)
 
 UINT ACTION_FindRelatedProducts(MSIPACKAGE *package)
 {
-    static const WCHAR Query[] = 
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',
-         ' ','`','U','p','g','r','a','d','e','`',0};
-    UINT rc = ERROR_SUCCESS;
+    static const WCHAR query[] = {
+        'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+        '`','U','p','g','r','a','d','e','`',0};
     MSIQUERY *view;
+    UINT rc;
 
     if (msi_get_property_int(package->db, szInstalled, 0))
     {
         TRACE("Skipping FindRelatedProducts action: product already installed\n");
         return ERROR_SUCCESS;
     }
-
     if (msi_action_is_unique(package, szFindRelatedProducts))
     {
         TRACE("Skipping FindRelatedProducts action: already done in UI sequence\n");
@@ -225,12 +224,11 @@ UINT ACTION_FindRelatedProducts(MSIPACKAGE *package)
     else
         msi_register_unique_action(package, szFindRelatedProducts);
 
-    rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
+    rc = MSI_DatabaseOpenViewW(package->db, query, &view);
     if (rc != ERROR_SUCCESS)
         return ERROR_SUCCESS;
     
     rc = MSI_IterateRecords(view, NULL, ITERATE_FindRelatedProducts, package);
     msiobj_release(&view->hdr);
-    
     return rc;
 }
-- 
1.7.4.1







More information about the wine-patches mailing list