setupapi: Add stub for CM_Get_Device_Interface_Alias{A,W}.
[wine.git] / dlls / msi / sql.y
blob8ffbcd4de588f301b889160599aa9ac4981c399b
1 %{
3 /*
4 * Implementation of the Microsoft Installer (msi.dll)
6 * Copyright 2002-2004 Mike McCormack for CodeWeavers
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include <stdarg.h>
24 #include <stdio.h>
25 #include <stdlib.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "query.h"
30 #include "wine/list.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(msi);
35 static UINT SQL_getstring( void *info, const struct sql_str *strdata, LPWSTR *str );
36 static INT SQL_getint( void *info );
37 static int sql_lex( void *SQL_lval, SQL_input *info );
38 static int sql_error( SQL_input *info, const char *str);
40 static LPWSTR parser_add_table( void *info, LPCWSTR list, LPCWSTR table );
41 static void *parser_alloc( void *info, unsigned int sz );
42 static column_info *parser_alloc_column( void *info, LPCWSTR table, LPCWSTR column );
44 static BOOL SQL_MarkPrimaryKeys( column_info **cols, column_info *keys);
46 static struct expr * EXPR_complex( void *info, struct expr *l, UINT op, struct expr *r );
47 static struct expr * EXPR_unary( void *info, struct expr *l, UINT op );
48 static struct expr * EXPR_column( void *info, const column_info *column );
49 static struct expr * EXPR_ival( void *info, int val );
50 static struct expr * EXPR_sval( void *info, const struct sql_str *str );
51 static struct expr * EXPR_wildcard( void *info );
53 #define PARSER_BUBBLE_UP_VIEW( sql, result, current_view ) \
54 *sql->view = current_view; \
55 result = current_view
59 %lex-param { SQL_input *info }
60 %parse-param { SQL_input *info }
61 %define api.pure
63 %union
65 struct sql_str str;
66 LPWSTR string;
67 column_info *column_list;
68 MSIVIEW *query;
69 struct expr *expr;
70 USHORT column_type;
71 int integer;
74 %token TK_ALTER TK_AND TK_BY TK_CHAR TK_COMMA TK_CREATE TK_DELETE TK_DROP
75 %token TK_DISTINCT TK_DOT TK_EQ TK_FREE TK_FROM TK_GE TK_GT TK_HOLD TK_ADD
76 %token <str> TK_ID
77 %token TK_ILLEGAL TK_INSERT TK_INT
78 %token <str> TK_INTEGER
79 %token TK_INTO TK_IS TK_KEY TK_LE TK_LONG TK_LONGCHAR TK_LP TK_LT
80 %token TK_LOCALIZABLE TK_MINUS TK_NE TK_NOT TK_NULL
81 %token TK_OBJECT TK_OR TK_ORDER TK_PRIMARY TK_RP
82 %token TK_SELECT TK_SET TK_SHORT TK_SPACE TK_STAR
83 %token <str> TK_STRING
84 %token TK_TABLE TK_TEMPORARY TK_UPDATE TK_VALUES TK_WHERE TK_WILDCARD
87 * These are extra tokens used by the lexer but never seen by the
88 * parser. We put them in a rule so that the parser generator will
89 * add them to the parse.h output file.
92 %nonassoc END_OF_FILE ILLEGAL SPACE UNCLOSED_STRING COMMENT FUNCTION
93 COLUMN AGG_FUNCTION.
95 %type <string> table tablelist id string
96 %type <column_list> selcollist collist selcolumn column column_and_type column_def table_def
97 %type <column_list> column_assignment update_assign_list constlist
98 %type <query> query from selectfrom unorderdfrom
99 %type <query> oneupdate onedelete oneselect onequery onecreate oneinsert onealter onedrop
100 %type <expr> expr val column_val const_val
101 %type <column_type> column_type data_type data_type_l data_count
102 %type <integer> number alterop
104 %left TK_OR
105 %left TK_AND
106 %left TK_NOT
107 %left TK_EQ TK_NE TK_LT TK_GT TK_LE TK_GE TK_LIKE
108 %right TK_NEGATION
112 query:
113 onequery
115 SQL_input* sql = (SQL_input*) info;
116 *sql->view = $1;
120 onequery:
121 oneselect
122 | onecreate
123 | oneinsert
124 | oneupdate
125 | onedelete
126 | onealter
127 | onedrop
130 oneinsert:
131 TK_INSERT TK_INTO table TK_LP collist TK_RP TK_VALUES TK_LP constlist TK_RP
133 SQL_input *sql = (SQL_input*) info;
134 MSIVIEW *insert = NULL;
136 INSERT_CreateView( sql->db, &insert, $3, $5, $9, FALSE );
137 if( !insert )
138 YYABORT;
140 PARSER_BUBBLE_UP_VIEW( sql, $$, insert );
142 | TK_INSERT TK_INTO table TK_LP collist TK_RP TK_VALUES TK_LP constlist TK_RP TK_TEMPORARY
144 SQL_input *sql = (SQL_input*) info;
145 MSIVIEW *insert = NULL;
147 INSERT_CreateView( sql->db, &insert, $3, $5, $9, TRUE );
148 if( !insert )
149 YYABORT;
151 PARSER_BUBBLE_UP_VIEW( sql, $$, insert );
155 onecreate:
156 TK_CREATE TK_TABLE table TK_LP table_def TK_RP
158 SQL_input* sql = (SQL_input*) info;
159 MSIVIEW *create = NULL;
160 UINT r;
162 if( !$5 )
163 YYABORT;
164 r = CREATE_CreateView( sql->db, &create, $3, $5, FALSE );
165 if( !create )
167 sql->r = r;
168 YYABORT;
171 PARSER_BUBBLE_UP_VIEW( sql, $$, create );
173 | TK_CREATE TK_TABLE table TK_LP table_def TK_RP TK_HOLD
175 SQL_input* sql = (SQL_input*) info;
176 MSIVIEW *create = NULL;
178 if( !$5 )
179 YYABORT;
180 CREATE_CreateView( sql->db, &create, $3, $5, TRUE );
181 if( !create )
182 YYABORT;
184 PARSER_BUBBLE_UP_VIEW( sql, $$, create );
188 oneupdate:
189 TK_UPDATE table TK_SET update_assign_list TK_WHERE expr
191 SQL_input* sql = (SQL_input*) info;
192 MSIVIEW *update = NULL;
194 UPDATE_CreateView( sql->db, &update, $2, $4, $6 );
195 if( !update )
196 YYABORT;
198 PARSER_BUBBLE_UP_VIEW( sql, $$, update );
200 | TK_UPDATE table TK_SET update_assign_list
202 SQL_input* sql = (SQL_input*) info;
203 MSIVIEW *update = NULL;
205 UPDATE_CreateView( sql->db, &update, $2, $4, NULL );
206 if( !update )
207 YYABORT;
209 PARSER_BUBBLE_UP_VIEW( sql, $$, update );
213 onedelete:
214 TK_DELETE from
216 SQL_input* sql = (SQL_input*) info;
217 MSIVIEW *delete = NULL;
219 DELETE_CreateView( sql->db, &delete, $2 );
220 if( !delete )
221 YYABORT;
223 PARSER_BUBBLE_UP_VIEW( sql, $$, delete );
227 onealter:
228 TK_ALTER TK_TABLE table alterop
230 SQL_input* sql = (SQL_input*) info;
231 MSIVIEW *alter = NULL;
233 ALTER_CreateView( sql->db, &alter, $3, NULL, $4 );
234 if( !alter )
235 YYABORT;
237 PARSER_BUBBLE_UP_VIEW( sql, $$, alter );
239 | TK_ALTER TK_TABLE table TK_ADD column_and_type
241 SQL_input *sql = (SQL_input *)info;
242 MSIVIEW *alter = NULL;
244 ALTER_CreateView( sql->db, &alter, $3, $5, 0 );
245 if (!alter)
246 YYABORT;
248 PARSER_BUBBLE_UP_VIEW( sql, $$, alter );
250 | TK_ALTER TK_TABLE table TK_ADD column_and_type TK_HOLD
252 SQL_input *sql = (SQL_input *)info;
253 MSIVIEW *alter = NULL;
255 ALTER_CreateView( sql->db, &alter, $3, $5, 1 );
256 if (!alter)
257 YYABORT;
259 PARSER_BUBBLE_UP_VIEW( sql, $$, alter );
263 alterop:
264 TK_HOLD
266 $$ = 1;
268 | TK_FREE
270 $$ = -1;
274 onedrop:
275 TK_DROP TK_TABLE table
277 SQL_input* sql = (SQL_input*) info;
278 MSIVIEW* drop = NULL;
279 UINT r;
281 r = DROP_CreateView( sql->db, &drop, $3 );
282 if( r != ERROR_SUCCESS || !$$ )
283 YYABORT;
285 PARSER_BUBBLE_UP_VIEW( sql, $$, drop );
289 table_def:
290 column_def TK_PRIMARY TK_KEY collist
292 if( SQL_MarkPrimaryKeys( &$1, $4 ) )
293 $$ = $1;
294 else
295 $$ = NULL;
299 column_def:
300 column_def TK_COMMA column_and_type
302 column_info *ci;
304 for( ci = $1; ci->next; ci = ci->next )
307 ci->next = $3;
308 $$ = $1;
310 | column_and_type
312 $$ = $1;
316 column_and_type:
317 column column_type
319 $$ = $1;
320 $$->type = ($2 | MSITYPE_VALID);
321 $$->temporary = $2 & MSITYPE_TEMPORARY ? TRUE : FALSE;
325 column_type:
326 data_type_l
328 $$ = $1;
330 | data_type_l TK_LOCALIZABLE
332 $$ = $1 | MSITYPE_LOCALIZABLE;
334 | data_type_l TK_TEMPORARY
336 $$ = $1 | MSITYPE_TEMPORARY;
340 data_type_l:
341 data_type
343 $$ |= MSITYPE_NULLABLE;
345 | data_type TK_NOT TK_NULL
347 $$ = $1;
351 data_type:
352 TK_CHAR
354 $$ = MSITYPE_STRING | 0x400;
356 | TK_CHAR TK_LP data_count TK_RP
358 $$ = MSITYPE_STRING | 0x400 | $3;
360 | TK_LONGCHAR
362 $$ = MSITYPE_STRING | 0x400;
364 | TK_SHORT
366 $$ = 2 | 0x400;
368 | TK_INT
370 $$ = 2 | 0x400;
372 | TK_LONG
374 $$ = 4;
376 | TK_OBJECT
378 $$ = MSITYPE_STRING | MSITYPE_VALID;
382 data_count:
383 number
385 if( ( $1 > 255 ) || ( $1 < 0 ) )
386 YYABORT;
387 $$ = $1;
391 oneselect:
392 TK_SELECT selectfrom
394 $$ = $2;
396 | TK_SELECT TK_DISTINCT selectfrom
398 SQL_input* sql = (SQL_input*) info;
399 MSIVIEW* distinct = NULL;
400 UINT r;
402 r = DISTINCT_CreateView( sql->db, &distinct, $3 );
403 if (r != ERROR_SUCCESS)
404 YYABORT;
406 PARSER_BUBBLE_UP_VIEW( sql, $$, distinct );
410 selectfrom:
411 selcollist from
413 SQL_input* sql = (SQL_input*) info;
414 MSIVIEW* select = NULL;
415 UINT r;
417 if( $1 )
419 r = SELECT_CreateView( sql->db, &select, $2, $1 );
420 if (r != ERROR_SUCCESS)
421 YYABORT;
423 PARSER_BUBBLE_UP_VIEW( sql, $$, select );
425 else
426 $$ = $2;
430 selcollist:
431 selcolumn
432 | selcolumn TK_COMMA selcollist
434 $1->next = $3;
436 | TK_STAR
438 $$ = NULL;
442 collist:
443 column
444 | column TK_COMMA collist
446 $1->next = $3;
448 | TK_STAR
450 $$ = NULL;
454 from:
455 TK_FROM table
457 SQL_input* sql = (SQL_input*) info;
458 MSIVIEW* table = NULL;
459 UINT r;
461 r = TABLE_CreateView( sql->db, $2, &table );
462 if( r != ERROR_SUCCESS || !$$ )
463 YYABORT;
465 PARSER_BUBBLE_UP_VIEW( sql, $$, table );
467 | unorderdfrom TK_ORDER TK_BY collist
469 UINT r;
471 if( $4 )
473 r = $1->ops->sort( $1, $4 );
474 if ( r != ERROR_SUCCESS)
475 YYABORT;
478 $$ = $1;
480 | unorderdfrom
483 unorderdfrom:
484 TK_FROM tablelist
486 SQL_input* sql = (SQL_input*) info;
487 MSIVIEW* where = NULL;
488 UINT r;
490 r = WHERE_CreateView( sql->db, &where, $2, NULL );
491 if( r != ERROR_SUCCESS )
492 YYABORT;
494 PARSER_BUBBLE_UP_VIEW( sql, $$, where );
496 | TK_FROM tablelist TK_WHERE expr
498 SQL_input* sql = (SQL_input*) info;
499 MSIVIEW* where = NULL;
500 UINT r;
502 r = WHERE_CreateView( sql->db, &where, $2, $4 );
503 if( r != ERROR_SUCCESS )
504 YYABORT;
506 PARSER_BUBBLE_UP_VIEW( sql, $$, where );
510 tablelist:
511 table
513 $$ = $1;
515 | table TK_COMMA tablelist
517 $$ = parser_add_table( info, $3, $1 );
518 if (!$$)
519 YYABORT;
523 expr:
524 TK_LP expr TK_RP
526 $$ = $2;
527 if( !$$ )
528 YYABORT;
530 | expr TK_AND expr
532 $$ = EXPR_complex( info, $1, OP_AND, $3 );
533 if( !$$ )
534 YYABORT;
536 | expr TK_OR expr
538 $$ = EXPR_complex( info, $1, OP_OR, $3 );
539 if( !$$ )
540 YYABORT;
542 | column_val TK_EQ val
544 $$ = EXPR_complex( info, $1, OP_EQ, $3 );
545 if( !$$ )
546 YYABORT;
548 | column_val TK_GT val
550 $$ = EXPR_complex( info, $1, OP_GT, $3 );
551 if( !$$ )
552 YYABORT;
554 | column_val TK_LT val
556 $$ = EXPR_complex( info, $1, OP_LT, $3 );
557 if( !$$ )
558 YYABORT;
560 | column_val TK_LE val
562 $$ = EXPR_complex( info, $1, OP_LE, $3 );
563 if( !$$ )
564 YYABORT;
566 | column_val TK_GE val
568 $$ = EXPR_complex( info, $1, OP_GE, $3 );
569 if( !$$ )
570 YYABORT;
572 | column_val TK_NE val
574 $$ = EXPR_complex( info, $1, OP_NE, $3 );
575 if( !$$ )
576 YYABORT;
578 | column_val TK_IS TK_NULL
580 $$ = EXPR_unary( info, $1, OP_ISNULL );
581 if( !$$ )
582 YYABORT;
584 | column_val TK_IS TK_NOT TK_NULL
586 $$ = EXPR_unary( info, $1, OP_NOTNULL );
587 if( !$$ )
588 YYABORT;
592 val:
593 column_val
594 | const_val
597 constlist:
598 const_val
600 $$ = parser_alloc_column( info, NULL, NULL );
601 if( !$$ )
602 YYABORT;
603 $$->val = $1;
605 | const_val TK_COMMA constlist
607 $$ = parser_alloc_column( info, NULL, NULL );
608 if( !$$ )
609 YYABORT;
610 $$->val = $1;
611 $$->next = $3;
615 update_assign_list:
616 column_assignment
617 | column_assignment TK_COMMA update_assign_list
619 $$ = $1;
620 $$->next = $3;
624 column_assignment:
625 column TK_EQ const_val
627 $$ = $1;
628 $$->val = $3;
632 const_val:
633 number
635 $$ = EXPR_ival( info, $1 );
636 if( !$$ )
637 YYABORT;
639 | TK_MINUS number %prec TK_NEGATION
641 $$ = EXPR_ival( info, -$2 );
642 if( !$$ )
643 YYABORT;
645 | TK_STRING
647 $$ = EXPR_sval( info, &$1 );
648 if( !$$ )
649 YYABORT;
651 | TK_WILDCARD
653 $$ = EXPR_wildcard( info );
654 if( !$$ )
655 YYABORT;
657 | TK_NULL
659 $$ = EXPR_sval( info, NULL );
660 if ( !$$ )
661 YYABORT;
665 column_val:
666 column
668 $$ = EXPR_column( info, $1 );
669 if( !$$ )
670 YYABORT;
674 column:
675 table TK_DOT id
677 $$ = parser_alloc_column( info, $1, $3 );
678 if( !$$ )
679 YYABORT;
681 | id
683 $$ = parser_alloc_column( info, NULL, $1 );
684 if( !$$ )
685 YYABORT;
689 selcolumn:
690 table TK_DOT id
692 $$ = parser_alloc_column( info, $1, $3 );
693 if( !$$ )
694 YYABORT;
696 | id
698 $$ = parser_alloc_column( info, NULL, $1 );
699 if( !$$ )
700 YYABORT;
702 | string
704 $$ = parser_alloc_column( info, NULL, $1 );
705 if( !$$ )
706 YYABORT;
710 table:
713 $$ = $1;
718 TK_ID
720 if ( SQL_getstring( info, &$1, &$$ ) != ERROR_SUCCESS || !$$ )
721 YYABORT;
725 string:
726 TK_STRING
728 if ( SQL_getstring( info, &$1, &$$ ) != ERROR_SUCCESS || !$$ )
729 YYABORT;
733 number:
734 TK_INTEGER
736 $$ = SQL_getint( info );
742 static LPWSTR parser_add_table( void *info, LPCWSTR list, LPCWSTR table )
744 static const WCHAR space[] = {' ',0};
745 DWORD len = lstrlenW( list ) + lstrlenW( table ) + 2;
746 LPWSTR ret;
748 ret = parser_alloc( info, len * sizeof(WCHAR) );
749 if( ret )
751 lstrcpyW( ret, list );
752 lstrcatW( ret, space );
753 lstrcatW( ret, table );
755 return ret;
758 static void *parser_alloc( void *info, unsigned int sz )
760 SQL_input* sql = (SQL_input*) info;
761 struct list *mem;
763 mem = msi_alloc( sizeof (struct list) + sz );
764 list_add_tail( sql->mem, mem );
765 return &mem[1];
768 static column_info *parser_alloc_column( void *info, LPCWSTR table, LPCWSTR column )
770 column_info *col;
772 col = parser_alloc( info, sizeof (*col) );
773 if( col )
775 col->table = table;
776 col->column = column;
777 col->val = NULL;
778 col->type = 0;
779 col->next = NULL;
782 return col;
785 static int sql_lex( void *SQL_lval, SQL_input *sql )
787 int token, skip;
788 struct sql_str * str = SQL_lval;
792 sql->n += sql->len;
793 if( ! sql->command[sql->n] )
794 return 0; /* end of input */
796 /* TRACE("string : %s\n", debugstr_w(&sql->command[sql->n])); */
797 sql->len = sqliteGetToken( &sql->command[sql->n], &token, &skip );
798 if( sql->len==0 )
799 break;
800 str->data = &sql->command[sql->n];
801 str->len = sql->len;
802 sql->n += skip;
804 while( token == TK_SPACE );
806 /* TRACE("token : %d (%s)\n", token, debugstr_wn(&sql->command[sql->n], sql->len)); */
808 return token;
811 UINT SQL_getstring( void *info, const struct sql_str *strdata, LPWSTR *str )
813 LPCWSTR p = strdata->data;
814 UINT len = strdata->len;
816 /* match quotes */
817 if( ( (p[0]=='`') && (p[len-1]!='`') ) ||
818 ( (p[0]=='\'') && (p[len-1]!='\'') ) )
819 return ERROR_FUNCTION_FAILED;
821 /* if there are quotes, remove them */
822 if( ( (p[0]=='`') && (p[len-1]=='`') ) ||
823 ( (p[0]=='\'') && (p[len-1]=='\'') ) )
825 p++;
826 len -= 2;
828 *str = parser_alloc( info, (len + 1)*sizeof(WCHAR) );
829 if( !*str )
830 return ERROR_OUTOFMEMORY;
831 memcpy( *str, p, len*sizeof(WCHAR) );
832 (*str)[len]=0;
834 return ERROR_SUCCESS;
837 INT SQL_getint( void *info )
839 SQL_input* sql = (SQL_input*) info;
840 LPCWSTR p = &sql->command[sql->n];
841 INT i, r = 0;
843 for( i=0; i<sql->len; i++ )
845 if( '0' > p[i] || '9' < p[i] )
847 ERR("should only be numbers here!\n");
848 break;
850 r = (p[i]-'0') + r*10;
853 return r;
856 static int sql_error( SQL_input *info, const char *str )
858 return 0;
861 static struct expr * EXPR_wildcard( void *info )
863 struct expr *e = parser_alloc( info, sizeof *e );
864 if( e )
866 e->type = EXPR_WILDCARD;
868 return e;
871 static struct expr * EXPR_complex( void *info, struct expr *l, UINT op, struct expr *r )
873 struct expr *e = parser_alloc( info, sizeof *e );
874 if( e )
876 e->type = EXPR_COMPLEX;
877 e->u.expr.left = l;
878 e->u.expr.op = op;
879 e->u.expr.right = r;
881 return e;
884 static struct expr * EXPR_unary( void *info, struct expr *l, UINT op )
886 struct expr *e = parser_alloc( info, sizeof *e );
887 if( e )
889 e->type = EXPR_UNARY;
890 e->u.expr.left = l;
891 e->u.expr.op = op;
892 e->u.expr.right = NULL;
894 return e;
897 static struct expr * EXPR_column( void *info, const column_info *column )
899 struct expr *e = parser_alloc( info, sizeof *e );
900 if( e )
902 e->type = EXPR_COLUMN;
903 e->u.column.unparsed.column = column->column;
904 e->u.column.unparsed.table = column->table;
906 return e;
909 static struct expr * EXPR_ival( void *info, int val )
911 struct expr *e = parser_alloc( info, sizeof *e );
912 if( e )
914 e->type = EXPR_IVAL;
915 e->u.ival = val;
917 return e;
920 static struct expr * EXPR_sval( void *info, const struct sql_str *str )
922 struct expr *e = parser_alloc( info, sizeof *e );
923 if( e )
925 e->type = EXPR_SVAL;
926 if( !str) e->u.sval = NULL;
927 else if( SQL_getstring( info, str, (LPWSTR *)&e->u.sval ) != ERROR_SUCCESS )
928 return NULL; /* e will be freed by query destructor */
930 return e;
933 static void swap_columns( column_info **cols, column_info *A, int idx )
935 column_info *preA = NULL, *preB = NULL, *B, *ptr;
936 int i = 0;
938 B = NULL;
939 ptr = *cols;
940 while( ptr )
942 if( i++ == idx )
943 B = ptr;
944 else if( !B )
945 preB = ptr;
947 if( ptr->next == A )
948 preA = ptr;
950 ptr = ptr->next;
953 if( preB ) preB->next = A;
954 if( preA ) preA->next = B;
955 ptr = A->next;
956 A->next = B->next;
957 B->next = ptr;
958 if( idx == 0 )
959 *cols = A;
962 static BOOL SQL_MarkPrimaryKeys( column_info **cols,
963 column_info *keys )
965 column_info *k;
966 BOOL found = TRUE;
967 int count;
969 for( k = keys, count = 0; k && found; k = k->next, count++ )
971 column_info *c;
972 int idx;
974 found = FALSE;
975 for( c = *cols, idx = 0; c && !found; c = c->next, idx++ )
977 if( wcscmp( k->column, c->column ) )
978 continue;
979 c->type |= MSITYPE_KEY;
980 found = TRUE;
981 if (idx != count)
982 swap_columns( cols, c, count );
986 return found;
989 UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview,
990 struct list *mem )
992 SQL_input sql;
993 int r;
995 *phview = NULL;
997 sql.db = db;
998 sql.command = command;
999 sql.n = 0;
1000 sql.len = 0;
1001 sql.r = ERROR_BAD_QUERY_SYNTAX;
1002 sql.view = phview;
1003 sql.mem = mem;
1005 r = sql_parse(&sql);
1007 TRACE("Parse returned %d\n", r);
1008 if( r )
1010 if (*sql.view)
1012 (*sql.view)->ops->delete(*sql.view);
1013 *sql.view = NULL;
1015 return sql.r;
1018 return ERROR_SUCCESS;