~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/filesystem_engine/filesystem_engine.cc

  • Committer: Brian Aker
  • Date: 2010-10-22 23:33:58 UTC
  • mfrom: (1869.1.7 refactor)
  • Revision ID: brian@tangent.org-20101022233358-kmtrpm1yvmmyaame
Merge in overhaul to how cursor and table are handled. Cursor now only knows
about table, and will always have a table and engine reference.

This cleans up a number of ownership issues, the biggest being that it now
creates the space needed for the next big refactor in locks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
    pthread_mutex_destroy(&filesystem_mutex);
75
75
  }
76
76
 
77
 
  virtual Cursor *create(TableShare &table)
 
77
  virtual Cursor *create(Table &table)
78
78
  {
79
79
    return new FilesystemCursor(*this, table);
80
80
  }
369
369
{
370
370
  Guard g(filesystem_mutex);
371
371
 
372
 
  FilesystemEngine *a_engine= static_cast<FilesystemEngine *>(engine);
 
372
  FilesystemEngine *a_engine= static_cast<FilesystemEngine *>(getEngine());
373
373
  share= a_engine->findOpenTable(table_name);
374
374
 
375
375
  /*
384
384
      return NULL;
385
385
    }
386
386
 
387
 
    share->format.parseFromTable(table->getShare()->getTableProto());
 
387
    share->format.parseFromTable(getTable()->getShare()->getTableProto());
388
388
    if (!share->format.isFileGiven())
389
389
    {
390
390
      return NULL;
414
414
  Guard g(filesystem_mutex);
415
415
 
416
416
  if (!--share->use_count){
417
 
    FilesystemEngine *a_engine= static_cast<FilesystemEngine *>(engine);
 
417
    FilesystemEngine *a_engine= static_cast<FilesystemEngine *>(getEngine());
418
418
    a_engine->deleteOpenTable(share->table_name);
419
419
    pthread_mutex_destroy(&share->mutex);
420
420
    delete share;
453
453
  thread_locked = false;
454
454
}
455
455
 
456
 
FilesystemCursor::FilesystemCursor(drizzled::plugin::StorageEngine &engine_arg, TableShare &table_arg)
 
456
FilesystemCursor::FilesystemCursor(drizzled::plugin::StorageEngine &engine_arg, Table &table_arg)
457
457
  : Cursor(engine_arg, table_arg),
458
458
    file_buff(new TransparentFile),
459
459
    thread_locked(false)
487
487
 
488
488
int FilesystemCursor::doStartTableScan(bool)
489
489
{
490
 
  sql_command_type = session_sql_command(table->getSession());
 
490
  sql_command_type = session_sql_command(getTable()->getSession());
491
491
 
492
492
  if (thread_locked)
493
493
    critical_section_exit();
515
515
 
516
516
int FilesystemCursor::find_current_row(unsigned char *buf)
517
517
{
518
 
  ptrdiff_t row_offset= buf - table->record[0];
 
518
  ptrdiff_t row_offset= buf - getTable()->record[0];
519
519
 
520
520
  next_position= current_position;
521
521
 
522
522
  string content;
523
523
  bool line_done= false;
524
524
  bool line_blank= true;
525
 
  Field **field= table->getFields();
 
525
  Field **field= getTable()->getFields();
526
526
  for (; !line_done && *field; ++next_position)
527
527
  {
528
528
    char ch= file_buff->get_value(next_position);
616
616
    if (tag_depth >= share->vm.size())
617
617
      return HA_ERR_END_OF_FILE;
618
618
 
619
 
    ptrdiff_t row_offset= buf - table->record[0];
620
 
    for (Field **field= table->getFields(); *field; field++)
 
619
    ptrdiff_t row_offset= buf - getTable()->record[0];
 
620
    for (Field **field= getTable()->getFields(); *field; field++)
621
621
    {
622
622
      string key((*field)->field_name);
623
623
      string content= share->vm[tag_depth][key];
696
696
 
697
697
int FilesystemCursor::doEndTableScan()
698
698
{
699
 
  sql_command_type = session_sql_command(table->getSession());
 
699
  sql_command_type = session_sql_command(getTable()->getSession());
700
700
 
701
701
  if (share->format.isTagFormat())
702
702
  {
784
784
{
785
785
  bool first= true;
786
786
  drizzled::String attribute;
787
 
  for (Field **field= table->getFields(); *field; ++field)
 
787
  for (Field **field= getTable()->getFields(); *field; ++field)
788
788
  {
789
789
    if (first == true)
790
790
    {
817
817
  if (share->format.isTagFormat())
818
818
    return 0;
819
819
 
820
 
  sql_command_type = session_sql_command(table->getSession());
 
820
  sql_command_type = session_sql_command(getTable()->getSession());
821
821
 
822
822
  critical_section_enter();
823
823