Skip to content

Commit e6af2a5

Browse files
winesynclearn-more
authored andcommitted
[WINESYNC] msi: Support INSERT INTO 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 9130379710297cb487dbd8891b82f505e754c39d by Piotr Caban <[email protected]>
1 parent 28c50c1 commit e6af2a5

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

dll/win32/msi/table.c

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,16 +2507,51 @@ static UINT TransformView_add_column( MSITABLEVIEW *tv, MSIRECORD *rec )
25072507

25082508
static UINT TransformView_insert_row( MSIVIEW *view, MSIRECORD *rec, UINT row, BOOL temporary )
25092509
{
2510+
static const WCHAR query_fmt[] =
2511+
L"INSERT INTO `_TransformView` (`Table`, `Column`, `Row`) VALUES ('%s', 'INSERT', '%s')";
2512+
25102513
MSITABLEVIEW *tv = (MSITABLEVIEW*)view;
2514+
WCHAR buf[256], *query = buf;
2515+
MSIQUERY *q;
2516+
WCHAR *key;
2517+
int len;
2518+
UINT r;
25112519

25122520
if (!wcscmp(tv->name, szTables))
25132521
return TransformView_create_table( tv, rec );
25142522

25152523
if (!wcscmp(tv->name, szColumns))
25162524
return TransformView_add_column( tv, rec );
25172525

2518-
FIXME("\n");
2519-
return ERROR_CALL_NOT_IMPLEMENTED;
2526+
key = create_key_string( tv, rec );
2527+
if (!key)
2528+
return ERROR_OUTOFMEMORY;
2529+
2530+
len = _snwprintf( NULL, 0, query_fmt, tv->name, key ) + 1;
2531+
if (len > ARRAY_SIZE(buf))
2532+
{
2533+
query = msi_alloc( len * sizeof(WCHAR) );
2534+
if (!query)
2535+
{
2536+
msi_free( key );
2537+
return ERROR_OUTOFMEMORY;
2538+
}
2539+
}
2540+
swprintf( query, len, query_fmt, tv->name, key );
2541+
msi_free( key );
2542+
2543+
r = MSI_DatabaseOpenViewW( tv->db, query, &q );
2544+
if (query != buf)
2545+
msi_free( query );
2546+
if (r != ERROR_SUCCESS)
2547+
return r;
2548+
2549+
r = MSI_ViewExecute( q, NULL );
2550+
msiobj_release( &q->hdr );
2551+
if (r != ERROR_SUCCESS)
2552+
return r;
2553+
2554+
return TransformView_set_row( view, row, rec, ~0 );
25202555
}
25212556

25222557
static UINT TransformView_delete_row( MSIVIEW *view, UINT row )

0 commit comments

Comments
 (0)