~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/ha_myisam.cc

Merged build changes from Antony.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#endif
20
20
 
21
21
#define MYSQL_SERVER 1
22
 
#include "mysql_priv.h"
23
 
#include <mysql/plugin.h>
24
 
#include <m_ctype.h>
25
 
#include <my_bit.h>
 
22
#include <drizzled/mysql_priv.h>
 
23
#include <mystrings/m_ctype.h>
 
24
#include <mysys/my_bit.h>
26
25
#include <myisampack.h>
27
26
#include "ha_myisam.h"
28
27
#include <stdarg.h>
150
149
  pos= table_arg->key_info;
151
150
  for (i= 0; i < share->keys; i++, pos++)
152
151
  {
153
 
    keydef[i].flag= ((uint16) pos->flags & (HA_NOSAME | HA_FULLTEXT ));
 
152
    keydef[i].flag= ((uint16_t) pos->flags & (HA_NOSAME | HA_FULLTEXT ));
154
153
    keydef[i].key_alg= pos->algorithm == HA_KEY_ALG_UNDEF ?  (HA_KEY_ALG_BTREE) : pos->algorithm;
155
154
    keydef[i].block_length= pos->block_size;
156
155
    keydef[i].seg= keyseg;
173
172
          /* No blobs here */
174
173
          if (j == 0)
175
174
            keydef[i].flag|= HA_PACK_KEY;
176
 
          if (!(field->flags & ZEROFILL_FLAG) &&
177
 
              (field->type() == MYSQL_TYPE_STRING ||
178
 
               field->type() == MYSQL_TYPE_VAR_STRING ||
 
175
          if ((field->type() == DRIZZLE_TYPE_STRING ||
 
176
               field->type() == DRIZZLE_TYPE_VAR_STRING ||
179
177
               ((int) (pos->key_part[j].length - field->decimals())) >= 4))
180
178
            keydef[i].seg[j].flag|= HA_SPACE_PACK;
181
179
        }
201
199
        keydef[i].seg[j].null_bit= 0;
202
200
        keydef[i].seg[j].null_pos= 0;
203
201
      }
204
 
      if (field->type() == MYSQL_TYPE_BLOB)
 
202
      if (field->type() == DRIZZLE_TYPE_BLOB)
205
203
      {
206
204
        keydef[i].seg[j].flag|= HA_BLOB_PART;
207
205
        /* save number of bytes used to pack length */
241
239
    }
242
240
    if (recpos != minpos)
243
241
    { // Reserved space (Null bits?)
244
 
      bzero((char*) recinfo_pos, sizeof(*recinfo_pos));
 
242
      memset((char*) recinfo_pos, 0, sizeof(*recinfo_pos));
245
243
      recinfo_pos->type= (int) FIELD_NORMAL;
246
 
      recinfo_pos++->length= (uint16) (minpos - recpos);
 
244
      recinfo_pos++->length= (uint16_t) (minpos - recpos);
247
245
    }
248
246
    if (!found)
249
247
      break;
250
248
 
251
249
    if (found->flags & BLOB_FLAG)
252
250
      recinfo_pos->type= (int) FIELD_BLOB;
253
 
    else if (found->type() == MYSQL_TYPE_VARCHAR)
 
251
    else if (found->type() == DRIZZLE_TYPE_VARCHAR)
254
252
      recinfo_pos->type= FIELD_VARCHAR;
255
253
    else if (!(options & HA_OPTION_PACK_RECORD))
256
254
      recinfo_pos->type= (int) FIELD_NORMAL;
257
255
    else if (found->zero_pack())
258
256
      recinfo_pos->type= (int) FIELD_SKIP_ZERO;
259
257
    else
260
 
      recinfo_pos->type= (int) ((length <= 3 ||
261
 
                                 (found->flags & ZEROFILL_FLAG)) ?
262
 
                                  FIELD_NORMAL :
263
 
                                  found->type() == MYSQL_TYPE_STRING ||
264
 
                                  found->type() == MYSQL_TYPE_VAR_STRING ?
 
258
      recinfo_pos->type= (int) ((length <= 3) ?  FIELD_NORMAL : found->type() == DRIZZLE_TYPE_STRING ||
 
259
                                  found->type() == DRIZZLE_TYPE_VAR_STRING ?
265
260
                                  FIELD_SKIP_ENDSPACE :
266
261
                                  FIELD_SKIP_PRESPACE);
267
262
    if (found->null_ptr)
275
270
      recinfo_pos->null_bit= 0;
276
271
      recinfo_pos->null_pos= 0;
277
272
    }
278
 
    (recinfo_pos++)->length= (uint16) length;
 
273
    (recinfo_pos++)->length= (uint16_t) length;
279
274
    recpos= minpos + length;
280
275
  }
281
276
  *records_out= (uint) (recinfo_pos - recinfo);
362
357
    }
363
358
    for (j=  t1_keyinfo[i].keysegs; j--;)
364
359
    {
365
 
      uint8 t1_keysegs_j__type= t1_keysegs[j].type;
 
360
      uint8_t t1_keysegs_j__type= t1_keysegs[j].type;
366
361
 
367
362
      /*
368
363
        Table migration from 4.1 to 5.1. In 5.1 a *TEXT key part is
521
516
}
522
517
 
523
518
 
524
 
const char *ha_myisam::index_type(uint key_number __attribute__((__unused__)))
 
519
const char *ha_myisam::index_type(uint key_number __attribute__((unused)))
525
520
{
526
521
  return "BTREE";
527
522
}
733
728
*/
734
729
 
735
730
int ha_myisam::analyze(THD *thd,
736
 
                       HA_CHECK_OPT* check_opt __attribute__((__unused__)))
 
731
                       HA_CHECK_OPT* check_opt __attribute__((unused)))
737
732
{
738
733
  int error=0;
739
734
  MI_CHECK param;
1337
1332
C_MODE_END
1338
1333
 
1339
1334
 
1340
 
int ha_myisam::index_init(uint idx, bool sorted __attribute__((__unused__)))
 
1335
int ha_myisam::index_init(uint idx, bool sorted __attribute__((unused)))
1341
1336
1342
1337
  active_index=idx;
1343
1338
  //in_range_read= false;
1496
1491
}
1497
1492
 
1498
1493
 
1499
 
void ha_myisam::position(const uchar *record __attribute__((__unused__)))
 
1494
void ha_myisam::position(const uchar *record __attribute__((unused)))
1500
1495
{
1501
1496
  my_off_t row_position= mi_position(file);
1502
1497
  my_store_ptr(ref, ref_length, row_position);
1614
1609
                                       F_UNLCK : F_EXTRA_LCK));
1615
1610
}
1616
1611
 
1617
 
THR_LOCK_DATA **ha_myisam::store_lock(THD *thd __attribute__((__unused__)),
 
1612
THR_LOCK_DATA **ha_myisam::store_lock(THD *thd __attribute__((unused)),
1618
1613
                                      THR_LOCK_DATA **to,
1619
1614
                                      enum thr_lock_type lock_type)
1620
1615
{
1657
1652
  }
1658
1653
  if ((error= table2myisam(table_arg, &keydef, &recinfo, &records)))
1659
1654
    return(error); /* purecov: inspected */
1660
 
  bzero((char*) &create_info, sizeof(create_info));
 
1655
  memset((char*) &create_info, 0, sizeof(create_info));
1661
1656
  create_info.max_rows= share->max_rows;
1662
1657
  create_info.reloc_rows= share->min_rows;
1663
1658
  create_info.with_auto_increment= share->next_number_key_offset == 0;
1699
1694
}
1700
1695
 
1701
1696
 
1702
 
void ha_myisam::get_auto_increment(uint64_t offset __attribute__((__unused__)),
1703
 
                                   uint64_t increment __attribute__((__unused__)),
1704
 
                                   uint64_t nb_desired_values __attribute__((__unused__)),
 
1697
void ha_myisam::get_auto_increment(uint64_t offset __attribute__((unused)),
 
1698
                                   uint64_t increment __attribute__((unused)),
 
1699
                                   uint64_t nb_desired_values __attribute__((unused)),
1705
1700
                                   uint64_t *first_value,
1706
1701
                                   uint64_t *nb_reserved_values)
1707
1702
{
1806
1801
  return COMPATIBLE_DATA_YES;
1807
1802
}
1808
1803
 
1809
 
int myisam_panic(handlerton *hton __attribute__((__unused__)), ha_panic_function flag)
 
1804
int myisam_deinit(void *hton __attribute__((unused)))
1810
1805
{
1811
 
  return mi_panic(flag);
 
1806
  return mi_panic(HA_PANIC_CLOSE);
1812
1807
}
1813
1808
 
1814
1809
static int myisam_init(void *p)
1819
1814
  myisam_hton->state= SHOW_OPTION_YES;
1820
1815
  myisam_hton->db_type= DB_TYPE_MYISAM;
1821
1816
  myisam_hton->create= myisam_create_handler;
1822
 
  myisam_hton->panic= myisam_panic;
1823
1817
  myisam_hton->flags= HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES;
1824
1818
  return 0;
1825
1819
}
1891
1885
  "Default engine as of MySQL 3.23 with great performance",
1892
1886
  PLUGIN_LICENSE_GPL,
1893
1887
  myisam_init, /* Plugin Init */
1894
 
  NULL, /* Plugin Deinit */
 
1888
  myisam_deinit, /* Plugin Deinit */
1895
1889
  NULL,                       /* status variables                */
1896
1890
  NULL,                       /* system variables                */
1897
1891
  NULL                        /* config options                  */