~ubuntu-branches/ubuntu/gutsy/mysql-dfsg-5.0/gutsy

« back to all changes in this revision

Viewing changes to sql/sql_lex.cc

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2007-04-03 09:43:01 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20070403094301-fnjhfr59hu72pvtg
Tags: 5.0.38-0ubuntu1
* Package the Enterprise version again (.37 was a community version), since
  Debian and we have always done so. This brings in a few more bug fixes and
  makes functional derivations less likely.
* debian/README.Maintainer: Add pointer to upstream download URL, since it
  is very hard to find the Enterprise versions.
* Disable 33_scripts__mysql_create_system_tables__no_test.dpatch, since that
  script was removed upstream.
* debian/patches/41_scripts__mysql_install_db.sh__no_test.dpatch: Adapted to
  changed formatting in new upstream version.
* Remove debian/patches/86_PATH_MAX.dpatch, fixed upstream.
* Add debian/patches/90_org_tables_definition.dpatch: Fix local variable
  declaration in libmysqld/sql_parse.cc to fix compilation with
  EMBEDDED_LIBRARY.

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
}
100
100
 
101
101
 
 
102
void
 
103
st_parsing_options::reset()
 
104
{
 
105
  allows_variable= TRUE;
 
106
  allows_select_into= TRUE;
 
107
  allows_select_procedure= TRUE;
 
108
  allows_derived= TRUE;
 
109
}
 
110
 
 
111
 
102
112
/*
103
113
  This is called before every query that is to be parsed.
104
114
  Because of this, it's critical to not do too much things here.
149
159
  lex->safe_to_cache_query= 1;
150
160
  lex->time_zone_tables_used= 0;
151
161
  lex->leaf_tables_insert= 0;
 
162
  lex->parsing_options.reset();
152
163
  lex->empty_field_list_on_rset= 0;
153
164
  lex->select_lex.select_number= 1;
154
165
  lex->next_state=MY_LEX_START;
173
184
  lex->proc_list.first= 0;
174
185
  lex->escape_used= FALSE;
175
186
  lex->reset_query_tables_list(FALSE);
176
 
  lex->profile_options= PROFILE_NONE;
 
187
 
177
188
  lex->nest_level=0 ;
178
189
  lex->allow_sum_func= 0;
179
190
  lex->in_sum_func= NULL;
286
297
  {
287
298
    c = yyGet();
288
299
#ifdef USE_MB
289
 
    int l;
290
 
    if (use_mb(cs) &&
291
 
        (l = my_ismbchar(cs,
292
 
                         (const char *)lex->ptr-1,
293
 
                         (const char *)lex->end_of_query))) {
 
300
    {
 
301
      int l;
 
302
      if (use_mb(cs) &&
 
303
          (l = my_ismbchar(cs,
 
304
                           (const char *)lex->ptr-1,
 
305
                           (const char *)lex->end_of_query))) {
294
306
        lex->ptr += l-1;
295
307
        continue;
 
308
      }
296
309
    }
297
310
#endif
298
311
    if (c == '\\' &&
759
772
      lex->tok_start=lex->ptr;                  // Skip first `
760
773
      while ((c=yyGet()))
761
774
      {
762
 
        int length;
763
 
        if ((length= my_mbcharlen(cs, c)) == 1)
 
775
        int var_length;
 
776
        if ((var_length= my_mbcharlen(cs, c)) == 1)
764
777
        {
765
778
          if (c == (uchar) NAMES_SEP_CHAR)
766
779
            break; /* Old .frm format can't handle this char */
774
787
          }
775
788
        }
776
789
#ifdef USE_MB
777
 
        else if (length < 1)
 
790
        else if (var_length < 1)
778
791
          break;                                // Error
779
 
        lex->ptr+= length-1;
 
792
        lex->ptr+= var_length-1;
780
793
#endif
781
794
      }
782
795
      if (double_quotes)
1151
1164
  cond_count= between_count= with_wild= 0;
1152
1165
  conds_processed_with_permanent_arena= 0;
1153
1166
  ref_pointer_array= 0;
 
1167
  select_n_where_fields= 0;
1154
1168
  select_n_having_items= 0;
1155
1169
  subquery_in_having= explicit_limit= 0;
1156
1170
  is_item_list_lookup= 0;
1192
1206
  is_correlated= 0;
1193
1207
  cur_pos_in_select_list= UNDEF_POS;
1194
1208
  non_agg_fields.empty();
 
1209
  cond_value= having_value= Item::COND_UNDEF;
 
1210
  inner_refs_list.empty();
1195
1211
}
1196
1212
 
1197
1213
/*
1549
1565
          (Item **)arena->alloc(sizeof(Item*) * (n_child_sum_items +
1550
1566
                                                 item_list.elements +
1551
1567
                                                 select_n_having_items +
 
1568
                                                 select_n_where_fields +
1552
1569
                                                 order_group_num)*5)) == 0;
1553
1570
}
1554
1571
 
1632
1649
  }
1633
1650
}
1634
1651
 
 
1652
/**
 
1653
  @brief Restore the LEX and THD in case of a parse error.
 
1654
 
 
1655
  This is a clean up call that is invoked by the Bison generated
 
1656
  parser before returning an error from MYSQLparse. If your
 
1657
  semantic actions manipulate with the global thread state (which
 
1658
  is a very bad practice and should not normally be employed) and
 
1659
  need a clean-up in case of error, and you can not use %destructor
 
1660
  rule in the grammar file itself, this function should be used
 
1661
  to implement the clean up.
 
1662
*/
 
1663
 
 
1664
void st_lex::cleanup_lex_after_parse_error(THD *thd)
 
1665
{
 
1666
  /*
 
1667
    Delete sphead for the side effect of restoring of the original
 
1668
    LEX state, thd->lex, thd->mem_root and thd->free_list if they
 
1669
    were replaced when parsing stored procedure statements.  We
 
1670
    will never use sphead object after a parse error, so it's okay
 
1671
    to delete it only for the sake of the side effect.
 
1672
    TODO: make this functionality explicit in sp_head class.
 
1673
    Sic: we must nullify the member of the main lex, not the
 
1674
    current one that will be thrown away
 
1675
  */
 
1676
  if (thd->lex->sphead)
 
1677
  {
 
1678
    delete thd->lex->sphead;
 
1679
    thd->lex->sphead= NULL;
 
1680
  }
 
1681
}
1635
1682
 
1636
1683
/*
1637
1684
  Initialize (or reset) Query_tables_list object.
1736
1783
  bool selects_allow_merge= select_lex.next_select() == 0;
1737
1784
  if (selects_allow_merge)
1738
1785
  {
1739
 
    for (SELECT_LEX_UNIT *unit= select_lex.first_inner_unit();
1740
 
         unit;
1741
 
         unit= unit->next_unit())
 
1786
    for (SELECT_LEX_UNIT *tmp_unit= select_lex.first_inner_unit();
 
1787
         tmp_unit;
 
1788
         tmp_unit= tmp_unit->next_unit())
1742
1789
    {
1743
 
      if (unit->first_select()->parent_lex == this &&
1744
 
          (unit->item == 0 ||
1745
 
           (unit->item->place() != IN_WHERE && unit->item->place() != IN_ON)))
 
1790
      if (tmp_unit->first_select()->parent_lex == this &&
 
1791
          (tmp_unit->item == 0 ||
 
1792
           (tmp_unit->item->place() != IN_WHERE &&
 
1793
            tmp_unit->item->place() != IN_ON)))
1746
1794
      {
1747
1795
        selects_allow_merge= 0;
1748
1796
        break;
2039
2087
   FALSE - success
2040
2088
*/
2041
2089
 
2042
 
bool st_lex::add_time_zone_tables_to_query_tables(THD *thd)
 
2090
bool st_lex::add_time_zone_tables_to_query_tables(THD *thd_arg)
2043
2091
{
2044
2092
  /* We should not add these tables twice */
2045
2093
  if (!time_zone_tables_used)
2046
2094
  {
2047
 
    time_zone_tables_used= my_tz_get_table_list(thd, &query_tables_last);
 
2095
    time_zone_tables_used= my_tz_get_table_list(thd_arg, &query_tables_last);
2048
2096
    if (time_zone_tables_used == &fake_time_zone_tables_list)
2049
2097
      return TRUE;
2050
2098
  }