diff options
author | unknown <bell@sanja.is.com.ua> | 2003-01-14 19:18:09 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2003-01-14 19:18:09 +0200 |
commit | 2d6f1c223d94fe874ac7acba089a1678f314dfac (patch) | |
tree | 1529aa2abd10f395f9225c5377c8807f58ac3177 /sql | |
parent | 5ce475835c84a79279b78838edc5113329a785ca (diff) | |
parent | 742de8f5ff550da8cfe681fe7bc7b4bdfdccc083 (diff) | |
download | mariadb-git-2d6f1c223d94fe874ac7acba089a1678f314dfac.tar.gz |
Merge abelkin@work.mysql.com:/home/bk/mysql-4.1
into sanja.is.com.ua:/home/bell/mysql/mysql-4.1
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_base.cc | 8 | ||||
-rw-r--r-- | sql/sql_lex.cc | 2 | ||||
-rw-r--r-- | sql/sql_lex.h | 1 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 40 |
4 files changed, 40 insertions, 11 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index a384e723e32..038a286f4df 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1749,12 +1749,8 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables, } if (report_error) { - if (thd->lex.current_select->get_master()->order_list.elements) - my_printf_error(ER_TABLENAME_NOT_ALLOWED_HERE, ER(ER_TABLENAME_NOT_ALLOWED_HERE), - MYF(0), table_name, thd->where); - else - my_printf_error(ER_UNKNOWN_TABLE, ER(ER_UNKNOWN_TABLE), MYF(0), - table_name, thd->where); + my_printf_error(ER_UNKNOWN_TABLE, ER(ER_UNKNOWN_TABLE), MYF(0), + table_name, thd->where); } else return (Field*) not_found_field; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index dda3d4e822e..b656f698e89 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -943,7 +943,7 @@ int yylex(void *arg, void *yythd) void st_select_lex_node::init_query() { - dependent= 0; + no_table_names_allowed= dependent= 0; } void st_select_lex_node::init_select() diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 4b6ac927f07..e4a17838cd2 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -212,6 +212,7 @@ public: bool with_sum_func; bool create_refs; bool dependent; /* dependent from outer select subselect */ + bool no_table_names_allowed; /* used for global order by */ static void *operator new(size_t size) { diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 0985859caae..318d563b88a 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3740,17 +3740,41 @@ simple_ident: } | ident '.' ident { - SELECT_LEX_NODE *sel=Select; + THD *thd= YYTHD; + LEX *lex= &thd->lex; + SELECT_LEX_NODE *sel= lex->current_select; + if (sel->no_table_names_allowed) + { + my_printf_error(ER_TABLENAME_NOT_ALLOWED_HERE, + ER(ER_TABLENAME_NOT_ALLOWED_HERE), + MYF(0), $1.str, thd->where); + } $$ = !sel->create_refs || sel->get_in_sum_expr() > 0 ? (Item*) new Item_field(NullS,$1.str,$3.str) : (Item*) new Item_ref(NullS,$1.str,$3.str); } | '.' ident '.' ident { - SELECT_LEX_NODE *sel=Select; + THD *thd= YYTHD; + LEX *lex= &thd->lex; + SELECT_LEX_NODE *sel= lex->current_select; + if (sel->no_table_names_allowed) + { + my_printf_error(ER_TABLENAME_NOT_ALLOWED_HERE, + ER(ER_TABLENAME_NOT_ALLOWED_HERE), + MYF(0), $2.str, thd->where); + } $$ = !sel->create_refs || sel->get_in_sum_expr() > 0 ? (Item*) new Item_field(NullS,$2.str,$4.str) : (Item*) new Item_ref(NullS,$2.str,$4.str); } | ident '.' ident '.' ident { - SELECT_LEX_NODE *sel=Select; + THD *thd= YYTHD; + LEX *lex= &thd->lex; + SELECT_LEX_NODE *sel= lex->current_select; + if (sel->no_table_names_allowed) + { + my_printf_error(ER_TABLENAME_NOT_ALLOWED_HERE, + ER(ER_TABLENAME_NOT_ALLOWED_HERE), + MYF(0), $3.str, thd->where); + } $$ = !sel->create_refs || sel->get_in_sum_expr() > 0 ? (Item*) new Item_field((YYTHD->client_capabilities & CLIENT_NO_SCHEMA ? NullS :$1.str),$3.str,$5.str) : (Item*) new Item_ref((YYTHD->client_capabilities & CLIENT_NO_SCHEMA ? NullS :$1.str),$3.str,$5.str); }; @@ -4535,7 +4559,8 @@ optional_order_or_limit: /* Empty */ {} | { - LEX *lex=Lex; + THD *thd= YYTHD; + LEX *lex= &thd->lex; if (!lex->current_select->linkage == GLOBAL_OPTIONS_TYPE) { send_error(lex->thd, ER_SYNTAX_ERROR); @@ -4547,8 +4572,15 @@ optional_order_or_limit: lex->current_select= sel->master_unit(); lex->current_select->select_limit= lex->thd->variables.select_limit; + lex->current_select->no_table_names_allowed= 1; + thd->where= "global ORDER clause"; } order_or_limit + { + THD *thd= YYTHD; + thd->lex.current_select->no_table_names_allowed= 0; + thd->where= ""; + } ; order_or_limit: |