2006-02-17 00:04:10 +00:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2004 Mike McCormack for CodeWeavers
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2008-01-16 10:11:22 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2006-02-17 00:04:10 +00:00
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-08-01 23:12:11 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-02-17 00:04:10 +00:00
|
|
|
*/
|
|
|
|
|
2013-12-25 20:42:59 +00:00
|
|
|
#include "msipriv.h"
|
2006-02-17 00:04:10 +00:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msidb);
|
|
|
|
|
|
|
|
/* below is the query interface to a table */
|
|
|
|
|
|
|
|
typedef struct tagMSIUPDATEVIEW
|
|
|
|
{
|
|
|
|
MSIVIEW view;
|
|
|
|
MSIDATABASE *db;
|
|
|
|
MSIVIEW *wv;
|
|
|
|
column_info *vals;
|
|
|
|
} MSIUPDATEVIEW;
|
|
|
|
|
|
|
|
static UINT UPDATE_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val )
|
|
|
|
{
|
|
|
|
MSIUPDATEVIEW *uv = (MSIUPDATEVIEW*)view;
|
|
|
|
|
|
|
|
TRACE("%p %d %d %p\n", uv, row, col, val );
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT UPDATE_execute( struct tagMSIVIEW *view, MSIRECORD *record )
|
|
|
|
{
|
|
|
|
MSIUPDATEVIEW *uv = (MSIUPDATEVIEW*)view;
|
2006-11-28 11:21:39 +00:00
|
|
|
UINT i, r, col_count = 0, row_count = 0;
|
|
|
|
MSIRECORD *values = NULL;
|
2008-01-16 10:11:22 +00:00
|
|
|
MSIRECORD *where = NULL;
|
2006-02-17 00:04:10 +00:00
|
|
|
MSIVIEW *wv;
|
2008-01-16 10:11:22 +00:00
|
|
|
UINT cols_count, where_count;
|
|
|
|
column_info *col = uv->vals;
|
2006-02-17 00:04:10 +00:00
|
|
|
|
|
|
|
TRACE("%p %p\n", uv, record );
|
|
|
|
|
2008-01-16 10:11:22 +00:00
|
|
|
/* extract the where markers from the record */
|
|
|
|
if (record)
|
|
|
|
{
|
|
|
|
r = MSI_RecordGetFieldCount(record);
|
|
|
|
|
|
|
|
for (i = 0; col; col = col->next)
|
|
|
|
i++;
|
|
|
|
|
|
|
|
cols_count = i;
|
|
|
|
where_count = r - i;
|
|
|
|
|
|
|
|
if (where_count > 0)
|
|
|
|
{
|
|
|
|
where = MSI_CreateRecord(where_count);
|
|
|
|
|
|
|
|
if (where)
|
|
|
|
for (i = 1; i <= where_count; i++)
|
|
|
|
MSI_RecordCopyField(record, cols_count + i, where, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-17 00:04:10 +00:00
|
|
|
wv = uv->wv;
|
|
|
|
if( !wv )
|
2008-01-16 10:11:22 +00:00
|
|
|
{
|
|
|
|
r = ERROR_FUNCTION_FAILED;
|
|
|
|
goto done;
|
|
|
|
}
|
2006-02-17 00:04:10 +00:00
|
|
|
|
2008-01-16 10:11:22 +00:00
|
|
|
r = wv->ops->execute( wv, where );
|
2006-02-17 00:04:10 +00:00
|
|
|
TRACE("tv execute returned %x\n", r);
|
|
|
|
if( r )
|
2008-01-16 10:11:22 +00:00
|
|
|
goto done;
|
2006-02-17 00:04:10 +00:00
|
|
|
|
|
|
|
r = wv->ops->get_dimensions( wv, &row_count, &col_count );
|
|
|
|
if( r )
|
2008-01-16 10:11:22 +00:00
|
|
|
goto done;
|
2006-02-17 00:04:10 +00:00
|
|
|
|
2006-11-28 11:21:39 +00:00
|
|
|
values = msi_query_merge_record( col_count, uv->vals, record );
|
|
|
|
if (!values)
|
2008-01-16 10:11:22 +00:00
|
|
|
{
|
|
|
|
r = ERROR_FUNCTION_FAILED;
|
|
|
|
goto done;
|
|
|
|
}
|
2006-11-28 11:21:39 +00:00
|
|
|
|
|
|
|
for ( i=0; i<row_count; i++ )
|
2006-02-17 00:04:10 +00:00
|
|
|
{
|
2006-11-28 11:21:39 +00:00
|
|
|
r = wv->ops->set_row( wv, i, values, (1 << col_count) - 1 );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
break;
|
2006-02-17 00:04:10 +00:00
|
|
|
}
|
|
|
|
|
2008-01-16 10:11:22 +00:00
|
|
|
done:
|
|
|
|
if ( where ) msiobj_release( &where->hdr );
|
|
|
|
if ( values ) msiobj_release( &values->hdr );
|
2006-11-28 11:21:39 +00:00
|
|
|
|
|
|
|
return r;
|
2006-02-17 00:04:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static UINT UPDATE_close( struct tagMSIVIEW *view )
|
|
|
|
{
|
|
|
|
MSIUPDATEVIEW *uv = (MSIUPDATEVIEW*)view;
|
|
|
|
MSIVIEW *wv;
|
|
|
|
|
|
|
|
TRACE("%p\n", uv);
|
|
|
|
|
|
|
|
wv = uv->wv;
|
|
|
|
if( !wv )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
return wv->ops->close( wv );
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT UPDATE_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *cols )
|
|
|
|
{
|
|
|
|
MSIUPDATEVIEW *uv = (MSIUPDATEVIEW*)view;
|
|
|
|
MSIVIEW *wv;
|
|
|
|
|
|
|
|
TRACE("%p %p %p\n", uv, rows, cols );
|
|
|
|
|
|
|
|
wv = uv->wv;
|
|
|
|
if( !wv )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
return wv->ops->get_dimensions( wv, rows, cols );
|
|
|
|
}
|
|
|
|
|
2012-01-21 17:19:12 +00:00
|
|
|
static UINT UPDATE_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
|
|
|
|
UINT *type, BOOL *temporary, LPCWSTR *table_name )
|
2006-02-17 00:04:10 +00:00
|
|
|
{
|
|
|
|
MSIUPDATEVIEW *uv = (MSIUPDATEVIEW*)view;
|
|
|
|
MSIVIEW *wv;
|
|
|
|
|
2009-11-16 01:13:42 +00:00
|
|
|
TRACE("%p %d %p %p %p %p\n", uv, n, name, type, temporary, table_name );
|
2006-02-17 00:04:10 +00:00
|
|
|
|
|
|
|
wv = uv->wv;
|
|
|
|
if( !wv )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2009-11-16 01:13:42 +00:00
|
|
|
return wv->ops->get_column_info( wv, n, name, type, temporary, table_name );
|
2006-02-17 00:04:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static UINT UPDATE_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode,
|
2008-01-16 10:11:22 +00:00
|
|
|
MSIRECORD *rec, UINT row )
|
2006-02-17 00:04:10 +00:00
|
|
|
{
|
|
|
|
MSIUPDATEVIEW *uv = (MSIUPDATEVIEW*)view;
|
|
|
|
|
|
|
|
TRACE("%p %d %p\n", uv, eModifyMode, rec );
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT UPDATE_delete( struct tagMSIVIEW *view )
|
|
|
|
{
|
|
|
|
MSIUPDATEVIEW *uv = (MSIUPDATEVIEW*)view;
|
|
|
|
MSIVIEW *wv;
|
|
|
|
|
|
|
|
TRACE("%p\n", uv );
|
|
|
|
|
|
|
|
wv = uv->wv;
|
|
|
|
if( wv )
|
|
|
|
wv->ops->delete( wv );
|
|
|
|
msiobj_release( &uv->db->hdr );
|
|
|
|
msi_free( uv );
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-08-01 23:12:11 +00:00
|
|
|
static UINT UPDATE_find_matching_rows( struct tagMSIVIEW *view, UINT col, UINT val, UINT *row, MSIITERHANDLE *handle )
|
|
|
|
{
|
|
|
|
TRACE("%p %d %d %p\n", view, col, val, *handle );
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2006-02-17 00:04:10 +00:00
|
|
|
|
2008-01-16 10:11:22 +00:00
|
|
|
static const MSIVIEWOPS update_ops =
|
2006-02-17 00:04:10 +00:00
|
|
|
{
|
|
|
|
UPDATE_fetch_int,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2008-01-16 10:11:22 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2006-02-17 00:04:10 +00:00
|
|
|
UPDATE_execute,
|
|
|
|
UPDATE_close,
|
|
|
|
UPDATE_get_dimensions,
|
|
|
|
UPDATE_get_column_info,
|
|
|
|
UPDATE_modify,
|
2006-08-01 23:12:11 +00:00
|
|
|
UPDATE_delete,
|
2008-01-16 10:11:22 +00:00
|
|
|
UPDATE_find_matching_rows,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2008-12-27 15:10:14 +00:00
|
|
|
NULL,
|
2006-02-17 00:04:10 +00:00
|
|
|
};
|
|
|
|
|
2012-01-21 17:19:12 +00:00
|
|
|
UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
|
2006-02-17 00:04:10 +00:00
|
|
|
column_info *columns, struct expr *expr )
|
|
|
|
{
|
|
|
|
MSIUPDATEVIEW *uv = NULL;
|
|
|
|
UINT r;
|
2012-01-21 17:19:12 +00:00
|
|
|
MSIVIEW *sv = NULL, *wv = NULL;
|
2006-02-17 00:04:10 +00:00
|
|
|
|
|
|
|
TRACE("%p\n", uv );
|
|
|
|
|
2006-11-28 11:21:39 +00:00
|
|
|
if (expr)
|
2012-01-21 17:19:12 +00:00
|
|
|
r = WHERE_CreateView( db, &wv, table, expr );
|
2006-11-28 11:21:39 +00:00
|
|
|
else
|
2012-01-21 17:19:12 +00:00
|
|
|
r = TABLE_CreateView( db, table, &wv );
|
|
|
|
|
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
return r;
|
2006-11-28 11:21:39 +00:00
|
|
|
|
2006-02-17 00:04:10 +00:00
|
|
|
/* then select the columns we want */
|
|
|
|
r = SELECT_CreateView( db, &sv, wv, columns );
|
|
|
|
if( r != ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
wv->ops->delete( wv );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
uv = msi_alloc_zero( sizeof *uv );
|
|
|
|
if( !uv )
|
2009-06-06 15:59:47 +00:00
|
|
|
{
|
|
|
|
wv->ops->delete( wv );
|
2006-02-17 00:04:10 +00:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2009-06-06 15:59:47 +00:00
|
|
|
}
|
2006-02-17 00:04:10 +00:00
|
|
|
|
|
|
|
/* fill the structure */
|
|
|
|
uv->view.ops = &update_ops;
|
|
|
|
msiobj_addref( &db->hdr );
|
|
|
|
uv->db = db;
|
|
|
|
uv->vals = columns;
|
|
|
|
uv->wv = sv;
|
|
|
|
*view = (MSIVIEW*) uv;
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|