Commit 9f45c9e3 authored by serg@serg.mylan's avatar serg@serg.mylan

followup to handler cleanup

parent cfd78595
...@@ -1181,3 +1181,12 @@ a ...@@ -1181,3 +1181,12 @@ a
A A
a a
drop table t1; drop table t1;
set autocommit=0;
create table t1(b varchar(30)) engine=bdb;
insert into t1 values ('one');
commit;
select b FROM t1 outer_table where
exists (select 'two' from t1 where 'two' = outer_table.b);
b
drop table t1;
set autocommit=1;
...@@ -822,3 +822,28 @@ alter table t1 modify a char(10) binary; ...@@ -822,3 +822,28 @@ alter table t1 modify a char(10) binary;
explain select a from t1; explain select a from t1;
select a from t1; select a from t1;
drop table t1; drop table t1;
#
# Bug #4000: problem with active cursor.
#
set autocommit=0;
create table t1(b varchar(30)) engine=bdb;
insert into t1 values ('one');
commit;
select b FROM t1 outer_table where
exists (select 'two' from t1 where 'two' = outer_table.b);
drop table t1;
set autocommit=1;
#
# Bug #4089: subselect and open cursor.
#
#create table t1(a int primary key, b varchar(30)) engine=bdb;
#insert into t1 values (1,'one'), (2,'two'), (3,'three'), (4,'four');
#create table t2 like t1;
#insert into t2 (a, b)
# select a, b from t1 where (a, b) in (select a, b from t1);
#select * from t2;
#drop table t1, t2;
...@@ -481,13 +481,13 @@ int ha_archive::update_row(const byte * old_data, byte * new_data) ...@@ -481,13 +481,13 @@ int ha_archive::update_row(const byte * old_data, byte * new_data)
{ {
DBUG_ENTER("ha_archive::update_row"); DBUG_ENTER("ha_archive::update_row");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
int ha_archive::delete_row(const byte * buf) int ha_archive::delete_row(const byte * buf)
{ {
DBUG_ENTER("ha_archive::delete_row"); DBUG_ENTER("ha_archive::delete_row");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
int ha_archive::index_read(byte * buf, const byte * key, int ha_archive::index_read(byte * buf, const byte * key,
...@@ -496,7 +496,7 @@ int ha_archive::index_read(byte * buf, const byte * key, ...@@ -496,7 +496,7 @@ int ha_archive::index_read(byte * buf, const byte * key,
__attribute__((unused))) __attribute__((unused)))
{ {
DBUG_ENTER("ha_archive::index_read"); DBUG_ENTER("ha_archive::index_read");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
int ha_archive::index_read_idx(byte * buf, uint index, const byte * key, int ha_archive::index_read_idx(byte * buf, uint index, const byte * key,
...@@ -505,32 +505,32 @@ int ha_archive::index_read_idx(byte * buf, uint index, const byte * key, ...@@ -505,32 +505,32 @@ int ha_archive::index_read_idx(byte * buf, uint index, const byte * key,
__attribute__((unused))) __attribute__((unused)))
{ {
DBUG_ENTER("ha_archive::index_read_idx"); DBUG_ENTER("ha_archive::index_read_idx");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
int ha_archive::index_next(byte * buf) int ha_archive::index_next(byte * buf)
{ {
DBUG_ENTER("ha_archive::index_next"); DBUG_ENTER("ha_archive::index_next");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
int ha_archive::index_prev(byte * buf) int ha_archive::index_prev(byte * buf)
{ {
DBUG_ENTER("ha_archive::index_prev"); DBUG_ENTER("ha_archive::index_prev");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
int ha_archive::index_first(byte * buf) int ha_archive::index_first(byte * buf)
{ {
DBUG_ENTER("ha_archive::index_first"); DBUG_ENTER("ha_archive::index_first");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
int ha_archive::index_last(byte * buf) int ha_archive::index_last(byte * buf)
{ {
DBUG_ENTER("ha_archive::index_last"); DBUG_ENTER("ha_archive::index_last");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
...@@ -581,6 +581,6 @@ ha_rows ha_archive::records_in_range(int inx, ...@@ -581,6 +581,6 @@ ha_rows ha_archive::records_in_range(int inx,
enum ha_rkey_function end_search_flag) enum ha_rkey_function end_search_flag)
{ {
DBUG_ENTER("ha_archive::records_in_range "); DBUG_ENTER("ha_archive::records_in_range ");
DBUG_RETURN(records); // HA_ERR_NOT_IMPLEMENTED DBUG_RETURN(records); // HA_ERR_WRONG_COMMAND
} }
#endif /* HAVE_ARCHIVE_DB */ #endif /* HAVE_ARCHIVE_DB */
...@@ -69,21 +69,18 @@ public: ...@@ -69,21 +69,18 @@ public:
const char **bas_ext() const; const char **bas_ext() const;
ulong table_flags() const ulong table_flags() const
{ {
return (HA_REC_NOT_IN_SEQ | HA_NOT_EXACT_COUNT | HA_NO_WRITE_DELAYED | return (HA_REC_NOT_IN_SEQ | HA_NOT_EXACT_COUNT | HA_NO_AUTO_INCREMENT |
HA_NO_AUTO_INCREMENT); HA_FILE_BASED);
} }
ulong index_flags(uint inx) const ulong index_flags(uint idx, uint part) const
{ {
return 0; return 0;
} }
/* /*
This is just a default, there is no real limit as far as Have to put something here, there is no real limit as far as
archive is concerned. archive is concerned.
*/ */
uint max_record_length() const { return HA_MAX_REC_LENGTH; } uint max_supported_record_length() const { return UINT_MAX; }
uint max_keys() const { return 0; }
uint max_key_parts() const { return 0; }
uint max_key_length() const { return 0; }
/* /*
Called in test_quick_select to determine if indexes should be used. Called in test_quick_select to determine if indexes should be used.
*/ */
......
...@@ -251,7 +251,7 @@ int ha_example::close(void) ...@@ -251,7 +251,7 @@ int ha_example::close(void)
int ha_example::write_row(byte * buf) int ha_example::write_row(byte * buf)
{ {
DBUG_ENTER("ha_example::write_row"); DBUG_ENTER("ha_example::write_row");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
...@@ -274,7 +274,7 @@ int ha_example::update_row(const byte * old_data, byte * new_data) ...@@ -274,7 +274,7 @@ int ha_example::update_row(const byte * old_data, byte * new_data)
{ {
DBUG_ENTER("ha_example::update_row"); DBUG_ENTER("ha_example::update_row");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
...@@ -294,7 +294,7 @@ int ha_example::update_row(const byte * old_data, byte * new_data) ...@@ -294,7 +294,7 @@ int ha_example::update_row(const byte * old_data, byte * new_data)
int ha_example::delete_row(const byte * buf) int ha_example::delete_row(const byte * buf)
{ {
DBUG_ENTER("ha_example::delete_row"); DBUG_ENTER("ha_example::delete_row");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
...@@ -309,7 +309,7 @@ int ha_example::index_read(byte * buf, const byte * key, ...@@ -309,7 +309,7 @@ int ha_example::index_read(byte * buf, const byte * key,
__attribute__((unused))) __attribute__((unused)))
{ {
DBUG_ENTER("ha_example::index_read"); DBUG_ENTER("ha_example::index_read");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
...@@ -323,7 +323,7 @@ int ha_example::index_read_idx(byte * buf, uint index, const byte * key, ...@@ -323,7 +323,7 @@ int ha_example::index_read_idx(byte * buf, uint index, const byte * key,
__attribute__((unused))) __attribute__((unused)))
{ {
DBUG_ENTER("ha_example::index_read_idx"); DBUG_ENTER("ha_example::index_read_idx");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
...@@ -333,7 +333,7 @@ int ha_example::index_read_idx(byte * buf, uint index, const byte * key, ...@@ -333,7 +333,7 @@ int ha_example::index_read_idx(byte * buf, uint index, const byte * key,
int ha_example::index_next(byte * buf) int ha_example::index_next(byte * buf)
{ {
DBUG_ENTER("ha_example::index_next"); DBUG_ENTER("ha_example::index_next");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
...@@ -343,7 +343,7 @@ int ha_example::index_next(byte * buf) ...@@ -343,7 +343,7 @@ int ha_example::index_next(byte * buf)
int ha_example::index_prev(byte * buf) int ha_example::index_prev(byte * buf)
{ {
DBUG_ENTER("ha_example::index_prev"); DBUG_ENTER("ha_example::index_prev");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
...@@ -356,7 +356,7 @@ int ha_example::index_prev(byte * buf) ...@@ -356,7 +356,7 @@ int ha_example::index_prev(byte * buf)
int ha_example::index_first(byte * buf) int ha_example::index_first(byte * buf)
{ {
DBUG_ENTER("ha_example::index_first"); DBUG_ENTER("ha_example::index_first");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
...@@ -369,7 +369,7 @@ int ha_example::index_first(byte * buf) ...@@ -369,7 +369,7 @@ int ha_example::index_first(byte * buf)
int ha_example::index_last(byte * buf) int ha_example::index_last(byte * buf)
{ {
DBUG_ENTER("ha_example::index_last"); DBUG_ENTER("ha_example::index_last");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
...@@ -385,9 +385,14 @@ int ha_example::index_last(byte * buf) ...@@ -385,9 +385,14 @@ int ha_example::index_last(byte * buf)
int ha_example::rnd_init(bool scan) int ha_example::rnd_init(bool scan)
{ {
DBUG_ENTER("ha_example::rnd_init"); DBUG_ENTER("ha_example::rnd_init");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
int ha_example::rnd_end()
{
DBUG_ENTER("ha_example::rnd_end");
DBUG_RETURN(0);
}
/* /*
This is called for each row of the table scan. When you run out of records This is called for each row of the table scan. When you run out of records
...@@ -436,7 +441,7 @@ void ha_example::position(const byte *record) ...@@ -436,7 +441,7 @@ void ha_example::position(const byte *record)
int ha_example::rnd_pos(byte * buf, byte *pos) int ha_example::rnd_pos(byte * buf, byte *pos)
{ {
DBUG_ENTER("ha_example::rnd_pos"); DBUG_ENTER("ha_example::rnd_pos");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
...@@ -529,7 +534,7 @@ int ha_example::reset(void) ...@@ -529,7 +534,7 @@ int ha_example::reset(void)
int ha_example::delete_all_rows() int ha_example::delete_all_rows()
{ {
DBUG_ENTER("ha_example::delete_all_rows"); DBUG_ENTER("ha_example::delete_all_rows");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
...@@ -623,7 +628,7 @@ int ha_example::delete_table(const char *name) ...@@ -623,7 +628,7 @@ int ha_example::delete_table(const char *name)
int ha_example::rename_table(const char * from, const char * to) int ha_example::rename_table(const char * from, const char * to)
{ {
DBUG_ENTER("ha_example::rename_table "); DBUG_ENTER("ha_example::rename_table ");
DBUG_RETURN(HA_ERR_NOT_IMPLEMENTED); DBUG_RETURN(HA_ERR_WRONG_COMMAND);
} }
/* /*
......
...@@ -53,13 +53,16 @@ public: ...@@ -53,13 +53,16 @@ public:
} }
/* The name that will be used for display purposes */ /* The name that will be used for display purposes */
const char *table_type() const { return "EXAMPLE"; } const char *table_type() const { return "EXAMPLE"; }
/* The name of the index type that will be used for display */ /*
const char *index_type(uint inx) { return "NONE"; } The name of the index type that will be used for display
don't implement this method unless you really have indexes
*/
const char *index_type(uint inx) { return "HASH"; }
const char **bas_ext() const; const char **bas_ext() const;
/* /*
This is a list of flags that says what the storage engine This is a list of flags that says what the storage engine
implements. The current table flags are documented in implements. The current table flags are documented in
table_flags. handler.h
*/ */
ulong table_flags() const ulong table_flags() const
{ {
...@@ -71,18 +74,24 @@ public: ...@@ -71,18 +74,24 @@ public:
handler.h. If you do not implement indexes, just return zero handler.h. If you do not implement indexes, just return zero
here. here.
*/ */
ulong index_flags(uint inx) const ulong index_flags(uint inx, uint part) const
{ {
return 0; return 0;
} }
/* /*
unireg.cc will call the following to make sure that the storage engine can unireg.cc will call the following to make sure that the storage engine can
handle the data it is about to send. handle the data it is about to send.
Return *real* limits of your storage engine here. MySQL will do
min(your_limits, MySQL_limits) automatically
There is no need to implement ..._key_... methods if you don't suport
indexes.
*/ */
uint max_record_length() const { return HA_MAX_REC_LENGTH; } uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; }
uint max_keys() const { return 0; } uint max_supported_keys() const { return 0; }
uint max_key_parts() const { return 0; } uint max_supported_key_parts() const { return 0; }
uint max_key_length() const { return 0; } uint max_supported_key_length() const { return 0; }
/* /*
Called in test_quick_select to determine if indexes should be used. Called in test_quick_select to determine if indexes should be used.
*/ */
...@@ -94,9 +103,13 @@ public: ...@@ -94,9 +103,13 @@ public:
/* /*
Everything below are methods that we implment in ha_example.cc. Everything below are methods that we implment in ha_example.cc.
Most of these methods are not obligatory, skip them and
MySQL will treat them as not implemented
*/ */
int open(const char *name, int mode, uint test_if_locked); int open(const char *name, int mode, uint test_if_locked); // required
int close(void); int close(void); // required
int write_row(byte * buf); int write_row(byte * buf);
int update_row(const byte * old_data, byte * new_data); int update_row(const byte * old_data, byte * new_data);
int delete_row(const byte * buf); int delete_row(const byte * buf);
...@@ -108,21 +121,32 @@ public: ...@@ -108,21 +121,32 @@ public:
int index_prev(byte * buf); int index_prev(byte * buf);
int index_first(byte * buf); int index_first(byte * buf);
int index_last(byte * buf); int index_last(byte * buf);
int rnd_init(bool scan=1); /*
int rnd_next(byte *buf); unlike index_init(), rnd_init() can be called two times
int rnd_pos(byte * buf, byte *pos); without rnd_end() in between (it only makes sense if scan=1).
void position(const byte *record); then the second call should prepare for the new table scan
void info(uint); (e.g if rnd_init allocates the cursor, second call should
position it to the start of the table, no need to deallocate
and allocate it again
*/
int rnd_init(bool scan); //required
int rnd_end();
int rnd_next(byte *buf); //required
int rnd_pos(byte * buf, byte *pos); //required
void position(const byte *record); //required
void info(uint); //required
int extra(enum ha_extra_function operation); int extra(enum ha_extra_function operation);
int reset(void); int reset(void);
int external_lock(THD *thd, int lock_type); int external_lock(THD *thd, int lock_type); //required
int delete_all_rows(void); int delete_all_rows(void);
ha_rows records_in_range(uint inx, key_range *min_key, ha_rows records_in_range(uint inx, key_range *min_key,
key_range *max_key); key_range *max_key);
int delete_table(const char *from); int delete_table(const char *from);
int rename_table(const char * from, const char * to); int rename_table(const char * from, const char * to);
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); int create(const char *name, TABLE *form,
HA_CREATE_INFO *create_info); //required
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
enum thr_lock_type lock_type); enum thr_lock_type lock_type); //required
}; };
...@@ -1583,7 +1583,7 @@ int ha_berkeley::index_last(byte * buf) ...@@ -1583,7 +1583,7 @@ int ha_berkeley::index_last(byte * buf)
int ha_berkeley::rnd_init(bool scan) int ha_berkeley::rnd_init(bool scan)
{ {
DBUG_ENTER("rnd_init"); DBUG_ENTER("rnd_init");
DBUG_ASSERT(active_index==MAX_KEY); //DBUG_ASSERT(active_index==MAX_KEY);
current_row.flags=DB_DBT_REALLOC; current_row.flags=DB_DBT_REALLOC;
DBUG_RETURN(index_init(primary_key)); DBUG_RETURN(index_init(primary_key));
} }
......
...@@ -88,7 +88,7 @@ class ha_berkeley: public handler ...@@ -88,7 +88,7 @@ class ha_berkeley: public handler
public: public:
ha_berkeley(TABLE *table): handler(table), alloc_ptr(0),rec_buff(0), file(0), ha_berkeley(TABLE *table): handler(table), alloc_ptr(0),rec_buff(0), file(0),
int_table_flags(HA_REC_NOT_IN_SEQ | HA_FAST_KEY_READ | int_table_flags(HA_REC_NOT_IN_SEQ | HA_FAST_KEY_READ |
HA_NULL_IN_KEY | HA_BLOB_KEY | HA_NOT_EXACT_COUNT | HA_NULL_IN_KEY | HA_CAN_INDEX_BLOBS | HA_NOT_EXACT_COUNT |
HA_PRIMARY_KEY_IN_READ_INDEX | HA_FILE_BASED | HA_PRIMARY_KEY_IN_READ_INDEX | HA_FILE_BASED |
HA_AUTO_PART_KEY | HA_TABLE_SCAN_ON_INDEX), HA_AUTO_PART_KEY | HA_TABLE_SCAN_ON_INDEX),
changed_rows(0),last_dup_key((uint) -1),version(0),using_ignore(0) {} changed_rows(0),last_dup_key((uint) -1),version(0),using_ignore(0) {}
......
...@@ -3872,15 +3872,11 @@ JOIN::join_free(bool full) ...@@ -3872,15 +3872,11 @@ JOIN::join_free(bool full)
{ {
for (tab= join_tab, end= tab+tables; tab != end; tab++) for (tab= join_tab, end= tab+tables; tab != end; tab++)
{ {
if (tab->table) if (tab->table && tab->table->file->inited == handler::RND)
{
/* Don't free index if we are using read_record */
if (tab->table->file->inited==handler::RND)
tab->table->file->ha_rnd_end(); tab->table->file->ha_rnd_end();
} }
} }
} }
}
/* /*
We are not using tables anymore We are not using tables anymore
Unlock all tables. We may be in an INSERT .... SELECT statement. Unlock all tables. We may be in an INSERT .... SELECT statement.
......
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