~drizzle-trunk/drizzle/development

1283.3.1 by Stewart Smith
Skeleton embedded_innodb plugin. Does nothing.
1
/*
2
  Copyright (C) 2010 Stewart Smith
3
4
  This program is free software; you can redistribute it and/or
5
  modify it under the terms of the GNU General Public License
6
  as published by the Free Software Foundation; either version 2
7
  of the License, or (at your option) any later version.
8
9
  This program is distributed in the hope that it will be useful,
10
  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
  GNU General Public License for more details.
13
14
  You should have received a copy of the GNU General Public License
15
  along with this program; if not, write to the Free Software
16
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17
*/
18
19
#ifndef PLUGIN_EMBEDDED_INNODB_EMBEDDED_INNODB_ENGINE_H
20
#define PLUGIN_EMBEDDED_INNODB_EMBEDDED_INNODB_ENGINE_H
21
22
#include <drizzled/cursor.h>
1283.36.13 by Stewart Smith
basic auto_increment implementation for embedded_innodb. On startup, fetch the maximum value for the auto_increment column (or what's in the table message as the auto_increment value). Use an atomic variable in the embedded-innodb table share to keep track of the auto_increment_value. We can then use atomic ops to get an autoinc value (or several) as well as update it in the event of inserting a larger number. Currently there's a bug (well, difference in behaviour) around inserting -1 into an auto-inc field where the table already has a value 'higher' than that and then asking for another auto-inc value. Check the auto_increment test case failure for it. This will be fixed in a later commit.
23
#include <drizzled/atomics.h>
1283.3.1 by Stewart Smith
Skeleton embedded_innodb plugin. Does nothing.
24
1283.3.80 by Stewart Smith
add basic transactional support to Embedded InnoDB engine.
25
class EmbeddedInnoDBTableShare
26
{
27
public:
1283.35.97 by Stewart Smith
support tables without an explicit primary key in embedded_innodb by creating a hidden auto_increment primary key. We also have to support tables without an explicit primary key but with an auto increment, so we have our own hidden one. yes, it hurts.
28
  EmbeddedInnoDBTableShare(const char* name, bool hidden_primary_key);
1283.3.80 by Stewart Smith
add basic transactional support to Embedded InnoDB engine.
29
30
  drizzled::THR_LOCK lock;
31
  int use_count;
32
  std::string table_name;
1283.36.13 by Stewart Smith
basic auto_increment implementation for embedded_innodb. On startup, fetch the maximum value for the auto_increment column (or what's in the table message as the auto_increment value). Use an atomic variable in the embedded-innodb table share to keep track of the auto_increment_value. We can then use atomic ops to get an autoinc value (or several) as well as update it in the event of inserting a larger number. Currently there's a bug (well, difference in behaviour) around inserting -1 into an auto-inc field where the table already has a value 'higher' than that and then asking for another auto-inc value. Check the auto_increment test case failure for it. This will be fixed in a later commit.
33
34
  drizzled::atomic<uint64_t> auto_increment_value;
1283.35.97 by Stewart Smith
support tables without an explicit primary key in embedded_innodb by creating a hidden auto_increment primary key. We also have to support tables without an explicit primary key but with an auto increment, so we have our own hidden one. yes, it hurts.
35
  drizzled::atomic<uint64_t> hidden_pkey_auto_increment_value;
36
  bool has_hidden_primary_key;
1283.3.80 by Stewart Smith
add basic transactional support to Embedded InnoDB engine.
37
};
38
1283.3.1 by Stewart Smith
Skeleton embedded_innodb plugin. Does nothing.
39
class EmbeddedInnoDBCursor: public drizzled::Cursor
40
{
41
public:
42
  EmbeddedInnoDBCursor(drizzled::plugin::StorageEngine &engine, drizzled::TableShare &table_arg);
43
  ~EmbeddedInnoDBCursor()
44
  {}
45
46
  /*
47
    The name of the index type that will be used for display
48
    don't implement this method unless you really have indexes
49
  */
50
  const char *index_type(uint32_t key_number);
51
  uint32_t index_flags(uint32_t inx) const;
52
  int open(const char *name, int mode, uint32_t test_if_locked);
53
  int close(void);
1491.1.2 by Jay Pipes
Cursor::write_row() -> Cursor::doInsertRecord(). Cursor::ha_write_row() -> Cursor::insertRecord()
54
  int doInsertRecord(unsigned char * buf);
1491.1.10 by Jay Pipes
ha_rnd_init -> startTableScan, rnd_init -> doStartTableScan, ha_rnd_end -> endTableScan, rnd_end -> doEndTableScan
55
  int doStartTableScan(bool scan);
1283.3.1 by Stewart Smith
Skeleton embedded_innodb plugin. Does nothing.
56
  int rnd_next(unsigned char *buf);
1491.1.10 by Jay Pipes
ha_rnd_init -> startTableScan, rnd_init -> doStartTableScan, ha_rnd_end -> endTableScan, rnd_end -> doEndTableScan
57
  int doEndTableScan();
1283.3.1 by Stewart Smith
Skeleton embedded_innodb plugin. Does nothing.
58
  int rnd_pos(unsigned char * buf, unsigned char *pos);
59
1491.1.6 by Jay Pipes
Cursor::ha_index_init() -> Cursor::startIndexScan(). Cursor::ha_index_end() -> Cursor::endIndexScan()
60
  int doStartIndexScan(uint32_t, bool);
1283.3.52 by Stewart Smith
simple index_read() for embedded innodb. Add a test for first column beivng primary key and index lookups/scans.
61
  int index_read(unsigned char *buf, const unsigned char *key_ptr,
62
                 uint32_t key_len, drizzled::ha_rkey_function find_flag);
63
1283.60.10 by Stewart Smith
the memory management for BLOBS is completely insane. For certain types of index lookups we *must* do a copy and clear it *only* in ::reset() or ::extra(). This patch fixes up any valgrind warnings/assertions for embedded_innodb executing type_blob test.
64
  int innodb_index_read(unsigned char *buf,
65
                        const unsigned char *key_ptr,
66
                        uint32_t key_len,
67
                        drizzled::ha_rkey_function find_flag,
68
                        bool allocate_blobs);
69
70
  uint32_t calculate_key_len(uint32_t key_position,
71
                             drizzled::key_part_map keypart_map_arg);
72
  int innodb_index_read_map(unsigned char * buf,
73
                            const unsigned char *key,
74
                            drizzled::key_part_map keypart_map,
75
                            drizzled::ha_rkey_function find_flag,
76
                            bool allocate_blobs);
77
  int index_read_idx_map(unsigned char * buf,
78
                         uint32_t index,
79
                         const unsigned char * key,
80
                         drizzled::key_part_map keypart_map,
81
                         drizzled::ha_rkey_function find_flag);
82
1283.3.1 by Stewart Smith
Skeleton embedded_innodb plugin. Does nothing.
83
  int index_next(unsigned char * buf);
1491.1.6 by Jay Pipes
Cursor::ha_index_init() -> Cursor::startIndexScan(). Cursor::ha_index_end() -> Cursor::endIndexScan()
84
  int doEndIndexScan();
1283.3.1 by Stewart Smith
Skeleton embedded_innodb plugin. Does nothing.
85
  int index_prev(unsigned char * buf);
86
  int index_first(unsigned char * buf);
87
  int index_last(unsigned char * buf);
88
  void position(const unsigned char *record);
89
  int info(uint32_t flag);
1283.3.42 by Stewart Smith
basic index scan of embedded innodb clustered index
90
  double scan_time();
1475.2.4 by Stewart Smith
fix update_record nad delete_record in embedded_innodb to be doUpdateRecord and doDeleteRecord
91
  int doDeleteRecord(const unsigned char *);
1283.3.79 by Stewart Smith
implement TRUNCATE TABLE for Embedded Innodb using the (fast) ib_cursor_truncate() call instead of deleting each row individually.
92
  int delete_all_rows(void);
1475.2.4 by Stewart Smith
fix update_record nad delete_record in embedded_innodb to be doUpdateRecord and doDeleteRecord
93
  int doUpdateRecord(const unsigned char * old_data, unsigned char * new_data);
1283.39.8 by Stewart Smith
add support for REPLACE to embedded_innodb. On duplicate key on insert if we have HA_EXTRA_WRITE_CAN_REPLACE set, then we delete the row and insert.
94
  int extra(drizzled::ha_extra_function operation);
1283.3.27 by Stewart Smith
basic code to insert a integer
95
1283.35.97 by Stewart Smith
support tables without an explicit primary key in embedded_innodb by creating a hidden auto_increment primary key. We also have to support tables without an explicit primary key but with an auto increment, so we have our own hidden one. yes, it hurts.
96
  EmbeddedInnoDBTableShare *get_share(const char *table_name,
97
                                      bool has_hidden_primary_key,
98
                                      int *rc);
1283.3.80 by Stewart Smith
add basic transactional support to Embedded InnoDB engine.
99
  int free_share();
100
101
  EmbeddedInnoDBTableShare *share;
102
  drizzled::THR_LOCK_DATA lock;  /* lock for store_lock. this is ass. */
103
  drizzled::THR_LOCK_DATA **store_lock(drizzled::Session *,
104
                                       drizzled::THR_LOCK_DATA **to,
105
                                       drizzled::thr_lock_type);
106
1283.36.13 by Stewart Smith
basic auto_increment implementation for embedded_innodb. On startup, fetch the maximum value for the auto_increment column (or what's in the table message as the auto_increment value). Use an atomic variable in the embedded-innodb table share to keep track of the auto_increment_value. We can then use atomic ops to get an autoinc value (or several) as well as update it in the event of inserting a larger number. Currently there's a bug (well, difference in behaviour) around inserting -1 into an auto-inc field where the table already has a value 'higher' than that and then asking for another auto-inc value. Check the auto_increment test case failure for it. This will be fixed in a later commit.
107
  uint64_t getInitialAutoIncrementValue();
1283.35.97 by Stewart Smith
support tables without an explicit primary key in embedded_innodb by creating a hidden auto_increment primary key. We also have to support tables without an explicit primary key but with an auto increment, so we have our own hidden one. yes, it hurts.
108
  uint64_t getHiddenPrimaryKeyInitialAutoIncrementValue();
109
1283.36.13 by Stewart Smith
basic auto_increment implementation for embedded_innodb. On startup, fetch the maximum value for the auto_increment column (or what's in the table message as the auto_increment value). Use an atomic variable in the embedded-innodb table share to keep track of the auto_increment_value. We can then use atomic ops to get an autoinc value (or several) as well as update it in the event of inserting a larger number. Currently there's a bug (well, difference in behaviour) around inserting -1 into an auto-inc field where the table already has a value 'higher' than that and then asking for another auto-inc value. Check the auto_increment test case failure for it. This will be fixed in a later commit.
110
  void get_auto_increment(uint64_t ,
111
                          uint64_t ,
112
                          uint64_t ,
113
                          uint64_t *first_value,
114
                          uint64_t *nb_reserved_values);
115
1283.60.10 by Stewart Smith
the memory management for BLOBS is completely insane. For certain types of index lookups we *must* do a copy and clear it *only* in ::reset() or ::extra(). This patch fixes up any valgrind warnings/assertions for embedded_innodb executing type_blob test.
116
  int reset();
117
1283.3.27 by Stewart Smith
basic code to insert a integer
118
private:
119
  ib_crsr_t cursor;
120
  ib_tpl_t tuple;
1283.60.4 by Stewart Smith
Change when we call ib_cursor_next/prev. Instead of calling it after reading
121
  bool advance_cursor;
1283.28.15 by Stewart Smith
support secondary index scan in embedded_innodb. we add a next_innodb_error member to EmbeddedInnodbCursor as unlike clustered indexes, trying to fetch a row after you have gotten DB_END_OF_INDEX results in a much nastier crash than a simple error code.
122
1283.39.8 by Stewart Smith
add support for REPLACE to embedded_innodb. On duplicate key on insert if we have HA_EXTRA_WRITE_CAN_REPLACE set, then we delete the row and insert.
123
  bool write_can_replace;
1283.35.97 by Stewart Smith
support tables without an explicit primary key in embedded_innodb by creating a hidden auto_increment primary key. We also have to support tables without an explicit primary key but with an auto increment, so we have our own hidden one. yes, it hurts.
124
  uint64_t hidden_autoinc_pkey_position;
1283.60.10 by Stewart Smith
the memory management for BLOBS is completely insane. For certain types of index lookups we *must* do a copy and clear it *only* in ::reset() or ::extra(). This patch fixes up any valgrind warnings/assertions for embedded_innodb executing type_blob test.
125
  drizzled::memory::Root *blobroot;
1283.60.11 by Stewart Smith
doStartTableScan() can be called twice in a row without a doEndTableScan()
126
127
  bool in_table_scan;
1283.3.1 by Stewart Smith
Skeleton embedded_innodb plugin. Does nothing.
128
};
129
130
#endif /* PLUGIN_EMBEDDED_INNODB_EMBEDDED_INNODB_ENGINE_H */