summaryrefslogtreecommitdiff
path: root/sql/handler.h
diff options
context:
space:
mode:
authorunknown <kostja@bodhi.(none)>2007-12-19 00:36:20 +0300
committerunknown <kostja@bodhi.(none)>2007-12-19 00:36:20 +0300
commit554599e854a8a15d8ca12631182b376b818fdf3a (patch)
tree2888ab0019abb2e66f5366cb2efef275304e59a3 /sql/handler.h
parentfba0a6dbedd75647d3cfa5eca544dff964d9003b (diff)
downloadmariadb-git-554599e854a8a15d8ca12631182b376b818fdf3a.tar.gz
Sort class handler public declarations.
sql/handler.h: Collect ha_* wrappers and their virtual counterparts into two symmetrical groups. Previously they were scattered all over class handler declaration. That should ease maintenance and addition of new ha_ wrappers. When a new ha_* wrapper is added, it should be added to the end of the ha_* group. Its virtual counterpart should become private and be moved to the end of the hander class.
Diffstat (limited to 'sql/handler.h')
-rw-r--r--sql/handler.h241
1 files changed, 115 insertions, 126 deletions
diff --git a/sql/handler.h b/sql/handler.h
index 0f019756902..c5b867e315f 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -973,32 +973,12 @@ class handler :public Sql_alloc
public:
typedef ulonglong Table_flags;
-
- protected:
+protected:
struct st_table_share *table_share; /* The table definition */
struct st_table *table; /* The current open table */
Table_flags cached_table_flags; /* Set on init() and open() */
- virtual int index_init(uint idx, bool sorted) { active_index=idx; return 0; }
- virtual int index_end() { active_index=MAX_KEY; return 0; }
- /**
- rnd_init() can be called two times without rnd_end() in between
- (it only makes sense if scan=1).
- then the second call should prepare for the new table scan (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
- */
- virtual int rnd_init(bool scan) =0;
- virtual int rnd_end() { return 0; }
- virtual Table_flags table_flags(void) const =0;
-
- void ha_statistic_increment(ulong SSV::*offset) const;
- void **ha_data(THD *) const;
- THD *ha_thd(void) const;
-
ha_rows estimation_rows_to_insert;
- virtual void start_bulk_insert(ha_rows rows) {}
- virtual int end_bulk_insert() {return 0; }
public:
handlerton *ht; /* storage engine of this handler */
uchar *ref; /* Pointer to current row */
@@ -1071,7 +1051,74 @@ public:
{
cached_table_flags= table_flags();
}
+ /* ha_ methods: pubilc wrappers for private virtual API */
+
int ha_open(TABLE *table, const char *name, int mode, int test_if_locked);
+ int ha_index_init(uint idx, bool sorted)
+ {
+ int result;
+ DBUG_ENTER("ha_index_init");
+ DBUG_ASSERT(inited==NONE);
+ if (!(result= index_init(idx, sorted)))
+ inited=INDEX;
+ DBUG_RETURN(result);
+ }
+ int ha_index_end()
+ {
+ DBUG_ENTER("ha_index_end");
+ DBUG_ASSERT(inited==INDEX);
+ inited=NONE;
+ DBUG_RETURN(index_end());
+ }
+ int ha_rnd_init(bool scan)
+ {
+ int result;
+ DBUG_ENTER("ha_rnd_init");
+ DBUG_ASSERT(inited==NONE || (inited==RND && scan));
+ inited= (result= rnd_init(scan)) ? NONE: RND;
+ DBUG_RETURN(result);
+ }
+ int ha_rnd_end()
+ {
+ DBUG_ENTER("ha_rnd_end");
+ DBUG_ASSERT(inited==RND);
+ inited=NONE;
+ DBUG_RETURN(rnd_end());
+ }
+ int ha_reset();
+ /* this is necessary in many places, e.g. in HANDLER command */
+ int ha_index_or_rnd_end()
+ {
+ return inited == INDEX ? ha_index_end() : inited == RND ? ha_rnd_end() : 0;
+ }
+ Table_flags ha_table_flags() const { return cached_table_flags; }
+ /**
+ These functions represent the public interface to *users* of the
+ handler class, hence they are *not* virtual. For the inheritance
+ interface, see the (private) functions write_row(), update_row(),
+ and delete_row() below.
+ */
+ int ha_external_lock(THD *thd, int lock_type);
+ int ha_write_row(uchar * buf);
+ int ha_update_row(const uchar * old_data, uchar * new_data);
+ int ha_delete_row(const uchar * buf);
+ void ha_release_auto_increment();
+
+ int ha_check_for_upgrade(HA_CHECK_OPT *check_opt);
+ /** to be actually called to get 'check()' functionality*/
+ int ha_check(THD *thd, HA_CHECK_OPT *check_opt);
+ int ha_repair(THD* thd, HA_CHECK_OPT* check_opt);
+ void ha_start_bulk_insert(ha_rows rows)
+ {
+ estimation_rows_to_insert= rows;
+ start_bulk_insert(rows);
+ }
+ int ha_end_bulk_insert()
+ {
+ estimation_rows_to_insert= 0;
+ return end_bulk_insert();
+ }
+
void adjust_next_insert_id_after_explicit_value(ulonglong nr);
int update_auto_increment();
void print_keydup_error(uint key_nr, const char *msg);
@@ -1134,45 +1181,6 @@ public:
virtual const char *index_type(uint key_number) { DBUG_ASSERT(0); return "";}
- int ha_index_init(uint idx, bool sorted)
- {
- int result;
- DBUG_ENTER("ha_index_init");
- DBUG_ASSERT(inited==NONE);
- if (!(result= index_init(idx, sorted)))
- inited=INDEX;
- DBUG_RETURN(result);
- }
- int ha_index_end()
- {
- DBUG_ENTER("ha_index_end");
- DBUG_ASSERT(inited==INDEX);
- inited=NONE;
- DBUG_RETURN(index_end());
- }
- int ha_rnd_init(bool scan)
- {
- int result;
- DBUG_ENTER("ha_rnd_init");
- DBUG_ASSERT(inited==NONE || (inited==RND && scan));
- inited= (result= rnd_init(scan)) ? NONE: RND;
- DBUG_RETURN(result);
- }
- int ha_rnd_end()
- {
- DBUG_ENTER("ha_rnd_end");
- DBUG_ASSERT(inited==RND);
- inited=NONE;
- DBUG_RETURN(rnd_end());
- }
- int ha_reset();
-
- /* this is necessary in many places, e.g. in HANDLER command */
- int ha_index_or_rnd_end()
- {
- return inited == INDEX ? ha_index_end() : inited == RND ? ha_rnd_end() : 0;
- }
- Table_flags ha_table_flags() const { return cached_table_flags; }
/**
Signal that the table->read_set and table->write_set table maps changed
@@ -1183,21 +1191,9 @@ public:
*/
virtual void column_bitmaps_signal();
uint get_index(void) const { return active_index; }
- virtual int open(const char *name, int mode, uint test_if_locked)=0;
virtual int close(void)=0;
/**
- These functions represent the public interface to *users* of the
- handler class, hence they are *not* virtual. For the inheritance
- interface, see the (private) functions write_row(), update_row(),
- and delete_row() below.
- */
- int ha_external_lock(THD *thd, int lock_type);
- int ha_write_row(uchar * buf);
- int ha_update_row(const uchar * old_data, uchar * new_data);
- int ha_delete_row(const uchar * buf);
-
- /**
@retval 0 Bulk update used by handler
@retval 1 Bulk update not used, normal operation used
*/
@@ -1258,11 +1254,6 @@ public:
DBUG_ASSERT(FALSE);
return HA_ERR_WRONG_COMMAND;
}
-private:
- virtual int index_read(uchar * buf, const uchar * key, uint key_len,
- enum ha_rkey_function find_flag)
- { return HA_ERR_WRONG_COMMAND; }
-public:
/**
@brief
Positions an index cursor to the index specified in the handle. Fetches the
@@ -1294,10 +1285,6 @@ public:
virtual int index_last(uchar * buf)
{ return HA_ERR_WRONG_COMMAND; }
virtual int index_next_same(uchar *buf, const uchar *key, uint keylen);
- private:
- virtual int index_read_last(uchar * buf, const uchar * key, uint key_len)
- { return (my_errno=HA_ERR_WRONG_COMMAND); }
-public:
/**
@brief
The following functions works like index_read, but it find the last
@@ -1357,12 +1344,6 @@ public:
{ return extra(operation); }
/**
- Reset state of file to after 'open'.
- This function is called after every statement for all tables used
- by that statement.
- */
- virtual int reset() { return 0; }
- /**
In an UPDATE or DELETE, if the row under the cursor was locked by another
transaction, and the engine used an optimistic read of the last
committed row value under the cursor, then the engine returns 1 from this
@@ -1396,10 +1377,6 @@ public:
ulonglong nb_desired_values,
ulonglong *first_value,
ulonglong *nb_reserved_values);
-private:
- virtual void release_auto_increment() { return; };
-public:
- void ha_release_auto_increment();
void set_next_insert_id(ulonglong id)
{
DBUG_PRINT("info",("auto_increment: next value %lu", (ulong)id));
@@ -1430,26 +1407,7 @@ public:
{ return HA_ERR_WRONG_COMMAND; }
virtual void update_create_info(HA_CREATE_INFO *create_info) {}
-protected:
- /* to be implemented in handlers */
-
- /** admin commands - called from mysql_admin_table */
- virtual int check(THD* thd, HA_CHECK_OPT* check_opt)
- { return HA_ADMIN_NOT_IMPLEMENTED; }
-
- /**
- In these two methods check_opt can be modified
- to specify CHECK option to use to call check()
- upon the table.
- */
- virtual int check_for_upgrade(HA_CHECK_OPT *check_opt)
- { return 0; }
-public:
- int ha_check_for_upgrade(HA_CHECK_OPT *check_opt);
int check_old_types();
- /** to be actually called to get 'check()' functionality*/
- int ha_check(THD *thd, HA_CHECK_OPT *check_opt);
-
virtual int backup(THD* thd, HA_CHECK_OPT* check_opt)
{ return HA_ADMIN_NOT_IMPLEMENTED; }
/**
@@ -1458,11 +1416,6 @@ public:
*/
virtual int restore(THD* thd, HA_CHECK_OPT* check_opt)
{ return HA_ADMIN_NOT_IMPLEMENTED; }
-protected:
- virtual int repair(THD* thd, HA_CHECK_OPT* check_opt)
- { return HA_ADMIN_NOT_IMPLEMENTED; }
-public:
- int ha_repair(THD* thd, HA_CHECK_OPT* check_opt);
virtual int optimize(THD* thd, HA_CHECK_OPT* check_opt)
{ return HA_ADMIN_NOT_IMPLEMENTED; }
virtual int analyze(THD* thd, HA_CHECK_OPT* check_opt)
@@ -1478,16 +1431,6 @@ public:
virtual int disable_indexes(uint mode) { return HA_ERR_WRONG_COMMAND; }
virtual int enable_indexes(uint mode) { return HA_ERR_WRONG_COMMAND; }
virtual int indexes_are_disabled(void) {return 0;}
- void ha_start_bulk_insert(ha_rows rows)
- {
- estimation_rows_to_insert= rows;
- start_bulk_insert(rows);
- }
- int ha_end_bulk_insert()
- {
- estimation_rows_to_insert= 0;
- return end_bulk_insert();
- }
virtual int discard_or_import_tablespace(my_bool discard)
{return HA_ERR_WRONG_COMMAND;}
virtual int net_read_dump(NET* net) { return HA_ERR_WRONG_COMMAND; }
@@ -1754,13 +1697,37 @@ public:
*/
virtual void use_hidden_primary_key();
+protected:
+ /* Service methods for use by storage engines. */
+ void ha_statistic_increment(ulong SSV::*offset) const;
+ void **ha_data(THD *) const;
+ THD *ha_thd(void) const;
private:
/*
- Row-level primitives for storage engines. These should be
+ Low-level primitives for storage engines. These should be
overridden by the storage engine class. To call these methods, use
the corresponding 'ha_*' method above.
*/
+ virtual int open(const char *name, int mode, uint test_if_locked)=0;
+ virtual int index_init(uint idx, bool sorted) { active_index= idx; return 0; }
+ virtual int index_end() { active_index= MAX_KEY; return 0; }
+ /**
+ rnd_init() can be called two times without rnd_end() in between
+ (it only makes sense if scan=1).
+ then the second call should prepare for the new table scan (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
+ */
+ virtual int rnd_init(bool scan)= 0;
+ virtual int rnd_end() { return 0; }
+ /**
+ Reset state of file to after 'open'.
+ This function is called after every statement for all tables used
+ by that statement.
+ */
+ virtual int reset() { return 0; }
+ virtual Table_flags table_flags(void) const= 0;
/**
Is not invoked for non-transactional temporary tables.
@@ -1788,8 +1755,30 @@ private:
{
return 0;
}
+ virtual void release_auto_increment() { return; };
+ /** admin commands - called from mysql_admin_table */
+ virtual int check_for_upgrade(HA_CHECK_OPT *check_opt)
+ { return 0; }
+ virtual int check(THD* thd, HA_CHECK_OPT* check_opt)
+ { return HA_ADMIN_NOT_IMPLEMENTED; }
+
+ /**
+ In this method check_opt can be modified
+ to specify CHECK option to use to call check()
+ upon the table.
+ */
+ virtual int repair(THD* thd, HA_CHECK_OPT* check_opt)
+ { return HA_ADMIN_NOT_IMPLEMENTED; }
+ virtual void start_bulk_insert(ha_rows rows) {}
+ virtual int end_bulk_insert() { return 0; }
+ virtual int index_read(uchar * buf, const uchar * key, uint key_len,
+ enum ha_rkey_function find_flag)
+ { return HA_ERR_WRONG_COMMAND; }
+ virtual int index_read_last(uchar * buf, const uchar * key, uint key_len)
+ { return (my_errno= HA_ERR_WRONG_COMMAND); }
};
+
/* Some extern variables used with handlers */
extern const char *ha_row_type[];