diff --git a/dlls/msi/order.c b/dlls/msi/order.c index c04d6f94e69..0e3b98fa84e 100644 --- a/dlls/msi/order.c +++ b/dlls/msi/order.c @@ -264,40 +264,8 @@ MSIVIEWOPS order_ops = ORDER_delete }; -UINT ORDER_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table ) +static UINT ORDER_AddColumn( MSIORDERVIEW *ov, LPCWSTR name ) { - MSIORDERVIEW *ov = NULL; - UINT count = 0, r; - - TRACE("%p\n", ov ); - - r = table->ops->get_dimensions( table, NULL, &count ); - if( r != ERROR_SUCCESS ) - { - ERR("can't get table dimensions\n"); - return r; - } - - ov = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof *ov + sizeof (UINT) * count ); - if( !ov ) - return ERROR_FUNCTION_FAILED; - - /* fill the structure */ - ov->view.ops = &order_ops; - msiobj_addref( &db->hdr ); - ov->db = db; - ov->table = table; - ov->reorder = NULL; - ov->num_cols = 0; - *view = (MSIVIEW*) ov; - - return ERROR_SUCCESS; -} - -UINT ORDER_AddColumn( MSIVIEW *view, LPWSTR name ) -{ - MSIORDERVIEW *ov = (MSIORDERVIEW*)view; UINT n, count, r; MSIVIEW *table; @@ -332,3 +300,39 @@ UINT ORDER_AddColumn( MSIVIEW *view, LPWSTR name ) return ERROR_SUCCESS; } + +UINT ORDER_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, + string_list *columns ) +{ + MSIORDERVIEW *ov = NULL; + UINT count = 0, r; + string_list *x; + + TRACE("%p\n", ov ); + + r = table->ops->get_dimensions( table, NULL, &count ); + if( r != ERROR_SUCCESS ) + { + ERR("can't get table dimensions\n"); + return r; + } + + ov = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof *ov + sizeof (UINT) * count ); + if( !ov ) + return ERROR_FUNCTION_FAILED; + + /* fill the structure */ + ov->view.ops = &order_ops; + msiobj_addref( &db->hdr ); + ov->db = db; + ov->table = table; + ov->reorder = NULL; + ov->num_cols = 0; + *view = (MSIVIEW*) ov; + + for( x = columns; x ; x = x->next ) + ORDER_AddColumn( ov, x->string ); + + return ERROR_SUCCESS; +} diff --git a/dlls/msi/query.h b/dlls/msi/query.h index 46c800cb892..7ecf3fd31cd 100644 --- a/dlls/msi/query.h +++ b/dlls/msi/query.h @@ -114,8 +114,8 @@ UINT SELECT_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, UINT DISTINCT_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table ); -UINT ORDER_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table ); -UINT ORDER_AddColumn( MSIVIEW *group, LPWSTR name ); +UINT ORDER_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, + string_list *columns ); UINT WHERE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, struct expr *cond ); diff --git a/dlls/msi/sql.y b/dlls/msi/sql.y index 79bf5febf4e..fbe813ddf12 100644 --- a/dlls/msi/sql.y +++ b/dlls/msi/sql.y @@ -54,8 +54,6 @@ static int SQL_lex( void *SQL_lval, SQL_input *info); static MSIVIEW *do_one_select( MSIDATABASE *db, MSIVIEW *in, string_list *columns ); -static MSIVIEW *do_order_by( MSIDATABASE *db, MSIVIEW *in, - string_list *columns ); static BOOL SQL_MarkPrimaryKeys( create_col_info *cols, string_list *keys); @@ -330,12 +328,13 @@ oneselect: { SQL_input* sql = (SQL_input*) info; - if( !$1 ) - YYABORT; + $$ = NULL; if( $4 ) - $$ = do_order_by( sql->db, $1, $4 ); + ORDER_CreateView( sql->db, &$$, $1, $4 ); else $$ = $1; + if( !$$ ) + YYABORT; } | unorderedsel ; @@ -690,25 +689,6 @@ static MSIVIEW *do_one_select( MSIDATABASE *db, MSIVIEW *in, return view; } -static MSIVIEW *do_order_by( MSIDATABASE *db, MSIVIEW *in, - string_list *columns ) -{ - MSIVIEW *view = NULL; - - ORDER_CreateView( db, &view, in ); - if( view ) - { - string_list *x = columns; - - for( x = columns; x ; x = x->next ) - ORDER_AddColumn( view, x->string ); - } - else - ERR("Error creating select query\n"); - delete_string_list( columns ); - return view; -} - static struct expr * EXPR_wildcard() { struct expr *e = HeapAlloc( GetProcessHeap(), 0, sizeof *e );