summaryrefslogtreecommitdiff
path: root/sql/sql_lex.cc
diff options
context:
space:
mode:
authorunknown <pem@mysql.com>2004-05-07 18:52:06 +0200
committerunknown <pem@mysql.com>2004-05-07 18:52:06 +0200
commite9c1e75b48e5d2c0047a3e88b35667a33d6395e4 (patch)
tree2f7b236a8721d14f1b398964b898d922fd133131 /sql/sql_lex.cc
parentf3d691a970627f34ed825a9cf7b84520dcdd43b3 (diff)
parente3211fbd6a59c3dc6a97066c97ab86bfc67d382f (diff)
downloadmariadb-git-e9c1e75b48e5d2c0047a3e88b35667a33d6395e4.tar.gz
Merge 4.1 -> 5.0
BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union VC++Files/sql/mysqld.dsp: Auto merged configure.in: Auto merged include/my_global.h: Auto merged include/mysql_com.h: Auto merged libmysql/libmysql.c: Auto merged libmysqld/Makefile.am: Auto merged myisam/myisamchk.c: Auto merged myisam/myisamdef.h: Auto merged mysql-test/install_test_db.sh: Auto merged mysql-test/r/func_time.result: Auto merged mysql-test/r/mysqldump.result: Auto merged mysql-test/r/show_check.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/union.result: Auto merged mysql-test/t/func_time.test: Auto merged mysql-test/t/subselect.test: Auto merged scripts/make_binary_distribution.sh: Auto merged scripts/mysql_install_db.sh: Auto merged sql/ha_berkeley.cc: Auto merged mysql-test/t/rpl_error_ignored_table.test: Auto merged sql/ha_berkeley.h: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_innodb.h: Auto merged sql/ha_myisam.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_cmpfunc.h: Auto merged sql/item_subselect.cc: Auto merged sql/item_sum.cc: Auto merged sql/item_sum.h: Auto merged sql/lex.h: Auto merged sql/log.cc: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/protocol.cc: Auto merged sql/records.cc: Auto merged sql/set_var.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_acl.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_load.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_select.h: Auto merged sql/sql_show.cc: Auto merged sql/sql_string.cc: Auto merged sql/sql_test.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.h: Auto merged tests/client_test.c: Auto merged
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r--sql/sql_lex.cc85
1 files changed, 77 insertions, 8 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 071e41b1247..7e38941f344 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -869,13 +869,15 @@ int yylex(void *arg, void *yythd)
}
yySkip();
return (SET_VAR);
- case MY_LEX_COLON: // optional line terminator
+ case MY_LEX_SEMICOLON: // optional line terminator
if (yyPeek())
{
- if (((THD *)yythd)->client_capabilities & CLIENT_MULTI_STATEMENTS)
+ THD* thd= (THD*)yythd;
+ if ((thd->client_capabilities & CLIENT_MULTI_STATEMENTS) &&
+ (thd->command != COM_PREPARE))
{
lex->found_colon=(char*)lex->ptr;
- ((THD *)yythd)->server_status |= SERVER_MORE_RESULTS_EXISTS;
+ thd->server_status |= SERVER_MORE_RESULTS_EXISTS;
lex->next_state=MY_LEX_END;
return(END_OF_INPUT);
}
@@ -1012,6 +1014,7 @@ void st_select_lex::init_query()
ref_pointer_array= 0;
select_n_having_items= 0;
prep_where= 0;
+ explicit_limit= 0;
}
void st_select_lex::init_select()
@@ -1520,7 +1523,7 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num)
*/
bool st_select_lex_unit::check_updateable(char *db, char *table)
{
- for(SELECT_LEX *sl= first_select(); sl; sl= sl->next_select())
+ for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select())
if (sl->check_updateable(db, table))
return 1;
return 0;
@@ -1605,10 +1608,7 @@ void st_select_lex::print_limit(THD *thd, String *str)
if (!thd)
thd= current_thd;
- if ((select_limit != thd->variables.select_limit &&
- this == &thd->lex->select_lex) ||
- (select_limit != HA_POS_ERROR && this != &thd->lex->select_lex) ||
- offset_limit != 0L)
+ if (explicit_limit)
{
str->append(" limit ", 7);
char buff[20];
@@ -1644,6 +1644,75 @@ void st_select_lex_unit::set_limit(SELECT_LEX *values,
sl->options&= ~OPTION_FOUND_ROWS;
}
+
+/*
+ Unlink first table from global table list and first table from outer select
+ list (lex->select_lex)
+
+ SYNOPSIS
+ unlink_first_table()
+ tables Global table list
+ global_first Save first global table here
+ local_first Save first local table here
+
+ NORES
+ global_first & local_first are used to save result for link_first_table_back
+
+ RETURN
+ global list without first table
+
+*/
+TABLE_LIST *st_lex::unlink_first_table(TABLE_LIST *tables,
+ TABLE_LIST **global_first,
+ TABLE_LIST **local_first)
+{
+ *global_first= tables;
+ *local_first= (TABLE_LIST*)select_lex.table_list.first;
+ /*
+ Exclude from global table list
+ */
+ tables= tables->next;
+ /*
+ and from local list if it is not the same
+ */
+ select_lex.table_list.first= ((&select_lex != all_selects_list) ?
+ (byte*) (*local_first)->next :
+ (byte*) tables);
+ (*global_first)->next= 0;
+ return tables;
+}
+
+
+/*
+ Link table back that was unlinked with unlink_first_table()
+
+ SYNOPSIS
+ link_first_table_back()
+ tables Global table list
+ global_first Saved first global table
+ local_first Saved first local table
+
+ RETURN
+ global list
+*/
+TABLE_LIST *st_lex::link_first_table_back(TABLE_LIST *tables,
+ TABLE_LIST *global_first,
+ TABLE_LIST *local_first)
+{
+ global_first->next= tables;
+ if (&select_lex != all_selects_list)
+ {
+ /*
+ we do not touch local table 'next' field => we need just
+ put the table in the list
+ */
+ select_lex.table_list.first= (byte*) local_first;
+ }
+ else
+ select_lex.table_list.first= (byte*) global_first;
+ return global_first;
+}
+
/*
There are st_select_lex::add_table_to_list &
st_select_lex::set_lock_for_tables are in sql_parse.cc