~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/log_event.cc

  • Committer: Brian Aker
  • Date: 2008-08-16 22:34:15 UTC
  • mto: This revision was merged to the branch mainline in revision 346.
  • Revision ID: brian@tangent.org-20080816223415-n24esdpfcqi4pwpy
Refactor around classes. TABLE_LIST has been factored out of table.h

Show diffs side-by-side

added added

removed removed

Lines of Context:
117
117
*/
118
118
static void inline slave_rows_error_report(enum loglevel level, int ha_error,
119
119
                                           Relay_log_info const *rli, THD *thd,
120
 
                                           TABLE *table, const char * type,
 
120
                                           Table *table, const char * type,
121
121
                                           const char *log_name, ulong pos)
122
122
{
123
123
  const char *handler_error= HA_ERR(ha_error);
2367
2367
    probably, so data_buf will be freed, so the thd->... listed above will be
2368
2368
    pointers to freed memory. 
2369
2369
    So we must set them to 0, so that those bad pointers values are not later
2370
 
    used. Note that "cleanup" queries like automatic DROP TEMPORARY TABLE
 
2370
    used. Note that "cleanup" queries like automatic DROP TEMPORARY Table
2371
2371
    don't suffer from these assignments to 0 as DROP TEMPORARY
2372
 
    TABLE uses the db.table syntax.
 
2372
    Table uses the db.table syntax.
2373
2373
  */
2374
2374
  thd->catalog= 0;
2375
2375
  thd->set_db(NULL, 0);                 /* will free the current database */
2561
2561
 
2562
2562
    IMPLEMENTATION
2563
2563
    - To handle the case where the master died without having time to write
2564
 
    DROP TEMPORARY TABLE, DO RELEASE_LOCK (prepared statements' deletion is
 
2564
    DROP TEMPORARY Table, DO RELEASE_LOCK (prepared statements' deletion is
2565
2565
    TODO), we clean up all temporary tables that we got, if we are sure we
2566
2566
    can (see below).
2567
2567
 
3030
3030
    18 + fname_len + 2 +                    // "LOAD DATA INFILE 'file''"
3031
3031
    7 +                                     // LOCAL
3032
3032
    9 +                                     // " REPLACE or IGNORE "
3033
 
    13 + table_name_len*2 +                 // "INTO TABLE `table`"
 
3033
    13 + table_name_len*2 +                 // "INTO Table `table`"
3034
3034
    21 + sql_ex.field_term_len*4 + 2 +      // " FIELDS TERMINATED BY 'str'"
3035
3035
    23 + sql_ex.enclosed_len*4 + 2 +        // " OPTIONALLY ENCLOSED BY 'str'"
3036
3036
    12 + sql_ex.escaped_len*4 + 2 +         // " ESCAPED BY 'str'"
3074
3074
  if (fn_end)
3075
3075
    *fn_end= pos;
3076
3076
 
3077
 
  pos= stpcpy(pos ," TABLE `");
 
3077
  pos= stpcpy(pos ," Table `");
3078
3078
  memcpy(pos, table_name, table_name_len);
3079
3079
  pos+= table_name_len;
3080
3080
 
3399
3399
  else if (sql_ex.opt_flags & IGNORE_FLAG)
3400
3400
    my_b_printf(&cache," IGNORE ");
3401
3401
  
3402
 
  my_b_printf(&cache, "INTO TABLE `%s`", table_name);
 
3402
  my_b_printf(&cache, "INTO Table `%s`", table_name);
3403
3403
  my_b_printf(&cache, " FIELDS TERMINATED BY ");
3404
3404
  pretty_print_str(&cache, sql_ex.field_term, sql_ex.field_term_len);
3405
3405
 
4845
4845
/*
4846
4846
  The master stopped.  We used to clean up all temporary tables but
4847
4847
  this is useless as, as the master has shut down properly, it has
4848
 
  written all DROP TEMPORARY TABLE (prepared statements' deletion is
 
4848
  written all DROP TEMPORARY Table (prepared statements' deletion is
4849
4849
  TODO only when we binlog prep stmts).  We used to clean up
4850
4850
  slave_load_tmpdir, but this is useless as it has been cleared at the
4851
4851
  end of LOAD DATA INFILE.  So we have nothing to do here.  The place
5884
5884
**************************************************************************/
5885
5885
 
5886
5886
#ifndef DRIZZLE_CLIENT
5887
 
Rows_log_event::Rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid,
 
5887
Rows_log_event::Rows_log_event(THD *thd_arg, Table *tbl_arg, ulong tid,
5888
5888
                               MY_BITMAP const *cols, bool is_transactional)
5889
5889
  : Log_event(thd_arg, 0, is_transactional),
5890
5890
    m_row_count(0),
6289
6289
    }
6290
6290
  }
6291
6291
 
6292
 
  TABLE* 
 
6292
  Table* 
6293
6293
    table= 
6294
6294
    m_table= const_cast<Relay_log_info*>(rli)->m_table_map.get_table(m_table_id);
6295
6295
 
6760
6760
  (tbl->s->db etc) and not pointer content.
6761
6761
 */
6762
6762
#if !defined(DRIZZLE_CLIENT)
6763
 
Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid,
 
6763
Table_map_log_event::Table_map_log_event(THD *thd, Table *tbl, ulong tid,
6764
6764
                                         bool is_transactional __attribute__((unused)),
6765
6765
                                         uint16_t flags)
6766
6766
  : Log_event(thd, 0, true),
7196
7196
  Constructor used to build an event for writing to the binary log.
7197
7197
 */
7198
7198
#if !defined(DRIZZLE_CLIENT)
7199
 
Write_rows_log_event::Write_rows_log_event(THD *thd_arg, TABLE *tbl_arg,
 
7199
Write_rows_log_event::Write_rows_log_event(THD *thd_arg, Table *tbl_arg,
7200
7200
                                           ulong tid_arg,
7201
7201
                                           bool is_transactional)
7202
7202
  : Rows_log_event(thd_arg, tbl_arg, tid_arg, tbl_arg->write_set, is_transactional)
7300
7300
  Check if there are more UNIQUE keys after the given key.
7301
7301
*/
7302
7302
static int
7303
 
last_uniq_key(TABLE *table, uint keyno)
 
7303
last_uniq_key(Table *table, uint keyno)
7304
7304
{
7305
7305
  while (++keyno < table->s->keys)
7306
7306
    if (table->key_info[keyno].flags & HA_NOSAME)
7374
7374
{
7375
7375
  assert(m_table != NULL && thd != NULL);
7376
7376
 
7377
 
  TABLE *table= m_table;  // pointer to event's table
 
7377
  Table *table= m_table;  // pointer to event's table
7378
7378
  int error;
7379
7379
  int keynum;
7380
7380
  auto_afree_ptr<char> key(NULL);
7581
7581
 
7582
7582
  Returns TRUE if different.
7583
7583
*/
7584
 
static bool record_compare(TABLE *table)
 
7584
static bool record_compare(Table *table)
7585
7585
{
7586
7586
  /*
7587
7587
    Need to set the X bit and the filler bits in both records since
7684
7684
{
7685
7685
  assert(m_table && m_table->in_use != NULL);
7686
7686
 
7687
 
  TABLE *table= m_table;
 
7687
  Table *table= m_table;
7688
7688
  int error;
7689
7689
 
7690
7690
  /* unpack row - missing fields get default values */
7879
7879
 */
7880
7880
 
7881
7881
#ifndef DRIZZLE_CLIENT
7882
 
Delete_rows_log_event::Delete_rows_log_event(THD *thd_arg, TABLE *tbl_arg,
 
7882
Delete_rows_log_event::Delete_rows_log_event(THD *thd_arg, Table *tbl_arg,
7883
7883
                                             ulong tid,
7884
7884
                                             bool is_transactional)
7885
7885
  : Rows_log_event(thd_arg, tbl_arg, tid, tbl_arg->read_set, is_transactional)
7970
7970
  Constructor used to build an event for writing to the binary log.
7971
7971
 */
7972
7972
#if !defined(DRIZZLE_CLIENT)
7973
 
Update_rows_log_event::Update_rows_log_event(THD *thd_arg, TABLE *tbl_arg,
 
7973
Update_rows_log_event::Update_rows_log_event(THD *thd_arg, Table *tbl_arg,
7974
7974
                                             ulong tid,
7975
7975
                                             bool is_transactional)
7976
7976
: Rows_log_event(thd_arg, tbl_arg, tid, tbl_arg->read_set, is_transactional)