Commit a172df24 authored by mskold/marty@mysql.com/linux.site's avatar mskold/marty@mysql.com/linux.site

Merge mskold@bk-internal.mysql.com:/home/bk/mysql-5.0

into  mysql.com:/windows/Linux_space/MySQL/mysql-5.0-ndb
parents 4d418e6c 638c294b
...@@ -140,7 +140,40 @@ b int unsigned not null, ...@@ -140,7 +140,40 @@ b int unsigned not null,
c int unsigned, c int unsigned,
UNIQUE USING HASH (b, c) UNIQUE USING HASH (b, c)
) engine=ndbcluster; ) engine=ndbcluster;
ERROR 42000: Column 'c' is used with UNIQUE or INDEX but is not defined as NOT NULL Warnings:
Warning 1121 Ndb does not support unique index on NULL valued attributes, index access with NULL value will become full table scan
insert t2 values(1,1,NULL),(2,2,2),(3,3,NULL),(4,4,4),(5,5,NULL),(6,6,6),(7,7,NULL),(8,3,NULL),(9,3,NULL);
select * from t2 where c IS NULL order by a;
a b c
1 1 NULL
3 3 NULL
5 5 NULL
7 7 NULL
8 3 NULL
9 3 NULL
select * from t2 where b = 3 AND c IS NULL order by a;
a b c
3 3 NULL
8 3 NULL
9 3 NULL
select * from t2 where (b = 3 OR b = 5) AND c IS NULL order by a;
a b c
3 3 NULL
5 5 NULL
8 3 NULL
9 3 NULL
set @old_ecpd = @@session.engine_condition_pushdown;
set engine_condition_pushdown = true;
explain select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range PRIMARY,b PRIMARY 4 NULL 1 Using where with pushed condition
select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a;
a b c
3 3 NULL
5 5 NULL
8 3 NULL
set engine_condition_pushdown = @old_ecpd;
drop table t2;
CREATE TABLE t3 ( CREATE TABLE t3 (
a int unsigned NOT NULL, a int unsigned NOT NULL,
b int unsigned not null, b int unsigned not null,
......
...@@ -17,8 +17,17 @@ pk1 b c ...@@ -17,8 +17,17 @@ pk1 b c
0 0 0 0 0 0
2 2 2 2 2 2
4 1 1 4 1 1
UPDATE t1 set pk1 = 4 where pk1 = 2;
ERROR 23000: Duplicate entry '4' for key 1
UPDATE IGNORE t1 set pk1 = 4 where pk1 = 2;
select * from t1 order by pk1;
pk1 b c
0 0 0
2 2 2
4 1 1
UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4; UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4;
ERROR 23000: Duplicate entry '' for key 0 ERROR 23000: Duplicate entry '' for key 0
UPDATE IGNORE t1 set pk1 = 1, c = 2 where pk1 = 4;
select * from t1 order by pk1; select * from t1 order by pk1;
pk1 b c pk1 b c
0 0 0 0 0 0
......
...@@ -85,7 +85,6 @@ select * from t2 order by a; ...@@ -85,7 +85,6 @@ select * from t2 order by a;
drop table t2; drop table t2;
-- error 1121
CREATE TABLE t2 ( CREATE TABLE t2 (
a int unsigned NOT NULL PRIMARY KEY, a int unsigned NOT NULL PRIMARY KEY,
b int unsigned not null, b int unsigned not null,
...@@ -93,6 +92,20 @@ CREATE TABLE t2 ( ...@@ -93,6 +92,20 @@ CREATE TABLE t2 (
UNIQUE USING HASH (b, c) UNIQUE USING HASH (b, c)
) engine=ndbcluster; ) engine=ndbcluster;
insert t2 values(1,1,NULL),(2,2,2),(3,3,NULL),(4,4,4),(5,5,NULL),(6,6,6),(7,7,NULL),(8,3,NULL),(9,3,NULL);
select * from t2 where c IS NULL order by a;
select * from t2 where b = 3 AND c IS NULL order by a;
select * from t2 where (b = 3 OR b = 5) AND c IS NULL order by a;
set @old_ecpd = @@session.engine_condition_pushdown;
set engine_condition_pushdown = true;
explain select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a;
select * from t2 where (b = 3 OR b = 5) AND c IS NULL AND a < 9 order by a;
set engine_condition_pushdown = @old_ecpd;
drop table t2;
# #
# Show use of PRIMARY KEY USING HASH indexes # Show use of PRIMARY KEY USING HASH indexes
# #
......
...@@ -23,8 +23,13 @@ UPDATE t1 set b = c; ...@@ -23,8 +23,13 @@ UPDATE t1 set b = c;
select * from t1 order by pk1; select * from t1 order by pk1;
UPDATE t1 set pk1 = 4 where pk1 = 1; UPDATE t1 set pk1 = 4 where pk1 = 1;
select * from t1 order by pk1; select * from t1 order by pk1;
--error 1062
UPDATE t1 set pk1 = 4 where pk1 = 2;
UPDATE IGNORE t1 set pk1 = 4 where pk1 = 2;
select * from t1 order by pk1;
-- error 1062 -- error 1062
UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4; UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4;
UPDATE IGNORE t1 set pk1 = 1, c = 2 where pk1 = 4;
select * from t1 order by pk1; select * from t1 order by pk1;
UPDATE t1 set pk1 = pk1 + 10; UPDATE t1 set pk1 = pk1 + 10;
select * from t1 order by pk1; select * from t1 order by pk1;
......
...@@ -65,6 +65,5 @@ SocketInputStream::gets(char * buf, int bufLen) { ...@@ -65,6 +65,5 @@ SocketInputStream::gets(char * buf, int bufLen) {
if(res == -1) if(res == -1)
return 0; return 0;
return buf; return buf;
} }
...@@ -53,10 +53,6 @@ readln_socket(NDB_SOCKET_TYPE socket, int timeout_millis, ...@@ -53,10 +53,6 @@ readln_socket(NDB_SOCKET_TYPE socket, int timeout_millis,
if(buflen <= 1) if(buflen <= 1)
return 0; return 0;
int sock_flags= fcntl(socket, F_GETFL);
if(fcntl(socket, F_SETFL, sock_flags | O_NONBLOCK) == -1)
return -1;
fd_set readset; fd_set readset;
FD_ZERO(&readset); FD_ZERO(&readset);
FD_SET(socket, &readset); FD_SET(socket, &readset);
...@@ -71,43 +67,70 @@ readln_socket(NDB_SOCKET_TYPE socket, int timeout_millis, ...@@ -71,43 +67,70 @@ readln_socket(NDB_SOCKET_TYPE socket, int timeout_millis,
} }
if(selectRes == -1){ if(selectRes == -1){
fcntl(socket, F_SETFL, sock_flags);
return -1; return -1;
} }
const int t = recv(socket, buf, buflen, MSG_PEEK); char* ptr = buf;
int len = buflen;
do
{
int t;
while((t = recv(socket, ptr, len, MSG_PEEK)) == -1 && errno == EINTR);
if(t < 1) if(t < 1)
{ {
fcntl(socket, F_SETFL, sock_flags);
return -1; return -1;
} }
for(int i=0; i< t;i++)
for(int i = 0; i<t; i++)
{
if(ptr[i] == '\n')
{
/**
* Now consume
*/
for (len = 1 + i; len; )
{ {
if(buf[i] == '\n'){ while ((t = recv(socket, ptr, len, 0)) == -1 && errno == EINTR);
int r= recv(socket, buf, i+1, 0); if (t < 1)
buf[i+1]= 0;
if(r < 1) {
fcntl(socket, F_SETFL, sock_flags);
return -1; return -1;
ptr += t;
len -= t;
} }
if (i > 0 && buf[i-1] == '\r')
if(i > 0 && buf[i-1] == '\r'){ {
buf[i-1] = '\n'; buf[i-1] = '\n';
buf[i]= '\0'; ptr--;
}
ptr[0]= 0;
return ptr - buf;
}
} }
fcntl(socket, F_SETFL, sock_flags); for (int tmp = t; tmp; )
return r; {
while ((t = recv(socket, ptr, tmp, 0)) == -1 && errno == EINTR);
if (t < 1)
{
return -1;
} }
ptr += t;
len -= t;
tmp -= t;
} }
int r= recv(socket, buf, t, 0); FD_ZERO(&readset);
if(r>=0) FD_SET(socket, &readset);
buf[r] = 0; timeout.tv_sec = (timeout_millis / 1000);
fcntl(socket, F_SETFL, sock_flags); timeout.tv_usec = (timeout_millis % 1000) * 1000;
return r; const int selectRes = select(socket + 1, &readset, 0, 0, &timeout);
if(selectRes != 1){
return -1;
}
} while (len > 0);
return -1;
} }
extern "C" extern "C"
......
...@@ -697,6 +697,7 @@ Cmvmi::execTEST_ORD(Signal * signal){ ...@@ -697,6 +697,7 @@ Cmvmi::execTEST_ORD(Signal * signal){
// Do nothing // Do nothing
break; break;
} }
globalSignalLoggers.flushSignalLog();
} }
#endif #endif
......
...@@ -1893,7 +1893,7 @@ runDictOps(NDBT_Context* ctx, NDBT_Step* step) ...@@ -1893,7 +1893,7 @@ runDictOps(NDBT_Context* ctx, NDBT_Step* step)
// create indexes // create indexes
const char** indlist = NDBT_Tables::getIndexes(tabName); const char** indlist = NDBT_Tables::getIndexes(tabName);
uint indnum = 0; uint indnum = 0;
while (*indlist != 0) { while (indlist != 0 && *indlist != 0) {
uint count = 0; uint count = 0;
try_create_index: try_create_index:
count++; count++;
......
...@@ -510,7 +510,7 @@ args: -n TemporaryTables T1 T6 T7 T8 ...@@ -510,7 +510,7 @@ args: -n TemporaryTables T1 T6 T7 T8
max-time: 1500 max-time: 1500
cmd: testDict cmd: testDict
args: -n Restart_NR2 T1 args: -n Restart_NR2 T1 I3
# #
# TEST NDBAPI # TEST NDBAPI
......
...@@ -37,7 +37,6 @@ static int g_verbose = 0; ...@@ -37,7 +37,6 @@ static int g_verbose = 0;
static int try_reconnect = 3; static int try_reconnect = 3;
static int g_nodes, g_connections, g_section; static int g_nodes, g_connections, g_section;
static const char * g_connectstring = 0;
static const char * g_query = 0; static const char * g_query = 0;
static int g_nodeid = 0; static int g_nodeid = 0;
...@@ -486,7 +485,7 @@ fetch_configuration() ...@@ -486,7 +485,7 @@ fetch_configuration()
ndb_mgm_set_error_stream(mgm, stderr); ndb_mgm_set_error_stream(mgm, stderr);
if (ndb_mgm_set_connectstring(mgm, g_connectstring)) if (ndb_mgm_set_connectstring(mgm, opt_connect_str))
{ {
fprintf(stderr, "* %5d: %s\n", fprintf(stderr, "* %5d: %s\n",
ndb_mgm_get_latest_error(mgm), ndb_mgm_get_latest_error(mgm),
......
This diff is collapsed.
...@@ -56,6 +56,7 @@ typedef struct ndb_index_data { ...@@ -56,6 +56,7 @@ typedef struct ndb_index_data {
void *index; void *index;
void *unique_index; void *unique_index;
unsigned char *unique_index_attrid_map; unsigned char *unique_index_attrid_map;
bool null_in_unique_index;
} NDB_INDEX_DATA; } NDB_INDEX_DATA;
typedef struct st_ndbcluster_share { typedef struct st_ndbcluster_share {
...@@ -546,7 +547,9 @@ class ha_ndbcluster: public handler ...@@ -546,7 +547,9 @@ class ha_ndbcluster: public handler
KEY_MULTI_RANGE*ranges, uint range_count, KEY_MULTI_RANGE*ranges, uint range_count,
bool sorted, HANDLER_BUFFER *buffer); bool sorted, HANDLER_BUFFER *buffer);
int read_multi_range_next(KEY_MULTI_RANGE **found_range_p); int read_multi_range_next(KEY_MULTI_RANGE **found_range_p);
bool null_value_index_search(KEY_MULTI_RANGE *ranges,
KEY_MULTI_RANGE *end_range,
HANDLER_BUFFER *buffer);
bool get_error_message(int error, String *buf); bool get_error_message(int error, String *buf);
int info(uint); int info(uint);
int extra(enum ha_extra_function operation); int extra(enum ha_extra_function operation);
...@@ -649,7 +652,8 @@ static void set_tabname(const char *pathname, char *tabname); ...@@ -649,7 +652,8 @@ static void set_tabname(const char *pathname, char *tabname);
void release_metadata(); void release_metadata();
NDB_INDEX_TYPE get_index_type(uint idx_no) const; NDB_INDEX_TYPE get_index_type(uint idx_no) const;
NDB_INDEX_TYPE get_index_type_from_table(uint index_no) const; NDB_INDEX_TYPE get_index_type_from_table(uint index_no) const;
int check_index_fields_not_null(uint index_no); bool has_null_in_unique_index(uint idx_no) const;
bool check_index_fields_not_null(uint index_no);
int pk_read(const byte *key, uint key_len, byte *buf); int pk_read(const byte *key, uint key_len, byte *buf);
int complemented_pk_read(const byte *old_data, byte *new_data); int complemented_pk_read(const byte *old_data, byte *new_data);
...@@ -663,6 +667,11 @@ static void set_tabname(const char *pathname, char *tabname); ...@@ -663,6 +667,11 @@ static void set_tabname(const char *pathname, char *tabname);
int ordered_index_scan(const key_range *start_key, int ordered_index_scan(const key_range *start_key,
const key_range *end_key, const key_range *end_key,
bool sorted, bool descending, byte* buf); bool sorted, bool descending, byte* buf);
int unique_index_scan(const KEY* key_info,
const byte *key,
uint key_len,
byte *buf);
int full_table_scan(byte * buf); int full_table_scan(byte * buf);
int fetch_next(NdbScanOperation* op); int fetch_next(NdbScanOperation* op);
int next_result(byte *buf); int next_result(byte *buf);
...@@ -725,6 +734,13 @@ bool uses_blob_value(bool all_fields); ...@@ -725,6 +734,13 @@ bool uses_blob_value(bool all_fields);
int build_scan_filter(Ndb_cond* &cond, NdbScanFilter* filter); int build_scan_filter(Ndb_cond* &cond, NdbScanFilter* filter);
int generate_scan_filter(Ndb_cond_stack* cond_stack, int generate_scan_filter(Ndb_cond_stack* cond_stack,
NdbScanOperation* op); NdbScanOperation* op);
int generate_scan_filter_from_cond(Ndb_cond_stack* cond_stack,
NdbScanFilter& filter);
int generate_scan_filter_from_key(NdbScanOperation* op,
const KEY* key_info,
const byte *key,
uint key_len,
byte *buf);
friend int execute_commit(ha_ndbcluster*, NdbTransaction*); friend int execute_commit(ha_ndbcluster*, NdbTransaction*);
friend int execute_no_commit(ha_ndbcluster*, NdbTransaction*, bool); friend int execute_no_commit(ha_ndbcluster*, NdbTransaction*, bool);
......
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