Get rid of some redundant parser types.
diff --git a/dlls/msi/create.c b/dlls/msi/create.c index 51d316e..2d92db1 100644 --- a/dlls/msi/create.c +++ b/dlls/msi/create.c
@@ -44,7 +44,7 @@ MSIDATABASE *db; LPWSTR name; BOOL bIsTemp; - create_col_info *col_info; + column_info *col_info; } MSICREATEVIEW; static UINT CREATE_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val ) @@ -59,7 +59,7 @@ static UINT CREATE_execute( struct tagMSIVIEW *view, MSIRECORD *record ) { MSICREATEVIEW *cv = (MSICREATEVIEW*)view; - create_col_info *col; + column_info *col; UINT r, nField, row, table_val, column_val; static const WCHAR szTables[] = { '_','T','a','b','l','e','s',0 }; static const WCHAR szColumns[] = { '_','C','o','l','u','m','n','s',0 }; @@ -122,8 +122,8 @@ if( r ) goto err; - column_val = msi_addstringW( cv->db->strings, 0, col->colname, -1, 1 ); - TRACE("New string %s -> %d\n", debugstr_w( col->colname ), column_val ); + column_val = msi_addstringW( cv->db->strings, 0, col->column, -1, 1 ); + TRACE("New string %s -> %d\n", debugstr_w( col->column ), column_val ); if( column_val < 0 ) break; @@ -226,7 +226,7 @@ }; UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table, - create_col_info *col_info, BOOL temp ) + column_info *col_info, BOOL temp ) { MSICREATEVIEW *cv = NULL;
diff --git a/dlls/msi/insert.c b/dlls/msi/insert.c index 1ec84bf..120e093 100644 --- a/dlls/msi/insert.c +++ b/dlls/msi/insert.c
@@ -255,7 +255,7 @@ }; UINT INSERT_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table, - string_list *columns, value_list *values, BOOL temp ) + column_info *columns, value_list *values, BOOL temp ) { MSIINSERTVIEW *iv = NULL; UINT r;
diff --git a/dlls/msi/order.c b/dlls/msi/order.c index 0e3b98f..2a03bab 100644 --- a/dlls/msi/order.c +++ b/dlls/msi/order.c
@@ -302,11 +302,11 @@ } UINT ORDER_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, - string_list *columns ) + column_info *columns ) { MSIORDERVIEW *ov = NULL; UINT count = 0, r; - string_list *x; + column_info *x; TRACE("%p\n", ov ); @@ -332,7 +332,7 @@ *view = (MSIVIEW*) ov; for( x = columns; x ; x = x->next ) - ORDER_AddColumn( ov, x->string ); + ORDER_AddColumn( ov, x->column ); return ERROR_SUCCESS; }
diff --git a/dlls/msi/query.h b/dlls/msi/query.h index 28f74b5..07d4876 100644 --- a/dlls/msi/query.h +++ b/dlls/msi/query.h
@@ -59,11 +59,14 @@ INT len; }; -typedef struct _string_list +typedef struct _column_info { - LPWSTR string; - struct _string_list *next; -} string_list; + LPCWSTR table; + LPCWSTR column; + UINT type; + struct expr *val; + struct _column_info *next; +} column_info; struct complex_expr { @@ -80,56 +83,42 @@ struct complex_expr expr; INT ival; UINT uval; - LPWSTR sval; - LPWSTR column; + LPCWSTR sval; + LPCWSTR column; UINT col_number; } u; }; -typedef struct _create_col_info -{ - LPWSTR colname; - UINT type; - struct _create_col_info *next; -} create_col_info; - typedef struct _value_list { struct expr *val; struct _value_list *next; } value_list; -typedef struct _column_assignment -{ - string_list *col_list; - value_list *val_list; -} column_assignment; - - UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview, struct list *mem ); UINT TABLE_CreateView( MSIDATABASE *db, LPCWSTR name, MSIVIEW **view ); UINT SELECT_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, - string_list *columns ); + column_info *columns ); UINT DISTINCT_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table ); UINT ORDER_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, - string_list *columns ); + column_info *columns ); UINT WHERE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, struct expr *cond ); UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table, - create_col_info *col_info, BOOL temp ); + column_info *col_info, BOOL temp ); UINT INSERT_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table, - string_list *columns, value_list *values, BOOL temp ); + column_info *columns, value_list *values, BOOL temp ); UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **, LPWSTR table, - column_assignment *list, struct expr *expr ); + column_info *list, struct expr *expr ); UINT DELETE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table );
diff --git a/dlls/msi/select.c b/dlls/msi/select.c index 6118966..9378676 100644 --- a/dlls/msi/select.c +++ b/dlls/msi/select.c
@@ -210,7 +210,7 @@ SELECT_delete }; -static UINT SELECT_AddColumn( MSISELECTVIEW *sv, LPWSTR name ) +static UINT SELECT_AddColumn( MSISELECTVIEW *sv, LPCWSTR name ) { UINT r, n=0; MSIVIEW *table; @@ -245,7 +245,7 @@ } UINT SELECT_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table, - string_list *columns ) + column_info *columns ) { MSISELECTVIEW *sv = NULL; UINT count = 0, r; @@ -273,7 +273,7 @@ while( columns ) { - r = SELECT_AddColumn( sv, columns->string ); + r = SELECT_AddColumn( sv, columns->column ); if( r ) break; columns = columns->next;
diff --git a/dlls/msi/sql.y b/dlls/msi/sql.y index 41d91cf..e97399d 100644 --- a/dlls/msi/sql.y +++ b/dlls/msi/sql.y
@@ -55,11 +55,12 @@ static int SQL_lex( void *SQL_lval, SQL_input *info ); static void *parser_alloc( void *info, unsigned int sz ); +static column_info *parser_alloc_column( void *info, LPCWSTR table, LPCWSTR column ); -static BOOL SQL_MarkPrimaryKeys( create_col_info *cols, string_list *keys); +static BOOL SQL_MarkPrimaryKeys( column_info *cols, column_info *keys); static struct expr * EXPR_complex( void *info, struct expr *l, UINT op, struct expr *r ); -static struct expr * EXPR_column( void *info, LPWSTR column ); +static struct expr * EXPR_column( void *info, column_info *column ); static struct expr * EXPR_ival( void *info, struct sql_str *, int sign ); static struct expr * EXPR_sval( void *info, struct sql_str * ); static struct expr * EXPR_wildcard( void *info ); @@ -72,13 +73,11 @@ { struct sql_str str; LPWSTR string; - string_list *column_list; + column_info *column_list; value_list *val_list; MSIVIEW *query; struct expr *expr; USHORT column_type; - create_col_info *column_info; - column_assignment update_col_info; } %token TK_ABORT TK_AFTER TK_AGG_FUNCTION TK_ALL TK_AND TK_AS TK_ASC @@ -125,15 +124,14 @@ %nonassoc END_OF_FILE ILLEGAL SPACE UNCLOSED_STRING COMMENT FUNCTION COLUMN AGG_FUNCTION. -%type <string> column table id -%type <column_list> selcollist -%type <query> query from fromtable unorderedsel selectfrom +%type <string> table id +%type <column_list> selcollist column column_and_type column_def table_def +%type <column_list> column_assignment update_assign_list +%type <query> query from fromtable selectfrom unorderedsel %type <query> oneupdate onedelete oneselect onequery onecreate oneinsert %type <expr> expr val column_val const_val %type <column_type> column_type data_type data_type_l data_count -%type <column_info> column_def table_def %type <val_list> constlist -%type <update_col_info> column_assignment update_assign_list %% @@ -210,7 +208,7 @@ SQL_input* sql = (SQL_input*) info; MSIVIEW *update = NULL; - UPDATE_CreateView( sql->db, &update, $2, &$4, $6 ); + UPDATE_CreateView( sql->db, &update, $2, $4, $6 ); if( !update ) YYABORT; $$ = update; @@ -241,33 +239,27 @@ ; column_def: - column_def TK_COMMA column column_type + column_def TK_COMMA column_and_type { - create_col_info *ci; + column_info *ci; for( ci = $1; ci->next; ci = ci->next ) ; - ci->next = HeapAlloc( GetProcessHeap(), 0, sizeof *$$ ); - if( !ci->next ) - { - /* FIXME: free $1 */ - YYABORT; - } - ci->next->colname = $3; - ci->next->type = $4; - ci->next->next = NULL; - + ci->next = $3; $$ = $1; } - | column column_type + | column_and_type { - $$ = HeapAlloc( GetProcessHeap(), 0, sizeof *$$ ); - if( ! $$ ) - YYABORT; - $$->colname = $1; + $$ = $1; + } + ; + +column_and_type: + column column_type + { + $$ = $1; $$->type = $2; - $$->next = NULL; } ; @@ -386,30 +378,9 @@ selcollist: column - { - string_list *list; - - list = HeapAlloc( GetProcessHeap(), 0, sizeof *list ); - if( !list ) - YYABORT; - list->string = $1; - list->next = NULL; - - $$ = list; - TRACE("Collist %s\n",debugstr_w($$->string)); - } | column TK_COMMA selcollist { - string_list *list; - - list = HeapAlloc( GetProcessHeap(), 0, sizeof *list ); - if( !list ) - YYABORT; - list->string = $1; - list->next = $3; - - $$ = list; - TRACE("From table: %s\n",debugstr_w($$->string)); + $1->next = $3; } | TK_STAR { @@ -553,25 +524,16 @@ column_assignment | column_assignment TK_COMMA update_assign_list { - $1.col_list->next = $3.col_list; - $1.val_list->next = $3.val_list; $$ = $1; + $$->next = $3; } ; column_assignment: column TK_EQ const_val { - $$.col_list = HeapAlloc( GetProcessHeap(), 0, sizeof *$$.col_list ); - if( !$$.col_list ) - YYABORT; - $$.col_list->string = $1; - $$.col_list->next = NULL; - $$.val_list = HeapAlloc( GetProcessHeap(), 0, sizeof *$$.val_list ); - if( !$$.val_list ) - YYABORT; - $$.val_list->val = $3; - $$.val_list->next = 0; + $$ = $1; + $$->val = $3; } ; @@ -614,11 +576,15 @@ column: table TK_DOT id { - $$ = $3; /* FIXME */ + $$ = parser_alloc_column( info, $1, $3 ); + if( !$$ ) + YYABORT; } | id { - $$ = $1; + $$ = parser_alloc_column( info, NULL, $1 ); + if( !$$ ) + YYABORT; } ; @@ -650,6 +616,23 @@ return &mem[1]; } +static column_info *parser_alloc_column( void *info, LPCWSTR table, LPCWSTR column ) +{ + column_info *col; + + col = parser_alloc( info, sizeof (*col) ); + if( col ) + { + col->table = table; + col->column = column; + col->val = NULL; + col->type = 0; + col->next = NULL; + } + + return col; +} + int SQL_lex( void *SQL_lval, SQL_input *sql ) { int token; @@ -733,13 +716,13 @@ return e; } -static struct expr * EXPR_column( void *info, LPWSTR column ) +static struct expr * EXPR_column( void *info, column_info *column ) { struct expr *e = parser_alloc( info, sizeof *e ); if( e ) { e->type = EXPR_COLUMN; - e->u.sval = column; + e->u.sval = column->column; } return e; } @@ -766,19 +749,20 @@ return e; } -static BOOL SQL_MarkPrimaryKeys( create_col_info *cols, string_list *keys) +static BOOL SQL_MarkPrimaryKeys( column_info *cols, + column_info *keys ) { - string_list *k; + column_info *k; BOOL found = TRUE; for( k = keys; k && found; k = k->next ) { - create_col_info *c; + column_info *c; found = FALSE; for( c = cols; c && !found; c = c->next ) { - if( lstrcmpW( k->string, c->colname ) ) + if( lstrcmpW( k->column, c->column ) ) continue; c->type |= MSITYPE_KEY; found = TRUE;
diff --git a/dlls/msi/update.c b/dlls/msi/update.c index 3ab3860..0af29e0 100644 --- a/dlls/msi/update.c +++ b/dlls/msi/update.c
@@ -43,7 +43,7 @@ MSIVIEW view; MSIDATABASE *db; MSIVIEW *wv; - value_list *vals; + column_info *vals; } MSIUPDATEVIEW; static UINT UPDATE_fetch_int( struct tagMSIVIEW *view, UINT row, UINT col, UINT *val ) @@ -193,7 +193,7 @@ }; UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table, - column_assignment *list, struct expr *expr ) + column_info *columns, struct expr *expr ) { MSIUPDATEVIEW *uv = NULL; UINT r; @@ -215,7 +215,7 @@ } /* then select the columns we want */ - r = SELECT_CreateView( db, &sv, wv, list->col_list ); + r = SELECT_CreateView( db, &sv, wv, columns ); if( r != ERROR_SUCCESS ) { if( tv ) @@ -231,7 +231,7 @@ uv->view.ops = &update_ops; msiobj_addref( &db->hdr ); uv->db = db; - uv->vals = list->val_list; + uv->vals = columns; uv->wv = sv; *view = (MSIVIEW*) uv;