MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:Osku Salerma Date:August 12 2005 8:39am
Subject:bk commit into 5.0 tree (osku:1.1978) BUG#7819
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of osku. When osku 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.1978 05/08/12 11:39:19 osku@127.(none) +10 -0
  InnoDB: Print more than 300 characters of queries in various error conditions,
  most notably deadlocked ones in SHOW INNODB STATUS. Fixes bug #7819.

  sql/ha_innodb.cc
    1.241 05/08/12 11:29:57 osku@127.(none) +43 -20
    Add max_query_len parameter to innobase_mysql_print_thd.

  innobase/trx/trx0trx.c
    1.60 05/08/12 11:29:57 osku@127.(none) +14 -11
    Add max_query_len parameter to trx_print.

  innobase/srv/srv0srv.c
    1.92 05/08/12 11:29:57 osku@127.(none) +1 -1
    Adapt to changes in trx_print.

  innobase/row/row0upd.c
    1.39 05/08/12 11:29:57 osku@127.(none) +1 -1
    Adapt to changes in trx_print.

  innobase/row/row0umod.c
    1.20 05/08/12 11:29:57 osku@127.(none) +1 -1
    Adapt to changes in trx_print.

  innobase/row/row0sel.c
    1.100 05/08/12 11:29:57 osku@127.(none) +3 -3
    Adapt to changes in trx_print.

  innobase/row/row0ins.c
    1.69 05/08/12 11:29:56 osku@127.(none) +3 -3
    Adapt to changes in trx_print.

  innobase/lock/lock0lock.c
    1.64 05/08/12 11:29:56 osku@127.(none) +4 -4
    Adapt to changes in trx_print.

  innobase/include/trx0trx.h
    1.53 05/08/12 11:29:56 osku@127.(none) +9 -6
    Add max_query_len parameter to trx_print.

  innobase/btr/btr0pcur.c
    1.16 05/08/12 11:29:56 osku@127.(none) +1 -1
    Adapt to changes in trx_print.

# 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:	osku
# Host:	127.(none)
# Root:	/home/osku/mysql-5.0

--- 1.15/innobase/btr/btr0pcur.c	2005-06-14 12:21:31 +03:00
+++ 1.16/innobase/btr/btr0pcur.c	2005-08-12 11:29:56 +03:00
@@ -210,7 +210,7 @@
 			     && cursor->pos_state != BTR_PCUR_IS_POSITIONED)) {
 		ut_print_buf(stderr, (const byte*)cursor, sizeof(btr_pcur_t));
 		if (cursor->trx_if_known) {
-			trx_print(stderr, cursor->trx_if_known);
+			trx_print(stderr, cursor->trx_if_known, 0);
 		}
 		
 		ut_error;

--- 1.52/innobase/include/trx0trx.h	2005-08-03 17:08:24 +03:00
+++ 1.53/innobase/include/trx0trx.h	2005-08-12 11:29:56 +03:00
@@ -329,17 +329,20 @@
 /*============*/
 				/* out: query thread to run next, or NULL */
 	que_thr_t*	thr);	/* in: query thread */
+
 /**************************************************************************
-Prints info about a transaction to the standard output. The caller must
-own the kernel mutex and must have called
-innobase_mysql_prepare_print_arbitrary_thd(), unless he knows that MySQL or
-InnoDB cannot meanwhile change the info printed here. */
+Prints info about a transaction to the given file. The caller must own the
+kernel mutex and must have called
+innobase_mysql_prepare_print_arbitrary_thd(), unless he knows that MySQL
+or InnoDB cannot meanwhile change the info printed here. */
 
 void
 trx_print(
 /*======*/
-	FILE*	f,	/* in: output stream */
-	trx_t*	trx);	/* in: transaction */
+	FILE*	f,		/* in: output stream */
+	trx_t*	trx,		/* in: transaction */
+	uint	max_query_len);	/* in: max query length to print, or 0 to
+				   use the default max length */
 
 #ifndef UNIV_HOTBACKUP
 /**************************************************************************

--- 1.63/innobase/lock/lock0lock.c	2005-07-01 20:42:11 +03:00
+++ 1.64/innobase/lock/lock0lock.c	2005-08-12 11:29:56 +03:00
@@ -3297,7 +3297,7 @@
 
 				fputs("\n*** (1) TRANSACTION:\n", ef);
 
-				trx_print(ef, wait_lock->trx);
+				trx_print(ef, wait_lock->trx, 3000);
 
 				fputs(
 			"*** (1) WAITING FOR THIS LOCK TO BE GRANTED:\n", ef);
@@ -3310,7 +3310,7 @@
 			
 				fputs("*** (2) TRANSACTION:\n", ef);
 
-				trx_print(ef, lock->trx);
+				trx_print(ef, lock->trx, 3000);
 
 				fputs("*** (2) HOLDS THE LOCK(S):\n", ef);
 			
@@ -4207,7 +4207,7 @@
 	while (trx) {
 		if (trx->conc_state == TRX_NOT_STARTED) {
 			fputs("---", file);
-			trx_print(file, trx);
+			trx_print(file, trx, 600);
 		}
 			
 		trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
@@ -4239,7 +4239,7 @@
 
 	if (nth_lock == 0) {
 		fputs("---", file);
-		trx_print(file, trx);
+		trx_print(file, trx, 600);
 		
 	        if (trx->read_view) {
 			fprintf(file,

--- 1.68/innobase/row/row0ins.c	2005-06-22 12:50:51 +03:00
+++ 1.69/innobase/row/row0ins.c	2005-08-12 11:29:56 +03:00
@@ -602,7 +602,7 @@
 	rewind(ef);
 	ut_print_timestamp(ef);
 	fputs(" Transaction:\n", ef);
-	trx_print(ef, trx);
+	trx_print(ef, trx, 600);
 
 	fputs("Foreign key constraint fails for table ", ef);
 	ut_print_name(ef, trx, foreign->foreign_table_name);
@@ -653,7 +653,7 @@
 	rewind(ef);
 	ut_print_timestamp(ef);
 	fputs(" Transaction:\n", ef);
-	trx_print(ef, trx);
+	trx_print(ef, trx, 600);
 	fputs("Foreign key constraint fails for table ", ef);
 	ut_print_name(ef, trx, foreign->foreign_table_name);
 	fputs(":\n", ef);
@@ -1228,7 +1228,7 @@
 			rewind(ef);
 			ut_print_timestamp(ef);
 			fputs(" Transaction:\n", ef);
-			trx_print(ef, trx);
+			trx_print(ef, trx, 600);
 			fputs("Foreign key constraint fails for table ", ef);
 			ut_print_name(ef, trx, foreign->foreign_table_name);
 			fputs(":\n", ef);

--- 1.99/innobase/row/row0sel.c	2005-08-10 17:36:02 +03:00
+++ 1.100/innobase/row/row0sel.c	2005-08-12 11:29:57 +03:00
@@ -2685,7 +2685,7 @@
 				"InnoDB: clust index record ", stderr);
 			rec_print(stderr, clust_rec, clust_index);
 			putc('\n', stderr);
-			trx_print(stderr, trx);
+			trx_print(stderr, trx, 600);
 
 			fputs("\n"
 "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr);
@@ -3128,7 +3128,7 @@
 "InnoDB: Error: MySQL is trying to perform a SELECT\n"
 "InnoDB: but it has not locked any tables in ::external_lock()!\n",
                       stderr);
-		trx_print(stderr, trx);
+		trx_print(stderr, trx, 600);
                 fputc('\n', stderr);
 	}
 
@@ -3455,7 +3455,7 @@
 			fputs(
 "InnoDB: Error: MySQL is trying to perform a consistent read\n"
 "InnoDB: but the read view is not assigned!\n", stderr);
-			trx_print(stderr, trx);
+			trx_print(stderr, trx, 600);
                         fputc('\n', stderr);
 			ut_a(0);
 		}

--- 1.19/innobase/row/row0umod.c	2005-06-21 11:49:46 +03:00
+++ 1.20/innobase/row/row0umod.c	2005-08-12 11:29:57 +03:00
@@ -431,7 +431,7 @@
 			"InnoDB: record ", stderr);
 		rec_print(stderr, btr_pcur_get_rec(&pcur), index);
 		putc('\n', stderr);
-		trx_print(stderr, trx);
+		trx_print(stderr, trx, 0);
 		fputs("\n"
 "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr);
 	} else {

--- 1.38/innobase/row/row0upd.c	2005-06-27 18:58:13 +03:00
+++ 1.39/innobase/row/row0upd.c	2005-08-12 11:29:57 +03:00
@@ -1279,7 +1279,7 @@
 		rec_print(stderr, rec, index);
 		putc('\n', stderr);
 
-		trx_print(stderr, trx);
+		trx_print(stderr, trx, 0);
 
 		fputs("\n"
 "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr);

--- 1.91/innobase/srv/srv0srv.c	2005-08-03 17:07:43 +03:00
+++ 1.92/innobase/srv/srv0srv.c	2005-08-12 11:29:57 +03:00
@@ -999,7 +999,7 @@
 		fputs(
 "  InnoDB: Error: trying to declare trx to enter InnoDB, but\n"
 "InnoDB: it already is declared.\n", stderr);
-		trx_print(stderr, trx);
+		trx_print(stderr, trx, 0);
 		putc('\n', stderr);
 		os_fast_mutex_unlock(&srv_conc_mutex);
 

--- 1.59/innobase/trx/trx0trx.c	2005-08-03 17:07:34 +03:00
+++ 1.60/innobase/trx/trx0trx.c	2005-08-12 11:29:57 +03:00
@@ -30,8 +30,9 @@
 copy MUST be equal to the one in mysql/sql/ha_innodb.cc ! */
 
 void innobase_mysql_print_thd(
-	FILE* f,
-	void* thd);
+	FILE*	f,
+	void*	thd,
+	uint	max_query_len);
 
 /* Dummy session used currently in MySQL interface */
 sess_t*		trx_dummy_sess = NULL;
@@ -262,7 +263,7 @@
 		fputs(
 "  InnoDB: Error: Freeing a trx which is declared to be processing\n"
 "InnoDB: inside InnoDB.\n", stderr);
-		trx_print(stderr, trx);
+		trx_print(stderr, trx, 600);
 		putc('\n', stderr);
 	}
 
@@ -277,7 +278,7 @@
 			(ulong)trx->n_mysql_tables_in_use,
 			(ulong)trx->mysql_n_tables_locked);
 
-		trx_print(stderr, trx);		
+		trx_print(stderr, trx, 600);
 
 		ut_print_buf(stderr, (byte*)trx, sizeof(trx_t));
 	}
@@ -1651,16 +1652,18 @@
 }
 
 /**************************************************************************
-Prints info about a transaction to the standard output. The caller must
-own the kernel mutex and must have called
-innobase_mysql_prepare_print_arbitrary_thd(), unless he knows that MySQL or
-InnoDB cannot meanwhile change the info printed here. */
+Prints info about a transaction to the given file. The caller must own the
+kernel mutex and must have called
+innobase_mysql_prepare_print_arbitrary_thd(), unless he knows that MySQL
+or InnoDB cannot meanwhile change the info printed here. */
 
 void
 trx_print(
 /*======*/
-	FILE*	f,	/* in: output stream */
-	trx_t*	trx)	/* in: transaction */
+	FILE*	f,		/* in: output stream */
+	trx_t*	trx,		/* in: transaction */
+	uint	max_query_len)	/* in: max query length to print, or 0 to
+				   use the default max length */
 {
 	ibool	newline;
 
@@ -1755,7 +1758,7 @@
 	}
 
   	if (trx->mysql_thd != NULL) {
-		innobase_mysql_print_thd(f, trx->mysql_thd);
+		innobase_mysql_print_thd(f, trx->mysql_thd, max_query_len);
   	}  
 }
 

--- 1.240/sql/ha_innodb.cc	2005-08-10 17:36:03 +03:00
+++ 1.241/sql/ha_innodb.cc	2005-08-12 11:29:57 +03:00
@@ -550,19 +550,20 @@
 }
 
 /*****************************************************************
-Prints info of a THD object (== user session thread) to the
-standard output. NOTE that /mysql/innobase/trx/trx0trx.c must contain
-the prototype for this function! */
+Prints info of a THD object (== user session thread) to the given file.
+NOTE that /mysql/innobase/trx/trx0trx.c must contain the prototype for
+this function! */
 extern "C"
 void
 innobase_mysql_print_thd(
 /*=====================*/
-	FILE*   f,	/* in: output stream */
-        void*   input_thd)/* in: pointer to a MySQL THD object */
+	FILE*   f,		/* in: output stream */
+	void*   input_thd,	/* in: pointer to a MySQL THD object */
+	uint	max_query_len)	/* in: max query length to print, or 0 to
+				   use the default max length */
 {
 	const THD*	thd;
 	const char*	s;
-	char		buf[301];
 
         thd = (const THD*) input_thd;
 
@@ -589,25 +590,47 @@
 	}
 
 	if ((s = thd->query)) {
-		/* determine the length of the query string */
-		uint32 i, len;
+		/* 3100 is chosen because currently 3000 is the maximum
+		   max_query_len we ever give this. */
+		char	buf[3100];
+		uint	len;
+
+		/* If buf is too small, we dynamically allocate storage
+		   in this. */
+		char*	dyn_str = NULL;
+
+		/* Points to buf or dyn_str. */
+		char*	str = buf;
+		
+		if (max_query_len == 0)
+		{
+			/* ADDITIONAL SAFETY: the default is to print at
+			   most 300 chars to reduce the probability of a
+			   seg fault if there is a race in
+			   thd->query_length in MySQL; after May 14, 2004
+			   probably no race any more, but better be
+			   safe */
+			max_query_len = 300;
+		}
 		
-		len = thd->query_length;
+		len = min(thd->query_length, max_query_len);
 
-		if (len > 300) {
-			len = 300;	/* ADDITIONAL SAFETY: print at most
-					300 chars to reduce the probability of
-					a seg fault if there is a race in
-					thd->query_length in MySQL; after
-					May 14, 2004 probably no race any more,
-					but better be safe */
+		if (len > (sizeof(buf) - 1))
+		{
+			dyn_str = my_malloc(len + 1, MYF(0));
+			str = dyn_str;
 		}
 
-                /* Use strmake to reduce the timeframe
-                   for a race, compared to fwrite() */
-		i= (uint) (strmake(buf, s, len) - buf);
+                /* Use strmake to reduce the timeframe for a race,
+                   compared to fwrite() */
+		len = (uint) (strmake(str, s, len) - str);
 		putc('\n', f);
-		fwrite(buf, 1, i, f);
+		fwrite(str, 1, len, f);
+
+		if (dyn_str)
+		{
+			my_free(dyn_str, MYF(0));
+		}
 	}
 
 	putc('\n', f);
Thread
bk commit into 5.0 tree (osku:1.1978) BUG#7819Osku Salerma12 Aug