gdi32: Always use biClrUsed for the number of colors of internal BITMAPINFO structures.
[wine/multimedia.git] / dlls / msi / sql.y
blob8de696d3ae823c722a08b7cf1ba21cc3fbf0d78b
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 #define YYLEX_PARAM info
38 #define YYPARSE_PARAM info
40 static int sql_error(const char *str);
42 WINE_DEFAULT_DEBUG_CHANNEL(msi);
44 typedef struct tag_SQL_input
46 MSIDATABASE *db;
47 LPCWSTR command;
48 DWORD n, len;
49 UINT r;
50 MSIVIEW **view; /* View structure for the resulting query. This value
51 * tracks the view currently being created so we can free
52 * this view on syntax error.
54 struct list *mem;
55 } SQL_input;
57 static UINT SQL_getstring( void *info, const struct sql_str *strdata, LPWSTR *str );
58 static INT SQL_getint( void *info );
59 static int sql_lex( void *SQL_lval, SQL_input *info );
61 static LPWSTR parser_add_table( void *info, LPCWSTR list, LPCWSTR table );
62 static void *parser_alloc( void *info, unsigned int sz );
63 static column_info *parser_alloc_column( void *info, LPCWSTR table, LPCWSTR column );
65 static BOOL SQL_MarkPrimaryKeys( column_info **cols, column_info *keys);
67 static struct expr * EXPR_complex( void *info, struct expr *l, UINT op, struct expr *r );
68 static struct expr * EXPR_unary( void *info, struct expr *l, UINT op );
69 static struct expr * EXPR_column( void *info, const column_info *column );
70 static struct expr * EXPR_ival( void *info, int val );
71 static struct expr * EXPR_sval( void *info, const struct sql_str *str );
72 static struct expr * EXPR_wildcard( void *info );
74 #define PARSER_BUBBLE_UP_VIEW( sql, result, current_view ) \
75 *sql->view = current_view; \
76 result = current_view
80 %pure-parser
82 %union
84 struct sql_str str;
85 LPWSTR string;
86 column_info *column_list;
87 MSIVIEW *query;
88 struct expr *expr;
89 USHORT column_type;
90 int integer;
93 %token TK_ALTER TK_AND TK_BY TK_CHAR TK_COMMA TK_CREATE TK_DELETE TK_DROP
94 %token TK_DISTINCT TK_DOT TK_EQ TK_FREE TK_FROM TK_GE TK_GT TK_HOLD TK_ADD
95 %token <str> TK_ID
96 %token TK_ILLEGAL TK_INSERT TK_INT
97 %token <str> TK_INTEGER
98 %token TK_INTO TK_IS TK_KEY TK_LE TK_LONG TK_LONGCHAR TK_LP TK_LT
99 %token TK_LOCALIZABLE TK_MINUS TK_NE TK_NOT TK_NULL
100 %token TK_OBJECT TK_OR TK_ORDER TK_PRIMARY TK_RP
101 %token TK_SELECT TK_SET TK_SHORT TK_SPACE TK_STAR
102 %token <str> TK_STRING
103 %token TK_TABLE TK_TEMPORARY TK_UPDATE TK_VALUES TK_WHERE TK_WILDCARD
106 * These are extra tokens used by the lexer but never seen by the
107 * parser. We put them in a rule so that the parser generator will
108 * add them to the parse.h output file.
111 %nonassoc END_OF_FILE ILLEGAL SPACE UNCLOSED_STRING COMMENT FUNCTION
112 COLUMN AGG_FUNCTION.
114 %type <string> table tablelist id
115 %type <column_list> selcollist column column_and_type column_def table_def
116 %type <column_list> column_assignment update_assign_list constlist
117 %type <query> query from selectfrom unorderdfrom
118 %type <query> oneupdate onedelete oneselect onequery onecreate oneinsert onealter onedrop
119 %type <expr> expr val column_val const_val
120 %type <column_type> column_type data_type data_type_l data_count
121 %type <integer> number alterop
123 /* Reference: http://mates.ms.mff.cuni.cz/oracle/doc/ora815nt/server.815/a67779/operator.htm */
124 %left TK_OR
125 %left TK_AND
126 %left TK_NOT
127 %left TK_EQ TK_NE TK_LT TK_GT TK_LE TK_GE TK_LIKE
128 %right TK_NEGATION
132 query:
133 onequery
135 SQL_input* sql = (SQL_input*) info;
136 *sql->view = $1;
140 onequery:
141 oneselect
142 | onecreate
143 | oneinsert
144 | oneupdate
145 | onedelete
146 | onealter
147 | onedrop
150 oneinsert:
151 TK_INSERT TK_INTO table TK_LP selcollist TK_RP TK_VALUES TK_LP constlist TK_RP
153 SQL_input *sql = (SQL_input*) info;
154 MSIVIEW *insert = NULL;
156 INSERT_CreateView( sql->db, &insert, $3, $5, $9, FALSE );
157 if( !insert )
158 YYABORT;
160 PARSER_BUBBLE_UP_VIEW( sql, $$, insert );
162 | TK_INSERT TK_INTO table TK_LP selcollist TK_RP TK_VALUES TK_LP constlist TK_RP TK_TEMPORARY
164 SQL_input *sql = (SQL_input*) info;
165 MSIVIEW *insert = NULL;
167 INSERT_CreateView( sql->db, &insert, $3, $5, $9, TRUE );
168 if( !insert )
169 YYABORT;
171 PARSER_BUBBLE_UP_VIEW( sql, $$, insert );
175 onecreate:
176 TK_CREATE TK_TABLE table TK_LP table_def TK_RP
178 SQL_input* sql = (SQL_input*) info;
179 MSIVIEW *create = NULL;
180 UINT r;
182 if( !$5 )
183 YYABORT;
184 r = CREATE_CreateView( sql->db, &create, $3, $5, FALSE );
185 if( !create )
187 sql->r = r;
188 YYABORT;
191 PARSER_BUBBLE_UP_VIEW( sql, $$, create );
193 | TK_CREATE TK_TABLE table TK_LP table_def TK_RP TK_HOLD
195 SQL_input* sql = (SQL_input*) info;
196 MSIVIEW *create = NULL;
198 if( !$5 )
199 YYABORT;
200 CREATE_CreateView( sql->db, &create, $3, $5, TRUE );
201 if( !create )
202 YYABORT;
204 PARSER_BUBBLE_UP_VIEW( sql, $$, create );
208 oneupdate:
209 TK_UPDATE table TK_SET update_assign_list TK_WHERE expr
211 SQL_input* sql = (SQL_input*) info;
212 MSIVIEW *update = NULL;
214 UPDATE_CreateView( sql->db, &update, $2, $4, $6 );
215 if( !update )
216 YYABORT;
218 PARSER_BUBBLE_UP_VIEW( sql, $$, update );
220 | TK_UPDATE table TK_SET update_assign_list
222 SQL_input* sql = (SQL_input*) info;
223 MSIVIEW *update = NULL;
225 UPDATE_CreateView( sql->db, &update, $2, $4, NULL );
226 if( !update )
227 YYABORT;
229 PARSER_BUBBLE_UP_VIEW( sql, $$, update );
233 onedelete:
234 TK_DELETE from
236 SQL_input* sql = (SQL_input*) info;
237 MSIVIEW *delete = NULL;
239 DELETE_CreateView( sql->db, &delete, $2 );
240 if( !delete )
241 YYABORT;
243 PARSER_BUBBLE_UP_VIEW( sql, $$, delete );
247 onealter:
248 TK_ALTER TK_TABLE table alterop
250 SQL_input* sql = (SQL_input*) info;
251 MSIVIEW *alter = NULL;
253 ALTER_CreateView( sql->db, &alter, $3, NULL, $4 );
254 if( !alter )
255 YYABORT;
257 PARSER_BUBBLE_UP_VIEW( sql, $$, alter );
259 | TK_ALTER TK_TABLE table TK_ADD column_and_type
261 SQL_input *sql = (SQL_input *)info;
262 MSIVIEW *alter = NULL;
264 ALTER_CreateView( sql->db, &alter, $3, $5, 0 );
265 if (!alter)
266 YYABORT;
268 PARSER_BUBBLE_UP_VIEW( sql, $$, alter );
270 | TK_ALTER TK_TABLE table TK_ADD column_and_type TK_HOLD
272 SQL_input *sql = (SQL_input *)info;
273 MSIVIEW *alter = NULL;
275 ALTER_CreateView( sql->db, &alter, $3, $5, 1 );
276 if (!alter)
277 YYABORT;
279 PARSER_BUBBLE_UP_VIEW( sql, $$, alter );
283 alterop:
284 TK_HOLD
286 $$ = 1;
288 | TK_FREE
290 $$ = -1;
294 onedrop:
295 TK_DROP TK_TABLE table
297 SQL_input* sql = (SQL_input*) info;
298 MSIVIEW* drop = NULL;
299 UINT r;
301 r = DROP_CreateView( sql->db, &drop, $3 );
302 if( r != ERROR_SUCCESS || !$$ )
303 YYABORT;
305 PARSER_BUBBLE_UP_VIEW( sql, $$, drop );
309 table_def:
310 column_def TK_PRIMARY TK_KEY selcollist
312 if( SQL_MarkPrimaryKeys( &$1, $4 ) )
313 $$ = $1;
314 else
315 $$ = NULL;
319 column_def:
320 column_def TK_COMMA column_and_type
322 column_info *ci;
324 for( ci = $1; ci->next; ci = ci->next )
327 ci->next = $3;
328 $$ = $1;
330 | column_and_type
332 $$ = $1;
336 column_and_type:
337 column column_type
339 $$ = $1;
340 $$->type = ($2 | MSITYPE_VALID);
341 $$->temporary = $2 & MSITYPE_TEMPORARY ? TRUE : FALSE;
345 column_type:
346 data_type_l
348 $$ = $1;
350 | data_type_l TK_LOCALIZABLE
352 $$ = $1 | MSITYPE_LOCALIZABLE;
354 | data_type_l TK_TEMPORARY
356 $$ = $1 | MSITYPE_TEMPORARY;
360 data_type_l:
361 data_type
363 $$ |= MSITYPE_NULLABLE;
365 | data_type TK_NOT TK_NULL
367 $$ = $1;
371 data_type:
372 TK_CHAR
374 $$ = MSITYPE_STRING | 1;
376 | TK_CHAR TK_LP data_count TK_RP
378 $$ = MSITYPE_STRING | 0x400 | $3;
380 | TK_LONGCHAR
382 $$ = MSITYPE_STRING | 0x400;
384 | TK_SHORT
386 $$ = 2 | 0x400;
388 | TK_INT
390 $$ = 2 | 0x400;
392 | TK_LONG
394 $$ = 4;
396 | TK_OBJECT
398 $$ = MSITYPE_STRING | MSITYPE_VALID;
402 data_count:
403 number
405 if( ( $1 > 255 ) || ( $1 < 0 ) )
406 YYABORT;
407 $$ = $1;
411 oneselect:
412 TK_SELECT selectfrom
414 $$ = $2;
416 | TK_SELECT TK_DISTINCT selectfrom
418 SQL_input* sql = (SQL_input*) info;
419 MSIVIEW* distinct = NULL;
420 UINT r;
422 r = DISTINCT_CreateView( sql->db, &distinct, $3 );
423 if (r != ERROR_SUCCESS)
424 YYABORT;
426 PARSER_BUBBLE_UP_VIEW( sql, $$, distinct );
430 selectfrom:
431 selcollist from
433 SQL_input* sql = (SQL_input*) info;
434 MSIVIEW* select = NULL;
435 UINT r;
437 if( $1 )
439 r = SELECT_CreateView( sql->db, &select, $2, $1 );
440 if (r != ERROR_SUCCESS)
441 YYABORT;
443 PARSER_BUBBLE_UP_VIEW( sql, $$, select );
445 else
446 $$ = $2;
450 selcollist:
451 column
452 | column TK_COMMA selcollist
454 $1->next = $3;
456 | TK_STAR
458 $$ = NULL;
462 from:
463 TK_FROM table
465 SQL_input* sql = (SQL_input*) info;
466 MSIVIEW* table = NULL;
467 UINT r;
469 r = TABLE_CreateView( sql->db, $2, &table );
470 if( r != ERROR_SUCCESS || !$$ )
471 YYABORT;
473 PARSER_BUBBLE_UP_VIEW( sql, $$, table );
475 | unorderdfrom TK_ORDER TK_BY selcollist
477 UINT r;
479 if( $4 )
481 r = $1->ops->sort( $1, $4 );
482 if ( r != ERROR_SUCCESS)
483 YYABORT;
486 $$ = $1;
488 | unorderdfrom
491 unorderdfrom:
492 TK_FROM tablelist
494 SQL_input* sql = (SQL_input*) info;
495 MSIVIEW* where = NULL;
496 UINT r;
498 r = WHERE_CreateView( sql->db, &where, $2, NULL );
499 if( r != ERROR_SUCCESS )
500 YYABORT;
502 PARSER_BUBBLE_UP_VIEW( sql, $$, where );
504 | TK_FROM tablelist TK_WHERE expr
506 SQL_input* sql = (SQL_input*) info;
507 MSIVIEW* where = NULL;
508 UINT r;
510 r = WHERE_CreateView( sql->db, &where, $2, $4 );
511 if( r != ERROR_SUCCESS )
512 YYABORT;
514 PARSER_BUBBLE_UP_VIEW( sql, $$, where );
518 tablelist:
519 table
521 $$ = $1;
524 table TK_COMMA tablelist
526 $$ = parser_add_table( info, $3, $1 );
527 if (!$$)
528 YYABORT;
532 expr:
533 TK_LP expr TK_RP
535 $$ = $2;
536 if( !$$ )
537 YYABORT;
539 | expr TK_AND expr
541 $$ = EXPR_complex( info, $1, OP_AND, $3 );
542 if( !$$ )
543 YYABORT;
545 | expr TK_OR expr
547 $$ = EXPR_complex( info, $1, OP_OR, $3 );
548 if( !$$ )
549 YYABORT;
551 | column_val TK_EQ val
553 $$ = EXPR_complex( info, $1, OP_EQ, $3 );
554 if( !$$ )
555 YYABORT;
557 | column_val TK_GT val
559 $$ = EXPR_complex( info, $1, OP_GT, $3 );
560 if( !$$ )
561 YYABORT;
563 | column_val TK_LT val
565 $$ = EXPR_complex( info, $1, OP_LT, $3 );
566 if( !$$ )
567 YYABORT;
569 | column_val TK_LE val
571 $$ = EXPR_complex( info, $1, OP_LE, $3 );
572 if( !$$ )
573 YYABORT;
575 | column_val TK_GE val
577 $$ = EXPR_complex( info, $1, OP_GE, $3 );
578 if( !$$ )
579 YYABORT;
581 | column_val TK_NE val
583 $$ = EXPR_complex( info, $1, OP_NE, $3 );
584 if( !$$ )
585 YYABORT;
587 | column_val TK_IS TK_NULL
589 $$ = EXPR_unary( info, $1, OP_ISNULL );
590 if( !$$ )
591 YYABORT;
593 | column_val TK_IS TK_NOT TK_NULL
595 $$ = EXPR_unary( info, $1, OP_NOTNULL );
596 if( !$$ )
597 YYABORT;
601 val:
602 column_val
603 | const_val
606 constlist:
607 const_val
609 $$ = parser_alloc_column( info, NULL, NULL );
610 if( !$$ )
611 YYABORT;
612 $$->val = $1;
614 | const_val TK_COMMA constlist
616 $$ = parser_alloc_column( info, NULL, NULL );
617 if( !$$ )
618 YYABORT;
619 $$->val = $1;
620 $$->next = $3;
624 update_assign_list:
625 column_assignment
626 | column_assignment TK_COMMA update_assign_list
628 $$ = $1;
629 $$->next = $3;
633 column_assignment:
634 column TK_EQ const_val
636 $$ = $1;
637 $$->val = $3;
641 const_val:
642 number
644 $$ = EXPR_ival( info, $1 );
645 if( !$$ )
646 YYABORT;
648 | TK_MINUS number %prec TK_NEGATION
650 $$ = EXPR_ival( info, -$2 );
651 if( !$$ )
652 YYABORT;
654 | TK_STRING
656 $$ = EXPR_sval( info, &$1 );
657 if( !$$ )
658 YYABORT;
660 | TK_WILDCARD
662 $$ = EXPR_wildcard( info );
663 if( !$$ )
664 YYABORT;
668 column_val:
669 column
671 $$ = EXPR_column( info, $1 );
672 if( !$$ )
673 YYABORT;
677 column:
678 table TK_DOT id
680 $$ = parser_alloc_column( info, $1, $3 );
681 if( !$$ )
682 YYABORT;
684 | id
686 $$ = parser_alloc_column( info, NULL, $1 );
687 if( !$$ )
688 YYABORT;
692 table:
695 $$ = $1;
700 TK_ID
702 if ( SQL_getstring( info, &$1, &$$ ) != ERROR_SUCCESS || !$$ )
703 YYABORT;
707 number:
708 TK_INTEGER
710 $$ = SQL_getint( info );
716 static LPWSTR parser_add_table( void *info, LPCWSTR list, LPCWSTR table )
718 static const WCHAR space[] = {' ',0};
719 DWORD len = strlenW( list ) + strlenW( table ) + 2;
720 LPWSTR ret;
722 ret = parser_alloc( info, len * sizeof(WCHAR) );
723 if( ret )
725 strcpyW( ret, list );
726 strcatW( ret, space );
727 strcatW( ret, table );
729 return ret;
732 static void *parser_alloc( void *info, unsigned int sz )
734 SQL_input* sql = (SQL_input*) info;
735 struct list *mem;
737 mem = msi_alloc( sizeof (struct list) + sz );
738 list_add_tail( sql->mem, mem );
739 return &mem[1];
742 static column_info *parser_alloc_column( void *info, LPCWSTR table, LPCWSTR column )
744 column_info *col;
746 col = parser_alloc( info, sizeof (*col) );
747 if( col )
749 col->table = table;
750 col->column = column;
751 col->val = NULL;
752 col->type = 0;
753 col->next = NULL;
756 return col;
759 static int sql_lex( void *SQL_lval, SQL_input *sql )
761 int token;
762 struct sql_str * str = SQL_lval;
766 sql->n += sql->len;
767 if( ! sql->command[sql->n] )
768 return 0; /* end of input */
770 /* TRACE("string : %s\n", debugstr_w(&sql->command[sql->n])); */
771 sql->len = sqliteGetToken( &sql->command[sql->n], &token );
772 if( sql->len==0 )
773 break;
774 str->data = &sql->command[sql->n];
775 str->len = sql->len;
777 while( token == TK_SPACE );
779 /* TRACE("token : %d (%s)\n", token, debugstr_wn(&sql->command[sql->n], sql->len)); */
781 return token;
784 UINT SQL_getstring( void *info, const struct sql_str *strdata, LPWSTR *str )
786 LPCWSTR p = strdata->data;
787 UINT len = strdata->len;
789 /* match quotes */
790 if( ( (p[0]=='`') && (p[len-1]!='`') ) ||
791 ( (p[0]=='\'') && (p[len-1]!='\'') ) )
792 return ERROR_FUNCTION_FAILED;
794 /* if there's quotes, remove them */
795 if( ( (p[0]=='`') && (p[len-1]=='`') ) ||
796 ( (p[0]=='\'') && (p[len-1]=='\'') ) )
798 p++;
799 len -= 2;
801 *str = parser_alloc( info, (len + 1)*sizeof(WCHAR) );
802 if( !*str )
803 return ERROR_OUTOFMEMORY;
804 memcpy( *str, p, len*sizeof(WCHAR) );
805 (*str)[len]=0;
807 return ERROR_SUCCESS;
810 INT SQL_getint( void *info )
812 SQL_input* sql = (SQL_input*) info;
813 LPCWSTR p = &sql->command[sql->n];
814 INT i, r = 0;
816 for( i=0; i<sql->len; i++ )
818 if( '0' > p[i] || '9' < p[i] )
820 ERR("should only be numbers here!\n");
821 break;
823 r = (p[i]-'0') + r*10;
826 return r;
829 static int sql_error( const char *str )
831 return 0;
834 static struct expr * EXPR_wildcard( void *info )
836 struct expr *e = parser_alloc( info, sizeof *e );
837 if( e )
839 e->type = EXPR_WILDCARD;
841 return e;
844 static struct expr * EXPR_complex( void *info, struct expr *l, UINT op, struct expr *r )
846 struct expr *e = parser_alloc( info, sizeof *e );
847 if( e )
849 e->type = EXPR_COMPLEX;
850 e->u.expr.left = l;
851 e->u.expr.op = op;
852 e->u.expr.right = r;
854 return e;
857 static struct expr * EXPR_unary( void *info, struct expr *l, UINT op )
859 struct expr *e = parser_alloc( info, sizeof *e );
860 if( e )
862 e->type = EXPR_UNARY;
863 e->u.expr.left = l;
864 e->u.expr.op = op;
865 e->u.expr.right = NULL;
867 return e;
870 static struct expr * EXPR_column( void *info, const column_info *column )
872 struct expr *e = parser_alloc( info, sizeof *e );
873 if( e )
875 e->type = EXPR_COLUMN;
876 e->u.column.unparsed.column = column->column;
877 e->u.column.unparsed.table = column->table;
879 return e;
882 static struct expr * EXPR_ival( void *info, int val )
884 struct expr *e = parser_alloc( info, sizeof *e );
885 if( e )
887 e->type = EXPR_IVAL;
888 e->u.ival = val;
890 return e;
893 static struct expr * EXPR_sval( void *info, const struct sql_str *str )
895 struct expr *e = parser_alloc( info, sizeof *e );
896 if( e )
898 e->type = EXPR_SVAL;
899 if( SQL_getstring( info, str, (LPWSTR *)&e->u.sval ) != ERROR_SUCCESS )
900 return NULL; /* e will be freed by query destructor */
902 return e;
905 static void swap_columns( column_info **cols, column_info *A, int idx )
907 column_info *preA = NULL, *preB = NULL, *B, *ptr;
908 int i = 0;
910 B = NULL;
911 ptr = *cols;
912 while( ptr )
914 if( i++ == idx )
915 B = ptr;
916 else if( !B )
917 preB = ptr;
919 if( ptr->next == A )
920 preA = ptr;
922 ptr = ptr->next;
925 if( preB ) preB->next = A;
926 if( preA ) preA->next = B;
927 ptr = A->next;
928 A->next = B->next;
929 B->next = ptr;
930 if( idx == 0 )
931 *cols = A;
934 static BOOL SQL_MarkPrimaryKeys( column_info **cols,
935 column_info *keys )
937 column_info *k;
938 BOOL found = TRUE;
939 int count;
941 for( k = keys, count = 0; k && found; k = k->next, count++ )
943 column_info *c;
944 int idx;
946 found = FALSE;
947 for( c = *cols, idx = 0; c && !found; c = c->next, idx++ )
949 if( strcmpW( k->column, c->column ) )
950 continue;
951 c->type |= MSITYPE_KEY;
952 found = TRUE;
953 if (idx != count)
954 swap_columns( cols, c, count );
958 return found;
961 UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview,
962 struct list *mem )
964 SQL_input sql;
965 int r;
967 *phview = NULL;
969 sql.db = db;
970 sql.command = command;
971 sql.n = 0;
972 sql.len = 0;
973 sql.r = ERROR_BAD_QUERY_SYNTAX;
974 sql.view = phview;
975 sql.mem = mem;
977 r = sql_parse(&sql);
979 TRACE("Parse returned %d\n", r);
980 if( r )
982 if (*sql.view)
984 (*sql.view)->ops->delete(*sql.view);
985 *sql.view = NULL;
987 return sql.r;
990 return ERROR_SUCCESS;