Commit 77a59a1f authored by mskold/marty@linux.site's avatar mskold/marty@linux.site

Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.0

into  mysql.com:/windows/Linux_space/MySQL/mysql-5.1
parents 5d96bced ae0d7e87
...@@ -17,6 +17,14 @@ pk1 b c ...@@ -17,6 +17,14 @@ 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 '*UNKNOWN*' ERROR 23000: Duplicate entry '' for key '*UNKNOWN*'
select * from t1 order by pk1; select * from t1 order by pk1;
......
...@@ -23,6 +23,10 @@ UPDATE t1 set b = c; ...@@ -23,6 +23,10 @@ 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;
select * from t1 order by pk1; select * from t1 order by pk1;
......
...@@ -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);
...@@ -76,43 +72,65 @@ readln_socket(NDB_SOCKET_TYPE socket, int timeout_millis, ...@@ -76,43 +72,65 @@ 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;
if(t < 1) do
{ {
fcntl(socket, F_SETFL, sock_flags); int t;
return -1; while((t = recv(socket, ptr, len, MSG_PEEK)) == -1 && errno == EINTR);
}
if(t < 1)
{
return -1;
}
for(int i=0; i< t;i++)
{ for(int i = 0; i<t; i++)
if(buf[i] == '\n'){ {
int r= recv(socket, buf, i+1, 0); if(ptr[i] == '\n')
buf[i+1]= 0; {
if(r < 1) { /**
fcntl(socket, F_SETFL, sock_flags); * Now consume
return -1; */
for (len = 1 + i; len; )
{
while ((t = recv(socket, ptr, len, 0)) == -1 && errno == EINTR);
if (t < 1)
return -1;
ptr += t;
len -= t;
}
ptr[0]= 0;
return ptr - buf;
} }
}
if(i > 0 && buf[i-1] == '\r'){
buf[i-1] = '\n'; for (int tmp = t; tmp; )
buf[i]= '\0'; {
while ((t = recv(socket, ptr, tmp, 0)) == -1 && errno == EINTR);
if (t < 1)
{
return -1;
} }
ptr += t;
fcntl(socket, F_SETFL, sock_flags); len -= t;
return r; 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"
......
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