~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.cc

  • Committer: Brian Aker
  • Date: 2009-11-11 21:40:59 UTC
  • mfrom: (1208.3.3 reference)
  • mto: This revision was merged to the branch mainline in revision 1212.
  • Revision ID: brian@gaz-20091111214059-0xfxkwrrixpx2jd9
Update for cursor name change.

Show diffs side-by-side

added added

removed removed

Lines of Context:
108
108
 
109
109
 
110
110
/*
111
 
  Close file handle, but leave the table in the table cache
 
111
  Close cursor handle, but leave the table in the table cache
112
112
 
113
113
  SYNOPSIS
114
114
  close_handle_and_leave_table_as_lock()
149
149
    share->tmp_table= INTERNAL_TMP_TABLE;       // for intern_close_table()
150
150
  }
151
151
 
152
 
  table->file->close();
153
 
  table->db_stat= 0;                            // Mark file closed
 
152
  table->cursor->close();
 
153
  table->db_stat= 0;                            // Mark cursor closed
154
154
  TableShare::release(table->s);
155
155
  table->s= share;
156
 
  table->file->change_table_ptr(table, table->s);
 
156
  table->cursor->change_table_ptr(table, table->s);
157
157
}
158
158
 
159
159
 
240
240
void Table::intern_close_table()
241
241
{                                               // Free all structures
242
242
  free_io_cache();
243
 
  if (file)                              // Not true if name lock
244
 
    closefrm(true);                     // close file
 
243
  if (cursor)                              // Not true if name lock
 
244
    closefrm(true);                     // close cursor
245
245
}
246
246
 
247
247
/*
465
465
 
466
466
  safe_mutex_assert_owner(&LOCK_open);
467
467
  assert(table->key_read == 0);
468
 
  assert(!table->file || table->file->inited == Cursor::NONE);
 
468
  assert(!table->cursor || table->cursor->inited == Cursor::NONE);
469
469
 
470
470
  open_tables= table->next;
471
471
 
484
484
    assert(!table->open_placeholder);
485
485
 
486
486
    /* Free memory and reset for next loop */
487
 
    table->file->ha_reset();
 
487
    table->cursor->ha_reset();
488
488
    table->in_use= false;
489
489
 
490
490
    if (unused_tables)
922
922
  /*
923
923
    We want to prevent other connections from opening this table until end
924
924
    of statement as it is likely that modifications of table's metadata are
925
 
    not yet finished (for example CREATE TRIGGER have to change .TRG file,
 
925
    not yet finished (for example CREATE TRIGGER have to change .TRG cursor,
926
926
    or we might want to drop table if CREATE TABLE ... SELECT fails).
927
927
    This also allows us to assume that no other connection will sneak in
928
928
    before we will get table-level lock on this table.
1415
1415
  table Table object
1416
1416
 
1417
1417
  NOTES
1418
 
  The data file for the table is already closed and the share is released
 
1418
  The data cursor for the table is already closed and the share is released
1419
1419
  The table has a 'dummy' share that mainly contains database and table name.
1420
1420
 
1421
1421
  RETURN
1469
1469
  tmp.next=             table->next;
1470
1470
  tmp.prev=             table->prev;
1471
1471
 
1472
 
  if (table->file)
1473
 
    table->closefrm(true);              // close file, free everything
 
1472
  if (table->cursor)
 
1473
    table->closefrm(true);              // close cursor, free everything
1474
1474
 
1475
1475
  *table= tmp;
1476
1476
  table->default_column_bitmaps();
1477
 
  table->file->change_table_ptr(table, table->s);
 
1477
  table->cursor->change_table_ptr(table, table->s);
1478
1478
 
1479
1479
  assert(table->alias != 0);
1480
1480
  for (field=table->field ; *field ; field++)
1864
1864
        if (table->db_stat)
1865
1865
        {
1866
1866
          table->db_stat= 0;
1867
 
          table->file->close();
 
1867
          table->cursor->close();
1868
1868
        }
1869
1869
      }
1870
1870
      else
1909
1909
}
1910
1910
 
1911
1911
/*
1912
 
  Load a table definition from file and open unireg table
 
1912
  Load a table definition from cursor and open unireg table
1913
1913
 
1914
1914
  SYNOPSIS
1915
1915
  open_unireg_entry()
1993
1993
    }
1994
1994
    if (!entry->s || !entry->s->crashed)
1995
1995
      goto err;
1996
 
    // Code below is for repairing a crashed file
 
1996
    // Code below is for repairing a crashed cursor
1997
1997
    if ((error= lock_table_name(session, table_list, true)))
1998
1998
    {
1999
1999
      if (error < 0)
2013
2013
                                          HA_TRY_READ_ONLY),
2014
2014
                              EXTRA_RECORD,
2015
2015
                              ha_open_options | HA_OPEN_FOR_REPAIR,
2016
 
                              entry, OTM_OPEN) || ! entry->file)
 
2016
                              entry, OTM_OPEN) || ! entry->cursor)
2017
2017
    {
2018
2018
      /* Give right error message */
2019
2019
      session->clear_error();
2020
2020
      my_error(ER_NOT_KEYFILE, MYF(0), share->table_name.str, my_errno);
2021
2021
      errmsg_printf(ERRMSG_LVL_ERROR, _("Couldn't repair table: %s.%s"), share->db.str,
2022
2022
                    share->table_name.str);
2023
 
      if (entry->file)
 
2023
      if (entry->cursor)
2024
2024
        entry->closefrm(false);
2025
2025
      error=1;
2026
2026
    }
2038
2038
    If we are here, there was no fatal error (but error may be still
2039
2039
    unitialized).
2040
2040
  */
2041
 
  if (unlikely(entry->file->implicit_emptied))
 
2041
  if (unlikely(entry->cursor->implicit_emptied))
2042
2042
  {
2043
2043
    ReplicationServices &replication_services= ReplicationServices::singleton();
2044
 
    entry->file->implicit_emptied= 0;
 
2044
    entry->cursor->implicit_emptied= 0;
2045
2045
    {
2046
2046
      char *query, *end;
2047
2047
      uint32_t query_buf_size= 20 + share->db.length + share->table_name.length +1;
2403
2403
    share->tmp_table= TMP_TABLE_FRM_FILE_ONLY;
2404
2404
  }
2405
2405
  else
2406
 
    share->tmp_table= (new_tmp_table->file->has_transactions() ?
 
2406
    share->tmp_table= (new_tmp_table->cursor->has_transactions() ?
2407
2407
                       TRANSACTIONAL_TMP_TABLE : NON_TRANSACTIONAL_TMP_TABLE);
2408
2408
 
2409
2409
  if (link_in_list)