do not crash on myrg_rprev/myrg_rnext if no current table

(as when previous myrg_rkey failed, e.g. found nothing)
parent a0cfa789
...@@ -23,8 +23,7 @@ MYRG_INFO *info, ...@@ -23,8 +23,7 @@ MYRG_INFO *info,
const byte *record) const byte *record)
{ {
if (!info->current_table) if (!info->current_table)
{ return my_errno=HA_ERR_NO_ACTIVE_RECORD ;
return(my_errno=HA_ERR_NO_ACTIVE_RECORD);
}
return mi_delete(info->current_table->table,record); return mi_delete(info->current_table->table,record);
} }
...@@ -20,9 +20,7 @@ ...@@ -20,9 +20,7 @@
#include "myrg_def.h" #include "myrg_def.h"
int myrg_lock_database( int myrg_lock_database(MYRG_INFO *info, int lock_type)
MYRG_INFO *info,
int lock_type)
{ {
int error,new_error; int error,new_error;
MYRG_TABLE *file; MYRG_TABLE *file;
......
...@@ -25,6 +25,9 @@ int myrg_rnext(MYRG_INFO *info, byte *buf, int inx) ...@@ -25,6 +25,9 @@ int myrg_rnext(MYRG_INFO *info, byte *buf, int inx)
int err; int err;
MI_INFO *mi; MI_INFO *mi;
if (!info->current_table)
return HA_ERR_KEY_NOT_FOUND;
/* at first, do rnext for the table found before */ /* at first, do rnext for the table found before */
if ((err=mi_rnext(info->current_table->table,NULL,inx))) if ((err=mi_rnext(info->current_table->table,NULL,inx)))
{ {
......
...@@ -25,8 +25,8 @@ int myrg_rprev(MYRG_INFO *info, byte *buf, int inx) ...@@ -25,8 +25,8 @@ int myrg_rprev(MYRG_INFO *info, byte *buf, int inx)
int err; int err;
MI_INFO *mi; MI_INFO *mi;
if (!info || !info->current_table) if (!info->current_table)
return HA_ERR_UNSUPPORTED; return HA_ERR_KEY_NOT_FOUND;
/* at first, do rprev for the table found before */ /* at first, do rprev for the table found before */
if ((err=mi_rprev(info->current_table->table,NULL,inx))) if ((err=mi_rprev(info->current_table->table,NULL,inx)))
......
...@@ -19,12 +19,10 @@ ...@@ -19,12 +19,10 @@
int myrg_rsame(MYRG_INFO *info,byte *record,int inx) int myrg_rsame(MYRG_INFO *info,byte *record,int inx)
{ {
if (inx) /* not yet used, should be 0 */ if (inx) /* not yet used, should be 0 */
{ return my_errno=HA_ERR_WRONG_INDEX;
return(my_errno=HA_ERR_WRONG_INDEX);
}
if (!info->current_table) if (!info->current_table)
{ return my_errno=HA_ERR_NO_ACTIVE_RECORD;
return(my_errno=HA_ERR_NO_ACTIVE_RECORD);
}
return mi_rsame(info->current_table->table,record,inx); return mi_rsame(info->current_table->table,record,inx);
} }
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
int myrg_update(register MYRG_INFO *info,const byte *oldrec, byte *newrec) int myrg_update(register MYRG_INFO *info,const byte *oldrec, byte *newrec)
{ {
if (!info->current_table) if (!info->current_table)
return(my_errno=HA_ERR_NO_ACTIVE_RECORD); return my_errno=HA_ERR_NO_ACTIVE_RECORD;
return mi_update(info->current_table->table,oldrec,newrec); return mi_update(info->current_table->table,oldrec,newrec);
} }
...@@ -26,5 +26,5 @@ int myrg_write(register MYRG_INFO *info, byte *rec) ...@@ -26,5 +26,5 @@ int myrg_write(register MYRG_INFO *info, byte *rec)
else if (info->merge_insert_method == MERGE_INSERT_TO_LAST) else if (info->merge_insert_method == MERGE_INSERT_TO_LAST)
return mi_write(info->end_table[-1].table,rec); return mi_write(info->end_table[-1].table,rec);
else /* unsupported insertion method */ else /* unsupported insertion method */
return (my_errno=HA_ERR_WRONG_COMMAND); return my_errno=HA_ERR_WRONG_COMMAND;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment