Create the WHERE part of a query in one function call.
This commit is contained in:
parent
ed7c4bc84c
commit
f6492dc5ca
|
@ -110,8 +110,8 @@ 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 WHERE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table );
|
||||
UINT WHERE_AddCondition( MSIVIEW *view, struct expr *condition );
|
||||
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 );
|
||||
|
|
|
@ -215,40 +215,37 @@ column_def:
|
|||
;
|
||||
|
||||
ci->next = HeapAlloc( GetProcessHeap(), 0, sizeof *$$ );
|
||||
if( ci->next )
|
||||
if( !ci->next )
|
||||
{
|
||||
ci->next->colname = $3;
|
||||
ci->next->type = $4;
|
||||
ci->next->next = NULL;
|
||||
}
|
||||
else if( $1 )
|
||||
{
|
||||
HeapFree( GetProcessHeap(), 0, $1 );
|
||||
$1 = NULL;
|
||||
/* FIXME: free $1 */
|
||||
YYABORT;
|
||||
}
|
||||
ci->next->colname = $3;
|
||||
ci->next->type = $4;
|
||||
ci->next->next = NULL;
|
||||
|
||||
$$ = $1;
|
||||
}
|
||||
| column column_type
|
||||
{
|
||||
$$ = HeapAlloc( GetProcessHeap(), 0, sizeof *$$ );
|
||||
if( $$ )
|
||||
{
|
||||
$$->colname = $1;
|
||||
$$->type = $2;
|
||||
$$->next = NULL;
|
||||
}
|
||||
if( ! $$ )
|
||||
YYABORT;
|
||||
$$->colname = $1;
|
||||
$$->type = $2;
|
||||
$$->next = NULL;
|
||||
}
|
||||
;
|
||||
|
||||
column_type:
|
||||
data_type_l
|
||||
{
|
||||
$$ = $1;
|
||||
$$ = $1 | MSITYPE_VALID;
|
||||
}
|
||||
| data_type_l TK_LOCALIZABLE
|
||||
{
|
||||
FIXME("LOCALIZABLE ignored\n");
|
||||
$$ = $1;
|
||||
$$ = $1 | MSITYPE_VALID;
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -270,7 +267,7 @@ data_type:
|
|||
}
|
||||
| TK_CHAR TK_LP data_count TK_RP
|
||||
{
|
||||
$$ = MSITYPE_STRING | 0x500 | $3;
|
||||
$$ = MSITYPE_STRING | 0x400 | $3;
|
||||
}
|
||||
| TK_LONGCHAR
|
||||
{
|
||||
|
@ -397,10 +394,7 @@ from:
|
|||
r = TABLE_CreateView( sql->db, $2, &view );
|
||||
if( r != ERROR_SUCCESS )
|
||||
YYABORT;
|
||||
r = WHERE_CreateView( sql->db, &view, view );
|
||||
if( r != ERROR_SUCCESS )
|
||||
YYABORT;
|
||||
r = WHERE_AddCondition( view, $4 );
|
||||
r = WHERE_CreateView( sql->db, &view, view, $4 );
|
||||
if( r != ERROR_SUCCESS )
|
||||
YYABORT;
|
||||
$$ = view;
|
||||
|
|
|
@ -321,36 +321,6 @@ MSIVIEWOPS where_ops =
|
|||
WHERE_delete
|
||||
};
|
||||
|
||||
UINT WHERE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table )
|
||||
{
|
||||
MSIWHEREVIEW *wv = NULL;
|
||||
UINT count = 0, r;
|
||||
|
||||
TRACE("%p\n", wv );
|
||||
|
||||
r = table->ops->get_dimensions( table, NULL, &count );
|
||||
if( r != ERROR_SUCCESS )
|
||||
{
|
||||
ERR("can't get table dimensions\n");
|
||||
return r;
|
||||
}
|
||||
|
||||
wv = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof *wv );
|
||||
if( !wv )
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
|
||||
/* fill the structure */
|
||||
wv->view.ops = &where_ops;
|
||||
wv->db = db;
|
||||
wv->table = table;
|
||||
wv->row_count = 0;
|
||||
wv->reorder = NULL;
|
||||
wv->cond = NULL;
|
||||
*view = (MSIVIEW*) wv;
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static UINT WHERE_VerifyCondition( MSIDATABASE *db, MSIVIEW *table, struct expr *cond,
|
||||
UINT *valid )
|
||||
{
|
||||
|
@ -423,33 +393,42 @@ static UINT WHERE_VerifyCondition( MSIDATABASE *db, MSIVIEW *table, struct expr
|
|||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
UINT WHERE_AddCondition( MSIVIEW *view, struct expr *cond )
|
||||
UINT WHERE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table,
|
||||
struct expr *cond )
|
||||
{
|
||||
MSIWHEREVIEW *wv = (MSIWHEREVIEW *) view;
|
||||
UINT r, valid = 0;
|
||||
MSIWHEREVIEW *wv = NULL;
|
||||
UINT count = 0, r, valid = 0;
|
||||
|
||||
if( wv->view.ops != &where_ops )
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
if( !wv->table )
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
TRACE("%p\n", wv );
|
||||
|
||||
if( !cond )
|
||||
return ERROR_SUCCESS;
|
||||
|
||||
TRACE("Adding condition\n");
|
||||
|
||||
r = WHERE_VerifyCondition( wv->db, wv->table, cond, &valid );
|
||||
r = table->ops->get_dimensions( table, NULL, &count );
|
||||
if( r != ERROR_SUCCESS )
|
||||
ERR("condition evaluation failed\n");
|
||||
|
||||
TRACE("condition is %s\n", valid ? "valid" : "invalid" );
|
||||
if( !valid )
|
||||
{
|
||||
delete_expr( cond );
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
ERR("can't get table dimensions\n");
|
||||
return r;
|
||||
}
|
||||
|
||||
if( cond )
|
||||
{
|
||||
r = WHERE_VerifyCondition( db, table, cond, &valid );
|
||||
if( r != ERROR_SUCCESS )
|
||||
return r;
|
||||
if( !valid )
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
}
|
||||
|
||||
wv = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof *wv );
|
||||
if( !wv )
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
|
||||
/* fill the structure */
|
||||
wv->view.ops = &where_ops;
|
||||
wv->db = db;
|
||||
wv->table = table;
|
||||
wv->row_count = 0;
|
||||
wv->reorder = NULL;
|
||||
wv->cond = cond;
|
||||
*view = (MSIVIEW*) wv;
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue