msi: Replace lengthy calls to MSI_DatabaseOpenView with MSI_OpenQuery.

This commit is contained in:
James Hawkins 2008-10-08 22:42:50 -05:00 committed by Alexandre Julliard
parent f03889ae82
commit 8128d97fd4
1 changed files with 7 additions and 25 deletions

View File

@ -557,25 +557,16 @@ static UINT msi_add_records_to_table(MSIDATABASE *db, LPWSTR *columns, LPWSTR *t
int num_columns, int num_records) int num_columns, int num_records)
{ {
UINT r; UINT r;
DWORD i, size; DWORD i;
MSIQUERY *view; MSIQUERY *view;
MSIRECORD *rec; MSIRECORD *rec;
LPWSTR query;
static const WCHAR select[] = { static const WCHAR select[] = {
'S','E','L','E','C','T',' ','*',' ', 'S','E','L','E','C','T',' ','*',' ',
'F','R','O','M',' ','`','%','s','`',0 'F','R','O','M',' ','`','%','s','`',0
}; };
size = lstrlenW(select) + lstrlenW(labels[0]) - 1; r = MSI_OpenQuery(db, &view, select, labels[0]);
query = msi_alloc(size * sizeof(WCHAR));
if (!query)
return ERROR_OUTOFMEMORY;
sprintfW(query, select, labels[0]);
r = MSI_DatabaseOpenViewW(db, query, &view);
msi_free(query);
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
return r; return r;
@ -1268,29 +1259,21 @@ static UINT merge_diff_tables(MSIRECORD *rec, LPVOID param)
{ {
MERGEDATA *data = (MERGEDATA *)param; MERGEDATA *data = (MERGEDATA *)param;
MERGETABLE *table; MERGETABLE *table;
MSIQUERY *dbview = NULL; MSIQUERY *dbview;
MSIQUERY *mergeview = NULL; MSIQUERY *mergeview = NULL;
LPCWSTR name; LPCWSTR name;
LPWSTR query;
DWORD size;
UINT r; UINT r;
static const WCHAR fmt[] = {'S','E','L','E','C','T',' ','*',' ', static const WCHAR query[] = {'S','E','L','E','C','T',' ','*',' ',
'F','R','O','M',' ','`','%','s','`',0}; 'F','R','O','M',' ','`','%','s','`',0};
name = MSI_RecordGetString(rec, 1); name = MSI_RecordGetString(rec, 1);
size = lstrlenW(fmt) + lstrlenW(name) - 1;
query = msi_alloc(size * sizeof(WCHAR));
if (!query)
return ERROR_OUTOFMEMORY;
sprintfW(query, fmt, name); r = MSI_OpenQuery(data->db, &dbview, query, name);
r = MSI_DatabaseOpenViewW(data->db, query, &dbview);
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
goto done; return r;
r = MSI_DatabaseOpenViewW(data->merge, query, &mergeview); r = MSI_OpenQuery(data->merge, &mergeview, query, name);
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
goto done; goto done;
@ -1326,7 +1309,6 @@ static UINT merge_diff_tables(MSIRECORD *rec, LPVOID param)
list_add_tail(data->tabledata, &table->entry); list_add_tail(data->tabledata, &table->entry);
done: done:
msi_free(query);
msiobj_release(&dbview->hdr); msiobj_release(&dbview->hdr);
msiobj_release(&mergeview->hdr); msiobj_release(&mergeview->hdr);
return r; return r;