From 4ab109e507bcf29450da18f5935962e340ebf089 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Tue, 25 Jul 2006 11:17:56 +0900 Subject: [PATCH] msi: Fix where queries on 32bit integer columns. --- dlls/msi/query.h | 1 + dlls/msi/tests/db.c | 7 ++----- dlls/msi/where.c | 26 ++++++++++++++++++-------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/dlls/msi/query.h b/dlls/msi/query.h index ea32c69cbce..03ebbdda57e 100644 --- a/dlls/msi/query.h +++ b/dlls/msi/query.h @@ -53,6 +53,7 @@ #define EXPR_STRCMP 7 #define EXPR_WILDCARD 9 #define EXPR_COL_NUMBER_STRING 10 +#define EXPR_COL_NUMBER32 11 struct sql_str { LPCWSTR data; diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c index 5d03ca4aaca..c2681254341 100644 --- a/dlls/msi/tests/db.c +++ b/dlls/msi/tests/db.c @@ -1029,11 +1029,8 @@ static void test_where(void) query = "SELECT * FROM `Media` WHERE `LastSequence` >= 1"; r = do_query(hdb, query, &rec); - todo_wine - { - ok(r == ERROR_SUCCESS, "MsiViewFetch failed: %d\n", r); - ok( check_record( rec, 4, "one.cab"), "wrong cabinet\n"); - } + ok(r == ERROR_SUCCESS, "MsiViewFetch failed: %d\n", r); + ok( check_record( rec, 4, "one.cab"), "wrong cabinet\n"); MsiCloseHandle( hdb ); DeleteFile(msifile); diff --git a/dlls/msi/where.c b/dlls/msi/where.c index 8fbedce4ded..7670bfd9301 100644 --- a/dlls/msi/where.c +++ b/dlls/msi/where.c @@ -99,7 +99,7 @@ static UINT WHERE_set_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT val return wv->table->ops->set_int( wv->table, row, col, val ); } -static UINT INT_evaluate( UINT lval, UINT op, UINT rval ) +static INT INT_evaluate( INT lval, UINT op, INT rval ) { switch( op ) { @@ -156,7 +156,7 @@ static const WCHAR *STRING_evaluate( string_table *st, } static UINT STRCMP_Evaluate( string_table *st, MSIVIEW *table, UINT row, - struct expr *cond, UINT *val, MSIRECORD *record ) + struct expr *cond, INT *val, MSIRECORD *record ) { int sr; const WCHAR *l_str, *r_str; @@ -180,18 +180,25 @@ static UINT STRCMP_Evaluate( string_table *st, MSIVIEW *table, UINT row, } static UINT WHERE_evaluate( MSIDATABASE *db, MSIVIEW *table, UINT row, - struct expr *cond, UINT *val, MSIRECORD *record ) + struct expr *cond, INT *val, MSIRECORD *record ) { - UINT r, lval, rval; + UINT r, tval; + INT lval, rval; if( !cond ) return ERROR_SUCCESS; switch( cond->type ) { - case EXPR_COL_NUMBER_STRING: case EXPR_COL_NUMBER: - return table->ops->fetch_int( table, row, cond->u.col_number, val ); + r = table->ops->fetch_int( table, row, cond->u.col_number, &tval ); + *val = tval - 0x8000; + return ERROR_SUCCESS; + + case EXPR_COL_NUMBER32: + r = table->ops->fetch_int( table, row, cond->u.col_number, &tval ); + *val = tval; + return r; case EXPR_UVAL: *val = cond->u.uval; @@ -226,7 +233,8 @@ static UINT WHERE_evaluate( MSIDATABASE *db, MSIVIEW *table, UINT row, static UINT WHERE_execute( struct tagMSIVIEW *view, MSIRECORD *record ) { MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view; - UINT count = 0, r, val, i; + UINT count = 0, r, i; + INT val; MSIVIEW *table = wv->table; TRACE("%p %p\n", wv, record); @@ -440,6 +448,8 @@ static UINT WHERE_VerifyCondition( MSIDATABASE *db, MSIVIEW *table, struct expr { if (type&MSITYPE_STRING) cond->type = EXPR_COL_NUMBER_STRING; + else if ((type&0xff) == 4) + cond->type = EXPR_COL_NUMBER32; else cond->type = EXPR_COL_NUMBER; cond->u.col_number = val; @@ -490,7 +500,7 @@ static UINT WHERE_VerifyCondition( MSIDATABASE *db, MSIVIEW *table, struct expr case EXPR_IVAL: *valid = 1; cond->type = EXPR_UVAL; - cond->u.uval = cond->u.ival + (1<<15); + cond->u.uval = cond->u.ival; break; case EXPR_WILDCARD: *valid = 1;