Commit 4f4f20d4 authored by unknown's avatar unknown

MATCH(a,b) AGAINST (... IN NATURAL LANGUAGE MODE)

remove explicit $<ulong_num>$ from sql_yacc.yy


mysql-test/r/fulltext.result:
  MATCH(a,b) AGAINST (... IN NATURAL LANGUAGE MODE)
mysql-test/t/fulltext.test:
  MATCH(a,b) AGAINST (... IN NATURAL LANGUAGE MODE)
parent 3649a68f
...@@ -41,6 +41,15 @@ a b ...@@ -41,6 +41,15 @@ a b
Full-text indexes are called collections Full-text indexes are called collections
Only MyISAM tables support collections Only MyISAM tables support collections
MySQL has now support for full-text search MySQL has now support for full-text search
select * from t1 where MATCH(a,b) AGAINST ("indexes" IN NATURAL LANGUAGE MODE);
a b
Full-text indexes are called collections
select * from t1 where MATCH(a,b) AGAINST ("indexes" IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION);
a b
Full-text indexes are called collections
Only MyISAM tables support collections
select * from t1 where MATCH(a,b) AGAINST ("indexes" IN BOOLEAN MODE WITH QUERY EXPANSION);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH QUERY EXPANSION)' at line 1
explain select * from t1 where MATCH(a,b) AGAINST ("collections"); explain select * from t1 where MATCH(a,b) AGAINST ("collections");
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 fulltext a a 0 1 Using where 1 SIMPLE t1 fulltext a a 0 1 Using where
......
...@@ -28,6 +28,12 @@ select * from t1 where MATCH(a,b) AGAINST ("collections" WITH QUERY EXPANSION); ...@@ -28,6 +28,12 @@ select * from t1 where MATCH(a,b) AGAINST ("collections" WITH QUERY EXPANSION);
select * from t1 where MATCH(a,b) AGAINST ("indexes" WITH QUERY EXPANSION); select * from t1 where MATCH(a,b) AGAINST ("indexes" WITH QUERY EXPANSION);
select * from t1 where MATCH(a,b) AGAINST ("indexes collections" WITH QUERY EXPANSION); select * from t1 where MATCH(a,b) AGAINST ("indexes collections" WITH QUERY EXPANSION);
# IN NATURAL LANGUAGE MODE
select * from t1 where MATCH(a,b) AGAINST ("indexes" IN NATURAL LANGUAGE MODE);
select * from t1 where MATCH(a,b) AGAINST ("indexes" IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION);
--error 1064
select * from t1 where MATCH(a,b) AGAINST ("indexes" IN BOOLEAN MODE WITH QUERY EXPANSION);
# add_ft_keys() tests # add_ft_keys() tests
explain select * from t1 where MATCH(a,b) AGAINST ("collections"); explain select * from t1 where MATCH(a,b) AGAINST ("collections");
......
...@@ -746,6 +746,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -746,6 +746,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
opt_ignore_leaves fulltext_options spatial_type union_option opt_ignore_leaves fulltext_options spatial_type union_option
start_transaction_opts opt_chain opt_release start_transaction_opts opt_chain opt_release
union_opt select_derived_init option_type2 union_opt select_derived_init option_type2
opt_natural_language_mode opt_query_expansion
opt_ev_status opt_ev_on_completion ev_on_completion opt_ev_comment
ev_alter_on_schedule_completion opt_ev_rename_to opt_ev_sql_stmt
%type <ulong_num> %type <ulong_num>
ulong_num merge_insert_types ulong_num merge_insert_types
...@@ -1309,9 +1312,9 @@ create: ...@@ -1309,9 +1312,9 @@ create:
YYABORT; YYABORT;
sp->init_strings(YYTHD, lex, $3); sp->init_strings(YYTHD, lex, $3);
lex->sql_command= SQLCOM_CREATE_PROCEDURE; lex->sql_command= SQLCOM_CREATE_PROCEDURE;
/* /*
Restore flag if it was cleared above Restore flag if it was cleared above
Be careful with counting. the block where we save the value Be careful with counting. the block where we save the value
is $4. is $4.
*/ */
...@@ -1319,8 +1322,8 @@ create: ...@@ -1319,8 +1322,8 @@ create:
sp->restore_thd_mem_root(YYTHD); sp->restore_thd_mem_root(YYTHD);
} }
| CREATE EVENT_SYM opt_if_not_exists sp_name | CREATE EVENT_SYM opt_if_not_exists sp_name
/* /*
BE CAREFUL when you add a new rule to update the block where BE CAREFUL when you add a new rule to update the block where
YYTHD->client_capabilities is set back to original value YYTHD->client_capabilities is set back to original value
*/ */
{ {
...@@ -1338,10 +1341,10 @@ create: ...@@ -1338,10 +1341,10 @@ create:
} }
lex->create_info.options= $3; lex->create_info.options= $3;
if (!(lex->et= new event_timed())) // implicitly calls event_timed::init() if (!(lex->et= new event_timed())) // implicitly calls event_timed::init()
YYABORT; YYABORT;
/* /*
We have to turn of CLIENT_MULTI_QUERIES while parsing a We have to turn of CLIENT_MULTI_QUERIES while parsing a
stored procedure, otherwise yylex will chop it into pieces stored procedure, otherwise yylex will chop it into pieces
...@@ -1441,31 +1444,31 @@ ev_schedule_time: EVERY_SYM expr interval ...@@ -1441,31 +1444,31 @@ ev_schedule_time: EVERY_SYM expr interval
str2? str2->c_ptr():"NULL"); str2? str2->c_ptr():"NULL");
YYABORT; YYABORT;
break; break;
} }
case EVEX_BAD_PARAMS: case EVEX_BAD_PARAMS:
my_error(ER_EVENT_EXEC_TIME_IN_THE_PAST, MYF(0)); my_error(ER_EVENT_EXEC_TIME_IN_THE_PAST, MYF(0));
YYABORT; YYABORT;
break; break;
} }
} }
} }
; ;
opt_ev_status: /* empty */ {$<ulong_num>$= 0;} opt_ev_status: /* empty */ { $$= 0; }
| ENABLE_SYM | ENABLE_SYM
{ {
LEX *lex=Lex; LEX *lex=Lex;
if (!lex->et_compile_phase) if (!lex->et_compile_phase)
lex->et->status= MYSQL_EVENT_ENABLED; lex->et->status= MYSQL_EVENT_ENABLED;
$<ulong_num>$= 1; $$= 1;
} }
| DISABLE_SYM | DISABLE_SYM
{ {
LEX *lex=Lex; LEX *lex=Lex;
if (!lex->et_compile_phase) if (!lex->et_compile_phase)
lex->et->status= MYSQL_EVENT_DISABLED; lex->et->status= MYSQL_EVENT_DISABLED;
$<ulong_num>$= 1; $$= 1;
} }
; ;
...@@ -1475,7 +1478,7 @@ ev_starts: /* empty */ ...@@ -1475,7 +1478,7 @@ ev_starts: /* empty */
LEX *lex= Lex; LEX *lex= Lex;
if (!lex->et_compile_phase) if (!lex->et_compile_phase)
{ {
switch (lex->et->init_starts(YYTHD, $2)) { switch (lex->et->init_starts(YYTHD, $2)) {
case EVEX_PARSE_ERROR: case EVEX_PARSE_ERROR:
yyerror(ER(ER_SYNTAX_ERROR)); yyerror(ER(ER_SYNTAX_ERROR));
...@@ -1516,28 +1519,28 @@ ev_ends: /* empty */ ...@@ -1516,28 +1519,28 @@ ev_ends: /* empty */
} }
; ;
opt_ev_on_completion: /* empty */ {$<ulong_num>$= 0;} opt_ev_on_completion: /* empty */ { $$= 0; }
| ev_on_completion | ev_on_completion
; ;
ev_on_completion: ev_on_completion:
ON COMPLETION_SYM PRESERVE_SYM ON COMPLETION_SYM PRESERVE_SYM
{ {
LEX *lex=Lex; LEX *lex=Lex;
if (!lex->et_compile_phase) if (!lex->et_compile_phase)
lex->et->on_completion= MYSQL_EVENT_ON_COMPLETION_PRESERVE; lex->et->on_completion= MYSQL_EVENT_ON_COMPLETION_PRESERVE;
$<ulong_num>$= 1; $$= 1;
} }
| ON COMPLETION_SYM NOT_SYM PRESERVE_SYM | ON COMPLETION_SYM NOT_SYM PRESERVE_SYM
{ {
LEX *lex=Lex; LEX *lex=Lex;
if (!lex->et_compile_phase) if (!lex->et_compile_phase)
lex->et->on_completion= MYSQL_EVENT_ON_COMPLETION_DROP; lex->et->on_completion= MYSQL_EVENT_ON_COMPLETION_DROP;
$<ulong_num>$= 1; $$= 1;
} }
; ;
opt_ev_comment: /* empty */ {$<ulong_num>$= 0;} opt_ev_comment: /* empty */ { $$= 0; }
| COMMENT_SYM TEXT_STRING_sys | COMMENT_SYM TEXT_STRING_sys
{ {
LEX *lex= Lex; LEX *lex= Lex;
...@@ -1546,7 +1549,7 @@ opt_ev_comment: /* empty */ {$<ulong_num>$= 0;} ...@@ -1546,7 +1549,7 @@ opt_ev_comment: /* empty */ {$<ulong_num>$= 0;}
lex->comment= $2; lex->comment= $2;
lex->et->init_comment(YYTHD, &$2); lex->et->init_comment(YYTHD, &$2);
} }
$<ulong_num>$= 1; $$= 1;
} }
; ;
...@@ -1554,9 +1557,9 @@ ev_sql_stmt: ...@@ -1554,9 +1557,9 @@ ev_sql_stmt:
{ {
LEX *lex= Lex; LEX *lex= Lex;
sp_head *sp; sp_head *sp;
$<sphead>$= lex->sphead; $<sphead>$= lex->sphead;
if (!lex->sphead) if (!lex->sphead)
{ {
if (!(sp= new sp_head())) if (!(sp= new sp_head()))
...@@ -1564,14 +1567,14 @@ ev_sql_stmt: ...@@ -1564,14 +1567,14 @@ ev_sql_stmt:
sp->reset_thd_mem_root(YYTHD); sp->reset_thd_mem_root(YYTHD);
sp->init(lex); sp->init(lex);
sp->m_type= TYPE_ENUM_PROCEDURE; sp->m_type= TYPE_ENUM_PROCEDURE;
lex->sphead= sp; lex->sphead= sp;
bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics)); bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
lex->sphead->m_chistics= &lex->sp_chistics; lex->sphead->m_chistics= &lex->sp_chistics;
lex->sphead->m_body_begin= lex->ptr; lex->sphead->m_body_begin= lex->ptr;
} }
...@@ -1581,14 +1584,14 @@ ev_sql_stmt: ...@@ -1581,14 +1584,14 @@ ev_sql_stmt:
ev_sql_stmt_inner ev_sql_stmt_inner
{ {
LEX *lex=Lex; LEX *lex=Lex;
if (!$<sphead>1) if (!$<sphead>1)
{ {
sp_head *sp= lex->sphead; sp_head *sp= lex->sphead;
// return back to the original memory root ASAP // return back to the original memory root ASAP
sp->init_strings(YYTHD, lex, NULL); sp->init_strings(YYTHD, lex, NULL);
sp->restore_thd_mem_root(YYTHD); sp->restore_thd_mem_root(YYTHD);
lex->sp_chistics.suid= SP_IS_SUID;//always the definer! lex->sp_chistics.suid= SP_IS_SUID;//always the definer!
lex->et->sphead= lex->sphead; lex->et->sphead= lex->sphead;
...@@ -1600,14 +1603,14 @@ ev_sql_stmt: ...@@ -1600,14 +1603,14 @@ ev_sql_stmt:
} }
} }
; ;
ev_sql_stmt_inner: ev_sql_stmt_inner:
sp_proc_stmt_statement sp_proc_stmt_statement
| sp_proc_stmt_return | sp_proc_stmt_return
| sp_proc_stmt_if | sp_proc_stmt_if
| sp_proc_stmt_case_simple | sp_proc_stmt_case_simple
| sp_proc_stmt_case | sp_proc_stmt_case
| sp_labeled_control {} | sp_labeled_control
| sp_proc_stmt_unlabeled | sp_proc_stmt_unlabeled
| sp_proc_stmt_leave | sp_proc_stmt_leave
| sp_proc_stmt_iterate | sp_proc_stmt_iterate
...@@ -2286,7 +2289,6 @@ sp_proc_stmt: ...@@ -2286,7 +2289,6 @@ sp_proc_stmt:
| sp_proc_stmt_case_simple | sp_proc_stmt_case_simple
| sp_proc_stmt_case | sp_proc_stmt_case
| sp_labeled_control | sp_labeled_control
{}
| sp_proc_stmt_unlabeled | sp_proc_stmt_unlabeled
| sp_proc_stmt_leave | sp_proc_stmt_leave
| sp_proc_stmt_iterate | sp_proc_stmt_iterate
...@@ -4798,8 +4800,8 @@ alter: ...@@ -4798,8 +4800,8 @@ alter:
view_list_opt AS view_select view_check_option view_list_opt AS view_select view_check_option
{} {}
| ALTER EVENT_SYM sp_name | ALTER EVENT_SYM sp_name
/* /*
BE CAREFUL when you add a new rule to update the block where BE CAREFUL when you add a new rule to update the block where
YYTHD->client_capabilities is set back to original value YYTHD->client_capabilities is set back to original value
*/ */
{ {
...@@ -4816,7 +4818,7 @@ alter: ...@@ -4816,7 +4818,7 @@ alter:
YYABORT; YYABORT;
} }
lex->spname= 0;//defensive programming lex->spname= 0;//defensive programming
if (!(et= new event_timed()))// implicitly calls event_timed::init() if (!(et= new event_timed()))// implicitly calls event_timed::init()
YYABORT; YYABORT;
lex->et = et; lex->et = et;
...@@ -4826,7 +4828,7 @@ alter: ...@@ -4826,7 +4828,7 @@ alter:
et->init_definer(YYTHD); et->init_definer(YYTHD);
et->init_name(YYTHD, $3); et->init_name(YYTHD, $3);
} }
/* /*
We have to turn of CLIENT_MULTI_QUERIES while parsing a We have to turn of CLIENT_MULTI_QUERIES while parsing a
stored procedure, otherwise yylex will chop it into pieces stored procedure, otherwise yylex will chop it into pieces
...@@ -4853,8 +4855,7 @@ alter: ...@@ -4853,8 +4855,7 @@ alter:
sql_command is set here because some rules in ev_sql_stmt sql_command is set here because some rules in ev_sql_stmt
can overwrite it can overwrite it
*/ */
if (!($<ulong_num>5 || $<ulong_num>6 || $<ulong_num>7 || if (!($5 || $6 || $7 || $8 || $9))
$<ulong_num>8 || $<ulong_num>9))
{ {
yyerror(ER(ER_SYNTAX_ERROR)); yyerror(ER(ER_SYNTAX_ERROR));
YYABORT; YYABORT;
...@@ -4866,7 +4867,7 @@ alter: ...@@ -4866,7 +4867,7 @@ alter:
LEX *lex= Lex; LEX *lex= Lex;
lex->alter_tablespace_info->ts_cmd_type= ALTER_TABLESPACE; lex->alter_tablespace_info->ts_cmd_type= ALTER_TABLESPACE;
} }
| ALTER LOGFILE_SYM GROUP alter_logfile_group_info | ALTER LOGFILE_SYM GROUP alter_logfile_group_info
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->alter_tablespace_info->ts_cmd_type= ALTER_LOGFILE_GROUP; lex->alter_tablespace_info->ts_cmd_type= ALTER_LOGFILE_GROUP;
...@@ -4876,34 +4877,31 @@ alter: ...@@ -4876,34 +4877,31 @@ alter:
LEX *lex= Lex; LEX *lex= Lex;
lex->alter_tablespace_info->ts_cmd_type= CHANGE_FILE_TABLESPACE; lex->alter_tablespace_info->ts_cmd_type= CHANGE_FILE_TABLESPACE;
} }
| ALTER TABLESPACE change_tablespace_access | ALTER TABLESPACE change_tablespace_access
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->alter_tablespace_info->ts_cmd_type= ALTER_ACCESS_MODE_TABLESPACE; lex->alter_tablespace_info->ts_cmd_type= ALTER_ACCESS_MODE_TABLESPACE;
} }
; ;
ev_alter_on_schedule_completion: /* empty */ { $<ulong_num>$= 0;} ev_alter_on_schedule_completion: /* empty */ { $$= 0;}
| ON SCHEDULE_SYM ev_schedule_time { $<ulong_num>$= 1; } | ON SCHEDULE_SYM ev_schedule_time { $$= 1; }
| ev_on_completion { $<ulong_num>$= 1; } | ev_on_completion { $$= 1; }
| ON SCHEDULE_SYM ev_schedule_time ev_on_completion { $<ulong_num>$= 1; } | ON SCHEDULE_SYM ev_schedule_time ev_on_completion { $$= 1; }
; ;
opt_ev_rename_to: /* empty */ { $<ulong_num>$= 0;} opt_ev_rename_to: /* empty */ { $$= 0;}
| RENAME TO_SYM sp_name | RENAME TO_SYM sp_name
{ {
LEX *lex=Lex; LEX *lex=Lex;
lex->spname= $3; //use lex's spname to hold the new name lex->spname= $3; //use lex's spname to hold the new name
//the original name is in the event_timed object //the original name is in the event_timed object
$<ulong_num>$= 1; $$= 1;
} }
; ;
opt_ev_sql_stmt: /* empty*/ { $<ulong_num>$= 0;} opt_ev_sql_stmt: /* empty*/ { $$= 0;}
| DO_SYM ev_sql_stmt | DO_SYM ev_sql_stmt { $$= 1; }
{
$<ulong_num>$= 1;
}
; ;
...@@ -6625,9 +6623,20 @@ geometry_function: ...@@ -6625,9 +6623,20 @@ geometry_function:
; ;
fulltext_options: fulltext_options:
/* nothing */ { $$= FT_NL; } opt_natural_language_mode opt_query_expansion
| WITH QUERY_SYM EXPANSION_SYM { $$= FT_NL | FT_EXPAND; } { $$= $1 | $2; }
| IN_SYM BOOLEAN_SYM MODE_SYM { $$= FT_BOOL; } | IN_SYM BOOLEAN_SYM MODE_SYM
{ $$= FT_BOOL; }
;
opt_natural_language_mode:
/* nothing */ { $$= FT_NL; }
| IN_SYM NATURAL LANGUAGE_SYM MODE_SYM { $$= FT_NL; }
;
opt_query_expansion:
/* nothing */ { $$= 0; }
| WITH QUERY_SYM EXPANSION_SYM { $$= FT_EXPAND; }
; ;
udf_expr_list: udf_expr_list:
...@@ -10889,25 +10898,25 @@ view_check_option: ...@@ -10889,25 +10898,25 @@ view_check_option:
**************************************************************************/ **************************************************************************/
trigger_tail: trigger_tail:
TRIGGER_SYM remember_name sp_name trg_action_time trg_event TRIGGER_SYM remember_name sp_name trg_action_time trg_event
ON table_ident FOR_SYM EACH_SYM ROW_SYM ON table_ident FOR_SYM EACH_SYM ROW_SYM
{ {
LEX *lex= Lex; LEX *lex= Lex;
sp_head *sp; sp_head *sp;
if (lex->sphead) if (lex->sphead)
{ {
my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), "TRIGGER"); my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), "TRIGGER");
YYABORT; YYABORT;
} }
if (!(sp= new sp_head())) if (!(sp= new sp_head()))
YYABORT; YYABORT;
sp->reset_thd_mem_root(YYTHD); sp->reset_thd_mem_root(YYTHD);
sp->init(lex); sp->init(lex);
lex->trigger_definition_begin= $2; lex->trigger_definition_begin= $2;
sp->m_type= TYPE_ENUM_TRIGGER; sp->m_type= TYPE_ENUM_TRIGGER;
lex->sphead= sp; lex->sphead= sp;
lex->spname= $3; lex->spname= $3;
...@@ -10918,7 +10927,7 @@ trigger_tail: ...@@ -10918,7 +10927,7 @@ trigger_tail:
*/ */
$<ulong_num>$= YYTHD->client_capabilities & CLIENT_MULTI_QUERIES; $<ulong_num>$= YYTHD->client_capabilities & CLIENT_MULTI_QUERIES;
YYTHD->client_capabilities &= ~CLIENT_MULTI_QUERIES; YYTHD->client_capabilities &= ~CLIENT_MULTI_QUERIES;
bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics)); bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
lex->sphead->m_chistics= &lex->sp_chistics; lex->sphead->m_chistics= &lex->sp_chistics;
lex->sphead->m_body_begin= lex->ptr; lex->sphead->m_body_begin= lex->ptr;
...@@ -10929,27 +10938,27 @@ trigger_tail: ...@@ -10929,27 +10938,27 @@ trigger_tail:
{ {
LEX *lex= Lex; LEX *lex= Lex;
sp_head *sp= lex->sphead; sp_head *sp= lex->sphead;
lex->sql_command= SQLCOM_CREATE_TRIGGER; lex->sql_command= SQLCOM_CREATE_TRIGGER;
sp->init_strings(YYTHD, lex, $3); sp->init_strings(YYTHD, lex, $3);
/* Restore flag if it was cleared above */ /* Restore flag if it was cleared above */
YYTHD->client_capabilities |= $<ulong_num>11; YYTHD->client_capabilities |= $<ulong_num>11;
sp->restore_thd_mem_root(YYTHD); sp->restore_thd_mem_root(YYTHD);
if (sp->is_not_allowed_in_function("trigger")) if (sp->is_not_allowed_in_function("trigger"))
YYABORT; YYABORT;
/* /*
We have to do it after parsing trigger body, because some of We have to do it after parsing trigger body, because some of
sp_proc_stmt alternatives are not saving/restoring LEX, so sp_proc_stmt alternatives are not saving/restoring LEX, so
lex->query_tables can be wiped out. lex->query_tables can be wiped out.
QQ: What are other consequences of this? QQ: What are other consequences of this?
QQ: Could we loosen lock type in certain cases ? QQ: Could we loosen lock type in certain cases ?
*/ */
if (!lex->select_lex.add_table_to_list(YYTHD, $7, if (!lex->select_lex.add_table_to_list(YYTHD, $7,
(LEX_STRING*) 0, (LEX_STRING*) 0,
TL_OPTION_UPDATING, TL_OPTION_UPDATING,
TL_WRITE)) TL_WRITE))
......
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