~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_parse.cc

  • Committer: Olaf van der Spek
  • Date: 2011-03-10 12:49:38 UTC
  • mto: This revision was merged to the branch mainline in revision 2233.
  • Revision ID: olafvdspek@gmail.com-20110310124938-gwhzx3pq8ueg682n
Session::lex()

Show diffs side-by-side

added added

removed removed

Lines of Context:
169
169
                         can be zero.
170
170
 
171
171
  @todo
172
 
    set session->getLex()->sql_command to SQLCOM_END here.
 
172
    set session->lex().sql_command to SQLCOM_END here.
173
173
  @todo
174
174
    The following has to be changed to an 8 byte integer
175
175
 
188
188
  DRIZZLE_COMMAND_START(session->thread_id, command);
189
189
 
190
190
  session->command= command;
191
 
  session->getLex()->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */
 
191
  session->lex().sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */
192
192
  session->set_time();
193
193
  session->setQueryId(query_id.value());
194
194
 
202
202
    query_id.next();
203
203
  }
204
204
 
205
 
  /* @todo set session->getLex()->sql_command to SQLCOM_END here */
 
205
  /* @todo set session->lex().sql_command to SQLCOM_END here */
206
206
 
207
207
  plugin::Logging::preDo(session);
208
208
  if (unlikely(plugin::EventObserver::beforeStatement(*session)))
468
468
  bool res= false;
469
469
 
470
470
  /* first Select_Lex (have special meaning for many of non-SELECTcommands) */
471
 
  Select_Lex *select_lex= &session->getLex()->select_lex;
 
471
  Select_Lex *select_lex= &session->lex().select_lex;
472
472
 
473
473
  /* list of all tables in query */
474
474
  TableList *all_tables;
488
488
    assert(first_table == all_tables);
489
489
    assert(first_table == all_tables && first_table != 0);
490
490
  */
491
 
  session->getLex()->first_lists_tables_same();
 
491
  session->lex().first_lists_tables_same();
492
492
 
493
493
  /* should be assigned after making first tables same */
494
 
  all_tables= session->getLex()->query_tables;
 
494
  all_tables= session->lex().query_tables;
495
495
 
496
496
  /* set context for commands which do not use setup_tables */
497
497
  select_lex->context.resolve_in_table_list_only((TableList*)select_lex->table_list.first);
503
503
    variables, but for now this is probably good enough.
504
504
    Don't reset warnings when executing a stored routine.
505
505
  */
506
 
  if (all_tables || ! session->getLex()->is_single_level_stmt())
 
506
  if (all_tables || ! session->lex().is_single_level_stmt())
507
507
  {
508
508
    drizzle_reset_errors(session, 0);
509
509
  }
512
512
 
513
513
  if (! (session->server_status & SERVER_STATUS_AUTOCOMMIT)
514
514
      && ! session->inTransaction()
515
 
      && session->getLex()->statement->isTransactional())
 
515
      && session->lex().statement->isTransactional())
516
516
  {
517
517
    if (session->startTransaction() == false)
518
518
    {
522
522
  }
523
523
 
524
524
  /* now we are ready to execute the statement */
525
 
  res= session->getLex()->statement->execute();
 
525
  res= session->lex().statement->execute();
526
526
  session->set_proc_info("query end");
527
527
  /*
528
528
    The return value for ROW_COUNT() is "implementation dependent" if the
530
530
    wants. We also keep the last value in case of SQLCOM_CALL or
531
531
    SQLCOM_EXECUTE.
532
532
  */
533
 
  if (! (sql_command_flags[session->getLex()->sql_command].test(CF_BIT_HAS_ROW_COUNT)))
 
533
  if (! (sql_command_flags[session->lex().sql_command].test(CF_BIT_HAS_ROW_COUNT)))
534
534
  {
535
535
    session->row_count_func= -1;
536
536
  }
576
576
        return true;
577
577
      session->send_explain_fields(result);
578
578
      optimizer::ExplainPlan planner;
579
 
      res= planner.explainUnion(session, &session->getLex()->unit, result);
 
579
      res= planner.explainUnion(session, &session->lex().unit, result);
580
580
      if (lex->describe & DESCRIBE_EXTENDED)
581
581
      {
582
582
        char buff[1024];
583
583
        String str(buff,(uint32_t) sizeof(buff), system_charset_info);
584
584
        str.length(0);
585
 
        session->getLex()->unit.print(&str);
 
585
        session->lex().unit.print(&str);
586
586
        str.append('\0');
587
587
        push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
588
588
                     ER_YES, str.ptr());
780
780
 
781
781
void parse(Session *session, const char *inBuf, uint32_t length)
782
782
{
783
 
  session->getLex()->start(session);
 
783
  session->lex().start(session);
784
784
 
785
785
  session->reset_for_next_command();
786
786
  /* Check if the Query is Cached if and return true if yes
1351
1351
    */
1352
1352
    global_parameters= fake_select_lex;
1353
1353
    fake_select_lex->no_table_names_allowed= 1;
1354
 
    session_arg->getLex()->current_select= fake_select_lex;
 
1354
    session_arg->lex().current_select= fake_select_lex;
1355
1355
  }
1356
 
  session_arg->getLex()->pop_context();
 
1356
  session_arg->lex().pop_context();
1357
1357
  return(0);
1358
1358
}
1359
1359
 
1389
1389
    left_op->first_leaf_for_name_resolution();
1390
1390
  on_context->last_name_resolution_table=
1391
1391
    right_op->last_leaf_for_name_resolution();
1392
 
  return session->getLex()->push_context(on_context);
 
1392
  return session->lex().push_context(on_context);
1393
1393
}
1394
1394
 
1395
1395
 
1479
1479
 
1480
1480
bool check_simple_select(Session::pointer session)
1481
1481
{
1482
 
  if (session->getLex()->current_select != &session->getLex()->select_lex)
 
1482
  if (session->lex().current_select != &session->lex().select_lex)
1483
1483
  {
1484
1484
    char command[80];
1485
1485
    Lex_input_stream *lip= session->m_lip;
1539
1539
bool update_precheck(Session *session, TableList *)
1540
1540
{
1541
1541
  const char *msg= 0;
1542
 
  Select_Lex *select_lex= &session->getLex()->select_lex;
 
1542
  Select_Lex *select_lex= &session->lex().select_lex;
1543
1543
 
1544
 
  if (session->getLex()->select_lex.item_list.size() != session->getLex()->value_list.size())
 
1544
  if (session->lex().select_lex.item_list.size() != session->lex().value_list.size())
1545
1545
  {
1546
1546
    my_message(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0));
1547
1547
    return(true);
1548
1548
  }
1549
1549
 
1550
 
  if (session->getLex()->select_lex.table_list.size() > 1)
 
1550
  if (session->lex().select_lex.table_list.size() > 1)
1551
1551
  {
1552
1552
    if (select_lex->order_list.size())
1553
1553
      msg= "ORDER BY";
1581
1581
    Check that we have modify privileges for the first table and
1582
1582
    select privileges for the rest
1583
1583
  */
1584
 
  if (session->getLex()->update_list.size() != session->getLex()->value_list.size())
 
1584
  if (session->lex().update_list.size() != session->lex().value_list.size())
1585
1585
  {
1586
1586
    my_message(ER_WRONG_VALUE_COUNT, ER(ER_WRONG_VALUE_COUNT), MYF(0));
1587
1587
    return(true);
1608
1608
  {
1609
1609
    /* it is NOT(NOT( ... )) */
1610
1610
    Item *arg= ((Item_func *) expr)->arguments()[0];
1611
 
    enum_parsing_place place= session->getLex()->current_select->parsing_place;
 
1611
    enum_parsing_place place= session->lex().current_select->parsing_place;
1612
1612
    if (arg->is_bool_func() || place == IN_WHERE || place == IN_HAVING)
1613
1613
      return arg;
1614
1614
    /*