List:Commits« Previous MessageNext Message »
From:Marc Alff Date:July 14 2011 9:54am
Subject:bzr push into mysql-trunk-wl5342 branch (marc.alff:3379 to 3380) WL#5342
View as plain text  
 3380 Marc Alff	2011-07-14
      WL#5342 PERFORMANCE SCHEMA SETUP_OBJECTS, ENABLED column 
      
      Implemented stronger checks for out of bound enum values.
      Added tests in dml_setup_objects, setup_objects.

    modified:
      mysql-test/suite/perfschema/r/dml_setup_objects.result
      mysql-test/suite/perfschema/r/setup_objects.result
      mysql-test/suite/perfschema/t/dml_setup_objects.test
      mysql-test/suite/perfschema/t/setup_objects.test
      storage/perfschema/table_setup_objects.cc
 3379 Marc Alff	2011-07-14 [merge]
      Merge mysql-trunk --> mysql-trunk-wl5342

    modified:
      client/mysqlbinlog.cc
      include/welcome_copyright_notice.h
      mysql-test/include/mix1.inc
      mysql-test/suite/innodb/r/innodb-index.result
      mysql-test/suite/innodb/r/innodb_mysql.result
      mysql-test/suite/innodb/t/innodb-index.test
      mysys/psi_noop.cc
      plugin/audit_null/audit_null.c
      sql/handler.cc
      sql/item_geofunc.cc
      sql/partition_info.cc
      sql/rpl_info_file.cc
      sql/sql_load.cc
      sql/sql_select.cc
      storage/innobase/lock/lock0lock.c
      storage/innobase/row/row0row.c
      storage/innobase/trx/trx0purge.c
      storage/innobase/trx/trx0rec.c
      storage/perfschema/pfs_instr.cc
      storage/perfschema/unittest/pfs_instr_class-t.cc
      support-files/mysql-log-rotate.sh
=== modified file 'mysql-test/suite/perfschema/r/dml_setup_objects.result'
--- a/mysql-test/suite/perfschema/r/dml_setup_objects.result	2011-05-05 06:11:49 +0000
+++ b/mysql-test/suite/perfschema/r/dml_setup_objects.result	2011-07-14 09:53:42 +0000
@@ -16,14 +16,14 @@ order by object_type, object_schema, obj
 OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	ENABLED	TIMED
 insert into performance_schema.setup_objects
 set object_type='ILLEGAL', object_schema='FOO', object_name='BAR',
-timed='YES';
+enabled='YES', timed='YES';
 ERROR 23000: Cannot add or update a child row: a foreign key constraint fails ()
 insert into performance_schema.setup_objects
 set object_type='TABLE', object_schema='FOO', object_name='BAR',
-timed='YES';
+enabled='YES', timed='YES';
 insert into performance_schema.setup_objects
 set object_type='TABLE', object_schema='FOO', object_name='BAR',
-timed='NO';
+enabled='YES', timed='NO';
 ERROR 23000: Can't write; duplicate key in table 'setup_objects'
 delete from performance_schema.setup_objects
 where object_type='TABLE' and object_schema='FOO';
@@ -32,11 +32,11 @@ order by object_type, object_schema, obj
 OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	ENABLED	TIMED
 insert into performance_schema.setup_objects
 set object_type='TABLE', object_schema='FOO', object_name='BAR',
-timed='YES';
+enabled='NO', timed='YES';
 select * from performance_schema.setup_objects
 order by object_type, object_schema, object_name;
 OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	ENABLED	TIMED
-TABLE	FOO	BAR	YES	YES
+TABLE	FOO	BAR	NO	YES
 update performance_schema.setup_objects
 set object_type='ILLEGAL';
 ERROR HY000: Invalid performance_schema usage.
@@ -47,13 +47,13 @@ update performance_schema.setup_objects
 set object_name='ILLEGAL';
 ERROR HY000: Invalid performance_schema usage.
 update performance_schema.setup_objects
-set timed='NO';
+set enabled='NO', timed='NO';
 select * from performance_schema.setup_objects
 order by object_type, object_schema, object_name;
 OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	ENABLED	TIMED
-TABLE	FOO	BAR	YES	NO
+TABLE	FOO	BAR	NO	NO
 update performance_schema.setup_objects
-set timed='YES';
+set enabled='YES', timed='YES';
 delete from performance_schema.setup_objects
 where object_type = 'TABLE';
 delete from performance_schema.setup_objects;

=== modified file 'mysql-test/suite/perfschema/r/setup_objects.result'
--- a/mysql-test/suite/perfschema/r/setup_objects.result	2011-05-05 06:11:49 +0000
+++ b/mysql-test/suite/perfschema/r/setup_objects.result	2011-07-14 09:53:42 +0000
@@ -21,6 +21,49 @@ insert into performance_schema.setup_obj
 values ('TABLE', 'db4', 't1', 'NO', 'YES');
 insert into performance_schema.setup_objects
 values ('TABLE', 'db4', '%', 'YES', 'NO');
+insert into performance_schema.setup_objects
+values ('SOMETHING', 'bad1', 'bad1', 'YES', 'NO');
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails ()
+show warnings;
+Level	Code	Message
+Warning	1265	Data truncated for column 'OBJECT_TYPE' at row 1
+Error	1452	Cannot add or update a child row: a foreign key constraint fails ()
+insert into performance_schema.setup_objects
+values ('TABLE', 'bad2', 'bad2', 'MAYBE', 'NO');
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails ()
+show warnings;
+Level	Code	Message
+Warning	1265	Data truncated for column 'ENABLED' at row 1
+Error	1452	Cannot add or update a child row: a foreign key constraint fails ()
+insert into performance_schema.setup_objects
+values ('TABLE', 'bad3', 'bad3', 'YES', 'MAYBE NOT');
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails ()
+show warnings;
+Level	Code	Message
+Warning	1265	Data truncated for column 'TIMED' at row 1
+Error	1452	Cannot add or update a child row: a foreign key constraint fails ()
+select * from performance_schema.setup_objects
+order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	ENABLED	TIMED
+TABLE	db1	%	YES	YES
+TABLE	db1	t1	YES	YES
+TABLE	db1	t2	YES	NO
+TABLE	db2	t1	YES	YES
+TABLE	db2	t2	YES	NO
+TABLE	db3	%	NO	YES
+TABLE	db3	t1	YES	YES
+TABLE	db3	t2	NO	NO
+TABLE	db4	%	YES	NO
+TABLE	db4	t1	NO	YES
+update performance_schema.setup_objects
+set OBJECT_TYPE='SOMETHING' where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1';
+ERROR HY000: Invalid performance_schema usage.
+update performance_schema.setup_objects
+set ENABLED='MAYBE' where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1';
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails ()
+update performance_schema.setup_objects
+set TIMED='MAYBE NOT' where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1';
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails ()
 select * from performance_schema.setup_objects
 order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
 OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	ENABLED	TIMED

=== modified file 'mysql-test/suite/perfschema/t/dml_setup_objects.test'
--- a/mysql-test/suite/perfschema/t/dml_setup_objects.test	2010-11-15 15:04:34 +0000
+++ b/mysql-test/suite/perfschema/t/dml_setup_objects.test	2011-07-14 09:53:42 +0000
@@ -44,16 +44,16 @@ select * from performance_schema.setup_o
 --error ER_NO_REFERENCED_ROW_2
 insert into performance_schema.setup_objects
   set object_type='ILLEGAL', object_schema='FOO', object_name='BAR',
-  timed='YES';
+  enabled='YES', timed='YES';
 
 insert into performance_schema.setup_objects
   set object_type='TABLE', object_schema='FOO', object_name='BAR',
-  timed='YES';
+  enabled='YES', timed='YES';
 
 --error ER_DUP_KEY
 insert into performance_schema.setup_objects
   set object_type='TABLE', object_schema='FOO', object_name='BAR',
-  timed='NO';
+  enabled='YES', timed='NO';
 
 delete from performance_schema.setup_objects
   where object_type='TABLE' and object_schema='FOO';
@@ -63,7 +63,7 @@ select * from performance_schema.setup_o
 
 insert into performance_schema.setup_objects
   set object_type='TABLE', object_schema='FOO', object_name='BAR',
-  timed='YES';
+  enabled='NO', timed='YES';
 
 select * from performance_schema.setup_objects
   order by object_type, object_schema, object_name;
@@ -81,13 +81,13 @@ update performance_schema.setup_objects
   set object_name='ILLEGAL';
 
 update performance_schema.setup_objects
-  set timed='NO';
+  set enabled='NO', timed='NO';
 
 select * from performance_schema.setup_objects
   order by object_type, object_schema, object_name;
 
 update performance_schema.setup_objects
-  set timed='YES';
+  set enabled='YES', timed='YES';
 
 delete from performance_schema.setup_objects
   where object_type = 'TABLE';

=== modified file 'mysql-test/suite/perfschema/t/setup_objects.test'
--- a/mysql-test/suite/perfschema/t/setup_objects.test	2011-05-05 06:11:49 +0000
+++ b/mysql-test/suite/perfschema/t/setup_objects.test	2011-07-14 09:53:42 +0000
@@ -54,6 +54,45 @@ insert into performance_schema.setup_obj
 insert into performance_schema.setup_objects
   values ('TABLE', 'db4', '%', 'YES', 'NO');
 
+# Also test insert of invalid enum values
+
+--error ER_NO_REFERENCED_ROW_2
+insert into performance_schema.setup_objects
+  values ('SOMETHING', 'bad1', 'bad1', 'YES', 'NO');
+show warnings;
+
+--error ER_NO_REFERENCED_ROW_2
+insert into performance_schema.setup_objects
+  values ('TABLE', 'bad2', 'bad2', 'MAYBE', 'NO');
+show warnings;
+
+--error ER_NO_REFERENCED_ROW_2
+insert into performance_schema.setup_objects
+  values ('TABLE', 'bad3', 'bad3', 'YES', 'MAYBE NOT');
+show warnings;
+
+select * from performance_schema.setup_objects
+  order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+# Also test update of invalid enum values
+# Note: do not use SHOW WARNINGS in the test,
+# because error messages such as:
+#   "Data truncated for column 'OBJECT_TYPE' at row <N>"
+# do not always use the same row number <N>.
+
+# ER_WRONG_PERFSCHEMA_USAGE because of privileges, expected.
+--error ER_WRONG_PERFSCHEMA_USAGE
+update performance_schema.setup_objects
+  set OBJECT_TYPE='SOMETHING' where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1';
+
+--error ER_NO_REFERENCED_ROW_2
+update performance_schema.setup_objects
+  set ENABLED='MAYBE' where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1';
+
+--error ER_NO_REFERENCED_ROW_2
+update performance_schema.setup_objects
+  set TIMED='MAYBE NOT' where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1';
+
 select * from performance_schema.setup_objects
   order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
 

=== modified file 'storage/perfschema/table_setup_objects.cc'
--- a/storage/perfschema/table_setup_objects.cc	2011-07-07 19:13:19 +0000
+++ b/storage/perfschema/table_setup_objects.cc	2011-07-14 09:53:42 +0000
@@ -105,7 +105,8 @@ int table_setup_objects::write_row(TABLE
   String object_name_data("%", 1, &my_charset_utf8_bin);
   String *object_schema= &object_schema_data;
   String *object_name= &object_name_data;
-  enum_yes_no yes_no;
+  enum_yes_no enabled_value= ENUM_YES;
+  enum_yes_no timed_value= ENUM_YES;
   bool enabled= true;
   bool timed= true;
 
@@ -125,12 +126,10 @@ int table_setup_objects::write_row(TABLE
         object_name= get_field_varchar_utf8(f, &object_name_data);
         break;
       case 3: /* ENABLED */
-        yes_no= (enum_yes_no) get_field_enum(f);
-        enabled= (yes_no == ENUM_YES) ? true : false;
+        enabled_value= (enum_yes_no) get_field_enum(f);
         break;
       case 4: /* TIMED */
-        yes_no= (enum_yes_no) get_field_enum(f);
-        timed= (yes_no == ENUM_YES) ? true : false;
+        timed_value= (enum_yes_no) get_field_enum(f);
         break;
       default:
         DBUG_ASSERT(false);
@@ -142,6 +141,17 @@ int table_setup_objects::write_row(TABLE
   if (object_type != OBJECT_TYPE_TABLE)
     return HA_ERR_NO_REFERENCED_ROW;
 
+  /* Reject illegal enum values in ENABLED */
+  if ((enabled_value != ENUM_YES) && (enabled_value != ENUM_NO))
+    return HA_ERR_NO_REFERENCED_ROW;
+
+  /* Reject illegal enum values in TIMED */
+  if ((timed_value != ENUM_YES) && (timed_value != ENUM_NO))
+    return HA_ERR_NO_REFERENCED_ROW;
+
+  enabled= (enabled_value == ENUM_YES) ? true : false;
+  timed= (timed_value == ENUM_YES) ? true : false;
+
   result= insert_setup_object(object_type, object_schema, object_name,
                               enabled, timed);
   if (result == 0)
@@ -303,10 +313,16 @@ int table_setup_objects::update_row_valu
         return HA_ERR_WRONG_COMMAND;
       case 3: /* ENABLED */
         value= (enum_yes_no) get_field_enum(f);
+        /* Reject illegal enum values in ENABLED */
+        if ((value != ENUM_YES) && (value != ENUM_NO))
+          return HA_ERR_NO_REFERENCED_ROW;
         *m_row.m_enabled_ptr= (value == ENUM_YES) ? true : false;
         break;
       case 4: /* TIMED */
         value= (enum_yes_no) get_field_enum(f);
+        /* Reject illegal enum values in TIMED */
+        if ((value != ENUM_YES) && (value != ENUM_NO))
+          return HA_ERR_NO_REFERENCED_ROW;
         *m_row.m_timed_ptr= (value == ENUM_YES) ? true : false;
         break;
       default:

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-wl5342 branch (marc.alff:3379 to 3380) WL#5342Marc Alff17 Jul