dmime: Remove DECLSPEC_HIDDEN usage.
[wine.git] / dlls / msi / sql.y
blob43425fa4afcf600110d39c2053799f834694c58b
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.prefix {sql_}
62 %define api.pure
64 %union
66 struct sql_str str;
67 LPWSTR string;
68 column_info *column_list;
69 MSIVIEW *query;
70 struct expr *expr;
71 USHORT column_type;
72 int integer;
75 %token TK_ALTER TK_AND TK_BY TK_CHAR TK_COMMA TK_CREATE TK_DELETE TK_DROP
76 %token TK_DISTINCT TK_DOT TK_EQ TK_FREE TK_FROM TK_GE TK_GT TK_HOLD TK_ADD
77 %token <str> TK_ID
78 %token TK_ILLEGAL TK_INSERT TK_INT
79 %token <str> TK_INTEGER
80 %token TK_INTO TK_IS TK_KEY TK_LE TK_LONG TK_LONGCHAR TK_LP TK_LT
81 %token TK_LOCALIZABLE TK_MINUS TK_NE TK_NOT TK_NULL
82 %token TK_OBJECT TK_OR TK_ORDER TK_PRIMARY TK_RP
83 %token TK_SELECT TK_SET TK_SHORT TK_SPACE TK_STAR
84 %token <str> TK_STRING
85 %token TK_TABLE TK_TEMPORARY TK_UPDATE TK_VALUES TK_WHERE TK_WILDCARD
88 * These are extra tokens used by the lexer but never seen by the
89 * parser. We put them in a rule so that the parser generator will
90 * add them to the parse.h output file.
93 %nonassoc END_OF_FILE ILLEGAL SPACE UNCLOSED_STRING COMMENT FUNCTION
94 COLUMN AGG_FUNCTION.
96 %type <string> table tablelist id string
97 %type <column_list> selcollist collist selcolumn column column_and_type column_def table_def
98 %type <column_list> column_assignment update_assign_list constlist
99 %type <query> query from selectfrom unorderdfrom
100 %type <query> oneupdate onedelete oneselect onequery onecreate oneinsert onealter onedrop
101 %type <expr> expr val column_val const_val
102 %type <column_type> column_type data_type data_type_l data_count
103 %type <integer> number alterop
105 %left TK_OR
106 %left TK_AND
107 %left TK_NOT
108 %left TK_EQ TK_NE TK_LT TK_GT TK_LE TK_GE TK_LIKE
109 %right TK_NEGATION
113 query:
114 onequery
116 SQL_input* sql = (SQL_input*) info;
117 *sql->view = $1;
121 onequery:
122 oneselect
123 | onecreate
124 | oneinsert
125 | oneupdate
126 | onedelete
127 | onealter
128 | onedrop
131 oneinsert:
132 TK_INSERT TK_INTO table TK_LP collist TK_RP TK_VALUES TK_LP constlist TK_RP
134 SQL_input *sql = (SQL_input*) info;
135 MSIVIEW *insert = NULL;
137 INSERT_CreateView( sql->db, &insert, $3, $5, $9, FALSE );
138 if( !insert )
139 YYABORT;
141 PARSER_BUBBLE_UP_VIEW( sql, $$, insert );
143 | TK_INSERT TK_INTO table TK_LP collist TK_RP TK_VALUES TK_LP constlist TK_RP TK_TEMPORARY
145 SQL_input *sql = (SQL_input*) info;
146 MSIVIEW *insert = NULL;
148 INSERT_CreateView( sql->db, &insert, $3, $5, $9, TRUE );
149 if( !insert )
150 YYABORT;
152 PARSER_BUBBLE_UP_VIEW( sql, $$, insert );
156 onecreate:
157 TK_CREATE TK_TABLE table TK_LP table_def TK_RP
159 SQL_input* sql = (SQL_input*) info;
160 MSIVIEW *create = NULL;
161 UINT r;
163 if( !$5 )
164 YYABORT;
165 r = CREATE_CreateView( sql->db, &create, $3, $5, FALSE );
166 if( !create )
168 sql->r = r;
169 YYABORT;
172 PARSER_BUBBLE_UP_VIEW( sql, $$, create );
174 | TK_CREATE TK_TABLE table TK_LP table_def TK_RP TK_HOLD
176 SQL_input* sql = (SQL_input*) info;
177 MSIVIEW *create = NULL;
179 if( !$5 )
180 YYABORT;
181 CREATE_CreateView( sql->db, &create, $3, $5, TRUE );
182 if( !create )
183 YYABORT;
185 PARSER_BUBBLE_UP_VIEW( sql, $$, create );
189 oneupdate:
190 TK_UPDATE table TK_SET update_assign_list TK_WHERE expr
192 SQL_input* sql = (SQL_input*) info;
193 MSIVIEW *update = NULL;
195 UPDATE_CreateView( sql->db, &update, $2, $4, $6 );
196 if( !update )
197 YYABORT;
199 PARSER_BUBBLE_UP_VIEW( sql, $$, update );
201 | TK_UPDATE table TK_SET update_assign_list
203 SQL_input* sql = (SQL_input*) info;
204 MSIVIEW *update = NULL;
206 UPDATE_CreateView( sql->db, &update, $2, $4, NULL );
207 if( !update )
208 YYABORT;
210 PARSER_BUBBLE_UP_VIEW( sql, $$, update );
214 onedelete:
215 TK_DELETE from
217 SQL_input* sql = (SQL_input*) info;
218 MSIVIEW *delete = NULL;
220 DELETE_CreateView( sql->db, &delete, $2 );
221 if( !delete )
222 YYABORT;
224 PARSER_BUBBLE_UP_VIEW( sql, $$, delete );
228 onealter:
229 TK_ALTER TK_TABLE table alterop
231 SQL_input* sql = (SQL_input*) info;
232 MSIVIEW *alter = NULL;
234 ALTER_CreateView( sql->db, &alter, $3, NULL, $4 );
235 if( !alter )
236 YYABORT;
238 PARSER_BUBBLE_UP_VIEW( sql, $$, alter );
240 | TK_ALTER TK_TABLE table TK_ADD column_and_type
242 SQL_input *sql = (SQL_input *)info;
243 MSIVIEW *alter = NULL;
245 ALTER_CreateView( sql->db, &alter, $3, $5, 0 );
246 if (!alter)
247 YYABORT;
249 PARSER_BUBBLE_UP_VIEW( sql, $$, alter );
251 | TK_ALTER TK_TABLE table TK_ADD column_and_type TK_HOLD
253 SQL_input *sql = (SQL_input *)info;
254 MSIVIEW *alter = NULL;
256 ALTER_CreateView( sql->db, &alter, $3, $5, 1 );
257 if (!alter)
258 YYABORT;
260 PARSER_BUBBLE_UP_VIEW( sql, $$, alter );
264 alterop:
265 TK_HOLD
267 $$ = 1;
269 | TK_FREE
271 $$ = -1;
275 onedrop:
276 TK_DROP TK_TABLE table
278 SQL_input* sql = (SQL_input*) info;
279 MSIVIEW* drop = NULL;
280 UINT r;
282 r = DROP_CreateView( sql->db, &drop, $3 );
283 if( r != ERROR_SUCCESS || !$$ )
284 YYABORT;
286 PARSER_BUBBLE_UP_VIEW( sql, $$, drop );
290 table_def:
291 column_def TK_PRIMARY TK_KEY collist
293 if( SQL_MarkPrimaryKeys( &$1, $4 ) )
294 $$ = $1;
295 else
296 $$ = NULL;
300 column_def:
301 column_def TK_COMMA column_and_type
303 column_info *ci;
305 for( ci = $1; ci->next; ci = ci->next )
308 ci->next = $3;
309 $$ = $1;
311 | column_and_type
313 $$ = $1;
317 column_and_type:
318 column column_type
320 $$ = $1;
321 $$->type = ($2 | MSITYPE_VALID);
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 DWORD len = lstrlenW( list ) + lstrlenW( table ) + 2;
745 LPWSTR ret;
747 ret = parser_alloc( info, len * sizeof(WCHAR) );
748 if( ret )
750 lstrcpyW( ret, list );
751 lstrcatW( ret, L" " );
752 lstrcatW( ret, table );
754 return ret;
757 static void *parser_alloc( void *info, unsigned int sz )
759 SQL_input* sql = (SQL_input*) info;
760 struct list *mem;
762 mem = malloc( sizeof (struct list) + sz );
763 list_add_tail( sql->mem, mem );
764 return &mem[1];
767 static column_info *parser_alloc_column( void *info, LPCWSTR table, LPCWSTR column )
769 column_info *col;
771 col = parser_alloc( info, sizeof (*col) );
772 if( col )
774 col->table = table;
775 col->column = column;
776 col->val = NULL;
777 col->type = 0;
778 col->next = NULL;
781 return col;
784 static int sql_lex( void *SQL_lval, SQL_input *sql )
786 int token, skip;
787 struct sql_str * str = SQL_lval;
791 sql->n += sql->len;
792 if( ! sql->command[sql->n] )
793 return 0; /* end of input */
795 /* TRACE("string : %s\n", debugstr_w(&sql->command[sql->n])); */
796 sql->len = sqliteGetToken( &sql->command[sql->n], &token, &skip );
797 if( sql->len==0 )
798 break;
799 str->data = &sql->command[sql->n];
800 str->len = sql->len;
801 sql->n += skip;
803 while( token == TK_SPACE );
805 /* TRACE("token : %d (%s)\n", token, debugstr_wn(&sql->command[sql->n], sql->len)); */
807 return token;
810 UINT SQL_getstring( void *info, const struct sql_str *strdata, LPWSTR *str )
812 LPCWSTR p = strdata->data;
813 UINT len = strdata->len;
815 /* match quotes */
816 if( ( (p[0]=='`') && (p[len-1]!='`') ) ||
817 ( (p[0]=='\'') && (p[len-1]!='\'') ) )
818 return ERROR_FUNCTION_FAILED;
820 /* if there are quotes, remove them */
821 if( ( (p[0]=='`') && (p[len-1]=='`') ) ||
822 ( (p[0]=='\'') && (p[len-1]=='\'') ) )
824 p++;
825 len -= 2;
827 *str = parser_alloc( info, (len + 1)*sizeof(WCHAR) );
828 if( !*str )
829 return ERROR_OUTOFMEMORY;
830 memcpy( *str, p, len*sizeof(WCHAR) );
831 (*str)[len]=0;
833 return ERROR_SUCCESS;
836 INT SQL_getint( void *info )
838 SQL_input* sql = (SQL_input*) info;
839 LPCWSTR p = &sql->command[sql->n];
840 INT i, r = 0;
842 for( i=0; i<sql->len; i++ )
844 if( '0' > p[i] || '9' < p[i] )
846 ERR("should only be numbers here!\n");
847 break;
849 r = (p[i]-'0') + r*10;
852 return r;
855 static int sql_error( SQL_input *info, const char *str )
857 return 0;
860 static struct expr * EXPR_wildcard( void *info )
862 struct expr *e = parser_alloc( info, sizeof *e );
863 if( e )
865 e->type = EXPR_WILDCARD;
867 return e;
870 static struct expr * EXPR_complex( void *info, struct expr *l, UINT op, struct expr *r )
872 struct expr *e = parser_alloc( info, sizeof *e );
873 if( e )
875 e->type = EXPR_COMPLEX;
876 e->u.expr.left = l;
877 e->u.expr.op = op;
878 e->u.expr.right = r;
880 return e;
883 static struct expr * EXPR_unary( void *info, struct expr *l, UINT op )
885 struct expr *e = parser_alloc( info, sizeof *e );
886 if( e )
888 e->type = EXPR_UNARY;
889 e->u.expr.left = l;
890 e->u.expr.op = op;
891 e->u.expr.right = NULL;
893 return e;
896 static struct expr * EXPR_column( void *info, const column_info *column )
898 struct expr *e = parser_alloc( info, sizeof *e );
899 if( e )
901 e->type = EXPR_COLUMN;
902 e->u.column.unparsed.column = column->column;
903 e->u.column.unparsed.table = column->table;
905 return e;
908 static struct expr * EXPR_ival( void *info, int val )
910 struct expr *e = parser_alloc( info, sizeof *e );
911 if( e )
913 e->type = EXPR_IVAL;
914 e->u.ival = val;
916 return e;
919 static struct expr * EXPR_sval( void *info, const struct sql_str *str )
921 struct expr *e = parser_alloc( info, sizeof *e );
922 if( e )
924 e->type = EXPR_SVAL;
925 if( !str) e->u.sval = NULL;
926 else if( SQL_getstring( info, str, (LPWSTR *)&e->u.sval ) != ERROR_SUCCESS )
927 return NULL; /* e will be freed by query destructor */
929 return e;
932 static void swap_columns( column_info **cols, column_info *A, int idx )
934 column_info *preA = NULL, *preB = NULL, *B, *ptr;
935 int i = 0;
937 B = NULL;
938 ptr = *cols;
939 while( ptr )
941 if( i++ == idx )
942 B = ptr;
943 else if( !B )
944 preB = ptr;
946 if( ptr->next == A )
947 preA = ptr;
949 ptr = ptr->next;
952 if( preB ) preB->next = A;
953 if( preA ) preA->next = B;
954 ptr = A->next;
955 A->next = B->next;
956 B->next = ptr;
957 if( idx == 0 )
958 *cols = A;
961 static BOOL SQL_MarkPrimaryKeys( column_info **cols,
962 column_info *keys )
964 column_info *k;
965 BOOL found = TRUE;
966 int count;
968 for( k = keys, count = 0; k && found; k = k->next, count++ )
970 column_info *c;
971 int idx;
973 found = FALSE;
974 for( c = *cols, idx = 0; c && !found; c = c->next, idx++ )
976 if( wcscmp( k->column, c->column ) )
977 continue;
978 c->type |= MSITYPE_KEY;
979 found = TRUE;
980 if (idx != count)
981 swap_columns( cols, c, count );
985 return found;
988 UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview,
989 struct list *mem )
991 SQL_input sql;
992 int r;
994 *phview = NULL;
996 sql.db = db;
997 sql.command = command;
998 sql.n = 0;
999 sql.len = 0;
1000 sql.r = ERROR_BAD_QUERY_SYNTAX;
1001 sql.view = phview;
1002 sql.mem = mem;
1004 r = sql_parse(&sql);
1006 TRACE("Parse returned %d\n", r);
1007 if( r )
1009 if (*sql.view)
1011 (*sql.view)->ops->delete(*sql.view);
1012 *sql.view = NULL;
1014 return sql.r;
1017 return ERROR_SUCCESS;