My first analysis was incorrect, its not the compound statement that is broken, but the existing implementation of the WHERE statement in MSI SQL is broken. I've ran several tests to confirm this.
I don't know how this can be replicated in windows, as the problem lies within the existing implementation of wine MSI SQL, the WHERE clause is returning the wrong values.
SELECT * FROM TABLE WHERE Tablevalue >= testvalue should return greater than or equal to, regardless of what platform you run that query on, and it returns the wrong value in wines msi implementation.
Further down in where.txt, which is the result of the WHERE query I saw the QUERY WHERE LastSequence > 1, was returning a 0 at disk 22, which is wrong. The ORDER BY QUERY works fine. The WHERE STATEMENT in the existing wine code is broken. I've ran several other tests, on multiple tables to verify this. My code I used for testing is included below if you would like to have a look at it.
I queried the File table WHERE Sequence >= 8, and in the retuned values the SQL statement returned Sequences 1 to 7, which are less than 8, so the SQL statement isn't functioning properly.
Example 1. I changed the sql statement in my installer to read the following at ready_media_for_file.
SELECT * FROM Media WHERE LastSequence > %i
, and it returns the 1st DiskId, with a LastSequence of 6, even after the LastSequence exceeds 6.
The WHERE STATEMENT is broken in msi SQL.
The installation of the first 6 .dlls works nicely, they are in my C: folder.
trace:msi:ACTION_InstallFiles file paths L"C:\windows\temp\FL_mfc71_dll_1_____X86.3643236F_FC70_11D3_A536_0090278A1BB8" to L"C:\mfc71.dll" trace:msi:ACTION_InstallFiles Pass 2: L"_a8c1851f3c994e35b6e28a65f4793745" trace:msi:MSI_DatabaseOpenViewW L"SELECT * FROM `Media` WHERE `LastSequence`
=7" 0x7fb8f794
trace:msi:msiobj_addref 0x7fd53fd8 trace:msi:msiobj_addref 0x7fd53fd8 trace:msi:MSI_ParseSQL Parse returned 0
trace:msi:ready_media_for_file LastSequence 6 trace:msi:ready_media_for_file Source is CAB L"Disk1.cab"
Example 2: - query from the File table, also returns the wrong values
I also tried querying another table to ensure it is the WHERE statement and not a table specific problem.
here is the result of the SELECT * FROM File WHERE Sequence >= 8
Though this query doesn't return in sequential order like from the Media table, I did find numbers lower than 8 in the results
trace:msi:MSI_DatabaseOpenViewW L"SELECT * FROM `File` WHERE `Sequence` >= 8" 0x7fb8fa38
trace:msi:msiobj_release object 0x7efded70 destroyed trace:msi:MSI_ViewFetch 0x7efdbca0 0x7fb8f9f8 trace:msi:ITERATE_QueryTest File Sequence: 7 trace:msi:msiobj_release object 0x7efded70 destroyed trace:msi:MSI_ViewFetch 0x7efdbca0 0x7fb8f9f8 trace:msi:ITERATE_QueryTest File Sequence: 2 trace:msi:msiobj_release 0x7efded70 trace:msi:msiobj_release object 0x7efded70 destroyed trace:msi:MSI_ViewFetch 0x7efdbca0 0x7fb8f9f8 trace:msi:ITERATE_QueryTest File Sequence: 1 trace:msi:msiobj_release 0x7efded70 trace:msi:msiobj_release object 0x7efded70 destroyed trace:msi:MSI_ViewFetch 0x7efdbca0 0x7fb8f9f8 trace:msi:ITERATE_QueryTest File Sequence: 3 trace:msi:msiobj_release 0x7efded70 trace:msi:msiobj_release object 0x7efded70 destroyed trace:msi:MSI_ViewFetch 0x7efdbca0 0x7fb8f9f8 trace:msi:ITERATE_QueryTest File Sequence: 5 trace:msi:msiobj_release 0x7efded70 trace:msi:msiobj_release object 0x7efded70 destroyed trace:msi:MSI_ViewFetch 0x7efdbca0 0x7fb8f9f8 trace:msi:ITERATE_QueryTest File Sequence: 4
From: "EA Durbin" ead1234@hotmail.com To: dank@kegel.com CC: wine-devel@winehq.org Subject: Re: MSI query tests Date: Thu, 01 Jun 2006 21:51:20 -0500
1. The conformance test suite must run on Windows. This is necessary to provide a reasonable way to verify its accuracy. Furthermore the tests must pass successfully on all Windows platforms (tests not relevant to a given platform should be skipped).
I don't know how I would run this on windows. I edited the wine code itself and queried tables in the MSI database to troubleshoot the behavior of the installer code. Then i retrieved the pertainent values from the results, as in the case of the file table i retrieved the sequence value being returned by the query
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/f...
Here is the code i used to iterate queries
MSIQUERY * view; static const WCHAR ExecSeqQuery[] = {'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','`',' ','>','=',' ','8',0};
rc = MSI_DatabaseOpenViewW( package->db, ExecSeqQuery, &view ); if ( rc != ERROR_SUCCESS ) return ERROR_SUCCESS;
TRACE( "DEBUGGING SELECT * FROM File WHERE Sequence >= 8 \n" ); rc = MSI_IterateRecords( view, NULL, ITERATE_QueryTest, package ); return rc;
static UINT ITERATE_QueryTest( MSIRECORD *row, LPVOID param ) { MSIPACKAGE *package = (MSIPACKAGE*)param; int fileSequence; fileSequence = MSI_RecordGetInteger( row, 8 ); TRACE( "File Sequence: %i \n", fileSequence ); return ERROR_SUCCESS; }
and the Media table i returned the DiskId, cabinet, and LastSequence values from the results
http://msdn.microsoft.com/library/en-us/msi/setup/media_table.asp?frame=true
static UINT ITERATE_QueryTest( MSIRECORD *row, LPVOID param ) { MSIPACKAGE *package = (MSIPACKAGE*)param; int lastSequence, DiskId; LPWSTR cab;
lastSequence = MSI_RecordGetInteger( row, 2 ); DiskId = MSI_RecordGetInteger( row, 1); cab = MSI_RecordGetString( row, 4)
TRACE( " Last Sequence: %u \n", lastSequence ); TRACE( " CAB %s \n", debugstr_w( cab ) ); TRACE( " Disk ID %u \n", DiskId ); return ERROR_SUCCESS; }
From: "Dan Kegel" dank@kegel.com To: "EA Durbin" ead1234@hotmail.com CC: wine-devel@winehq.org Subject: Re: MSI query tests Date: Thu, 1 Jun 2006 19:34:12 -0700
On 6/1/06, EA Durbin ead1234@hotmail.com wrote:
Great. Can you package up the tests as Wine conformance tests?
I'm new to wine, how do I accomplish this?
http://winehq.org/site/docs/winedev-guide/testing has an introduction to the subject. - Dan #
From: Mike McCormack mike@codeweavers.com To: EA Durbin ead1234@hotmail.com CC: wine-devel@winehq.org Subject: Re: MSI Query tests Date: Fri, 02 Jun 2006 12:19:59 +0900
EA Durbin wrote:
SELECT * FROM `Media` WHERE `LastSequence` > 1 that it returns the SQL statement correctly.
Then in orderby.txt i query SELECT * FROM `Media` ORDER BY `LastSequence` and it returns the results as expected.
Then in compoundsql.txt I query SELECT * FROM `Media` WHERE `LastSequence` > 1 ORDER BY `LastSequence`, which is just as the statement appears in InstallFiles().
In this query it ignores the WHERE CLAUSE and uses what is to the far right , the ORDER BY LastSequence statement, which first grabs the LastSequence of 0.
Thanks for the analysis.
Do you think you could add a test case to dlls/msi/tests/db.c that shows the correct behaviour of the above query on Windows for me? If you can do that, I'll have a go at fixing it...
Mike