2003-08-13 01:27:48 +00:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
2003-09-08 19:38:45 +00:00
|
|
|
* Copyright 2002 Mike McCormack for CodeWeavers
|
2003-08-13 01:27:48 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2003-08-13 01:27:48 +00:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "msi.h"
|
|
|
|
#include "msiquery.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
#include "objidl.h"
|
|
|
|
#include "msipriv.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
|
|
|
|
#include "query.h"
|
|
|
|
|
2005-11-02 14:24:21 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msidb);
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* below is the query interface to a table */
|
|
|
|
|
|
|
|
typedef struct tagMSIWHEREVIEW
|
|
|
|
{
|
|
|
|
MSIVIEW view;
|
|
|
|
MSIDATABASE *db;
|
|
|
|
MSIVIEW *table;
|
|
|
|
UINT row_count;
|
|
|
|
UINT *reorder;
|
|
|
|
struct expr *cond;
|
|
|
|
} MSIWHEREVIEW;
|
|
|
|
|
|
|
|
static UINT WHERE_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val )
|
|
|
|
{
|
|
|
|
MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view;
|
|
|
|
|
|
|
|
TRACE("%p %d %d %p\n", wv, row, col, val );
|
|
|
|
|
|
|
|
if( !wv->table )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
if( row > wv->row_count )
|
|
|
|
return ERROR_NO_MORE_ITEMS;
|
|
|
|
|
|
|
|
row = wv->reorder[ row ];
|
|
|
|
|
|
|
|
return wv->table->ops->fetch_int( wv->table, row, col, val );
|
|
|
|
}
|
|
|
|
|
2004-07-06 18:56:12 +00:00
|
|
|
static UINT WHERE_fetch_stream( struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm )
|
|
|
|
{
|
|
|
|
MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view;
|
|
|
|
|
|
|
|
TRACE("%p %d %d %p\n", wv, row, col, stm );
|
|
|
|
|
|
|
|
if( !wv->table )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
if( row > wv->row_count )
|
|
|
|
return ERROR_NO_MORE_ITEMS;
|
|
|
|
|
|
|
|
row = wv->reorder[ row ];
|
|
|
|
|
|
|
|
return wv->table->ops->fetch_stream( wv->table, row, col, stm );
|
|
|
|
}
|
|
|
|
|
2004-07-04 00:30:02 +00:00
|
|
|
static UINT WHERE_set_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT val )
|
|
|
|
{
|
|
|
|
MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view;
|
|
|
|
|
|
|
|
TRACE("%p %d %d %04x\n", wv, row, col, val );
|
|
|
|
|
|
|
|
if( !wv->table )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
if( row > wv->row_count )
|
|
|
|
return ERROR_NO_MORE_ITEMS;
|
|
|
|
|
|
|
|
row = wv->reorder[ row ];
|
|
|
|
|
|
|
|
return wv->table->ops->set_int( wv->table, row, col, val );
|
|
|
|
}
|
|
|
|
|
2003-08-13 01:27:48 +00:00
|
|
|
static UINT INT_evaluate( UINT lval, UINT op, UINT rval )
|
|
|
|
{
|
|
|
|
switch( op )
|
|
|
|
{
|
|
|
|
case OP_EQ:
|
|
|
|
return ( lval == rval );
|
|
|
|
case OP_AND:
|
|
|
|
return ( lval && rval );
|
|
|
|
case OP_OR:
|
|
|
|
return ( lval || rval );
|
|
|
|
case OP_GT:
|
|
|
|
return ( lval > rval );
|
|
|
|
case OP_LT:
|
|
|
|
return ( lval < rval );
|
|
|
|
case OP_LE:
|
|
|
|
return ( lval <= rval );
|
|
|
|
case OP_GE:
|
|
|
|
return ( lval >= rval );
|
|
|
|
case OP_NE:
|
|
|
|
return ( lval != rval );
|
|
|
|
case OP_ISNULL:
|
|
|
|
return ( !lval );
|
|
|
|
case OP_NOTNULL:
|
|
|
|
return ( lval );
|
|
|
|
default:
|
|
|
|
ERR("Unknown operator %d\n", op );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-06-30 18:18:27 +00:00
|
|
|
static const WCHAR *STRING_evaluate( string_table *st,
|
2004-07-09 22:25:34 +00:00
|
|
|
MSIVIEW *table, UINT row, struct expr *expr, MSIRECORD *record )
|
2004-06-26 00:11:08 +00:00
|
|
|
{
|
|
|
|
UINT val = 0, r;
|
|
|
|
|
|
|
|
switch( expr->type )
|
|
|
|
{
|
2004-12-22 15:22:12 +00:00
|
|
|
case EXPR_COL_NUMBER_STRING:
|
2004-06-26 00:11:08 +00:00
|
|
|
r = table->ops->fetch_int( table, row, expr->u.col_number, &val );
|
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
return NULL;
|
|
|
|
return msi_string_lookup_id( st, val );
|
|
|
|
|
2004-06-30 18:18:27 +00:00
|
|
|
case EXPR_SVAL:
|
|
|
|
return expr->u.sval;
|
|
|
|
|
|
|
|
case EXPR_WILDCARD:
|
|
|
|
return MSI_RecordGetString( record, 1 );
|
2004-06-26 00:11:08 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
ERR("Invalid expression type\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT STRCMP_Evaluate( string_table *st, MSIVIEW *table, UINT row,
|
2004-07-09 22:25:34 +00:00
|
|
|
struct expr *cond, UINT *val, MSIRECORD *record )
|
2004-06-26 00:11:08 +00:00
|
|
|
{
|
|
|
|
int sr;
|
2004-06-30 18:18:27 +00:00
|
|
|
const WCHAR *l_str, *r_str;
|
2004-06-26 00:11:08 +00:00
|
|
|
|
2004-06-30 18:18:27 +00:00
|
|
|
l_str = STRING_evaluate( st, table, row, cond->u.expr.left, record );
|
|
|
|
r_str = STRING_evaluate( st, table, row, cond->u.expr.right, record );
|
2004-06-26 00:11:08 +00:00
|
|
|
if( l_str == r_str )
|
|
|
|
sr = 0;
|
|
|
|
else if( l_str && ! r_str )
|
|
|
|
sr = 1;
|
|
|
|
else if( r_str && ! l_str )
|
|
|
|
sr = -1;
|
|
|
|
else
|
2005-05-29 20:08:12 +00:00
|
|
|
sr = lstrcmpW( l_str, r_str );
|
2004-06-26 00:11:08 +00:00
|
|
|
|
|
|
|
*val = ( cond->u.expr.op == OP_EQ && ( sr == 0 ) ) ||
|
|
|
|
( cond->u.expr.op == OP_LT && ( sr < 0 ) ) ||
|
|
|
|
( cond->u.expr.op == OP_GT && ( sr > 0 ) );
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT WHERE_evaluate( MSIDATABASE *db, MSIVIEW *table, UINT row,
|
2004-07-09 22:25:34 +00:00
|
|
|
struct expr *cond, UINT *val, MSIRECORD *record )
|
2003-08-13 01:27:48 +00:00
|
|
|
{
|
|
|
|
UINT r, lval, rval;
|
|
|
|
|
|
|
|
if( !cond )
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
switch( cond->type )
|
|
|
|
{
|
2004-12-22 15:22:12 +00:00
|
|
|
case EXPR_COL_NUMBER_STRING:
|
2003-08-13 01:27:48 +00:00
|
|
|
case EXPR_COL_NUMBER:
|
|
|
|
return table->ops->fetch_int( table, row, cond->u.col_number, val );
|
|
|
|
|
|
|
|
case EXPR_UVAL:
|
|
|
|
*val = cond->u.uval;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
case EXPR_COMPLEX:
|
2004-06-30 18:18:27 +00:00
|
|
|
r = WHERE_evaluate( db, table, row, cond->u.expr.left, &lval, record );
|
2003-08-13 01:27:48 +00:00
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
return r;
|
2004-06-30 18:18:27 +00:00
|
|
|
r = WHERE_evaluate( db, table, row, cond->u.expr.right, &rval, record );
|
2003-08-13 01:27:48 +00:00
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
return r;
|
|
|
|
*val = INT_evaluate( lval, cond->u.expr.op, rval );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2004-06-26 00:11:08 +00:00
|
|
|
case EXPR_STRCMP:
|
2004-06-30 18:18:27 +00:00
|
|
|
return STRCMP_Evaluate( db->strings, table, row, cond, val, record );
|
|
|
|
|
|
|
|
case EXPR_WILDCARD:
|
2004-07-09 22:25:34 +00:00
|
|
|
*val = MSI_RecordGetInteger( record, 1 );
|
2004-06-30 18:18:27 +00:00
|
|
|
return ERROR_SUCCESS;
|
2004-06-26 00:11:08 +00:00
|
|
|
|
2003-08-13 01:27:48 +00:00
|
|
|
default:
|
|
|
|
ERR("Invalid expression type\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
static UINT WHERE_execute( struct tagMSIVIEW *view, MSIRECORD *record )
|
2003-08-13 01:27:48 +00:00
|
|
|
{
|
|
|
|
MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view;
|
|
|
|
UINT count = 0, r, val, i;
|
|
|
|
MSIVIEW *table = wv->table;
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
TRACE("%p %p\n", wv, record);
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
if( !table )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
r = table->ops->execute( table, record );
|
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = table->ops->get_dimensions( table, &count, NULL );
|
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
return r;
|
|
|
|
|
2005-09-26 10:55:18 +00:00
|
|
|
msi_free( wv->reorder );
|
2005-09-20 11:57:19 +00:00
|
|
|
wv->reorder = msi_alloc( count*sizeof(UINT) );
|
2003-08-13 01:27:48 +00:00
|
|
|
if( !wv->reorder )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2005-02-16 16:06:05 +00:00
|
|
|
wv->row_count = 0;
|
2003-08-13 01:27:48 +00:00
|
|
|
for( i=0; i<count; i++ )
|
|
|
|
{
|
|
|
|
val = 0;
|
2004-06-30 18:18:27 +00:00
|
|
|
r = WHERE_evaluate( wv->db, table, i, wv->cond, &val, record );
|
2003-08-13 01:27:48 +00:00
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
return r;
|
|
|
|
if( val )
|
|
|
|
wv->reorder[ wv->row_count ++ ] = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT WHERE_close( struct tagMSIVIEW *view )
|
|
|
|
{
|
|
|
|
MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view;
|
|
|
|
|
|
|
|
TRACE("%p\n", wv );
|
|
|
|
|
|
|
|
if( !wv->table )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2005-09-20 11:57:19 +00:00
|
|
|
msi_free( wv->reorder );
|
2003-08-13 01:27:48 +00:00
|
|
|
wv->reorder = NULL;
|
|
|
|
|
|
|
|
return wv->table->ops->close( wv->table );
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT WHERE_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *cols )
|
|
|
|
{
|
|
|
|
MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view;
|
|
|
|
|
|
|
|
TRACE("%p %p %p\n", wv, rows, cols );
|
|
|
|
|
|
|
|
if( !wv->table )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
if( rows )
|
|
|
|
{
|
|
|
|
if( !wv->reorder )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
*rows = wv->row_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return wv->table->ops->get_dimensions( wv->table, NULL, cols );
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT WHERE_get_column_info( struct tagMSIVIEW *view,
|
|
|
|
UINT n, LPWSTR *name, UINT *type )
|
|
|
|
{
|
|
|
|
MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view;
|
|
|
|
|
|
|
|
TRACE("%p %d %p %p\n", wv, n, name, type );
|
|
|
|
|
|
|
|
if( !wv->table )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
return wv->table->ops->get_column_info( wv->table, n, name, type );
|
|
|
|
}
|
|
|
|
|
2005-02-08 13:44:25 +00:00
|
|
|
static UINT WHERE_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode,
|
|
|
|
MSIRECORD *rec )
|
2003-08-13 01:27:48 +00:00
|
|
|
{
|
|
|
|
MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view;
|
|
|
|
|
2005-02-08 13:44:25 +00:00
|
|
|
TRACE("%p %d %p\n", wv, eModifyMode, rec );
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
if( !wv->table )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2005-02-08 13:44:25 +00:00
|
|
|
return wv->table->ops->modify( wv->table, eModifyMode, rec );
|
2003-08-13 01:27:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static UINT WHERE_delete( struct tagMSIVIEW *view )
|
|
|
|
{
|
|
|
|
MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view;
|
|
|
|
|
|
|
|
TRACE("%p\n", wv );
|
|
|
|
|
|
|
|
if( wv->table )
|
|
|
|
wv->table->ops->delete( wv->table );
|
2005-09-26 10:55:18 +00:00
|
|
|
wv->table = 0;
|
2003-08-13 01:27:48 +00:00
|
|
|
|
2005-09-20 11:57:19 +00:00
|
|
|
msi_free( wv->reorder );
|
2003-08-13 01:27:48 +00:00
|
|
|
wv->reorder = NULL;
|
|
|
|
wv->row_count = 0;
|
|
|
|
|
2004-07-09 22:25:34 +00:00
|
|
|
msiobj_release( &wv->db->hdr );
|
2005-09-20 11:57:19 +00:00
|
|
|
msi_free( wv );
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MSIVIEWOPS where_ops =
|
|
|
|
{
|
|
|
|
WHERE_fetch_int,
|
2004-07-06 18:56:12 +00:00
|
|
|
WHERE_fetch_stream,
|
2004-07-04 00:30:02 +00:00
|
|
|
WHERE_set_int,
|
2004-03-19 01:16:36 +00:00
|
|
|
NULL,
|
2003-08-13 01:27:48 +00:00
|
|
|
WHERE_execute,
|
|
|
|
WHERE_close,
|
|
|
|
WHERE_get_dimensions,
|
|
|
|
WHERE_get_column_info,
|
|
|
|
WHERE_modify,
|
|
|
|
WHERE_delete
|
|
|
|
};
|
|
|
|
|
2004-06-26 00:11:08 +00:00
|
|
|
static UINT WHERE_VerifyCondition( MSIDATABASE *db, MSIVIEW *table, struct expr *cond,
|
2003-08-13 01:27:48 +00:00
|
|
|
UINT *valid )
|
|
|
|
{
|
2004-06-30 18:18:27 +00:00
|
|
|
UINT r, val = 0;
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
switch( cond->type )
|
|
|
|
{
|
|
|
|
case EXPR_COLUMN:
|
2004-06-26 00:11:08 +00:00
|
|
|
r = VIEW_find_column( table, cond->u.column, &val );
|
2003-08-13 01:27:48 +00:00
|
|
|
if( r == ERROR_SUCCESS )
|
|
|
|
{
|
2004-12-22 15:22:12 +00:00
|
|
|
UINT type = 0;
|
|
|
|
r = table->ops->get_column_info( table, val, NULL, &type );
|
|
|
|
if( r == ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
if (type&MSITYPE_STRING)
|
|
|
|
cond->type = EXPR_COL_NUMBER_STRING;
|
|
|
|
else
|
|
|
|
cond->type = EXPR_COL_NUMBER;
|
|
|
|
cond->u.col_number = val;
|
|
|
|
*valid = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*valid = 0;
|
2003-08-13 01:27:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*valid = 0;
|
|
|
|
ERR("Couldn't find column %s\n", debugstr_w( cond->u.column ) );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EXPR_COMPLEX:
|
2004-06-26 00:11:08 +00:00
|
|
|
r = WHERE_VerifyCondition( db, table, cond->u.expr.left, valid );
|
2003-08-13 01:27:48 +00:00
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
return r;
|
|
|
|
if( !*valid )
|
|
|
|
return ERROR_SUCCESS;
|
2004-06-26 00:11:08 +00:00
|
|
|
r = WHERE_VerifyCondition( db, table, cond->u.expr.right, valid );
|
2003-08-13 01:27:48 +00:00
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
return r;
|
2004-06-26 00:11:08 +00:00
|
|
|
|
|
|
|
/* check the type of the comparison */
|
2004-06-30 18:18:27 +00:00
|
|
|
if( ( cond->u.expr.left->type == EXPR_SVAL ) ||
|
2004-12-22 15:22:12 +00:00
|
|
|
( cond->u.expr.left->type == EXPR_COL_NUMBER_STRING ) ||
|
|
|
|
( cond->u.expr.right->type == EXPR_SVAL ) ||
|
|
|
|
( cond->u.expr.right->type == EXPR_COL_NUMBER_STRING ) )
|
2004-06-26 00:11:08 +00:00
|
|
|
{
|
|
|
|
switch( cond->u.expr.op )
|
|
|
|
{
|
|
|
|
case OP_EQ:
|
|
|
|
case OP_GT:
|
|
|
|
case OP_LT:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*valid = FALSE;
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: check we're comparing a string to a column */
|
|
|
|
|
|
|
|
cond->type = EXPR_STRCMP;
|
|
|
|
}
|
|
|
|
|
2003-08-13 01:27:48 +00:00
|
|
|
break;
|
|
|
|
case EXPR_IVAL:
|
|
|
|
*valid = 1;
|
|
|
|
cond->type = EXPR_UVAL;
|
|
|
|
cond->u.uval = cond->u.ival + (1<<15);
|
|
|
|
break;
|
2004-06-30 18:18:27 +00:00
|
|
|
case EXPR_WILDCARD:
|
|
|
|
*valid = 1;
|
|
|
|
break;
|
2003-08-13 01:27:48 +00:00
|
|
|
case EXPR_SVAL:
|
2004-06-26 00:11:08 +00:00
|
|
|
*valid = 1;
|
2003-08-13 01:27:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Invalid expression type\n");
|
|
|
|
*valid = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-07-04 00:27:48 +00:00
|
|
|
UINT WHERE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table,
|
|
|
|
struct expr *cond )
|
2003-08-13 01:27:48 +00:00
|
|
|
{
|
2004-07-04 00:27:48 +00:00
|
|
|
MSIWHEREVIEW *wv = NULL;
|
|
|
|
UINT count = 0, r, valid = 0;
|
2003-08-13 01:27:48 +00:00
|
|
|
|
2005-09-26 10:55:18 +00:00
|
|
|
TRACE("%p\n", table );
|
2003-08-13 01:27:48 +00:00
|
|
|
|
2004-07-04 00:27:48 +00:00
|
|
|
r = table->ops->get_dimensions( table, NULL, &count );
|
2003-08-13 01:27:48 +00:00
|
|
|
if( r != ERROR_SUCCESS )
|
2004-07-04 00:27:48 +00:00
|
|
|
{
|
|
|
|
ERR("can't get table dimensions\n");
|
|
|
|
return r;
|
|
|
|
}
|
2003-08-13 01:27:48 +00:00
|
|
|
|
2004-07-04 00:27:48 +00:00
|
|
|
if( cond )
|
2003-08-13 01:27:48 +00:00
|
|
|
{
|
2004-07-04 00:27:48 +00:00
|
|
|
r = WHERE_VerifyCondition( db, table, cond, &valid );
|
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
return r;
|
|
|
|
if( !valid )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
2003-08-13 01:27:48 +00:00
|
|
|
}
|
|
|
|
|
2005-09-20 11:57:19 +00:00
|
|
|
wv = msi_alloc_zero( sizeof *wv );
|
2004-07-04 00:27:48 +00:00
|
|
|
if( !wv )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
/* fill the structure */
|
|
|
|
wv->view.ops = &where_ops;
|
2004-07-09 22:25:34 +00:00
|
|
|
msiobj_addref( &db->hdr );
|
2004-07-04 00:27:48 +00:00
|
|
|
wv->db = db;
|
|
|
|
wv->table = table;
|
|
|
|
wv->row_count = 0;
|
|
|
|
wv->reorder = NULL;
|
2003-08-13 01:27:48 +00:00
|
|
|
wv->cond = cond;
|
2004-07-04 00:27:48 +00:00
|
|
|
*view = (MSIVIEW*) wv;
|
2003-08-13 01:27:48 +00:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|