diff options
author | unknown <elliot@mysql.com> | 2006-06-26 04:48:16 +0200 |
---|---|---|
committer | unknown <elliot@mysql.com> | 2006-06-26 04:48:16 +0200 |
commit | eef15bdf4610a4bf6b28a3ffaa9e6047b3060653 (patch) | |
tree | 332f66ef58f955fc87fc490524db51e1525adcf0 | |
parent | 9d7799e7a89235d9799eb0e8acd8a52c79746107 (diff) | |
parent | 971193167a5c433a327ac18bc0442d34ba83ca68 (diff) | |
download | mariadb-git-eef15bdf4610a4bf6b28a3ffaa9e6047b3060653.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/data0/bk/mysql-5.0-maint
sql/sp_head.cc:
Auto merged
sql/table.cc:
Auto merged
-rw-r--r-- | .bzrignore | 1 | ||||
-rw-r--r-- | client/mysqldump.c | 21 | ||||
-rw-r--r-- | mysql-test/r/bdb.result | 34 | ||||
-rw-r--r-- | mysql-test/r/func_time.result | 2 | ||||
-rw-r--r-- | mysql-test/r/func_timestamp.result | 2 | ||||
-rw-r--r-- | mysql-test/r/mysqldump.result | 9 | ||||
-rw-r--r-- | mysql-test/r/type_timestamp.result | 2 | ||||
-rw-r--r-- | mysql-test/r/udf.result | 18 | ||||
-rw-r--r-- | mysql-test/t/bdb.test | 35 | ||||
-rw-r--r-- | mysql-test/t/func_time.test | 7 | ||||
-rw-r--r-- | mysql-test/t/func_timestamp.test | 6 | ||||
-rw-r--r-- | mysql-test/t/mysqldump.test | 12 | ||||
-rw-r--r-- | mysql-test/t/type_timestamp.test | 6 | ||||
-rw-r--r-- | mysql-test/t/udf.test | 12 | ||||
-rw-r--r-- | mysys/my_lib.c | 2 | ||||
-rw-r--r-- | sql/log.cc | 22 | ||||
-rw-r--r-- | sql/log_event.cc | 27 | ||||
-rw-r--r-- | sql/log_event.h | 21 | ||||
-rw-r--r-- | sql/sp_head.cc | 4 | ||||
-rw-r--r-- | sql/sql_table.cc | 17 | ||||
-rw-r--r-- | sql/sql_udf.h | 2 | ||||
-rw-r--r-- | sql/table.cc | 8 |
22 files changed, 252 insertions, 18 deletions
diff --git a/.bzrignore b/.bzrignore index eafc384fda5..ef02a085144 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1285,3 +1285,4 @@ vio/viotest-sslconnect.cpp vio/viotest.cpp zlib/*.ds? zlib/*.vcproj +BitKeeper/etc/RESYNC_TREE diff --git a/client/mysqldump.c b/client/mysqldump.c index e89e8064c9a..fbd8ae351b2 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1503,9 +1503,15 @@ static uint get_table_structure(char *table, char *db, char *table_type, field= mysql_fetch_field_direct(result, 0); if (strcmp(field->name, "View") == 0) { + char *scv_buff = NULL; + if (verbose) fprintf(stderr, "-- It's a view, create dummy table for view\n"); + /* save "show create" statement for later */ + if ((row= mysql_fetch_row(result)) && (scv_buff=row[1])) + scv_buff= my_strdup(scv_buff, MYF(0)); + mysql_free_result(result); /* @@ -1523,9 +1529,22 @@ static uint get_table_structure(char *table, char *db, char *table_type, "SHOW FIELDS FROM %s", result_table); if (mysql_query_with_error_report(sock, 0, query_buff)) { + /* + View references invalid or privileged table/col/fun (err 1356), + so we cannot create a stand-in table. Be defensive and dump + a comment with the view's 'show create' statement. (Bug #17371) + */ + + if (mysql_errno(sock) == ER_VIEW_INVALID) + fprintf(sql_file, "\n-- failed on view %s: %s\n\n", result_table, scv_buff ? scv_buff : ""); + + my_free(scv_buff, MYF(MY_ALLOW_ZERO_PTR)); + safe_exit(EX_MYSQLERR); - DBUG_RETURN(0); + DBUG_RETURN(0); } + else + my_free(scv_buff, MYF(MY_ALLOW_ZERO_PTR)); if ((result= mysql_store_result(sock))) { diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index af6319afe99..588644a6c66 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -1928,4 +1928,38 @@ create table t1 (a int) engine=bdb; commit; alter table t1 add primary key(a); drop table t1; +set autocommit=1; +reset master; +create table bug16206 (a int) engine= blackhole; +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) engine= blackhole +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; insert into bug16206 values(2) +drop table bug16206; +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb +f n Query 1 n use `test`; insert into bug16206 values(0) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; BEGIN +f n Query 1 n use `test`; insert into bug16206 values(2) +f n Query 1 n use `test`; COMMIT +f n Query 1 n use `test`; insert into bug16206 values(3) +drop table bug16206; +set autocommit=0; End of 5.0 tests diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 593ce7b26c8..aaa86378626 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -1,4 +1,5 @@ drop table if exists t1,t2,t3; +set time_zone="+03:00"; select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(date_add(curdate(), interval 1 day))-to_days(curdate()),weekday("1997-11-29"); from_days(to_days("960101")) to_days(960201)-to_days("19960101") to_days(date_add(curdate(), interval 1 day))-to_days(curdate()) weekday("1997-11-29") 1996-01-01 31 1 5 @@ -945,3 +946,4 @@ id day id day 1 2005-06-01 3 2005-07-15 3 2005-07-01 3 2005-07-15 DROP TABLE t1,t2; +set time_zone= @@global.time_zone; diff --git a/mysql-test/r/func_timestamp.result b/mysql-test/r/func_timestamp.result index d9912f08b72..495fedea9e6 100644 --- a/mysql-test/r/func_timestamp.result +++ b/mysql-test/r/func_timestamp.result @@ -1,4 +1,5 @@ drop table if exists t1; +set time_zone="+03:00"; create table t1 (Zeit time, Tag tinyint not null, Monat tinyint not null, Jahr smallint not null, index(Tag), index(Monat), index(Jahr) ); insert into t1 values ("09:26:00",16,9,1998),("09:26:00",16,9,1998); @@ -9,3 +10,4 @@ Date Unix 1998-9-16 09:26:00 905927160 1998-9-16 09:26:00 905927160 drop table t1; +set time_zone= @@global.time_zone; diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index e496e1ef35d..acb9b9af276 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -2757,6 +2757,15 @@ p CREATE DEFINER=`root`@`localhost` PROCEDURE `p`() select 42 drop function f; drop procedure p; +create table t1 ( id serial ); +create view v1 as select * from t1; +drop table t1; +mysqldump { + +-- failed on view `v1`: CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`id` AS `id` from `t1` + +} mysqldump +drop view v1; create database mysqldump_test_db; use mysqldump_test_db; create table t1 (id int); diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result index 61ed6bbabf3..0817cc3b6c7 100644 --- a/mysql-test/r/type_timestamp.result +++ b/mysql-test/r/type_timestamp.result @@ -1,4 +1,5 @@ drop table if exists t1,t2; +set time_zone="+03:00"; CREATE TABLE t1 (a int, t timestamp); CREATE TABLE t2 (a int, t datetime); SET TIMESTAMP=1234; @@ -491,3 +492,4 @@ a b c 5 NULL 2001-09-09 04:46:59 6 NULL 2006-06-06 06:06:06 drop table t1; +set time_zone= @@global.time_zone; diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result index be52fd7f87c..484c42c41bf 100644 --- a/mysql-test/r/udf.result +++ b/mysql-test/r/udf.result @@ -76,6 +76,24 @@ call XXX2(); metaphon(testval) HL drop procedure xxx2; +CREATE TABLE bug19904(n INT, v varchar(10)); +INSERT INTO bug19904 VALUES (1,'one'),(2,'two'),(NULL,NULL),(3,'three'),(4,'four'); +SELECT myfunc_double(n) AS f FROM bug19904; +f +49.00 +50.00 +NULL +51.00 +52.00 +SELECT metaphon(v) AS f FROM bug19904; +f +ON +TW +NULL +0R +FR +DROP TABLE bug19904; +End of 5.0 tests. DROP FUNCTION metaphon; DROP FUNCTION myfunc_double; DROP FUNCTION myfunc_nonexist; diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test index d017d91bfb1..d2e3ca5f36e 100644 --- a/mysql-test/t/bdb.test +++ b/mysql-test/t/bdb.test @@ -1019,4 +1019,39 @@ commit; alter table t1 add primary key(a); drop table t1; + +# +# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode +# +set autocommit=1; + +let $VERSION=`select version()`; + +reset master; +create table bug16206 (a int) engine= blackhole; +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +set autocommit=0; + + --echo End of 5.0 tests diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index d817d016881..05c033f2b22 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -5,6 +5,9 @@ drop table if exists t1,t2,t3; --enable_warnings +# Set timezone to GMT-3, to make it possible to use "interval 3 hour" +set time_zone="+03:00"; + select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(date_add(curdate(), interval 1 day))-to_days(curdate()),weekday("1997-11-29"); select period_add("9602",-12),period_diff(199505,"9404") ; @@ -335,6 +338,7 @@ select last_day("1997-12-1")+0.0; # Test SAPDB UTC_% functions. This part is TZ dependant (It is supposed that # TZ variable set to GMT-3 + select strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0; select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%T"), utc_time())=0; select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%Y-%m-%d"), utc_date())=0; @@ -513,3 +517,6 @@ SELECT * FROM t1, t2 DROP TABLE t1,t2; # End of 5.0 tests + +# Restore timezone to default +set time_zone= @@global.time_zone; diff --git a/mysql-test/t/func_timestamp.test b/mysql-test/t/func_timestamp.test index e1bb7e878ee..05a91b06d28 100644 --- a/mysql-test/t/func_timestamp.test +++ b/mysql-test/t/func_timestamp.test @@ -6,6 +6,9 @@ drop table if exists t1; --enable_warnings +# Set timezone to GMT-3, to make it possible to use "interval 3 hour" +set time_zone="+03:00"; + create table t1 (Zeit time, Tag tinyint not null, Monat tinyint not null, Jahr smallint not null, index(Tag), index(Monat), index(Jahr) ); insert into t1 values ("09:26:00",16,9,1998),("09:26:00",16,9,1998); @@ -15,3 +18,6 @@ FROM t1; drop table t1; # End of 4.1 tests + +# Restore timezone to default +set time_zone= @@global.time_zone; diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index ab865594d42..4749141f7fe 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1162,6 +1162,18 @@ drop function f; drop procedure p; # +# Bug #17371 Unable to dump a schema with invalid views +# +# +create table t1 ( id serial ); +create view v1 as select * from t1; +drop table t1; +# mysqldump gets 1356 from server, but gives us 2 +--echo mysqldump { +--error 2 +--exec $MYSQL_DUMP --force -N --compact --skip-comments test +--echo } mysqldump +drop view v1; # BUG#17201 Spurious 'DROP DATABASE' in output, # also confusion between tables and views. # Example code from Markus Popp diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test index f96beedbebc..ddfc3f11665 100644 --- a/mysql-test/t/type_timestamp.test +++ b/mysql-test/t/type_timestamp.test @@ -6,6 +6,9 @@ drop table if exists t1,t2; --enable_warnings +# Set timezone to GMT-3, to make it possible to use "interval 3 hour" +set time_zone="+03:00"; + CREATE TABLE t1 (a int, t timestamp); CREATE TABLE t2 (a int, t datetime); SET TIMESTAMP=1234; @@ -322,3 +325,6 @@ select * from t1; drop table t1; # End of 4.1 tests + +# Restore timezone to default +set time_zone= @@global.time_zone; diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test index e2556692612..f3be08c8537 100644 --- a/mysql-test/t/udf.test +++ b/mysql-test/t/udf.test @@ -99,6 +99,17 @@ delimiter ;// call XXX2(); drop procedure xxx2; +# +# Bug#19904: UDF: not initialized *is_null per row +# + +CREATE TABLE bug19904(n INT, v varchar(10)); +INSERT INTO bug19904 VALUES (1,'one'),(2,'two'),(NULL,NULL),(3,'three'),(4,'four'); +SELECT myfunc_double(n) AS f FROM bug19904; +SELECT metaphon(v) AS f FROM bug19904; +DROP TABLE bug19904; + +--echo End of 5.0 tests. # # Drop the example functions from udf_example @@ -114,3 +125,4 @@ DROP FUNCTION lookup; DROP FUNCTION reverse_lookup; DROP FUNCTION avgcost; + diff --git a/mysys/my_lib.c b/mysys/my_lib.c index 03f2d91916d..1c5630ad14e 100644 --- a/mysys/my_lib.c +++ b/mysys/my_lib.c @@ -501,7 +501,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags) if (!(MyFlags & MY_DONT_SORT)) qsort((void *) result->dir_entry, result->number_off_files, sizeof(FILEINFO), (qsort_cmp) comp_names); - DBUG_PRINT(exit, ("found %d files", result->number_off_files)); + DBUG_PRINT("exit", ("found %d files", result->number_off_files)); DBUG_RETURN(result); error: my_errno=errno; diff --git a/sql/log.cc b/sql/log.cc index ba02c9ba082..cfb90d398e6 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -36,6 +36,8 @@ MYSQL_LOG mysql_log, mysql_slow_log, mysql_bin_log; ulong sync_binlog_counter= 0; +static Muted_query_log_event invisible_commit; + static bool test_if_number(const char *str, long *res, bool allow_wildcards); static bool binlog_init(); @@ -94,7 +96,9 @@ static int binlog_end_trans(THD *thd, IO_CACHE *trans_log, Log_event *end_ev) { int error=0; DBUG_ENTER("binlog_end_trans"); - if (end_ev) + + /* NULL denotes ROLLBACK with nothing to replicate */ + if (end_ev != NULL) error= mysql_bin_log.write(thd, trans_log, end_ev); statistic_increment(binlog_cache_use, &LOCK_status); @@ -126,14 +130,19 @@ static int binlog_commit(THD *thd, bool all) DBUG_ASSERT(mysql_bin_log.is_open() && (all || !(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))); - if (!my_b_tell(trans_log)) + if (my_b_tell(trans_log) == 0) { // we're here because trans_log was flushed in MYSQL_LOG::log() DBUG_RETURN(0); } - Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE); - qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE) - DBUG_RETURN(binlog_end_trans(thd, trans_log, &qev)); + if (all) + { + Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE); + qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE) + DBUG_RETURN(binlog_end_trans(thd, trans_log, &qev)); + } + else + DBUG_RETURN(binlog_end_trans(thd, trans_log, &invisible_commit)); } static int binlog_rollback(THD *thd, bool all) @@ -1813,6 +1822,9 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event) DBUG_ENTER("MYSQL_LOG::write(THD *, IO_CACHE *, Log_event *)"); VOID(pthread_mutex_lock(&LOCK_log)); + /* NULL would represent nothing to replicate after ROLLBACK */ + DBUG_ASSERT(commit_event != NULL); + if (likely(is_open())) // Should always be true { uint length; diff --git a/sql/log_event.cc b/sql/log_event.cc index 266d6b064bd..cabf4631284 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1229,6 +1229,18 @@ bool Query_log_event::write(IO_CACHE* file) my_b_safe_write(file, (byte*) query, q_len)) ? 1 : 0; } +/* + Query_log_event::Query_log_event() + + The simplest constructor that could possibly work. This is used for + creating static objects that have a special meaning and are invisible + to the log. +*/ +Query_log_event::Query_log_event() + :Log_event(), data_buf(0) +{ +} + /* Query_log_event::Query_log_event() @@ -1876,6 +1888,21 @@ end: /************************************************************************** + Muted_query_log_event methods +**************************************************************************/ + +#ifndef MYSQL_CLIENT +/* + Muted_query_log_event::Muted_query_log_event() +*/ +Muted_query_log_event::Muted_query_log_event() + :Query_log_event() +{ +} +#endif + + +/************************************************************************** Start_log_event_v3 methods **************************************************************************/ diff --git a/sql/log_event.h b/sql/log_event.h index 0e1eb7cd13c..f1b441dedb1 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -783,6 +783,7 @@ public: void print(FILE* file, PRINT_EVENT_INFO* print_event_info= 0); #endif + Query_log_event(); Query_log_event(const char* buf, uint event_len, const Format_description_log_event *description_event, Log_event_type event_type); @@ -806,6 +807,26 @@ public: /* Writes derived event-specific part of post header. */ }; + +/***************************************************************************** + + Muted Query Log Event class + + Pretends to Log SQL queries, but doesn't actually do so. + + ****************************************************************************/ +class Muted_query_log_event: public Query_log_event +{ +public: +#ifndef MYSQL_CLIENT + Muted_query_log_event(); + + bool write(IO_CACHE* file) { return(false); }; + virtual bool write_post_header_for_derived(IO_CACHE* file) { return FALSE; } +#endif +}; + + #ifdef HAVE_REPLICATION /***************************************************************************** diff --git a/sql/sp_head.cc b/sql/sp_head.cc index ef2f895c8b2..2a486e3f93d 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -565,7 +565,7 @@ create_typelib(MEM_ROOT *mem_root, create_field *field_def, List<String> *src) result->name= ""; if (!(result->type_names=(const char **) alloc_root(mem_root,(sizeof(char *)+sizeof(int))*(result->count+1)))) - return 0; + DBUG_RETURN(0); result->type_lengths= (unsigned int *)(result->type_names + result->count+1); List_iterator<String> it(*src); String conv; @@ -599,7 +599,7 @@ create_typelib(MEM_ROOT *mem_root, create_field *field_def, List<String> *src) result->type_names[result->count]= 0; result->type_lengths[result->count]= 0; } - return result; + DBUG_RETURN(result); } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 275cfbaa088..77c681d4a48 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1656,8 +1656,23 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, my_casedn_str(files_charset_info, path); create_info->table_options|=HA_CREATE_DELAY_KEY_WRITE; } - else + else + { + #ifdef FN_DEVCHAR + /* check if the table name contains FN_DEVCHAR when defined */ + const char *start= alias; + while (*start != '\0') + { + if (*start == FN_DEVCHAR) + { + my_error(ER_WRONG_TABLE_NAME, MYF(0), alias); + DBUG_RETURN(TRUE); + } + start++; + } + #endif build_table_path(path, sizeof(path), db, alias, reg_ext); + } /* Check if table already exists */ if ((create_info->options & HA_LEX_CREATE_TMP_TABLE) diff --git a/sql/sql_udf.h b/sql/sql_udf.h index d588572a762..d0729deecaa 100644 --- a/sql/sql_udf.h +++ b/sql/sql_udf.h @@ -70,6 +70,7 @@ class udf_handler :public Sql_alloc void cleanup(); double val(my_bool *null_value) { + is_null= 0; if (get_arguments()) { *null_value=1; @@ -88,6 +89,7 @@ class udf_handler :public Sql_alloc } longlong val_int(my_bool *null_value) { + is_null= 0; if (get_arguments()) { *null_value=1; diff --git a/sql/table.cc b/sql/table.cc index f3c9b8f8a8a..9ec9463c33c 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1593,10 +1593,6 @@ bool check_db_name(char *name) if (*name == '/' || *name == '\\' || *name == FN_LIBCHAR || *name == FN_EXTCHAR) return 1; -#ifdef FN_DEVCHAR - if (*name == FN_DEVCHAR) - return 1; -#endif name++; } return last_char_is_space || (uint) (name - start) > NAME_LEN; @@ -1639,10 +1635,6 @@ bool check_table_name(const char *name, uint length) #endif if (*name == '/' || *name == '\\' || *name == FN_EXTCHAR) return 1; -#ifdef FN_DEVCHAR - if (*name == FN_DEVCHAR) - return 1; -#endif name++; } #if defined(USE_MB) && defined(USE_MB_IDENT) |