Commit 70b344f9 authored by gluh@mysql.com's avatar gluh@mysql.com

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

into mysql.com:/home/gluh/MySQL/Bugs/5.0.17602
parents 48580321 f641a919
......@@ -334,3 +334,25 @@ lock table mysql.user write;
revoke all on *.* from 'mysqltest_1'@'localhost';
unlock tables;
drop user 'mysqltest_1'@'localhost';
create database TESTDB;
create table t2(a int);
create temporary table t1 as select * from mysql.user;
delete from mysql.user where host='localhost';
INSERT INTO mysql.user VALUES
('%','mysqltest_1',password('password'),'N','N','N','N','N','N',
'N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N',
'','','','',0,0,0,0);
INSERT INTO mysql.db VALUES
('%','TESTDB','mysqltest_1','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','N','Y','Y','Y','
Y','N');
Warnings:
Warning 1265 Data truncated for column 'Alter_routine_priv' at row 1
FLUSH PRIVILEGES;
create database TEStdb;
ERROR 42000: Access denied for user 'mysqltest_1'@'%' to database 'TEStdb'
delete from mysql.user;
delete from mysql.db where host='%' and user='mysqltest_1' and db='TESTDB';
insert into mysql.user select * from t1;
drop table t1, t2;
drop database TESTDB;
flush privileges;
drop table if exists t1, t2;
== Connected to server1 ==
set GLOBAL query_cache_type=on;
set GLOBAL query_cache_size=1355776;
set GLOBAL ndb_cache_check_time=1;
reset query cache;
flush status;
== Connected to server2 ==
set GLOBAL query_cache_type=on;
set GLOBAL query_cache_size=1355776;
set GLOBAL ndb_cache_check_time=1;
reset query cache;
flush status;
== Connected to server1 ==
create table t1 (a int) engine=ndbcluster;
create table t2 (a int) engine=ndbcluster;
insert into t1 value (2);
......@@ -16,18 +19,22 @@ insert into t2 value (3);
select * from t1;
a
2
select a != 3 from t1;
a != 3
1
select * from t2;
a
3
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
Qcache_queries_in_cache 3
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 2
Qcache_inserts 3
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
== Connected to server2 ==
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
......@@ -50,24 +57,13 @@ show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
update t1 set a=3 where a=2;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 2
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
== Connected to server1 ==
select * from t1;
a
3
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 3
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 4
drop table t1, t2;
set GLOBAL query_cache_size=0;
set GLOBAL ndb_cache_check_time=0;
......
......@@ -429,3 +429,38 @@ disconnect con2root;
disconnect con3root;
# End of 4.1 tests
#
# Bug#17279 user with no global privs and with create
# priv in db can create databases
#
create database TESTDB;
create table t2(a int);
create temporary table t1 as select * from mysql.user;
delete from mysql.user where host='localhost';
INSERT INTO mysql.user VALUES
('%','mysqltest_1',password('password'),'N','N','N','N','N','N',
'N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N',
'','','','',0,0,0,0);
INSERT INTO mysql.db VALUES
('%','TESTDB','mysqltest_1','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','N','Y','Y','Y','
Y','N');
FLUSH PRIVILEGES;
connect (con1,localhost,mysqltest_1,password,TESTDB);
# The user mysqltest_1 should only be allowed access to
# database TESTDB, not TEStdb
--error 1044
create database TEStdb;
# Clean-up
connection default;
delete from mysql.user;
delete from mysql.db where host='%' and user='mysqltest_1' and db='TESTDB';
insert into mysql.user select * from t1;
drop table t1, t2;
drop database TESTDB;
flush privileges;
......@@ -10,6 +10,7 @@ drop table if exists t1, t2;
# Turn on and reset query cache on server1
connection server1;
echo == Connected to server1 ==;
set GLOBAL query_cache_type=on;
set GLOBAL query_cache_size=1355776;
set GLOBAL ndb_cache_check_time=1;
......@@ -18,6 +19,7 @@ flush status;
# Turn on and reset query cache on server2
connection server2;
echo == Connected to server2 ==;
set GLOBAL query_cache_type=on;
set GLOBAL query_cache_size=1355776;
set GLOBAL ndb_cache_check_time=1;
......@@ -27,11 +29,14 @@ flush status;
# Create test tables in NDB and load them into cache
# on server1
connection server1;
echo == Connected to server1 ==;
create table t1 (a int) engine=ndbcluster;
create table t2 (a int) engine=ndbcluster;
insert into t1 value (2);
insert into t2 value (3);
select * from t1;
# Run the check query once to load it into qc on server1
select a != 3 from t1;
select * from t2;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
......@@ -40,6 +45,7 @@ show status like "Qcache_hits";
# Connect server2, load table in to cache, then update the table
connection server2;
echo == Connected to server2 ==;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
......@@ -49,12 +55,10 @@ show status like "Qcache_inserts";
show status like "Qcache_hits";
update t1 set a=3 where a=2;
# Connect to server1 and check that cache is invalidated
# Connect to server1 and check that cache is invalidated
# and correct data is returned
connection server1;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
echo == Connected to server1 ==;
# Loop and wait for max 10 seconds until query cache thread
# has invalidated the cache and the column a in t1 is equal to 3
......@@ -75,8 +79,6 @@ select * from t1;
# There should now be three queries in the cache
show status like "Qcache_queries_in_cache";
# And inserts should be four
show status like "Qcache_inserts";
drop table t1, t2;
......
......@@ -6014,7 +6014,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
ndb_util_thread= pthread_self();
thd->thread_stack= (char*)&thd; /* remember where our stack is */
if (thd->store_globals() && (ndb->init() != -1))
if (thd->store_globals() || (ndb->init() != 0))
{
thd->cleanup();
delete thd;
......
......@@ -1116,6 +1116,13 @@ public:
enum Sumfunctype sum_func () const {return GROUP_CONCAT_FUNC;}
const char *func_name() const { return "group_concat"; }
virtual Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const
{
if (max_length/collation.collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB)
return FIELD_TYPE_BLOB;
else
return MYSQL_TYPE_VARCHAR;
}
void clear();
bool add();
void reset_field() { DBUG_ASSERT(0); } // not used
......
......@@ -208,23 +208,40 @@ my_bool net_realloc(NET *net, ulong length)
RETURN VALUES
0 No data to read
1 Data or EOF to read
-1 Don't know if data is ready or not
*/
static my_bool net_data_is_ready(my_socket sd)
static int net_data_is_ready(my_socket sd)
{
#ifdef HAVE_POLL
struct pollfd ufds;
int res;
ufds.fd= sd;
ufds.events= POLLIN | POLLPRI;
if (!(res= poll(&ufds, 1, 0)))
return 0;
if (res < 0 || !(ufds.revents & (POLLIN | POLLPRI)))
return 0;
return 1;
#else
fd_set sfds;
struct timeval tv;
int res;
if (sd >= FD_SETSIZE)
return -1;
FD_ZERO(&sfds);
FD_SET(sd, &sfds);
tv.tv_sec= tv.tv_usec= 0;
if ((res= select(sd+1, &sfds, NULL, NULL, &tv)) < 0)
return FALSE;
return 0;
else
return test(res ? FD_ISSET(sd, &sfds) : 0);
#endif
}
......@@ -251,10 +268,10 @@ static my_bool net_data_is_ready(my_socket sd)
void net_clear(NET *net)
{
int count;
int count, ready;
DBUG_ENTER("net_clear");
#if !defined(EMBEDDED_LIBRARY)
while(net_data_is_ready(net->vio->sd))
while((ready= net_data_is_ready(net->vio->sd)) != 0)
{
/* The socket is ready */
if ((count= vio_read(net->vio, (char*) (net->buff),
......@@ -269,6 +286,10 @@ void net_clear(NET *net)
}
else
{
/* No data to read and 'net_data_is_ready' returned "don't know" */
if (ready == -1)
break;
DBUG_PRINT("info",("socket ready but only EOF to read - disconnected"));
net->error= 2;
break;
......
......@@ -148,7 +148,9 @@ my_bool acl_init(bool dont_read_acl_tables)
acl_cache= new hash_filo(ACL_CACHE_SIZE, 0, 0,
(hash_get_key) acl_entry_get_key,
(hash_free_key) free, system_charset_info);
(hash_free_key) free,
/* Use the case sensitive "binary" charset */
&my_charset_bin);
if (dont_read_acl_tables)
{
DBUG_RETURN(0); /* purecov: tested */
......
......@@ -14841,6 +14841,40 @@ static void test_bug15613()
}
/*
Bug#14169: type of group_concat() result changed to blob if tmp_table was used
*/
static void test_bug14169()
{
MYSQL_STMT *stmt;
const char *stmt_text;
MYSQL_RES *res;
MYSQL_FIELD *field;
int rc;
myheader("test_bug14169");
rc= mysql_query(mysql, "drop table if exists t1");
myquery(rc);
rc= mysql_query(mysql, "set session group_concat_max_len=1024");
myquery(rc);
rc= mysql_query(mysql, "create table t1 (f1 int unsigned, f2 varchar(255))");
myquery(rc);
rc= mysql_query(mysql, "insert into t1 values (1,repeat('a',255)),"
"(2,repeat('b',255))");
myquery(rc);
stmt= mysql_stmt_init(mysql);
stmt_text= "select f2,group_concat(f1) from t1 group by f2";
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
myquery(rc);
res= mysql_stmt_result_metadata(stmt);
field= mysql_fetch_fields(res);
if (!opt_silent)
printf("GROUP_CONCAT() result type %i", field[1].type);
DIE_UNLESS(field[1].type == MYSQL_TYPE_BLOB);
rc= mysql_query(mysql, "drop table t1");
myquery(rc);
}/*
Read and parse arguments and MySQL options from my.cnf
*/
......@@ -15105,6 +15139,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug16143", test_bug16143 },
{ "test_bug16144", test_bug16144 },
{ "test_bug15613", test_bug15613 },
{ "test_bug14169", test_bug14169 },
{ 0, 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