Commit 7a1b9ef6 authored by Sergei Golubchik's avatar Sergei Golubchik

fix oqgraph compilation failures.

fix rpl_mdev382.result
parent e1f681c9
...@@ -10,7 +10,7 @@ if ($binlog_file) ...@@ -10,7 +10,7 @@ if ($binlog_file)
{ {
--let $_in_binlog_file=in '$binlog_file' --let $_in_binlog_file=in '$binlog_file'
} }
--replace_result $_binlog_start <binlog_start> --replace_result $_binlog_start <binlog_start> $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_column 2 # 5 # --replace_column 2 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /file_id=[0-9]+/file_id=#/ --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /file_id=[0-9]+/file_id=#/
--eval show binlog events $_in_binlog_file from $_binlog_start --eval show binlog events $_in_binlog_file from $_binlog_start
...@@ -148,12 +148,12 @@ master-bin.000001 # Query 1 # use `db1``; select 'oops!'`; CREATE TABLE `t``1` ( ...@@ -148,12 +148,12 @@ master-bin.000001 # Query 1 # use `db1``; select 'oops!'`; CREATE TABLE `t``1` (
`c``3` VARCHAR(7)) `c``3` VARCHAR(7))
master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Begin_load_query 1 # ;file_id=#;block_len=14 master-bin.000001 # Begin_load_query 1 # ;file_id=#;block_len=14
master-bin.000001 # Execute_load_query 1 # use `db1``; select 'oops!'`; LOAD DATA INFILE '/usr/home/serg/Abk/mysql/10.0-monty/mysql-test/var/tmp/f\'le.txt' INTO TABLE `t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, @`b```) SET `b``2`= @`b```, `c``3`= concat('|', "b""a'z", "!") ;file_id=# master-bin.000001 # Execute_load_query 1 # use `db1``; select 'oops!'`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, @`b```) SET `b``2`= @`b```, `c``3`= concat('|', "b""a'z", "!") ;file_id=#
master-bin.000001 # Query 1 # COMMIT master-bin.000001 # Query 1 # COMMIT
master-bin.000001 # Query 1 # use `db1``; select 'oops!'`; truncate `t``1` master-bin.000001 # Query 1 # use `db1``; select 'oops!'`; truncate `t``1`
master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Begin_load_query 1 # ;file_id=#;block_len=14 master-bin.000001 # Begin_load_query 1 # ;file_id=#;block_len=14
master-bin.000001 # Execute_load_query 1 # use `test`; LOAD DATA INFILE '/usr/home/serg/Abk/mysql/10.0-monty/mysql-test/var/tmp/f\'le.txt' INTO TABLE `db1``; select 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`= concat('|', "b""a'z", "!") ;file_id=# master-bin.000001 # Execute_load_query 1 # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/f\'le.txt' INTO TABLE `db1``; select 'oops!'`.`t``1` FIELDS TERMINATED BY ',' ENCLOSED BY '\'' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a``1`, `b``2`) SET `c``3`= concat('|', "b""a'z", "!") ;file_id=#
master-bin.000001 # Query 1 # COMMIT master-bin.000001 # Query 1 # COMMIT
/*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
...@@ -216,7 +216,7 @@ show binlog events from <binlog_start>; ...@@ -216,7 +216,7 @@ show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Query 1 # BEGIN
master-bin.000001 # Begin_load_query 1 # ;file_id=#;block_len=8 master-bin.000001 # Begin_load_query 1 # ;file_id=#;block_len=8
master-bin.000001 # Execute_load_query 1 # use `test`; LOAD DATA INFILE '/usr/home/serg/Abk/mysql/10.0-monty/mysql-test/var/tmp/file.txt' INTO TABLE `t1` FIELDS TERMINATED BY ',' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`= CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b) ;file_id=# master-bin.000001 # Execute_load_query 1 # use `test`; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/file.txt' INTO TABLE `t1` FIELDS TERMINATED BY ',' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`a`, @`b`) SET `b`= CONCAT(@b, '| 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J123456789K123456789L123456789M123456789N123456789O123456789P123456789Q123456789R123456789123456789T123456789U123456789V123456789W123456789X123456789Y123456789Z123456789|', @b) ;file_id=#
master-bin.000001 # Query 1 # COMMIT master-bin.000001 # Query 1 # COMMIT
SELECT * FROM t1 ORDER BY a; SELECT * FROM t1 ORDER BY a;
a b a b
......
...@@ -24,12 +24,6 @@ ...@@ -24,12 +24,6 @@
====================================================================== ======================================================================
*/ */
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation // gcc: Class implementation
#endif
#ifdef HAVE_OQGRAPH
#include <mysql_version.h> #include <mysql_version.h>
#include "ha_oqgraph.h" #include "ha_oqgraph.h"
#include "graphcore.h" #include "graphcore.h"
...@@ -39,7 +33,6 @@ ...@@ -39,7 +33,6 @@
#include "table.h" #include "table.h"
#include "field.h" #include "field.h"
#include "key.h" #include "key.h"
//#include "sql_class.h"
#define OQGRAPH_STATS_UPDATE_THRESHOLD 10 #define OQGRAPH_STATS_UPDATE_THRESHOLD 10
...@@ -61,52 +54,11 @@ static const char oqgraph_description[]= ...@@ -61,52 +54,11 @@ static const char oqgraph_description[]=
"Open Query Graph Computation Engine, stored in memory " "Open Query Graph Computation Engine, stored in memory "
"(http://openquery.com/graph)"; "(http://openquery.com/graph)";
#if MYSQL_VERSION_ID < 50100
static bool oqgraph_init();
handlerton oqgraph_hton= {
"OQGRAPH",
SHOW_OPTION_YES,
oqgraph_description,
DB_TYPE_OQGRAPH,
oqgraph_init,
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
NULL, /* savepoint */
NULL, /* rollback to savepoint */
NULL, /* release savepoint */
NULL, /* commit */
NULL, /* rollback */
NULL, /* prepare */
NULL, /* recover */
NULL, /* commit_by_xid */
NULL, /* rollback_by_xid */
NULL, /* create_cursor_read_view */
NULL, /* set_cursor_read_view */
NULL, /* close_cursor_read_view */
HTON_NO_FLAGS
};
#define STATISTIC_INCREMENT(X) \
statistic_increment(table->in_use->status_var.X, &LOCK_status)
#define MOVE(X) move_field(X)
#define RECORDS records
#else
#define STATISTIC_INCREMENT(X) /* nothing */
#define MOVE(X) move_field_offset(X)
#define RECORDS stats.records
#endif
static HASH oqgraph_open_tables; static HASH oqgraph_open_tables;
static pthread_mutex_t LOCK_oqgraph; static mysql_mutex_t LOCK_oqgraph;
static bool oqgraph_init_done= 0; static bool oqgraph_init_done= 0;
#if MYSQL_VERSION_ID >= 50130
#define HASH_KEY_LENGTH size_t #define HASH_KEY_LENGTH size_t
#else
#define HASH_KEY_LENGTH uint
#endif
static uchar* get_key(const uchar *ptr, HASH_KEY_LENGTH *length, static uchar* get_key(const uchar *ptr, HASH_KEY_LENGTH *length,
my_bool) my_bool)
...@@ -116,7 +68,22 @@ static uchar* get_key(const uchar *ptr, HASH_KEY_LENGTH *length, ...@@ -116,7 +68,22 @@ static uchar* get_key(const uchar *ptr, HASH_KEY_LENGTH *length,
return (uchar*) share->name; return (uchar*) share->name;
} }
#if MYSQL_VERSION_ID >= 50100 #ifdef HAVE_PSI_INTERFACE
static PSI_mutex_key key_LOCK_oqgraph;
static PSI_mutex_info all_mutexes[]=
{
{ &key_LOCK_oqgraph, "LOCK_oqgraph", PSI_FLAG_GLOBAL},
};
static void init_psi_keys()
{
mysql_mutex_register("oqgraph", all_mutexes, array_elements(all_mutexes));
}
#else
#define init_psi_keys() /* no-op */
#endif /* HAVE_PSI_INTERFACE */
static handler* oqgraph_create_handler(handlerton *hton, TABLE_SHARE *table, static handler* oqgraph_create_handler(handlerton *hton, TABLE_SHARE *table,
MEM_ROOT *mem_root) MEM_ROOT *mem_root)
{ {
...@@ -125,51 +92,39 @@ static handler* oqgraph_create_handler(handlerton *hton, TABLE_SHARE *table, ...@@ -125,51 +92,39 @@ static handler* oqgraph_create_handler(handlerton *hton, TABLE_SHARE *table,
static int oqgraph_init(handlerton *hton) static int oqgraph_init(handlerton *hton)
{ {
#else init_psi_keys();
static bool oqgraph_init() if (mysql_mutex_init(key_LOCK_oqgraph, &LOCK_oqgraph, MY_MUTEX_INIT_FAST))
{
if (have_oqgraph == SHOW_OPTION_DISABLED)
return 1;
#endif
if (pthread_mutex_init(&LOCK_oqgraph, MY_MUTEX_INIT_FAST))
goto error; goto error;
if (my_hash_init(&oqgraph_open_tables, &my_charset_bin, 32, 0, 0, if (my_hash_init(&oqgraph_open_tables, &my_charset_bin, 32, 0, 0,
get_key, 0, 0)) get_key, 0, 0))
{ {
pthread_mutex_destroy(&LOCK_oqgraph); mysql_mutex_destroy(&LOCK_oqgraph);
goto error; goto error;
} }
#if MYSQL_VERSION_ID >= 50100
hton->state= SHOW_OPTION_YES; hton->state= SHOW_OPTION_YES;
hton->db_type= DB_TYPE_AUTOASSIGN; hton->db_type= DB_TYPE_AUTOASSIGN;
hton->create= oqgraph_create_handler; hton->create= oqgraph_create_handler;
hton->flags= HTON_NO_FLAGS; hton->flags= HTON_NO_FLAGS;
#endif
oqgraph_init_done= TRUE; oqgraph_init_done= TRUE;
return 0; return 0;
error: error:
#if MYSQL_VERSION_ID < 50100
have_oqgraph= SHOW_OPTION_DISABLED;
#endif
return 1; return 1;
} }
#if MYSQL_VERSION_ID >= 50100
static int oqgraph_fini(void *) static int oqgraph_fini(void *)
{ {
my_hash_free(&oqgraph_open_tables); my_hash_free(&oqgraph_open_tables);
pthread_mutex_destroy(&LOCK_oqgraph); mysql_mutex_destroy(&LOCK_oqgraph);
oqgraph_init_done= FALSE; oqgraph_init_done= FALSE;
return 0; return 0;
} }
#endif
static OQGRAPH_INFO *get_share(const char *name, TABLE *table=0) static OQGRAPH_INFO *get_share(const char *name, TABLE *table=0)
{ {
OQGRAPH_INFO *share; OQGRAPH_INFO *share;
uint length= strlen(name); uint length= strlen(name);
safe_mutex_assert_owner(&LOCK_oqgraph); mysql_mutex_assert_owner(&LOCK_oqgraph);
if (!(share= (OQGRAPH_INFO*) my_hash_search(&oqgraph_open_tables, if (!(share= (OQGRAPH_INFO*) my_hash_search(&oqgraph_open_tables,
(byte*) name, length))) (byte*) name, length)))
{ {
...@@ -198,7 +153,7 @@ static OQGRAPH_INFO *get_share(const char *name, TABLE *table=0) ...@@ -198,7 +153,7 @@ static OQGRAPH_INFO *get_share(const char *name, TABLE *table=0)
static int free_share(OQGRAPH_INFO *share, bool drop=0) static int free_share(OQGRAPH_INFO *share, bool drop=0)
{ {
safe_mutex_assert_owner(&LOCK_oqgraph); mysql_mutex_assert_owner(&LOCK_oqgraph);
if (!share) if (!share)
return 0; return 0;
if (drop) if (drop)
...@@ -331,13 +286,8 @@ static int oqgraph_check_table_structure (TABLE *table_arg) ...@@ -331,13 +286,8 @@ static int oqgraph_check_table_structure (TABLE *table_arg)
** OQGRAPH tables ** OQGRAPH tables
*****************************************************************************/ *****************************************************************************/
#if MYSQL_VERSION_ID >= 50100
ha_oqgraph::ha_oqgraph(handlerton *hton, TABLE_SHARE *table_arg) ha_oqgraph::ha_oqgraph(handlerton *hton, TABLE_SHARE *table_arg)
: handler(hton, table_arg), : handler(hton, table_arg),
#else
ha_oqgraph::ha_oqgraph(TABLE *table_arg)
: handler(&oqgraph_hton, table_arg),
#endif
share(0), graph(0), records_changed(0), key_stat_version(0) share(0), graph(0), records_changed(0), key_stat_version(0)
{ } { }
...@@ -352,11 +302,7 @@ const char **ha_oqgraph::bas_ext() const ...@@ -352,11 +302,7 @@ const char **ha_oqgraph::bas_ext() const
return ha_oqgraph_exts; return ha_oqgraph_exts;
} }
#if MYSQL_VERSION_ID >= 50100
ulonglong ha_oqgraph::table_flags() const ulonglong ha_oqgraph::table_flags() const
#else
ulong ha_oqgraph::table_flags() const
#endif
{ {
return (HA_NO_BLOBS | HA_NULL_IN_KEY | return (HA_NO_BLOBS | HA_NULL_IN_KEY |
HA_REC_NOT_IN_SEQ | HA_CAN_INSERT_DELAYED | HA_REC_NOT_IN_SEQ | HA_CAN_INSERT_DELAYED |
...@@ -370,7 +316,7 @@ ulong ha_oqgraph::index_flags(uint inx, uint part, bool all_parts) const ...@@ -370,7 +316,7 @@ ulong ha_oqgraph::index_flags(uint inx, uint part, bool all_parts) const
int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) int ha_oqgraph::open(const char *name, int mode, uint test_if_locked)
{ {
pthread_mutex_lock(&LOCK_oqgraph); mysql_mutex_lock(&LOCK_oqgraph);
if ((share = get_share(name, table))) if ((share = get_share(name, table)))
{ {
ref_length= oqgraph::sizeof_ref; ref_length= oqgraph::sizeof_ref;
...@@ -393,17 +339,17 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) ...@@ -393,17 +339,17 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked)
*/ */
key_stat_version= share->key_stat_version-1; key_stat_version= share->key_stat_version-1;
} }
pthread_mutex_unlock(&LOCK_oqgraph); mysql_mutex_unlock(&LOCK_oqgraph);
return (share ? 0 : 1); return (share ? 0 : 1);
} }
int ha_oqgraph::close(void) int ha_oqgraph::close(void)
{ {
pthread_mutex_lock(&LOCK_oqgraph); mysql_mutex_lock(&LOCK_oqgraph);
oqgraph::free(graph); graph= 0; oqgraph::free(graph); graph= 0;
int res= free_share(share); int res= free_share(share);
pthread_mutex_unlock(&LOCK_oqgraph); mysql_mutex_unlock(&LOCK_oqgraph);
return error_code(res); return error_code(res);
} }
...@@ -439,18 +385,15 @@ int ha_oqgraph::write_row(byte * buf) ...@@ -439,18 +385,15 @@ int ha_oqgraph::write_row(byte * buf)
{ {
int res= oqgraph::MISC_FAIL; int res= oqgraph::MISC_FAIL;
Field ** const field= table->field; Field ** const field= table->field;
STATISTIC_INCREMENT(ha_write_count);
#if MYSQL_VERSION_ID >= 50100
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
#endif
my_ptrdiff_t ptrdiff= buf - table->record[0]; my_ptrdiff_t ptrdiff= buf - table->record[0];
if (ptrdiff) if (ptrdiff)
{ {
field[1]->MOVE(ptrdiff); field[1]->move_field_offset(ptrdiff);
field[2]->MOVE(ptrdiff); field[2]->move_field_offset(ptrdiff);
field[3]->MOVE(ptrdiff); field[3]->move_field_offset(ptrdiff);
} }
if (!field[1]->is_null() && !field[2]->is_null()) if (!field[1]->is_null() && !field[2]->is_null())
...@@ -473,13 +416,11 @@ int ha_oqgraph::write_row(byte * buf) ...@@ -473,13 +416,11 @@ int ha_oqgraph::write_row(byte * buf)
if (ptrdiff) if (ptrdiff)
{ {
field[1]->MOVE(-ptrdiff); field[1]->move_field_offset(-ptrdiff);
field[2]->MOVE(-ptrdiff); field[2]->move_field_offset(-ptrdiff);
field[3]->MOVE(-ptrdiff); field[3]->move_field_offset(-ptrdiff);
} }
#if MYSQL_VERSION_ID >= 50100
dbug_tmp_restore_column_map(table->read_set, old_map); dbug_tmp_restore_column_map(table->read_set, old_map);
#endif
if (!res && records_changed*OQGRAPH_STATS_UPDATE_THRESHOLD > share->records) if (!res && records_changed*OQGRAPH_STATS_UPDATE_THRESHOLD > share->records)
{ {
...@@ -499,19 +440,16 @@ int ha_oqgraph::update_row(const byte * old, byte * buf) ...@@ -499,19 +440,16 @@ int ha_oqgraph::update_row(const byte * old, byte * buf)
VertexID orig_id, dest_id; VertexID orig_id, dest_id;
EdgeWeight weight= 1; EdgeWeight weight= 1;
Field **field= table->field; Field **field= table->field;
STATISTIC_INCREMENT(ha_update_count);
#if MYSQL_VERSION_ID >= 50100
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
#endif
my_ptrdiff_t ptrdiff= buf - table->record[0]; my_ptrdiff_t ptrdiff= buf - table->record[0];
if (ptrdiff) if (ptrdiff)
{ {
field[0]->MOVE(ptrdiff); field[0]->move_field_offset(ptrdiff);
field[1]->MOVE(ptrdiff); field[1]->move_field_offset(ptrdiff);
field[2]->MOVE(ptrdiff); field[2]->move_field_offset(ptrdiff);
field[3]->MOVE(ptrdiff); field[3]->move_field_offset(ptrdiff);
} }
if (inited == INDEX || inited == RND) if (inited == INDEX || inited == RND)
...@@ -527,10 +465,10 @@ int ha_oqgraph::update_row(const byte * old, byte * buf) ...@@ -527,10 +465,10 @@ int ha_oqgraph::update_row(const byte * old, byte * buf)
my_ptrdiff_t ptrdiff2= old - buf; my_ptrdiff_t ptrdiff2= old - buf;
field[0]->MOVE(ptrdiff2); field[0]->move_field_offset(ptrdiff2);
field[1]->MOVE(ptrdiff2); field[1]->move_field_offset(ptrdiff2);
field[2]->MOVE(ptrdiff2); field[2]->move_field_offset(ptrdiff2);
field[3]->MOVE(ptrdiff2); field[3]->move_field_offset(ptrdiff2);
if (field[0]->is_null()) if (field[0]->is_null())
{ {
...@@ -551,22 +489,20 @@ int ha_oqgraph::update_row(const byte * old, byte * buf) ...@@ -551,22 +489,20 @@ int ha_oqgraph::update_row(const byte * old, byte * buf)
res= oqgraph::OK; res= oqgraph::OK;
} }
field[0]->MOVE(-ptrdiff2); field[0]->move_field_offset(-ptrdiff2);
field[1]->MOVE(-ptrdiff2); field[1]->move_field_offset(-ptrdiff2);
field[2]->MOVE(-ptrdiff2); field[2]->move_field_offset(-ptrdiff2);
field[3]->MOVE(-ptrdiff2); field[3]->move_field_offset(-ptrdiff2);
} }
if (ptrdiff) if (ptrdiff)
{ {
field[0]->MOVE(-ptrdiff); field[0]->move_field_offset(-ptrdiff);
field[1]->MOVE(-ptrdiff); field[1]->move_field_offset(-ptrdiff);
field[2]->MOVE(-ptrdiff); field[2]->move_field_offset(-ptrdiff);
field[3]->MOVE(-ptrdiff); field[3]->move_field_offset(-ptrdiff);
} }
#if MYSQL_VERSION_ID >= 50100
dbug_tmp_restore_column_map(table->read_set, old_map); dbug_tmp_restore_column_map(table->read_set, old_map);
#endif
if (!res && records_changed*OQGRAPH_STATS_UPDATE_THRESHOLD > share->records) if (!res && records_changed*OQGRAPH_STATS_UPDATE_THRESHOLD > share->records)
{ {
...@@ -583,7 +519,6 @@ int ha_oqgraph::delete_row(const byte * buf) ...@@ -583,7 +519,6 @@ int ha_oqgraph::delete_row(const byte * buf)
{ {
int res= oqgraph::EDGE_NOT_FOUND; int res= oqgraph::EDGE_NOT_FOUND;
Field **field= table->field; Field **field= table->field;
STATISTIC_INCREMENT(ha_delete_count);
if (inited == INDEX || inited == RND) if (inited == INDEX || inited == RND)
{ {
...@@ -595,16 +530,14 @@ int ha_oqgraph::delete_row(const byte * buf) ...@@ -595,16 +530,14 @@ int ha_oqgraph::delete_row(const byte * buf)
} }
if (res != oqgraph::OK) if (res != oqgraph::OK)
{ {
#if MYSQL_VERSION_ID >= 50100
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
#endif
my_ptrdiff_t ptrdiff= buf - table->record[0]; my_ptrdiff_t ptrdiff= buf - table->record[0];
if (ptrdiff) if (ptrdiff)
{ {
field[0]->MOVE(ptrdiff); field[0]->move_field_offset(ptrdiff);
field[1]->MOVE(ptrdiff); field[1]->move_field_offset(ptrdiff);
field[2]->MOVE(ptrdiff); field[2]->move_field_offset(ptrdiff);
} }
if (field[0]->is_null() && !field[1]->is_null() && !field[2]->is_null()) if (field[0]->is_null() && !field[1]->is_null() && !field[2]->is_null())
...@@ -621,13 +554,11 @@ int ha_oqgraph::delete_row(const byte * buf) ...@@ -621,13 +554,11 @@ int ha_oqgraph::delete_row(const byte * buf)
if (ptrdiff) if (ptrdiff)
{ {
field[0]->MOVE(-ptrdiff); field[0]->move_field_offset(-ptrdiff);
field[1]->MOVE(-ptrdiff); field[1]->move_field_offset(-ptrdiff);
field[2]->MOVE(-ptrdiff); field[2]->move_field_offset(-ptrdiff);
} }
#if MYSQL_VERSION_ID >= 50100
dbug_tmp_restore_column_map(table->read_set, old_map); dbug_tmp_restore_column_map(table->read_set, old_map);
#endif
} }
if (!res && table->s->tmp_table == NO_TMP_TABLE && if (!res && table->s->tmp_table == NO_TMP_TABLE &&
...@@ -654,7 +585,6 @@ int ha_oqgraph::index_next_same(byte *buf, const byte *key, uint key_len) ...@@ -654,7 +585,6 @@ int ha_oqgraph::index_next_same(byte *buf, const byte *key, uint key_len)
int res; int res;
open_query::row row; open_query::row row;
DBUG_ASSERT(inited==INDEX); DBUG_ASSERT(inited==INDEX);
STATISTIC_INCREMENT(ha_read_key_count);
if (!(res= graph->fetch_row(row))) if (!(res= graph->fetch_row(row)))
res= fill_record(buf, row); res= fill_record(buf, row);
table->status= res ? STATUS_NOT_FOUND : 0; table->status= res ? STATUS_NOT_FOUND : 0;
...@@ -672,21 +602,18 @@ int ha_oqgraph::index_read_idx(byte * buf, uint index, const byte * key, ...@@ -672,21 +602,18 @@ int ha_oqgraph::index_read_idx(byte * buf, uint index, const byte * key,
VertexID *orig_idp=0, *dest_idp=0; VertexID *orig_idp=0, *dest_idp=0;
int *latchp=0; int *latchp=0;
open_query::row row; open_query::row row;
STATISTIC_INCREMENT(ha_read_key_count);
bmove_align(buf, table->s->default_values, table->s->reclength); bmove_align(buf, table->s->default_values, table->s->reclength);
key_restore(buf, (byte*) key, key_info, key_len); key_restore(buf, (byte*) key, key_info, key_len);
#if MYSQL_VERSION_ID >= 50100
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
#endif
my_ptrdiff_t ptrdiff= buf - table->record[0]; my_ptrdiff_t ptrdiff= buf - table->record[0];
if (ptrdiff) if (ptrdiff)
{ {
field[0]->MOVE(ptrdiff); field[0]->move_field_offset(ptrdiff);
field[1]->MOVE(ptrdiff); field[1]->move_field_offset(ptrdiff);
field[2]->MOVE(ptrdiff); field[2]->move_field_offset(ptrdiff);
} }
if (!field[0]->is_null()) if (!field[0]->is_null())
...@@ -709,13 +636,11 @@ int ha_oqgraph::index_read_idx(byte * buf, uint index, const byte * key, ...@@ -709,13 +636,11 @@ int ha_oqgraph::index_read_idx(byte * buf, uint index, const byte * key,
if (ptrdiff) if (ptrdiff)
{ {
field[0]->MOVE(-ptrdiff); field[0]->move_field_offset(-ptrdiff);
field[1]->MOVE(-ptrdiff); field[1]->move_field_offset(-ptrdiff);
field[2]->MOVE(-ptrdiff); field[2]->move_field_offset(-ptrdiff);
} }
#if MYSQL_VERSION_ID >= 50100
dbug_tmp_restore_column_map(table->read_set, old_map); dbug_tmp_restore_column_map(table->read_set, old_map);
#endif
res= graph->search(latchp, orig_idp, dest_idp); res= graph->search(latchp, orig_idp, dest_idp);
...@@ -731,19 +656,17 @@ int ha_oqgraph::fill_record(byte *record, const open_query::row &row) ...@@ -731,19 +656,17 @@ int ha_oqgraph::fill_record(byte *record, const open_query::row &row)
bmove_align(record, table->s->default_values, table->s->reclength); bmove_align(record, table->s->default_values, table->s->reclength);
#if MYSQL_VERSION_ID >= 50100
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set); my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
#endif
my_ptrdiff_t ptrdiff= record - table->record[0]; my_ptrdiff_t ptrdiff= record - table->record[0];
if (ptrdiff) if (ptrdiff)
{ {
field[0]->MOVE(ptrdiff); field[0]->move_field_offset(ptrdiff);
field[1]->MOVE(ptrdiff); field[1]->move_field_offset(ptrdiff);
field[2]->MOVE(ptrdiff); field[2]->move_field_offset(ptrdiff);
field[3]->MOVE(ptrdiff); field[3]->move_field_offset(ptrdiff);
field[4]->MOVE(ptrdiff); field[4]->move_field_offset(ptrdiff);
field[5]->MOVE(ptrdiff); field[5]->move_field_offset(ptrdiff);
} }
// just each field specifically, no sense iterating // just each field specifically, no sense iterating
...@@ -785,16 +708,14 @@ int ha_oqgraph::fill_record(byte *record, const open_query::row &row) ...@@ -785,16 +708,14 @@ int ha_oqgraph::fill_record(byte *record, const open_query::row &row)
if (ptrdiff) if (ptrdiff)
{ {
field[0]->MOVE(-ptrdiff); field[0]->move_field_offset(-ptrdiff);
field[1]->MOVE(-ptrdiff); field[1]->move_field_offset(-ptrdiff);
field[2]->MOVE(-ptrdiff); field[2]->move_field_offset(-ptrdiff);
field[3]->MOVE(-ptrdiff); field[3]->move_field_offset(-ptrdiff);
field[4]->MOVE(-ptrdiff); field[4]->move_field_offset(-ptrdiff);
field[5]->MOVE(-ptrdiff); field[5]->move_field_offset(-ptrdiff);
} }
#if MYSQL_VERSION_ID >= 50100
dbug_tmp_restore_column_map(table->write_set, old_map); dbug_tmp_restore_column_map(table->write_set, old_map);
#endif
return 0; return 0;
} }
...@@ -808,7 +729,6 @@ int ha_oqgraph::rnd_next(byte *buf) ...@@ -808,7 +729,6 @@ int ha_oqgraph::rnd_next(byte *buf)
{ {
int res; int res;
open_query::row row; open_query::row row;
STATISTIC_INCREMENT(ha_read_rnd_next_count);
if (!(res= graph->fetch_row(row))) if (!(res= graph->fetch_row(row)))
res= fill_record(buf, row); res= fill_record(buf, row);
table->status= res ? STATUS_NOT_FOUND: 0; table->status= res ? STATUS_NOT_FOUND: 0;
...@@ -819,7 +739,6 @@ int ha_oqgraph::rnd_pos(byte * buf, byte *pos) ...@@ -819,7 +739,6 @@ int ha_oqgraph::rnd_pos(byte * buf, byte *pos)
{ {
int res; int res;
open_query::row row; open_query::row row;
STATISTIC_INCREMENT(ha_read_rnd_count);
if (!(res= graph->fetch_row(row, pos))) if (!(res= graph->fetch_row(row, pos)))
res= fill_record(buf, row); res= fill_record(buf, row);
table->status=res ? STATUS_NOT_FOUND: 0; table->status=res ? STATUS_NOT_FOUND: 0;
...@@ -838,17 +757,7 @@ int ha_oqgraph::cmp_ref(const byte *ref1, const byte *ref2) ...@@ -838,17 +757,7 @@ int ha_oqgraph::cmp_ref(const byte *ref1, const byte *ref2)
int ha_oqgraph::info(uint flag) int ha_oqgraph::info(uint flag)
{ {
RECORDS= graph->vertices_count() + graph->edges_count(); stats.records= graph->vertices_count() + graph->edges_count();
#if 0
records= hp_info.records;
deleted= hp_info.deleted;
errkey= hp_info.errkey;
mean_rec_length= hp_info.reclength;
data_file_length= hp_info.data_length;
index_file_length= hp_info.index_length;
max_data_file_length= hp_info.max_records* hp_info.reclength;
delete_length= hp_info.deleted * hp_info.reclength;
#endif
/* /*
If info() is called for the first time after open(), we will still If info() is called for the first time after open(), we will still
have to update the key statistics. Hoping that a table lock is now have to update the key statistics. Hoping that a table lock is now
...@@ -929,25 +838,25 @@ int ha_oqgraph::delete_table(const char *name) ...@@ -929,25 +838,25 @@ int ha_oqgraph::delete_table(const char *name)
{ {
int res= 0; int res= 0;
OQGRAPH_INFO *share; OQGRAPH_INFO *share;
pthread_mutex_lock(&LOCK_oqgraph); mysql_mutex_lock(&LOCK_oqgraph);
if ((share= get_share(name))) if ((share= get_share(name)))
{ {
res= free_share(share, true); res= free_share(share, true);
} }
pthread_mutex_unlock(&LOCK_oqgraph); mysql_mutex_unlock(&LOCK_oqgraph);
return error_code(res); return error_code(res);
} }
int ha_oqgraph::rename_table(const char * from, const char * to) int ha_oqgraph::rename_table(const char * from, const char * to)
{ {
pthread_mutex_lock(&LOCK_oqgraph); mysql_mutex_lock(&LOCK_oqgraph);
if (OQGRAPH_INFO *share= get_share(from)) if (OQGRAPH_INFO *share= get_share(from))
{ {
strmov(share->name, to); strmov(share->name, to);
my_hash_update(&oqgraph_open_tables, (byte*) share, my_hash_update(&oqgraph_open_tables, (byte*) share,
(byte*) from, strlen(from)); (byte*) from, strlen(from));
} }
pthread_mutex_unlock(&LOCK_oqgraph); mysql_mutex_unlock(&LOCK_oqgraph);
return 0; return 0;
} }
...@@ -956,8 +865,6 @@ ha_rows ha_oqgraph::records_in_range(uint inx, key_range *min_key, ...@@ -956,8 +865,6 @@ ha_rows ha_oqgraph::records_in_range(uint inx, key_range *min_key,
key_range *max_key) key_range *max_key)
{ {
KEY *key=table->key_info+inx; KEY *key=table->key_info+inx;
//if (key->algorithm == HA_KEY_ALG_BTREE)
// return btree_records_in_range(file, inx, min_key, max_key);
if (!min_key || !max_key || if (!min_key || !max_key ||
min_key->length != max_key->length || min_key->length != max_key->length ||
...@@ -976,8 +883,8 @@ ha_rows ha_oqgraph::records_in_range(uint inx, key_range *min_key, ...@@ -976,8 +883,8 @@ ha_rows ha_oqgraph::records_in_range(uint inx, key_range *min_key,
return HA_POS_ERROR; // Can only use exact keys return HA_POS_ERROR; // Can only use exact keys
} }
if (RECORDS <= 1) if (stats.records <= 1)
return RECORDS; return stats.records;
/* Assert that info() did run. We need current statistics here. */ /* Assert that info() did run. We need current statistics here. */
DBUG_ASSERT(key_stat_version == share->key_stat_version); DBUG_ASSERT(key_stat_version == share->key_stat_version);
...@@ -993,7 +900,7 @@ int ha_oqgraph::create(const char *name, TABLE *table_arg, ...@@ -993,7 +900,7 @@ int ha_oqgraph::create(const char *name, TABLE *table_arg,
int res = -1; int res = -1;
OQGRAPH_INFO *share; OQGRAPH_INFO *share;
pthread_mutex_lock(&LOCK_oqgraph); mysql_mutex_lock(&LOCK_oqgraph);
if ((share= get_share(name))) if ((share= get_share(name)))
{ {
free_share(share); free_share(share);
...@@ -1003,7 +910,7 @@ int ha_oqgraph::create(const char *name, TABLE *table_arg, ...@@ -1003,7 +910,7 @@ int ha_oqgraph::create(const char *name, TABLE *table_arg,
if (!oqgraph_check_table_structure(table_arg)) if (!oqgraph_check_table_structure(table_arg))
res= 0;; res= 0;;
} }
pthread_mutex_unlock(&LOCK_oqgraph); mysql_mutex_unlock(&LOCK_oqgraph);
if (this->share) if (this->share)
info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE); info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE);
...@@ -1014,11 +921,8 @@ int ha_oqgraph::create(const char *name, TABLE *table_arg, ...@@ -1014,11 +921,8 @@ int ha_oqgraph::create(const char *name, TABLE *table_arg,
void ha_oqgraph::update_create_info(HA_CREATE_INFO *create_info) void ha_oqgraph::update_create_info(HA_CREATE_INFO *create_info)
{ {
table->file->info(HA_STATUS_AUTO); table->file->info(HA_STATUS_AUTO);
//if (!(create_info->used_fields & HA_CREATE_USED_AUTO))
// create_info->auto_increment_value= auto_increment_value;
} }
#if MYSQL_VERSION_ID >= 50100
struct st_mysql_storage_engine oqgraph_storage_engine= struct st_mysql_storage_engine oqgraph_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION }; { MYSQL_HANDLERTON_INTERFACE_VERSION };
...@@ -1039,7 +943,3 @@ maria_declare_plugin(oqgraph) ...@@ -1039,7 +943,3 @@ maria_declare_plugin(oqgraph)
MariaDB_PLUGIN_MATURITY_BETA MariaDB_PLUGIN_MATURITY_BETA
} }
maria_declare_plugin_end; maria_declare_plugin_end;
#endif
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment