Commit f015b825 authored by osku's avatar osku

Add support for UNSIGNED types in InnoDB's SQL parser.

Remove trailing whitespace from flex/bison input files.
parent 92436940
...@@ -114,7 +114,8 @@ ...@@ -114,7 +114,8 @@
PARS_COMMIT_TOKEN = 340, PARS_COMMIT_TOKEN = 340,
PARS_ROLLBACK_TOKEN = 341, PARS_ROLLBACK_TOKEN = 341,
PARS_WORK_TOKEN = 342, PARS_WORK_TOKEN = 342,
NEG = 343 PARS_UNSIGNED_TOKEN = 343,
NEG = 344
}; };
#endif #endif
#define PARS_INT_LIT 258 #define PARS_INT_LIT 258
...@@ -202,7 +203,8 @@ ...@@ -202,7 +203,8 @@
#define PARS_COMMIT_TOKEN 340 #define PARS_COMMIT_TOKEN 340
#define PARS_ROLLBACK_TOKEN 341 #define PARS_ROLLBACK_TOKEN 341
#define PARS_WORK_TOKEN 342 #define PARS_WORK_TOKEN 342
#define NEG 343 #define PARS_UNSIGNED_TOKEN 343
#define NEG 344
......
...@@ -345,6 +345,8 @@ pars_column_def( ...@@ -345,6 +345,8 @@ pars_column_def(
pars_res_word_t* type, /* in: data type */ pars_res_word_t* type, /* in: data type */
sym_node_t* len, /* in: length of column, or sym_node_t* len, /* in: length of column, or
NULL */ NULL */
void* is_unsigned, /* in: if not NULL, column
is of type UNSIGNED. */
void* is_not_null); /* in: if not NULL, column void* is_not_null); /* in: if not NULL, column
is of type NOT NULL. */ is of type NOT NULL. */
/************************************************************************* /*************************************************************************
......
This diff is collapsed.
This diff is collapsed.
...@@ -114,7 +114,8 @@ ...@@ -114,7 +114,8 @@
PARS_COMMIT_TOKEN = 340, PARS_COMMIT_TOKEN = 340,
PARS_ROLLBACK_TOKEN = 341, PARS_ROLLBACK_TOKEN = 341,
PARS_WORK_TOKEN = 342, PARS_WORK_TOKEN = 342,
NEG = 343 PARS_UNSIGNED_TOKEN = 343,
NEG = 344
}; };
#endif #endif
#define PARS_INT_LIT 258 #define PARS_INT_LIT 258
...@@ -202,7 +203,8 @@ ...@@ -202,7 +203,8 @@
#define PARS_COMMIT_TOKEN 340 #define PARS_COMMIT_TOKEN 340
#define PARS_ROLLBACK_TOKEN 341 #define PARS_ROLLBACK_TOKEN 341
#define PARS_WORK_TOKEN 342 #define PARS_WORK_TOKEN 342
#define NEG 343 #define PARS_UNSIGNED_TOKEN 343
#define NEG 344
......
...@@ -29,7 +29,7 @@ que_node_t */ ...@@ -29,7 +29,7 @@ que_node_t */
int int
yylex(void); yylex(void);
%} %}
%token PARS_INT_LIT %token PARS_INT_LIT
%token PARS_FLOAT_LIT %token PARS_FLOAT_LIT
%token PARS_STR_LIT %token PARS_STR_LIT
...@@ -115,6 +115,7 @@ yylex(void); ...@@ -115,6 +115,7 @@ yylex(void);
%token PARS_COMMIT_TOKEN %token PARS_COMMIT_TOKEN
%token PARS_ROLLBACK_TOKEN %token PARS_ROLLBACK_TOKEN
%token PARS_WORK_TOKEN %token PARS_WORK_TOKEN
%token PARS_UNSIGNED_TOKEN
%left PARS_AND_TOKEN PARS_OR_TOKEN %left PARS_AND_TOKEN PARS_OR_TOKEN
%left PARS_NOT_TOKEN %left PARS_NOT_TOKEN
...@@ -262,14 +263,14 @@ select_item: ...@@ -262,14 +263,14 @@ select_item:
que_node_list_add_last(NULL, que_node_list_add_last(NULL,
$3)); } $3)); }
; ;
select_item_list: select_item_list:
/* Nothing */ { $$ = NULL; } /* Nothing */ { $$ = NULL; }
| select_item { $$ = que_node_list_add_last(NULL, $1); } | select_item { $$ = que_node_list_add_last(NULL, $1); }
| select_item_list ',' select_item | select_item_list ',' select_item
{ $$ = que_node_list_add_last($1, $3); } { $$ = que_node_list_add_last($1, $3); }
; ;
select_list: select_list:
'*' { $$ = pars_select_list(&pars_star_denoter, '*' { $$ = pars_select_list(&pars_star_denoter,
NULL); } NULL); }
...@@ -377,7 +378,7 @@ delete_statement_positioned: ...@@ -377,7 +378,7 @@ delete_statement_positioned:
delete_statement_start delete_statement_start
cursor_positioned { $$ = pars_update_statement($1, $2, NULL); } cursor_positioned { $$ = pars_update_statement($1, $2, NULL); }
; ;
row_printf_statement: row_printf_statement:
PARS_ROW_PRINTF_TOKEN select_statement PARS_ROW_PRINTF_TOKEN select_statement
{ $$ = pars_row_printf_statement($2); } { $$ = pars_row_printf_statement($2); }
...@@ -450,8 +451,8 @@ fetch_statement: ...@@ -450,8 +451,8 @@ fetch_statement:
; ;
column_def: column_def:
PARS_ID_TOKEN type_name opt_column_len opt_not_null PARS_ID_TOKEN type_name opt_column_len opt_unsigned opt_not_null
{ $$ = pars_column_def($1, $2, $3, $4); } { $$ = pars_column_def($1, $2, $3, $4, $5); }
; ;
column_def_list: column_def_list:
...@@ -466,6 +467,13 @@ opt_column_len: ...@@ -466,6 +467,13 @@ opt_column_len:
{ $$ = $2; } { $$ = $2; }
; ;
opt_unsigned:
/* Nothing */ { $$ = NULL; }
| PARS_UNSIGNED_TOKEN
{ $$ = &pars_int_token;
/* pass any non-NULL pointer */ }
;
opt_not_null: opt_not_null:
/* Nothing */ { $$ = NULL; } /* Nothing */ { $$ = NULL; }
| PARS_NOT_TOKEN PARS_NULL_LIT | PARS_NOT_TOKEN PARS_NULL_LIT
...@@ -479,7 +487,7 @@ not_fit_in_memory: ...@@ -479,7 +487,7 @@ not_fit_in_memory:
{ $$ = &pars_int_token; { $$ = &pars_int_token;
/* pass any non-NULL pointer */ } /* pass any non-NULL pointer */ }
; ;
create_table: create_table:
PARS_CREATE_TOKEN PARS_TABLE_TOKEN PARS_CREATE_TOKEN PARS_TABLE_TOKEN
PARS_ID_TOKEN '(' column_def_list ')' PARS_ID_TOKEN '(' column_def_list ')'
...@@ -550,8 +558,8 @@ variable_declaration: ...@@ -550,8 +558,8 @@ variable_declaration:
; ;
variable_declaration_list: variable_declaration_list:
/* Nothing */ /* Nothing */
| variable_declaration | variable_declaration
| variable_declaration_list variable_declaration | variable_declaration_list variable_declaration
; ;
...@@ -577,5 +585,5 @@ procedure_definition: ...@@ -577,5 +585,5 @@ procedure_definition:
PARS_END_TOKEN { $$ = pars_procedure_definition($2, $4, PARS_END_TOKEN { $$ = pars_procedure_definition($2, $4,
$10); } $10); }
; ;
%% %%
...@@ -96,7 +96,7 @@ string_append( ...@@ -96,7 +96,7 @@ string_append(
} }
%} %}
DIGIT [0-9] DIGIT [0-9]
ID [a-z_A-Z][a-z_A-Z0-9]* ID [a-z_A-Z][a-z_A-Z0-9]*
%x comment %x comment
...@@ -462,6 +462,10 @@ In the state 'quoted', only two actions are possible (defined below). */ ...@@ -462,6 +462,10 @@ In the state 'quoted', only two actions are possible (defined below). */
return(PARS_WORK_TOKEN); return(PARS_WORK_TOKEN);
} }
"UNSIGNED" {
return(PARS_UNSIGNED_TOKEN);
}
{ID} { {ID} {
yylval = sym_tab_add_id(pars_sym_tab_global, yylval = sym_tab_add_id(pars_sym_tab_global,
(byte*)yytext, (byte*)yytext,
......
...@@ -1085,6 +1085,8 @@ pars_set_dfield_type( ...@@ -1085,6 +1085,8 @@ pars_set_dfield_type(
pars_res_word_t* type, /* in: pointer to a type pars_res_word_t* type, /* in: pointer to a type
token */ token */
ulint len, /* in: length, or 0 */ ulint len, /* in: length, or 0 */
ibool is_unsigned, /* in: if TRUE, column is
UNSIGNED. */
ibool is_not_null) /* in: if TRUE, column is ibool is_not_null) /* in: if TRUE, column is
NOT NULL. */ NOT NULL. */
{ {
...@@ -1094,6 +1096,10 @@ pars_set_dfield_type( ...@@ -1094,6 +1096,10 @@ pars_set_dfield_type(
flags |= DATA_NOT_NULL; flags |= DATA_NOT_NULL;
} }
if (is_unsigned) {
flags |= DATA_UNSIGNED;
}
if (type == &pars_int_token) { if (type == &pars_int_token) {
if (len != 0) { if (len != 0) {
ut_error; ut_error;
...@@ -1158,7 +1164,7 @@ pars_variable_declaration( ...@@ -1158,7 +1164,7 @@ pars_variable_declaration(
node->param_type = PARS_NOT_PARAM; node->param_type = PARS_NOT_PARAM;
pars_set_dfield_type(que_node_get_val(node), type, 0, FALSE); pars_set_dfield_type(que_node_get_val(node), type, 0, FALSE, FALSE);
return(node); return(node);
} }
...@@ -1529,6 +1535,8 @@ pars_column_def( ...@@ -1529,6 +1535,8 @@ pars_column_def(
pars_res_word_t* type, /* in: data type */ pars_res_word_t* type, /* in: data type */
sym_node_t* len, /* in: length of column, or sym_node_t* len, /* in: length of column, or
NULL */ NULL */
void* is_unsigned, /* in: if not NULL, column
is of type UNSIGNED. */
void* is_not_null) /* in: if not NULL, column void* is_not_null) /* in: if not NULL, column
is of type NOT NULL. */ is of type NOT NULL. */
{ {
...@@ -1541,7 +1549,7 @@ pars_column_def( ...@@ -1541,7 +1549,7 @@ pars_column_def(
} }
pars_set_dfield_type(que_node_get_val(sym_node), type, len2, pars_set_dfield_type(que_node_get_val(sym_node), type, len2,
is_not_null != NULL); is_unsigned != NULL, is_not_null != NULL);
return(sym_node); return(sym_node);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment