summaryrefslogtreecommitdiff
path: root/sql/sql_lex.cc
diff options
context:
space:
mode:
authorChad MILLER <chad@mysql.com>2008-12-17 15:01:34 -0500
committerChad MILLER <chad@mysql.com>2008-12-17 15:01:34 -0500
commit926e5f6694d1bb1dd5b8074efd526fd8983b620f (patch)
tree14bfefa872195990d45ab8f3ee850730cd31ed1b /sql/sql_lex.cc
parent27d35e3517a063c9259a0f8b9638bf3073cf020b (diff)
parent4d1a042df0c52fd7c721313ec84d39e2b2c0a2f6 (diff)
downloadmariadb-git-926e5f6694d1bb1dd5b8074efd526fd8983b620f.tar.gz
Merged from 5.0 (enterprise).
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r--sql/sql_lex.cc43
1 files changed, 31 insertions, 12 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 16fab313e61..de2e5867955 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -192,7 +192,6 @@ void lex_start(THD *thd)
lex->select_lex.order_list.empty();
lex->select_lex.udf_list.empty();
lex->current_select= &lex->select_lex;
- lex->yacc_yyss=lex->yacc_yyvs=0;
lex->sql_command= lex->orig_sql_command= SQLCOM_END;
lex->duplicates= DUP_ERROR;
lex->ignore= 0;
@@ -210,11 +209,16 @@ void lex_start(THD *thd)
void lex_end(LEX *lex)
{
- DBUG_ENTER("lex_end");
- DBUG_PRINT("enter", ("lex: 0x%lx", (long) lex));
- x_free(lex->yacc_yyss);
- x_free(lex->yacc_yyvs);
- DBUG_VOID_RETURN;
+ /* Empty in 5.0, non empty in 5.1 */
+}
+
+Yacc_state::~Yacc_state()
+{
+ if (yacc_yyss)
+ {
+ x_free(yacc_yyss);
+ x_free(yacc_yyvs);
+ }
}
@@ -531,7 +535,7 @@ int MYSQLlex(void *arg, void *yythd)
uint length;
enum my_lex_states state;
THD *thd= (THD *)yythd;
- Lex_input_stream *lip= thd->m_lip;
+ Lex_input_stream *lip= & thd->m_parser_state->m_lip;
LEX *lex= thd->lex;
YYSTYPE *yylval=(YYSTYPE*) arg;
CHARSET_INFO *cs= thd->charset();
@@ -1201,6 +1205,7 @@ void st_select_lex::init_query()
subquery_in_having= explicit_limit= 0;
is_item_list_lookup= 0;
first_execution= 1;
+ first_natural_join_processing= 1;
first_cond_optimization= 1;
parsing_place= NO_MATTER;
exclude_from_table_unique_test= no_wrap_view_item= FALSE;
@@ -1781,7 +1786,7 @@ void Query_tables_list::destroy_query_tables_list()
*/
st_lex::st_lex()
- :result(0), yacc_yyss(0), yacc_yyvs(0),
+ :result(0),
sql_command(SQLCOM_END)
{
reset_query_tables_list(TRUE);
@@ -2036,12 +2041,26 @@ st_lex::copy_db_to(char **p_db, uint *p_db_length) const
void st_select_lex_unit::set_limit(SELECT_LEX *sl)
{
ha_rows select_limit_val;
+ ulonglong val;
DBUG_ASSERT(! thd->stmt_arena->is_stmt_prepare());
- select_limit_val= (ha_rows)(sl->select_limit ? sl->select_limit->val_uint() :
- HA_POS_ERROR);
- offset_limit_cnt= (ha_rows)(sl->offset_limit ? sl->offset_limit->val_uint() :
- ULL(0));
+ val= sl->select_limit ? sl->select_limit->val_uint() : HA_POS_ERROR;
+ select_limit_val= (ha_rows)val;
+#ifndef BIG_TABLES
+ /*
+ Check for overflow : ha_rows can be smaller then ulonglong if
+ BIG_TABLES is off.
+ */
+ if (val != (ulonglong)select_limit_val)
+ select_limit_val= HA_POS_ERROR;
+#endif
+ val= sl->offset_limit ? sl->offset_limit->val_uint() : ULL(0);
+ offset_limit_cnt= (ha_rows)val;
+#ifndef BIG_TABLES
+ /* Check for truncation. */
+ if (val != (ulonglong)offset_limit_cnt)
+ offset_limit_cnt= HA_POS_ERROR;
+#endif
select_limit_cnt= select_limit_val + offset_limit_cnt;
if (select_limit_cnt < select_limit_val)
select_limit_cnt= HA_POS_ERROR; // no limit