Loading libmysqld/lib_sql.cc +6 −6 Original line number Diff line number Diff line Loading @@ -822,7 +822,7 @@ int Protocol::begin_dataset() remove last row of current recordset SYNOPSIS Protocol_simple::remove_last_row() Protocol_text::remove_last_row() NOTES does the loop from the beginning of the current recordset to Loading @@ -830,12 +830,12 @@ int Protocol::begin_dataset() Not supposed to be frequently called. */ void Protocol_simple::remove_last_row() void Protocol_text::remove_last_row() { MYSQL_DATA *data= thd->cur_data; MYSQL_ROWS **last_row_hook= &data->data; uint count= data->rows; DBUG_ENTER("Protocol_simple::remove_last_row"); DBUG_ENTER("Protocol_text::remove_last_row"); while (--count) last_row_hook= &(*last_row_hook)->next; Loading Loading @@ -964,7 +964,7 @@ bool Protocol::write() return false; } bool Protocol_prep::write() bool Protocol_binary::write() { MYSQL_ROWS *cur; MYSQL_DATA *data= thd->cur_data; Loading Loading @@ -1031,7 +1031,7 @@ void net_send_error_packet(THD *thd, uint sql_errno, const char *err) } void Protocol_simple::prepare_for_resend() void Protocol_text::prepare_for_resend() { MYSQL_ROWS *cur; MYSQL_DATA *data= thd->cur_data; Loading @@ -1056,7 +1056,7 @@ void Protocol_simple::prepare_for_resend() DBUG_VOID_RETURN; } bool Protocol_simple::store_null() bool Protocol_text::store_null() { *(next_field++)= NULL; ++next_mysql_field; Loading mysql-test/include/have_query_cache.inc +0 −3 Original line number Diff line number Diff line -- require r/have_query_cache.require # As PS are not cached we disable them to ensure the we get the right number # of query cache hits -- disable_ps_protocol disable_query_log; show variables like "have_query_cache"; enable_query_log; mysql-test/r/query_cache.result +23 −0 Original line number Diff line number Diff line Loading @@ -1325,4 +1325,27 @@ start transaction; insert into t1(c1) select c1 from v1; drop table t1, t2, t3; drop view v1; create table t1(c1 int); insert into t1 values(1),(10),(100); select * from t1; c1 1 10 100 select * from t1; c1 1 10 100 select * from t1; c1 1 10 100 select * from t1; c1 1 10 100 drop table t1; set global query_cache_size=0; mysql-test/r/query_cache_sql_prepare.result 0 → 100644 +204 −0 Original line number Diff line number Diff line set global query_cache_size=100000; flush status; create table t1(c1 int); insert into t1 values(1),(10),(100); prepare stmt1 from "select * from t1 where c1=10"; show status like 'Qcache_hits'; Variable_name Value Qcache_hits 0 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 0 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 1 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 2 prepare stmt2 from "select * from t1 where c1=10"; execute stmt2; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 3 execute stmt2; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 4 execute stmt2; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 5 prepare stmt3 from "select * from t1 where c1=10"; execute stmt3; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 6 execute stmt3; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 7 execute stmt3; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 8 select * from t1 where c1=10; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 9 flush tables; execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 9 select * from t1 where c1=10; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 prepare stmt1 from "select * from t1 where c1=?"; show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 set @a=1; execute stmt1 using @a; c1 1 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 set @a=100; execute stmt1 using @a; c1 100 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 set @a=10; execute stmt1 using @a; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 prepare stmt1 from "select * from t1 where c1=10"; set global query_cache_size=0; show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 set global query_cache_size=100000; execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 11 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 set global query_cache_size=0; prepare stmt1 from "select * from t1 where c1=10"; set global query_cache_size=100000; show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 set global query_cache_size=0; prepare stmt1 from "select * from t1 where c1=?"; set global query_cache_size=100000; show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 set @a=1; execute stmt1 using @a; c1 1 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 set @a=100; execute stmt1 using @a; c1 100 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 set @a=10; execute stmt1 using @a; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 drop table t1; set global query_cache_size=0; flush status; mysql-test/t/grant_cache.test +26 −0 Original line number Diff line number Diff line # Grant tests not performed with embedded server -- source include/not_embedded.inc -- source include/have_query_cache.inc # See at the end of the test why we disable the ps protocol (*) -- disable_ps_protocol # # Test grants with query cache Loading Loading @@ -151,3 +153,27 @@ drop database mysqltest; set GLOBAL query_cache_size=default; # End of 4.1 tests # (*) Why we disable the ps protocol: because in normal protocol, # a SELECT failing due to insufficient privileges increments # Qcache_not_cached, while in ps-protocol, no. # In detail: in normal protocol, # the "access denied" errors on SELECT are issued at (stack trace): # mysql_parse/mysql_execute_command/execute_sqlcom_select/handle_select/ # mysql_select/JOIN::prepare/setup_wild/insert_fields/ # check_grant_all_columns/my_error/my_message_sql, which then calls # push_warning/query_cache_abort: at this moment, # query_cache_store_query() has been called, so query exists in cache, # so thd->net.query_cache_query!=NULL, so query_cache_abort() removes # the query from cache, which causes a query_cache.refused++ (thus, # a Qcache_not_cached++). # While in ps-protocol, the error is issued at prepare time; # for this mysql_test_select() is called, not execute_sqlcom_select() # (and that also leads to JOIN::prepare/etc). Thus, as # query_cache_store_query() has not been called, # thd->net.query_cache_query==NULL, so query_cache_abort() does nothing: # Qcache_not_cached is not incremented. # As this test prints Qcache_not_cached after SELECT failures, # we cannot enable this test in ps-protocol. --enable_ps_protocol Loading
libmysqld/lib_sql.cc +6 −6 Original line number Diff line number Diff line Loading @@ -822,7 +822,7 @@ int Protocol::begin_dataset() remove last row of current recordset SYNOPSIS Protocol_simple::remove_last_row() Protocol_text::remove_last_row() NOTES does the loop from the beginning of the current recordset to Loading @@ -830,12 +830,12 @@ int Protocol::begin_dataset() Not supposed to be frequently called. */ void Protocol_simple::remove_last_row() void Protocol_text::remove_last_row() { MYSQL_DATA *data= thd->cur_data; MYSQL_ROWS **last_row_hook= &data->data; uint count= data->rows; DBUG_ENTER("Protocol_simple::remove_last_row"); DBUG_ENTER("Protocol_text::remove_last_row"); while (--count) last_row_hook= &(*last_row_hook)->next; Loading Loading @@ -964,7 +964,7 @@ bool Protocol::write() return false; } bool Protocol_prep::write() bool Protocol_binary::write() { MYSQL_ROWS *cur; MYSQL_DATA *data= thd->cur_data; Loading Loading @@ -1031,7 +1031,7 @@ void net_send_error_packet(THD *thd, uint sql_errno, const char *err) } void Protocol_simple::prepare_for_resend() void Protocol_text::prepare_for_resend() { MYSQL_ROWS *cur; MYSQL_DATA *data= thd->cur_data; Loading @@ -1056,7 +1056,7 @@ void Protocol_simple::prepare_for_resend() DBUG_VOID_RETURN; } bool Protocol_simple::store_null() bool Protocol_text::store_null() { *(next_field++)= NULL; ++next_mysql_field; Loading
mysql-test/include/have_query_cache.inc +0 −3 Original line number Diff line number Diff line -- require r/have_query_cache.require # As PS are not cached we disable them to ensure the we get the right number # of query cache hits -- disable_ps_protocol disable_query_log; show variables like "have_query_cache"; enable_query_log;
mysql-test/r/query_cache.result +23 −0 Original line number Diff line number Diff line Loading @@ -1325,4 +1325,27 @@ start transaction; insert into t1(c1) select c1 from v1; drop table t1, t2, t3; drop view v1; create table t1(c1 int); insert into t1 values(1),(10),(100); select * from t1; c1 1 10 100 select * from t1; c1 1 10 100 select * from t1; c1 1 10 100 select * from t1; c1 1 10 100 drop table t1; set global query_cache_size=0;
mysql-test/r/query_cache_sql_prepare.result 0 → 100644 +204 −0 Original line number Diff line number Diff line set global query_cache_size=100000; flush status; create table t1(c1 int); insert into t1 values(1),(10),(100); prepare stmt1 from "select * from t1 where c1=10"; show status like 'Qcache_hits'; Variable_name Value Qcache_hits 0 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 0 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 1 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 2 prepare stmt2 from "select * from t1 where c1=10"; execute stmt2; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 3 execute stmt2; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 4 execute stmt2; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 5 prepare stmt3 from "select * from t1 where c1=10"; execute stmt3; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 6 execute stmt3; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 7 execute stmt3; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 8 select * from t1 where c1=10; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 9 flush tables; execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 9 select * from t1 where c1=10; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 prepare stmt1 from "select * from t1 where c1=?"; show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 set @a=1; execute stmt1 using @a; c1 1 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 set @a=100; execute stmt1 using @a; c1 100 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 set @a=10; execute stmt1 using @a; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 prepare stmt1 from "select * from t1 where c1=10"; set global query_cache_size=0; show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 set global query_cache_size=100000; execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 10 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 11 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 set global query_cache_size=0; prepare stmt1 from "select * from t1 where c1=10"; set global query_cache_size=100000; show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 execute stmt1; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 set global query_cache_size=0; prepare stmt1 from "select * from t1 where c1=?"; set global query_cache_size=100000; show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 set @a=1; execute stmt1 using @a; c1 1 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 set @a=100; execute stmt1 using @a; c1 100 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 set @a=10; execute stmt1 using @a; c1 10 show status like 'Qcache_hits'; Variable_name Value Qcache_hits 12 drop table t1; set global query_cache_size=0; flush status;
mysql-test/t/grant_cache.test +26 −0 Original line number Diff line number Diff line # Grant tests not performed with embedded server -- source include/not_embedded.inc -- source include/have_query_cache.inc # See at the end of the test why we disable the ps protocol (*) -- disable_ps_protocol # # Test grants with query cache Loading Loading @@ -151,3 +153,27 @@ drop database mysqltest; set GLOBAL query_cache_size=default; # End of 4.1 tests # (*) Why we disable the ps protocol: because in normal protocol, # a SELECT failing due to insufficient privileges increments # Qcache_not_cached, while in ps-protocol, no. # In detail: in normal protocol, # the "access denied" errors on SELECT are issued at (stack trace): # mysql_parse/mysql_execute_command/execute_sqlcom_select/handle_select/ # mysql_select/JOIN::prepare/setup_wild/insert_fields/ # check_grant_all_columns/my_error/my_message_sql, which then calls # push_warning/query_cache_abort: at this moment, # query_cache_store_query() has been called, so query exists in cache, # so thd->net.query_cache_query!=NULL, so query_cache_abort() removes # the query from cache, which causes a query_cache.refused++ (thus, # a Qcache_not_cached++). # While in ps-protocol, the error is issued at prepare time; # for this mysql_test_select() is called, not execute_sqlcom_select() # (and that also leads to JOIN::prepare/etc). Thus, as # query_cache_store_query() has not been called, # thd->net.query_cache_query==NULL, so query_cache_abort() does nothing: # Qcache_not_cached is not incremented. # As this test prints Qcache_not_cached after SELECT failures, # we cannot enable this test in ps-protocol. --enable_ps_protocol