2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2004 Mike McCormack for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 WINE_DEFAULT_DEBUG_CHANNEL(msidb
);
25 /* below is the query interface to a table */
27 typedef struct tagMSIUPDATEVIEW
35 static UINT
UPDATE_fetch_int( struct tagMSIVIEW
*view
, UINT row
, UINT col
, UINT
*val
)
37 MSIUPDATEVIEW
*uv
= (MSIUPDATEVIEW
*)view
;
39 TRACE("%p %d %d %p\n", uv
, row
, col
, val
);
41 return ERROR_FUNCTION_FAILED
;
44 static UINT
UPDATE_execute( struct tagMSIVIEW
*view
, MSIRECORD
*record
)
46 MSIUPDATEVIEW
*uv
= (MSIUPDATEVIEW
*)view
;
47 UINT i
, r
, col_count
= 0, row_count
= 0;
48 MSIRECORD
*values
= NULL
;
49 MSIRECORD
*where
= NULL
;
51 UINT cols_count
, where_count
;
52 column_info
*col
= uv
->vals
;
54 TRACE("%p %p\n", uv
, record
);
56 /* extract the where markers from the record */
59 r
= MSI_RecordGetFieldCount(record
);
61 for (i
= 0; col
; col
= col
->next
)
69 where
= MSI_CreateRecord(where_count
);
72 for (i
= 1; i
<= where_count
; i
++)
73 MSI_RecordCopyField(record
, cols_count
+ i
, where
, i
);
80 r
= ERROR_FUNCTION_FAILED
;
84 r
= wv
->ops
->execute( wv
, where
);
85 TRACE("tv execute returned %x\n", r
);
89 r
= wv
->ops
->get_dimensions( wv
, &row_count
, &col_count
);
93 values
= msi_query_merge_record( col_count
, uv
->vals
, record
);
96 r
= ERROR_FUNCTION_FAILED
;
100 for ( i
=0; i
<row_count
; i
++ )
102 r
= wv
->ops
->set_row( wv
, i
, values
, (1 << col_count
) - 1 );
103 if (r
!= ERROR_SUCCESS
)
108 if ( where
) msiobj_release( &where
->hdr
);
109 if ( values
) msiobj_release( &values
->hdr
);
115 static UINT
UPDATE_close( struct tagMSIVIEW
*view
)
117 MSIUPDATEVIEW
*uv
= (MSIUPDATEVIEW
*)view
;
124 return ERROR_FUNCTION_FAILED
;
126 return wv
->ops
->close( wv
);
129 static UINT
UPDATE_get_dimensions( struct tagMSIVIEW
*view
, UINT
*rows
, UINT
*cols
)
131 MSIUPDATEVIEW
*uv
= (MSIUPDATEVIEW
*)view
;
134 TRACE("%p %p %p\n", uv
, rows
, cols
);
138 return ERROR_FUNCTION_FAILED
;
140 return wv
->ops
->get_dimensions( wv
, rows
, cols
);
143 static UINT
UPDATE_get_column_info( struct tagMSIVIEW
*view
, UINT n
, LPCWSTR
*name
,
144 UINT
*type
, BOOL
*temporary
, LPCWSTR
*table_name
)
146 MSIUPDATEVIEW
*uv
= (MSIUPDATEVIEW
*)view
;
149 TRACE("%p %d %p %p %p %p\n", uv
, n
, name
, type
, temporary
, table_name
);
153 return ERROR_FUNCTION_FAILED
;
155 return wv
->ops
->get_column_info( wv
, n
, name
, type
, temporary
, table_name
);
158 static UINT
UPDATE_modify( struct tagMSIVIEW
*view
, MSIMODIFY eModifyMode
,
159 MSIRECORD
*rec
, UINT row
)
161 MSIUPDATEVIEW
*uv
= (MSIUPDATEVIEW
*)view
;
163 TRACE("%p %d %p\n", uv
, eModifyMode
, rec
);
165 return ERROR_FUNCTION_FAILED
;
168 static UINT
UPDATE_delete( struct tagMSIVIEW
*view
)
170 MSIUPDATEVIEW
*uv
= (MSIUPDATEVIEW
*)view
;
177 wv
->ops
->delete( wv
);
178 msiobj_release( &uv
->db
->hdr
);
181 return ERROR_SUCCESS
;
184 static UINT
UPDATE_find_matching_rows( struct tagMSIVIEW
*view
, UINT col
, UINT val
, UINT
*row
, MSIITERHANDLE
*handle
)
186 TRACE("%p %d %d %p\n", view
, col
, val
, *handle
);
188 return ERROR_FUNCTION_FAILED
;
192 static const MSIVIEWOPS update_ops
=
202 UPDATE_get_dimensions
,
203 UPDATE_get_column_info
,
206 UPDATE_find_matching_rows
,
214 UINT
UPDATE_CreateView( MSIDATABASE
*db
, MSIVIEW
**view
, LPWSTR table
,
215 column_info
*columns
, struct expr
*expr
)
217 MSIUPDATEVIEW
*uv
= NULL
;
219 MSIVIEW
*sv
= NULL
, *wv
= NULL
;
224 r
= WHERE_CreateView( db
, &wv
, table
, expr
);
226 r
= TABLE_CreateView( db
, table
, &wv
);
228 if( r
!= ERROR_SUCCESS
)
231 /* then select the columns we want */
232 r
= SELECT_CreateView( db
, &sv
, wv
, columns
);
233 if( r
!= ERROR_SUCCESS
)
235 wv
->ops
->delete( wv
);
239 uv
= msi_alloc_zero( sizeof *uv
);
242 wv
->ops
->delete( wv
);
243 return ERROR_FUNCTION_FAILED
;
246 /* fill the structure */
247 uv
->view
.ops
= &update_ops
;
248 msiobj_addref( &db
->hdr
);
252 *view
= (MSIVIEW
*) uv
;
254 return ERROR_SUCCESS
;