mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Merge mysql.com:/home/my/mysql-5.1
into mysql.com:/home/my/mysql-new BitKeeper/etc/ignore: auto-union BUILD/SETUP.sh: Auto merged CMakeLists.txt: Auto merged client/get_password.c: Auto merged client/mysqldump.c: Auto merged client/mysqltest.c: Auto merged cmd-line-utils/readline/bind.c: Auto merged cmd-line-utils/readline/display.c: Auto merged cmd-line-utils/readline/histexpand.c: Auto merged cmd-line-utils/readline/history.c: Auto merged cmd-line-utils/readline/readline.c: Auto merged cmd-line-utils/readline/text.c: Auto merged dbug/user.r: Auto merged extra/yassl/src/handshake.cpp: Auto merged include/config-win.h: Auto merged include/m_string.h: Auto merged include/my_global.h: Auto merged include/my_pthread.h: Auto merged include/mysql/plugin.h: Auto merged include/mysql_com.h: Auto merged include/thr_alarm.h: Auto merged libmysql/CMakeLists.txt: Auto merged libmysql/Makefile.shared: Auto merged libmysql/dll.c: Auto merged libmysql/get_password.c: Auto merged libmysql/libmysql.c: Auto merged libmysqld/Makefile.am: Auto merged mysql-test/lib/mtr_cases.pl: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/r/alter_table.result: Auto merged mysql-test/r/change_user.result: Auto merged mysql-test/r/create.result: Auto merged mysql-test/r/innodb.result: Auto merged mysql-test/r/merge.result: Auto merged mysql-test/r/mix2_myisam.result: Auto merged mysql-test/r/mysqldump.result: Auto merged mysql-test/r/query_cache.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/valgrind.supp: Auto merged mysql-test/r/view.result: Auto merged mysql-test/suite/rpl/r/rpl_events.result: Auto merged mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test: Auto merged mysql-test/t/create.test: Auto merged mysql-test/t/mysqldump.test: Auto merged mysql-test/t/query_cache.test: Auto merged mysql-test/t/subselect.test: Auto merged mysql-test/t/variables.test: Auto merged mysql-test/t/view.test: Auto merged mysys/mf_iocache.c: Auto merged mysys/mf_tempfile.c: Auto merged mysys/my_atomic.c: Auto merged mysys/my_bit.c: Auto merged mysys/my_bitmap.c: Auto merged mysys/my_compress.c: Auto merged mysys/my_create.c: Auto merged mysys/my_delete.c: Auto merged mysys/my_error.c: Auto merged mysys/my_init.c: Auto merged mysys/my_open.c: Auto merged mysys/my_realloc.c: Auto merged mysys/my_rename.c: Auto merged mysys/my_symlink.c: Auto merged mysys/my_sync.c: Auto merged mysys/my_thr_init.c: Auto merged mysys/thr_alarm.c: Auto merged mysys/thr_lock.c: Auto merged scripts/make_binary_distribution.sh: Auto merged server-tools/instance-manager/mysql_connection.cc: Auto merged sql/CMakeLists.txt: Auto merged sql/Makefile.am: Auto merged sql/events.cc: Auto merged sql/field.cc: Auto merged sql/field.h: Auto merged sql/filesort.cc: Auto merged sql/gen_lex_hash.cc: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/ha_partition.h: Auto merged sql/handler.h: Auto merged sql/item.cc: Auto merged sql/item.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_strfunc.cc: Auto merged sql/item_strfunc.h: Auto merged sql/item_subselect.cc: Auto merged sql/lock.cc: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/net_serv.cc: Auto merged sql/opt_range.cc: Auto merged sql/partition_info.cc: Auto merged sql/rpl_injector.cc: Auto merged sql/set_var.cc: Auto merged sql/slave.cc: Auto merged sql/slave.h: Auto merged sql/sp_head.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_delete.cc: Auto merged sql/sql_load.cc: Auto merged sql/sql_plugin.cc: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_test.cc: Auto merged sql/sql_union.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.cc: Auto merged sql/table.h: Auto merged sql/unireg.cc: Auto merged sql/share/errmsg.txt: Auto merged storage/csv/ha_tina.cc: Auto merged storage/csv/ha_tina.h: Auto merged storage/myisam/CMakeLists.txt: Auto merged storage/myisam/ft_boolean_search.c: Auto merged storage/myisam/ft_eval.c: Auto merged storage/myisam/ft_nlq_search.c: Auto merged storage/myisam/ft_parser.c: Auto merged storage/myisam/ft_static.c: Auto merged storage/myisam/ft_stopwords.c: Auto merged storage/myisam/ft_test1.c: Auto merged storage/myisam/ft_update.c: Auto merged storage/myisam/ha_myisam.cc: Auto merged storage/myisam/mi_check.c: Auto merged storage/myisam/mi_create.c: Auto merged storage/myisam/mi_delete.c: Auto merged storage/myisam/mi_delete_all.c: Auto merged storage/myisam/mi_dynrec.c: Auto merged storage/myisam/mi_key.c: Auto merged storage/myisam/mi_packrec.c: Auto merged storage/myisam/mi_range.c: Auto merged storage/myisam/mi_search.c: Auto merged storage/myisam/mi_test1.c: Auto merged storage/myisam/mi_test2.c: Auto merged storage/myisam/mi_test3.c: Auto merged storage/myisam/mi_unique.c: Auto merged storage/myisam/mi_write.c: Auto merged storage/myisam/myisamchk.c: Auto merged storage/myisam/myisamdef.h: Auto merged storage/myisam/myisampack.c: Auto merged storage/myisam/sort.c: Auto merged storage/myisam/sp_test.c: Auto merged support-files/mysql.spec.sh: Auto merged tests/mysql_client_test.c: Auto merged configure.in: Manual merge dbug/dbug.c: Restore to original state in Maria tree The big diff comes from a wrong pull from 5.0 -> 5.1 after backporting dbug to 5.0 from 5.1 include/Makefile.am: Manual merge include/my_atomic.h: Ignore changes include/my_base.h: Manual merge include/my_dbug.h: Use orginal my_dbug.h from maria tree include/my_handler.h: Manual merge include/my_sys.h: Manual merge include/myisam.h: Manual merge mysql-test/lib/mtr_report.pl: Manual merge mysql-test/r/myisam.result: Manual merge mysql-test/suite/binlog/r/binlog_unsafe.result: Manual merge mysql-test/suite/binlog/t/binlog_unsafe.test: Manual merge mysql-test/suite/rpl/r/rpl_row_flsh_tbls.result: Manual merge mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result: No changes mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test: Manual merge mysql-test/t/change_user.test: Manual merge mysql-test/t/disabled.def: Manual merge mysql-test/t/merge.test: No changes mysql-test/t/myisam.test: Manual merge mysys/Makefile.am: Manual merge mysys/array.c: Manual merge mysys/mf_keycache.c: Manual merge mysys/my_getsystime.c: Manual merge mysys/my_handler.c: Manual merge mysys/my_pread.c: Manual merge mysys/safemalloc.c: Manual merge sql/ha_partition.cc: Manual merge sql/handler.cc: Manual merge sql/lex.h: Manual merge sql/mysql_priv.h: Manual merge sql/mysqld.cc: Manual merge sql/set_var.h: Manual merge sql/sql_class.cc: Manual merge sql/sql_insert.cc: Manual merge sql/sql_parse.cc: Manual merge sql/sql_select.cc: Manual merge sql/sql_show.cc: Manual merge sql/sql_table.cc: Manual merge storage/myisam/mi_checksum.c: No changes storage/myisam/mi_extra.c: Manual merge storage/myisam/mi_open.c: Manual merge storage/myisammrg/ha_myisammrg.cc: Manual merge strings/strmake.c: No changes
This commit is contained in:
125
sql/sql_table.cc
125
sql/sql_table.cc
@ -42,7 +42,7 @@ static int copy_data_between_tables(TABLE *from,TABLE *to,
|
||||
|
||||
static bool prepare_blob_field(THD *thd, Create_field *sql_field);
|
||||
static bool check_engine(THD *, const char *, HA_CREATE_INFO *);
|
||||
static bool
|
||||
static int
|
||||
mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
Alter_info *alter_info,
|
||||
bool tmp_table,
|
||||
@ -1226,8 +1226,12 @@ uint build_table_shadow_filename(char *buff, size_t bufflen,
|
||||
flags Flags as defined below
|
||||
WFRM_INITIAL_WRITE If set we need to prepare table before
|
||||
creating the frm file
|
||||
WFRM_CREATE_HANDLER_FILES If set we need to create the handler file as
|
||||
part of the creation of the frm file
|
||||
WFRM_INSTALL_SHADOW If set we should install the new frm
|
||||
WFRM_KEEP_SHARE If set we know that the share is to be
|
||||
retained and thus we should ensure share
|
||||
object is correct, if not set we don't
|
||||
set the new partition syntax string since
|
||||
we know the share object is destroyed.
|
||||
WFRM_PACK_FRM If set we should pack the frm file and delete
|
||||
the frm file
|
||||
|
||||
@ -1370,7 +1374,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
|
||||
goto err;
|
||||
}
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
if (part_info)
|
||||
if (part_info && (flags & WFRM_KEEP_SHARE))
|
||||
{
|
||||
TABLE_SHARE *share= lpt->table->s;
|
||||
char *tmp_part_syntax_str;
|
||||
@ -1497,7 +1501,7 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
|
||||
|
||||
if (error)
|
||||
DBUG_RETURN(TRUE);
|
||||
send_ok(thd);
|
||||
my_ok(thd);
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
@ -2173,7 +2177,7 @@ int prepare_create_field(Create_field *sql_field,
|
||||
TRUE error
|
||||
*/
|
||||
|
||||
static bool
|
||||
static int
|
||||
mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
Alter_info *alter_info,
|
||||
bool tmp_table,
|
||||
@ -3001,6 +3005,37 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
|
||||
(qsort_cmp) sort_keys);
|
||||
create_info->null_bits= null_fields;
|
||||
|
||||
/* Check fields. */
|
||||
it.rewind();
|
||||
while ((sql_field=it++))
|
||||
{
|
||||
Field::utype type= (Field::utype) MTYP_TYPENR(sql_field->unireg_check);
|
||||
|
||||
if (thd->variables.sql_mode & MODE_NO_ZERO_DATE &&
|
||||
!sql_field->def &&
|
||||
sql_field->sql_type == MYSQL_TYPE_TIMESTAMP &&
|
||||
(sql_field->flags & NOT_NULL_FLAG) &&
|
||||
(type == Field::NONE || type == Field::TIMESTAMP_UN_FIELD))
|
||||
{
|
||||
/*
|
||||
An error should be reported if:
|
||||
- NO_ZERO_DATE SQL mode is active;
|
||||
- there is no explicit DEFAULT clause (default column value);
|
||||
- this is a TIMESTAMP column;
|
||||
- the column is not NULL;
|
||||
- this is not the DEFAULT CURRENT_TIMESTAMP column.
|
||||
|
||||
In other words, an error should be reported if
|
||||
- NO_ZERO_DATE SQL mode is active;
|
||||
- the column definition is equivalent to
|
||||
'column_name TIMESTAMP DEFAULT 0'.
|
||||
*/
|
||||
|
||||
my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
@ -3292,8 +3327,9 @@ bool mysql_create_table_no_lock(THD *thd,
|
||||
}
|
||||
}
|
||||
}
|
||||
DBUG_PRINT("info", ("db_type = %d",
|
||||
ha_legacy_type(part_info->default_engine_type)));
|
||||
DBUG_PRINT("info", ("db_type = %s create_info->db_type = %s",
|
||||
ha_resolve_storage_engine_name(part_info->default_engine_type),
|
||||
ha_resolve_storage_engine_name(create_info->db_type)));
|
||||
if (part_info->check_partition_info(thd, &engine_type, file,
|
||||
create_info, TRUE))
|
||||
goto err;
|
||||
@ -3317,8 +3353,8 @@ bool mysql_create_table_no_lock(THD *thd,
|
||||
The handler assigned to the table cannot handle partitioning.
|
||||
Assign the partition handler as the handler of the table.
|
||||
*/
|
||||
DBUG_PRINT("info", ("db_type: %d",
|
||||
ha_legacy_type(create_info->db_type)));
|
||||
DBUG_PRINT("info", ("db_type: %s",
|
||||
ha_resolve_storage_engine_name(create_info->db_type)));
|
||||
delete file;
|
||||
create_info->db_type= partition_hton;
|
||||
if (!(file= get_ha_partition(part_info)))
|
||||
@ -3488,8 +3524,36 @@ bool mysql_create_table_no_lock(THD *thd,
|
||||
thd_proc_info(thd, "creating table");
|
||||
create_info->table_existed= 0; // Mark that table is created
|
||||
|
||||
if (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)
|
||||
#ifdef HAVE_READLINK
|
||||
if (test_if_data_home_dir(create_info->data_file_name))
|
||||
{
|
||||
my_error(ER_WRONG_ARGUMENTS, MYF(0), "DATA DIRECTORY");
|
||||
goto unlock_and_end;
|
||||
}
|
||||
if (test_if_data_home_dir(create_info->index_file_name))
|
||||
{
|
||||
my_error(ER_WRONG_ARGUMENTS, MYF(0), "INDEX DIRECTORY");
|
||||
goto unlock_and_end;
|
||||
}
|
||||
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
if (check_partition_dirs(thd->lex->part_info))
|
||||
{
|
||||
goto unlock_and_end;
|
||||
}
|
||||
#endif /* WITH_PARTITION_STORAGE_ENGINE */
|
||||
|
||||
if (!my_use_symdir || (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE))
|
||||
#endif /* HAVE_READLINK */
|
||||
{
|
||||
if (create_info->data_file_name)
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
|
||||
"DATA DIRECTORY option ignored");
|
||||
if (create_info->index_file_name)
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
|
||||
"INDEX DIRECTORY option ignored");
|
||||
create_info->data_file_name= create_info->index_file_name= 0;
|
||||
}
|
||||
create_info->table_options=db_options;
|
||||
|
||||
path[path_length - reg_ext_length]= '\0'; // Remove .frm extension
|
||||
@ -3752,9 +3816,9 @@ mysql_rename_table(handlerton *base, const char *old_db,
|
||||
wait_while_table_is_used()
|
||||
thd Thread handler
|
||||
table Table to remove from cache
|
||||
function HA_EXTRA_PREPARE_FOR_DROP if table is to be deleted
|
||||
HA_EXTRA_FORCE_REOPEN if table is not be used
|
||||
HA_EXTRA_PREPARE_FOR_REANME if table is to be renamed
|
||||
function HA_EXTRA_PREPARE_FOR_DROP if table is to be deleted
|
||||
HA_EXTRA_FORCE_REOPEN if table is not be used
|
||||
HA_EXTRA_PREPARE_FOR_RENAME if table is to be renamed
|
||||
NOTES
|
||||
When returning, the table will be unusable for other threads until
|
||||
the table is closed.
|
||||
@ -4141,6 +4205,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
switch ((*prepare_func)(thd, table, check_opt)) {
|
||||
case 1: // error, message written to net
|
||||
ha_autocommit_or_rollback(thd, 1);
|
||||
end_trans(thd, ROLLBACK);
|
||||
close_thread_tables(thd);
|
||||
DBUG_PRINT("admin", ("simple error, admin next table"));
|
||||
continue;
|
||||
@ -4199,6 +4264,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
table_name);
|
||||
protocol->store(buff, length, system_charset_info);
|
||||
ha_autocommit_or_rollback(thd, 0);
|
||||
end_trans(thd, COMMIT);
|
||||
close_thread_tables(thd);
|
||||
lex->reset_query_tables_list(FALSE);
|
||||
table->table=0; // For query cache
|
||||
@ -4471,17 +4537,19 @@ send_result_message:
|
||||
}
|
||||
}
|
||||
ha_autocommit_or_rollback(thd, 0);
|
||||
end_trans(thd, COMMIT);
|
||||
close_thread_tables(thd);
|
||||
table->table=0; // For query cache
|
||||
if (protocol->write())
|
||||
goto err;
|
||||
}
|
||||
|
||||
send_eof(thd);
|
||||
my_eof(thd);
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
err:
|
||||
err:
|
||||
ha_autocommit_or_rollback(thd, 1);
|
||||
end_trans(thd, ROLLBACK);
|
||||
close_thread_tables(thd); // Shouldn't be needed
|
||||
if (table)
|
||||
table->table=0;
|
||||
@ -5004,8 +5072,8 @@ mysql_discard_or_import_tablespace(THD *thd,
|
||||
query_cache_invalidate3(thd, table_list, 0);
|
||||
|
||||
/* The ALTER TABLE is always in its own transaction */
|
||||
error = ha_commit_stmt(thd);
|
||||
if (ha_commit(thd))
|
||||
error = ha_autocommit_or_rollback(thd, 0);
|
||||
if (end_active_trans(thd))
|
||||
error=1;
|
||||
if (error)
|
||||
goto err;
|
||||
@ -5013,12 +5081,11 @@ mysql_discard_or_import_tablespace(THD *thd,
|
||||
|
||||
err:
|
||||
ha_autocommit_or_rollback(thd, error);
|
||||
close_thread_tables(thd);
|
||||
thd->tablespace_op=FALSE;
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
send_ok(thd);
|
||||
my_ok(thd);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
@ -5985,7 +6052,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
||||
Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE);
|
||||
mysql_bin_log.write(&qinfo);
|
||||
}
|
||||
send_ok(thd);
|
||||
my_ok(thd);
|
||||
}
|
||||
|
||||
unlock_table_names(thd, table_list, (TABLE_LIST*) 0);
|
||||
@ -6223,7 +6290,7 @@ view_err:
|
||||
if (!error)
|
||||
{
|
||||
write_bin_log(thd, TRUE, thd->query, thd->query_length);
|
||||
send_ok(thd);
|
||||
my_ok(thd);
|
||||
}
|
||||
else if (error > 0)
|
||||
{
|
||||
@ -6539,8 +6606,8 @@ view_err:
|
||||
VOID(pthread_mutex_unlock(&LOCK_open));
|
||||
alter_table_manage_keys(table, table->file->indexes_are_disabled(),
|
||||
alter_info->keys_onoff);
|
||||
error= ha_commit_stmt(thd);
|
||||
if (ha_commit(thd))
|
||||
error= ha_autocommit_or_rollback(thd, 0);
|
||||
if (end_active_trans(thd))
|
||||
error= 1;
|
||||
}
|
||||
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
|
||||
@ -6628,7 +6695,7 @@ view_err:
|
||||
|
||||
/* Need to commit before a table is unlocked (NDB requirement). */
|
||||
DBUG_PRINT("info", ("Committing before unlocking table"));
|
||||
if (ha_commit_stmt(thd) || ha_commit(thd))
|
||||
if (ha_autocommit_or_rollback(thd, 0) || end_active_trans(thd))
|
||||
goto err1;
|
||||
}
|
||||
/*end of if (! new_table) for add/drop index*/
|
||||
@ -6858,7 +6925,7 @@ end_temporary:
|
||||
my_snprintf(tmp_name, sizeof(tmp_name), ER(ER_INSERT_INFO),
|
||||
(ulong) (copied + deleted), (ulong) deleted,
|
||||
(ulong) thd->cuted_fields);
|
||||
send_ok(thd, copied + deleted, 0L, tmp_name);
|
||||
my_ok(thd, copied + deleted, 0L, tmp_name);
|
||||
thd->some_tables_deleted=0;
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
@ -7126,9 +7193,9 @@ err:
|
||||
Ensure that the new table is saved properly to disk so that we
|
||||
can do a rename
|
||||
*/
|
||||
if (ha_commit_stmt(thd))
|
||||
if (ha_autocommit_or_rollback(thd, 0))
|
||||
error=1;
|
||||
if (ha_commit(thd))
|
||||
if (end_active_trans(thd))
|
||||
error=1;
|
||||
|
||||
thd->variables.sql_mode= save_sql_mode;
|
||||
@ -7293,7 +7360,7 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
|
||||
goto err;
|
||||
}
|
||||
|
||||
send_eof(thd);
|
||||
my_eof(thd);
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
err:
|
||||
|
Reference in New Issue
Block a user