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); |
|
1283.61.8
by Stewart Smith
support correct isolation levels for Embedded InnoDB. READ COMMITTED doesn't work because of bug lp:587772 - it doesn't work for innobase either. We also add tests for READ UNCOMMITTED and REPEATABLE READ |
54 |
int external_lock(drizzled::Session* session, int lock_type); |
1491.1.2
by Jay Pipes
Cursor::write_row() -> Cursor::doInsertRecord(). Cursor::ha_write_row() -> Cursor::insertRecord() |
55 |
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 |
56 |
int doStartTableScan(bool scan); |
1283.3.1
by Stewart Smith
Skeleton embedded_innodb plugin. Does nothing. |
57 |
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 |
58 |
int doEndTableScan(); |
1283.3.1
by Stewart Smith
Skeleton embedded_innodb plugin. Does nothing. |
59 |
int rnd_pos(unsigned char * buf, unsigned char *pos); |
60 |
||
1491.1.6
by Jay Pipes
Cursor::ha_index_init() -> Cursor::startIndexScan(). Cursor::ha_index_end() -> Cursor::endIndexScan() |
61 |
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. |
62 |
int index_read(unsigned char *buf, const unsigned char *key_ptr, |
63 |
uint32_t key_len, drizzled::ha_rkey_function find_flag); |
|
64 |
||
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. |
65 |
int innodb_index_read(unsigned char *buf, |
66 |
const unsigned char *key_ptr, |
|
67 |
uint32_t key_len, |
|
68 |
drizzled::ha_rkey_function find_flag, |
|
69 |
bool allocate_blobs); |
|
70 |
||
71 |
uint32_t calculate_key_len(uint32_t key_position, |
|
72 |
drizzled::key_part_map keypart_map_arg); |
|
73 |
int innodb_index_read_map(unsigned char * buf, |
|
74 |
const unsigned char *key, |
|
75 |
drizzled::key_part_map keypart_map, |
|
76 |
drizzled::ha_rkey_function find_flag, |
|
77 |
bool allocate_blobs); |
|
78 |
int index_read_idx_map(unsigned char * buf, |
|
79 |
uint32_t index, |
|
80 |
const unsigned char * key, |
|
81 |
drizzled::key_part_map keypart_map, |
|
82 |
drizzled::ha_rkey_function find_flag); |
|
83 |
||
1283.3.1
by Stewart Smith
Skeleton embedded_innodb plugin. Does nothing. |
84 |
int index_next(unsigned char * buf); |
1491.1.6
by Jay Pipes
Cursor::ha_index_init() -> Cursor::startIndexScan(). Cursor::ha_index_end() -> Cursor::endIndexScan() |
85 |
int doEndIndexScan(); |
1283.3.1
by Stewart Smith
Skeleton embedded_innodb plugin. Does nothing. |
86 |
int index_prev(unsigned char * buf); |
87 |
int index_first(unsigned char * buf); |
|
88 |
int index_last(unsigned char * buf); |
|
89 |
void position(const unsigned char *record); |
|
90 |
int info(uint32_t flag); |
|
1283.3.42
by Stewart Smith
basic index scan of embedded innodb clustered index |
91 |
double scan_time(); |
1475.2.4
by Stewart Smith
fix update_record nad delete_record in embedded_innodb to be doUpdateRecord and doDeleteRecord |
92 |
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. |
93 |
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 |
94 |
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. |
95 |
int extra(drizzled::ha_extra_function operation); |
1283.3.27
by Stewart Smith
basic code to insert a integer |
96 |
|
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. |
97 |
EmbeddedInnoDBTableShare *get_share(const char *table_name, |
98 |
bool has_hidden_primary_key, |
|
99 |
int *rc); |
|
1283.3.80
by Stewart Smith
add basic transactional support to Embedded InnoDB engine. |
100 |
int free_share(); |
101 |
||
102 |
EmbeddedInnoDBTableShare *share; |
|
103 |
drizzled::THR_LOCK_DATA lock; /* lock for store_lock. this is ass. */ |
|
104 |
drizzled::THR_LOCK_DATA **store_lock(drizzled::Session *, |
|
105 |
drizzled::THR_LOCK_DATA **to, |
|
106 |
drizzled::thr_lock_type); |
|
107 |
||
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. |
108 |
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. |
109 |
uint64_t getHiddenPrimaryKeyInitialAutoIncrementValue(); |
110 |
||
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. |
111 |
void get_auto_increment(uint64_t , |
112 |
uint64_t , |
|
113 |
uint64_t , |
|
114 |
uint64_t *first_value, |
|
115 |
uint64_t *nb_reserved_values); |
|
116 |
||
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. |
117 |
int reset(); |
118 |
||
1283.3.27
by Stewart Smith
basic code to insert a integer |
119 |
private: |
120 |
ib_crsr_t cursor; |
|
121 |
ib_tpl_t tuple; |
|
1283.60.4
by Stewart Smith
Change when we call ib_cursor_next/prev. Instead of calling it after reading |
122 |
bool advance_cursor; |
1283.63.1
by Stewart Smith
support SELECT ... FOR UPDATE locking for embedded_innodb. Do stupid shit because of the complete lack of error checking for startTableScan in parts of the upper layer. |
123 |
ib_lck_mode_t ib_lock_mode; |
124 |
int previous_error; |
|
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. |
125 |
|
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. |
126 |
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. |
127 |
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. |
128 |
drizzled::memory::Root *blobroot; |
1283.60.11
by Stewart Smith
doStartTableScan() can be called twice in a row without a doEndTableScan() |
129 |
|
130 |
bool in_table_scan; |
|
1283.3.1
by Stewart Smith
Skeleton embedded_innodb plugin. Does nothing. |
131 |
};
|
132 |
||
133 |
#endif /* PLUGIN_EMBEDDED_INNODB_EMBEDDED_INNODB_ENGINE_H */ |