~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_lex.cc

  • Committer: Brian Aker
  • Date: 2010-11-08 18:54:26 UTC
  • mto: (1921.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 1916.
  • Revision ID: brian@tangent.org-20101108185426-fymkf2xnelupf11x
Rename lock methods to be style + well make sense.

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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
16
 
17
17
/* A lexical scanner on a temporary buffer with a yacc interface */
26
26
#include "drizzled/lookup_symbol.h"
27
27
#include "drizzled/index_hint.h"
28
28
 
 
29
#include <cstdio>
29
30
#include <ctype.h>
30
31
 
31
32
using namespace std;
43
44
*/
44
45
static bool add_to_list(Session *session, SQL_LIST &list, Item *item, bool asc)
45
46
{
46
 
  order_st *order;
47
 
  if (!(order = (order_st *) session->alloc(sizeof(order_st))))
 
47
  Order *order;
 
48
  if (!(order = (Order *) session->alloc(sizeof(Order))))
48
49
    return(1);
49
50
  order->item_ptr= item;
50
51
  order->item= &order->item_ptr;
205
206
  Because of this, it's critical to not do too much things here.
206
207
  (We already do too much here)
207
208
*/
 
209
void LEX::start(Session *arg)
 
210
{
 
211
  lex_start(arg);
 
212
}
 
213
 
208
214
void lex_start(Session *session)
209
215
{
210
216
  LEX *lex= session->lex;
258
264
 
259
265
  lex->is_lex_started= true;
260
266
  lex->statement= NULL;
 
267
  
 
268
  lex->is_cross= false;
 
269
 
 
270
  lex->reset();
261
271
}
262
272
 
263
 
void lex_end(LEX *lex)
 
273
void LEX::end()
264
274
{
265
 
  if (lex->yacc_yyss)
 
275
  if (yacc_yyss)
266
276
  {
267
 
    free(lex->yacc_yyss);
268
 
    free(lex->yacc_yyvs);
269
 
    lex->yacc_yyss= 0;
270
 
    lex->yacc_yyvs= 0;
 
277
    free(yacc_yyss);
 
278
    free(yacc_yyvs);
 
279
    yacc_yyss= 0;
 
280
    yacc_yyvs= 0;
271
281
  }
272
282
 
273
 
  delete lex->result;
274
 
 
275
 
  lex->result= 0;
276
 
 
277
 
  if (lex->statement) 
278
 
    delete lex->statement;
 
283
  delete result;
 
284
 
 
285
  result= 0;
 
286
  setCacheable(true);
 
287
 
 
288
  delete statement;
 
289
  statement= NULL;
279
290
}
280
291
 
281
292
static int find_keyword(Lex_input_stream *lip, uint32_t len, bool function)
1293
1304
  options= 0;
1294
1305
  linkage= UNSPECIFIED_TYPE;
1295
1306
  no_error= no_table_names_allowed= 0;
1296
 
  uncacheable= 0;
 
1307
  uncacheable.reset();
1297
1308
}
1298
1309
 
1299
1310
void Select_Lex_Node::init_select()
1362
1373
  group_list.empty();
1363
1374
  db= 0;
1364
1375
  having= 0;
1365
 
  table_join_options= 0;
1366
1376
  in_sum_expr= with_wild= 0;
1367
1377
  options= 0;
1368
1378
  braces= 0;
1559
1569
       s && s != last;
1560
1570
       s= s->outer_select())
1561
1571
  {
1562
 
    if (!(s->uncacheable & UNCACHEABLE_DEPENDENT))
 
1572
    if (! (s->uncacheable.test(UNCACHEABLE_DEPENDENT)))
1563
1573
    {
1564
1574
      // Select is dependent of outer select
1565
 
      s->uncacheable= (s->uncacheable & ~UNCACHEABLE_UNITED) |
1566
 
                       UNCACHEABLE_DEPENDENT;
 
1575
      s->uncacheable.set(UNCACHEABLE_DEPENDENT);
 
1576
      s->uncacheable.set(UNCACHEABLE_UNITED);
1567
1577
      Select_Lex_Unit *munit= s->master_unit();
1568
 
      munit->uncacheable= (munit->uncacheable & ~UNCACHEABLE_UNITED) |
1569
 
                       UNCACHEABLE_DEPENDENT;
 
1578
      munit->uncacheable.set(UNCACHEABLE_UNITED);
 
1579
      munit->uncacheable.set(UNCACHEABLE_DEPENDENT);
1570
1580
      for (Select_Lex *sl= munit->first_select(); sl ; sl= sl->next_select())
1571
1581
      {
1572
1582
        if (sl != s &&
1573
 
            !(sl->uncacheable & (UNCACHEABLE_DEPENDENT | UNCACHEABLE_UNITED)))
1574
 
          sl->uncacheable|= UNCACHEABLE_UNITED;
 
1583
            ! (sl->uncacheable.test(UNCACHEABLE_DEPENDENT) && sl->uncacheable.test(UNCACHEABLE_UNITED)))
 
1584
          sl->uncacheable.set(UNCACHEABLE_UNITED);
1575
1585
      }
1576
1586
    }
1577
1587
    s->is_correlated= true;
1596
1606
List<Item>* Select_Lex_Node::get_item_list()
1597
1607
{ return NULL; }
1598
1608
 
1599
 
TableList *Select_Lex_Node::add_table_to_list (Session *, Table_ident *, LEX_STRING *, uint32_t,
1600
 
                                                  thr_lock_type, List<Index_hint> *, LEX_STRING *)
 
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 *)
1601
1616
{
1602
1617
  return 0;
1603
1618
}
1604
1619
 
1605
 
uint32_t Select_Lex_Node::get_table_join_options()
1606
 
{
1607
 
  return 0;
1608
 
}
1609
1620
 
1610
1621
/*
1611
1622
  prohibit using LIMIT clause
1683
1694
  return &item_list;
1684
1695
}
1685
1696
 
1686
 
uint32_t Select_Lex::get_table_join_options()
1687
 
{
1688
 
  return table_join_options;
1689
 
}
1690
1697
 
1691
1698
bool Select_Lex::setup_ref_array(Session *session, uint32_t order_group_num)
1692
1699
{
1727
1734
      str->append(STRING_WITH_LEN(" order by "));
1728
1735
      fake_select_lex->print_order(
1729
1736
        str,
1730
 
        (order_st *) fake_select_lex->order_list.first,
 
1737
        (Order *) fake_select_lex->order_list.first,
1731
1738
        query_type);
1732
1739
    }
1733
1740
    fake_select_lex->print_limit(session, str, query_type);
1735
1742
}
1736
1743
 
1737
1744
void Select_Lex::print_order(String *str,
1738
 
                                order_st *order,
 
1745
                                Order *order,
1739
1746
                                enum_query_type query_type)
1740
1747
{
1741
1748
  for (; order; order= order->next)
1857
1864
    for this.
1858
1865
*/
1859
1866
LEX::LEX()
1860
 
  :result(0), yacc_yyss(0), yacc_yyvs(0),
1861
 
   sql_command(SQLCOM_END), option_type(OPT_DEFAULT), is_lex_started(0)
 
1867
  :
 
1868
    result(0), 
 
1869
    yacc_yyss(0), 
 
1870
    yacc_yyvs(0),
 
1871
    charset(NULL),
 
1872
    sql_command(SQLCOM_END), 
 
1873
    option_type(OPT_DEFAULT), 
 
1874
    is_lex_started(0),
 
1875
    cacheable(true),
 
1876
    sum_expr_used(false)
1862
1877
{
1863
1878
  reset_query_tables_list(true);
1864
1879
  statement= NULL;
1865
1880
}
1866
1881
 
1867
 
/*
1868
 
  Detect that we need only table structure of derived table/view
1869
 
 
1870
 
  SYNOPSIS
1871
 
    only_view_structure()
1872
 
 
1873
 
  RETURN
1874
 
    true yes, we need only structure
1875
 
    false no, we need data
1876
 
*/
1877
 
bool LEX::only_view_structure()
1878
 
{
1879
 
  if (sql_command == SQLCOM_SHOW_CREATE)
1880
 
    return true;
1881
 
 
1882
 
  return false;
1883
 
}
1884
 
 
1885
 
/*
1886
 
  Should Items_ident be printed correctly
1887
 
 
1888
 
  SYNOPSIS
1889
 
    need_correct_ident()
1890
 
 
1891
 
  RETURN
1892
 
    true yes, we need only structure
1893
 
    false no, we need data
1894
 
*/
1895
 
bool LEX::need_correct_ident()
1896
 
{
1897
 
  if (sql_command== SQLCOM_SHOW_CREATE)
1898
 
    return true;
1899
 
 
1900
 
  return false;
1901
 
}
1902
 
 
1903
1882
/**
1904
1883
  This method should be called only during parsing.
1905
1884
  It is aware of compound statements (stored routine bodies)