~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_parse.cc

  • Committer: Brian Aker
  • Date: 2010-08-13 17:44:18 UTC
  • mto: This revision was merged to the branch mainline in revision 1709.
  • Revision ID: brian@tangent.org-20100813174418-pq2wr6r6f2okx3gb
Remove myisam_data_pointer_siz

Show diffs side-by-side

added added

removed removed

Lines of Context:
182
182
    break;
183
183
  /* Increase id and count all other statements. */
184
184
  default:
185
 
    statistic_increment(session->status_var.questions, &LOCK_status);
 
185
    session->status_var.questions++;
186
186
    query_id.next();
187
187
  }
188
188
 
195
195
  switch (command) {
196
196
  case COM_INIT_DB:
197
197
  {
198
 
    status_var_increment(session->status_var.com_stat[SQLCOM_CHANGE_DB]);
199
198
    if (packet_length == 0)
200
199
    {
201
200
      my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
232
231
    break;
233
232
  case COM_SHUTDOWN:
234
233
  {
235
 
    status_var_increment(session->status_var.com_other);
 
234
    session->status_var.com_other++;
236
235
    session->my_eof();
237
236
    session->close_thread_tables();                     // Free before kill
238
237
    kill_drizzle();
240
239
    break;
241
240
  }
242
241
  case COM_PING:
243
 
    status_var_increment(session->status_var.com_other);
 
242
    session->status_var.com_other++;
244
243
    session->my_ok();                           // Tell client we are alive
245
244
    break;
246
245
  case COM_SLEEP:
254
253
  /* If commit fails, we should be able to reset the OK status. */
255
254
  session->main_da.can_overwrite_status= true;
256
255
  TransactionServices &transaction_services= TransactionServices::singleton();
257
 
  transaction_services.ha_autocommit_or_rollback(session, session->is_error());
 
256
  transaction_services.autocommitOrRollback(session, session->is_error());
258
257
  session->main_da.can_overwrite_status= false;
259
258
 
260
259
  session->transaction.stmt.reset();
269
268
  if (session->killed == Session::KILL_QUERY || session->killed == Session::KILL_BAD_DATA)
270
269
  {
271
270
    session->killed= Session::NOT_KILLED;
272
 
    session->mysys_var->abort= 0;
 
271
    session->setAbort(false);
273
272
  }
274
273
 
275
274
  /* Can not be true, but do not take chances in production. */
315
314
  session->query.clear();
316
315
 
317
316
  session->set_proc_info(NULL);
318
 
  free_root(session->mem_root,MYF(memory::KEEP_PREALLOC));
 
317
  session->mem_root->free_root(MYF(memory::KEEP_PREALLOC));
319
318
 
320
319
  if (DRIZZLE_QUERY_DONE_ENABLED() || DRIZZLE_COMMAND_DONE_ENABLED())
321
320
  {
473
472
    drizzle_reset_errors(session, 0);
474
473
  }
475
474
 
476
 
  status_var_increment(session->status_var.com_stat[lex->sql_command]);
477
 
 
478
475
  assert(session->transaction.stmt.hasModifiedNonTransData() == false);
479
476
 
480
477
  /* now we are ready to execute the statement */
715
712
 
716
713
void mysql_parse(Session *session, const char *inBuf, uint32_t length)
717
714
{
 
715
  uint64_t start_time= my_getsystime();
718
716
  lex_start(session);
719
717
  session->reset_for_next_command();
720
718
 
732
730
        DRIZZLE_QUERY_EXEC_START(session->query.c_str(),
733
731
                                 session->thread_id,
734
732
                                 const_cast<const char *>(session->db.empty() ? "" : session->db.c_str()));
 
733
        // Implement Views here --Brian
 
734
 
735
735
        /* Actually execute the query */
736
 
        mysql_execute_command(session);
 
736
        try {
 
737
          mysql_execute_command(session);
 
738
        }
 
739
        catch (...)
 
740
        {
 
741
          // Just try to catch any random failures that could have come
 
742
          // during execution.
 
743
        }
737
744
        DRIZZLE_QUERY_EXEC_DONE(0);
738
745
      }
739
746
    }
747
754
  session->set_proc_info("freeing items");
748
755
  session->end_statement();
749
756
  session->cleanup_after_query();
750
 
 
751
 
  return;
 
757
  session->status_var.execution_time_nsec+= my_getsystime() - start_time;
752
758
}
753
759
 
754
760
 
902
908
  {
903
909
    my_casedn_str(files_charset_info, table->db.str);
904
910
 
905
 
    SchemaIdentifier schema_identifier(string(table->db.str, table->db.length));
906
 
    if (not check_db_name(schema_identifier))
 
911
    SchemaIdentifier schema_identifier(string(table->db.str));
 
912
    if (not check_db_name(session, schema_identifier))
907
913
    {
908
914
 
909
915
      my_error(ER_WRONG_DB_NAME, MYF(0), table->db.str);
924
930
  }
925
931
  if (!(ptr = (TableList *) session->calloc(sizeof(TableList))))
926
932
    return NULL;
 
933
 
927
934
  if (table->db.str)
928
935
  {
929
 
    ptr->is_fqtn= true;
 
936
    ptr->setIsFqtn(true);
930
937
    ptr->db= table->db.str;
931
938
    ptr->db_length= table->db.length;
932
939
  }
933
940
  else if (lex->copy_db_to(&ptr->db, &ptr->db_length))
934
941
    return NULL;
935
942
  else
936
 
    ptr->is_fqtn= false;
 
943
    ptr->setIsFqtn(false);
937
944
 
938
945
  ptr->alias= alias_str;
939
 
  ptr->is_alias= alias ? true : false;
 
946
  ptr->setIsAlias(alias ? true : false);
940
947
  if (table->table.length)
941
948
    table->table.length= my_casedn_str(files_charset_info, table->table.str);
942
949
  ptr->table_name=table->table.str;
1026
1033
  if (!(ptr= (TableList*) session->calloc(ALIGN_SIZE(sizeof(TableList))+
1027
1034
                                       sizeof(nested_join_st))))
1028
1035
    return true;
1029
 
  nested_join= ptr->nested_join=
1030
 
    ((nested_join_st*) ((unsigned char*) ptr + ALIGN_SIZE(sizeof(TableList))));
1031
 
 
 
1036
  ptr->setNestedJoin(((nested_join_st*) ((unsigned char*) ptr + ALIGN_SIZE(sizeof(TableList)))));
 
1037
  nested_join= ptr->getNestedJoin();
1032
1038
  join_list->push_front(ptr);
1033
 
  ptr->embedding= embedding;
1034
 
  ptr->join_list= join_list;
 
1039
  ptr->setEmbedding(embedding);
 
1040
  ptr->setJoinList(join_list);
1035
1041
  ptr->alias= (char*) "(nested_join)";
1036
1042
  embedding= ptr;
1037
1043
  join_list= &nested_join->join_list;
1061
1067
 
1062
1068
  assert(embedding);
1063
1069
  ptr= embedding;
1064
 
  join_list= ptr->join_list;
1065
 
  embedding= ptr->embedding;
1066
 
  nested_join= ptr->nested_join;
 
1070
  join_list= ptr->getJoinList();
 
1071
  embedding= ptr->getEmbedding();
 
1072
  nested_join= ptr->getNestedJoin();
1067
1073
  if (nested_join->join_list.elements == 1)
1068
1074
  {
1069
1075
    TableList *embedded= nested_join->join_list.head();
1070
1076
    join_list->pop();
1071
 
    embedded->join_list= join_list;
1072
 
    embedded->embedding= embedding;
 
1077
    embedded->setJoinList(join_list);
 
1078
    embedded->setEmbedding(embedding);
1073
1079
    join_list->push_front(embedded);
1074
1080
    ptr= embedded;
1075
1081
  }
1102
1108
  List<TableList> *embedded_list;
1103
1109
 
1104
1110
  if (!(ptr= (TableList*) session->calloc(ALIGN_SIZE(sizeof(TableList))+
1105
 
                                       sizeof(nested_join_st))))
 
1111
                                          sizeof(nested_join_st))))
1106
1112
    return NULL;
1107
 
  nested_join= ptr->nested_join=
1108
 
    ((nested_join_st*) ((unsigned char*) ptr + ALIGN_SIZE(sizeof(TableList))));
1109
 
 
1110
 
  ptr->embedding= embedding;
1111
 
  ptr->join_list= join_list;
 
1113
  ptr->setNestedJoin(((nested_join_st*) ((unsigned char*) ptr + ALIGN_SIZE(sizeof(TableList)))));
 
1114
  nested_join= ptr->getNestedJoin();
 
1115
  ptr->setEmbedding(embedding);
 
1116
  ptr->setJoinList(join_list);
1112
1117
  ptr->alias= (char*) "(nest_last_join)";
1113
1118
  embedded_list= &nested_join->join_list;
1114
1119
  embedded_list->empty();
1116
1121
  for (uint32_t i=0; i < 2; i++)
1117
1122
  {
1118
1123
    TableList *table= join_list->pop();
1119
 
    table->join_list= embedded_list;
1120
 
    table->embedding= ptr;
 
1124
    table->setJoinList(embedded_list);
 
1125
    table->setEmbedding(ptr);
1121
1126
    embedded_list->push_back(table);
1122
1127
    if (table->natural_join)
1123
1128
    {
1153
1158
void Select_Lex::add_joined_table(TableList *table)
1154
1159
{
1155
1160
  join_list->push_front(table);
1156
 
  table->join_list= join_list;
1157
 
  table->embedding= embedding;
 
1161
  table->setJoinList(join_list);
 
1162
  table->setEmbedding(embedding);
1158
1163
}
1159
1164
 
1160
1165
 
1412
1417
{
1413
1418
  Session *tmp= NULL;
1414
1419
  uint32_t error= ER_NO_SUCH_THREAD;
1415
 
  pthread_mutex_lock(&LOCK_thread_count); // For unlink from list
 
1420
  LOCK_thread_count.lock(); // For unlink from list
1416
1421
  
1417
1422
  for (SessionList::iterator it= getSessionList().begin(); it != getSessionList().end(); ++it )
1418
1423
  {
1419
1424
    if ((*it)->thread_id == id)
1420
1425
    {
1421
1426
      tmp= *it;
1422
 
      pthread_mutex_lock(&tmp->LOCK_delete);    // Lock from delete
 
1427
      tmp->lockForDelete();
1423
1428
      break;
1424
1429
    }
1425
1430
  }
1426
 
  pthread_mutex_unlock(&LOCK_thread_count);
 
1431
  LOCK_thread_count.unlock();
1427
1432
  if (tmp)
1428
1433
  {
1429
1434
 
1433
1438
      error= 0;
1434
1439
    }
1435
1440
 
1436
 
    pthread_mutex_unlock(&tmp->LOCK_delete);
 
1441
    tmp->unlockForDelete();
1437
1442
  }
1438
1443
  return(error);
1439
1444
}