~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/records.cc

  • Committer: Andy Lester
  • Date: 2008-08-09 05:13:22 UTC
  • mto: (266.1.29 use-replace-funcs)
  • mto: This revision was merged to the branch mainline in revision 287.
  • Revision ID: andy@petdance.com-20080809051322-dzas70no2mv6c9i5
removed incorrect comment

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
static int rr_from_pointers(READ_RECORD *info);
31
31
static int rr_from_cache(READ_RECORD *info);
32
32
static int init_rr_cache(THD *thd, READ_RECORD *info);
33
 
static int rr_cmp(unsigned char *a,unsigned char *b);
 
33
static int rr_cmp(uchar *a,uchar *b);
34
34
static int rr_index_first(READ_RECORD *info);
35
35
static int rr_index(READ_RECORD *info);
36
36
 
53
53
 
54
54
void init_read_record_idx(READ_RECORD *info,
55
55
                          THD *thd __attribute__((unused)),
56
 
                          Table *table,
57
 
                          bool print_error, uint32_t idx)
 
56
                          TABLE *table,
 
57
                          bool print_error, uint idx)
58
58
{
59
59
  empty_record(table);
60
60
  memset(info, 0, sizeof(*info));
139
139
    This is the most basic access method of a table using rnd_init,
140
140
    rnd_next and rnd_end. No indexes are used.
141
141
*/
142
 
void init_read_record(READ_RECORD *info,THD *thd, Table *table,
 
142
void init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
143
143
                      SQL_SELECT *select,
144
144
                      int use_record_cache, bool print_error)
145
145
{
153
153
  
154
154
  if (table->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE &&
155
155
      !table->sort.addon_field)
156
 
    table->file->extra(HA_EXTRA_MMAP);
 
156
    VOID(table->file->extra(HA_EXTRA_MMAP));
157
157
  
158
158
  if (table->sort.addon_field)
159
159
  {
191
191
      and table->sort.io_cache is read sequentially
192
192
    */
193
193
    if (!table->sort.addon_field &&
 
194
        ! (specialflag & SPECIAL_SAFE_MODE) &&
194
195
        thd->variables.read_rnd_buff_size &&
195
196
        !(table->file->ha_table_flags() & HA_FAST_KEY_READ) &&
196
197
        (table->db_stat & HA_READ_ONLY ||
233
234
         !(table->s->db_options_in_use & HA_OPTION_PACK_RECORD) ||
234
235
         (use_record_cache < 0 &&
235
236
          !(table->file->ha_table_flags() & HA_NOT_DELETE_WITH_CACHE))))
236
 
      table->file->extra_opt(HA_EXTRA_CACHE, thd->variables.read_buff_size);
 
237
      VOID(table->file->extra_opt(HA_EXTRA_CACHE,
 
238
                                  thd->variables.read_buff_size));
237
239
  }
238
240
  /* 
239
241
    Do condition pushdown for UPDATE/DELETE.
255
257
{                   /* free cache if used */
256
258
  if (info->cache)
257
259
  {
258
 
    free((char*) info->cache);
 
260
    my_free_lock((char*) info->cache,MYF(0));
259
261
    info->cache=0;
260
262
  }
261
263
  if (info->table)
301
303
      break;
302
304
    }
303
305
  }
304
 
  update_virtual_fields_marked_for_write(info->table);
305
306
  return tmp;
306
307
}
307
308
 
374
375
      break;
375
376
    }
376
377
  }
377
 
  if (!tmp)
378
 
    update_virtual_fields_marked_for_write(info->table);
379
378
  return tmp;
380
379
}
381
380
 
420
419
{
421
420
  if (my_b_read(info->io_cache, info->rec_buf, info->ref_length))
422
421
    return -1;
423
 
  Table *table= info->table;
 
422
  TABLE *table= info->table;
424
423
  (*table->sort.unpack)(table->sort.addon_field, info->rec_buf);
425
424
 
426
425
  return 0;
429
428
static int rr_from_pointers(READ_RECORD *info)
430
429
{
431
430
  int tmp;
432
 
  unsigned char *cache_pos;
 
431
  uchar *cache_pos;
433
432
 
434
433
  for (;;)
435
434
  {
471
470
{
472
471
  if (info->cache_pos == info->cache_end)
473
472
    return -1;                      /* End of buffer */
474
 
  Table *table= info->table;
 
473
  TABLE *table= info->table;
475
474
  (*table->sort.unpack)(table->sort.addon_field, info->cache_pos);
476
475
  info->cache_pos+= info->ref_length;
477
476
 
481
480
 
482
481
static int init_rr_cache(THD *thd, READ_RECORD *info)
483
482
{
484
 
  uint32_t rec_cache_size;
 
483
  uint rec_cache_size;
485
484
 
486
485
  info->struct_length= 3+MAX_REFLENGTH;
487
486
  info->reclength= ALIGN_SIZE(info->table->s->reclength+1);
496
495
 
497
496
  // We have to allocate one more byte to use uint3korr (see comments for it)
498
497
  if (info->cache_records <= 2 ||
499
 
      !(info->cache=(unsigned char*) my_malloc_lock(rec_cache_size+info->cache_records*
 
498
      !(info->cache=(uchar*) my_malloc_lock(rec_cache_size+info->cache_records*
500
499
                                           info->struct_length+1,
501
500
                                           MYF(0))))
502
501
    return(1);
513
512
 
514
513
static int rr_from_cache(READ_RECORD *info)
515
514
{
516
 
  register uint32_t i;
517
 
  uint32_t length;
 
515
  register uint i;
 
516
  ulong length;
518
517
  my_off_t rest_of_file;
519
518
  int16_t error;
520
 
  unsigned char *position,*ref_position,*record_pos;
521
 
  uint32_t record;
 
519
  uchar *position,*ref_position,*record_pos;
 
520
  ulong record;
522
521
 
523
522
  for (;;)
524
523
  {
542
541
    length=info->rec_cache_size;
543
542
    rest_of_file=info->io_cache->end_of_file - my_b_tell(info->io_cache);
544
543
    if ((my_off_t) length > rest_of_file)
545
 
      length= (uint32_t) rest_of_file;
 
544
      length= (ulong) rest_of_file;
546
545
    if (!length || my_b_read(info->io_cache,info->cache,length))
547
546
    {
548
547
      return -1;                        /* End of file */
582
581
} /* rr_from_cache */
583
582
 
584
583
 
585
 
static int rr_cmp(unsigned char *a,unsigned char *b)
 
584
static int rr_cmp(uchar *a,uchar *b)
586
585
{
587
586
  if (a[0] != b[0])
588
587
    return (int) a[0] - (int) b[0];