List:Commits« Previous MessageNext Message »
From:Petr Chardin Date:February 24 2006 7:00pm
Subject:bk commit into 5.1 tree (petr:1.2160) BUG#17600
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of cps. When cps 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
  1.2160 06/02/24 21:00:41 petr@stripped +5 -0
  Fix Bug#17600: Invalid data logged into mysql.slow_log

  mysql-test/t/log_tables-master.opt
    1.1 06/02/24 21:00:37 petr@stripped +1 -0
    New BitKeeper file ``mysql-test/t/log_tables-master.opt''

  storage/csv/ha_tina.cc
    1.36 06/02/24 21:00:37 petr@stripped +14 -3
    Explicitly check fo NULLs, when writing a row.
    We should not hope, that the null field was
    cleaned up.
    Though usually we do call Field::reset() or
    rstore_row(), before calling Field::set_null(),
    this depency is neither documented nor enforced
    by other means.

  sql/log.cc
    1.193 06/02/24 21:00:37 petr@stripped +20 -10
    Fix NULL handling in log tables

  mysql-test/t/log_tables.test
    1.6 06/02/24 21:00:37 petr@stripped +10 -0
    add a test

  mysql-test/t/log_tables-master.opt
    1.0 06/02/24 21:00:37 petr@stripped +0 -0
    BitKeeper file
/home/cps/mysql/trees/5.1/5.1-virgin-no-debug/mysql-test/t/log_tables-master.opt

  mysql-test/r/log_tables.result
    1.3 06/02/24 21:00:37 petr@stripped +8 -0
    update result

# 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:	petr
# Host:	outpost.site
# Root:	/home/cps/mysql/trees/5.1/5.1-virgin-no-debug

--- 1.192/sql/log.cc	2006-02-18 21:07:28 +03:00
+++ 1.193/sql/log.cc	2006-02-24 21:00:37 +03:00
@@ -286,7 +286,7 @@
   Log command to the general log table
 
   SYNOPSIS
-    log_general_to_csv()
+    log_general()
 
     event_time        command start timestamp
     user_host         the pointer to the string with user@host info
@@ -328,10 +328,15 @@
   table->field[0]->set_null();
 
   table->field[1]->store(user_host, user_host_len, client_cs);
+  table->field[1]->set_notnull();
   table->field[2]->store((longlong) thread_id);
+  table->field[2]->set_notnull();
   table->field[3]->store((longlong) server_id);
+  table->field[3]->set_notnull();
   table->field[4]->store(command_type, command_type_len, client_cs);
+  table->field[4]->set_notnull();
   table->field[5]->store(sql_text, sql_text_len, client_cs);
+  table->field[5]->set_notnull();
   table->file->ha_write_row(table->record[0]);
 
   reenable_binlog(current_thd);
@@ -344,7 +349,7 @@
   Log a query to the slow log table
 
   SYNOPSIS
-    log_slow_to_csv()
+    log_slow()
     thd               THD of the query
     current_time      current timestamp
     query_start_arg   command start timestamp
@@ -379,7 +384,7 @@
   TABLE *table= slow_log.table;
   CHARSET_INFO *client_cs= thd->variables.character_set_client;
 
-  DBUG_ENTER("log_slow_to_csv");
+  DBUG_ENTER("log_slow");
 
   /* below should never happen */
   if (unlikely(!logger.is_log_tables_initialized))
@@ -393,6 +398,7 @@
      This will be default value for the field
   */
   slow_log_thd->start_time= query_start_arg;
+  restore_record(table, s->default_values);    // Get empty record
 
   /* set default value (which is CURRENT_TIMESTAMP) */
   table->field[0]->set_null();
@@ -419,24 +425,28 @@
     table->field[5]->set_null();
   }
 
+  /* fill database field */
   if (thd->db)
-    /* fill database field */
+  {
     table->field[6]->store(thd->db, thd->db_length, client_cs);
-  else
-    table->field[6]->set_null();
+    table->field[6]->set_notnull();
+  }
 
   if (thd->last_insert_id_used)
+  {
     table->field[7]->store((longlong) thd->current_insert_id);
-  else
-    table->field[7]->set_null();
+    table->field[7]->set_notnull();
+  }
 
   /* set value if we do an insert on autoincrement column */
   if (thd->insert_id_used)
+  {
     table->field[8]->store((longlong) thd->last_insert_id);
-  else
-    table->field[8]->set_null();
+    table->field[8]->set_notnull();
+  }
 
   table->field[9]->store((longlong) server_id);
+  table->field[9]->set_notnull();
 
   /* sql_text */
   table->field[10]->store(sql_text,sql_text_len, client_cs);

--- 1.35/storage/csv/ha_tina.cc	2006-02-14 12:51:20 +03:00
+++ 1.36/storage/csv/ha_tina.cc	2006-02-24 21:00:37 +03:00
@@ -351,9 +351,20 @@
     const char *ptr;
     const char *end_ptr;
 
-    (*field)->val_str(&attribute,&attribute);
-    ptr= attribute.ptr();
-    end_ptr= attribute.length() + ptr;
+    /*
+      Write an empty string to the buffer in case of a NULL value.
+      Basically this is a safety check, as no one ensures that the
+      field content is cleaned up every time we use Field::set_null()
+      in the code.
+    */
+    if ((*field)->is_null())
+      ptr= end_ptr= 0;
+    else
+    {
+      (*field)->val_str(&attribute,&attribute);
+      ptr= attribute.ptr();
+      end_ptr= attribute.length() + ptr;
+    }
 
     buffer.append('"');
 

--- 1.2/mysql-test/r/log_tables.result	2006-02-03 13:05:10 +03:00
+++ 1.3/mysql-test/r/log_tables.result	2006-02-24 21:00:37 +03:00
@@ -64,3 +64,11 @@
 TIMESTAMP	root[root] @ localhost []	2	1	Query	insert into bug16905 values ('новое')
 TIMESTAMP	root[root] @ localhost []	2	1	Query	select * from mysql.general_log
 drop table bug16905;
+truncate table mysql.slow_log;
+set session long_query_time=1;
+select sleep(2);
+sleep(2)
+0
+select * from mysql.slow_log;
+start_time	user_host	query_time	lock_time	rows_sent	rows_examined	db	last_insert_id	insert_id	server_id	sql_text
+TIMESTAMP,	root[root] @ localhost []	USER_HOST,	QUERY_TIME	1	0	test	0	0	1	select sleep(2)

--- 1.5/mysql-test/t/log_tables.test	2006-02-12 14:47:55 +03:00
+++ 1.6/mysql-test/t/log_tables.test	2006-02-24 21:00:37 +03:00
@@ -160,6 +160,16 @@
 select * from mysql.general_log;
 drop table bug16905;
 
+#
+# Bug #17600: Invalid data logged into mysql.slow_log
+#
+
+truncate table mysql.slow_log;
+set session long_query_time=1;
+select sleep(2);
+--replace_column 1 TIMESTAMP, 3 USER_HOST, 4 QUERY_TIME
+select * from mysql.slow_log;
+
 # kill all connections
 disconnect con1;
 disconnect con2;
--- New file ---
+++ mysql-test/t/log_tables-master.opt	06/02/24 21:00:37
--log-slow-queries

Thread
bk commit into 5.1 tree (petr:1.2160) BUG#17600Petr Chardin24 Feb