~eday/drizzle/eday-dev

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_create.cc

  • Committer: Eric Day
  • Date: 2010-01-07 20:02:38 UTC
  • mfrom: (971.3.291 staging)
  • Revision ID: eday@oddments.org-20100107200238-uqw8v6kv9pl7nny5
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
/* Create a MyISAM table */
17
17
 
18
18
#include "myisam_priv.h"
19
 
#include <mysys/my_tree.h>
20
 
#include <mysys/my_bit.h>
21
 
 
22
 
#include <drizzled/util/test.h>
23
 
 
 
19
#include "drizzled/internal/my_bit.h"
 
20
 
 
21
#include "drizzled/util/test.h"
 
22
#include "drizzled/global_charset_info.h"
 
23
#include "drizzled/my_error.h"
 
24
 
 
25
#include <cassert>
24
26
#include <algorithm>
25
27
 
26
28
using namespace std;
35
37
              MI_CREATE_INFO *ci,uint32_t flags)
36
38
{
37
39
  register uint32_t i, j;
38
 
  File dfile= 0, file= 0;
 
40
  int dfile= 0, file= 0;
39
41
  int errpos,save_errno, create_mode= O_RDWR | O_TRUNC;
40
42
  myf create_flag;
41
43
  uint32_t fields,length,max_key_length,packed,pointer,real_length_diff,
65
67
 
66
68
  if (keys + uniques > MI_MAX_KEY || columns == 0)
67
69
  {
68
 
    return(my_errno=HA_WRONG_CREATE_OPTION);
 
70
    return(errno=HA_WRONG_CREATE_OPTION);
69
71
  }
70
72
  errpos= 0;
71
73
  options= 0;
88
90
 
89
91
  if (!(rec_per_key_part=
90
92
        (ulong*) malloc((keys + uniques)*MI_MAX_KEY_SEG*sizeof(long))))
91
 
    return(my_errno);
 
93
    return(errno);
92
94
  memset(rec_per_key_part, 0, (keys + uniques)*MI_MAX_KEY_SEG*sizeof(long));
93
95
 
94
96
        /* Start by checking fields and field-types used */
321
323
    key_segs+=keydef->keysegs;
322
324
    if (keydef->keysegs > MI_MAX_KEY_SEG)
323
325
    {
324
 
      my_errno=HA_WRONG_CREATE_OPTION;
 
326
      errno=HA_WRONG_CREATE_OPTION;
325
327
      goto err;
326
328
    }
327
329
    /*
346
348
    if (keydef->block_length > MI_MAX_KEY_BLOCK_LENGTH ||
347
349
        length >= MI_MAX_KEY_BUFF)
348
350
    {
349
 
      my_errno=HA_WRONG_CREATE_OPTION;
 
351
      errno=HA_WRONG_CREATE_OPTION;
350
352
      goto err;
351
353
    }
352
354
    set_if_bigger(max_key_block_length,(uint32_t)keydef->block_length);
392
394
    my_printf_error(0, "MyISAM table '%s' has too many columns and/or "
393
395
                    "indexes and/or unique constraints.",
394
396
                    MYF(0), name + dirname_length(name));
395
 
    my_errno= HA_WRONG_CREATE_OPTION;
 
397
    errno= HA_WRONG_CREATE_OPTION;
396
398
    goto err;
397
399
  }
398
400
 
526
528
    my_printf_error(0, "MyISAM table '%s' is in use "
527
529
                    "(most likely by a MERGE table). Try FLUSH TABLES.",
528
530
                    MYF(0), name + dirname_length(name));
529
 
    my_errno= HA_ERR_TABLE_EXIST;
 
531
    errno= HA_ERR_TABLE_EXIST;
530
532
    goto err;
531
533
  }
532
534
 
672
674
 
673
675
err:
674
676
  pthread_mutex_unlock(&THR_LOCK_myisam);
675
 
  save_errno=my_errno;
 
677
  save_errno=errno;
676
678
  switch (errpos) {
677
679
  case 3:
678
680
    my_close(dfile,MYF(0));
691
693
                             MYF(0));
692
694
  }
693
695
  free((char*) rec_per_key_part);
694
 
  return(my_errno=save_errno);          /* return the fatal errno */
 
696
  return(errno=save_errno);             /* return the fatal errno */
695
697
}
696
698
 
697
699