Ndb handler cleanup:

  - removed some returns on ndb internal error codes, return ndb cause in warnings
  - moved all errorcode mapping mysqld-ndb to ndberror.c
  - ndb util thread to discover all ndb tables at startup
  - ndb util thread to wait for mysqld startup
parent 4caff6eb
...@@ -6,7 +6,7 @@ a b ...@@ -6,7 +6,7 @@ a b
4 5 4 5
show status like 'handler_discover%'; show status like 'handler_discover%';
Variable_name Value Variable_name Value
Handler_discover 1 Handler_discover 0
drop table t9; drop table t9;
select * from t10; select * from t10;
ERROR HY000: Got error 4263 'Invalid blob attributes or invalid blob parts table' from NDBCLUSTER ERROR HY000: Got error 4263 'Invalid blob attributes or invalid blob parts table' from NDBCLUSTER
......
...@@ -201,10 +201,18 @@ create table t1 ( ...@@ -201,10 +201,18 @@ create table t1 (
pk1 bit(9) not null primary key, pk1 bit(9) not null primary key,
b int b int
) engine=ndbcluster; ) engine=ndbcluster;
ERROR HY000: Can't create table './test/t1.frm' (errno: 739) ERROR HY000: Can't create table './test/t1.frm' (errno: 140)
show warnings;
Level Code Message
Error 1296 Got error 739 'Unsupported primary key length' from NDB
Error 1005 Can't create table './test/t1.frm' (errno: 140)
create table t1 ( create table t1 (
pk1 int not null primary key, pk1 int not null primary key,
b bit(9), b bit(9),
key(b) key(b)
) engine=ndbcluster; ) engine=ndbcluster;
ERROR HY000: Can't create table './test/t1.frm' (errno: 743) ERROR HY000: Can't create table './test/t1.frm' (errno: 140)
show warnings;
Level Code Message
Error 1296 Got error 743 'Unsupported character set in table or index' from NDB
Error 1005 Can't create table './test/t1.frm' (errno: 140)
...@@ -29,7 +29,12 @@ drop table t1; ...@@ -29,7 +29,12 @@ drop table t1;
create table t1 (a int) engine=ndbcluster; create table t1 (a int) engine=ndbcluster;
insert into t1 value (2); insert into t1 value (2);
select * from t1; select * from t1;
ERROR HY000: Got error 241 'Invalid schema object version' from NDBCLUSTER ERROR HY000: Table definition has changed, please retry transaction
show warnings;
Level Code Message
Error 1296 Got error 241 'Invalid schema object version' from NDB
Error 1412 Table definition has changed, please retry transaction
Error 1105 Unknown error
select * from t1; select * from t1;
a a
2 2
......
...@@ -11,7 +11,11 @@ partitions 3 ...@@ -11,7 +11,11 @@ partitions 3
(partition x1 values less than (5) nodegroup 12, (partition x1 values less than (5) nodegroup 12,
partition x2 values less than (10) nodegroup 13, partition x2 values less than (10) nodegroup 13,
partition x3 values less than (20) nodegroup 14); partition x3 values less than (20) nodegroup 14);
ERROR HY000: Can't create table './test/t1.frm' (errno: 771) ERROR HY000: Can't create table './test/t1.frm' (errno: 140)
show warnings;
Level Code Message
Error 1296 Got error 771 'Given NODEGROUP doesn't exist in this cluster' from NDB
Error 1005 Can't create table './test/t1.frm' (errno: 140)
CREATE TABLE t1 ( CREATE TABLE t1 (
a int not null, a int not null,
b int not null, b int not null,
......
DROP TABLE IF EXISTS t1, r1; DROP TABLE IF EXISTS t1, t2, r1;
create table t1 ( create table t1 (
a int primary key, a int primary key,
b int not null, b int not null,
......
...@@ -104,6 +104,7 @@ create table t1 ( ...@@ -104,6 +104,7 @@ create table t1 (
pk1 bit(9) not null primary key, pk1 bit(9) not null primary key,
b int b int
) engine=ndbcluster; ) engine=ndbcluster;
show warnings;
--error 1005 --error 1005
create table t1 ( create table t1 (
...@@ -111,4 +112,4 @@ create table t1 ( ...@@ -111,4 +112,4 @@ create table t1 (
b bit(9), b bit(9),
key(b) key(b)
) engine=ndbcluster; ) engine=ndbcluster;
show warnings;
...@@ -38,8 +38,9 @@ create table t1 (a int) engine=ndbcluster; ...@@ -38,8 +38,9 @@ create table t1 (a int) engine=ndbcluster;
insert into t1 value (2); insert into t1 value (2);
connection server1; connection server1;
# Currently a retry is required remotely # Currently a retry is required remotely
--error 1296 --error 1412
select * from t1; select * from t1;
show warnings;
select * from t1; select * from t1;
# Connect to server2 and use the tables from there # Connect to server2 and use the tables from there
......
...@@ -26,6 +26,7 @@ partitions 3 ...@@ -26,6 +26,7 @@ partitions 3
(partition x1 values less than (5) nodegroup 12, (partition x1 values less than (5) nodegroup 12,
partition x2 values less than (10) nodegroup 13, partition x2 values less than (10) nodegroup 13,
partition x3 values less than (20) nodegroup 14); partition x3 values less than (20) nodegroup 14);
show warnings;
# #
# Partition by range, create normal valid table # Partition by range, create normal valid table
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
-- source include/not_embedded.inc -- source include/not_embedded.inc
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1, r1; DROP TABLE IF EXISTS t1, t2, r1;
--enable_warnings --enable_warnings
# #
......
This diff is collapsed.
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#pragma interface /* gcc class implementation */ #pragma interface /* gcc class implementation */
#endif #endif
#include <ndbapi/NdbApi.hpp>
#include <ndbapi_limits.h> #include <ndbapi_limits.h>
class Ndb; // Forward declaration class Ndb; // Forward declaration
...@@ -36,10 +37,13 @@ class NdbScanFilter; ...@@ -36,10 +37,13 @@ class NdbScanFilter;
class NdbIndexScanOperation; class NdbIndexScanOperation;
class NdbBlob; class NdbBlob;
class NdbIndexStat; class NdbIndexStat;
class NdbEventOperation;
// connectstring to cluster if given by mysqld // connectstring to cluster if given by mysqld
extern const char *ndbcluster_connectstring; extern const char *ndbcluster_connectstring;
extern ulong ndb_cache_check_time; extern ulong ndb_cache_check_time;
extern ulong ndb_report_thresh_binlog_epoch_slip;
extern ulong ndb_report_thresh_binlog_mem_usage;
typedef enum ndb_index_type { typedef enum ndb_index_type {
UNDEFINED_INDEX = 0, UNDEFINED_INDEX = 0,
...@@ -63,13 +67,25 @@ typedef struct ndb_index_data { ...@@ -63,13 +67,25 @@ typedef struct ndb_index_data {
uint index_stat_query_count; uint index_stat_query_count;
} NDB_INDEX_DATA; } NDB_INDEX_DATA;
typedef union { const NdbRecAttr *rec; NdbBlob *blob; void *ptr; } NdbValue;
typedef enum {
NSS_INITIAL= 0,
NSS_DROPPED
} NDB_SHARE_STATE;
typedef struct st_ndbcluster_share { typedef struct st_ndbcluster_share {
MEM_ROOT mem_root;
THR_LOCK lock; THR_LOCK lock;
pthread_mutex_t mutex; pthread_mutex_t mutex;
char *table_name; char *key;
uint table_name_length,use_count; uint key_length;
THD *util_lock;
uint use_count;
uint commit_count_lock; uint commit_count_lock;
ulonglong commit_count; ulonglong commit_count;
char *db;
char *table_name;
} NDB_SHARE; } NDB_SHARE;
typedef enum ndb_item_type { typedef enum ndb_item_type {
...@@ -595,9 +611,16 @@ static void set_tabname(const char *pathname, char *tabname); ...@@ -595,9 +611,16 @@ static void set_tabname(const char *pathname, char *tabname);
bool check_if_incompatible_data(HA_CREATE_INFO *info, bool check_if_incompatible_data(HA_CREATE_INFO *info,
uint table_changes); uint table_changes);
static void invalidate_dictionary_cache(TABLE *table, Ndb *ndb,
const char *tabname, bool global);
private: private:
friend int ndbcluster_drop_database(const char *path);
int alter_table_name(const char *to); int alter_table_name(const char *to);
static int delete_table(ha_ndbcluster *h, Ndb *ndb,
const char *path,
const char *db,
const char *table_name);
int drop_table(); int drop_table();
int create_index(const char *name, KEY *key_info, bool unique); int create_index(const char *name, KEY *key_info, bool unique);
int create_ordered_index(const char *name, KEY *key_info); int create_ordered_index(const char *name, KEY *key_info);
...@@ -643,7 +666,8 @@ private: ...@@ -643,7 +666,8 @@ private:
uint fieldnr, const byte* field_ptr); uint fieldnr, const byte* field_ptr);
int set_ndb_key(NdbOperation*, Field *field, int set_ndb_key(NdbOperation*, Field *field,
uint fieldnr, const byte* field_ptr); uint fieldnr, const byte* field_ptr);
int set_ndb_value(NdbOperation*, Field *field, uint fieldnr, bool *set_blob_value= 0); int set_ndb_value(NdbOperation*, Field *field, uint fieldnr,
int row_offset= 0, bool *set_blob_value= 0);
int get_ndb_value(NdbOperation*, Field *field, uint fieldnr, byte*); int get_ndb_value(NdbOperation*, Field *field, uint fieldnr, byte*);
friend int g_get_ndb_blobs_value(NdbBlob *ndb_blob, void *arg); friend int g_get_ndb_blobs_value(NdbBlob *ndb_blob, void *arg);
int get_ndb_blobs_value(NdbBlob *last_ndb_blob); int get_ndb_blobs_value(NdbBlob *last_ndb_blob);
...@@ -688,6 +712,7 @@ private: ...@@ -688,6 +712,7 @@ private:
NdbScanOperation* op); NdbScanOperation* op);
friend int execute_commit(ha_ndbcluster*, NdbTransaction*); friend int execute_commit(ha_ndbcluster*, NdbTransaction*);
friend int execute_no_commit_ignore_no_key(ha_ndbcluster*, NdbTransaction*);
friend int execute_no_commit(ha_ndbcluster*, NdbTransaction*); friend int execute_no_commit(ha_ndbcluster*, NdbTransaction*);
friend int execute_no_commit_ie(ha_ndbcluster*, NdbTransaction*); friend int execute_no_commit_ie(ha_ndbcluster*, NdbTransaction*);
...@@ -704,7 +729,6 @@ private: ...@@ -704,7 +729,6 @@ private:
NDB_SHARE *m_share; NDB_SHARE *m_share;
NDB_INDEX_DATA m_index[MAX_KEY]; NDB_INDEX_DATA m_index[MAX_KEY];
// NdbRecAttr has no reference to blob // NdbRecAttr has no reference to blob
typedef union { const NdbRecAttr *rec; NdbBlob *blob; void *ptr; } NdbValue;
NdbValue m_value[NDB_MAX_ATTRIBUTES_IN_TABLE]; NdbValue m_value[NDB_MAX_ATTRIBUTES_IN_TABLE];
partition_info *m_part_info; partition_info *m_part_info;
byte *m_rec0; byte *m_rec0;
...@@ -715,6 +739,7 @@ private: ...@@ -715,6 +739,7 @@ private:
bool m_ignore_dup_key; bool m_ignore_dup_key;
bool m_primary_key_update; bool m_primary_key_update;
bool m_write_op; bool m_write_op;
bool m_ignore_no_key;
ha_rows m_rows_to_insert; ha_rows m_rows_to_insert;
ha_rows m_rows_inserted; ha_rows m_rows_inserted;
ha_rows m_bulk_insert_rows; ha_rows m_bulk_insert_rows;
...@@ -760,3 +785,4 @@ int ndbcluster_drop_database(const char* path); ...@@ -760,3 +785,4 @@ int ndbcluster_drop_database(const char* path);
void ndbcluster_print_error(int error, const NdbOperation *error_op); void ndbcluster_print_error(int error, const NdbOperation *error_op);
int ndbcluster_show_status(THD*); int ndbcluster_show_status(THD*);
...@@ -1224,6 +1224,9 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, ...@@ -1224,6 +1224,9 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open,
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
extern pthread_mutex_t LOCK_des_key_file; extern pthread_mutex_t LOCK_des_key_file;
#endif #endif
extern pthread_mutex_t LOCK_server_started;
extern pthread_cond_t COND_server_started;
extern int mysqld_server_started;
extern rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; extern rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager; extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager;
extern pthread_attr_t connection_attrib; extern pthread_attr_t connection_attrib;
......
...@@ -501,6 +501,10 @@ rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; ...@@ -501,6 +501,10 @@ rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
pthread_cond_t COND_refresh,COND_thread_count; pthread_cond_t COND_refresh,COND_thread_count;
pthread_t signal_thread; pthread_t signal_thread;
pthread_attr_t connection_attrib; pthread_attr_t connection_attrib;
pthread_mutex_t LOCK_server_started;
pthread_cond_t COND_server_started;
int mysqld_server_started= 0;
/* replication parameters, if master_host is not NULL, we are a slave */ /* replication parameters, if master_host is not NULL, we are a slave */
uint master_port= MYSQL_PORT, master_connect_retry = 60; uint master_port= MYSQL_PORT, master_connect_retry = 60;
...@@ -2765,6 +2769,8 @@ static int init_thread_environment() ...@@ -2765,6 +2769,8 @@ static int init_thread_environment()
(void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST); (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
(void) pthread_cond_init(&COND_rpl_status, NULL); (void) pthread_cond_init(&COND_rpl_status, NULL);
#endif #endif
(void) pthread_mutex_init(&LOCK_server_started, MY_MUTEX_INIT_FAST);
(void) pthread_cond_init(&COND_server_started,NULL);
sp_cache_init(); sp_cache_init();
/* Parameter for threads created for connections */ /* Parameter for threads created for connections */
(void) pthread_attr_init(&connection_attrib); (void) pthread_attr_init(&connection_attrib);
...@@ -3450,6 +3456,10 @@ we force server id to 2, but this MySQL server will not act as a slave."); ...@@ -3450,6 +3456,10 @@ we force server id to 2, but this MySQL server will not act as a slave.");
mysqld_port, mysqld_port,
MYSQL_COMPILATION_COMMENT); MYSQL_COMPILATION_COMMENT);
// Signal threads waiting for server to be started
mysqld_server_started= 1;
pthread_cond_signal(&COND_server_started);
#if defined(__NT__) || defined(HAVE_SMEM) #if defined(__NT__) || defined(HAVE_SMEM)
handle_connections_methods(); handle_connections_methods();
#else #else
...@@ -3497,6 +3507,7 @@ we force server id to 2, but this MySQL server will not act as a slave."); ...@@ -3497,6 +3507,7 @@ we force server id to 2, but this MySQL server will not act as a slave.");
CloseHandle(hEventShutdown); CloseHandle(hEventShutdown);
} }
#endif #endif
clean_up(1);
wait_for_signal_thread_to_end(); wait_for_signal_thread_to_end();
clean_up_mutexes(); clean_up_mutexes();
my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0);
......
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