summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorunknown <ram@gw.mysql.r18.ru>2004-06-24 14:33:36 +0500
committerunknown <ram@gw.mysql.r18.ru>2004-06-24 14:33:36 +0500
commitf527bdb79c2d1188554873f3076d893825d8e454 (patch)
treea2aee3b26167ef91954283ea13304ef991056628 /sql/sql_select.cc
parent4b055292b13a5ffcccad07b83b947b995793fc62 (diff)
parentac82d8bb7979c4e327e7bf3f5ce3d1914684f991 (diff)
downloadmariadb-git-f527bdb79c2d1188554873f3076d893825d8e454.tar.gz
Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-4.1
into gw.mysql.r18.ru:/usr/home/ram/work/4.1.b4198 sql/sql_select.cc: Auto merged
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc27
1 files changed, 18 insertions, 9 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 7d0c56aed2b..151c25b0cca 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -131,7 +131,8 @@ static int remove_dup_with_hash_index(THD *thd,TABLE *table,
static int join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count);
static ulong used_blob_length(CACHE_FIELD **ptr);
static bool store_record_in_cache(JOIN_CACHE *cache);
-static void reset_cache(JOIN_CACHE *cache);
+static void reset_cache_read(JOIN_CACHE *cache);
+static void reset_cache_write(JOIN_CACHE *cache);
static void read_cached_record(JOIN_TAB *tab);
static bool cmp_buffer_with_ref(JOIN_TAB *tab);
static bool setup_new_fields(THD *thd,TABLE_LIST *tables,List<Item> &fields,
@@ -5843,8 +5844,7 @@ flush_cached_records(JOIN *join,JOIN_TAB *join_tab,bool skip_last)
/* read through all records */
if ((error=join_init_read_record(join_tab)))
{
- reset_cache(&join_tab->cache);
- join_tab->cache.records=0; join_tab->cache.ptr_record= (uint) ~0;
+ reset_cache_write(&join_tab->cache);
return -error; /* No records or error */
}
@@ -5867,21 +5867,23 @@ flush_cached_records(JOIN *join,JOIN_TAB *join_tab,bool skip_last)
!join_tab->cache.select->skip_record()))
{
uint i;
- reset_cache(&join_tab->cache);
+ reset_cache_read(&join_tab->cache);
for (i=(join_tab->cache.records- (skip_last ? 1 : 0)) ; i-- > 0 ;)
{
read_cached_record(join_tab);
if (!select || !select->skip_record())
if ((error=(join_tab->next_select)(join,join_tab+1,0)) < 0)
+ {
+ reset_cache_write(&join_tab->cache);
return error; /* purecov: inspected */
+ }
}
}
} while (!(error=info->read_record(info)));
if (skip_last)
read_cached_record(join_tab); // Restore current record
- reset_cache(&join_tab->cache);
- join_tab->cache.records=0; join_tab->cache.ptr_record= (uint) ~0;
+ reset_cache_write(&join_tab->cache);
if (error > 0) // Fatal error
return -1; /* purecov: inspected */
for (JOIN_TAB *tmp2=join->join_tab; tmp2 != join_tab ; tmp2++)
@@ -7776,7 +7778,6 @@ join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count)
}
}
- cache->records=0; cache->ptr_record= (uint) ~0;
cache->length=length+blobs*sizeof(char*);
cache->blobs=blobs;
*blob_ptr=0; /* End sequentel */
@@ -7784,7 +7785,7 @@ join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count)
if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
DBUG_RETURN(1); /* Don't use cache */ /* purecov: inspected */
cache->end=cache->buff+size;
- reset_cache(cache);
+ reset_cache_write(cache);
DBUG_RETURN(0);
}
@@ -7868,13 +7869,21 @@ store_record_in_cache(JOIN_CACHE *cache)
static void
-reset_cache(JOIN_CACHE *cache)
+reset_cache_read(JOIN_CACHE *cache)
{
cache->record_nr=0;
cache->pos=cache->buff;
}
+static void reset_cache_write(JOIN_CACHE *cache)
+{
+ reset_cache_read(cache);
+ cache->records= 0;
+ cache->ptr_record= (uint) ~0;
+}
+
+
static void
read_cached_record(JOIN_TAB *tab)
{