summaryrefslogtreecommitdiff
path: root/libmysqld/emb_qcache.cc
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2004-01-07 16:41:09 +0400
committerunknown <hf@deer.(none)>2004-01-07 16:41:09 +0400
commit902c361910cdec368c5baec1be6079978a46f1a8 (patch)
tree344ec2a77b98d518354cc4178e4801ea2ddf2def /libmysqld/emb_qcache.cc
parentfae79aeca552593a830cb95e77ecb32a012faf70 (diff)
downloadmariadb-git-902c361910cdec368c5baec1be6079978a46f1a8.tar.gz
SCRUM
WL#1246 (Query cache in embedded library) Some fixes after testing libmysqld/emb_qcache.cc: code added to check if the recordset has no rows sql/sql_cache.cc: this code should not work if the query isn't cacheable
Diffstat (limited to 'libmysqld/emb_qcache.cc')
-rw-r--r--libmysqld/emb_qcache.cc32
1 files changed, 24 insertions, 8 deletions
diff --git a/libmysqld/emb_qcache.cc b/libmysqld/emb_qcache.cc
index 0374ab58784..4dac154ab80 100644
--- a/libmysqld/emb_qcache.cc
+++ b/libmysqld/emb_qcache.cc
@@ -284,11 +284,18 @@ uint emb_count_querycache_size(THD *thd)
MYSQL *mysql= thd->mysql;
MYSQL_FIELD *field= mysql->fields;
MYSQL_FIELD *field_end= field + mysql->field_count;
+ MYSQL_ROWS *cur_row=NULL;
+ my_ulonglong n_rows=0;
- *thd->data->prev_ptr= NULL; // this marks the last record
- MYSQL_ROWS *cur_row= thd->data->data;
-
- result= 4+8 + (42 + 4*thd->data->rows)*mysql->field_count;
+ if (!field)
+ return 0;
+ if (thd->data)
+ {
+ *thd->data->prev_ptr= NULL; // this marks the last record
+ cur_row= thd->data->data;
+ n_rows= thd->data->rows;
+ }
+ result= 4+8 + (42 + 4*n_rows)*mysql->field_count;
for(; field < field_end; field++)
{
@@ -315,12 +322,21 @@ void emb_store_querycache_result(Querycache_stream *dst, THD *thd)
MYSQL *mysql= thd->mysql;
MYSQL_FIELD *field= mysql->fields;
MYSQL_FIELD *field_end= field + mysql->field_count;
-
- *thd->data->prev_ptr= NULL; // this marks the last record
- MYSQL_ROWS *cur_row= thd->data->data;
+ MYSQL_ROWS *cur_row= NULL;
+ my_ulonglong n_rows= 0;
+
+ if (!field)
+ return;
+
+ if (thd->data)
+ {
+ *thd->data->prev_ptr= NULL; // this marks the last record
+ cur_row= thd->data->data;
+ n_rows= thd->data->rows;
+ }
dst->store_int((uint)mysql->field_count);
- dst->store_ll((uint)thd->data->rows);
+ dst->store_ll((uint)n_rows);
for(; field < field_end; field++)
{