Commit 8d54d173 authored by Marko Mäkelä's avatar Marko Mäkelä

Cleanup: Remove ut_format_name()

This follows up commit 383f77cd
which simplified dict_table_schema_check().

Note: We can display quoted names like this:
my_snprintf(buf, sizeof buf, "%`.*s.%`s",
            int(t->name.dblen()), t->name.m_name, t->name.basename());
parent 91a2192b
CREATE TABLE t (c INT) ENGINE=INNODB;
SET @save_dbug = @@debug_dbug;
SET debug_dbug = '+d,test_ut_format_name';
DROP TABLE t;
SET debug_dbug = @save_dbug;
#
# Test ut_format_name()
#
-- source include/have_debug.inc
-- source include/have_innodb.inc
CREATE TABLE t (c INT) ENGINE=INNODB;
# This will invoke test_ut_format_name() in debug builds
SET @save_dbug = @@debug_dbug;
SET debug_dbug = '+d,test_ut_format_name';
DROP TABLE t;
SET debug_dbug = @save_dbug;
......@@ -5413,67 +5413,6 @@ test_normalize_table_name_low()
}
}
}
/*********************************************************************
Test ut_format_name(). */
static
void
test_ut_format_name()
/*=================*/
{
char buf[NAME_LEN * 3];
struct {
const char* name;
ulint buf_size;
const char* expected;
} test_data[] = {
{"test/t1", sizeof(buf), "`test`.`t1`"},
{"test/t1", 12, "`test`.`t1`"},
{"test/t1", 11, "`test`.`t1"},
{"test/t1", 10, "`test`.`t"},
{"test/t1", 9, "`test`.`"},
{"test/t1", 8, "`test`."},
{"test/t1", 7, "`test`"},
{"test/t1", 6, "`test"},
{"test/t1", 5, "`tes"},
{"test/t1", 4, "`te"},
{"test/t1", 3, "`t"},
{"test/t1", 2, "`"},
{"test/t1", 1, ""},
{"test/t1", 0, "BUF_NOT_CHANGED"},
{"table", sizeof(buf), "`table`"},
{"ta'le", sizeof(buf), "`ta'le`"},
{"ta\"le", sizeof(buf), "`ta\"le`"},
{"ta`le", sizeof(buf), "`ta``le`"},
};
for (size_t i = 0; i < UT_ARR_SIZE(test_data); i++) {
memcpy(buf, "BUF_NOT_CHANGED", strlen("BUF_NOT_CHANGED") + 1);
char* ret;
ret = ut_format_name(test_data[i].name,
buf,
test_data[i].buf_size);
ut_a(ret == buf);
if (strcmp(buf, test_data[i].expected) == 0) {
ib::info() << "ut_format_name(" << test_data[i].name
<< ", buf, " << test_data[i].buf_size << "),"
" expected " << test_data[i].expected
<< ", OK";
} else {
ib::error() << "ut_format_name(" << test_data[i].name
<< ", buf, " << test_data[i].buf_size << "),"
" expected " << test_data[i].expected
<< ", ERROR: got " << buf;
ut_error;
}
}
}
#endif /* !DBUG_OFF */
/** Match index columns between MySQL and InnoDB.
......@@ -13470,7 +13409,6 @@ int ha_innobase::delete_table(const char *name)
DBUG_EXECUTE_IF("test_normalize_table_name_low",
test_normalize_table_name_low(););
DBUG_EXECUTE_IF("test_ut_format_name", test_ut_format_name(););
trx_t *parent_trx= check_trx_exists(thd);
dict_table_t *table;
......
......@@ -242,20 +242,6 @@ ut_print_name(
FILE* ef, /*!< in: stream */
const trx_t* trx, /*!< in: transaction */
const char* name); /*!< in: table name to print */
/** Format a table name, quoted as an SQL identifier.
If the name contains a slash '/', the result will contain two
identifiers separated by a period (.), as in SQL
database_name.table_name.
@see table_name_t
@param[in] name table or index name
@param[out] formatted formatted result, will be NUL-terminated
@param[in] formatted_size size of the buffer in bytes
@return pointer to 'formatted' */
char*
ut_format_name(
const char* name,
char* formatted,
ulint formatted_size);
/**********************************************************************//**
Catenate files. */
......
......@@ -258,47 +258,6 @@ ut_print_name(
}
}
/** Format a table name, quoted as an SQL identifier.
If the name contains a slash '/', the result will contain two
identifiers separated by a period (.), as in SQL
database_name.table_name.
@see table_name_t
@param[in] name table or index name
@param[out] formatted formatted result, will be NUL-terminated
@param[in] formatted_size size of the buffer in bytes
@return pointer to 'formatted' */
char*
ut_format_name(
const char* name,
char* formatted,
ulint formatted_size)
{
switch (formatted_size) {
case 1:
formatted[0] = '\0';
/* FALL-THROUGH */
case 0:
return(formatted);
}
char* end;
end = innobase_convert_name(formatted, formatted_size,
name, strlen(name), NULL);
/* If the space in 'formatted' was completely used, then sacrifice
the last character in order to write '\0' at the end. */
if ((ulint) (end - formatted) == formatted_size) {
end--;
}
ut_a((ulint) (end - formatted) < formatted_size);
*end = '\0';
return(formatted);
}
/**********************************************************************//**
Catenate files. */
void
......
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