~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/join_cache.cc

Merge Andrew - fix bug #663765: Some unittests are won't compile in GCC 4.5
Merge Andrew - Add a GLOBAL UPPER bound to cap SORT BUFFER memory use

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "config.h"
31
31
#include "drizzled/sql_select.h" /* include join.h */
32
32
#include "drizzled/field/blob.h"
 
33
#include "drizzled/drizzled.h"
 
34
#include "drizzled/internal/my_sys.h"
33
35
 
34
36
#include <algorithm>
35
37
 
87
89
  if (!(cache->field=(CacheField*)
88
90
        memory::sql_alloc(sizeof(CacheField)*(cache->fields+table_count*2)+(blobs+1)* sizeof(CacheField*))))
89
91
  {
 
92
    size= cache->end - cache->buff;
 
93
    global_join_buffer.sub(size);
90
94
    free((unsigned char*) cache->buff);
91
95
    cache->buff=0;
92
96
    return(1);
162
166
  cache->blobs= blobs;
163
167
  *blob_ptr= NULL;                                      /* End sequentel */
164
168
  size= max((size_t) session->variables.join_buff_size, (size_t)cache->length);
 
169
  if (not global_join_buffer.add(size))
 
170
  {
 
171
    my_error(ER_OUT_OF_GLOBAL_JOINMEMORY, MYF(ME_ERROR+ME_WAITTANG));
 
172
    return 1;
 
173
  }
165
174
  if (!(cache->buff= (unsigned char*) malloc(size)))
166
175
    return 1;
167
176
  cache->end= cache->buff+size;