Commit 1bbd0b5b authored by Satya B's avatar Satya B

Applying InnoDB snapshot 5.1-ss6242, part 1. Fixes BUG#32430

1. BUG#32430 - 'show innodb status' causes errors Invalid (old?) table
               or database name in logs

2. White space fixup

Detailed revision comments:

r6136 | marko | 2009-11-04 12:28:10 +0200 (Wed, 04 Nov 2009) | 15 lines
branches/5.1: Port r6134 from branches/zip:

  ------------------------------------------------------------------------
  r6134 | marko | 2009-11-04 07:57:29 +0000 (Wed, 04 Nov 2009) | 5 lines

  branches/zip: innobase_convert_identifier(): Convert table names with
  explain_filename() to address Bug #32430: 'show innodb status'
  causes errors Invalid (old?) table or database name in logs.

  rb://134 approved by Sunny Bains
  ------------------------------------------------------------------------

innobase_print_identifier(): Replace with innobase_convert_name().

innobase_convert_identifier(): New function, called by innobase_convert_name().
r6152 | vasil | 2009-11-10 15:30:20 +0200 (Tue, 10 Nov 2009) | 4 lines
branches/5.1:

White space fixup.
parent f1f86ab0
......@@ -1499,70 +1499,148 @@ innobase_invalidate_query_cache(
#endif
}
/*********************************************************************
Display an SQL identifier. */
extern "C"
void
innobase_print_identifier(
/*======================*/
FILE* f, /* in: output stream */
trx_t* trx, /* in: transaction */
ibool table_id,/* in: TRUE=print a table name,
FALSE=print other identifier */
const char* name, /* in: name to print */
ulint namelen)/* in: length of name */
{
const char* s = name;
char* qname = NULL;
/*****************************************************************//**
Convert an SQL identifier to the MySQL system_charset_info (UTF-8)
and quote it if needed.
@return pointer to the end of buf */
static
char*
innobase_convert_identifier(
/*========================*/
char* buf, /*!< out: buffer for converted identifier */
ulint buflen, /*!< in: length of buf, in bytes */
const char* id, /*!< in: identifier to convert */
ulint idlen, /*!< in: length of id, in bytes */
void* thd, /*!< in: MySQL connection thread, or NULL */
ibool file_id)/*!< in: TRUE=id is a table or database name;
FALSE=id is an UTF-8 string */
{
char nz[NAME_LEN + 1];
#if MYSQL_VERSION_ID >= 50141
char nz2[NAME_LEN + 1 + EXPLAIN_FILENAME_MAX_EXTRA_LENGTH];
#else /* MYSQL_VERSION_ID >= 50141 */
char nz2[NAME_LEN + 1 + sizeof srv_mysql50_table_name_prefix];
#endif /* MYSQL_VERSION_ID >= 50141 */
const char* s = id;
int q;
if (table_id) {
/* Decode the table name. The filename_to_tablename()
function expects a NUL-terminated string. The input and
output strings buffers must not be shared. The function
only produces more output when the name contains other
characters than [0-9A-Z_a-z]. */
char* temp_name = (char*) my_malloc((uint) namelen + 1, MYF(MY_WME));
uint qnamelen = (uint) (namelen
+ (1 + sizeof srv_mysql50_table_name_prefix));
if (file_id) {
/* Decode the table name. The MySQL function expects
a NUL-terminated string. The input and output strings
buffers must not be shared. */
if (temp_name) {
qname = (char*) my_malloc(qnamelen, MYF(MY_WME));
if (qname) {
memcpy(temp_name, name, namelen);
temp_name[namelen] = 0;
s = qname;
namelen = filename_to_tablename(temp_name,
qname, qnamelen);
}
my_free(temp_name, MYF(0));
}
if (UNIV_UNLIKELY(idlen > (sizeof nz) - 1)) {
idlen = (sizeof nz) - 1;
}
if (!trx || !trx->mysql_thd) {
memcpy(nz, id, idlen);
nz[idlen] = 0;
s = nz2;
#if MYSQL_VERSION_ID >= 50141
idlen = explain_filename((THD*) thd, nz, nz2, sizeof nz2,
EXPLAIN_PARTITIONS_AS_COMMENT);
goto no_quote;
#else /* MYSQL_VERSION_ID >= 50141 */
idlen = filename_to_tablename(nz, nz2, sizeof nz2);
#endif /* MYSQL_VERSION_ID >= 50141 */
}
/* See if the identifier needs to be quoted. */
if (UNIV_UNLIKELY(!thd)) {
q = '"';
} else {
q = get_quote_char_for_identifier((THD*) trx->mysql_thd,
s, (int) namelen);
q = get_quote_char_for_identifier((THD*) thd, s, (int) idlen);
}
if (q == EOF) {
fwrite(s, 1, namelen, f);
} else {
const char* e = s + namelen;
putc(q, f);
while (s < e) {
#if MYSQL_VERSION_ID >= 50141
no_quote:
#endif /* MYSQL_VERSION_ID >= 50141 */
if (UNIV_UNLIKELY(idlen > buflen)) {
idlen = buflen;
}
memcpy(buf, s, idlen);
return(buf + idlen);
}
/* Quote the identifier. */
if (buflen < 2) {
return(buf);
}
*buf++ = q;
buflen--;
for (; idlen; idlen--) {
int c = *s++;
if (c == q) {
putc(c, f);
if (UNIV_UNLIKELY(c == q)) {
if (UNIV_UNLIKELY(buflen < 3)) {
break;
}
putc(c, f);
*buf++ = c;
*buf++ = c;
buflen -= 2;
} else {
if (UNIV_UNLIKELY(buflen < 2)) {
break;
}
*buf++ = c;
buflen--;
}
putc(q, f);
}
my_free(qname, MYF(MY_ALLOW_ZERO_PTR));
*buf++ = q;
return(buf);
}
/*****************************************************************//**
Convert a table or index name to the MySQL system_charset_info (UTF-8)
and quote it if needed.
@return pointer to the end of buf */
extern "C"
char*
innobase_convert_name(
/*==================*/
char* buf, /*!< out: buffer for converted identifier */
ulint buflen, /*!< in: length of buf, in bytes */
const char* id, /*!< in: identifier to convert */
ulint idlen, /*!< in: length of id, in bytes */
void* thd, /*!< in: MySQL connection thread, or NULL */
ibool table_id)/*!< in: TRUE=id is a table or database name;
FALSE=id is an index name */
{
char* s = buf;
const char* bufend = buf + buflen;
if (table_id) {
const char* slash = (const char*) memchr(id, '/', idlen);
if (!slash) {
goto no_db_name;
}
/* Print the database name and table name separately. */
s = innobase_convert_identifier(s, bufend - s, id, slash - id,
thd, TRUE);
if (UNIV_LIKELY(s < bufend)) {
*s++ = '.';
s = innobase_convert_identifier(s, bufend - s,
slash + 1, idlen
- (slash - id) - 1,
thd, TRUE);
}
} else {
no_db_name:
s = innobase_convert_identifier(buf, buflen, id, idlen,
thd, table_id);
}
return(s);
}
/**************************************************************************
......@@ -8194,8 +8272,7 @@ innobase_xa_prepare(
executing XA PREPARE and XA COMMIT commands.
In this case we cannot know how many minutes or hours
will be between XA PREPARE and XA COMMIT, and we don't want
to block for undefined period of time.
*/
to block for undefined period of time. */
pthread_mutex_lock(&prepare_commit_mutex);
trx->active_trans = 2;
}
......
......@@ -24,18 +24,21 @@ innobase_convert_string(
CHARSET_INFO* from_cs,
uint* errors);
/*********************************************************************
Display an SQL identifier. */
/*****************************************************************//**
Convert a table or index name to the MySQL system_charset_info (UTF-8)
and quote it if needed.
@return pointer to the end of buf */
void
innobase_print_identifier(
/*======================*/
FILE* f, /* in: output stream */
trx_t* trx, /* in: transaction */
ibool table_id,/* in: TRUE=print a table name,
FALSE=print other identifier */
const char* name, /* in: name to print */
ulint namelen);/* in: length of name */
char*
innobase_convert_name(
/*==================*/
char* buf, /*!< out: buffer for converted identifier */
ulint buflen, /*!< in: length of buf, in bytes */
const char* id, /*!< in: identifier to convert */
ulint idlen, /*!< in: length of id, in bytes */
void* thd, /*!< in: MySQL connection thread, or NULL */
ibool table_id);/*!< in: TRUE=id is a table or database name;
FALSE=id is an index name */
/**********************************************************************
Returns true if the thread is the replication thread on the slave
......
......@@ -19,6 +19,7 @@ Created 5/11/1994 Heikki Tuuri
#include "ut0sort.h"
#include "trx0trx.h"
#include "ha_prototypes.h"
#include "mysql_com.h" /* NAME_LEN */
ibool ut_always_false = FALSE;
......@@ -484,26 +485,17 @@ ut_print_namel(
const char* name, /* in: name to print */
ulint namelen)/* in: length of name */
{
#ifdef UNIV_HOTBACKUP
fwrite(name, 1, namelen, f);
#else
if (table_id) {
char* slash = memchr(name, '/', namelen);
if (!slash) {
/* 2 * NAME_LEN for database and table name,
and some slack for the #mysql50# prefix and quotes */
char buf[3 * NAME_LEN];
const char* bufend;
goto no_db_name;
}
bufend = innobase_convert_name(buf, sizeof buf,
name, namelen,
trx ? trx->mysql_thd : NULL,
table_id);
/* Print the database name and table name separately. */
innobase_print_identifier(f, trx, TRUE, name, slash - name);
putc('.', f);
innobase_print_identifier(f, trx, TRUE, slash + 1,
namelen - (slash - name) - 1);
} else {
no_db_name:
innobase_print_identifier(f, trx, table_id, name, namelen);
}
#endif
fwrite(buf, 1, bufend - buf, f);
}
/**************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment