summaryrefslogtreecommitdiff
path: root/sql/examples/ha_example.h
diff options
context:
space:
mode:
authorunknown <brian@brian-akers-computer.local>2004-05-11 15:59:20 -0700
committerunknown <brian@brian-akers-computer.local>2004-05-11 15:59:20 -0700
commit1662e59626427c4bd5774a1d2ec8358d52cd881f (patch)
treeed5ed1eece3a912b188b2071bb9b7563328b809e /sql/examples/ha_example.h
parentc6bc3cfb8457332b4519efcd10339c2632626acb (diff)
downloadmariadb-git-1662e59626427c4bd5774a1d2ec8358d52cd881f.tar.gz
Added comments to all methods. Added explanation for a sequential read through a storage engine.
sql/examples/ha_example.cc: Documentation updates (lots of comments in the code). sql/examples/ha_example.h: Documenation update, lots of comments in the code.
Diffstat (limited to 'sql/examples/ha_example.h')
-rw-r--r--sql/examples/ha_example.h40
1 files changed, 38 insertions, 2 deletions
diff --git a/sql/examples/ha_example.h b/sql/examples/ha_example.h
index 466632a1795..ffc4f5b941c 100644
--- a/sql/examples/ha_example.h
+++ b/sql/examples/ha_example.h
@@ -14,6 +14,17 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+/*
+ Please read ha_exmple.cc before reading this file.
+ Please keep in mind that the example storage engine implements all methods
+ that are required to be implemented. handler.h has a full list of methods
+ that you can implement.
+*/
+
+/*
+ EXAMPLE_SHARE is a structure that will be shared amoung all open handlers
+ The example implements the minimum of what you will probably need.
+*/
typedef struct st_example_share {
char *table_name;
uint table_name_length,use_count;
@@ -21,6 +32,9 @@ typedef struct st_example_share {
THR_LOCK lock;
} EXAMPLE_SHARE;
+/*
+ Class definition for the storage engine
+*/
class ha_example: public handler
{
THR_LOCK_DATA lock; /* MySQL lock */
@@ -33,17 +47,34 @@ public:
~ha_example()
{
}
- const char *table_type() const { return "EXAMPLE"; }
+ /* The name that will be used for display purposes */
+ 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"; }
const char **bas_ext() const;
+ /*
+ This is a list of flags that says what the storage engine
+ implements. The current table flags are documented in
+ table_flags.
+ */
ulong table_flags() const
{
return 0;
}
+ /*
+ This is a list of flags that says how the storage engine
+ implements indexes. The current index flags are documented in
+ handler.h. If you do not implement indexes, just return zero
+ here.
+ */
ulong index_flags(uint inx) const
{
return 0;
}
+ /*
+ unireg.cc will call the following to make sure that the storage engine can
+ handle the data it is about to send.
+ */
uint max_record_length() const { return HA_MAX_REC_LENGTH; }
uint max_keys() const { return 0; }
uint max_key_parts() const { return 0; }
@@ -52,10 +83,15 @@ public:
Called in test_quick_select to determine if indexes should be used.
*/
virtual double scan_time() { return (double) (records+deleted) / 20.0+10; }
- /* The next method will never be called */
+ /*
+ The next method will never be called if you do not implement indexes.
+ */
virtual double read_time(ha_rows rows) { return (double) rows / 20.0+1; }
virtual bool fast_key_read() { return 1;}
+ /*
+ Everything below are methods that we implment in ha_example.cc.
+ */
int open(const char *name, int mode, uint test_if_locked);
int close(void);
int write_row(byte * buf);