~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/records.cc

  • Committer: Mark Atwood
  • Date: 2008-10-16 11:33:16 UTC
  • mto: (520.1.13 drizzle)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: mark@fallenpegasus.com-20081016113316-ff6jdt31ck90sjdh
an implemention of the errmsg plugin

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(uchar *a,uchar *b);
 
33
static int rr_cmp(unsigned char *a,unsigned char *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, uint idx)
 
56
                          Table *table,
 
57
                          bool print_error, uint32_t 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
 
    VOID(table->file->extra(HA_EXTRA_MMAP));
 
156
    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) &&
195
194
        thd->variables.read_rnd_buff_size &&
196
195
        !(table->file->ha_table_flags() & HA_FAST_KEY_READ) &&
197
196
        (table->db_stat & HA_READ_ONLY ||
234
233
         !(table->s->db_options_in_use & HA_OPTION_PACK_RECORD) ||
235
234
         (use_record_cache < 0 &&
236
235
          !(table->file->ha_table_flags() & HA_NOT_DELETE_WITH_CACHE))))
237
 
      VOID(table->file->extra_opt(HA_EXTRA_CACHE,
238
 
                                  thd->variables.read_buff_size));
 
236
      table->file->extra_opt(HA_EXTRA_CACHE, thd->variables.read_buff_size);
239
237
  }
240
238
  /* 
241
239
    Do condition pushdown for UPDATE/DELETE.
257
255
{                   /* free cache if used */
258
256
  if (info->cache)
259
257
  {
260
 
    my_free_lock((char*) info->cache,MYF(0));
 
258
    free((char*) info->cache);
261
259
    info->cache=0;
262
260
  }
263
261
  if (info->table)
303
301
      break;
304
302
    }
305
303
  }
 
304
  update_virtual_fields_marked_for_write(info->table);
306
305
  return tmp;
307
306
}
308
307
 
375
374
      break;
376
375
    }
377
376
  }
 
377
  if (!tmp)
 
378
    update_virtual_fields_marked_for_write(info->table);
378
379
  return tmp;
379
380
}
380
381
 
419
420
{
420
421
  if (my_b_read(info->io_cache, info->rec_buf, info->ref_length))
421
422
    return -1;
422
 
  TABLE *table= info->table;
 
423
  Table *table= info->table;
423
424
  (*table->sort.unpack)(table->sort.addon_field, info->rec_buf);
424
425
 
425
426
  return 0;
428
429
static int rr_from_pointers(READ_RECORD *info)
429
430
{
430
431
  int tmp;
431
 
  uchar *cache_pos;
 
432
  unsigned char *cache_pos;
432
433
 
433
434
  for (;;)
434
435
  {
470
471
{
471
472
  if (info->cache_pos == info->cache_end)
472
473
    return -1;                      /* End of buffer */
473
 
  TABLE *table= info->table;
 
474
  Table *table= info->table;
474
475
  (*table->sort.unpack)(table->sort.addon_field, info->cache_pos);
475
476
  info->cache_pos+= info->ref_length;
476
477
 
480
481
 
481
482
static int init_rr_cache(THD *thd, READ_RECORD *info)
482
483
{
483
 
  uint rec_cache_size;
 
484
  uint32_t rec_cache_size;
484
485
 
485
486
  info->struct_length= 3+MAX_REFLENGTH;
486
487
  info->reclength= ALIGN_SIZE(info->table->s->reclength+1);
495
496
 
496
497
  // We have to allocate one more byte to use uint3korr (see comments for it)
497
498
  if (info->cache_records <= 2 ||
498
 
      !(info->cache=(uchar*) my_malloc_lock(rec_cache_size+info->cache_records*
 
499
      !(info->cache=(unsigned char*) my_malloc_lock(rec_cache_size+info->cache_records*
499
500
                                           info->struct_length+1,
500
501
                                           MYF(0))))
501
502
    return(1);
512
513
 
513
514
static int rr_from_cache(READ_RECORD *info)
514
515
{
515
 
  register uint i;
 
516
  register uint32_t i;
516
517
  uint32_t length;
517
518
  my_off_t rest_of_file;
518
519
  int16_t error;
519
 
  uchar *position,*ref_position,*record_pos;
 
520
  unsigned char *position,*ref_position,*record_pos;
520
521
  uint32_t record;
521
522
 
522
523
  for (;;)
581
582
} /* rr_from_cache */
582
583
 
583
584
 
584
 
static int rr_cmp(uchar *a,uchar *b)
 
585
static int rr_cmp(unsigned char *a,unsigned char *b)
585
586
{
586
587
  if (a[0] != b[0])
587
588
    return (int) a[0] - (int) b[0];