~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_lex.cc

  • Committer: David Shrewsbury
  • Date: 2010-09-21 19:25:33 UTC
  • mto: (1797.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1798.
  • Revision ID: shrewsbury.dave@gmail.com-20100921192533-4b1fjkun33r31pn5
Replace std::map with boost::unordered_map

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
 
17
17
/* A lexical scanner on a temporary buffer with a yacc interface */
44
44
*/
45
45
static bool add_to_list(Session *session, SQL_LIST &list, Item *item, bool asc)
46
46
{
47
 
  Order *order;
48
 
  if (!(order = (Order *) session->alloc(sizeof(Order))))
 
47
  order_st *order;
 
48
  if (!(order = (order_st *) session->alloc(sizeof(order_st))))
49
49
    return(1);
50
50
  order->item_ptr= item;
51
51
  order->item= &order->item_ptr;
206
206
  Because of this, it's critical to not do too much things here.
207
207
  (We already do too much here)
208
208
*/
209
 
void LEX::start(Session *arg)
210
 
{
211
 
  lex_start(arg);
212
 
}
213
 
 
214
209
void lex_start(Session *session)
215
210
{
216
211
  LEX *lex= session->lex;
270
265
  lex->reset();
271
266
}
272
267
 
273
 
void LEX::end()
 
268
void lex_end(LEX *lex)
274
269
{
275
 
  if (yacc_yyss)
 
270
  if (lex->yacc_yyss)
276
271
  {
277
 
    free(yacc_yyss);
278
 
    free(yacc_yyvs);
279
 
    yacc_yyss= 0;
280
 
    yacc_yyvs= 0;
 
272
    free(lex->yacc_yyss);
 
273
    free(lex->yacc_yyvs);
 
274
    lex->yacc_yyss= 0;
 
275
    lex->yacc_yyvs= 0;
281
276
  }
282
277
 
283
 
  delete result;
284
 
 
285
 
  result= 0;
286
 
  setCacheable(true);
287
 
 
288
 
  delete statement;
289
 
  statement= NULL;
 
278
  delete lex->result;
 
279
 
 
280
  lex->result= 0;
 
281
  lex->setCacheable(true);
 
282
 
 
283
  if (lex->statement) 
 
284
    delete lex->statement;
290
285
}
291
286
 
292
287
static int find_keyword(Lex_input_stream *lip, uint32_t len, bool function)
1304
1299
  options= 0;
1305
1300
  linkage= UNSPECIFIED_TYPE;
1306
1301
  no_error= no_table_names_allowed= 0;
1307
 
  uncacheable.reset();
 
1302
  uncacheable= 0;
1308
1303
}
1309
1304
 
1310
1305
void Select_Lex_Node::init_select()
1373
1368
  group_list.empty();
1374
1369
  db= 0;
1375
1370
  having= 0;
 
1371
  table_join_options= 0;
1376
1372
  in_sum_expr= with_wild= 0;
1377
1373
  options= 0;
1378
1374
  braces= 0;
1569
1565
       s && s != last;
1570
1566
       s= s->outer_select())
1571
1567
  {
1572
 
    if (! (s->uncacheable.test(UNCACHEABLE_DEPENDENT)))
 
1568
    if (!(s->uncacheable & UNCACHEABLE_DEPENDENT))
1573
1569
    {
1574
1570
      // Select is dependent of outer select
1575
 
      s->uncacheable.set(UNCACHEABLE_DEPENDENT);
1576
 
      s->uncacheable.set(UNCACHEABLE_UNITED);
 
1571
      s->uncacheable= (s->uncacheable & ~UNCACHEABLE_UNITED) |
 
1572
                       UNCACHEABLE_DEPENDENT;
1577
1573
      Select_Lex_Unit *munit= s->master_unit();
1578
 
      munit->uncacheable.set(UNCACHEABLE_UNITED);
1579
 
      munit->uncacheable.set(UNCACHEABLE_DEPENDENT);
 
1574
      munit->uncacheable= (munit->uncacheable & ~UNCACHEABLE_UNITED) |
 
1575
                       UNCACHEABLE_DEPENDENT;
1580
1576
      for (Select_Lex *sl= munit->first_select(); sl ; sl= sl->next_select())
1581
1577
      {
1582
1578
        if (sl != s &&
1583
 
            ! (sl->uncacheable.test(UNCACHEABLE_DEPENDENT) && sl->uncacheable.test(UNCACHEABLE_UNITED)))
1584
 
          sl->uncacheable.set(UNCACHEABLE_UNITED);
 
1579
            !(sl->uncacheable & (UNCACHEABLE_DEPENDENT | UNCACHEABLE_UNITED)))
 
1580
          sl->uncacheable|= UNCACHEABLE_UNITED;
1585
1581
      }
1586
1582
    }
1587
1583
    s->is_correlated= true;
1606
1602
List<Item>* Select_Lex_Node::get_item_list()
1607
1603
{ return NULL; }
1608
1604
 
1609
 
TableList *Select_Lex_Node::add_table_to_list(Session *, 
1610
 
                                              Table_ident *, 
1611
 
                                              LEX_STRING *, 
1612
 
                                              const bitset<NUM_OF_TABLE_OPTIONS>&,
1613
 
                                              thr_lock_type, 
1614
 
                                              List<Index_hint> *, 
1615
 
                                              LEX_STRING *)
 
1605
TableList *Select_Lex_Node::add_table_to_list (Session *, Table_ident *, LEX_STRING *, uint32_t,
 
1606
                                                  thr_lock_type, List<Index_hint> *, LEX_STRING *)
1616
1607
{
1617
1608
  return 0;
1618
1609
}
1619
1610
 
 
1611
uint32_t Select_Lex_Node::get_table_join_options()
 
1612
{
 
1613
  return 0;
 
1614
}
1620
1615
 
1621
1616
/*
1622
1617
  prohibit using LIMIT clause
1694
1689
  return &item_list;
1695
1690
}
1696
1691
 
 
1692
uint32_t Select_Lex::get_table_join_options()
 
1693
{
 
1694
  return table_join_options;
 
1695
}
1697
1696
 
1698
1697
bool Select_Lex::setup_ref_array(Session *session, uint32_t order_group_num)
1699
1698
{
1734
1733
      str->append(STRING_WITH_LEN(" order by "));
1735
1734
      fake_select_lex->print_order(
1736
1735
        str,
1737
 
        (Order *) fake_select_lex->order_list.first,
 
1736
        (order_st *) fake_select_lex->order_list.first,
1738
1737
        query_type);
1739
1738
    }
1740
1739
    fake_select_lex->print_limit(session, str, query_type);
1742
1741
}
1743
1742
 
1744
1743
void Select_Lex::print_order(String *str,
1745
 
                                Order *order,
 
1744
                                order_st *order,
1746
1745
                                enum_query_type query_type)
1747
1746
{
1748
1747
  for (; order; order= order->next)
1879
1878
  statement= NULL;
1880
1879
}
1881
1880
 
 
1881
/*
 
1882
  Detect that we need only table structure of derived table/view
 
1883
 
 
1884
  SYNOPSIS
 
1885
    only_view_structure()
 
1886
 
 
1887
  RETURN
 
1888
    true yes, we need only structure
 
1889
    false no, we need data
 
1890
*/
 
1891
bool LEX::only_view_structure()
 
1892
{
 
1893
  if (sql_command == SQLCOM_SHOW_CREATE)
 
1894
    return true;
 
1895
 
 
1896
  return false;
 
1897
}
 
1898
 
 
1899
/*
 
1900
  Should Items_ident be printed correctly
 
1901
 
 
1902
  SYNOPSIS
 
1903
    need_correct_ident()
 
1904
 
 
1905
  RETURN
 
1906
    true yes, we need only structure
 
1907
    false no, we need data
 
1908
*/
 
1909
bool LEX::need_correct_ident()
 
1910
{
 
1911
  if (sql_command== SQLCOM_SHOW_CREATE)
 
1912
    return true;
 
1913
 
 
1914
  return false;
 
1915
}
 
1916
 
1882
1917
/**
1883
1918
  This method should be called only during parsing.
1884
1919
  It is aware of compound statements (stored routine bodies)