~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/ha_myisam.cc

Added the testsuite location finding code to support in-plugin-dir test suites.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
 
 
16
 
 
17
 
 
18
 
#include "config.h"
19
 
#include "drizzled/internal/my_bit.h"
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
 
 
17
 
 
18
#include <drizzled/server_includes.h>
 
19
#include <mysys/my_bit.h>
20
20
#include "myisampack.h"
21
21
#include "ha_myisam.h"
22
22
#include "myisam_priv.h"
23
 
#include "drizzled/option.h"
24
 
#include "drizzled/internal/my_bit.h"
25
 
#include "drizzled/internal/m_string.h"
 
23
#include "mysys/my_bit.h"
26
24
#include "drizzled/util/test.h"
27
25
#include "drizzled/error.h"
28
26
#include "drizzled/errmsg_print.h"
29
27
#include "drizzled/gettext.h"
30
28
#include "drizzled/session.h"
31
 
#include "drizzled/plugin.h"
32
29
#include "drizzled/plugin/client.h"
33
30
#include "drizzled/table.h"
34
31
#include "drizzled/field/timestamp.h"
35
32
#include "drizzled/memory/multi_malloc.h"
36
 
#include "drizzled/plugin/daemon.h"
37
 
 
38
 
#include <boost/algorithm/string.hpp>
39
 
#include <boost/scoped_ptr.hpp>
40
33
 
41
34
#include <string>
42
 
#include <sstream>
43
35
#include <map>
44
36
#include <algorithm>
45
 
#include <memory>
46
 
#include <boost/program_options.hpp>
47
 
#include <drizzled/module/option_map.h>
48
 
 
49
 
namespace po= boost::program_options;
50
37
 
51
38
using namespace std;
52
 
using namespace drizzled;
53
39
 
54
40
static const string engine_name("MyISAM");
55
41
 
56
 
boost::mutex THR_LOCK_myisam;
 
42
pthread_mutex_t THR_LOCK_myisam= PTHREAD_MUTEX_INITIALIZER;
57
43
 
58
 
static uint32_t myisam_key_cache_block_size= KEY_CACHE_BLOCK_SIZE;
59
 
static uint32_t myisam_key_cache_size;
60
 
static uint32_t myisam_key_cache_division_limit;
61
 
static uint32_t myisam_key_cache_age_threshold;
 
44
static uint32_t repair_threads;
 
45
static uint32_t block_size;
62
46
static uint64_t max_sort_file_size;
63
 
typedef constrained_check<size_t, SIZE_MAX, 1024, 1024> sort_buffer_constraint;
64
 
static sort_buffer_constraint sort_buffer_size;
65
 
 
66
 
void st_mi_isam_share::setKeyCache()
67
 
{
68
 
  (void)init_key_cache(&key_cache,
69
 
                       myisam_key_cache_block_size,
70
 
                       myisam_key_cache_size,
71
 
                       myisam_key_cache_division_limit, 
72
 
                       myisam_key_cache_age_threshold);
73
 
}
 
47
static uint64_t sort_buffer_size;
74
48
 
75
49
/*****************************************************************************
76
50
** MyISAM tables
82
56
  NULL
83
57
};
84
58
 
85
 
class MyisamEngine : public plugin::StorageEngine
 
59
class MyisamEngine : public drizzled::plugin::StorageEngine
86
60
{
87
 
  MyisamEngine();
88
 
  MyisamEngine(const MyisamEngine&);
89
 
  MyisamEngine& operator=(const MyisamEngine&);
90
61
public:
91
 
  explicit MyisamEngine(string name_arg) :
92
 
    plugin::StorageEngine(name_arg,
93
 
                          HTON_CAN_INDEX_BLOBS |
94
 
                          HTON_STATS_RECORDS_IS_EXACT |
95
 
                          HTON_TEMPORARY_ONLY |
96
 
                          HTON_NULL_IN_KEY |
97
 
                          HTON_HAS_RECORDS |
98
 
                          HTON_DUPLICATE_POS |
99
 
                          HTON_AUTO_PART_KEY |
100
 
                          HTON_SKIP_STORE_LOCK)
101
 
  {
102
 
  }
103
 
 
104
 
  virtual ~MyisamEngine()
105
 
  { 
106
 
    mi_panic(HA_PANIC_CLOSE);
107
 
  }
108
 
 
109
 
  virtual Cursor *create(Table &table)
110
 
  {
111
 
    return new ha_myisam(*this, table);
 
62
  MyisamEngine(string name_arg)
 
63
   : drizzled::plugin::StorageEngine(name_arg, 
 
64
                                     HTON_CAN_RECREATE | 
 
65
                                     HTON_HAS_DATA_DICTIONARY |
 
66
                                     HTON_TEMPORARY_ONLY | 
 
67
                                     HTON_FILE_BASED ) {}
 
68
 
 
69
  ~MyisamEngine()
 
70
  { }
 
71
 
 
72
  virtual Cursor *create(TableShare *table,
 
73
                          MEM_ROOT *mem_root)
 
74
  {
 
75
    return new (mem_root) ha_myisam(this, table);
112
76
  }
113
77
 
114
78
  const char **bas_ext() const {
115
79
    return ha_myisam_exts;
116
80
  }
117
81
 
118
 
  int doCreateTable(Session&,
 
82
  int doCreateTable(Session *, const char *table_name,
119
83
                    Table& table_arg,
120
 
                    const TableIdentifier &identifier,
121
 
                    message::Table&);
122
 
 
123
 
  int doRenameTable(Session&, const TableIdentifier &from, const TableIdentifier &to);
124
 
 
125
 
  int doDropTable(Session&, const TableIdentifier &identifier);
 
84
                    HA_CREATE_INFO& ha_create_info,
 
85
                    drizzled::message::Table&);
 
86
 
 
87
  int doRenameTable(Session*, const char *from, const char *to);
 
88
 
 
89
  int doDropTable(Session&, const string table_name);
126
90
 
127
91
  int doGetTableDefinition(Session& session,
128
 
                           const TableIdentifier &identifier,
129
 
                           message::Table &table_message);
130
 
 
131
 
  uint32_t max_supported_keys()          const { return MI_MAX_KEY; }
132
 
  uint32_t max_supported_key_length()    const { return MI_MAX_KEY_LENGTH; }
133
 
  uint32_t max_supported_key_part_length() const { return MI_MAX_KEY_LENGTH; }
134
 
 
135
 
  uint32_t index_flags(enum  ha_key_alg) const
136
 
  {
137
 
    return (HA_READ_NEXT |
138
 
            HA_READ_PREV |
139
 
            HA_READ_RANGE |
140
 
            HA_READ_ORDER |
141
 
            HA_KEYREAD_ONLY);
142
 
  }
143
 
  bool doDoesTableExist(Session& session, const TableIdentifier &identifier);
144
 
 
145
 
  void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
146
 
                             const drizzled::SchemaIdentifier &schema_identifier,
147
 
                             drizzled::TableIdentifier::vector &set_of_identifiers);
148
 
  bool validateCreateTableOption(const std::string &key, const std::string &state)
149
 
  {
150
 
    (void)state;
151
 
    if (boost::iequals(key, "ROW_FORMAT"))
152
 
    {
153
 
      return true;
154
 
    }
155
 
 
156
 
    return false;
157
 
  }
 
92
                           const char* path,
 
93
                           const char *db,
 
94
                           const char *table_name,
 
95
                           const bool is_tmp,
 
96
                           drizzled::message::Table *table_proto);
 
97
 
 
98
  /* Temp only engine, so do not return values. */
 
99
  void doGetTableNames(CachedDirectory &, string& , set<string>&) { };
 
100
 
158
101
};
159
102
 
160
 
void MyisamEngine::doGetTableIdentifiers(drizzled::CachedDirectory&,
161
 
                                         const drizzled::SchemaIdentifier&,
162
 
                                         drizzled::TableIdentifier::vector&)
163
 
{
164
 
}
165
 
 
166
 
bool MyisamEngine::doDoesTableExist(Session &session, const TableIdentifier &identifier)
167
 
{
168
 
  return session.getMessageCache().doesTableMessageExist(identifier);
169
 
}
170
 
 
171
 
int MyisamEngine::doGetTableDefinition(Session &session,
172
 
                                       const TableIdentifier &identifier,
173
 
                                       message::Table &table_message)
174
 
{
175
 
  if (session.getMessageCache().getTableMessage(identifier, table_message))
176
 
    return EEXIST;
177
 
  return ENOENT;
 
103
int MyisamEngine::doGetTableDefinition(Session&,
 
104
                                       const char* path,
 
105
                                       const char *,
 
106
                                       const char *,
 
107
                                       const bool,
 
108
                                       drizzled::message::Table *table_proto)
 
109
{
 
110
  int error= 1;
 
111
  ProtoCache::iterator iter;
 
112
 
 
113
  pthread_mutex_lock(&proto_cache_mutex);
 
114
  iter= proto_cache.find(path);
 
115
 
 
116
  if (iter!= proto_cache.end())
 
117
  {
 
118
    if (table_proto)
 
119
      table_proto->CopyFrom(((*iter).second));
 
120
    error= EEXIST;
 
121
  }
 
122
  pthread_mutex_unlock(&proto_cache_mutex);
 
123
 
 
124
  return error;
178
125
}
179
126
 
180
127
/* 
217
164
  uint32_t i, j, recpos, minpos, fieldpos, temp_length, length;
218
165
  enum ha_base_keytype type= HA_KEYTYPE_BINARY;
219
166
  unsigned char *record;
 
167
  KEY *pos;
220
168
  MI_KEYDEF *keydef;
221
169
  MI_COLUMNDEF *recinfo, *recinfo_pos;
222
170
  HA_KEYSEG *keyseg;
223
 
  TableShare *share= table_arg->getMutableShare();
 
171
  TableShare *share= table_arg->s;
224
172
  uint32_t options= share->db_options_in_use;
225
 
  if (!(memory::multi_malloc(false,
226
 
          recinfo_out, (share->sizeFields() * 2 + 2) * sizeof(MI_COLUMNDEF),
227
 
          keydef_out, share->sizeKeys() * sizeof(MI_KEYDEF),
228
 
          &keyseg, (share->key_parts + share->sizeKeys()) * sizeof(HA_KEYSEG),
 
173
  if (!(drizzled::memory::multi_malloc(false,
 
174
          recinfo_out, (share->fields * 2 + 2) * sizeof(MI_COLUMNDEF),
 
175
          keydef_out, share->keys * sizeof(MI_KEYDEF),
 
176
          &keyseg, (share->key_parts + share->keys) * sizeof(HA_KEYSEG),
229
177
          NULL)))
230
178
    return(HA_ERR_OUT_OF_MEM);
231
179
  keydef= *keydef_out;
232
180
  recinfo= *recinfo_out;
233
 
  for (i= 0; i < share->sizeKeys(); i++)
 
181
  pos= table_arg->key_info;
 
182
  for (i= 0; i < share->keys; i++, pos++)
234
183
  {
235
 
    KeyInfo *pos= &table_arg->key_info[i];
236
184
    keydef[i].flag= ((uint16_t) pos->flags & (HA_NOSAME));
237
185
    keydef[i].key_alg= HA_KEY_ALG_BTREE;
238
186
    keydef[i].block_length= pos->block_size;
273
221
      {
274
222
        keydef[i].seg[j].null_bit= field->null_bit;
275
223
        keydef[i].seg[j].null_pos= (uint) (field->null_ptr-
276
 
                                           (unsigned char*) table_arg->getInsertRecord());
 
224
                                           (unsigned char*) table_arg->record[0]);
277
225
      }
278
226
      else
279
227
      {
292
240
  }
293
241
  if (table_arg->found_next_number_field)
294
242
    keydef[share->next_number_index].flag|= HA_AUTO_KEY;
295
 
  record= table_arg->getInsertRecord();
 
243
  record= table_arg->record[0];
296
244
  recpos= 0;
297
245
  recinfo_pos= recinfo;
298
246
  while (recpos < (uint) share->stored_rec_length)
299
247
  {
300
248
    Field **field, *found= 0;
301
 
    minpos= share->getRecordLength();
 
249
    minpos= share->reclength;
302
250
    length= 0;
303
251
 
304
 
    for (field= table_arg->getFields(); *field; field++)
 
252
    for (field= table_arg->field; *field; field++)
305
253
    {
306
254
      if ((fieldpos= (*field)->offset(record)) >= recpos &&
307
255
          fieldpos <= minpos)
341
289
    {
342
290
      recinfo_pos->null_bit= found->null_bit;
343
291
      recinfo_pos->null_pos= (uint) (found->null_ptr -
344
 
                                     (unsigned char*) table_arg->getInsertRecord());
 
292
                                     (unsigned char*) table_arg->record[0]);
345
293
    }
346
294
    else
347
295
    {
355
303
  return(0);
356
304
}
357
305
 
358
 
int ha_myisam::reset_auto_increment(uint64_t value)
359
 
{
360
 
  file->s->state.auto_increment= value;
361
 
  return 0;
362
 
}
363
306
 
364
307
/*
365
308
  Check for underlying table conformance
476
419
}
477
420
 
478
421
 
 
422
extern "C" {
 
423
 
479
424
volatile int *killed_ptr(MI_CHECK *param)
480
425
{
481
426
  /* In theory Unsafe conversion, but should be ok for now */
482
 
  return (int*) (((Session *)(param->session))->getKilledPtr());
 
427
  return (int*) &(((Session *)(param->session))->killed);
483
428
}
484
429
 
485
430
void mi_check_print_error(MI_CHECK *param, const char *fmt,...)
529
474
                        const char *sfile, uint32_t sline)
530
475
{
531
476
  Session *cur_session;
 
477
  pthread_mutex_lock(&file->s->intern_lock);
532
478
  if ((cur_session= file->in_use))
533
479
    errmsg_printf(ERRMSG_LVL_ERROR, _("Got an error from thread_id=%"PRIu64", %s:%d"),
534
480
                    cur_session->thread_id,
543
489
    errmsg_printf(ERRMSG_LVL_ERROR, "%s", _("Unknown thread accessing table"));
544
490
    ++it;
545
491
  }
546
 
}
547
 
 
548
 
ha_myisam::ha_myisam(plugin::StorageEngine &engine_arg,
549
 
                     Table &table_arg)
 
492
  pthread_mutex_unlock(&file->s->intern_lock);
 
493
}
 
494
 
 
495
}
 
496
 
 
497
ha_myisam::ha_myisam(drizzled::plugin::StorageEngine *engine_arg,
 
498
                     TableShare *table_arg)
550
499
  : Cursor(engine_arg, table_arg),
551
 
  file(0),
552
 
  can_enable_indexes(true),
553
 
  is_ordered(true)
554
 
{ }
 
500
    file(0),
 
501
    int_table_flags(HA_NULL_IN_KEY |
 
502
                    HA_DUPLICATE_POS |
 
503
                    HA_CAN_INDEX_BLOBS |
 
504
                    HA_AUTO_PART_KEY |
 
505
                    HA_NO_TRANSACTIONS |
 
506
                    HA_HAS_RECORDS |
 
507
                    HA_STATS_RECORDS_IS_EXACT |
 
508
                    HA_NEED_READ_RANGE_BUFFER |
 
509
                    HA_MRR_CANT_SORT),
 
510
     can_enable_indexes(1)
 
511
{}
555
512
 
556
 
Cursor *ha_myisam::clone(memory::Root *mem_root)
 
513
Cursor *ha_myisam::clone(MEM_ROOT *mem_root)
557
514
{
558
515
  ha_myisam *new_handler= static_cast <ha_myisam *>(Cursor::clone(mem_root));
559
516
  if (new_handler)
567
524
}
568
525
 
569
526
/* Name is here without an extension */
570
 
int ha_myisam::doOpen(const drizzled::TableIdentifier &identifier, int mode, uint32_t test_if_locked)
 
527
int ha_myisam::open(const char *name, int mode, uint32_t test_if_locked)
571
528
{
572
529
  MI_KEYDEF *keyinfo;
573
530
  MI_COLUMNDEF *recinfo= 0;
589
546
    open of a table that is in use by other threads already (if the
590
547
    MyISAM share exists already).
591
548
  */
592
 
  if (!(file= mi_open(identifier, mode, test_if_locked)))
593
 
    return (errno ? errno : -1);
 
549
  if (!(file=mi_open(name, mode, test_if_locked)))
 
550
    return (my_errno ? my_errno : -1);
594
551
 
595
 
  if (!getTable()->getShare()->getType()) /* No need to perform a check for tmp table */
 
552
  if (!table->s->tmp_table) /* No need to perform a check for tmp table */
596
553
  {
597
 
    if ((errno= table2myisam(getTable(), &keyinfo, &recinfo, &recs)))
 
554
    if ((my_errno= table2myisam(table, &keyinfo, &recinfo, &recs)))
598
555
    {
599
556
      goto err;
600
557
    }
601
 
    if (check_definition(keyinfo, recinfo, getTable()->getShare()->sizeKeys(), recs,
 
558
    if (check_definition(keyinfo, recinfo, table->s->keys, recs,
602
559
                         file->s->keyinfo, file->s->rec,
603
560
                         file->s->base.keys, file->s->base.fields, true))
604
561
    {
605
 
      errno= HA_ERR_CRASHED;
 
562
      my_errno= HA_ERR_CRASHED;
606
563
      goto err;
607
564
    }
608
565
  }
609
566
 
610
 
  assert(test_if_locked);
611
567
  if (test_if_locked & (HA_OPEN_IGNORE_IF_LOCKED | HA_OPEN_TMP_TABLE))
612
568
    mi_extra(file, HA_EXTRA_NO_WAIT_LOCK, 0);
613
569
 
614
570
  info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
615
571
  if (!(test_if_locked & HA_OPEN_WAIT_IF_LOCKED))
616
572
    mi_extra(file, HA_EXTRA_WAIT_LOCK, 0);
617
 
  if (!getTable()->getShare()->db_record_offset)
618
 
    is_ordered= false;
619
 
 
 
573
  if (!table->s->db_record_offset)
 
574
    int_table_flags|=HA_REC_NOT_IN_SEQ;
620
575
 
621
576
  keys_with_parts.reset();
622
 
  for (i= 0; i < getTable()->getShare()->sizeKeys(); i++)
 
577
  for (i= 0; i < table->s->keys; i++)
623
578
  {
624
 
    getTable()->key_info[i].block_size= file->s->keyinfo[i].block_length;
 
579
    table->key_info[i].block_size= file->s->keyinfo[i].block_length;
625
580
 
626
 
    KeyPartInfo *kp= getTable()->key_info[i].key_part;
627
 
    KeyPartInfo *kp_end= kp + getTable()->key_info[i].key_parts;
 
581
    KEY_PART_INFO *kp= table->key_info[i].key_part;
 
582
    KEY_PART_INFO *kp_end= kp + table->key_info[i].key_parts;
628
583
    for (; kp != kp_end; kp++)
629
584
    {
630
585
      if (!kp->field->part_of_key.test(i))
634
589
      }
635
590
    }
636
591
  }
637
 
  errno= 0;
 
592
  my_errno= 0;
638
593
  goto end;
639
594
 err:
640
595
  this->close();
645
600
  */
646
601
  if (recinfo)
647
602
    free((unsigned char*) recinfo);
648
 
  return errno;
 
603
  return my_errno;
649
604
}
650
605
 
651
606
int ha_myisam::close(void)
655
610
  return mi_close(tmp);
656
611
}
657
612
 
658
 
int ha_myisam::doInsertRecord(unsigned char *buf)
 
613
int ha_myisam::write_row(unsigned char *buf)
659
614
{
 
615
  ha_statistic_increment(&SSV::ha_write_count);
 
616
 
660
617
  /*
661
618
    If we have an auto_increment column and we are writing a changed row
662
619
    or a new row, then update the auto_increment value in the record.
663
620
  */
664
 
  if (getTable()->next_number_field && buf == getTable()->getInsertRecord())
 
621
  if (table->next_number_field && buf == table->record[0])
665
622
  {
666
623
    int error;
667
624
    if ((error= update_auto_increment()))
693
650
  {
694
651
    errmsg_printf(ERRMSG_LVL_INFO, "Retrying repair of: '%s' failed. "
695
652
                          "Please try REPAIR EXTENDED or myisamchk",
696
 
                          getTable()->getShare()->getPath());
 
653
                          table->s->path.str);
697
654
    return(HA_ADMIN_FAILED);
698
655
  }
699
656
 
700
 
  param.db_name=    getTable()->getShare()->getSchemaName();
701
 
  param.table_name= getTable()->getAlias();
 
657
  param.db_name=    table->s->db.str;
 
658
  param.table_name= table->alias;
702
659
  param.tmpfile_createflag = O_RDWR | O_TRUNC;
703
660
  param.using_global_keycache = 1;
704
661
  param.session= session;
705
662
  param.out_flag= 0;
706
 
  param.sort_buffer_length= static_cast<size_t>(sort_buffer_size);
 
663
  param.sort_buffer_length= (size_t)sort_buffer_size;
707
664
  strcpy(fixed_name,file->filename);
708
665
 
709
666
  // Don't lock tables if we have used LOCK Table
710
 
  if (mi_lock_database(file, getTable()->getShare()->getType() ? F_EXTRA_LCK : F_WRLCK))
 
667
  if (mi_lock_database(file, table->s->tmp_table ? F_EXTRA_LCK : F_WRLCK))
711
668
  {
712
 
    mi_check_print_error(&param,ER(ER_CANT_LOCK),errno);
 
669
    mi_check_print_error(&param,ER(ER_CANT_LOCK),my_errno);
713
670
    return(HA_ADMIN_FAILED);
714
671
  }
715
672
 
728
685
      local_testflag|= T_STATISTICS;
729
686
      param.testflag|= T_STATISTICS;            // We get this for free
730
687
      statistics_done=1;
 
688
      if (repair_threads > 1)
 
689
      {
 
690
        char buf[40];
 
691
        /* TODO: respect myisam_repair_threads variable */
 
692
        snprintf(buf, 40, "Repair with %d threads", my_count_bits(key_map));
 
693
        session->set_proc_info(buf);
 
694
        error = mi_repair_parallel(&param, file, fixed_name,
 
695
            param.testflag & T_QUICK);
 
696
        session->set_proc_info("Repair done"); // to reset proc_info, as
 
697
                                      // it was pointing to local buffer
 
698
      }
 
699
      else
731
700
      {
732
701
        session->set_proc_info("Repair by sorting");
733
702
        error = mi_repair_by_sort(&param, file, fixed_name,
793
762
    {
794
763
      char llbuff[22],llbuff2[22];
795
764
      mi_check_print_warning(&param,"Number of rows changed from %s to %s",
796
 
                             internal::llstr(rows,llbuff),
797
 
                             internal::llstr(file->state->records,llbuff2));
 
765
                             llstr(rows,llbuff),
 
766
                             llstr(file->state->records,llbuff2));
798
767
    }
799
768
  }
800
769
  else
904
873
  }
905
874
  else if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE)
906
875
  {
907
 
    Session *session= getTable()->in_use;
908
 
    boost::scoped_ptr<MI_CHECK> param_ap(new MI_CHECK);
909
 
    MI_CHECK &param= *param_ap.get();
 
876
    Session *session=current_session;
 
877
    MI_CHECK param;
910
878
    const char *save_proc_info= session->get_proc_info();
911
879
    session->set_proc_info("Creating index");
912
880
    myisamchk_init(&param);
914
882
    param.testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK |
915
883
                     T_CREATE_MISSING_KEYS);
916
884
    param.myf_rw&= ~MY_WAIT_IF_FULL;
917
 
    param.sort_buffer_length=  static_cast<size_t>(sort_buffer_size);
 
885
    param.sort_buffer_length=  (size_t)sort_buffer_size;
918
886
    param.stats_method= MI_STATS_METHOD_NULLS_NOT_EQUAL;
919
887
    if ((error= (repair(session,param,0) != HA_ADMIN_OK)) && param.retry_repair)
920
888
    {
921
889
      errmsg_printf(ERRMSG_LVL_WARN, "Warning: Enabling keys got errno %d on %s.%s, retrying",
922
 
                        errno, param.db_name, param.table_name);
 
890
                        my_errno, param.db_name, param.table_name);
923
891
      /* Repairing by sort failed. Now try standard repair method. */
924
892
      param.testflag&= ~(T_REP_BY_SORT | T_QUICK);
925
893
      error= (repair(session,param,0) != HA_ADMIN_OK);
981
949
 
982
950
void ha_myisam::start_bulk_insert(ha_rows rows)
983
951
{
984
 
  Session *session= getTable()->in_use;
 
952
  Session *session= current_session;
985
953
  ulong size= session->variables.read_buff_size;
986
954
 
987
955
  /* don't enable row cache if too few rows */
1033
1001
 
1034
1002
 
1035
1003
 
1036
 
int ha_myisam::doUpdateRecord(const unsigned char *old_data, unsigned char *new_data)
 
1004
int ha_myisam::update_row(const unsigned char *old_data, unsigned char *new_data)
1037
1005
{
 
1006
  ha_statistic_increment(&SSV::ha_update_count);
 
1007
  if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
 
1008
    table->timestamp_field->set_time();
1038
1009
  return mi_update(file,old_data,new_data);
1039
1010
}
1040
1011
 
1041
 
int ha_myisam::doDeleteRecord(const unsigned char *buf)
 
1012
int ha_myisam::delete_row(const unsigned char *buf)
1042
1013
{
 
1014
  ha_statistic_increment(&SSV::ha_delete_count);
1043
1015
  return mi_delete(file,buf);
1044
1016
}
1045
1017
 
1046
1018
 
1047
 
int ha_myisam::doStartIndexScan(uint32_t idx, bool )
 
1019
int ha_myisam::index_init(uint32_t idx, bool )
1048
1020
{
1049
1021
  active_index=idx;
1050
1022
  //in_range_read= false;
1052
1024
}
1053
1025
 
1054
1026
 
1055
 
int ha_myisam::doEndIndexScan()
 
1027
int ha_myisam::index_end()
1056
1028
{
1057
1029
  active_index=MAX_KEY;
1058
1030
  return 0;
1059
1031
}
1060
1032
 
1061
1033
 
 
1034
uint32_t ha_myisam::index_flags(uint32_t inx, uint32_t, bool) const
 
1035
{
 
1036
  return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT) ?
 
1037
          0 : HA_READ_NEXT | HA_READ_PREV | HA_READ_RANGE |
 
1038
          HA_READ_ORDER | HA_KEYREAD_ONLY |
 
1039
          (keys_with_parts.test(inx)?0:HA_DO_INDEX_COND_PUSHDOWN));
 
1040
}
 
1041
 
 
1042
 
1062
1043
int ha_myisam::index_read_map(unsigned char *buf, const unsigned char *key,
1063
1044
                              key_part_map keypart_map,
1064
1045
                              enum ha_rkey_function find_flag)
1065
1046
{
1066
1047
  assert(inited==INDEX);
1067
 
  ha_statistic_increment(&system_status_var::ha_read_key_count);
 
1048
  ha_statistic_increment(&SSV::ha_read_key_count);
1068
1049
  int error=mi_rkey(file, buf, active_index, key, keypart_map, find_flag);
1069
 
  getTable()->status=error ? STATUS_NOT_FOUND: 0;
 
1050
  table->status=error ? STATUS_NOT_FOUND: 0;
1070
1051
  return error;
1071
1052
}
1072
1053
 
1074
1055
                                  key_part_map keypart_map,
1075
1056
                                  enum ha_rkey_function find_flag)
1076
1057
{
1077
 
  ha_statistic_increment(&system_status_var::ha_read_key_count);
 
1058
  ha_statistic_increment(&SSV::ha_read_key_count);
1078
1059
  int error=mi_rkey(file, buf, index, key, keypart_map, find_flag);
1079
 
  getTable()->status=error ? STATUS_NOT_FOUND: 0;
 
1060
  table->status=error ? STATUS_NOT_FOUND: 0;
1080
1061
  return error;
1081
1062
}
1082
1063
 
1084
1065
                                   key_part_map keypart_map)
1085
1066
{
1086
1067
  assert(inited==INDEX);
1087
 
  ha_statistic_increment(&system_status_var::ha_read_key_count);
 
1068
  ha_statistic_increment(&SSV::ha_read_key_count);
1088
1069
  int error=mi_rkey(file, buf, active_index, key, keypart_map,
1089
1070
                    HA_READ_PREFIX_LAST);
1090
 
  getTable()->status=error ? STATUS_NOT_FOUND: 0;
 
1071
  table->status=error ? STATUS_NOT_FOUND: 0;
1091
1072
  return(error);
1092
1073
}
1093
1074
 
1094
1075
int ha_myisam::index_next(unsigned char *buf)
1095
1076
{
1096
1077
  assert(inited==INDEX);
1097
 
  ha_statistic_increment(&system_status_var::ha_read_next_count);
 
1078
  ha_statistic_increment(&SSV::ha_read_next_count);
1098
1079
  int error=mi_rnext(file,buf,active_index);
1099
 
  getTable()->status=error ? STATUS_NOT_FOUND: 0;
 
1080
  table->status=error ? STATUS_NOT_FOUND: 0;
1100
1081
  return error;
1101
1082
}
1102
1083
 
1103
1084
int ha_myisam::index_prev(unsigned char *buf)
1104
1085
{
1105
1086
  assert(inited==INDEX);
1106
 
  ha_statistic_increment(&system_status_var::ha_read_prev_count);
 
1087
  ha_statistic_increment(&SSV::ha_read_prev_count);
1107
1088
  int error=mi_rprev(file,buf, active_index);
1108
 
  getTable()->status=error ? STATUS_NOT_FOUND: 0;
 
1089
  table->status=error ? STATUS_NOT_FOUND: 0;
1109
1090
  return error;
1110
1091
}
1111
1092
 
1112
1093
int ha_myisam::index_first(unsigned char *buf)
1113
1094
{
1114
1095
  assert(inited==INDEX);
1115
 
  ha_statistic_increment(&system_status_var::ha_read_first_count);
 
1096
  ha_statistic_increment(&SSV::ha_read_first_count);
1116
1097
  int error=mi_rfirst(file, buf, active_index);
1117
 
  getTable()->status=error ? STATUS_NOT_FOUND: 0;
 
1098
  table->status=error ? STATUS_NOT_FOUND: 0;
1118
1099
  return error;
1119
1100
}
1120
1101
 
1121
1102
int ha_myisam::index_last(unsigned char *buf)
1122
1103
{
1123
1104
  assert(inited==INDEX);
1124
 
  ha_statistic_increment(&system_status_var::ha_read_last_count);
 
1105
  ha_statistic_increment(&SSV::ha_read_last_count);
1125
1106
  int error=mi_rlast(file, buf, active_index);
1126
 
  getTable()->status=error ? STATUS_NOT_FOUND: 0;
 
1107
  table->status=error ? STATUS_NOT_FOUND: 0;
1127
1108
  return error;
1128
1109
}
1129
1110
 
1133
1114
{
1134
1115
  int error;
1135
1116
  assert(inited==INDEX);
1136
 
  ha_statistic_increment(&system_status_var::ha_read_next_count);
 
1117
  ha_statistic_increment(&SSV::ha_read_next_count);
1137
1118
  do
1138
1119
  {
1139
1120
    error= mi_rnext_same(file,buf);
1140
1121
  } while (error == HA_ERR_RECORD_DELETED);
1141
 
  getTable()->status=error ? STATUS_NOT_FOUND: 0;
 
1122
  table->status=error ? STATUS_NOT_FOUND: 0;
1142
1123
  return error;
1143
1124
}
1144
1125
 
1168
1149
}
1169
1150
 
1170
1151
 
1171
 
int ha_myisam::doStartTableScan(bool scan)
 
1152
int ha_myisam::rnd_init(bool scan)
1172
1153
{
1173
1154
  if (scan)
1174
1155
    return mi_scan_init(file);
1177
1158
 
1178
1159
int ha_myisam::rnd_next(unsigned char *buf)
1179
1160
{
1180
 
  ha_statistic_increment(&system_status_var::ha_read_rnd_next_count);
 
1161
  ha_statistic_increment(&SSV::ha_read_rnd_next_count);
1181
1162
  int error=mi_scan(file, buf);
1182
 
  getTable()->status=error ? STATUS_NOT_FOUND: 0;
 
1163
  table->status=error ? STATUS_NOT_FOUND: 0;
1183
1164
  return error;
1184
1165
}
1185
1166
 
 
1167
int ha_myisam::restart_rnd_next(unsigned char *buf, unsigned char *pos)
 
1168
{
 
1169
  return rnd_pos(buf,pos);
 
1170
}
 
1171
 
1186
1172
int ha_myisam::rnd_pos(unsigned char *buf, unsigned char *pos)
1187
1173
{
1188
 
  ha_statistic_increment(&system_status_var::ha_read_rnd_count);
1189
 
  int error=mi_rrnd(file, buf, internal::my_get_ptr(pos,ref_length));
1190
 
  getTable()->status=error ? STATUS_NOT_FOUND: 0;
 
1174
  ha_statistic_increment(&SSV::ha_read_rnd_count);
 
1175
  int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
 
1176
  table->status=error ? STATUS_NOT_FOUND: 0;
1191
1177
  return error;
1192
1178
}
1193
1179
 
1194
1180
 
1195
1181
void ha_myisam::position(const unsigned char *)
1196
1182
{
1197
 
  internal::my_off_t row_position= mi_position(file);
1198
 
  internal::my_store_ptr(ref, ref_length, row_position);
 
1183
  my_off_t row_position= mi_position(file);
 
1184
  my_store_ptr(ref, ref_length, row_position);
1199
1185
}
1200
1186
 
1201
1187
int ha_myisam::info(uint32_t flag)
1216
1202
  }
1217
1203
  if (flag & HA_STATUS_CONST)
1218
1204
  {
1219
 
    TableShare *share= getTable()->getMutableShare();
 
1205
    TableShare *share= table->s;
1220
1206
    stats.max_data_file_length=  misam_info.max_data_file_length;
1221
1207
    stats.max_index_file_length= misam_info.max_index_file_length;
1222
1208
    stats.create_time= misam_info.create_time;
1223
1209
    ref_length= misam_info.reflength;
1224
1210
    share->db_options_in_use= misam_info.options;
1225
 
    stats.block_size= myisam_key_cache_block_size;        /* record block size */
 
1211
    stats.block_size= block_size;        /* record block size */
1226
1212
 
1227
 
    set_prefix(share->keys_in_use, share->sizeKeys());
 
1213
    /* Update share */
 
1214
    if (share->tmp_table == NO_TMP_TABLE)
 
1215
      pthread_mutex_lock(&share->mutex);
 
1216
    set_prefix(share->keys_in_use, share->keys);
1228
1217
    /*
1229
1218
     * Due to bug 394932 (32-bit solaris build failure), we need
1230
1219
     * to convert the uint64_t key_map member of the misam_info
1273
1262
    share->keys_for_keyread&= share->keys_in_use;
1274
1263
    share->db_record_offset= misam_info.record_offset;
1275
1264
    if (share->key_parts)
1276
 
      memcpy(getTable()->key_info[0].rec_per_key,
 
1265
      memcpy(table->key_info[0].rec_per_key,
1277
1266
             misam_info.rec_per_key,
1278
 
             sizeof(getTable()->key_info[0].rec_per_key)*share->key_parts);
1279
 
    assert(share->getType() != message::Table::STANDARD);
 
1267
             sizeof(table->key_info[0].rec_per_key)*share->key_parts);
 
1268
    if (share->tmp_table == NO_TMP_TABLE)
 
1269
      pthread_mutex_unlock(&share->mutex);
1280
1270
 
1281
1271
   /*
1282
1272
     Set data_file_name and index_file_name to point at the symlink value
1283
1273
     if table is symlinked (Ie;  Real name is not same as generated name)
1284
1274
   */
1285
1275
    data_file_name= index_file_name= 0;
1286
 
    internal::fn_format(name_buff, file->filename, "", MI_NAME_DEXT,
 
1276
    fn_format(name_buff, file->filename, "", MI_NAME_DEXT,
1287
1277
              MY_APPEND_EXT | MY_UNPACK_FILENAME);
1288
1278
    if (strcmp(name_buff, misam_info.data_file_name))
1289
1279
      data_file_name=misam_info.data_file_name;
1290
 
    internal::fn_format(name_buff, file->filename, "", MI_NAME_IEXT,
 
1280
    fn_format(name_buff, file->filename, "", MI_NAME_IEXT,
1291
1281
              MY_APPEND_EXT | MY_UNPACK_FILENAME);
1292
1282
    if (strcmp(name_buff, misam_info.index_file_name))
1293
1283
      index_file_name=misam_info.index_file_name;
1295
1285
  if (flag & HA_STATUS_ERRKEY)
1296
1286
  {
1297
1287
    errkey  = misam_info.errkey;
1298
 
    internal::my_store_ptr(dup_ref, ref_length, misam_info.dupp_key_pos);
 
1288
    my_store_ptr(dup_ref, ref_length, misam_info.dupp_key_pos);
1299
1289
  }
1300
1290
  if (flag & HA_STATUS_TIME)
1301
1291
    stats.update_time = misam_info.update_time;
1328
1318
  return mi_delete_all_rows(file);
1329
1319
}
1330
1320
 
1331
 
int MyisamEngine::doDropTable(Session &session,
1332
 
                              const TableIdentifier &identifier)
 
1321
int MyisamEngine::doDropTable(Session&, const string table_path)
1333
1322
{
1334
 
  session.getMessageCache().removeTableMessage(identifier);
1335
 
 
1336
 
  return mi_delete_table(identifier.getPath().c_str());
 
1323
  ProtoCache::iterator iter;
 
1324
 
 
1325
  pthread_mutex_lock(&proto_cache_mutex);
 
1326
  iter= proto_cache.find(table_path.c_str());
 
1327
 
 
1328
  if (iter!= proto_cache.end())
 
1329
    proto_cache.erase(iter);
 
1330
 
 
1331
  pthread_mutex_unlock(&proto_cache_mutex);
 
1332
 
 
1333
  return mi_delete_table(table_path.c_str());
1337
1334
}
1338
1335
 
1339
1336
 
1340
1337
int ha_myisam::external_lock(Session *session, int lock_type)
1341
1338
{
1342
1339
  file->in_use= session;
1343
 
  return mi_lock_database(file, !getTable()->getShare()->getType() ?
 
1340
  return mi_lock_database(file, !table->s->tmp_table ?
1344
1341
                          lock_type : ((lock_type == F_UNLCK) ?
1345
1342
                                       F_UNLCK : F_EXTRA_LCK));
1346
1343
}
1347
1344
 
1348
 
int MyisamEngine::doCreateTable(Session &session,
 
1345
THR_LOCK_DATA **ha_myisam::store_lock(Session *,
 
1346
                                      THR_LOCK_DATA **to,
 
1347
                                      enum thr_lock_type lock_type)
 
1348
{
 
1349
  if (lock_type != TL_IGNORE && file->lock.type == TL_UNLOCK)
 
1350
    file->lock.type=lock_type;
 
1351
  *to++= &file->lock;
 
1352
 
 
1353
  return to;
 
1354
}
 
1355
 
 
1356
int MyisamEngine::doCreateTable(Session *, const char *table_name,
1349
1357
                                Table& table_arg,
1350
 
                                const TableIdentifier &identifier,
1351
 
                                message::Table& create_proto)
 
1358
                                HA_CREATE_INFO& ha_create_info,
 
1359
                                drizzled::message::Table& create_proto)
1352
1360
{
1353
1361
  int error;
1354
1362
  uint32_t create_flags= 0, create_records;
1356
1364
  MI_KEYDEF *keydef;
1357
1365
  MI_COLUMNDEF *recinfo;
1358
1366
  MI_CREATE_INFO create_info;
1359
 
  TableShare *share= table_arg.getMutableShare();
 
1367
  TableShare *share= table_arg.s;
1360
1368
  uint32_t options= share->db_options_in_use;
1361
1369
  if ((error= table2myisam(&table_arg, &keydef, &recinfo, &create_records)))
1362
1370
    return(error);
1364
1372
  create_info.max_rows= create_proto.options().max_rows();
1365
1373
  create_info.reloc_rows= create_proto.options().min_rows();
1366
1374
  create_info.with_auto_increment= share->next_number_key_offset == 0;
1367
 
  create_info.auto_increment= (create_proto.options().has_auto_increment_value() ?
1368
 
                               create_proto.options().auto_increment_value() -1 :
 
1375
  create_info.auto_increment= (ha_create_info.auto_increment_value ?
 
1376
                               ha_create_info.auto_increment_value -1 :
1369
1377
                               (uint64_t) 0);
1370
1378
  create_info.data_file_length= (create_proto.options().max_rows() *
1371
1379
                                 create_proto.options().avg_row_length());
1373
1381
  create_info.index_file_name=  NULL;
1374
1382
  create_info.language= share->table_charset->number;
1375
1383
 
1376
 
  if (create_proto.type() == message::Table::TEMPORARY)
 
1384
  if (ha_create_info.options & HA_LEX_CREATE_TMP_TABLE)
1377
1385
    create_flags|= HA_CREATE_TMP_TABLE;
 
1386
  if (ha_create_info.options & HA_CREATE_KEEP_FILES)
 
1387
    create_flags|= HA_CREATE_KEEP_FILES;
1378
1388
  if (options & HA_OPTION_PACK_RECORD)
1379
1389
    create_flags|= HA_PACK_RECORD;
1380
1390
 
1381
 
  /* TODO: Check that the following internal::fn_format is really needed */
1382
 
  error= mi_create(internal::fn_format(buff, identifier.getPath().c_str(), "", "",
1383
 
                                       MY_UNPACK_FILENAME|MY_APPEND_EXT),
1384
 
                   share->sizeKeys(), keydef,
 
1391
  /* TODO: Check that the following fn_format is really needed */
 
1392
  error= mi_create(fn_format(buff, table_name, "", "",
 
1393
                             MY_UNPACK_FILENAME|MY_APPEND_EXT),
 
1394
                   share->keys, keydef,
1385
1395
                   create_records, recinfo,
1386
1396
                   0, (MI_UNIQUEDEF*) 0,
1387
1397
                   &create_info, create_flags);
1388
1398
  free((unsigned char*) recinfo);
1389
1399
 
1390
 
  session.getMessageCache().storeTableMessage(identifier, create_proto);
 
1400
  pthread_mutex_lock(&proto_cache_mutex);
 
1401
  proto_cache.insert(make_pair(table_name, create_proto));
 
1402
  pthread_mutex_unlock(&proto_cache_mutex);
1391
1403
 
1392
1404
  return error;
1393
1405
}
1394
1406
 
1395
1407
 
1396
 
int MyisamEngine::doRenameTable(Session &session, const TableIdentifier &from, const TableIdentifier &to)
 
1408
int MyisamEngine::doRenameTable(Session*,
 
1409
                                const char *from, const char *to)
1397
1410
{
1398
 
  session.getMessageCache().renameTableMessage(from, to);
1399
 
 
1400
 
  return mi_rename(from.getPath().c_str(), to.getPath().c_str());
 
1411
  return mi_rename(from,to);
1401
1412
}
1402
1413
 
1403
1414
 
1411
1422
  int error;
1412
1423
  unsigned char key[MI_MAX_KEY_LENGTH];
1413
1424
 
1414
 
  if (!getTable()->getShare()->next_number_key_offset)
 
1425
  if (!table->s->next_number_key_offset)
1415
1426
  {                                             // Autoincrement at key-start
1416
1427
    ha_myisam::info(HA_STATUS_AUTO);
1417
1428
    *first_value= stats.auto_increment_value;
1421
1432
  }
1422
1433
 
1423
1434
  /* it's safe to call the following if bulk_insert isn't on */
1424
 
  mi_flush_bulk_insert(file, getTable()->getShare()->next_number_index);
 
1435
  mi_flush_bulk_insert(file, table->s->next_number_index);
1425
1436
 
1426
1437
  (void) extra(HA_EXTRA_KEYREAD);
1427
 
  key_copy(key, getTable()->getInsertRecord(),
1428
 
           &getTable()->key_info[getTable()->getShare()->next_number_index],
1429
 
           getTable()->getShare()->next_number_key_offset);
1430
 
  error= mi_rkey(file, getTable()->getUpdateRecord(), (int) getTable()->getShare()->next_number_index,
1431
 
                 key, make_prev_keypart_map(getTable()->getShare()->next_number_keypart),
 
1438
  key_copy(key, table->record[0],
 
1439
           table->key_info + table->s->next_number_index,
 
1440
           table->s->next_number_key_offset);
 
1441
  error= mi_rkey(file, table->record[1], (int) table->s->next_number_index,
 
1442
                 key, make_prev_keypart_map(table->s->next_number_keypart),
1432
1443
                 HA_READ_PREFIX_LAST);
1433
1444
  if (error)
1434
1445
    nr= 1;
1435
1446
  else
1436
1447
  {
1437
 
    /* Get data from getUpdateRecord() */
1438
 
    nr= ((uint64_t) getTable()->next_number_field->
1439
 
         val_int_offset(getTable()->getShare()->rec_buff_length)+1);
 
1448
    /* Get data from record[1] */
 
1449
    nr= ((uint64_t) table->next_number_field->
 
1450
         val_int_offset(table->s->rec_buff_length)+1);
1440
1451
  }
1441
1452
  extra(HA_EXTRA_NO_KEYREAD);
1442
1453
  *first_value= nr;
1487
1498
  return (uint)file->state->checksum;
1488
1499
}
1489
1500
 
1490
 
static int myisam_init(module::Context &context)
1491
 
1492
 
  context.add(new MyisamEngine(engine_name));
1493
 
  context.registerVariable(new sys_var_constrained_value<size_t>("sort-buffer-size",
1494
 
                                                                 sort_buffer_size));
1495
 
  context.registerVariable(new sys_var_uint64_t_ptr("max_sort_file_size",
1496
 
                                                    &max_sort_file_size,
1497
 
                                                    context.getOptions()["max-sort-file-size"].as<uint64_t>()));
 
1501
static MyisamEngine *engine= NULL;
 
1502
 
 
1503
static int myisam_init(drizzled::plugin::Registry &registry)
 
1504
{
 
1505
  int error;
 
1506
  engine= new MyisamEngine(engine_name);
 
1507
  registry.add(engine);
 
1508
 
 
1509
  pthread_mutex_init(&THR_LOCK_myisam,MY_MUTEX_INIT_FAST);
 
1510
 
 
1511
  /* call ha_init_key_cache() on all key caches to init them */
 
1512
  error= init_key_cache(dflt_key_cache,
 
1513
                        (uint32_t) dflt_key_cache->param_block_size,
 
1514
                        (uint32_t) dflt_key_cache->param_buff_size,
 
1515
                        dflt_key_cache->param_division_limit, 
 
1516
                        dflt_key_cache->param_age_threshold);
 
1517
 
 
1518
  if (error == 0)
 
1519
    exit(1); /* Memory Allocation Failure */
1498
1520
 
1499
1521
  return 0;
1500
1522
}
1501
1523
 
1502
 
 
1503
 
static void init_options(drizzled::module::option_context &context)
 
1524
static int myisam_deinit(drizzled::plugin::Registry &registry)
1504
1525
{
1505
 
  context("max-sort-file-size",
1506
 
          po::value<uint64_t>(&max_sort_file_size)->default_value(INT32_MAX),
1507
 
          N_("Don't use the fast sort index method to created index if the temporary file would get bigger than this."));
1508
 
  context("sort-buffer-size",
1509
 
          po::value<sort_buffer_constraint>(&sort_buffer_size)->default_value(8192*1024),
1510
 
          N_("The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE."));
 
1526
  registry.remove(engine);
 
1527
  delete engine;
 
1528
 
 
1529
  pthread_mutex_destroy(&THR_LOCK_myisam);
 
1530
  end_key_cache(dflt_key_cache, 1);             // Can never fail
 
1531
 
 
1532
  return mi_panic(HA_PANIC_CLOSE);
1511
1533
}
1512
1534
 
1513
 
 
1514
 
DRIZZLE_DECLARE_PLUGIN
 
1535
static DRIZZLE_SYSVAR_UINT(block_size, block_size,
 
1536
                           PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
 
1537
                           N_("Block size to be used for MyISAM index pages."),
 
1538
                           NULL, NULL, MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, 
 
1539
                           MI_MAX_KEY_BLOCK_LENGTH, 0);
 
1540
 
 
1541
static DRIZZLE_SYSVAR_UINT(repair_threads, repair_threads,
 
1542
                           PLUGIN_VAR_RQCMDARG,
 
1543
                           N_("Number of threads to use when repairing MyISAM tables. The value of "
 
1544
                              "1 disables parallel repair."),
 
1545
                           NULL, NULL, 1, 1, UINT32_MAX, 0);
 
1546
 
 
1547
static DRIZZLE_SYSVAR_ULONGLONG(max_sort_file_size, max_sort_file_size,
 
1548
                                PLUGIN_VAR_RQCMDARG,
 
1549
                                N_("Don't use the fast sort index method to created index if the temporary file would get bigger than this."),
 
1550
                                NULL, NULL, INT32_MAX, 0, UINT64_MAX, 0);
 
1551
 
 
1552
static DRIZZLE_SYSVAR_ULONGLONG(sort_buffer_size, sort_buffer_size,
 
1553
                                PLUGIN_VAR_RQCMDARG,
 
1554
                                N_("The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE."),
 
1555
                                NULL, NULL, 8192*1024, 1024, SIZE_MAX, 0);
 
1556
 
 
1557
extern uint32_t data_pointer_size;
 
1558
static DRIZZLE_SYSVAR_UINT(data_pointer_size, data_pointer_size,
 
1559
                           PLUGIN_VAR_RQCMDARG,
 
1560
                           N_("Default pointer size to be used for MyISAM tables."),
 
1561
                           NULL, NULL, 6, 2, 7, 0);
 
1562
 
 
1563
static struct st_mysql_sys_var* system_variables[]= {
 
1564
  DRIZZLE_SYSVAR(block_size),
 
1565
  DRIZZLE_SYSVAR(repair_threads),
 
1566
  DRIZZLE_SYSVAR(max_sort_file_size),
 
1567
  DRIZZLE_SYSVAR(sort_buffer_size),
 
1568
  DRIZZLE_SYSVAR(data_pointer_size),
 
1569
  NULL
 
1570
};
 
1571
 
 
1572
 
 
1573
drizzle_declare_plugin
1515
1574
{
1516
 
  DRIZZLE_VERSION_ID,
1517
1575
  "MyISAM",
1518
 
  "2.0",
 
1576
  "1.0",
1519
1577
  "MySQL AB",
1520
1578
  "Default engine as of MySQL 3.23 with great performance",
1521
1579
  PLUGIN_LICENSE_GPL,
1522
1580
  myisam_init, /* Plugin Init */
1523
 
  NULL,           /* system variables */
1524
 
  init_options                        /* config options                  */
 
1581
  myisam_deinit, /* Plugin Deinit */
 
1582
  NULL,                       /* status variables                */
 
1583
  system_variables,           /* system variables */
 
1584
  NULL                        /* config options                  */
1525
1585
}
1526
 
DRIZZLE_DECLARE_PLUGIN_END;
 
1586
drizzle_declare_plugin_end;