mstask: Implement ITask::DeleteTrigger().
[wine.git] / dlls / msi / sql.y
blob2101c680eb38bfcd155e1112491e650e5714a5b4
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
24 #include "config.h"
26 #include <stdarg.h>
27 #include <stdio.h>
28 #include <stdlib.h>
30 #include "windef.h"
31 #include "winbase.h"
32 #include "query.h"
33 #include "wine/list.h"
34 #include "wine/debug.h"
35 #include "wine/unicode.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msi);
39 static UINT SQL_getstring( void *info, const struct sql_str *strdata, LPWSTR *str );
40 static INT SQL_getint( void *info );
41 static int sql_lex( void *SQL_lval, SQL_input *info );
42 static int sql_error( SQL_input *info, const char *str);
44 static LPWSTR parser_add_table( void *info, LPCWSTR list, LPCWSTR table );
45 static void *parser_alloc( void *info, unsigned int sz );
46 static column_info *parser_alloc_column( void *info, LPCWSTR table, LPCWSTR column );
48 static BOOL SQL_MarkPrimaryKeys( column_info **cols, column_info *keys);
50 static struct expr * EXPR_complex( void *info, struct expr *l, UINT op, struct expr *r );
51 static struct expr * EXPR_unary( void *info, struct expr *l, UINT op );
52 static struct expr * EXPR_column( void *info, const column_info *column );
53 static struct expr * EXPR_ival( void *info, int val );
54 static struct expr * EXPR_sval( void *info, const struct sql_str *str );
55 static struct expr * EXPR_wildcard( void *info );
57 #define PARSER_BUBBLE_UP_VIEW( sql, result, current_view ) \
58 *sql->view = current_view; \
59 result = current_view
63 %lex-param { SQL_input *info }
64 %parse-param { SQL_input *info }
65 %pure-parser
67 %union
69 struct sql_str str;
70 LPWSTR string;
71 column_info *column_list;
72 MSIVIEW *query;
73 struct expr *expr;
74 USHORT column_type;
75 int integer;
78 %token TK_ALTER TK_AND TK_BY TK_CHAR TK_COMMA TK_CREATE TK_DELETE TK_DROP
79 %token TK_DISTINCT TK_DOT TK_EQ TK_FREE TK_FROM TK_GE TK_GT TK_HOLD TK_ADD
80 %token <str> TK_ID
81 %token TK_ILLEGAL TK_INSERT TK_INT
82 %token <str> TK_INTEGER
83 %token TK_INTO TK_IS TK_KEY TK_LE TK_LONG TK_LONGCHAR TK_LP TK_LT
84 %token TK_LOCALIZABLE TK_MINUS TK_NE TK_NOT TK_NULL
85 %token TK_OBJECT TK_OR TK_ORDER TK_PRIMARY TK_RP
86 %token TK_SELECT TK_SET TK_SHORT TK_SPACE TK_STAR
87 %token <str> TK_STRING
88 %token TK_TABLE TK_TEMPORARY TK_UPDATE TK_VALUES TK_WHERE TK_WILDCARD
91 * These are extra tokens used by the lexer but never seen by the
92 * parser. We put them in a rule so that the parser generator will
93 * add them to the parse.h output file.
96 %nonassoc END_OF_FILE ILLEGAL SPACE UNCLOSED_STRING COMMENT FUNCTION
97 COLUMN AGG_FUNCTION.
99 %type <string> table tablelist id string
100 %type <column_list> selcollist collist selcolumn column column_and_type column_def table_def
101 %type <column_list> column_assignment update_assign_list constlist
102 %type <query> query from selectfrom unorderdfrom
103 %type <query> oneupdate onedelete oneselect onequery onecreate oneinsert onealter onedrop
104 %type <expr> expr val column_val const_val
105 %type <column_type> column_type data_type data_type_l data_count
106 %type <integer> number alterop
108 %left TK_OR
109 %left TK_AND
110 %left TK_NOT
111 %left TK_EQ TK_NE TK_LT TK_GT TK_LE TK_GE TK_LIKE
112 %right TK_NEGATION
116 query:
117 onequery
119 SQL_input* sql = (SQL_input*) info;
120 *sql->view = $1;
124 onequery:
125 oneselect
126 | onecreate
127 | oneinsert
128 | oneupdate
129 | onedelete
130 | onealter
131 | onedrop
134 oneinsert:
135 TK_INSERT TK_INTO table TK_LP collist TK_RP TK_VALUES TK_LP constlist TK_RP
137 SQL_input *sql = (SQL_input*) info;
138 MSIVIEW *insert = NULL;
140 INSERT_CreateView( sql->db, &insert, $3, $5, $9, FALSE );
141 if( !insert )
142 YYABORT;
144 PARSER_BUBBLE_UP_VIEW( sql, $$, insert );
146 | TK_INSERT TK_INTO table TK_LP collist TK_RP TK_VALUES TK_LP constlist TK_RP TK_TEMPORARY
148 SQL_input *sql = (SQL_input*) info;
149 MSIVIEW *insert = NULL;
151 INSERT_CreateView( sql->db, &insert, $3, $5, $9, TRUE );
152 if( !insert )
153 YYABORT;
155 PARSER_BUBBLE_UP_VIEW( sql, $$, insert );
159 onecreate:
160 TK_CREATE TK_TABLE table TK_LP table_def TK_RP
162 SQL_input* sql = (SQL_input*) info;
163 MSIVIEW *create = NULL;
164 UINT r;
166 if( !$5 )
167 YYABORT;
168 r = CREATE_CreateView( sql->db, &create, $3, $5, FALSE );
169 if( !create )
171 sql->r = r;
172 YYABORT;
175 PARSER_BUBBLE_UP_VIEW( sql, $$, create );
177 | TK_CREATE TK_TABLE table TK_LP table_def TK_RP TK_HOLD
179 SQL_input* sql = (SQL_input*) info;
180 MSIVIEW *create = NULL;
182 if( !$5 )
183 YYABORT;
184 CREATE_CreateView( sql->db, &create, $3, $5, TRUE );
185 if( !create )
186 YYABORT;
188 PARSER_BUBBLE_UP_VIEW( sql, $$, create );
192 oneupdate:
193 TK_UPDATE table TK_SET update_assign_list TK_WHERE expr
195 SQL_input* sql = (SQL_input*) info;
196 MSIVIEW *update = NULL;
198 UPDATE_CreateView( sql->db, &update, $2, $4, $6 );
199 if( !update )
200 YYABORT;
202 PARSER_BUBBLE_UP_VIEW( sql, $$, update );
204 | TK_UPDATE table TK_SET update_assign_list
206 SQL_input* sql = (SQL_input*) info;
207 MSIVIEW *update = NULL;
209 UPDATE_CreateView( sql->db, &update, $2, $4, NULL );
210 if( !update )
211 YYABORT;
213 PARSER_BUBBLE_UP_VIEW( sql, $$, update );
217 onedelete:
218 TK_DELETE from
220 SQL_input* sql = (SQL_input*) info;
221 MSIVIEW *delete = NULL;
223 DELETE_CreateView( sql->db, &delete, $2 );
224 if( !delete )
225 YYABORT;
227 PARSER_BUBBLE_UP_VIEW( sql, $$, delete );
231 onealter:
232 TK_ALTER TK_TABLE table alterop
234 SQL_input* sql = (SQL_input*) info;
235 MSIVIEW *alter = NULL;
237 ALTER_CreateView( sql->db, &alter, $3, NULL, $4 );
238 if( !alter )
239 YYABORT;
241 PARSER_BUBBLE_UP_VIEW( sql, $$, alter );
243 | TK_ALTER TK_TABLE table TK_ADD column_and_type
245 SQL_input *sql = (SQL_input *)info;
246 MSIVIEW *alter = NULL;
248 ALTER_CreateView( sql->db, &alter, $3, $5, 0 );
249 if (!alter)
250 YYABORT;
252 PARSER_BUBBLE_UP_VIEW( sql, $$, alter );
254 | TK_ALTER TK_TABLE table TK_ADD column_and_type TK_HOLD
256 SQL_input *sql = (SQL_input *)info;
257 MSIVIEW *alter = NULL;
259 ALTER_CreateView( sql->db, &alter, $3, $5, 1 );
260 if (!alter)
261 YYABORT;
263 PARSER_BUBBLE_UP_VIEW( sql, $$, alter );
267 alterop:
268 TK_HOLD
270 $$ = 1;
272 | TK_FREE
274 $$ = -1;
278 onedrop:
279 TK_DROP TK_TABLE table
281 SQL_input* sql = (SQL_input*) info;
282 MSIVIEW* drop = NULL;
283 UINT r;
285 r = DROP_CreateView( sql->db, &drop, $3 );
286 if( r != ERROR_SUCCESS || !$$ )
287 YYABORT;
289 PARSER_BUBBLE_UP_VIEW( sql, $$, drop );
293 table_def:
294 column_def TK_PRIMARY TK_KEY collist
296 if( SQL_MarkPrimaryKeys( &$1, $4 ) )
297 $$ = $1;
298 else
299 $$ = NULL;
303 column_def:
304 column_def TK_COMMA column_and_type
306 column_info *ci;
308 for( ci = $1; ci->next; ci = ci->next )
311 ci->next = $3;
312 $$ = $1;
314 | column_and_type
316 $$ = $1;
320 column_and_type:
321 column column_type
323 $$ = $1;
324 $$->type = ($2 | MSITYPE_VALID);
325 $$->temporary = $2 & MSITYPE_TEMPORARY ? TRUE : FALSE;
329 column_type:
330 data_type_l
332 $$ = $1;
334 | data_type_l TK_LOCALIZABLE
336 $$ = $1 | MSITYPE_LOCALIZABLE;
338 | data_type_l TK_TEMPORARY
340 $$ = $1 | MSITYPE_TEMPORARY;
344 data_type_l:
345 data_type
347 $$ |= MSITYPE_NULLABLE;
349 | data_type TK_NOT TK_NULL
351 $$ = $1;
355 data_type:
356 TK_CHAR
358 $$ = MSITYPE_STRING | 0x400;
360 | TK_CHAR TK_LP data_count TK_RP
362 $$ = MSITYPE_STRING | 0x400 | $3;
364 | TK_LONGCHAR
366 $$ = MSITYPE_STRING | 0x400;
368 | TK_SHORT
370 $$ = 2 | 0x400;
372 | TK_INT
374 $$ = 2 | 0x400;
376 | TK_LONG
378 $$ = 4;
380 | TK_OBJECT
382 $$ = MSITYPE_STRING | MSITYPE_VALID;
386 data_count:
387 number
389 if( ( $1 > 255 ) || ( $1 < 0 ) )
390 YYABORT;
391 $$ = $1;
395 oneselect:
396 TK_SELECT selectfrom
398 $$ = $2;
400 | TK_SELECT TK_DISTINCT selectfrom
402 SQL_input* sql = (SQL_input*) info;
403 MSIVIEW* distinct = NULL;
404 UINT r;
406 r = DISTINCT_CreateView( sql->db, &distinct, $3 );
407 if (r != ERROR_SUCCESS)
408 YYABORT;
410 PARSER_BUBBLE_UP_VIEW( sql, $$, distinct );
414 selectfrom:
415 selcollist from
417 SQL_input* sql = (SQL_input*) info;
418 MSIVIEW* select = NULL;
419 UINT r;
421 if( $1 )
423 r = SELECT_CreateView( sql->db, &select, $2, $1 );
424 if (r != ERROR_SUCCESS)
425 YYABORT;
427 PARSER_BUBBLE_UP_VIEW( sql, $$, select );
429 else
430 $$ = $2;
434 selcollist:
435 selcolumn
436 | selcolumn TK_COMMA selcollist
438 $1->next = $3;
440 | TK_STAR
442 $$ = NULL;
446 collist:
447 column
448 | column TK_COMMA collist
450 $1->next = $3;
452 | TK_STAR
454 $$ = NULL;
458 from:
459 TK_FROM table
461 SQL_input* sql = (SQL_input*) info;
462 MSIVIEW* table = NULL;
463 UINT r;
465 r = TABLE_CreateView( sql->db, $2, &table );
466 if( r != ERROR_SUCCESS || !$$ )
467 YYABORT;
469 PARSER_BUBBLE_UP_VIEW( sql, $$, table );
471 | unorderdfrom TK_ORDER TK_BY collist
473 UINT r;
475 if( $4 )
477 r = $1->ops->sort( $1, $4 );
478 if ( r != ERROR_SUCCESS)
479 YYABORT;
482 $$ = $1;
484 | unorderdfrom
487 unorderdfrom:
488 TK_FROM tablelist
490 SQL_input* sql = (SQL_input*) info;
491 MSIVIEW* where = NULL;
492 UINT r;
494 r = WHERE_CreateView( sql->db, &where, $2, NULL );
495 if( r != ERROR_SUCCESS )
496 YYABORT;
498 PARSER_BUBBLE_UP_VIEW( sql, $$, where );
500 | TK_FROM tablelist TK_WHERE expr
502 SQL_input* sql = (SQL_input*) info;
503 MSIVIEW* where = NULL;
504 UINT r;
506 r = WHERE_CreateView( sql->db, &where, $2, $4 );
507 if( r != ERROR_SUCCESS )
508 YYABORT;
510 PARSER_BUBBLE_UP_VIEW( sql, $$, where );
514 tablelist:
515 table
517 $$ = $1;
519 | table TK_COMMA tablelist
521 $$ = parser_add_table( info, $3, $1 );
522 if (!$$)
523 YYABORT;
527 expr:
528 TK_LP expr TK_RP
530 $$ = $2;
531 if( !$$ )
532 YYABORT;
534 | expr TK_AND expr
536 $$ = EXPR_complex( info, $1, OP_AND, $3 );
537 if( !$$ )
538 YYABORT;
540 | expr TK_OR expr
542 $$ = EXPR_complex( info, $1, OP_OR, $3 );
543 if( !$$ )
544 YYABORT;
546 | column_val TK_EQ val
548 $$ = EXPR_complex( info, $1, OP_EQ, $3 );
549 if( !$$ )
550 YYABORT;
552 | column_val TK_GT val
554 $$ = EXPR_complex( info, $1, OP_GT, $3 );
555 if( !$$ )
556 YYABORT;
558 | column_val TK_LT val
560 $$ = EXPR_complex( info, $1, OP_LT, $3 );
561 if( !$$ )
562 YYABORT;
564 | column_val TK_LE val
566 $$ = EXPR_complex( info, $1, OP_LE, $3 );
567 if( !$$ )
568 YYABORT;
570 | column_val TK_GE val
572 $$ = EXPR_complex( info, $1, OP_GE, $3 );
573 if( !$$ )
574 YYABORT;
576 | column_val TK_NE val
578 $$ = EXPR_complex( info, $1, OP_NE, $3 );
579 if( !$$ )
580 YYABORT;
582 | column_val TK_IS TK_NULL
584 $$ = EXPR_unary( info, $1, OP_ISNULL );
585 if( !$$ )
586 YYABORT;
588 | column_val TK_IS TK_NOT TK_NULL
590 $$ = EXPR_unary( info, $1, OP_NOTNULL );
591 if( !$$ )
592 YYABORT;
596 val:
597 column_val
598 | const_val
601 constlist:
602 const_val
604 $$ = parser_alloc_column( info, NULL, NULL );
605 if( !$$ )
606 YYABORT;
607 $$->val = $1;
609 | const_val TK_COMMA constlist
611 $$ = parser_alloc_column( info, NULL, NULL );
612 if( !$$ )
613 YYABORT;
614 $$->val = $1;
615 $$->next = $3;
619 update_assign_list:
620 column_assignment
621 | column_assignment TK_COMMA update_assign_list
623 $$ = $1;
624 $$->next = $3;
628 column_assignment:
629 column TK_EQ const_val
631 $$ = $1;
632 $$->val = $3;
636 const_val:
637 number
639 $$ = EXPR_ival( info, $1 );
640 if( !$$ )
641 YYABORT;
643 | TK_MINUS number %prec TK_NEGATION
645 $$ = EXPR_ival( info, -$2 );
646 if( !$$ )
647 YYABORT;
649 | TK_STRING
651 $$ = EXPR_sval( info, &$1 );
652 if( !$$ )
653 YYABORT;
655 | TK_WILDCARD
657 $$ = EXPR_wildcard( info );
658 if( !$$ )
659 YYABORT;
661 | TK_NULL
663 $$ = EXPR_sval( info, NULL );
664 if ( !$$ )
665 YYABORT;
669 column_val:
670 column
672 $$ = EXPR_column( info, $1 );
673 if( !$$ )
674 YYABORT;
678 column:
679 table TK_DOT id
681 $$ = parser_alloc_column( info, $1, $3 );
682 if( !$$ )
683 YYABORT;
685 | id
687 $$ = parser_alloc_column( info, NULL, $1 );
688 if( !$$ )
689 YYABORT;
693 selcolumn:
694 table TK_DOT id
696 $$ = parser_alloc_column( info, $1, $3 );
697 if( !$$ )
698 YYABORT;
700 | id
702 $$ = parser_alloc_column( info, NULL, $1 );
703 if( !$$ )
704 YYABORT;
706 | string
708 $$ = parser_alloc_column( info, NULL, $1 );
709 if( !$$ )
710 YYABORT;
714 table:
717 $$ = $1;
722 TK_ID
724 if ( SQL_getstring( info, &$1, &$$ ) != ERROR_SUCCESS || !$$ )
725 YYABORT;
729 string:
730 TK_STRING
732 if ( SQL_getstring( info, &$1, &$$ ) != ERROR_SUCCESS || !$$ )
733 YYABORT;
737 number:
738 TK_INTEGER
740 $$ = SQL_getint( info );
746 static LPWSTR parser_add_table( void *info, LPCWSTR list, LPCWSTR table )
748 static const WCHAR space[] = {' ',0};
749 DWORD len = strlenW( list ) + strlenW( table ) + 2;
750 LPWSTR ret;
752 ret = parser_alloc( info, len * sizeof(WCHAR) );
753 if( ret )
755 strcpyW( ret, list );
756 strcatW( ret, space );
757 strcatW( ret, table );
759 return ret;
762 static void *parser_alloc( void *info, unsigned int sz )
764 SQL_input* sql = (SQL_input*) info;
765 struct list *mem;
767 mem = msi_alloc( sizeof (struct list) + sz );
768 list_add_tail( sql->mem, mem );
769 return &mem[1];
772 static column_info *parser_alloc_column( void *info, LPCWSTR table, LPCWSTR column )
774 column_info *col;
776 col = parser_alloc( info, sizeof (*col) );
777 if( col )
779 col->table = table;
780 col->column = column;
781 col->val = NULL;
782 col->type = 0;
783 col->next = NULL;
786 return col;
789 static int sql_lex( void *SQL_lval, SQL_input *sql )
791 int token, skip;
792 struct sql_str * str = SQL_lval;
796 sql->n += sql->len;
797 if( ! sql->command[sql->n] )
798 return 0; /* end of input */
800 /* TRACE("string : %s\n", debugstr_w(&sql->command[sql->n])); */
801 sql->len = sqliteGetToken( &sql->command[sql->n], &token, &skip );
802 if( sql->len==0 )
803 break;
804 str->data = &sql->command[sql->n];
805 str->len = sql->len;
806 sql->n += skip;
808 while( token == TK_SPACE );
810 /* TRACE("token : %d (%s)\n", token, debugstr_wn(&sql->command[sql->n], sql->len)); */
812 return token;
815 UINT SQL_getstring( void *info, const struct sql_str *strdata, LPWSTR *str )
817 LPCWSTR p = strdata->data;
818 UINT len = strdata->len;
820 /* match quotes */
821 if( ( (p[0]=='`') && (p[len-1]!='`') ) ||
822 ( (p[0]=='\'') && (p[len-1]!='\'') ) )
823 return ERROR_FUNCTION_FAILED;
825 /* if there are quotes, remove them */
826 if( ( (p[0]=='`') && (p[len-1]=='`') ) ||
827 ( (p[0]=='\'') && (p[len-1]=='\'') ) )
829 p++;
830 len -= 2;
832 *str = parser_alloc( info, (len + 1)*sizeof(WCHAR) );
833 if( !*str )
834 return ERROR_OUTOFMEMORY;
835 memcpy( *str, p, len*sizeof(WCHAR) );
836 (*str)[len]=0;
838 return ERROR_SUCCESS;
841 INT SQL_getint( void *info )
843 SQL_input* sql = (SQL_input*) info;
844 LPCWSTR p = &sql->command[sql->n];
845 INT i, r = 0;
847 for( i=0; i<sql->len; i++ )
849 if( '0' > p[i] || '9' < p[i] )
851 ERR("should only be numbers here!\n");
852 break;
854 r = (p[i]-'0') + r*10;
857 return r;
860 static int sql_error( SQL_input *info, const char *str )
862 return 0;
865 static struct expr * EXPR_wildcard( void *info )
867 struct expr *e = parser_alloc( info, sizeof *e );
868 if( e )
870 e->type = EXPR_WILDCARD;
872 return e;
875 static struct expr * EXPR_complex( void *info, struct expr *l, UINT op, struct expr *r )
877 struct expr *e = parser_alloc( info, sizeof *e );
878 if( e )
880 e->type = EXPR_COMPLEX;
881 e->u.expr.left = l;
882 e->u.expr.op = op;
883 e->u.expr.right = r;
885 return e;
888 static struct expr * EXPR_unary( void *info, struct expr *l, UINT op )
890 struct expr *e = parser_alloc( info, sizeof *e );
891 if( e )
893 e->type = EXPR_UNARY;
894 e->u.expr.left = l;
895 e->u.expr.op = op;
896 e->u.expr.right = NULL;
898 return e;
901 static struct expr * EXPR_column( void *info, const column_info *column )
903 struct expr *e = parser_alloc( info, sizeof *e );
904 if( e )
906 e->type = EXPR_COLUMN;
907 e->u.column.unparsed.column = column->column;
908 e->u.column.unparsed.table = column->table;
910 return e;
913 static struct expr * EXPR_ival( void *info, int val )
915 struct expr *e = parser_alloc( info, sizeof *e );
916 if( e )
918 e->type = EXPR_IVAL;
919 e->u.ival = val;
921 return e;
924 static struct expr * EXPR_sval( void *info, const struct sql_str *str )
926 struct expr *e = parser_alloc( info, sizeof *e );
927 if( e )
929 e->type = EXPR_SVAL;
930 if( !str) e->u.sval = NULL;
931 else if( SQL_getstring( info, str, (LPWSTR *)&e->u.sval ) != ERROR_SUCCESS )
932 return NULL; /* e will be freed by query destructor */
934 return e;
937 static void swap_columns( column_info **cols, column_info *A, int idx )
939 column_info *preA = NULL, *preB = NULL, *B, *ptr;
940 int i = 0;
942 B = NULL;
943 ptr = *cols;
944 while( ptr )
946 if( i++ == idx )
947 B = ptr;
948 else if( !B )
949 preB = ptr;
951 if( ptr->next == A )
952 preA = ptr;
954 ptr = ptr->next;
957 if( preB ) preB->next = A;
958 if( preA ) preA->next = B;
959 ptr = A->next;
960 A->next = B->next;
961 B->next = ptr;
962 if( idx == 0 )
963 *cols = A;
966 static BOOL SQL_MarkPrimaryKeys( column_info **cols,
967 column_info *keys )
969 column_info *k;
970 BOOL found = TRUE;
971 int count;
973 for( k = keys, count = 0; k && found; k = k->next, count++ )
975 column_info *c;
976 int idx;
978 found = FALSE;
979 for( c = *cols, idx = 0; c && !found; c = c->next, idx++ )
981 if( strcmpW( k->column, c->column ) )
982 continue;
983 c->type |= MSITYPE_KEY;
984 found = TRUE;
985 if (idx != count)
986 swap_columns( cols, c, count );
990 return found;
993 UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview,
994 struct list *mem )
996 SQL_input sql;
997 int r;
999 *phview = NULL;
1001 sql.db = db;
1002 sql.command = command;
1003 sql.n = 0;
1004 sql.len = 0;
1005 sql.r = ERROR_BAD_QUERY_SYNTAX;
1006 sql.view = phview;
1007 sql.mem = mem;
1009 r = sql_parse(&sql);
1011 TRACE("Parse returned %d\n", r);
1012 if( r )
1014 if (*sql.view)
1016 (*sql.view)->ops->delete(*sql.view);
1017 *sql.view = NULL;
1019 return sql.r;
1022 return ERROR_SUCCESS;