~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Brian Aker
  • Date: 2009-02-21 00:18:15 UTC
  • Revision ID: brian@tangent.org-20090221001815-x20e8h71e984lvs1
Completion (?) of uint conversion.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
 
59
59
static unsigned char *get_field_name(Field **buff, size_t *length, bool)
60
60
{
61
 
  *length= (uint) strlen((*buff)->field_name);
 
61
  *length= (uint32_t) strlen((*buff)->field_name);
62
62
  return (unsigned char*) (*buff)->field_name;
63
63
}
64
64
 
1008
1008
  error=4;
1009
1009
 
1010
1010
  /* Read keyinformation */
1011
 
  key_info_length= (uint) uint2korr(head+28);
 
1011
  key_info_length= (uint32_t) uint2korr(head+28);
1012
1012
  lseek(file,(ulong) uint2korr(head+6),SEEK_SET);
1013
1013
  if (read_string(file,(unsigned char**) &disk_buff,key_info_length))
1014
1014
    goto err;                                   /* purecov: inspected */
1038
1038
 
1039
1039
    for (j=keyinfo->key_parts ; j-- ; key_part++)
1040
1040
    {
1041
 
      key_part->offset= (uint) uint2korr(strpos+2)-1;
1042
 
      key_part->key_type=       (uint) uint2korr(strpos+5);
 
1041
      key_part->offset= (uint32_t) uint2korr(strpos+2)-1;
 
1042
      key_part->key_type=       (uint32_t) uint2korr(strpos+5);
1043
1043
      if (new_frm_ver >= 1)
1044
1044
      {
1045
1045
        strpos+=9;
1179
1179
  /* WTF is with the share->fields+1 here... */
1180
1180
  if (!(field_ptr = (Field **)
1181
1181
        alloc_root(&share->mem_root,
1182
 
                   (uint) ((share->fields+1)*sizeof(Field*)+
 
1182
                   (uint32_t) ((share->fields+1)*sizeof(Field*)+
1183
1183
                           interval_count*sizeof(TYPELIB)+
1184
1184
                           (share->fields+interval_parts+
1185
1185
                            keys+3)*sizeof(char *)+
1188
1188
    goto err;                                   /* purecov: inspected */
1189
1189
 
1190
1190
  share->field= field_ptr;
1191
 
  read_length=(uint) (share->fields * field_pack_length +
1192
 
                      pos+ (uint) (n_length+int_length+com_length+
 
1191
  read_length=(uint32_t) (share->fields * field_pack_length +
 
1192
                      pos+ (uint32_t) (n_length+int_length+com_length+
1193
1193
                                   vcol_screen_length));
1194
1194
  if (read_string(file,(unsigned char**) &disk_buff,read_length))
1195
1195
    goto err;                                   /* purecov: inspected */
1201
1201
  if (!interval_count)
1202
1202
    share->intervals= 0;                        // For better debugging
1203
1203
  memcpy(names, strpos+(share->fields*field_pack_length),
1204
 
         (uint) (n_length+int_length));
 
1204
         (uint32_t) (n_length+int_length));
1205
1205
  comment_pos= (char *)(disk_buff+read_length-com_length-vcol_screen_length);
1206
1206
  vcol_screen_pos= names+(n_length+int_length);
1207
1207
  memcpy(vcol_screen_pos, disk_buff+read_length-vcol_screen_length,
1220
1220
         interval < share->intervals + interval_count;
1221
1221
         interval++)
1222
1222
    {
1223
 
      uint32_t count= (uint) (interval->count + 1) * sizeof(uint);
 
1223
      uint32_t count= (uint32_t) (interval->count + 1) * sizeof(uint32_t);
1224
1224
      if (!(interval->type_lengths= (uint32_t *) alloc_root(&share->mem_root,
1225
1225
                                                        count)))
1226
1226
        goto err;
1282
1282
      field_length= uint2korr(strpos+3);
1283
1283
      recpos=       uint3korr(strpos+5);
1284
1284
      pack_flag=    uint2korr(strpos+8);
1285
 
      unireg_type=  (uint) strpos[10];
1286
 
      interval_nr=  (uint) strpos[12];
 
1285
      unireg_type=  (uint32_t) strpos[10];
 
1286
      interval_nr=  (uint32_t) strpos[12];
1287
1287
      uint32_t comment_length=uint2korr(strpos+15);
1288
 
      field_type=(enum_field_types) (uint) strpos[13];
 
1288
      field_type=(enum_field_types) (uint32_t) strpos[13];
1289
1289
 
1290
1290
      {
1291
1291
        if (!strpos[14])
1292
1292
          charset= &my_charset_bin;
1293
 
        else if (!(charset=get_charset((uint) strpos[14])))
 
1293
        else if (!(charset=get_charset((uint32_t) strpos[14])))
1294
1294
        {
1295
1295
          error= 5; // Unknown or unavailable charset
1296
1296
          errarg= (int) strpos[14];
1328
1328
          byte 4-...  = virtual column expression (text data)
1329
1329
        */
1330
1330
        vcol_info= new virtual_column_info();
1331
 
        if ((uint)vcol_screen_pos[0] != 1)
 
1331
        if ((uint32_t)vcol_screen_pos[0] != 1)
1332
1332
        {
1333
1333
          error= 4;
1334
1334
          goto err;
1335
1335
        }
1336
1336
        field_type= (enum_field_types) (unsigned char) vcol_screen_pos[1];
1337
 
        fld_is_stored= (bool) (uint) vcol_screen_pos[2];
 
1337
        fld_is_stored= (bool) (uint32_t) vcol_screen_pos[2];
1338
1338
        vcol_info->expr_str.str= (char *)memdup_root(&share->mem_root,
1339
1339
                                                     vcol_screen_pos+
1340
 
                                                       (uint)FRM_VCOL_HEADER_SIZE,
 
1340
                                                       (uint32_t)FRM_VCOL_HEADER_SIZE,
1341
1341
                                                     vcol_info_length-
1342
 
                                                       (uint)FRM_VCOL_HEADER_SIZE);
1343
 
        vcol_info->expr_str.length= vcol_info_length-(uint)FRM_VCOL_HEADER_SIZE;
 
1342
                                                       (uint32_t)FRM_VCOL_HEADER_SIZE);
 
1343
        vcol_info->expr_str.length= vcol_info_length-(uint32_t)FRM_VCOL_HEADER_SIZE;
1344
1344
        vcol_screen_pos+= vcol_info_length;
1345
1345
        share->vfields++;
1346
1346
      }
1375
1375
      goto err;                 /* purecov: inspected */
1376
1376
    }
1377
1377
 
1378
 
    reg_field->flags|= ((uint)column_format << COLUMN_FORMAT_FLAGS);
 
1378
    reg_field->flags|= ((uint32_t)column_format << COLUMN_FORMAT_FLAGS);
1379
1379
    reg_field->field_index= i;
1380
1380
    reg_field->comment=comment;
1381
1381
    reg_field->vcol_info= vcol_info;
1411
1411
  /* Fix key->name and key_part->field */
1412
1412
  if (key_parts)
1413
1413
  {
1414
 
    uint32_t primary_key=(uint) (find_type((char*) "PRIMARY",
 
1414
    uint32_t primary_key=(uint32_t) (find_type((char*) "PRIMARY",
1415
1415
                                       &share->keynames, 3) - 1);
1416
1416
    int64_t ha_option= handler_file->ha_table_flags();
1417
1417
    keyinfo= share->key_info;
1455
1455
        key_part->type= field->key_type();
1456
1456
        if (field->null_ptr)
1457
1457
        {
1458
 
          key_part->null_offset=(uint) ((unsigned char*) field->null_ptr -
 
1458
          key_part->null_offset=(uint32_t) ((unsigned char*) field->null_ptr -
1459
1459
                                        share->default_values);
1460
1460
          key_part->null_bit= field->null_bit;
1461
1461
          key_part->store_length+=HA_KEY_NULL_LENGTH;
1566
1566
  if (share->found_next_number_field)
1567
1567
  {
1568
1568
    reg_field= *share->found_next_number_field;
1569
 
    if ((int) (share->next_number_index= (uint)
 
1569
    if ((int) (share->next_number_index= (uint32_t)
1570
1570
               find_ref_key(share->key_info, share->keys,
1571
1571
                            share->default_values, reg_field,
1572
1572
                            &share->next_number_key_offset,
1588
1588
    /* Store offsets to blob fields to find them fast */
1589
1589
    if (!(share->blob_field= save=
1590
1590
          (uint*) alloc_root(&share->mem_root,
1591
 
                             (uint) (share->blob_fields* sizeof(uint)))))
 
1591
                             (uint32_t) (share->blob_fields* sizeof(uint32_t)))))
1592
1592
      goto err;
1593
1593
    for (k=0, ptr= share->field ; *ptr ; ptr++, k++)
1594
1594
    {
2016
2016
#endif
2017
2017
 
2018
2018
  if (!(field_ptr = (Field **) alloc_root(&outparam->mem_root,
2019
 
                                          (uint) ((share->fields+1)*
 
2019
                                          (uint32_t) ((share->fields+1)*
2020
2020
                                                  sizeof(Field*)))))
2021
2021
    goto err;                                   /* purecov: inspected */
2022
2022
 
2036
2036
 
2037
2037
  if (share->found_next_number_field)
2038
2038
    outparam->found_next_number_field=
2039
 
      outparam->field[(uint) (share->found_next_number_field - share->field)];
 
2039
      outparam->field[(uint32_t) (share->found_next_number_field - share->field)];
2040
2040
  if (share->timestamp_field)
2041
2041
    outparam->timestamp_field= (Field_timestamp*) outparam->field[share->timestamp_field_offset];
2042
2042
 
2091
2091
    Process virtual columns, if any.
2092
2092
  */
2093
2093
  if (not (vfield_ptr = (Field **) alloc_root(&outparam->mem_root,
2094
 
                                              (uint) ((share->vfields+1)*
 
2094
                                              (uint32_t) ((share->vfields+1)*
2095
2095
                                                      sizeof(Field*)))))
2096
2096
    goto err;
2097
2097
 
2347
2347
  unsigned char buff[IO_SIZE];
2348
2348
  unsigned char *pos;
2349
2349
 
2350
 
  length=(uint) strlen(newname)+1;
 
2350
  length=(uint32_t) strlen(newname)+1;
2351
2351
  n_length=uint2korr(fileinfo+4);
2352
2352
  maxlength=uint2korr(fileinfo+6);
2353
2353
  names=uint2korr(fileinfo+8);
2358
2358
    newpos+=IO_SIZE;
2359
2359
    int4store(fileinfo+10,newpos);
2360
2360
    endpos= lseek(file,0,SEEK_END);/* Copy from file-end */
2361
 
    bufflength= (uint) (endpos & (IO_SIZE-1));  /* IO_SIZE is a power of 2 */
 
2361
    bufflength= (uint32_t) (endpos & (IO_SIZE-1));      /* IO_SIZE is a power of 2 */
2362
2362
 
2363
2363
    while (endpos > maxlength)
2364
2364
    {
2448
2448
  }
2449
2449
  case 5:
2450
2450
  {
2451
 
    const char *csname= get_charset_name((uint) errarg);
 
2451
    const char *csname= get_charset_name((uint32_t) errarg);
2452
2452
    char tmp[10];
2453
2453
    if (!csname || csname[0] =='?')
2454
2454
    {
2510
2510
    }
2511
2511
    else
2512
2512
      ptr++;
2513
 
    point_to_type->count= (uint) (*array - point_to_type->type_names);
 
2513
    point_to_type->count= (uint32_t) (*array - point_to_type->type_names);
2514
2514
    point_to_type++;
2515
2515
    *((*array)++)= NULL;                /* End of type */
2516
2516
  }
2526
2526
    return 0;
2527
2527
  result->count=strings.elements;
2528
2528
  result->name="";
2529
 
  uint32_t nbytes= (sizeof(char*) + sizeof(uint)) * (result->count + 1);
 
2529
  uint32_t nbytes= (sizeof(char*) + sizeof(uint32_t)) * (result->count + 1);
2530
2530
  if (!(result->type_names= (const char**) alloc_root(mem_root, nbytes)))
2531
2531
    return 0;
2532
2532
  result->type_lengths= (uint*) (result->type_names + result->count + 1);
2851
2851
  length= str.length();
2852
2852
  if (!length || !(to= (char*) alloc_root(mem,length+1)))
2853
2853
    return NULL;
2854
 
  memcpy(to,str.ptr(),(uint) length);
 
2854
  memcpy(to,str.ptr(),(uint32_t) length);
2855
2855
  to[length]=0;
2856
2856
  return to;
2857
2857
}
2971
2971
    name_length++;
2972
2972
  }
2973
2973
  /* Error if empty or too long column name */
2974
 
  return last_char_is_space || (uint) name_length > NAME_CHAR_LEN;
 
2974
  return last_char_is_space || (uint32_t) name_length > NAME_CHAR_LEN;
2975
2975
}
2976
2976
 
2977
2977
 
4128
4128
                        &share, sizeof(*share),
4129
4129
                        &reg_field, sizeof(Field*) * (field_count+1),
4130
4130
                        &default_field, sizeof(Field*) * (field_count),
4131
 
                        &blob_field, sizeof(uint)*(field_count+1),
 
4131
                        &blob_field, sizeof(uint32_t)*(field_count+1),
4132
4132
                        &from_field, sizeof(Field*)*field_count,
4133
4133
                        &copy_func, sizeof(*copy_func)*(copy_func_count+1),
4134
4134
                        &param->keyinfo, sizeof(*param->keyinfo),
4136
4136
                        sizeof(*key_part_info)*(param->group_parts+1),
4137
4137
                        &param->start_recinfo,
4138
4138
                        sizeof(*param->recinfo)*(field_count*2+4),
4139
 
                        &tmpname, (uint) strlen(path)+1,
 
4139
                        &tmpname, (uint32_t) strlen(path)+1,
4140
4140
                        &group_buff, (group && ! using_unique_constraint ?
4141
4141
                                      param->group_length : 0),
4142
4142
                        &bitmaps, bitmap_buffer_size(field_count)*2,
4338
4338
      null_count= 0;
4339
4339
    }
4340
4340
  }
4341
 
  assert(fieldnr == (uint) (reg_field - table->field));
4342
 
  assert(field_count >= (uint) (reg_field - table->field));
 
4341
  assert(fieldnr == (uint32_t) (reg_field - table->field));
 
4342
  assert(field_count >= (uint32_t) (reg_field - table->field));
4343
4343
  field_count= fieldnr;
4344
4344
  *reg_field= 0;
4345
4345
  *blob_field= 0;                               // End marker
4574
4574
          */
4575
4575
          keyinfo->flags|= HA_NULL_ARE_EQUAL;   // def. that NULL == NULL
4576
4576
          key_part_info->null_bit=field->null_bit;
4577
 
          key_part_info->null_offset= (uint) (field->null_ptr -
 
4577
          key_part_info->null_offset= (uint32_t) (field->null_ptr -
4578
4578
                                              (unsigned char*) table->record[0]);
4579
4579
          cur_group->buff++;                        // Pointer to field data
4580
4580
          group_buff++;                         // Skipp null flag
4636
4636
                                                (uint32_t) key_part_info->length,
4637
4637
                                                0,
4638
4638
                                                (unsigned char*) 0,
4639
 
                                                (uint) 0,
 
4639
                                                (uint32_t) 0,
4640
4640
                                                Field::NONE,
4641
4641
                                                NULL,
4642
4642
                                                table->s,
4745
4745
                        &table, sizeof(*table),
4746
4746
                        &share, sizeof(*share),
4747
4747
                        &field, (field_count + 1) * sizeof(Field*),
4748
 
                        &blob_field, (field_count+1) *sizeof(uint),
 
4748
                        &blob_field, (field_count+1) *sizeof(uint32_t),
4749
4749
                        &bitmaps, bitmap_buffer_size(field_count)*2,
4750
4750
                        NULL))
4751
4751
    return 0;
4777
4777
      null_count++;
4778
4778
 
4779
4779
    if ((*field)->flags & BLOB_FLAG)
4780
 
      share->blob_field[blob_count++]= (uint) (field - table->field);
 
4780
      share->blob_field[blob_count++]= (uint32_t) (field - table->field);
4781
4781
 
4782
4782
    field++;
4783
4783
  }
4949
4949
      if (!(key_field->flags & NOT_NULL_FLAG))
4950
4950
      {
4951
4951
        seg->null_bit= key_field->null_bit;
4952
 
        seg->null_pos= (uint) (key_field->null_ptr - (unsigned char*) record[0]);
 
4952
        seg->null_pos= (uint32_t) (key_field->null_ptr - (unsigned char*) record[0]);
4953
4953
        /*
4954
4954
          We are using a GROUP BY on something that contains NULL
4955
4955
          In this case we have to tell MyISAM that two NULL should
4968
4968
    create_info.data_file_length= ~(uint64_t) 0;
4969
4969
 
4970
4970
  if ((error=mi_create(share->table_name.str, share->keys, &keydef,
4971
 
                       (uint) (*recinfo-start_recinfo),
 
4971
                       (uint32_t) (*recinfo-start_recinfo),
4972
4972
                       start_recinfo,
4973
4973
                       share->uniques, &uniquedef,
4974
4974
                       &create_info,