summaryrefslogtreecommitdiff
path: root/sql/sql_show.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r--sql/sql_show.cc168
1 files changed, 87 insertions, 81 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 09fd982bdab..afe88167bab 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -490,22 +490,22 @@ bool mysqld_show_create_db(THD *thd, char *dbname,
protocol->prepare_for_resend();
protocol->store(dbname, strlen(dbname), system_charset_info);
buffer.length(0);
- buffer.append("CREATE DATABASE ", 16);
+ buffer.append(STRING_WITH_LEN("CREATE DATABASE "));
if (create_options & HA_LEX_CREATE_IF_NOT_EXISTS)
- buffer.append("/*!32312 IF NOT EXISTS*/ ", 25);
+ buffer.append(STRING_WITH_LEN("/*!32312 IF NOT EXISTS*/ "));
append_identifier(thd, &buffer, dbname, strlen(dbname));
if (create.default_table_charset)
{
- buffer.append(" /*!40100", 9);
- buffer.append(" DEFAULT CHARACTER SET ", 23);
+ buffer.append(STRING_WITH_LEN(" /*!40100"));
+ buffer.append(STRING_WITH_LEN(" DEFAULT CHARACTER SET "));
buffer.append(create.default_table_charset->csname);
if (!(create.default_table_charset->state & MY_CS_PRIMARY))
{
- buffer.append(" COLLATE ", 9);
+ buffer.append(STRING_WITH_LEN(" COLLATE "));
buffer.append(create.default_table_charset->name);
}
- buffer.append(" */", 3);
+ buffer.append(STRING_WITH_LEN(" */"));
}
protocol->store(buffer.ptr(), buffer.length(), buffer.charset());
@@ -716,7 +716,7 @@ static void append_directory(THD *thd, String *packet, const char *dir_type,
uint length= dirname_length(filename);
packet->append(' ');
packet->append(dir_type);
- packet->append(" DIRECTORY='", 12);
+ packet->append(STRING_WITH_LEN(" DIRECTORY='"));
#ifdef __WIN__
/* Convert \ to / to be able to create table on unix */
char *winfilename= (char*) thd->memdup(filename, length);
@@ -765,16 +765,16 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
restore_record(table, s->default_values); // Get empty record
if (share->tmp_table)
- packet->append("CREATE TEMPORARY TABLE ", 23);
+ packet->append(STRING_WITH_LEN("CREATE TEMPORARY TABLE "));
else
- packet->append("CREATE TABLE ", 13);
+ packet->append(STRING_WITH_LEN("CREATE TABLE "));
if (table_list->schema_table)
alias= table_list->schema_table->table_name;
else
alias= (lower_case_table_names == 2 ? table->alias :
share->table_name);
append_identifier(thd, packet, alias, strlen(alias));
- packet->append(" (\n", 3);
+ packet->append(STRING_WITH_LEN(" (\n"));
for (ptr=table->field ; (field= *ptr); ptr++)
{
@@ -783,9 +783,9 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
uint flags = field->flags;
if (ptr != table->field)
- packet->append(",\n", 2);
+ packet->append(STRING_WITH_LEN(",\n"));
- packet->append(" ", 2);
+ packet->append(STRING_WITH_LEN(" "));
append_identifier(thd,packet,field->field_name, strlen(field->field_name));
packet->append(' ');
// check for surprises from the previous call to Field::sql_type()
@@ -802,7 +802,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
{
if (field->charset() != share->table_charset)
{
- packet->append(" character set ", 15);
+ packet->append(STRING_WITH_LEN(" character set "));
packet->append(field->charset()->csname);
}
/*
@@ -811,20 +811,20 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
*/
if (!(field->charset()->state & MY_CS_PRIMARY))
{
- packet->append(" collate ", 9);
+ packet->append(STRING_WITH_LEN(" collate "));
packet->append(field->charset()->name);
}
}
if (flags & NOT_NULL_FLAG)
- packet->append(" NOT NULL", 9);
+ packet->append(STRING_WITH_LEN(" NOT NULL"));
else if (field->type() == FIELD_TYPE_TIMESTAMP)
{
/*
TIMESTAMP field require explicit NULL flag, because unlike
all other fields they are treated as NOT NULL by default.
*/
- packet->append(" NULL", 5);
+ packet->append(STRING_WITH_LEN(" NULL"));
}
/*
@@ -842,9 +842,9 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
if (has_default)
{
- packet->append(" default ", 9);
+ packet->append(STRING_WITH_LEN(" default "));
if (has_now_default)
- packet->append("CURRENT_TIMESTAMP",17);
+ packet->append(STRING_WITH_LEN("CURRENT_TIMESTAMP"));
else if (!field->is_null())
{ // Not null by default
type.set(tmp, sizeof(tmp), field->charset());
@@ -859,10 +859,10 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
append_unescaped(packet, def_val.ptr(), def_val.length());
}
else
- packet->append("''",2);
+ packet->append(STRING_WITH_LEN("''"));
}
else if (field->maybe_null())
- packet->append("NULL", 4); // Null as default
+ packet->append(STRING_WITH_LEN("NULL")); // Null as default
else
packet->append(tmp);
}
@@ -870,15 +870,15 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
if (!(thd->variables.sql_mode & MODE_NO_FIELD_OPTIONS) &&
table->timestamp_field == field &&
field->unireg_check != Field::TIMESTAMP_DN_FIELD)
- packet->append(" on update CURRENT_TIMESTAMP",28);
+ packet->append(STRING_WITH_LEN(" on update CURRENT_TIMESTAMP"));
if (field->unireg_check == Field::NEXT_NUMBER &&
!(thd->variables.sql_mode & MODE_NO_FIELD_OPTIONS))
- packet->append(" auto_increment", 15 );
+ packet->append(STRING_WITH_LEN(" auto_increment"));
if (field->comment.length)
{
- packet->append(" COMMENT ",9);
+ packet->append(STRING_WITH_LEN(" COMMENT "));
append_unescaped(packet, field->comment.str, field->comment.length);
}
}
@@ -893,20 +893,20 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
{
KEY_PART_INFO *key_part= key_info->key_part;
bool found_primary=0;
- packet->append(",\n ", 4);
+ packet->append(STRING_WITH_LEN(",\n "));
if (i == primary_key && !strcmp(key_info->name, primary_key_name))
{
found_primary=1;
- packet->append("PRIMARY ", 8);
+ packet->append(STRING_WITH_LEN("PRIMARY "));
}
else if (key_info->flags & HA_NOSAME)
- packet->append("UNIQUE ", 7);
+ packet->append(STRING_WITH_LEN("UNIQUE "));
else if (key_info->flags & HA_FULLTEXT)
- packet->append("FULLTEXT ", 9);
+ packet->append(STRING_WITH_LEN("FULLTEXT "));
else if (key_info->flags & HA_SPATIAL)
- packet->append("SPATIAL ", 8);
- packet->append("KEY ", 4);
+ packet->append(STRING_WITH_LEN("SPATIAL "));
+ packet->append(STRING_WITH_LEN("KEY "));
if (!found_primary)
append_identifier(thd, packet, key_info->name, strlen(key_info->name));
@@ -915,19 +915,19 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
!limited_mysql_mode && !foreign_db_mode)
{
if (key_info->algorithm == HA_KEY_ALG_BTREE)
- packet->append(" USING BTREE", 12);
+ packet->append(STRING_WITH_LEN(" USING BTREE"));
if (key_info->algorithm == HA_KEY_ALG_HASH)
- packet->append(" USING HASH", 11);
+ packet->append(STRING_WITH_LEN(" USING HASH"));
// +BAR: send USING only in non-default case: non-spatial rtree
if ((key_info->algorithm == HA_KEY_ALG_RTREE) &&
!(key_info->flags & HA_SPATIAL))
- packet->append(" USING RTREE", 12);
+ packet->append(STRING_WITH_LEN(" USING RTREE"));
// No need to send USING FULLTEXT, it is sent as FULLTEXT KEY
}
- packet->append(" (", 2);
+ packet->append(STRING_WITH_LEN(" ("));
for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
{
@@ -964,71 +964,71 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
file->free_foreign_key_create_info(for_str);
}
- packet->append("\n)", 2);
+ packet->append(STRING_WITH_LEN("\n)"));
if (!(thd->variables.sql_mode & MODE_NO_TABLE_OPTIONS) && !foreign_db_mode)
{
if (thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40))
- packet->append(" TYPE=", 6);
+ packet->append(STRING_WITH_LEN(" TYPE="));
else
- packet->append(" ENGINE=", 8);
+ packet->append(STRING_WITH_LEN(" ENGINE="));
packet->append(file->table_type());
if (share->table_charset &&
!(thd->variables.sql_mode & MODE_MYSQL323) &&
!(thd->variables.sql_mode & MODE_MYSQL40))
{
- packet->append(" DEFAULT CHARSET=", 17);
+ packet->append(STRING_WITH_LEN(" DEFAULT CHARSET="));
packet->append(share->table_charset->csname);
if (!(share->table_charset->state & MY_CS_PRIMARY))
{
- packet->append(" COLLATE=", 9);
+ packet->append(STRING_WITH_LEN(" COLLATE="));
packet->append(table->s->table_charset->name);
}
}
if (share->min_rows)
{
- packet->append(" MIN_ROWS=", 10);
+ packet->append(STRING_WITH_LEN(" MIN_ROWS="));
end= longlong10_to_str(share->min_rows, buff, 10);
packet->append(buff, (uint) (end- buff));
}
if (share->max_rows && !table_list->schema_table)
{
- packet->append(" MAX_ROWS=", 10);
+ packet->append(STRING_WITH_LEN(" MAX_ROWS="));
end= longlong10_to_str(share->max_rows, buff, 10);
packet->append(buff, (uint) (end - buff));
}
if (share->avg_row_length)
{
- packet->append(" AVG_ROW_LENGTH=", 16);
+ packet->append(STRING_WITH_LEN(" AVG_ROW_LENGTH="));
end= longlong10_to_str(share->avg_row_length, buff,10);
packet->append(buff, (uint) (end - buff));
}
if (share->db_create_options & HA_OPTION_PACK_KEYS)
- packet->append(" PACK_KEYS=1", 12);
+ packet->append(STRING_WITH_LEN(" PACK_KEYS=1"));
if (share->db_create_options & HA_OPTION_NO_PACK_KEYS)
- packet->append(" PACK_KEYS=0", 12);
+ packet->append(STRING_WITH_LEN(" PACK_KEYS=0"));
if (share->db_create_options & HA_OPTION_CHECKSUM)
- packet->append(" CHECKSUM=1", 11);
+ packet->append(STRING_WITH_LEN(" CHECKSUM=1"));
if (share->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
- packet->append(" DELAY_KEY_WRITE=1",18);
+ packet->append(STRING_WITH_LEN(" DELAY_KEY_WRITE=1"));
if (share->row_type != ROW_TYPE_DEFAULT)
{
- packet->append(" ROW_FORMAT=",12);
+ packet->append(STRING_WITH_LEN(" ROW_FORMAT="));
packet->append(ha_row_type[(uint) share->row_type]);
}
table->file->append_create_info(packet);
if (share->comment && share->comment[0])
{
- packet->append(" COMMENT=", 9);
+ packet->append(STRING_WITH_LEN(" COMMENT="));
append_unescaped(packet, share->comment, strlen(share->comment));
}
if (share->connect_string.length)
{
- packet->append(" CONNECTION=", 12);
+ packet->append(STRING_WITH_LEN(" CONNECTION="));
append_unescaped(packet, share->connect_string.str, share->connect_string.length);
}
if (file->raid_type)
@@ -1049,25 +1049,25 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
void
view_store_options(THD *thd, TABLE_LIST *table, String *buff)
{
- buff->append("ALGORITHM=", 10);
+ buff->append(STRING_WITH_LEN("ALGORITHM="));
switch ((int8)table->algorithm) {
case VIEW_ALGORITHM_UNDEFINED:
- buff->append("UNDEFINED ", 10);
+ buff->append(STRING_WITH_LEN("UNDEFINED "));
break;
case VIEW_ALGORITHM_TMPTABLE:
- buff->append("TEMPTABLE ", 10);
+ buff->append(STRING_WITH_LEN("TEMPTABLE "));
break;
case VIEW_ALGORITHM_MERGE:
- buff->append("MERGE ", 6);
+ buff->append(STRING_WITH_LEN("MERGE "));
break;
default:
DBUG_ASSERT(0); // never should happen
}
append_definer(thd, buff, &table->definer.user, &table->definer.host);
if (table->view_suid)
- buff->append("SQL SECURITY DEFINER ", 21);
+ buff->append(STRING_WITH_LEN("SQL SECURITY DEFINER "));
else
- buff->append("SQL SECURITY INVOKER ", 21);
+ buff->append(STRING_WITH_LEN("SQL SECURITY INVOKER "));
}
@@ -1125,19 +1125,19 @@ view_store_create_info(THD *thd, TABLE_LIST *table, String *buff)
}
}
- buff->append("CREATE ", 7);
+ buff->append(STRING_WITH_LEN("CREATE "));
if (!foreign_db_mode)
{
view_store_options(thd, table, buff);
}
- buff->append("VIEW ", 5);
+ buff->append(STRING_WITH_LEN("VIEW "));
if (!table->compact_view_format)
{
append_identifier(thd, buff, table->view_db.str, table->view_db.length);
buff->append('.');
}
append_identifier(thd, buff, table->view_name.str, table->view_name.length);
- buff->append(" AS ", 4);
+ buff->append(STRING_WITH_LEN(" AS "));
/*
We can't just use table->query, because our SQL_MODE may trigger
@@ -1148,9 +1148,9 @@ view_store_create_info(THD *thd, TABLE_LIST *table, String *buff)
if (table->with_check != VIEW_CHECK_NONE)
{
if (table->with_check == VIEW_CHECK_LOCAL)
- buff->append(" WITH LOCAL CHECK OPTION", 24);
+ buff->append(STRING_WITH_LEN(" WITH LOCAL CHECK OPTION"));
else
- buff->append(" WITH CASCADED CHECK OPTION", 27);
+ buff->append(STRING_WITH_LEN(" WITH CASCADED CHECK OPTION"));
}
return 0;
}
@@ -2134,20 +2134,24 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
{
if (with_i_schema)
{
- table->field[3]->store("SYSTEM VIEW", 11, system_charset_info);
+ table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"),
+ system_charset_info);
}
else
{
my_snprintf(end, len, "/%s%s", file_name, reg_ext);
switch (mysql_frm_type(thd, path, &not_used)) {
case FRMTYPE_ERROR:
- table->field[3]->store("ERROR", 5, system_charset_info);
+ table->field[3]->store(STRING_WITH_LEN("ERROR"),
+ system_charset_info);
break;
case FRMTYPE_TABLE:
- table->field[3]->store("BASE TABLE", 10, system_charset_info);
+ table->field[3]->store(STRING_WITH_LEN("BASE TABLE"),
+ system_charset_info);
break;
case FRMTYPE_VIEW:
- table->field[3]->store("VIEW", 4, system_charset_info);
+ table->field[3]->store(STRING_WITH_LEN("VIEW"),
+ system_charset_info);
break;
default:
DBUG_ASSERT(0);
@@ -2300,8 +2304,8 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables,
}
else if (tables->view)
{
- table->field[3]->store("VIEW", 4, cs);
- table->field[20]->store("VIEW", 4, cs);
+ table->field[3]->store(STRING_WITH_LEN("VIEW"), cs);
+ table->field[20]->store(STRING_WITH_LEN("VIEW"), cs);
}
else
{
@@ -2312,11 +2316,11 @@ static int get_schema_tables_record(THD *thd, struct st_table_list *tables,
file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO |
HA_STATUS_NO_LOCK);
if (share->tmp_table == SYSTEM_TMP_TABLE)
- table->field[3]->store("SYSTEM VIEW", 11, cs);
+ table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs);
else if (share->tmp_table)
- table->field[3]->store("LOCAL TEMPORARY", 15, cs);
+ table->field[3]->store(STRING_WITH_LEN("LOCAL TEMPORARY"), cs);
else
- table->field[3]->store("BASE TABLE", 10, cs);
+ table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs);
for (int i= 4; i < 20; i++)
{
@@ -2552,7 +2556,7 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables,
if (show_table->timestamp_field == field &&
field->unireg_check != Field::TIMESTAMP_UN_FIELD)
{
- table->field[5]->store("CURRENT_TIMESTAMP", 17, cs);
+ table->field[5]->store(STRING_WITH_LEN("CURRENT_TIMESTAMP"), cs);
table->field[5]->set_notnull();
}
else if (field->unireg_check != Field::NEXT_NUMBER &&
@@ -2814,8 +2818,8 @@ bool store_schema_proc(THD *thd, TABLE *table, TABLE *proc_table,
get_field(thd->mem_root, proc_table->field[10], &tmp_string);
table->field[7]->store(tmp_string.ptr(), tmp_string.length(), cs);
}
- table->field[6]->store("SQL", 3, cs);
- table->field[10]->store("SQL", 3, cs);
+ table->field[6]->store(STRING_WITH_LEN("SQL"), cs);
+ table->field[10]->store(STRING_WITH_LEN("SQL"), cs);
get_field(thd->mem_root, proc_table->field[6], &tmp_string);
table->field[11]->store(tmp_string.ptr(), tmp_string.length(), cs);
table->field[12]->store(sp_data_access_name[enum_idx].str,
@@ -2970,7 +2974,7 @@ static int get_schema_stat_record(THD *thd, struct st_table_list *tables,
pos= show_table->file->index_type(i);
table->field[13]->store(pos, strlen(pos), cs);
if (!show_table->s->keys_in_use.is_set(i))
- table->field[14]->store("disabled", 8, cs);
+ table->field[14]->store(STRING_WITH_LEN("disabled"), cs);
else
table->field[14]->store("", 0, cs);
table->field[14]->set_notnull();
@@ -3083,13 +3087,15 @@ static int get_schema_constraints_record(THD *thd, struct st_table_list *tables,
if (i == primary_key && !strcmp(key_info->name, primary_key_name))
{
if (store_constraints(thd, table, base_name, file_name, key_info->name,
- strlen(key_info->name), "PRIMARY KEY", 11))
+ strlen(key_info->name),
+ STRING_WITH_LEN("PRIMARY KEY")))
DBUG_RETURN(1);
}
else if (key_info->flags & HA_NOSAME)
{
if (store_constraints(thd, table, base_name, file_name, key_info->name,
- strlen(key_info->name), "UNIQUE", 6))
+ strlen(key_info->name),
+ STRING_WITH_LEN("UNIQUE")))
DBUG_RETURN(1);
}
}
@@ -3130,11 +3136,11 @@ static bool store_trigger(THD *thd, TABLE *table, const char *db,
table->field[5]->store(db, strlen(db), cs);
table->field[6]->store(tname, strlen(tname), cs);
table->field[9]->store(trigger_stmt->str, trigger_stmt->length, cs);
- table->field[10]->store("ROW", 3, cs);
+ table->field[10]->store(STRING_WITH_LEN("ROW"), cs);
table->field[11]->store(trg_action_time_type_names[timing].str,
trg_action_time_type_names[timing].length, cs);
- table->field[14]->store("OLD", 3, cs);
- table->field[15]->store("NEW", 3, cs);
+ table->field[14]->store(STRING_WITH_LEN("OLD"), cs);
+ table->field[15]->store(STRING_WITH_LEN("NEW"), cs);
sql_mode_str=
sys_var_thd_sql_mode::symbolic_mode_representation(thd,
@@ -3525,9 +3531,9 @@ int make_schemata_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
buffer.append(field_info->old_name);
if (lex->wild && lex->wild->ptr())
{
- buffer.append(" (");
+ buffer.append(STRING_WITH_LEN(" ("));
buffer.append(lex->wild->ptr());
- buffer.append(")");
+ buffer.append(')');
}
field->set_name(buffer.ptr(), buffer.length(), system_charset_info);
}
@@ -3548,9 +3554,9 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table)
buffer.append(lex->select_lex.db);
if (lex->wild && lex->wild->ptr())
{
- buffer.append(" (");
+ buffer.append(STRING_WITH_LEN(" ("));
buffer.append(lex->wild->ptr());
- buffer.append(")");
+ buffer.append(')');
}
Item_field *field= new Item_field(context,
NullS, NullS, field_info->field_name);