List:Commits« Previous MessageNext Message »
From:kroki Date:November 21 2006 2:49pm
Subject:bk commit into 4.1 tree (kroki:1.2551) BUG#23159
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of tomash. When tomash does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2006-11-21 16:49:18+03:00, kroki@stripped +4 -0
  BUG#23159: prepared_stmt_count should be status variable
  
  Make Prepared_stmt_count a global status variable, accessible via
  SHOW STATUS LIKE 'Prepared_stmt_count';.  Documentation should be
  updated.

  mysql-test/r/ps.result@stripped, 2006-11-21 16:49:16+03:00, kroki@stripped +52 -49
    Update result for bug#16365: Prepared Statements: DoS with too many
    open statements, according to bug#23159: prepared_stmt_count should be
    status variable.

  mysql-test/t/ps.test@stripped, 2006-11-21 16:49:16+03:00, kroki@stripped +25 -32
    Update test case for bug#16365: Prepared Statements: DoS with too many
    open statements, according to bug#23159: prepared_stmt_count should be
    status variable.

  sql/mysqld.cc@stripped, 2006-11-21 16:49:16+03:00, kroki@stripped +2 -0
    Add Prepared_stmt_count as global status variable.

  sql/set_var.cc@stripped, 2006-11-21 16:49:16+03:00, kroki@stripped +0 -14
    Remove prepared_stmt_count as system variable.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	kroki
# Host:	moonlight.intranet
# Root:	/home/tomash/src/mysql_ab/mysql-4.1-bug23159

--- 1.619/sql/mysqld.cc	2006-11-21 16:49:25 +03:00
+++ 1.620/sql/mysqld.cc	2006-11-21 16:49:25 +03:00
@@ -5722,6 +5722,7 @@ struct show_var_st status_vars[]= {
   {"Open_streams",             (char*) &my_stream_opened,       SHOW_LONG_CONST},
   {"Open_tables",              (char*) 0,                       SHOW_OPENTABLES},
   {"Opened_tables",            (char*) &opened_tables,          SHOW_LONG},
+  {"Prepared_stmt_count",      (char*) &prepared_stmt_count,    SHOW_LONG_CONST},
 #ifdef HAVE_QUERY_CACHE
   {"Qcache_free_blocks",       (char*) &query_cache.free_memory_blocks,
    SHOW_LONG_CONST},
@@ -5892,6 +5893,7 @@ static void mysql_init_variables(void)
   binlog_cache_use=  binlog_cache_disk_use= 0;
   max_used_connections= slow_launch_threads = 0;
   mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0;
+  prepared_stmt_count= 0;
   errmesg= 0;
   mysqld_unix_port= opt_mysql_tmpdir= my_bind_addr_str= NullS;
   bzero((gptr) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));

--- 1.188/sql/set_var.cc	2006-11-21 16:49:25 +03:00
+++ 1.189/sql/set_var.cc	2006-11-21 16:49:25 +03:00
@@ -119,7 +119,6 @@ static KEY_CACHE *create_key_cache(const
 void fix_sql_mode_var(THD *thd, enum_var_type type);
 static byte *get_error_count(THD *thd);
 static byte *get_warning_count(THD *thd);
-static byte *get_prepared_stmt_count(THD *thd);
 static byte *get_have_innodb(THD *thd);
 
 /*
@@ -482,9 +481,6 @@ static sys_var_readonly		sys_warning_cou
 						  OPT_SESSION,
 						  SHOW_LONG,
 						  get_warning_count);
-static sys_var_readonly	sys_prepared_stmt_count("prepared_stmt_count",
-                                                OPT_GLOBAL, SHOW_LONG,
-                                                get_prepared_stmt_count);
 
 /* alias for last_insert_id() to be compatible with Sybase */
 #ifdef HAVE_REPLICATION
@@ -604,7 +600,6 @@ sys_var *sys_variables[]=
   &sys_new_mode,
   &sys_old_passwords,
   &sys_preload_buff_size,
-  &sys_prepared_stmt_count,
   &sys_pseudo_thread_id,
   &sys_query_alloc_block_size,
   &sys_query_cache_size,
@@ -860,7 +855,6 @@ struct show_var_st init_vars[]= {
   {"pid_file",                (char*) pidfile_name,                 SHOW_CHAR},
   {"port",                    (char*) &mysqld_port,                  SHOW_INT},
   {sys_preload_buff_size.name, (char*) &sys_preload_buff_size,      SHOW_SYS},
-  {sys_prepared_stmt_count.name, (char*) &sys_prepared_stmt_count, SHOW_SYS},
   {"protocol_version",        (char*) &protocol_version,            SHOW_INT},
   {sys_query_alloc_block_size.name, (char*) &sys_query_alloc_block_size,
    SHOW_SYS},
@@ -2714,14 +2708,6 @@ static byte *get_have_innodb(THD *thd)
   return (byte*) show_comp_option_name[have_innodb];
 }
 
-
-static byte *get_prepared_stmt_count(THD *thd)
-{
-  pthread_mutex_lock(&LOCK_prepared_stmt_count);
-  thd->sys_var_tmp.ulong_value= prepared_stmt_count;
-  pthread_mutex_unlock(&LOCK_prepared_stmt_count);
-  return (byte*) &thd->sys_var_tmp.ulong_value;
-}
 
 /****************************************************************************
   Main handling of variables:

--- 1.52/mysql-test/r/ps.result	2006-11-21 16:49:25 +03:00
+++ 1.53/mysql-test/r/ps.result	2006-11-21 16:49:25 +03:00
@@ -775,12 +775,12 @@ set @old_max_prepared_stmt_count= @@max_
 show variables like 'max_prepared_stmt_count';
 Variable_name	Value
 max_prepared_stmt_count	16382
-show variables like 'prepared_stmt_count';
+show status like 'prepared_stmt_count';
 Variable_name	Value
-prepared_stmt_count	0
-select @@max_prepared_stmt_count, @@prepared_stmt_count;
-@@max_prepared_stmt_count	@@prepared_stmt_count
-16382	0
+Prepared_stmt_count	0
+select @@max_prepared_stmt_count;
+@@max_prepared_stmt_count
+16382
 set global max_prepared_stmt_count=-1;
 select @@max_prepared_stmt_count;
 @@max_prepared_stmt_count
@@ -799,67 +799,70 @@ set max_prepared_stmt_count=1;
 ERROR HY000: Variable 'max_prepared_stmt_count' is a GLOBAL variable and should be set
with SET GLOBAL
 set local max_prepared_stmt_count=1;
 ERROR HY000: Variable 'max_prepared_stmt_count' is a GLOBAL variable and should be set
with SET GLOBAL
-set local prepared_stmt_count=0;
-ERROR HY000: Variable 'prepared_stmt_count' is a GLOBAL variable and should be set with
SET GLOBAL
-set @@prepared_stmt_count=0;
-ERROR HY000: Variable 'prepared_stmt_count' is a GLOBAL variable and should be set with
SET GLOBAL
-set global prepared_stmt_count=1;
-ERROR 42000: Incorrect argument type to variable 'prepared_stmt_count'
 set global max_prepared_stmt_count=1;
 select @@max_prepared_stmt_count;
 @@max_prepared_stmt_count
 1
 set global max_prepared_stmt_count=0;
-select @@max_prepared_stmt_count, @@prepared_stmt_count;
-@@max_prepared_stmt_count	@@prepared_stmt_count
-0	0
+select @@max_prepared_stmt_count;
+@@max_prepared_stmt_count
+0
+show status like 'prepared_stmt_count';
+Variable_name	Value
+Prepared_stmt_count	0
 prepare stmt from "select 1";
 ERROR HY000: Unknown error
-select @@prepared_stmt_count;
-@@prepared_stmt_count
-0
+show status like 'prepared_stmt_count';
+Variable_name	Value
+Prepared_stmt_count	0
 set global max_prepared_stmt_count=1;
 prepare stmt from "select 1";
-select @@prepared_stmt_count;
-@@prepared_stmt_count
-1
+show status like 'prepared_stmt_count';
+Variable_name	Value
+Prepared_stmt_count	1
 prepare stmt1 from "select 1";
 ERROR HY000: Unknown error
-select @@prepared_stmt_count;
-@@prepared_stmt_count
-1
+show status like 'prepared_stmt_count';
+Variable_name	Value
+Prepared_stmt_count	1
 deallocate prepare stmt;
-select @@prepared_stmt_count;
-@@prepared_stmt_count
-0
+show status like 'prepared_stmt_count';
+Variable_name	Value
+Prepared_stmt_count	0
 prepare stmt from "select 1";
-select @@prepared_stmt_count;
-@@prepared_stmt_count
-1
+show status like 'prepared_stmt_count';
+Variable_name	Value
+Prepared_stmt_count	1
 prepare stmt from "select 2";
-select @@prepared_stmt_count;
-@@prepared_stmt_count
+show status like 'prepared_stmt_count';
+Variable_name	Value
+Prepared_stmt_count	1
+show status like 'prepared_stmt_count';
+Variable_name	Value
+Prepared_stmt_count	1
+select @@max_prepared_stmt_count;
+@@max_prepared_stmt_count
 1
-select @@prepared_stmt_count, @@max_prepared_stmt_count;
-@@prepared_stmt_count	@@max_prepared_stmt_count
-1	1
 set global max_prepared_stmt_count=0;
 prepare stmt from "select 1";
 ERROR HY000: Unknown error
 execute stmt;
 ERROR HY000: Unknown prepared statement handler (stmt) given to EXECUTE
-select @@prepared_stmt_count;
-@@prepared_stmt_count
-0
+show status like 'prepared_stmt_count';
+Variable_name	Value
+Prepared_stmt_count	0
 prepare stmt from "select 1";
 ERROR HY000: Unknown error
-select @@prepared_stmt_count;
-@@prepared_stmt_count
-0
+show status like 'prepared_stmt_count';
+Variable_name	Value
+Prepared_stmt_count	0
 set global max_prepared_stmt_count=3;
-select @@max_prepared_stmt_count, @@prepared_stmt_count;
-@@max_prepared_stmt_count	@@prepared_stmt_count
-3	0
+select @@max_prepared_stmt_count;
+@@max_prepared_stmt_count
+3
+show status like 'prepared_stmt_count';
+Variable_name	Value
+Prepared_stmt_count	0
 prepare stmt from "select 1";
 prepare stmt from "select 2";
 prepare stmt1 from "select 3";
@@ -867,13 +870,13 @@ prepare stmt2 from "select 4";
 ERROR HY000: Unknown error
 prepare stmt2 from "select 4";
 ERROR HY000: Unknown error
-select @@max_prepared_stmt_count, @@prepared_stmt_count;
-@@max_prepared_stmt_count	@@prepared_stmt_count
-3	3
+select @@max_prepared_stmt_count;
+@@max_prepared_stmt_count
+3
+show status like 'prepared_stmt_count';
+Variable_name	Value
+Prepared_stmt_count	3
 deallocate prepare stmt;
-select @@max_prepared_stmt_count, @@prepared_stmt_count;
-@@max_prepared_stmt_count	@@prepared_stmt_count
-3	0
 set global max_prepared_stmt_count= @old_max_prepared_stmt_count;
 drop table if exists t1;
 create temporary table if not exists t1 (a1 int);

--- 1.54/mysql-test/t/ps.test	2006-11-21 16:49:25 +03:00
+++ 1.55/mysql-test/t/ps.test	2006-11-21 16:49:25 +03:00
@@ -811,6 +811,9 @@ drop table t1;
 # Bug#16365 Prepared Statements: DoS with too many open statements
 # Check that the limit @@max_prpeared_stmt_count works.
 #
+# This is also the test for bug#23159 prepared_stmt_count should be
+# status variable.
+#
 # Save the old value
 set @old_max_prepared_stmt_count= @@max_prepared_stmt_count;
 #
@@ -820,17 +823,17 @@ set @old_max_prepared_stmt_count= @@max_
 #
 --disable_ps_protocol
 #
-# A. Check that the new variables are present in SHOW VARIABLES list.
+# A. Check that the new variables are present in SHOW VARIABLES and
+# SHOW STATUS lists.
 #
 show variables like 'max_prepared_stmt_count';
-show variables like 'prepared_stmt_count';
+show status like 'prepared_stmt_count';
 #
-# B. Check that the new variables are selectable.
+# B. Check that the new system variable is selectable.
 #
-select @@max_prepared_stmt_count, @@prepared_stmt_count;
+select @@max_prepared_stmt_count;
 #
-# C. Check that max_prepared_stmt_count is settable (global only),
-#    whereas prepared_stmt_count is readonly.
+# C. Check that max_prepared_stmt_count is settable (global only).
 #
 set global max_prepared_stmt_count=-1;
 select @@max_prepared_stmt_count;
@@ -844,12 +847,6 @@ set @@max_prepared_stmt_count=1;
 set max_prepared_stmt_count=1;
 --error 1229 # ER_GLOBAL_VARIABLE
 set local max_prepared_stmt_count=1;
---error 1229 # ER_GLOBAL_VARIABLE
-set local prepared_stmt_count=0;
---error 1229 # ER_GLOBAL_VARIABLE
-set @@prepared_stmt_count=0;
---error 1232 # ER_WRONG_TYPE_FOR_VAR
-set global prepared_stmt_count=1;
 # set to a reasonable limit works
 set global max_prepared_stmt_count=1;
 select @@max_prepared_stmt_count;
@@ -857,47 +854,50 @@ select @@max_prepared_stmt_count;
 # D. Check that the variables actually work.
 #
 set global max_prepared_stmt_count=0;
-select @@max_prepared_stmt_count, @@prepared_stmt_count;
+select @@max_prepared_stmt_count;
+show status like 'prepared_stmt_count';
 --error 1105 # ER_UNKNOWN_ERROR
 prepare stmt from "select 1";
-select @@prepared_stmt_count;
+show status like 'prepared_stmt_count';
 set global max_prepared_stmt_count=1;
 prepare stmt from "select 1";
-select @@prepared_stmt_count;
+show status like 'prepared_stmt_count';
 --error 1105 # ER_UNKNOWN_ERROR
 prepare stmt1 from "select 1";
-select @@prepared_stmt_count;
+show status like 'prepared_stmt_count';
 deallocate prepare stmt;
-select @@prepared_stmt_count;
+show status like 'prepared_stmt_count';
 #
 # E. Check that we can prepare a statement with the same name 
 # successfully, without hitting the limit.
 #
 prepare stmt from "select 1";
-select @@prepared_stmt_count;
+show status like 'prepared_stmt_count';
 prepare stmt from "select 2";
-select @@prepared_stmt_count;
+show status like 'prepared_stmt_count';
 #
 # F. We can set the max below the current count. In this case no new 
 # statements should be allowed to prepare.
 #
-select @@prepared_stmt_count, @@max_prepared_stmt_count;
+show status like 'prepared_stmt_count';
+select @@max_prepared_stmt_count;
 set global max_prepared_stmt_count=0;
 --error 1105 # ER_UNKNOWN_ERROR
 prepare stmt from "select 1";
 # Result: the old statement is deallocated, the new is not created.
 --error 1243 # ER_UNKNOWN_STMT_HANDLER
 execute stmt;
-select @@prepared_stmt_count;
+show status like 'prepared_stmt_count';
 --error 1105 # ER_UNKNOWN_ERROR
 prepare stmt from "select 1";
-select @@prepared_stmt_count;
+show status like 'prepared_stmt_count';
 #
 # G. Show that the variables are up to date even after a connection with all
 # statements in it was terminated.
 #
 set global max_prepared_stmt_count=3;
-select @@max_prepared_stmt_count, @@prepared_stmt_count;
+select @@max_prepared_stmt_count;
+show status like 'prepared_stmt_count';
 prepare stmt from "select 1";
 connect (con1,localhost,root,,);
 connection con1;
@@ -908,18 +908,11 @@ prepare stmt2 from "select 4";
 connection default;
 --error 1105 # ER_UNKNOWN_ERROR 
 prepare stmt2 from "select 4";
-select @@max_prepared_stmt_count, @@prepared_stmt_count;
+select @@max_prepared_stmt_count;
+show status like 'prepared_stmt_count';
 disconnect con1;
 connection default;
-# Wait for the connection to die: deal with a possible race
 deallocate prepare stmt;
-let $count= `select @@prepared_stmt_count`;
-if ($count)
-{
---sleep 2
-  let $count= `select @@prepared_stmt_count`;
-}
-select @@max_prepared_stmt_count, @@prepared_stmt_count;
 #
 # Restore the old value.
 #
Thread
bk commit into 4.1 tree (kroki:1.2551) BUG#23159kroki21 Nov