Loading mysql-test/mysql-test-run.sh +8 −7 Original line number Diff line number Diff line Loading @@ -347,7 +347,7 @@ fi [ -d $MYSQL_TEST_DIR/var/tmp ] || mkdir $MYSQL_TEST_DIR/var/tmp [ -d $MYSQL_TEST_DIR/var/run ] || mkdir $MYSQL_TEST_DIR/var/run [ -z "$COLUMNS" ] && COLUMNS=80 if test ${COLUMNS:-0} -lt 80 ; then COLUMNS=80 ; fi E=`$EXPR $COLUMNS - 8` DASH72=`$ECHO '------------------------------------------------------------------------'|$CUT -c 1-$E` Loading Loading @@ -605,6 +605,7 @@ start_manager() { if [ $USE_MANAGER = 0 ] ; then echo "Manager disabled, skipping manager start." $RM -f $MYSQL_MANAGER_LOG return fi $ECHO "Starting MySQL Manager" Loading Loading @@ -675,7 +676,7 @@ manager_term() shift if [ $USE_MANAGER = 0 ] ; then $MYSQLADMIN --no-defaults -uroot --socket=$MYSQL_TMP_DIR/$ident.sock -O \ connect_timeout=5 -O shutdown_timeout=20 shutdown >/dev/null 2>&1 connect_timeout=5 -O shutdown_timeout=20 shutdown >> $MYSQL_MANAGER_LOG 2>&1 return fi $MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT --user=$MYSQL_MANAGER_USER \ Loading mysql-test/r/query_cache.result +32 −2 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ flush query cache; flush query cache; reset query cache; flush status; drop table if exists t1,t2,t3,t11,t21; drop table if exists t1,t2,t3,t11,t21, mysqltest.t1; create table t1 (a int not null); insert into t1 values (1),(2),(3); select * from t1; Loading Loading @@ -346,7 +346,7 @@ show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 drop table t1,t2; create database mysqltest; create database if not exists mysqltest; create table mysqltest.t1 (i int not null auto_increment, a int, primary key (i)); insert into mysqltest.t1 (a) values (1); select * from mysqltest.t1 where i is null; Loading Loading @@ -375,6 +375,36 @@ set CHARACTER SET DEFAULT; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 2 show status like "Qcache_hits"; Variable_name Value Qcache_hits 4 drop table t1; create database if not exists mysqltest; create table mysqltest.t1 (i int not null); create table t1 (i int not null); insert into mysqltest.t1 (i) values (1); insert into t1 (i) values (2); select * from t1; i 2 use mysqltest; select * from t1; i 1 select * from t1; i 1 use test; select * from t1; i 2 show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 2 show status like "Qcache_hits"; Variable_name Value Qcache_hits 6 drop database mysqltest; drop table t1; flush query cache; reset query cache; Loading mysql-test/t/query_cache.test +24 −2 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ flush query cache; # This crashed in some versions flush query cache; # This crashed in some versions reset query cache; flush status; drop table if exists t1,t2,t3,t11,t21; drop table if exists t1,t2,t3,t11,t21, mysqltest.t1; # # First simple test Loading Loading @@ -235,7 +235,7 @@ drop table t1,t2; # # noncachable ODBC work around (and prepare cache for drop database) # create database mysqltest; create database if not exists mysqltest; create table mysqltest.t1 (i int not null auto_increment, a int, primary key (i)); insert into mysqltest.t1 (a) values (1); select * from mysqltest.t1 where i is null; Loading @@ -258,6 +258,7 @@ set CHARACTER SET cp1251_koi8; select * from t1; set CHARACTER SET DEFAULT; show status like "Qcache_queries_in_cache"; show status like "Qcache_hits"; drop table t1; # The following tests can't be done as the values differen on 32 and 64 bit Loading @@ -265,6 +266,27 @@ drop table t1; #show variables like "query_cache_size"; #show status like "Qcache_free_memory"; # # same tables in different db # create database if not exists mysqltest; create table mysqltest.t1 (i int not null); create table t1 (i int not null); insert into mysqltest.t1 (i) values (1); insert into t1 (i) values (2); select * from t1; use mysqltest; select * from t1; select * from t1; use test; select * from t1; show status like "Qcache_queries_in_cache"; show status like "Qcache_hits"; drop database mysqltest; drop table t1; # # Test insert delayed # Loading sql-bench/test-wisconsin.sh +1 −1 Original line number Diff line number Diff line Loading @@ -242,7 +242,7 @@ sub init_data { @onek= $server->create("onek", ["unique1 int(4) NOT NULL", ["unique1 int(5) NOT NULL", "unique2 int(4) NOT NULL", "two int(4)", "four int(4)", Loading sql/sql_cache.cc +19 −20 Original line number Diff line number Diff line Loading @@ -743,7 +743,7 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used) /* Key is query + database + flag */ if (thd->db_length) { memcpy(thd->query+thd->query_length, thd->db, thd->db_length); memcpy(thd->query+thd->query_length+1, thd->db, thd->db_length); DBUG_PRINT("qcache", ("database : %s length %u", thd->db, thd->db_length)); } Loading @@ -761,7 +761,7 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used) flags|= (byte) thd->convert_set->number(); DBUG_ASSERT(thd->convert_set->number() < 128); } tot_length=thd->query_length+1+thd->db_length; tot_length=thd->query_length+thd->db_length+2; thd->query[tot_length-1] = (char) flags; /* Check if another thread is processing the same query? */ Loading Loading @@ -832,7 +832,6 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used) statistic_increment(refused, &structure_guard_mutex); end: thd->query[thd->query_length]= 0; // Restore end null DBUG_VOID_RETURN; } Loading Loading @@ -890,12 +889,10 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) goto err; } /* Test if the query is a SELECT */ while (*sql == ' ' || *sql == '\t') { sql++; query_length--; } /* Test if the query is a SELECT (pre-space is removed in dispatch_command) */ if (toupper(sql[0]) != 'S' || toupper(sql[1]) != 'E' || toupper(sql[2]) !='L') { Loading @@ -911,10 +908,10 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) } Query_cache_block *query_block; tot_length=query_length+thd->db_length+1; tot_length=query_length+thd->db_length+2; if (thd->db_length) { memcpy(sql+query_length, thd->db, thd->db_length); memcpy(sql+query_length+1, thd->db, thd->db_length); DBUG_PRINT("qcache", ("database: '%s' length %u", thd->db, thd->db_length)); } Loading @@ -936,9 +933,6 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) sql[tot_length-1] = (char) flags; query_block = (Query_cache_block *) hash_search(&queries, (byte*) sql, tot_length); sql[query_length] = '\0'; // Restore end null /* Quick abort on unlocked data */ if (query_block == 0 || query_block->query()->result() == 0 || Loading Loading @@ -2582,8 +2576,11 @@ my_bool Query_cache::move_by_type(byte **border, pthread_cond_init(&new_query->lock, NULL); pthread_mutex_init(&new_query->clients_guard,MY_MUTEX_INIT_FAST); /* If someone is writing to this block, inform the writer that the block has been moved. */ NET *net = new_block->query()->writer(); /* QQ: When could this happen ? */ if (net != 0) { net->query_cache_query= (gptr) new_block; Loading Loading @@ -2877,15 +2874,17 @@ void Query_cache::queries_dump() { uint len; char *str = (char*) query_cache_query_get_key((byte*) block, &len, 0); uint flags = (uint) (uchar) str[len-1]; DBUG_PRINT("qcache", ("%u (%u,%u) %.*s",len, len--; // Point at flags uint flags = (uint) (uchar) str[len]; str[len]=0; DBUG_PRINT("qcache", ("%u (%u,%u) '%s' '%s'", ((flags & QUERY_CACHE_CLIENT_LONG_FLAG_MASK)? 1:0), (flags & QUERY_CACHE_CHARSET_CONVERT_MASK), len-1, str)); (flags & QUERY_CACHE_CHARSET_CONVERT_MASK), len, str,strend(str)+1)); DBUG_PRINT("qcache", ("-b- 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx", (ulong) block, (ulong) block->next, (ulong) block->prev, (ulong)block->pnext, (ulong)block->pprev)); str[len]=(char) flags; for (TABLE_COUNTER_TYPE t = 0; t < block->n_tables; t++) { Query_cache_table *table = block->table(t)->parent; Loading Loading
mysql-test/mysql-test-run.sh +8 −7 Original line number Diff line number Diff line Loading @@ -347,7 +347,7 @@ fi [ -d $MYSQL_TEST_DIR/var/tmp ] || mkdir $MYSQL_TEST_DIR/var/tmp [ -d $MYSQL_TEST_DIR/var/run ] || mkdir $MYSQL_TEST_DIR/var/run [ -z "$COLUMNS" ] && COLUMNS=80 if test ${COLUMNS:-0} -lt 80 ; then COLUMNS=80 ; fi E=`$EXPR $COLUMNS - 8` DASH72=`$ECHO '------------------------------------------------------------------------'|$CUT -c 1-$E` Loading Loading @@ -605,6 +605,7 @@ start_manager() { if [ $USE_MANAGER = 0 ] ; then echo "Manager disabled, skipping manager start." $RM -f $MYSQL_MANAGER_LOG return fi $ECHO "Starting MySQL Manager" Loading Loading @@ -675,7 +676,7 @@ manager_term() shift if [ $USE_MANAGER = 0 ] ; then $MYSQLADMIN --no-defaults -uroot --socket=$MYSQL_TMP_DIR/$ident.sock -O \ connect_timeout=5 -O shutdown_timeout=20 shutdown >/dev/null 2>&1 connect_timeout=5 -O shutdown_timeout=20 shutdown >> $MYSQL_MANAGER_LOG 2>&1 return fi $MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT --user=$MYSQL_MANAGER_USER \ Loading
mysql-test/r/query_cache.result +32 −2 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ flush query cache; flush query cache; reset query cache; flush status; drop table if exists t1,t2,t3,t11,t21; drop table if exists t1,t2,t3,t11,t21, mysqltest.t1; create table t1 (a int not null); insert into t1 values (1),(2),(3); select * from t1; Loading Loading @@ -346,7 +346,7 @@ show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 drop table t1,t2; create database mysqltest; create database if not exists mysqltest; create table mysqltest.t1 (i int not null auto_increment, a int, primary key (i)); insert into mysqltest.t1 (a) values (1); select * from mysqltest.t1 where i is null; Loading Loading @@ -375,6 +375,36 @@ set CHARACTER SET DEFAULT; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 2 show status like "Qcache_hits"; Variable_name Value Qcache_hits 4 drop table t1; create database if not exists mysqltest; create table mysqltest.t1 (i int not null); create table t1 (i int not null); insert into mysqltest.t1 (i) values (1); insert into t1 (i) values (2); select * from t1; i 2 use mysqltest; select * from t1; i 1 select * from t1; i 1 use test; select * from t1; i 2 show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 2 show status like "Qcache_hits"; Variable_name Value Qcache_hits 6 drop database mysqltest; drop table t1; flush query cache; reset query cache; Loading
mysql-test/t/query_cache.test +24 −2 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ flush query cache; # This crashed in some versions flush query cache; # This crashed in some versions reset query cache; flush status; drop table if exists t1,t2,t3,t11,t21; drop table if exists t1,t2,t3,t11,t21, mysqltest.t1; # # First simple test Loading Loading @@ -235,7 +235,7 @@ drop table t1,t2; # # noncachable ODBC work around (and prepare cache for drop database) # create database mysqltest; create database if not exists mysqltest; create table mysqltest.t1 (i int not null auto_increment, a int, primary key (i)); insert into mysqltest.t1 (a) values (1); select * from mysqltest.t1 where i is null; Loading @@ -258,6 +258,7 @@ set CHARACTER SET cp1251_koi8; select * from t1; set CHARACTER SET DEFAULT; show status like "Qcache_queries_in_cache"; show status like "Qcache_hits"; drop table t1; # The following tests can't be done as the values differen on 32 and 64 bit Loading @@ -265,6 +266,27 @@ drop table t1; #show variables like "query_cache_size"; #show status like "Qcache_free_memory"; # # same tables in different db # create database if not exists mysqltest; create table mysqltest.t1 (i int not null); create table t1 (i int not null); insert into mysqltest.t1 (i) values (1); insert into t1 (i) values (2); select * from t1; use mysqltest; select * from t1; select * from t1; use test; select * from t1; show status like "Qcache_queries_in_cache"; show status like "Qcache_hits"; drop database mysqltest; drop table t1; # # Test insert delayed # Loading
sql-bench/test-wisconsin.sh +1 −1 Original line number Diff line number Diff line Loading @@ -242,7 +242,7 @@ sub init_data { @onek= $server->create("onek", ["unique1 int(4) NOT NULL", ["unique1 int(5) NOT NULL", "unique2 int(4) NOT NULL", "two int(4)", "four int(4)", Loading
sql/sql_cache.cc +19 −20 Original line number Diff line number Diff line Loading @@ -743,7 +743,7 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used) /* Key is query + database + flag */ if (thd->db_length) { memcpy(thd->query+thd->query_length, thd->db, thd->db_length); memcpy(thd->query+thd->query_length+1, thd->db, thd->db_length); DBUG_PRINT("qcache", ("database : %s length %u", thd->db, thd->db_length)); } Loading @@ -761,7 +761,7 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used) flags|= (byte) thd->convert_set->number(); DBUG_ASSERT(thd->convert_set->number() < 128); } tot_length=thd->query_length+1+thd->db_length; tot_length=thd->query_length+thd->db_length+2; thd->query[tot_length-1] = (char) flags; /* Check if another thread is processing the same query? */ Loading Loading @@ -832,7 +832,6 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used) statistic_increment(refused, &structure_guard_mutex); end: thd->query[thd->query_length]= 0; // Restore end null DBUG_VOID_RETURN; } Loading Loading @@ -890,12 +889,10 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) goto err; } /* Test if the query is a SELECT */ while (*sql == ' ' || *sql == '\t') { sql++; query_length--; } /* Test if the query is a SELECT (pre-space is removed in dispatch_command) */ if (toupper(sql[0]) != 'S' || toupper(sql[1]) != 'E' || toupper(sql[2]) !='L') { Loading @@ -911,10 +908,10 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) } Query_cache_block *query_block; tot_length=query_length+thd->db_length+1; tot_length=query_length+thd->db_length+2; if (thd->db_length) { memcpy(sql+query_length, thd->db, thd->db_length); memcpy(sql+query_length+1, thd->db, thd->db_length); DBUG_PRINT("qcache", ("database: '%s' length %u", thd->db, thd->db_length)); } Loading @@ -936,9 +933,6 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) sql[tot_length-1] = (char) flags; query_block = (Query_cache_block *) hash_search(&queries, (byte*) sql, tot_length); sql[query_length] = '\0'; // Restore end null /* Quick abort on unlocked data */ if (query_block == 0 || query_block->query()->result() == 0 || Loading Loading @@ -2582,8 +2576,11 @@ my_bool Query_cache::move_by_type(byte **border, pthread_cond_init(&new_query->lock, NULL); pthread_mutex_init(&new_query->clients_guard,MY_MUTEX_INIT_FAST); /* If someone is writing to this block, inform the writer that the block has been moved. */ NET *net = new_block->query()->writer(); /* QQ: When could this happen ? */ if (net != 0) { net->query_cache_query= (gptr) new_block; Loading Loading @@ -2877,15 +2874,17 @@ void Query_cache::queries_dump() { uint len; char *str = (char*) query_cache_query_get_key((byte*) block, &len, 0); uint flags = (uint) (uchar) str[len-1]; DBUG_PRINT("qcache", ("%u (%u,%u) %.*s",len, len--; // Point at flags uint flags = (uint) (uchar) str[len]; str[len]=0; DBUG_PRINT("qcache", ("%u (%u,%u) '%s' '%s'", ((flags & QUERY_CACHE_CLIENT_LONG_FLAG_MASK)? 1:0), (flags & QUERY_CACHE_CHARSET_CONVERT_MASK), len-1, str)); (flags & QUERY_CACHE_CHARSET_CONVERT_MASK), len, str,strend(str)+1)); DBUG_PRINT("qcache", ("-b- 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx", (ulong) block, (ulong) block->next, (ulong) block->prev, (ulong)block->pnext, (ulong)block->pprev)); str[len]=(char) flags; for (TABLE_COUNTER_TYPE t = 0; t < block->n_tables; t++) { Query_cache_table *table = block->table(t)->parent; Loading