Commit 6f19c0fc authored by Matthias Leich's avatar Matthias Leich

Merge last changesets into tree, no conflicts

parents 1a04fc03 97bd7635
...@@ -40,6 +40,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -40,6 +40,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
IO_CACHE file; IO_CACHE file;
MI_INFO *isam=0; MI_INFO *isam=0;
uint found_merge_insert_method= 0; uint found_merge_insert_method= 0;
my_bool bad_children= FALSE;
DBUG_ENTER("myrg_open"); DBUG_ENTER("myrg_open");
LINT_INIT(key_parts); LINT_INIT(key_parts);
...@@ -89,13 +90,13 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -89,13 +90,13 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
fn_format(buff, buff, "", "", 0); fn_format(buff, buff, "", "", 0);
if (!(isam=mi_open(buff,mode,(handle_locking?HA_OPEN_WAIT_IF_LOCKED:0)))) if (!(isam=mi_open(buff,mode,(handle_locking?HA_OPEN_WAIT_IF_LOCKED:0))))
{ {
my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
if (handle_locking & HA_OPEN_FOR_REPAIR) if (handle_locking & HA_OPEN_FOR_REPAIR)
{ {
myrg_print_wrong_table(buff); myrg_print_wrong_table(buff);
bad_children= TRUE;
continue; continue;
} }
goto err; goto bad_children;
} }
if (!m_info) /* First file */ if (!m_info) /* First file */
{ {
...@@ -122,13 +123,13 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -122,13 +123,13 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
files++; files++;
if (m_info->reclength != isam->s->base.reclength) if (m_info->reclength != isam->s->base.reclength)
{ {
my_errno=HA_ERR_WRONG_MRG_TABLE_DEF;
if (handle_locking & HA_OPEN_FOR_REPAIR) if (handle_locking & HA_OPEN_FOR_REPAIR)
{ {
myrg_print_wrong_table(buff); myrg_print_wrong_table(buff);
bad_children= TRUE;
continue; continue;
} }
goto err; goto bad_children;
} }
m_info->options|= isam->s->options; m_info->options|= isam->s->options;
m_info->records+= isam->state->records; m_info->records+= isam->state->records;
...@@ -141,8 +142,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -141,8 +142,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
m_info->tables); m_info->tables);
} }
if (my_errno == HA_ERR_WRONG_MRG_TABLE_DEF) if (bad_children)
goto err; goto bad_children;
if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO), if (!m_info && !(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO),
MYF(MY_WME | MY_ZEROFILL)))) MYF(MY_WME | MY_ZEROFILL))))
goto err; goto err;
...@@ -170,12 +171,14 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) ...@@ -170,12 +171,14 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking)
pthread_mutex_unlock(&THR_LOCK_open); pthread_mutex_unlock(&THR_LOCK_open);
DBUG_RETURN(m_info); DBUG_RETURN(m_info);
bad_children:
my_errno= HA_ERR_WRONG_MRG_TABLE_DEF;
err: err:
save_errno=my_errno; save_errno=my_errno;
switch (errpos) { switch (errpos) {
case 3: case 3:
while (files) while (files)
mi_close(m_info->open_tables[--files].table); (void) mi_close(m_info->open_tables[--files].table);
my_free((char*) m_info,MYF(0)); my_free((char*) m_info,MYF(0));
/* Fall through */ /* Fall through */
case 2: case 2:
......
...@@ -940,4 +940,15 @@ m1 CREATE TABLE `m1` ( ...@@ -940,4 +940,15 @@ m1 CREATE TABLE `m1` (
`a` int(11) default NULL `a` int(11) default NULL
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1, m1; DROP TABLE t1, m1;
CREATE TABLE t1(a INT);
CREATE TABLE t2(a VARCHAR(10));
CREATE TABLE m1(a INT) ENGINE=MERGE UNION=(t1, t2);
CREATE TABLE m2(a INT) ENGINE=MERGE UNION=(t1);
SELECT * FROM t1;
a
SELECT * FROM m1;
ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
SELECT * FROM m2;
a
DROP TABLE t1, t2, m1, m2;
End of 5.0 tests End of 5.0 tests
...@@ -492,6 +492,7 @@ a b c ...@@ -492,6 +492,7 @@ a b c
5 NULL 2001-09-09 04:46:59 5 NULL 2001-09-09 04:46:59
6 NULL 2006-06-06 06:06:06 6 NULL 2006-06-06 06:06:06
drop table t1; drop table t1;
End of 4.1 tests
set time_zone= @@global.time_zone; set time_zone= @@global.time_zone;
CREATE TABLE t1 ( CREATE TABLE t1 (
`id` int(11) NOT NULL auto_increment, `id` int(11) NOT NULL auto_increment,
...@@ -508,3 +509,21 @@ select is_nullable from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='t1' and COL ...@@ -508,3 +509,21 @@ select is_nullable from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='t1' and COL
is_nullable is_nullable
NO NO
drop table t1; drop table t1;
CREATE TABLE t1 ( f1 INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
f2 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
f3 TIMESTAMP);
INSERT INTO t1 (f2,f3) VALUES (NOW(), "0000-00-00 00:00:00");
INSERT INTO t1 (f2,f3) VALUES (NOW(), NULL);
INSERT INTO t1 (f2,f3) VALUES (NOW(), ASCII(NULL));
INSERT INTO t1 (f2,f3) VALUES (NOW(), FROM_UNIXTIME('9999999999'));
INSERT INTO t1 (f2,f3) VALUES (NOW(), TIME(NULL));
UPDATE t1 SET f2=NOW(), f3=FROM_UNIXTIME('9999999999') WHERE f1=1;
SELECT f1,f2-f3 FROM t1;
f1 f2-f3
1 0
2 0
3 0
4 0
5 0
DROP TABLE t1;
End of 5.0 tests
...@@ -556,4 +556,17 @@ ALTER TABLE m1 UNION=(); ...@@ -556,4 +556,17 @@ ALTER TABLE m1 UNION=();
SHOW CREATE TABLE m1; SHOW CREATE TABLE m1;
DROP TABLE t1, m1; DROP TABLE t1, m1;
#
# BUG#32047 - 'Spurious' errors while opening MERGE tables
#
CREATE TABLE t1(a INT);
CREATE TABLE t2(a VARCHAR(10));
CREATE TABLE m1(a INT) ENGINE=MERGE UNION=(t1, t2);
CREATE TABLE m2(a INT) ENGINE=MERGE UNION=(t1);
SELECT * FROM t1;
--error ER_WRONG_MRG_TABLE
SELECT * FROM m1;
SELECT * FROM m2;
DROP TABLE t1, t2, m1, m2;
--echo End of 5.0 tests --echo End of 5.0 tests
...@@ -324,7 +324,7 @@ insert into t1 (a, c) values (4, '2004-04-04 00:00:00'), ...@@ -324,7 +324,7 @@ insert into t1 (a, c) values (4, '2004-04-04 00:00:00'),
select * from t1; select * from t1;
drop table t1; drop table t1;
# End of 4.1 tests --echo End of 4.1 tests
# Restore timezone to default # Restore timezone to default
set time_zone= @@global.time_zone; set time_zone= @@global.time_zone;
...@@ -339,3 +339,21 @@ PRIMARY KEY (`id`) ...@@ -339,3 +339,21 @@ PRIMARY KEY (`id`)
show fields from t1; show fields from t1;
select is_nullable from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='t1' and COLUMN_NAME='posted_on'; select is_nullable from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='t1' and COLUMN_NAME='posted_on';
drop table t1; drop table t1;
#
# Bug#41370: TIMESTAMP field does not accepts NULL from FROM_UNIXTIME()
#
CREATE TABLE t1 ( f1 INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
f2 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
f3 TIMESTAMP);
INSERT INTO t1 (f2,f3) VALUES (NOW(), "0000-00-00 00:00:00");
INSERT INTO t1 (f2,f3) VALUES (NOW(), NULL);
INSERT INTO t1 (f2,f3) VALUES (NOW(), ASCII(NULL));
INSERT INTO t1 (f2,f3) VALUES (NOW(), FROM_UNIXTIME('9999999999'));
INSERT INTO t1 (f2,f3) VALUES (NOW(), TIME(NULL));
UPDATE t1 SET f2=NOW(), f3=FROM_UNIXTIME('9999999999') WHERE f1=1;
SELECT f1,f2-f3 FROM t1;
DROP TABLE t1;
--echo End of 5.0 tests
...@@ -6,7 +6,7 @@ drop table if exists t1,t2; ...@@ -6,7 +6,7 @@ drop table if exists t1,t2;
--enable_warnings --enable_warnings
# #
# Bug #19263: variables.test doesn't clean up after itself (I/II -- save) # Bug#19263: variables.test doesn't clean up after itself (I/II -- save)
# #
set @my_binlog_cache_size =@@global.binlog_cache_size; set @my_binlog_cache_size =@@global.binlog_cache_size;
set @my_connect_timeout =@@global.connect_timeout; set @my_connect_timeout =@@global.connect_timeout;
...@@ -172,46 +172,46 @@ SELECT @@version_compile_os LIKE 'non-existent'; ...@@ -172,46 +172,46 @@ SELECT @@version_compile_os LIKE 'non-existent';
# The following should give errors # The following should give errors
--error 1231 --error ER_WRONG_VALUE_FOR_VAR
set big_tables=OFFF; set big_tables=OFFF;
--error 1231 --error ER_WRONG_VALUE_FOR_VAR
set big_tables="OFFF"; set big_tables="OFFF";
--error 1193 --error ER_UNKNOWN_SYSTEM_VARIABLE
set unknown_variable=1; set unknown_variable=1;
--error 1232 --error ER_WRONG_TYPE_FOR_VAR
set max_join_size="hello"; set max_join_size="hello";
--error 1286 --error ER_UNKNOWN_STORAGE_ENGINE
set storage_engine=UNKNOWN_TABLE_TYPE; set storage_engine=UNKNOWN_TABLE_TYPE;
--error 1231 --error ER_WRONG_VALUE_FOR_VAR
set storage_engine=MERGE, big_tables=2; set storage_engine=MERGE, big_tables=2;
show local variables like 'storage_engine'; show local variables like 'storage_engine';
--error 1229 --error ER_GLOBAL_VARIABLE
set SESSION query_cache_size=10000; set SESSION query_cache_size=10000;
--error 1230 --error ER_NO_DEFAULT
set GLOBAL storage_engine=DEFAULT; set GLOBAL storage_engine=DEFAULT;
--error 1115 --error ER_UNKNOWN_CHARACTER_SET
set character_set_client=UNKNOWN_CHARACTER_SET; set character_set_client=UNKNOWN_CHARACTER_SET;
--error 1273 --error ER_UNKNOWN_COLLATION
set collation_connection=UNKNOWN_COLLATION; set collation_connection=UNKNOWN_COLLATION;
--error 1231 --error ER_WRONG_VALUE_FOR_VAR
set character_set_client=NULL; set character_set_client=NULL;
--error 1231 --error ER_WRONG_VALUE_FOR_VAR
set collation_connection=NULL; set collation_connection=NULL;
--error 1228 --error ER_LOCAL_VARIABLE
set global autocommit=1; set global autocommit=1;
--error 1238 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@global.timestamp; select @@global.timestamp;
--error 1238 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
set @@version=''; set @@version='';
--error 1229 --error ER_GLOBAL_VARIABLE
set @@concurrent_insert=1; set @@concurrent_insert=1;
--error 1228 --error ER_LOCAL_VARIABLE
set @@global.sql_auto_is_null=1; set @@global.sql_auto_is_null=1;
--error 1238 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@global.sql_auto_is_null; select @@global.sql_auto_is_null;
--error 1229 --error ER_GLOBAL_VARIABLE
set myisam_max_sort_file_size=100; set myisam_max_sort_file_size=100;
--error 1231 --error ER_WRONG_VALUE_FOR_VAR
set @@SQL_WARNINGS=NULL; set @@SQL_WARNINGS=NULL;
# Test setting all variables # Test setting all variables
...@@ -338,23 +338,23 @@ drop table t1,t2; ...@@ -338,23 +338,23 @@ drop table t1,t2;
# error conditions # error conditions
# #
--error 1193 --error ER_UNKNOWN_SYSTEM_VARIABLE
select @@xxxxxxxxxx; select @@xxxxxxxxxx;
select 1; select 1;
--error 1238 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.key_buffer_size; select @@session.key_buffer_size;
--error 1229 --error ER_GLOBAL_VARIABLE
set ft_boolean_syntax = @@init_connect; set ft_boolean_syntax = @@init_connect;
--error 1231 --error ER_WRONG_VALUE_FOR_VAR
set global ft_boolean_syntax = @@init_connect; set global ft_boolean_syntax = @@init_connect;
--error 1229 --error ER_GLOBAL_VARIABLE
set init_connect = NULL; set init_connect = NULL;
set global init_connect = NULL; set global init_connect = NULL;
--error 1229 --error ER_GLOBAL_VARIABLE
set ft_boolean_syntax = @@init_connect; set ft_boolean_syntax = @@init_connect;
--error 1231 --error ER_WRONG_VALUE_FOR_VAR
set global ft_boolean_syntax = @@init_connect; set global ft_boolean_syntax = @@init_connect;
# Bug#3754 SET GLOBAL myisam_max_sort_file_size doesn't work as # Bug#3754 SET GLOBAL myisam_max_sort_file_size doesn't work as
...@@ -385,15 +385,15 @@ select @a, @b; ...@@ -385,15 +385,15 @@ select @a, @b;
# #
# Bug#2586:Disallow global/session/local as structured var. instance names # Bug#2586:Disallow global/session/local as structured var. instance names
# #
--error 1064 --error ER_PARSE_ERROR
set @@global.global.key_buffer_size= 1; set @@global.global.key_buffer_size= 1;
--error 1064 --error ER_PARSE_ERROR
set GLOBAL global.key_buffer_size= 1; set GLOBAL global.key_buffer_size= 1;
--error 1064 --error ER_PARSE_ERROR
SELECT @@global.global.key_buffer_size; SELECT @@global.global.key_buffer_size;
--error 1064 --error ER_PARSE_ERROR
SELECT @@global.session.key_buffer_size; SELECT @@global.session.key_buffer_size;
--error 1064 --error ER_PARSE_ERROR
SELECT @@global.local.key_buffer_size; SELECT @@global.local.key_buffer_size;
# BUG#5135: cannot turn on log_warnings with SET in 4.1 (and 4.0) # BUG#5135: cannot turn on log_warnings with SET in 4.1 (and 4.0)
...@@ -478,27 +478,27 @@ select @@lc_time_names; ...@@ -478,27 +478,27 @@ select @@lc_time_names;
--echo *** LC_TIME_NAMES: testing with string expressions --echo *** LC_TIME_NAMES: testing with string expressions
set lc_time_names=concat('de','_','DE'); set lc_time_names=concat('de','_','DE');
select @@lc_time_names; select @@lc_time_names;
--error 1105 --error ER_UNKNOWN_ERROR
set lc_time_names=concat('de','+','DE'); set lc_time_names=concat('de','+','DE');
select @@lc_time_names; select @@lc_time_names;
--echo LC_TIME_NAMES: testing with numeric expressions --echo LC_TIME_NAMES: testing with numeric expressions
set @@lc_time_names=1+2; set @@lc_time_names=1+2;
select @@lc_time_names; select @@lc_time_names;
--error 1232 --error ER_WRONG_TYPE_FOR_VAR
set @@lc_time_names=1/0; set @@lc_time_names=1/0;
select @@lc_time_names; select @@lc_time_names;
set lc_time_names=en_US; set lc_time_names=en_US;
--echo LC_TIME_NAMES: testing NULL and a negative number: --echo LC_TIME_NAMES: testing NULL and a negative number:
--error 1231 --error ER_WRONG_VALUE_FOR_VAR
set lc_time_names=NULL; set lc_time_names=NULL;
--error 1105 --error ER_UNKNOWN_ERROR
set lc_time_names=-1; set lc_time_names=-1;
select @@lc_time_names; select @@lc_time_names;
--echo LC_TIME_NAMES: testing locale with the last ID: --echo LC_TIME_NAMES: testing locale with the last ID:
set lc_time_names=108; set lc_time_names=108;
select @@lc_time_names; select @@lc_time_names;
--echo LC_TIME_NAMES: testing a number beyond the valid ID range: --echo LC_TIME_NAMES: testing a number beyond the valid ID range:
--error 1105 --error ER_UNKNOWN_ERROR
set lc_time_names=109; set lc_time_names=109;
select @@lc_time_names; select @@lc_time_names;
--echo LC_TIME_NAMES: testing that 0 is en_US: --echo LC_TIME_NAMES: testing that 0 is en_US:
...@@ -540,7 +540,7 @@ select @@query_prealloc_size = @test; ...@@ -540,7 +540,7 @@ select @@query_prealloc_size = @test;
# Bug#31588 buffer overrun when setting variables # Bug#31588 buffer overrun when setting variables
# #
# Buffer-size Off By One. Should throw valgrind-warning without fix #31588. # Buffer-size Off By One. Should throw valgrind-warning without fix #31588.
--error 1231 --error ER_WRONG_VALUE_FOR_VAR
set global sql_mode=repeat('a',80); set global sql_mode=repeat('a',80);
--echo End of 4.1 tests --echo End of 4.1 tests
...@@ -558,9 +558,9 @@ drop table t1; ...@@ -558,9 +558,9 @@ drop table t1;
# Bug #10339: read only variables. # Bug #10339: read only variables.
# #
--error 1238 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
set @@warning_count=1; set @@warning_count=1;
--error 1238 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
set @@global.error_count=1; set @@global.error_count=1;
# #
...@@ -578,9 +578,9 @@ select @@max_heap_table_size > 0; ...@@ -578,9 +578,9 @@ select @@max_heap_table_size > 0;
# Bug #11775 Variable character_set_system does not exist (sometimes) # Bug #11775 Variable character_set_system does not exist (sometimes)
# #
select @@character_set_system; select @@character_set_system;
--error 1238 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global character_set_system = latin1; set global character_set_system = latin1;
--error 1238 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
set @@global.version_compile_os='234'; set @@global.version_compile_os='234';
# #
...@@ -677,7 +677,7 @@ select @@@; ...@@ -677,7 +677,7 @@ select @@@;
# Don't actually output, since it depends on the system # Don't actually output, since it depends on the system
--replace_column 1 # --replace_column 1 #
select @@hostname; select @@hostname;
--error 1238 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
set @@hostname= "anothername"; set @@hostname= "anothername";
--replace_column 2 # --replace_column 2 #
show variables like 'hostname'; show variables like 'hostname';
...@@ -688,12 +688,12 @@ show variables like 'hostname'; ...@@ -688,12 +688,12 @@ show variables like 'hostname';
SHOW VARIABLES LIKE 'log'; SHOW VARIABLES LIKE 'log';
SELECT @@log; SELECT @@log;
--error 1238 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET GLOBAL log=0; SET GLOBAL log=0;
SHOW VARIABLES LIKE 'log_slow_queries'; SHOW VARIABLES LIKE 'log_slow_queries';
SELECT @@log_slow_queries; SELECT @@log_slow_queries;
--error 1238 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
SET GLOBAL log_slow_queries=0; SET GLOBAL log_slow_queries=0;
--echo End of 5.0 tests --echo End of 5.0 tests
......
...@@ -321,7 +321,7 @@ int Item::save_time_in_field(Field *field) ...@@ -321,7 +321,7 @@ int Item::save_time_in_field(Field *field)
{ {
MYSQL_TIME ltime; MYSQL_TIME ltime;
if (get_time(&ltime)) if (get_time(&ltime))
return set_field_to_null(field); return set_field_to_null_with_conversions(field, 0);
field->set_notnull(); field->set_notnull();
return field->store_time(&ltime, MYSQL_TIMESTAMP_TIME); return field->store_time(&ltime, MYSQL_TIMESTAMP_TIME);
} }
...@@ -331,7 +331,7 @@ int Item::save_date_in_field(Field *field) ...@@ -331,7 +331,7 @@ int Item::save_date_in_field(Field *field)
{ {
MYSQL_TIME ltime; MYSQL_TIME ltime;
if (get_date(&ltime, TIME_FUZZY_DATE)) if (get_date(&ltime, TIME_FUZZY_DATE))
return set_field_to_null(field); return set_field_to_null_with_conversions(field, 0);
field->set_notnull(); field->set_notnull();
return field->store_time(&ltime, MYSQL_TIMESTAMP_DATETIME); return field->store_time(&ltime, MYSQL_TIMESTAMP_DATETIME);
} }
......
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