22
22
/*****************************************************************************
24
Copyright (C) 2000, 2009, MySQL AB & Innobase Oy. All Rights Reserved.
25
Copyright (C) 2008, 2009 Google Inc.
24
Copyright (c) 2000, 2009, MySQL AB & Innobase Oy. All Rights Reserved.
25
Copyright (c) 2008, 2009 Google Inc.
27
27
Portions of this file contain modifications contributed and copyrighted by
28
28
Google, Inc. Those modifications are gratefully acknowledged and are described
45
45
*****************************************************************************/
46
46
/***********************************************************************
48
Copyright (C) 1995, 2009, Innobase Oy. All Rights Reserved.
49
Copyright (C) 2009, Percona Inc.
48
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
49
Copyright (c) 2009, Percona Inc.
51
51
Portions of this file contain modifications contributed and copyrighted
52
52
by Percona Inc.. Those modifications are
71
71
***********************************************************************/
75
75
#include <drizzled/table.h>
76
76
#include <drizzled/error.h>
77
#include <drizzled/internal/my_pthread.h>
77
#include "drizzled/internal/my_pthread.h"
78
78
#include <drizzled/plugin/transactional_storage_engine.h>
79
79
#include <drizzled/plugin/error_message.h>
90
90
#include <drizzled/message/table.pb.h>
91
#include <drizzled/internal/m_string.h>
91
#include "drizzled/internal/m_string.h"
93
#include <drizzled/global_charset_info.h>
93
#include "drizzled/global_charset_info.h"
95
95
#include "haildb_datadict_dump_func.h"
96
96
#include "config_table_function.h"
101
101
#include "haildb_engine.h"
103
103
#include <drizzled/field.h>
104
#include <drizzled/field/blob.h>
105
#include <drizzled/field/enum.h>
104
#include "drizzled/field/timestamp.h" // needed for UPDATE NOW()
105
#include "drizzled/field/blob.h"
106
#include "drizzled/field/enum.h"
106
107
#include <drizzled/session.h>
108
#include <boost/program_options.hpp>
107
109
#include <drizzled/module/option_map.h>
108
111
#include <drizzled/charset.h>
109
#include <drizzled/current_session.h>
113
113
namespace po= boost::program_options;
114
#include <boost/program_options.hpp>
115
114
#include <boost/algorithm/string.hpp>
117
116
using namespace std;
118
117
using namespace google;
119
118
using namespace drizzled;
121
int read_row_from_haildb(Session *session, unsigned char* buf, ib_crsr_t cursor, ib_tpl_t tuple, Table* table, bool has_hidden_primary_key, uint64_t *hidden_pkey, drizzled::memory::Root **blobroot= NULL);
120
int read_row_from_haildb(unsigned char* buf, ib_crsr_t cursor, ib_tpl_t tuple, Table* table, bool has_hidden_primary_key, uint64_t *hidden_pkey, drizzled::memory::Root **blobroot= NULL);
122
121
static void fill_ib_search_tpl_from_drizzle_key(ib_tpl_t search_tuple,
123
122
const drizzled::KeyInfo *key_info,
124
123
const unsigned char *key_ptr,
168
167
int doCreateTable(Session&,
169
168
Table& table_arg,
170
const drizzled::identifier::Table &identifier,
169
const drizzled::TableIdentifier &identifier,
171
170
drizzled::message::Table& proto);
173
int doDropTable(Session&, const identifier::Table &identifier);
172
int doDropTable(Session&, const TableIdentifier &identifier);
175
174
int doRenameTable(drizzled::Session&,
176
const drizzled::identifier::Table&,
177
const drizzled::identifier::Table&);
175
const drizzled::TableIdentifier&,
176
const drizzled::TableIdentifier&);
179
178
int doGetTableDefinition(Session& session,
180
const identifier::Table &identifier,
179
const TableIdentifier &identifier,
181
180
drizzled::message::Table &table_proto);
183
bool doDoesTableExist(Session&, const identifier::Table &identifier);
182
bool doDoesTableExist(Session&, const TableIdentifier &identifier);
186
void getTableNamesInSchemaFromHailDB(const drizzled::identifier::Schema &schema,
185
void getTableNamesInSchemaFromHailDB(const drizzled::SchemaIdentifier &schema,
187
186
drizzled::plugin::TableNameList *set_of_names,
188
drizzled::identifier::Table::vector *identifiers);
187
drizzled::TableIdentifier::vector *identifiers);
191
190
void doGetTableIdentifiers(drizzled::CachedDirectory &,
192
const drizzled::identifier::Schema &schema,
193
drizzled::identifier::Table::vector &identifiers);
191
const drizzled::SchemaIdentifier &schema,
192
drizzled::TableIdentifier::vector &identifiers);
195
194
/* The following defines can be increased if necessary */
196
195
uint32_t max_supported_keys() const { return 1000; }
241
240
/* This is a superset of the map from innobase plugin.
242
241
Unlike innobase plugin we don't act on errors here, we just
243
242
map error codes. */
244
static int ib_err_t_to_drizzle_error(Session* session, ib_err_t err)
243
static int ib_err_t_to_drizzle_error(ib_err_t err)
271
270
return HA_ERR_NO_ACTIVE_RECORD;
273
272
case DB_DEADLOCK:
274
/* HailDB will roll back a transaction itself due to DB_DEADLOCK.
275
This means we have to tell Drizzle about it */
276
session->markTransactionForRollback(true);
277
273
return HA_ERR_LOCK_DEADLOCK;
279
275
case DB_LOCK_WAIT_TIMEOUT:
280
session->markTransactionForRollback(false);
281
276
return HA_ERR_LOCK_WAIT_TIMEOUT;
283
278
case DB_NO_REFERENCED_ROW:
358
353
transaction= get_trx(session);
359
isolation_level= tx_isolation_to_ib_trx_level(session->getTxIsolation());
354
isolation_level= tx_isolation_to_ib_trx_level((enum_tx_isolation)session_tx_isolation(session));
360
355
*transaction= ib_trx_begin(isolation_level);
362
357
return *transaction == NULL;
393
388
err= ib_savepoint_rollback(*transaction, savepoint.getName().c_str(),
394
389
savepoint.getName().length());
396
return ib_err_t_to_drizzle_error(session, err);
391
return ib_err_t_to_drizzle_error(err);
399
394
int HailDBEngine::doReleaseSavepoint(Session* session,
405
400
err= ib_savepoint_release(*transaction, savepoint.getName().c_str(),
406
401
savepoint.getName().length());
407
402
if (err != DB_SUCCESS)
408
return ib_err_t_to_drizzle_error(session, err);
403
return ib_err_t_to_drizzle_error(err);
416
411
ib_trx_t *transaction= get_trx(session);
413
if (all || (!session_test_options(session, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
420
415
err= ib_trx_commit(*transaction);
422
417
if (err != DB_SUCCESS)
423
return ib_err_t_to_drizzle_error(session, err);
418
return ib_err_t_to_drizzle_error(err);
425
420
*transaction= NULL;
434
429
ib_trx_t *transaction= get_trx(session);
431
if (all || !session_test_options(session, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
438
if (ib_trx_state(*transaction) == IB_TRX_NOT_STARTED)
439
err= ib_trx_release(*transaction);
441
err= ib_trx_rollback(*transaction);
433
err= ib_trx_rollback(*transaction);
443
435
if (err != DB_SUCCESS)
444
return ib_err_t_to_drizzle_error(session, err);
436
return ib_err_t_to_drizzle_error(err);
446
438
*transaction= NULL;
450
if (ib_trx_state(*transaction) == IB_TRX_NOT_STARTED)
453
442
err= ib_savepoint_rollback(*transaction, statement_savepoint_name.c_str(),
454
443
statement_savepoint_name.length());
455
444
if (err != DB_SUCCESS)
456
return ib_err_t_to_drizzle_error(session, err);
445
return ib_err_t_to_drizzle_error(err);
499
488
assert (err == DB_SUCCESS);
500
err= ib_tuple_read_u64(tuple, getTable()->getShare()->sizeFields(), &nr);
489
err= ib_tuple_read_u64(tuple, getTable()->getShare()->fields, &nr);
503
492
ib_tuple_delete(tuple);
538
527
doEndIndexScan();
539
528
(void) extra(HA_EXTRA_NO_KEYREAD);
541
if (getTable()->getShare()->getTableMessage()->options().auto_increment_value() > nr)
542
nr= getTable()->getShare()->getTableMessage()->options().auto_increment_value();
530
if (getTable()->getShare()->getTableProto()->options().auto_increment_value() > nr)
531
nr= getTable()->getShare()->getTableProto()->options().auto_increment_value();
683
672
unexpected if an obsolete consistent read view would be
686
enum_tx_isolation isolation_level= session->getTxIsolation();
675
enum_tx_isolation isolation_level= session_tx_isolation(session);
688
677
if (isolation_level != ISO_SERIALIZABLE
689
678
&& (lock_type == TL_READ || lock_type == TL_READ_NO_INSERT)
727
716
if ((lock_type >= TL_WRITE_CONCURRENT_INSERT
728
717
&& lock_type <= TL_WRITE)
729
&& ! session->doing_tablespace_operation()
718
&& !session_tablespace_op(session)
730
719
&& sql_command != SQLCOM_TRUNCATE
731
720
&& sql_command != SQLCOM_CREATE_TABLE) {
806
static void TableIdentifier_to_haildb_name(const identifier::Table &identifier, std::string *str)
795
static void TableIdentifier_to_haildb_name(const TableIdentifier &identifier, std::string *str)
808
797
str->assign(table_path_to_haildb_name(identifier.getPath().c_str()));
839
828
if (err != DB_SUCCESS)
840
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
829
return ib_err_t_to_drizzle_error(err);
842
831
err= ib_cursor_open_table_using_id(table_id, NULL, &cursor);
843
832
cursor_is_sec_index= false;
845
834
if (err != DB_SUCCESS)
846
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
835
return ib_err_t_to_drizzle_error(err);
848
837
err= ib_index_get_id(haildb_table_name, "HIDDEN_PRIMARY", &idx_id);
938
927
*err= ib_table_schema_add_col(schema, field.name().c_str(), IB_INT,
939
928
column_attr, 0, 4);
941
case message::Table::Field::EPOCH:
930
case message::Table::Field::TIMESTAMP:
942
931
*err= ib_table_schema_add_col(schema, field.name().c_str(), IB_INT,
943
932
column_attr, 0, 8);
1039
1028
int HailDBEngine::doCreateTable(Session &session,
1040
1029
Table& table_obj,
1041
const drizzled::identifier::Table &identifier,
1030
const drizzled::TableIdentifier &identifier,
1042
1031
drizzled::message::Table& table_message)
1044
1033
ib_tbl_sch_t haildb_table_schema= NULL;
1082
1071
ER_CANT_CREATE_TABLE,
1083
1072
_("Cannot create table %s. HailDB Error %d (%s)\n"),
1084
1073
haildb_table_name.c_str(), haildb_err, ib_strerror(haildb_err));
1085
return ib_err_t_to_drizzle_error(&session, haildb_err);
1074
return ib_err_t_to_drizzle_error(haildb_err);
1088
1077
for (int colnr= 0; colnr < table_message.field_size() ; colnr++)
1103
1092
" HailDB Error %d (%s)\n"),
1104
1093
field.name().c_str(), haildb_table_name.c_str(),
1105
1094
haildb_err, ib_strerror(haildb_err));
1106
return ib_err_t_to_drizzle_error(&session, haildb_err);
1095
return ib_err_t_to_drizzle_error(haildb_err);
1108
1097
if (field_err != 0)
1109
1098
return field_err;
1251
1240
_("Cannot create table %s. HailDB Error %d (%s)\n"),
1252
1241
haildb_table_name.c_str(),
1253
1242
haildb_err, ib_strerror(haildb_err));
1254
return ib_err_t_to_drizzle_error(&session, haildb_err);
1243
return ib_err_t_to_drizzle_error(haildb_err);
1296
1285
int HailDBEngine::doDropTable(Session &session,
1297
const identifier::Table &identifier)
1286
const TableIdentifier &identifier)
1299
1288
ib_trx_t haildb_schema_transaction;
1300
1289
ib_err_t haildb_err;
1379
static ib_err_t rename_table_message(ib_trx_t transaction, const identifier::Table &from_identifier, const identifier::Table &to_identifier)
1368
static ib_err_t rename_table_message(ib_trx_t transaction, const TableIdentifier &from_identifier, const TableIdentifier &to_identifier)
1381
1370
ib_crsr_t cursor;
1382
1371
ib_tpl_t search_tuple;
1469
1458
int HailDBEngine::doRenameTable(drizzled::Session &session,
1470
const drizzled::identifier::Table &from,
1471
const drizzled::identifier::Table &to)
1459
const drizzled::TableIdentifier &from,
1460
const drizzled::TableIdentifier &to)
1473
1462
ib_trx_t haildb_schema_transaction;
1518
1507
assert(rollback_err == DB_SUCCESS);
1519
1508
rollback_err= ib_trx_rollback(haildb_schema_transaction);
1520
1509
assert(rollback_err == DB_SUCCESS);
1521
return ib_err_t_to_drizzle_error(&session, err);
1510
return ib_err_t_to_drizzle_error(err);
1524
1513
void HailDBEngine::getTableNamesInSchemaFromHailDB(
1525
const drizzled::identifier::Schema &schema,
1514
const drizzled::SchemaIdentifier &schema,
1526
1515
drizzled::plugin::TableNameList *set_of_names,
1527
drizzled::identifier::Table::vector *identifiers)
1516
drizzled::TableIdentifier::vector *identifiers)
1529
1518
ib_trx_t transaction;
1530
1519
ib_crsr_t cursor;
1555
1544
BOOST_FOREACH(std::string table_name, haildb_system_table_names)
1557
identifiers->push_back(identifier::Table(schema.getSchemaName(),
1546
identifiers->push_back(TableIdentifier(schema.getSchemaName(),
1618
1607
void HailDBEngine::doGetTableIdentifiers(drizzled::CachedDirectory &,
1619
const drizzled::identifier::Schema &schema,
1620
drizzled::identifier::Table::vector &identifiers)
1608
const drizzled::SchemaIdentifier &schema,
1609
drizzled::TableIdentifier::vector &identifiers)
1622
1611
getTableNamesInSchemaFromHailDB(schema, NULL, &identifiers);
1744
1733
int HailDBEngine::doGetTableDefinition(Session &session,
1745
const identifier::Table &identifier,
1734
const TableIdentifier &identifier,
1746
1735
drizzled::message::Table &table)
1748
1737
ib_crsr_t haildb_cursor= NULL;
1773
1762
bool HailDBEngine::doDoesTableExist(Session &,
1774
const identifier::Table& identifier)
1763
const TableIdentifier& identifier)
1776
1765
ib_crsr_t haildb_cursor;
1777
1766
string haildb_table_name;
1913
1902
err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
1915
1904
if (err != DB_SUCCESS)
1916
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
1905
return ib_err_t_to_drizzle_error(err);
1918
1907
cursor_is_sec_index= false;
1925
1914
err= ib_cursor_first(cursor);
1926
if (current_session->getLex()->sql_command == SQLCOM_CREATE_TABLE
1915
if (current_session->lex->sql_command == SQLCOM_CREATE_TABLE
1927
1916
&& err == DB_MISSING_HISTORY)
1929
1918
/* See https://bugs.launchpad.net/drizzle/+bug/556978
1984
1973
if (share->has_hidden_primary_key)
1986
err= ib_tuple_write_u64(tuple, getTable()->getShare()->sizeFields(),
1987
share->hidden_pkey_auto_increment_value.fetch_and_increment());
1975
err= ib_tuple_write_u64(tuple, getTable()->getShare()->fields, share->hidden_pkey_auto_increment_value.fetch_and_increment());
1990
1978
err= ib_cursor_insert_row(cursor, tuple);
2022
2010
ret= HA_ERR_FOUND_DUPP_KEY;
2024
2012
else if (err != DB_SUCCESS)
2025
ret= ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2013
ret= ib_err_t_to_drizzle_error(err);
2027
2015
tuple= ib_tuple_clear(tuple);
2028
2016
ib_tuple_delete(tuple);
2053
2041
err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
2055
2043
if (err != DB_SUCCESS)
2056
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2044
return ib_err_t_to_drizzle_error(err);
2057
2045
cursor_is_sec_index= false;
2126
2114
so only support TRUNCATE and not DELETE FROM t;
2127
2115
(this is what ha_innodb does)
2129
if (getTable()->in_use->getSqlCommand() != SQLCOM_TRUNCATE)
2117
if (session_sql_command(getTable()->in_use) != SQLCOM_TRUNCATE)
2130
2118
return HA_ERR_WRONG_COMMAND;
2142
2130
err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
2144
2132
if (err != DB_SUCCESS)
2145
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2133
return ib_err_t_to_drizzle_error(err);
2146
2134
cursor_is_sec_index= false;
2184
2172
ib_schema_unlock(transaction);
2185
2173
ib_err_t rollback_err= ib_trx_rollback(transaction);
2186
2174
assert(rollback_err == DB_SUCCESS);
2187
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2175
return ib_err_t_to_drizzle_error(err);
2190
2178
int HailDBCursor::doStartTableScan(bool)
2216
2204
if (err != DB_SUCCESS)
2217
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2205
return ib_err_t_to_drizzle_error(err);
2219
2207
err= ib_cursor_set_lock_mode(cursor, ib_lock_mode);
2220
2208
assert(err == DB_SUCCESS); // FIXME
2224
2212
err= ib_cursor_first(cursor);
2225
2213
if (err != DB_SUCCESS && err != DB_END_OF_INDEX)
2227
int reset_err= ib_cursor_reset(cursor);
2228
assert(reset_err == DB_SUCCESS);
2229
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2215
previous_error= ib_err_t_to_drizzle_error(err);
2216
err= ib_cursor_reset(cursor);
2217
return previous_error;
2232
2220
advance_cursor= false;
2237
int read_row_from_haildb(Session *session, unsigned char* buf, ib_crsr_t cursor, ib_tpl_t tuple, Table* table, bool has_hidden_primary_key, uint64_t *hidden_pkey, drizzled::memory::Root **blobroot)
2226
int read_row_from_haildb(unsigned char* buf, ib_crsr_t cursor, ib_tpl_t tuple, Table* table, bool has_hidden_primary_key, uint64_t *hidden_pkey, drizzled::memory::Root **blobroot)
2240
2229
ptrdiff_t row_offset= buf - table->getInsertRecord();
2244
2233
if (err == DB_RECORD_NOT_FOUND)
2245
2234
return HA_ERR_END_OF_FILE;
2246
2235
if (err != DB_SUCCESS)
2247
return ib_err_t_to_drizzle_error(session, err);
2236
return ib_err_t_to_drizzle_error(err);
2310
2299
(**field).move_field_offset(-row_offset);
2312
2301
if (err != DB_SUCCESS)
2313
return ib_err_t_to_drizzle_error(session, err);
2302
return ib_err_t_to_drizzle_error(err);
2316
2305
if (has_hidden_primary_key)
2318
2307
err= ib_tuple_read_u64(tuple, colnr, hidden_pkey);
2321
return ib_err_t_to_drizzle_error(session, err);
2310
return ib_err_t_to_drizzle_error(err);
2324
2313
int HailDBCursor::rnd_next(unsigned char *buf)
2319
return previous_error;
2329
2321
if (advance_cursor)
2331
2323
err= ib_cursor_next(cursor);
2332
2324
if (err != DB_SUCCESS)
2333
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2325
return ib_err_t_to_drizzle_error(err);
2336
2328
tuple= ib_tuple_clear(tuple);
2337
ret= read_row_from_haildb(getTable()->getSession(), buf, cursor, tuple,
2329
ret= read_row_from_haildb(buf, cursor, tuple, getTable(),
2339
2330
share->has_hidden_primary_key,
2340
2331
&hidden_autoinc_pkey_position);
2352
2343
err= ib_cursor_reset(cursor);
2353
2344
assert(err == DB_SUCCESS);
2354
2345
in_table_scan= false;
2355
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2347
return ib_err_t_to_drizzle_error(err);
2358
2350
int HailDBCursor::rnd_pos(unsigned char *buf, unsigned char *pos)
2367
2359
err= ib_col_set_value(search_tuple, 0,
2368
2360
((uint64_t*)(pos)), sizeof(uint64_t));
2369
2361
if (err != DB_SUCCESS)
2370
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2362
return ib_err_t_to_drizzle_error(err);
2385
2377
err= ib_cursor_moveto(cursor, search_tuple, IB_CUR_GE, &res);
2386
2378
if (err != DB_SUCCESS)
2387
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2379
return ib_err_t_to_drizzle_error(err);
2389
2381
assert(res==0);
2395
2387
tuple= ib_tuple_clear(tuple);
2398
ret= read_row_from_haildb(getTable()->getSession(), buf, cursor, tuple,
2390
ret= read_row_from_haildb(buf, cursor, tuple, getTable(),
2400
2391
share->has_hidden_primary_key,
2401
2392
&hidden_autoinc_pkey_position);
2538
if (flag & HA_STATUS_CONST)
2540
for (unsigned int i = 0; i < getTable()->getShare()->sizeKeys(); i++)
2542
const char* index_name= getTable()->key_info[i].name;
2545
ha_rows rec_per_key;
2547
err= ib_get_index_stat_n_diff_key_vals(cursor, index_name,
2550
if (err != DB_SUCCESS)
2551
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2553
for (unsigned int j=0; j < getTable()->key_info[i].key_parts; j++)
2555
if (n_diff[j+1] == 0)
2556
rec_per_key= stats.records;
2558
rec_per_key= stats.records / n_diff[j+1];
2560
/* We import this heuristic from ha_innodb, which says
2561
that MySQL favours table scans too much over index searches,
2562
so we pretend our index selectivity is 2 times better. */
2564
rec_per_key= rec_per_key / 2;
2566
if (rec_per_key == 0)
2569
getTable()->key_info[i].rec_per_key[j]=
2570
rec_per_key >= ~(ulong) 0 ? ~(ulong) 0 :
2571
(ulong) rec_per_key;
2595
2546
err= ib_cursor_open_table_using_id(table_id, transaction, &cursor);
2597
2548
if (err != DB_SUCCESS)
2598
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2549
return ib_err_t_to_drizzle_error(err);
2613
2564
getShare()->getKeyInfo(keynr).name,
2615
2566
if (err != DB_SUCCESS)
2616
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2567
return ib_err_t_to_drizzle_error(err);
2618
2569
err= ib_cursor_close(cursor);
2619
2570
assert(err == DB_SUCCESS);
2621
2572
err= ib_cursor_open_index_using_id(index_id, transaction, &cursor);
2623
2574
if (err != DB_SUCCESS)
2624
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2575
return ib_err_t_to_drizzle_error(err);
2626
2577
cursor_is_sec_index= true;
2775
2726
if (err != DB_SUCCESS)
2777
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2728
return ib_err_t_to_drizzle_error(err);
2780
2731
tuple= ib_tuple_clear(tuple);
2781
ret= read_row_from_haildb(getTable()->getSession(), buf, cursor, tuple,
2732
ret= read_row_from_haildb(buf, cursor, tuple, getTable(),
2783
2733
share->has_hidden_primary_key,
2784
2734
&hidden_autoinc_pkey_position,
2785
2735
(allocate_blobs)? &blobroot : NULL);
2859
int HailDBCursor::analyze(Session*)
2863
err= ib_update_table_statistics(cursor);
2865
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2868
2809
int HailDBCursor::index_next(unsigned char *buf)
2870
2811
int ret= HA_ERR_END_OF_FILE;
2879
2820
tuple= ib_tuple_clear(tuple);
2880
ret= read_row_from_haildb(getTable()->getSession(), buf, cursor, tuple,
2821
ret= read_row_from_haildb(buf, cursor, tuple, getTable(),
2882
2822
share->has_hidden_primary_key,
2883
2823
&hidden_autoinc_pkey_position);
2906
2846
if (err == DB_END_OF_INDEX)
2907
2847
return HA_ERR_END_OF_FILE;
2909
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2849
return ib_err_t_to_drizzle_error(err);
2913
2853
tuple= ib_tuple_clear(tuple);
2914
ret= read_row_from_haildb(getTable()->getSession(), buf, cursor, tuple,
2854
ret= read_row_from_haildb(buf, cursor, tuple, getTable(),
2916
2855
share->has_hidden_primary_key,
2917
2856
&hidden_autoinc_pkey_position);
2930
2869
err= ib_cursor_first(cursor);
2931
2870
if (err != DB_SUCCESS)
2932
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2871
return ib_err_t_to_drizzle_error(err);
2934
2873
tuple= ib_tuple_clear(tuple);
2935
ret= read_row_from_haildb(getTable()->getSession(), buf, cursor, tuple,
2874
ret= read_row_from_haildb(buf, cursor, tuple, getTable(),
2937
2875
share->has_hidden_primary_key,
2938
2876
&hidden_autoinc_pkey_position);
2951
2889
err= ib_cursor_last(cursor);
2952
2890
if (err != DB_SUCCESS)
2953
return ib_err_t_to_drizzle_error(getTable()->getSession(), err);
2891
return ib_err_t_to_drizzle_error(err);
2955
2893
tuple= ib_tuple_clear(tuple);
2956
ret= read_row_from_haildb(getTable()->getSession(), buf, cursor, tuple,
2894
ret= read_row_from_haildb(buf, cursor, tuple, getTable(),
2958
2895
share->has_hidden_primary_key,
2959
2896
&hidden_autoinc_pkey_position);
2960
2897
advance_cursor= true;
3149
3086
va_start(args, fmt);
3150
if (not shutdown_in_progress)
3152
r= plugin::ErrorMessage::vprintf(error::WARN, fmt, args);
3087
if (! shutdown_in_progress)
3088
r= plugin::ErrorMessage::vprintf(NULL, ERRMSG_LVL_WARN, fmt, args);
3156
3090
vfprintf(stderr, fmt, args);
3160
3093
return (! r==true);
3539
3472
"Transactional Storage Engine using the HailDB Library",
3540
3473
PLUGIN_LICENSE_GPL,
3541
3474
haildb_init, /* Plugin Init */
3475
NULL, /* system variables */
3543
3476
init_options /* config options */
3545
3478
DRIZZLE_DECLARE_PLUGIN_END;