MSI: create the ORDER BY view in a single call
Mike McCormack
mike at codeweavers.com
Sun May 22 11:07:22 CDT 2005
ChangeLog:
* create the ORDER BY view in a single call
-------------- next part --------------
Index: dlls/msi/order.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/order.c,v
retrieving revision 1.9
diff -u -p -r1.9 order.c
--- dlls/msi/order.c 8 Feb 2005 13:44:25 -0000 1.9
+++ dlls/msi/order.c 22 May 2005 16:06:20 -0000
@@ -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;
@@ -329,6 +297,42 @@ UINT ORDER_AddColumn( MSIVIEW *view, LPW
TRACE("Ordering by column %s (%d)\n", debugstr_w( name ), n);
ov->num_cols++;
+
+ 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;
}
Index: dlls/msi/query.h
===================================================================
RCS file: /home/wine/wine/dlls/msi/query.h,v
retrieving revision 1.13
diff -u -p -r1.13 query.h
--- dlls/msi/query.h 14 Feb 2005 11:07:13 -0000 1.13
+++ dlls/msi/query.h 22 May 2005 16:06:20 -0000
@@ -116,8 +114,8 @@ UINT SELECT_CreateView( MSIDATABASE *db,
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 );
Index: dlls/msi/sql.y
===================================================================
RCS file: /home/wine/wine/dlls/msi/sql.y,v
retrieving revision 1.22
diff -u -p -r1.22 sql.y
--- dlls/msi/sql.y 19 May 2005 11:15:37 -0000 1.22
+++ dlls/msi/sql.y 22 May 2005 16:06:20 -0000
@@ -54,8 +54,6 @@ static int SQL_lex( void *SQL_lval, SQL_
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);
@@ -342,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
;
@@ -680,25 +689,6 @@ static MSIVIEW *do_one_select( MSIDATABA
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 );
More information about the wine-patches
mailing list