Skip to content

Commit 27a430b

Browse files
winesynclearn-more
authored andcommitted
[WINESYNC] msi: Support CREATE when MSITRANSFORM_ERROR_VIEWTRANSFORM flag is used.
Signed-off-by: Piotr Caban <[email protected]> Signed-off-by: Hans Leidekker <[email protected]> Signed-off-by: Alexandre Julliard <[email protected]> wine commit id 7e4077fb6d77810e40e842e7557c03ab3abe0593 by Piotr Caban <[email protected]>
1 parent 317c1f6 commit 27a430b

File tree

1 file changed

+69
-4
lines changed

1 file changed

+69
-4
lines changed

dll/win32/msi/table.c

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2254,11 +2254,25 @@ static UINT msi_record_stream_name( const MSITABLEVIEW *tv, MSIRECORD *rec, LPWS
22542254

22552255
static UINT TransformView_fetch_int( MSIVIEW *view, UINT row, UINT col, UINT *val )
22562256
{
2257+
MSITABLEVIEW *tv = (MSITABLEVIEW*)view;
2258+
2259+
if (!tv->table)
2260+
{
2261+
*val = 0;
2262+
return ERROR_SUCCESS;
2263+
}
22572264
return TABLE_fetch_int( view, row, col, val );
22582265
}
22592266

22602267
static UINT TransformView_fetch_stream( MSIVIEW *view, UINT row, UINT col, IStream **stm )
22612268
{
2269+
MSITABLEVIEW *tv = (MSITABLEVIEW*)view;
2270+
2271+
if (!tv->table)
2272+
{
2273+
*stm = NULL;
2274+
return ERROR_SUCCESS;
2275+
}
22622276
return TABLE_fetch_stream( view, row, col, stm );
22632277
}
22642278

@@ -2403,8 +2417,48 @@ static UINT TransformView_set_row( MSIVIEW *view, UINT row, MSIRECORD *rec, UINT
24032417
return ERROR_SUCCESS;
24042418
}
24052419

2420+
static UINT TransformView_create_table( MSITABLEVIEW *tv, MSIRECORD *rec )
2421+
{
2422+
static const WCHAR query_fmt[] =
2423+
L"INSERT INTO `_TransformView` (`Table`, `Column`) VALUES ('%s', 'CREATE')";
2424+
2425+
WCHAR buf[256], *query = buf;
2426+
const WCHAR *name;
2427+
MSIQUERY *q;
2428+
int len;
2429+
UINT r;
2430+
2431+
name = msi_record_get_string( rec, 1, &len );
2432+
if (!name)
2433+
return ERROR_INSTALL_TRANSFORM_FAILURE;
2434+
2435+
len = _snwprintf( NULL, 0, query_fmt, name ) + 1;
2436+
if (len > ARRAY_SIZE(buf))
2437+
{
2438+
query = msi_alloc( len * sizeof(WCHAR) );
2439+
if (!query)
2440+
return ERROR_OUTOFMEMORY;
2441+
}
2442+
swprintf( query, len, query_fmt, name );
2443+
2444+
r = MSI_DatabaseOpenViewW( tv->db, query, &q );
2445+
if (query != buf)
2446+
msi_free( query );
2447+
if (r != ERROR_SUCCESS)
2448+
return r;
2449+
2450+
r = MSI_ViewExecute( q, NULL );
2451+
msiobj_release( &q->hdr );
2452+
return r;
2453+
}
2454+
24062455
static UINT TransformView_insert_row( MSIVIEW *view, MSIRECORD *rec, UINT row, BOOL temporary )
24072456
{
2457+
MSITABLEVIEW *tv = (MSITABLEVIEW*)view;
2458+
2459+
if (!wcscmp(tv->name, szTables))
2460+
return TransformView_create_table( tv, rec );
2461+
24082462
FIXME("\n");
24092463
return ERROR_CALL_NOT_IMPLEMENTED;
24102464
}
@@ -2466,15 +2520,23 @@ static const MSIVIEWOPS transform_view_ops =
24662520

24672521
UINT TransformView_Create( MSIDATABASE *db, string_table *st, LPCWSTR name, MSIVIEW **view )
24682522
{
2523+
UINT r, name_len, size;
24692524
MSITABLEVIEW *tv;
2470-
UINT r;
2525+
2526+
name_len = wcslen( name );
24712527

24722528
r = TABLE_CreateView( db, name, view );
24732529
if (r == ERROR_INVALID_PARAMETER)
24742530
{
24752531
/* table does not exist */
2476-
FIXME("\n");
2477-
return ERROR_CALL_NOT_IMPLEMENTED;
2532+
size = FIELD_OFFSET( MSITABLEVIEW, name[name_len + 1] );
2533+
tv = msi_alloc_zero( size );
2534+
if (!tv)
2535+
return ERROR_OUTOFMEMORY;
2536+
2537+
tv->db = db;
2538+
memcpy( tv->name, name, name_len * sizeof(WCHAR) );
2539+
*view = (MSIVIEW*)tv;
24782540
}
24792541
else if (r != ERROR_SUCCESS)
24802542
{
@@ -2912,7 +2974,10 @@ static UINT msi_table_load_transform( MSIDATABASE *db, IStorage *stg,
29122974

29132975
if (TRACE_ON(msidb)) dump_record( rec );
29142976

2915-
r = msi_table_find_row( tv, rec, &row, NULL );
2977+
if (tv->table)
2978+
r = msi_table_find_row( tv, rec, &row, NULL );
2979+
else
2980+
r = ERROR_FUNCTION_FAILED;
29162981
if (r == ERROR_SUCCESS)
29172982
{
29182983
if (!mask)

0 commit comments

Comments
 (0)