~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/ha_myisam.cc

  • Committer: Olaf van der Spek
  • Date: 2011-07-07 13:41:07 UTC
  • mto: This revision was merged to the branch mainline in revision 2385.
  • Revision ID: olafvdspek@gmail.com-20110707134107-6mi7pauiatxtf4oe
Rename strmake to strdup (standard name)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
 
17
17
 
18
 
#include "config.h"
19
 
#include "drizzled/internal/my_bit.h"
 
18
#include <config.h>
 
19
#include <drizzled/internal/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"
26
 
#include "drizzled/util/test.h"
27
 
#include "drizzled/error.h"
28
 
#include "drizzled/errmsg_print.h"
29
 
#include "drizzled/gettext.h"
30
 
#include "drizzled/session.h"
31
 
#include "drizzled/plugin.h"
32
 
#include "drizzled/plugin/client.h"
33
 
#include "drizzled/table.h"
34
 
#include "drizzled/field/timestamp.h"
35
 
#include "drizzled/memory/multi_malloc.h"
36
 
#include "drizzled/plugin/daemon.h"
 
23
#include <drizzled/option.h>
 
24
#include <drizzled/internal/my_bit.h>
 
25
#include <drizzled/internal/m_string.h>
 
26
#include <drizzled/util/test.h>
 
27
#include <drizzled/error.h>
 
28
#include <drizzled/errmsg_print.h>
 
29
#include <drizzled/gettext.h>
 
30
#include <drizzled/session.h>
 
31
#include <drizzled/plugin.h>
 
32
#include <drizzled/plugin/client.h>
 
33
#include <drizzled/table.h>
 
34
#include <drizzled/memory/multi_malloc.h>
 
35
#include <drizzled/plugin/daemon.h>
 
36
#include <drizzled/session/table_messages.h>
 
37
#include <drizzled/plugin/storage_engine.h>
 
38
#include <drizzled/key.h>
 
39
#include <drizzled/statistics_variables.h>
 
40
#include <drizzled/system_variables.h>
37
41
 
38
42
#include <boost/algorithm/string.hpp>
39
43
#include <boost/scoped_ptr.hpp>
117
121
 
118
122
  int doCreateTable(Session&,
119
123
                    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);
 
124
                    const identifier::Table &identifier,
 
125
                    const message::Table&);
 
126
 
 
127
  int doRenameTable(Session&, const identifier::Table &from, const identifier::Table &to);
 
128
 
 
129
  int doDropTable(Session&, const identifier::Table &identifier);
126
130
 
127
131
  int doGetTableDefinition(Session& session,
128
 
                           const TableIdentifier &identifier,
 
132
                           const identifier::Table &identifier,
129
133
                           message::Table &table_message);
130
134
 
131
135
  uint32_t max_supported_keys()          const { return MI_MAX_KEY; }
140
144
            HA_READ_ORDER |
141
145
            HA_KEYREAD_ONLY);
142
146
  }
143
 
  bool doDoesTableExist(Session& session, const TableIdentifier &identifier);
 
147
  bool doDoesTableExist(Session& session, const identifier::Table &identifier);
144
148
 
145
149
  void doGetTableIdentifiers(drizzled::CachedDirectory &directory,
146
 
                             const drizzled::SchemaIdentifier &schema_identifier,
147
 
                             drizzled::TableIdentifier::vector &set_of_identifiers);
 
150
                             const drizzled::identifier::Schema &schema_identifier,
 
151
                             drizzled::identifier::table::vector &set_of_identifiers);
148
152
  bool validateCreateTableOption(const std::string &key, const std::string &state)
149
153
  {
150
154
    (void)state;
158
162
};
159
163
 
160
164
void MyisamEngine::doGetTableIdentifiers(drizzled::CachedDirectory&,
161
 
                                         const drizzled::SchemaIdentifier&,
162
 
                                         drizzled::TableIdentifier::vector&)
 
165
                                         const drizzled::identifier::Schema&,
 
166
                                         drizzled::identifier::table::vector&)
163
167
{
164
168
}
165
169
 
166
 
bool MyisamEngine::doDoesTableExist(Session &session, const TableIdentifier &identifier)
 
170
bool MyisamEngine::doDoesTableExist(Session &session, const identifier::Table &identifier)
167
171
{
168
172
  return session.getMessageCache().doesTableMessageExist(identifier);
169
173
}
170
174
 
171
175
int MyisamEngine::doGetTableDefinition(Session &session,
172
 
                                       const TableIdentifier &identifier,
 
176
                                       const identifier::Table &identifier,
173
177
                                       message::Table &table_message)
174
178
{
175
179
  if (session.getMessageCache().getTableMessage(identifier, table_message))
285
289
        keydef[i].seg[j].flag|= HA_BLOB_PART;
286
290
        /* save number of bytes used to pack length */
287
291
        keydef[i].seg[j].bit_start= (uint) (field->pack_length() -
288
 
                                            share->blob_ptr_size);
 
292
                                            share->sizeBlobPtr());
289
293
      }
290
294
    }
291
295
    keyseg+= pos->key_parts;
295
299
  record= table_arg->getInsertRecord();
296
300
  recpos= 0;
297
301
  recinfo_pos= recinfo;
298
 
  while (recpos < (uint) share->stored_rec_length)
 
302
 
 
303
  while (recpos < (uint) share->sizeStoredRecord())
299
304
  {
300
305
    Field **field, *found= 0;
301
306
    minpos= share->getRecordLength();
309
314
        /* skip null fields */
310
315
        if (!(temp_length= (*field)->pack_length_in_rec()))
311
316
          continue; /* Skip null-fields */
 
317
 
312
318
        if (! found || fieldpos < minpos ||
313
319
            (fieldpos == minpos && temp_length < length))
314
320
        {
530
536
{
531
537
  Session *cur_session;
532
538
  if ((cur_session= file->in_use))
533
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Got an error from thread_id=%"PRIu64", %s:%d"),
 
539
  {
 
540
    errmsg_printf(error::ERROR, _("Got an error from thread_id=%"PRIu64", %s:%d"),
534
541
                    cur_session->thread_id,
535
542
                    sfile, sline);
 
543
  }
536
544
  else
537
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("Got an error from unknown thread, %s:%d"), sfile, sline);
 
545
  {
 
546
    errmsg_printf(error::ERROR, _("Got an error from unknown thread, %s:%d"), sfile, sline);
 
547
  }
 
548
 
538
549
  if (message)
539
 
    errmsg_printf(ERRMSG_LVL_ERROR, "%s", message);
 
550
    errmsg_printf(error::ERROR, "%s", message);
 
551
 
540
552
  list<Session *>::iterator it= file->s->in_use->begin();
541
553
  while (it != file->s->in_use->end())
542
554
  {
543
 
    errmsg_printf(ERRMSG_LVL_ERROR, "%s", _("Unknown thread accessing table"));
 
555
    errmsg_printf(error::ERROR, "%s", _("Unknown thread accessing table"));
544
556
    ++it;
545
557
  }
546
558
}
567
579
}
568
580
 
569
581
/* Name is here without an extension */
570
 
int ha_myisam::doOpen(const drizzled::TableIdentifier &identifier, int mode, uint32_t test_if_locked)
 
582
int ha_myisam::doOpen(const drizzled::identifier::Table &identifier, int mode, uint32_t test_if_locked)
571
583
{
572
584
  MI_KEYDEF *keyinfo;
573
585
  MI_COLUMNDEF *recinfo= 0;
691
703
  */
692
704
  if (file->dfile == -1)
693
705
  {
694
 
    errmsg_printf(ERRMSG_LVL_INFO, "Retrying repair of: '%s' failed. "
695
 
                          "Please try REPAIR EXTENDED or myisamchk",
696
 
                          getTable()->getShare()->getPath());
 
706
    errmsg_printf(error::INFO, "Retrying repair of: '%s' failed. "
 
707
                  "Please try REPAIR EXTENDED or myisamchk",
 
708
                  getTable()->getShare()->getPath());
697
709
    return(HA_ADMIN_FAILED);
698
710
  }
699
711
 
918
930
    param.stats_method= MI_STATS_METHOD_NULLS_NOT_EQUAL;
919
931
    if ((error= (repair(session,param,0) != HA_ADMIN_OK)) && param.retry_repair)
920
932
    {
921
 
      errmsg_printf(ERRMSG_LVL_WARN, "Warning: Enabling keys got errno %d on %s.%s, retrying",
 
933
      errmsg_printf(error::WARN, "Warning: Enabling keys got errno %d on %s.%s, retrying",
922
934
                        errno, param.db_name, param.table_name);
923
935
      /* Repairing by sort failed. Now try standard repair method. */
924
936
      param.testflag&= ~(T_REP_BY_SORT | T_QUICK);
928
940
        might have been set by the first repair. They can still be seen
929
941
        with SHOW WARNINGS then.
930
942
      */
931
 
      if (! error)
 
943
      if (not error)
932
944
        session->clear_error();
933
945
    }
934
946
    info(HA_STATUS_CONST);
1329
1341
}
1330
1342
 
1331
1343
int MyisamEngine::doDropTable(Session &session,
1332
 
                              const TableIdentifier &identifier)
 
1344
                              const identifier::Table &identifier)
1333
1345
{
1334
1346
  session.getMessageCache().removeTableMessage(identifier);
1335
1347
 
1347
1359
 
1348
1360
int MyisamEngine::doCreateTable(Session &session,
1349
1361
                                Table& table_arg,
1350
 
                                const TableIdentifier &identifier,
1351
 
                                message::Table& create_proto)
 
1362
                                const identifier::Table &identifier,
 
1363
                                const message::Table& create_proto)
1352
1364
{
1353
1365
  int error;
1354
1366
  uint32_t create_flags= 0, create_records;
1393
1405
}
1394
1406
 
1395
1407
 
1396
 
int MyisamEngine::doRenameTable(Session &session, const TableIdentifier &from, const TableIdentifier &to)
 
1408
int MyisamEngine::doRenameTable(Session &session, const identifier::Table &from, const identifier::Table &to)
1397
1409
{
1398
1410
  session.getMessageCache().renameTableMessage(from, to);
1399
1411
 
1504
1516
{
1505
1517
  context("max-sort-file-size",
1506
1518
          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."));
 
1519
          _("Don't use the fast sort index method to created index if the temporary file would get bigger than this."));
1508
1520
  context("sort-buffer-size",
1509
1521
          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."));
 
1522
          _("The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE."));
1511
1523
}
1512
1524
 
1513
1525
 
1520
1532
  "Default engine as of MySQL 3.23 with great performance",
1521
1533
  PLUGIN_LICENSE_GPL,
1522
1534
  myisam_init, /* Plugin Init */
1523
 
  NULL,           /* system variables */
 
1535
  NULL,           /* depends */
1524
1536
  init_options                        /* config options                  */
1525
1537
}
1526
1538
DRIZZLE_DECLARE_PLUGIN_END;