summaryrefslogtreecommitdiff
path: root/sql/handler.h
diff options
context:
space:
mode:
authorunknown <mats@mysql.com>2006-02-28 10:06:58 +0100
committerunknown <mats@mysql.com>2006-02-28 10:06:58 +0100
commit4e31551b929ca091d9d78969cfc6cdf15b9282d5 (patch)
treecb6ade436bf4b0cf01026964400f9aa8fb2f4ff9 /sql/handler.h
parent594ba86bc534f1f81cdb897a9a414ba8248a0aad (diff)
parentd11aa8345db0801c62fcf966bfce6c4d7eda63f8 (diff)
downloadmariadb-git-4e31551b929ca091d9d78969cfc6cdf15b9282d5.tar.gz
Merge mysql.com:/home/bkroot/mysql-5.1-new
into mysql.com:/home/bk/w3023-mysql-5.1-new configure.in: Auto merged BitKeeper/deleted/.del-sp_notembedded.test: Auto merged mysql-test/extra/binlog_tests/binlog.test: Auto merged mysql-test/extra/binlog_tests/blackhole.test: Auto merged mysql-test/r/binlog_stm_ctype_cp932.result: Auto merged mysql-test/t/sp.test: Auto merged scripts/mysql_fix_privilege_tables.sql: Auto merged sql/ha_ndbcluster_binlog.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/log.h: Auto merged sql/log_event.h: Auto merged sql/mysql_priv.h: Auto merged sql/opt_range.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_update.cc: Auto merged sql/table.h: Auto merged
Diffstat (limited to 'sql/handler.h')
-rw-r--r--sql/handler.h73
1 files changed, 56 insertions, 17 deletions
diff --git a/sql/handler.h b/sql/handler.h
index 450805d08ef..85681788361 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -636,7 +636,35 @@ typedef struct st_ha_create_information
bool store_on_disk; /* 1 if table stored on disk */
} HA_CREATE_INFO;
+/*
+ Class for maintaining hooks used inside operations on tables such
+ as: create table functions, delete table functions, and alter table
+ functions.
+
+ Class is using the Template Method pattern to separate the public
+ usage interface from the private inheritance interface. This
+ imposes no overhead, since the public non-virtual function is small
+ enough to be inlined.
+
+ The hooks are usually used for functions that does several things,
+ e.g., create_table_from_items(), which both create a table and lock
+ it.
+ */
+class TABLEOP_HOOKS
+{
+public:
+ inline void prelock(TABLE **tables, uint count)
+ {
+ do_prelock(tables, count);
+ }
+private:
+ /* Function primitive that is called prior to locking tables */
+ virtual void do_prelock(TABLE **tables, uint count)
+ {
+ /* Default is to do nothing */
+ }
+};
typedef struct st_savepoint SAVEPOINT;
extern ulong savepoint_alloc_size;
@@ -983,15 +1011,24 @@ public:
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;
- virtual int ha_write_row(byte * buf);
- virtual int ha_update_row(const byte * old_data, byte * new_data);
- virtual int ha_delete_row(const byte * buf);
+
+ /*
+ 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(byte * buf);
+ int ha_update_row(const byte * old_data, byte * new_data);
+ int ha_delete_row(const byte * buf);
+
/*
If the handler does it's own injection of the rows, this member function
should return 'true'.
*/
virtual bool is_injective() const { return false; }
-
+
/*
SYNOPSIS
start_bulk_update()
@@ -1123,7 +1160,6 @@ public:
{ return 0; }
virtual int extra_opt(enum ha_extra_function operation, ulong cache_size)
{ return extra(operation); }
- virtual int external_lock(THD *thd, int lock_type) { 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
@@ -1397,28 +1433,31 @@ public:
{ return COMPATIBLE_DATA_NO; }
private:
-
/*
- Row-level primitives for storage engines.
- These should be overridden by the storage engine class. To call
- these methods, use the corresponding 'ha_*' method above.
+ Row-level primitives for storage engines. These should be
+ overridden by the storage engine class. To call these methods, use
+ the corresponding 'ha_*' method above.
*/
- friend int ndb_add_binlog_index(THD *, void *);
+ virtual int external_lock(THD *thd __attribute__((unused)),
+ int lock_type __attribute__((unused)))
+ {
+ return 0;
+ }
- virtual int write_row(byte *buf __attribute__((unused)))
- {
- return HA_ERR_WRONG_COMMAND;
+ virtual int write_row(byte *buf __attribute__((unused)))
+ {
+ return HA_ERR_WRONG_COMMAND;
}
virtual int update_row(const byte *old_data __attribute__((unused)),
byte *new_data __attribute__((unused)))
- {
- return HA_ERR_WRONG_COMMAND;
+ {
+ return HA_ERR_WRONG_COMMAND;
}
virtual int delete_row(const byte *buf __attribute__((unused)))
- {
- return HA_ERR_WRONG_COMMAND;
+ {
+ return HA_ERR_WRONG_COMMAND;
}
};