~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/join_cache.cc

  • Committer: Brian Aker
  • Date: 2010-05-18 21:54:40 UTC
  • mto: This revision was merged to the branch mainline in revision 1540.
  • Revision ID: brian@gaz-20100518215440-ieapaanbp9yfg943
Update for Join structure changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
namespace drizzled
39
39
{
40
40
 
41
 
static uint32_t used_blob_length(CACHE_FIELD **ptr);
 
41
static uint32_t used_blob_length(CacheField **ptr);
42
42
 
43
 
static uint32_t used_blob_length(CACHE_FIELD **ptr)
 
43
static uint32_t used_blob_length(CacheField **ptr)
44
44
{
45
45
  uint32_t length,blob_length;
46
46
  for (length=0 ; *ptr ; ptr++)
60
60
******************************************************************************/
61
61
int join_init_cache(Session *session, JoinTable *tables, uint32_t table_count)
62
62
{
63
 
  register unsigned int i;
64
63
  unsigned int length, blobs;
65
64
  size_t size;
66
 
  CACHE_FIELD *copy,**blob_ptr;
67
 
  JOIN_CACHE  *cache;
 
65
  CacheField *copy,**blob_ptr;
 
66
  JoinCache  *cache;
68
67
  JoinTable *join_tab;
69
68
 
70
69
  cache= &tables[table_count].cache;
71
70
  cache->fields=blobs=0;
72
71
 
73
72
  join_tab= tables;
74
 
  for (i=0 ; i < table_count ; i++,join_tab++)
 
73
  for (unsigned int i= 0; i < table_count ; i++, join_tab++)
75
74
  {
76
75
    if (!join_tab->used_fieldlength)            /* Not calced yet */
77
76
      calc_used_field_length(session, join_tab);
85
84
      join_tab->used_fieldlength += join_tab->table->cursor->ref_length;
86
85
    }
87
86
  }
88
 
  if (!(cache->field=(CACHE_FIELD*)
89
 
        memory::sql_alloc(sizeof(CACHE_FIELD)*(cache->fields+table_count*2)+(blobs+1)* sizeof(CACHE_FIELD*))))
 
87
  if (!(cache->field=(CacheField*)
 
88
        memory::sql_alloc(sizeof(CacheField)*(cache->fields+table_count*2)+(blobs+1)* sizeof(CacheField*))))
90
89
  {
91
90
    free((unsigned char*) cache->buff);
92
91
    cache->buff=0;
93
92
    return(1);
94
93
  }
95
94
  copy=cache->field;
96
 
  blob_ptr=cache->blob_ptr=(CACHE_FIELD**)
 
95
  blob_ptr=cache->blob_ptr=(CacheField**)
97
96
    (cache->field+cache->fields+table_count*2);
98
97
 
99
98
  length=0;
100
 
  for (i=0 ; i < table_count ; i++)
 
99
  for (unsigned int i= 0 ; i < table_count ; i++)
101
100
  {
102
101
    uint32_t null_fields=0, used_fields;
103
102
    Field **f_ptr,*field;
170
169
  return 0;
171
170
}
172
171
 
173
 
bool store_record_in_cache(JOIN_CACHE *cache)
 
172
bool store_record_in_cache(JoinCache *cache)
174
173
{
175
174
  uint32_t length;
176
175
  unsigned char *pos;
177
 
  CACHE_FIELD *copy,*end_field;
 
176
  CacheField *copy,*end_field;
178
177
  bool last_record;
179
178
 
180
179
  pos= cache->pos;
233
232
  return last_record || (size_t) (cache->end - pos) < cache->length;
234
233
}
235
234
 
236
 
void reset_cache_read(JOIN_CACHE *cache)
 
235
void reset_cache_read(JoinCache *cache)
237
236
{
238
237
  cache->record_nr= 0;
239
238
  cache->pos= cache->buff;
240
239
}
241
240
 
242
 
void reset_cache_write(JOIN_CACHE *cache)
 
241
void reset_cache_write(JoinCache *cache)
243
242
{
244
243
  reset_cache_read(cache);
245
244
  cache->records= 0;