Commit a52c2bf9 authored by Bernhard Loos's avatar Bernhard Loos Committed by Alexandre Julliard

msi: Make WHEREVIEW able to deal directly with multiple tables.

parent 9b79fd57
...@@ -68,10 +68,19 @@ struct complex_expr ...@@ -68,10 +68,19 @@ struct complex_expr
struct expr *right; struct expr *right;
}; };
struct ext_column struct tagJOINTABLE;
union ext_column
{ {
LPCWSTR column; struct
LPCWSTR table; {
LPCWSTR column;
LPCWSTR table;
} unparsed;
struct
{
UINT column;
struct tagJOINTABLE *table;
} parsed;
}; };
struct expr struct expr
...@@ -83,8 +92,7 @@ struct expr ...@@ -83,8 +92,7 @@ struct expr
INT ival; INT ival;
UINT uval; UINT uval;
LPCWSTR sval; LPCWSTR sval;
struct ext_column column; union ext_column column;
UINT col_number;
} u; } u;
}; };
...@@ -101,7 +109,7 @@ UINT DISTINCT_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table ) DECL ...@@ -101,7 +109,7 @@ UINT DISTINCT_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table ) DECL
UINT ORDER_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, UINT ORDER_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table,
column_info *columns ) DECLSPEC_HIDDEN; column_info *columns ) DECLSPEC_HIDDEN;
UINT WHERE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, UINT WHERE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR tables,
struct expr *cond ) DECLSPEC_HIDDEN; struct expr *cond ) DECLSPEC_HIDDEN;
UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR table, UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR table,
...@@ -110,7 +118,7 @@ UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR table, ...@@ -110,7 +118,7 @@ UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR table,
UINT INSERT_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR table, UINT INSERT_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR table,
column_info *columns, column_info *values, BOOL temp ) DECLSPEC_HIDDEN; column_info *columns, column_info *values, BOOL temp ) DECLSPEC_HIDDEN;
UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR table, UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
column_info *list, struct expr *expr ) DECLSPEC_HIDDEN; column_info *list, struct expr *expr ) DECLSPEC_HIDDEN;
UINT DELETE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table ) DECLSPEC_HIDDEN; UINT DELETE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table ) DECLSPEC_HIDDEN;
......
...@@ -478,13 +478,13 @@ selcollist: ...@@ -478,13 +478,13 @@ selcollist:
from: from:
fromtable fromtable
| fromtable TK_WHERE expr | TK_FROM tablelist TK_WHERE expr
{ {
SQL_input* sql = (SQL_input*) info; SQL_input* sql = (SQL_input*) info;
MSIVIEW* where = NULL; MSIVIEW* where = NULL;
UINT r; UINT r;
r = WHERE_CreateView( sql->db, &where, $1, $3 ); r = WHERE_CreateView( sql->db, &where, $2, $4 );
if( r != ERROR_SUCCESS ) if( r != ERROR_SUCCESS )
YYABORT; YYABORT;
...@@ -877,8 +877,8 @@ static struct expr * EXPR_column( void *info, const column_info *column ) ...@@ -877,8 +877,8 @@ static struct expr * EXPR_column( void *info, const column_info *column )
if( e ) if( e )
{ {
e->type = EXPR_COLUMN; e->type = EXPR_COLUMN;
e->u.column.column = column->column; e->u.column.unparsed.column = column->column;
e->u.column.table = column->table; e->u.column.unparsed.table = column->table;
} }
return e; return e;
} }
......
...@@ -3895,7 +3895,7 @@ static void test_join(void) ...@@ -3895,7 +3895,7 @@ static void test_join(void)
/* primary key cannot be updated */ /* primary key cannot be updated */
r = MsiViewModify(hview, MSIMODIFY_UPDATE, hrec); r = MsiViewModify(hview, MSIMODIFY_UPDATE, hrec);
todo_wine ok( r == ERROR_FUNCTION_FAILED, "failed to update row: %d\n", r ); ok( r == ERROR_FUNCTION_FAILED, "failed to update row: %d\n", r );
MsiCloseHandle(hrec); MsiCloseHandle(hrec);
MsiViewClose(hview); MsiViewClose(hview);
......
...@@ -225,31 +225,22 @@ static const MSIVIEWOPS update_ops = ...@@ -225,31 +225,22 @@ static const MSIVIEWOPS update_ops =
NULL, NULL,
}; };
UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPCWSTR table, UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
column_info *columns, struct expr *expr ) column_info *columns, struct expr *expr )
{ {
MSIUPDATEVIEW *uv = NULL; MSIUPDATEVIEW *uv = NULL;
UINT r; UINT r;
MSIVIEW *tv = NULL, *sv = NULL, *wv = NULL; MSIVIEW *sv = NULL, *wv = NULL;
TRACE("%p\n", uv ); TRACE("%p\n", uv );
r = TABLE_CreateView( db, table, &tv );
if( r != ERROR_SUCCESS )
return r;
if (expr) if (expr)
{ r = WHERE_CreateView( db, &wv, table, expr );
/* add conditions first */
r = WHERE_CreateView( db, &wv, tv, expr );
if( r != ERROR_SUCCESS )
{
tv->ops->delete( tv );
return r;
}
}
else else
wv = tv; r = TABLE_CreateView( db, table, &wv );
if( r != ERROR_SUCCESS )
return r;
/* then select the columns we want */ /* then select the columns we want */
r = SELECT_CreateView( db, &sv, wv, columns ); r = SELECT_CreateView( db, &sv, wv, columns );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment