~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/csv/ha_tina.cc

[patch 106/129] Merge patch for revision 1915 from InnoDB SVN:
revno: 1915
revision-id: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6130
parent: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6126
committer: marko
timestamp: Mon 2009-11-02 09:42:56 +0000
message:
  branches/zip: Free all resources at shutdown. Set pointers to NULL, so
  that Valgrind will not complain about freed data structures that are
  reachable via pointers.  This addresses Bug #45992 and Bug #46656.
  
  This patch is mostly based on changes copied from branches/embedded-1.0,
  mainly c5432, c3439, c3134, c2994, c2978, but also some other code was
  copied.  Some added cleanup code is specific to MySQL/InnoDB.
  
  rb://199 approved by Sunny Bains
modified:
  ChangeLog                      2425@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2FChangeLog
  btr/btr0sea.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbtr%2Fbtr0sea.c
  buf/buf0buf.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbuf%2Fbuf0buf.c
  dict/dict0dict.c               2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fdict%2Fdict0dict.c
  fil/fil0fil.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ffil%2Ffil0fil.c
  ibuf/ibuf0ibuf.c               2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fibuf%2Fibuf0ibuf.c
  include/btr0sea.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fbtr0sea.h
  include/dict0dict.h            2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fdict0dict.h
  include/fil0fil.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ffil0fil.h
  include/ibuf0ibuf.h            2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fibuf0ibuf.h
  include/lock0lock.h            2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Flock0lock.h
  include/log0log.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Flog0log.h
  include/log0recv.h             2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Flog0recv.h
  include/mem0mem.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fmem0mem.h
  include/mem0pool.h             2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fmem0pool.h
  include/os0file.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fos0file.h
  include/pars0pars.h            2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fpars0pars.h
  include/srv0srv.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fsrv0srv.h
  include/thr0loc.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fthr0loc.h
  include/trx0i_s.h              1864@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Finclude%2Ftrx0i_s.h
  include/trx0purge.h            2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ftrx0purge.h
  include/trx0rseg.h             2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ftrx0rseg.h
  include/trx0sys.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ftrx0sys.h
  include/trx0undo.h             2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ftrx0undo.h
  include/usr0sess.h             2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fusr0sess.h
  lock/lock0lock.c               2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Flock%2Flock0lock.c
  log/log0log.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Flog%2Flog0log.c
  log/log0recv.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Flog%2Flog0recv.c
  mem/mem0dbg.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fmem%2Fmem0dbg.c
  mem/mem0pool.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fmem%2Fmem0pool.c
  os/os0file.c                   2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fos%2Fos0file.c
  os/os0sync.c                   2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fos%2Fos0sync.c
  os/os0thread.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fos%2Fos0thread.c
  pars/lexyy.c                   2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fpars%2Flexyy.c
  pars/pars0lex.l                2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fpars%2Fpars0lex.l
  que/que0que.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fque%2Fque0que.c
  srv/srv0srv.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fsrv%2Fsrv0srv.c
  srv/srv0start.c                2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fsrv%2Fsrv0start.c
  sync/sync0arr.c                2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fsync%2Fsync0arr.c
  sync/sync0sync.c               2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fsync%2Fsync0sync.c
  thr/thr0loc.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fthr%2Fthr0loc.c
  trx/trx0i_s.c                  1864@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Ftrx%2Ftrx0i_s.c
  trx/trx0purge.c                2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0purge.c
  trx/trx0rseg.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0rseg.c
  trx/trx0sys.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0sys.c
  trx/trx0undo.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0undo.c
  usr/usr0sess.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fusr%2Fusr0sess.c
  ut/ut0mem.c                    2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fut%2Fut0mem.c
diff:
=== modified file 'ChangeLog'

Show diffs side-by-side

added added

removed removed

Lines of Context:
112
112
    pthread_mutex_destroy(&tina_mutex);
113
113
  }
114
114
 
115
 
  virtual Cursor *create(Table &table)
 
115
  virtual Cursor *create(TableShare &table)
116
116
  {
117
117
    return new ha_tina(*this, table);
118
118
  }
144
144
 
145
145
  void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
146
146
                             const drizzled::SchemaIdentifier &schema_identifier,
147
 
                             drizzled::TableIdentifier::vector &set_of_identifiers);
 
147
                             drizzled::TableIdentifiers &set_of_identifiers);
148
148
};
149
149
 
150
150
void Tina::doGetTableIdentifiers(drizzled::CachedDirectory&,
151
151
                                 const drizzled::SchemaIdentifier&,
152
 
                                 drizzled::TableIdentifier::vector&)
 
152
                                 drizzled::TableIdentifiers&)
153
153
{
154
154
}
155
155
 
167
167
    }
168
168
  }
169
169
 
170
 
  session.getMessageCache().renameTableMessage(from, to);
 
170
  session.renameTableMessage(from, to);
171
171
 
172
172
  return error;
173
173
}
174
174
 
175
175
bool Tina::doDoesTableExist(Session &session, const drizzled::TableIdentifier &identifier)
176
176
{
177
 
  return session.getMessageCache().doesTableMessageExist(identifier);
 
177
  return session.doesTableMessageExist(identifier);
178
178
}
179
179
 
180
180
 
201
201
    error= enoent_or_zero;
202
202
  }
203
203
 
204
 
  session.getMessageCache().removeTableMessage(identifier);
 
204
  session.removeTableMessage(identifier);
205
205
 
206
206
  return error;
207
207
}
232
232
                               const drizzled::TableIdentifier &identifier,
233
233
                               drizzled::message::Table &table_message)
234
234
{
235
 
  if (session.getMessageCache().getTableMessage(identifier, table_message))
 
235
  if (session.getTableMessage(identifier, table_message))
236
236
    return EEXIST;
237
237
 
238
238
  return ENOENT;
279
279
{
280
280
  pthread_mutex_lock(&tina_mutex);
281
281
 
282
 
  Tina *a_tina= static_cast<Tina *>(getEngine());
 
282
  Tina *a_tina= static_cast<Tina *>(engine);
283
283
  share= a_tina->findOpenTable(table_name);
284
284
 
285
285
  std::string meta_file_name;
481
481
      share->tina_write_opened= false;
482
482
    }
483
483
 
484
 
    Tina *a_tina= static_cast<Tina *>(getEngine());
 
484
    Tina *a_tina= static_cast<Tina *>(engine);
485
485
    a_tina->deleteOpenTable(share->table_name);
486
486
    delete share;
487
487
  }
530
530
 
531
531
 
532
532
 
533
 
ha_tina::ha_tina(drizzled::plugin::StorageEngine &engine_arg, Table &table_arg)
 
533
ha_tina::ha_tina(drizzled::plugin::StorageEngine &engine_arg, TableShare &table_arg)
534
534
  :Cursor(engine_arg, table_arg),
535
535
  /*
536
536
    These definitions are found in Cursor.h
557
557
 
558
558
  buffer.length(0);
559
559
 
560
 
  for (Field **field= getTable()->getFields() ; *field ; field++)
 
560
  for (Field **field= table->getFields() ; *field ; field++)
561
561
  {
562
562
    const char *ptr;
563
563
    const char *end_ptr;
597
597
        {
598
598
          buffer.append('\\');
599
599
          buffer.append('"');
600
 
          (void) *ptr++;
 
600
          *ptr++;
601
601
        }
602
602
        else if (*ptr == '\r')
603
603
        {
604
604
          buffer.append('\\');
605
605
          buffer.append('r');
606
 
          (void) *ptr++;
 
606
          *ptr++;
607
607
        }
608
608
        else if (*ptr == '\\')
609
609
        {
610
610
          buffer.append('\\');
611
611
          buffer.append('\\');
612
 
          (void) *ptr++;
 
612
          *ptr++;
613
613
        }
614
614
        else if (*ptr == '\n')
615
615
        {
616
616
          buffer.append('\\');
617
617
          buffer.append('n');
618
 
          (void) *ptr++;
 
618
          *ptr++;
619
619
        }
620
620
        else
621
621
          buffer.append(*ptr++);
675
675
 
676
676
  error= HA_ERR_CRASHED_ON_USAGE;
677
677
 
678
 
  memset(buf, 0, getTable()->getShare()->null_bytes);
 
678
  memset(buf, 0, table->getShare()->null_bytes);
679
679
 
680
 
  for (Field **field= getTable()->getFields() ; *field ; field++)
 
680
  for (Field **field=table->getFields() ; *field ; field++)
681
681
  {
682
682
    char curr_char;
683
683
 
746
746
    {
747
747
      /* This masks a bug in the logic for a SELECT * */
748
748
      (*field)->setWriteSet();
749
 
      if ((*field)->store_and_check(CHECK_FIELD_WARN, buffer.c_ptr(), buffer.length(), buffer.charset()))
750
 
      {
 
749
      if ((*field)->store(buffer.ptr(), buffer.length(), buffer.charset(),
 
750
                          CHECK_FIELD_WARN))
751
751
        goto err;
752
 
      }
753
752
 
754
753
      if ((*field)->flags & BLOB_FLAG)
755
754
      {
1309
1308
 
1310
1309
  internal::my_close(create_file, MYF(0));
1311
1310
 
1312
 
  session.getMessageCache().storeTableMessage(identifier, create_proto);
 
1311
  session.storeTableMessage(identifier, create_proto);
1313
1312
 
1314
1313
  return 0;
1315
1314
}