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
......
...@@ -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
...@@ -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
......
...@@ -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