mirror of
https://github.com/MariaDB/server.git
synced 2025-12-03 05:41:09 +03:00
Manual merge from mysql-next-mr.
Conflicts: - sql/sql_yacc.yy
This commit is contained in:
174
sql/sql_parse.cc
174
sql/sql_parse.cc
@@ -263,8 +263,6 @@ void init_update_queries(void)
|
||||
sql_command_flags[SQLCOM_CREATE_DB]= CF_CHANGES_DATA;
|
||||
sql_command_flags[SQLCOM_DROP_DB]= CF_CHANGES_DATA;
|
||||
sql_command_flags[SQLCOM_RENAME_TABLE]= CF_CHANGES_DATA;
|
||||
sql_command_flags[SQLCOM_BACKUP_TABLE]= CF_CHANGES_DATA;
|
||||
sql_command_flags[SQLCOM_RESTORE_TABLE]= CF_CHANGES_DATA;
|
||||
sql_command_flags[SQLCOM_DROP_INDEX]= CF_CHANGES_DATA;
|
||||
sql_command_flags[SQLCOM_CREATE_VIEW]= CF_CHANGES_DATA | CF_REEXECUTION_FRAGILE;
|
||||
sql_command_flags[SQLCOM_DROP_VIEW]= CF_CHANGES_DATA;
|
||||
@@ -624,72 +622,6 @@ void cleanup_items(Item *item)
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
/**
|
||||
Handle COM_TABLE_DUMP command.
|
||||
|
||||
@param thd thread handle
|
||||
@param db database name or an empty string. If empty,
|
||||
the current database of the connection is used
|
||||
@param tbl_name name of the table to dump
|
||||
|
||||
@note
|
||||
This function is written to handle one specific command only.
|
||||
|
||||
@retval
|
||||
0 success
|
||||
@retval
|
||||
1 error, the error message is set in THD
|
||||
*/
|
||||
|
||||
static
|
||||
int mysql_table_dump(THD *thd, LEX_STRING *db, char *tbl_name)
|
||||
{
|
||||
TABLE* table;
|
||||
TABLE_LIST* table_list;
|
||||
int error = 0;
|
||||
DBUG_ENTER("mysql_table_dump");
|
||||
if (db->length == 0)
|
||||
{
|
||||
db->str= thd->db; /* purecov: inspected */
|
||||
db->length= thd->db_length; /* purecov: inspected */
|
||||
}
|
||||
if (!(table_list = (TABLE_LIST*) thd->calloc(sizeof(TABLE_LIST))))
|
||||
DBUG_RETURN(1); // out of memory
|
||||
table_list->db= db->str;
|
||||
table_list->table_name= table_list->alias= tbl_name;
|
||||
table_list->lock_type= TL_READ_NO_INSERT;
|
||||
table_list->prev_global= &table_list; // can be removed after merge with 4.1
|
||||
|
||||
if (check_db_name(db))
|
||||
{
|
||||
/* purecov: begin inspected */
|
||||
my_error(ER_WRONG_DB_NAME ,MYF(0), db->str ? db->str : "NULL");
|
||||
goto err;
|
||||
/* purecov: end */
|
||||
}
|
||||
if (lower_case_table_names)
|
||||
my_casedn_str(files_charset_info, tbl_name);
|
||||
|
||||
if (!(table=open_ltable(thd, table_list, TL_READ_NO_INSERT, 0)))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
if (check_one_table_access(thd, SELECT_ACL, table_list))
|
||||
goto err;
|
||||
thd->free_list = 0;
|
||||
thd->set_query(tbl_name, (uint) strlen(tbl_name));
|
||||
if ((error = mysqld_dump_create_info(thd, table_list, -1)))
|
||||
{
|
||||
my_error(ER_GET_ERRNO, MYF(0), my_errno);
|
||||
goto err;
|
||||
}
|
||||
net_flush(&thd->net);
|
||||
if ((error= table->file->dump(thd,-1)))
|
||||
my_error(ER_GET_ERRNO, MYF(0), error);
|
||||
|
||||
err:
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
/**
|
||||
Ends the current transaction and (maybe) begin the next.
|
||||
|
||||
@@ -1034,40 +966,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case COM_TABLE_DUMP:
|
||||
{
|
||||
char *tbl_name;
|
||||
LEX_STRING db;
|
||||
/* Safe because there is always a trailing \0 at the end of the packet */
|
||||
uint db_len= *(uchar*) packet;
|
||||
if (db_len + 1 > packet_length || db_len > NAME_LEN)
|
||||
{
|
||||
my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
|
||||
break;
|
||||
}
|
||||
/* Safe because there is always a trailing \0 at the end of the packet */
|
||||
uint tbl_len= *(uchar*) (packet + db_len + 1);
|
||||
if (db_len + tbl_len + 2 > packet_length || tbl_len > NAME_LEN)
|
||||
{
|
||||
my_message(ER_UNKNOWN_COM_ERROR, ER(ER_UNKNOWN_COM_ERROR), MYF(0));
|
||||
break;
|
||||
}
|
||||
|
||||
status_var_increment(thd->status_var.com_other);
|
||||
thd->enable_slow_log= opt_log_slow_admin_statements;
|
||||
db.str= (char*) thd->alloc(db_len + tbl_len + 2);
|
||||
if (!db.str)
|
||||
{
|
||||
my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
|
||||
break;
|
||||
}
|
||||
db.length= db_len;
|
||||
tbl_name= strmake(db.str, packet + 1, db_len)+1;
|
||||
strmake(tbl_name, packet + db_len + 2, tbl_len);
|
||||
if (mysql_table_dump(thd, &db, tbl_name) == 0)
|
||||
thd->stmt_da->disable_status();
|
||||
break;
|
||||
}
|
||||
case COM_CHANGE_USER:
|
||||
{
|
||||
status_var_increment(thd->status_var.com_other);
|
||||
@@ -2355,30 +2253,6 @@ case SQLCOM_PREPARE:
|
||||
}
|
||||
#endif
|
||||
|
||||
case SQLCOM_BACKUP_TABLE:
|
||||
{
|
||||
DBUG_ASSERT(first_table == all_tables && first_table != 0);
|
||||
if (check_table_access(thd, SELECT_ACL, all_tables, FALSE, UINT_MAX, FALSE)
|
||||
|| check_global_access(thd, FILE_ACL))
|
||||
goto error; /* purecov: inspected */
|
||||
thd->enable_slow_log= opt_log_slow_admin_statements;
|
||||
res = mysql_backup_table(thd, first_table);
|
||||
select_lex->table_list.first= (uchar*) first_table;
|
||||
lex->query_tables=all_tables;
|
||||
break;
|
||||
}
|
||||
case SQLCOM_RESTORE_TABLE:
|
||||
{
|
||||
DBUG_ASSERT(first_table == all_tables && first_table != 0);
|
||||
if (check_table_access(thd, INSERT_ACL, all_tables, FALSE, UINT_MAX, FALSE)
|
||||
|| check_global_access(thd, FILE_ACL))
|
||||
goto error; /* purecov: inspected */
|
||||
thd->enable_slow_log= opt_log_slow_admin_statements;
|
||||
res = mysql_restore_table(thd, first_table);
|
||||
select_lex->table_list.first= (uchar*) first_table;
|
||||
lex->query_tables=all_tables;
|
||||
break;
|
||||
}
|
||||
case SQLCOM_ASSIGN_TO_KEYCACHE:
|
||||
{
|
||||
DBUG_ASSERT(first_table == all_tables && first_table != 0);
|
||||
@@ -2437,13 +2311,6 @@ case SQLCOM_PREPARE:
|
||||
break;
|
||||
}
|
||||
|
||||
case SQLCOM_LOAD_MASTER_DATA: // sync with master
|
||||
if (check_global_access(thd, SUPER_ACL))
|
||||
goto error;
|
||||
if (end_active_trans(thd))
|
||||
goto error;
|
||||
res = load_master_data(thd);
|
||||
break;
|
||||
#endif /* HAVE_REPLICATION */
|
||||
case SQLCOM_SHOW_ENGINE_STATUS:
|
||||
{
|
||||
@@ -2459,35 +2326,6 @@ case SQLCOM_PREPARE:
|
||||
res = ha_show_status(thd, lex->create_info.db_type, HA_ENGINE_MUTEX);
|
||||
break;
|
||||
}
|
||||
#ifdef HAVE_REPLICATION
|
||||
case SQLCOM_LOAD_MASTER_TABLE:
|
||||
{
|
||||
DBUG_ASSERT(first_table == all_tables && first_table != 0);
|
||||
DBUG_ASSERT(first_table->db); /* Must be set in the parser */
|
||||
|
||||
if (check_access(thd, CREATE_ACL, first_table->db,
|
||||
&first_table->grant.privilege, 0, 0,
|
||||
test(first_table->schema_table)))
|
||||
goto error; /* purecov: inspected */
|
||||
/* Check that the first table has CREATE privilege */
|
||||
if (check_grant(thd, CREATE_ACL, all_tables, FALSE, 1, FALSE))
|
||||
goto error;
|
||||
|
||||
pthread_mutex_lock(&LOCK_active_mi);
|
||||
/*
|
||||
fetch_master_table will send the error to the client on failure.
|
||||
Give error if the table already exists.
|
||||
*/
|
||||
if (!fetch_master_table(thd, first_table->db, first_table->table_name,
|
||||
active_mi, 0, 0))
|
||||
{
|
||||
my_ok(thd);
|
||||
}
|
||||
pthread_mutex_unlock(&LOCK_active_mi);
|
||||
break;
|
||||
}
|
||||
#endif /* HAVE_REPLICATION */
|
||||
|
||||
case SQLCOM_CREATE_TABLE:
|
||||
{
|
||||
/* If CREATE TABLE of non-temporary table, do implicit commit */
|
||||
@@ -3018,6 +2856,7 @@ end_with_restore_list:
|
||||
if (check_table_access(thd, SELECT_ACL, all_tables,
|
||||
FALSE, UINT_MAX, FALSE))
|
||||
goto error; /* purecov: inspected */
|
||||
|
||||
res = mysql_checksum_table(thd, first_table, &lex->check_opt);
|
||||
break;
|
||||
}
|
||||
@@ -6303,17 +6142,6 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum_field_types type,
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
if (type == MYSQL_TYPE_TIMESTAMP && length)
|
||||
{
|
||||
/* Display widths are no longer supported for TIMSTAMP as of MySQL 4.1.
|
||||
In other words, for declarations such as TIMESTAMP(2), TIMESTAMP(4),
|
||||
and so on, the display width is ignored.
|
||||
*/
|
||||
char buf[32];
|
||||
my_snprintf(buf, sizeof(buf), "TIMESTAMP(%s)", length);
|
||||
WARN_DEPRECATED(thd, "6.0", buf, "'TIMESTAMP'");
|
||||
}
|
||||
|
||||
if (!(new_field= new Create_field()) ||
|
||||
new_field->init(thd, field_name->str, type, length, decimals, type_modifier,
|
||||
default_value, on_update_value, comment, change,
|
||||
|
||||
Reference in New Issue
Block a user