From 98f57fbe955f73c7c8111b10ff21c675d2f577d9 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Jun 2003 13:52:15 +0200 Subject: -- already approved; it would be nice if it goes into 3.23.57 -- Fix for bug 254 : the first Start_log_event after server startup will have created=now(), whereas the next ones (FLUSH LOGS, auto rotation) will have created=0. Before this, it was always now(). This way, slaves >=4.0.14 will know when they must drop stale temp tables or not. The next task is now modify 4.0.14 to implement this. sql/log.cc: Fix for bug 254 : the first Start_log_event after server startup will have created=now(), whereas the next ones (FLUSH LOGS, auto rotation) will have created=0. Before this, it was always now(). This way, slaves >=4.0.14 will know when they must drop stale temp tables or not. sql/log_event.h: An explanation. sql/sql_class.h: Prototype change (see log.cc). --- sql/log.cc | 16 +++++++++++++--- sql/log_event.h | 9 +++++++++ sql/sql_class.h | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-) (limited to 'sql') diff --git a/sql/log.cc b/sql/log.cc index d189f1f1fe3..69957c5c97c 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -157,7 +157,7 @@ void MYSQL_LOG::close_index() } void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, - const char *new_name) + const char *new_name, bool null_created) { MY_STAT tmp_stat; char buff[512]; @@ -230,8 +230,10 @@ void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, if ((do_magic && my_b_write(&log_file, (byte*) BINLOG_MAGIC, 4)) || open_index(O_APPEND | O_RDWR | O_CREAT)) goto err; - Start_log_event s; bool error; + Start_log_event s; + if (null_created) + s.created= 0; s.write(&log_file); flush_io_cache(&log_file); pthread_mutex_lock(&LOCK_index); @@ -548,7 +550,15 @@ void MYSQL_LOG::new_file(bool inside_mutex) strmov(new_name, old_name); // Reopen old file name name=0; close(); - open(old_name, log_type, new_name); + /* + new_file() is only used for rotation (in FLUSH LOGS or because size > + max_binlog_size). + If this is a binary log, the Start_log_event at the beginning of + the new file should have created=0 (to distinguish with the Start_log_event + written at server startup, which should trigger temp tables deletion on + >=4.0.14 slaves). + */ + open(old_name, log_type, new_name, 1); my_free(old_name,MYF(0)); last_time=query_start=0; write_error=0; diff --git a/sql/log_event.h b/sql/log_event.h index 68696442490..bb1c9260e21 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -327,6 +327,15 @@ extern char server_version[SERVER_VERSION_LENGTH]; class Start_log_event: public Log_event { public: + /* + If this event is at the start of the first binary log since server startup + 'created' should be the timestamp when the event (and the binary log) was + created. + In the other case (i.e. this event is at the start of a binary log created + by FLUSH LOGS or automatic rotation), 'created' should be 0. + This "trick" is used by MySQL >=4.0.14 slaves to know if they must drop the + stale temporary tables or not. + */ time_t created; uint16 binlog_version; char server_version[50]; diff --git a/sql/sql_class.h b/sql/sql_class.h index d9497907926..8abf87c4cda 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -73,7 +73,7 @@ public: void set_index_file_name(const char* index_file_name = 0); void init(enum_log_type log_type_arg); void open(const char *log_name,enum_log_type log_type, - const char *new_name=0); + const char *new_name=0, bool null_created= 0); void new_file(bool inside_mutex = 0); bool open_index(int options); void close_index(); -- cgit v1.2.1 From 07d6a199557308f49a8e700de95747f638b7dccd Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Jun 2003 14:13:26 +0200 Subject: In Start_log_event::print, don't print "created 1970 etc" if created == 0. Otherwise, we'll get questions from users about this curious 1970. --- sql/log_event.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sql') diff --git a/sql/log_event.cc b/sql/log_event.cc index 1c9c48e2d93..62d6bef3a51 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -302,9 +302,13 @@ void Start_log_event::print(FILE* file, bool short_form, char* last_db) return; print_header(file); - fprintf(file, "\tStart: binlog v %d, server v %s created ", binlog_version, + fprintf(file, "\tStart: binlog v %d, server v %s", binlog_version, server_version); - print_timestamp(file, &created); + if (created) + { + fprintf(file, " created "); + print_timestamp(file, &created); + } fputc('\n', file); fflush(file); } -- cgit v1.2.1 From 87473e96b7a201a81003a2ee3de56e90c358624d Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 8 Jun 2003 02:53:41 -0400 Subject: Translation updated BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- sql/share/spanish/errmsg.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'sql') diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index b9c88873106..089bc13e8d3 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -212,11 +212,11 @@ "Bloqueos de actualización no pueden ser adqueridos durante una transición READ UNCOMMITTED", "DROP DATABASE no permitido mientras un thread está ejerciendo un bloqueo de lectura global", "CREATE DATABASE no permitido mientras un thread está ejerciendo un bloqueo de lectura global", -"Wrong arguments to %s", -"%-.32s@%-.64s is not allowed to create new users", -"Incorrect table definition; All MERGE tables must be in the same database", -"Deadlock found when trying to get lock; Try restarting transaction", -"The used table type doesn't support FULLTEXT indexes", -"Cannot add foreign key constraint", -"Cannot add a child row: a foreign key constraint fails", -"Cannot delete a parent row: a foreign key constraint fails", +"Argumentos errados para %s", +"%-.32s@%-.64s no es permitido para crear nuevos usuarios", +"Incorrecta definición de la tabla; Todas las tablas MERGE deben estar en el mismo banco de datos", +"Encontrado deadlock cuando tentando obtener el bloqueo; Tente recomenzar la transición", +"El tipo de tabla usada no soporta índices FULLTEXT", +"No puede adicionar clave extranjera constraint", +"No puede adicionar una línea hijo: falla de clave extranjera constraint", +"No puede deletar una línea padre: falla de clave extranjera constraint", -- cgit v1.2.1 From 418fcdf16aeeb2db41b2dafd1ac9338233a3fd1d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 16 Jun 2003 23:38:33 +0200 Subject: Do not use 'created' for time anymore in Start_log_event, it's the same as the already-stored timestamp. Now 'created' is used only to know if this is a first binlog or not. And we may re-use the superfluous bytes in 5.0 when we need room. sql/log_event.cc: This sort of reverts a change I made in 3.23.57. In 3.23.57 I set 'created' to 0 if this was a non-first binlog, so I made mysqlbinlog not print the "created xx" part if created == 0. While this was sensible, as 'created' is 0 or equal to the timestamp which is already stored in the event, we can always print "created xx" by using the timestamp, and leaving the use of 'created' only to know if this is a first binlog or not (which we print as "created at startup"). sql/log_event.h: In Start_log_event, 'created' is always the same as 'when', or O. We didn't need 4 bytes for this, a bit would have been enough (O or "same as 'when'"). Possibly in 5.0 we will re-use the useless bytes. --- sql/log_event.cc | 8 +++----- sql/log_event.h | 11 +++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'sql') diff --git a/sql/log_event.cc b/sql/log_event.cc index 62d6bef3a51..b89f3c151a7 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -302,13 +302,11 @@ void Start_log_event::print(FILE* file, bool short_form, char* last_db) return; print_header(file); - fprintf(file, "\tStart: binlog v %d, server v %s", binlog_version, + fprintf(file, "\tStart: binlog v %d, server v %s created ", binlog_version, server_version); + print_timestamp(file); if (created) - { - fprintf(file, " created "); - print_timestamp(file, &created); - } + fprintf(file," at startup"); fputc('\n', file); fflush(file); } diff --git a/sql/log_event.h b/sql/log_event.h index bb1c9260e21..d3c74f7f7c2 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -335,6 +335,17 @@ public: by FLUSH LOGS or automatic rotation), 'created' should be 0. This "trick" is used by MySQL >=4.0.14 slaves to know if they must drop the stale temporary tables or not. + Note that when 'created'!=0, it is always equal to the event's timestamp; + indeed Start_log_event is written only in log.cc where the first + constructor below is called, in which 'created' is set to 'when'. + So in fact 'created' is a useless variable. When it is 0 + we can read the actual value from timestamp ('when') and when it is + non-zero we can read the same value from timestamp ('when'). Conclusion: + - we use timestamp to print when the binlog was created. + - we use 'created' only to know if this is a first binlog or not. + In 3.23.57 we did not pay attention to this identity, so mysqlbinlog in + 3.23.57 does not print 'created the_date' if created was zero. This is now + fixed. */ time_t created; uint16 binlog_version; -- cgit v1.2.1 From 650da0800a156e3d617f59202ec0d0bfd68eb8b8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 Jun 2003 12:09:32 -0400 Subject: Fix error msg. Bug #681 --- sql/nt_servc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/nt_servc.cc b/sql/nt_servc.cc index b917c91ce15..b18d3d00d88 100644 --- a/sql/nt_servc.cc +++ b/sql/nt_servc.cc @@ -462,7 +462,7 @@ BOOL NTService::SeekStatus(LPCSTR szInternName, int OperationType) { /* a remove operation */ if (!(service = OpenService(scm,szInternName, SERVICE_ALL_ACCESS ))) - printf("The service doesn't exists!\n"); + printf("The service doesn't exist!\n"); else { SERVICE_STATUS ss; -- cgit v1.2.1 From 7143815557275a3f954b279ace4305ea278020de Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 21 Jun 2003 16:32:27 +0200 Subject: Can't believe it: one more cset (04-27) which never found his way to the central repository (incredible that I forgot to push, but why not). So unfortunately the bugfix missed 3.23.57 and will be in .58 :( Instead of looking like working (bug #198), replication between a 3.23 slave and 4.0 master should frankly stop. Here we detect 4.0 masters in the 3.23 slave code when we see a strange Rotate event, and in that case we print an error and stop. 4.0.13 and older masters will be "often" caught (see the patch); 4.0.14 and newer masters will always be immediately caught. sql/slave.cc: Instead of looking like working (bug #198), replication between a 3.23 slave and 4.0 master should frankly stop. Here we detect 4.0 masters in the 3.23 slave code when we see a strange Rotate event, and in that case we print an error and stop. 4.0.13 and older masters will be "often" caught (see the patch); 4.0.14 and newer masters will always be immediately caught. --- sql/slave.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'sql') diff --git a/sql/slave.cc b/sql/slave.cc index 39c3d31ee66..50cb224d83d 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1216,6 +1216,28 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len) Rotate_log_event* rev = (Rotate_log_event*)ev; int ident_len = rev->ident_len; pthread_mutex_lock(&mi->lock); + /* + If the master is 4.0, he has an incompatible binlog format, which we + cannot read. We always can detect this in _fake_ Rotate events, where we + see zeros at the beginning of the expected binlog's filename (this is + because 4.0 _fake_ Rotate events have zeros in the 'log_pos' and 'flags' + parts of the event header). + Consider the following test as a sanity check, which must always pass, + and which has the good side effect of catching 4.0 masters. + Masters >= 4.0.14 will always send a fake Rotate event (even if the slave + asked for a position >4) so we are 100% sure to catch the problem. + */ + if (!ident_len || !(rev->new_log_ident[0])) + { + sql_print_error("Slave: could not parse Rotate event; it *might* be \ +that your master's version is 4.0 or newer, which cannot be replicated by \ +3.23 slaves (in that case you need to upgrade your slave to 4.0 or newer)"); + delete ev; + pthread_cond_broadcast(&mi->cond); + pthread_mutex_unlock(&mi->lock); + return 1; + } + memcpy(mi->log_file_name, rev->new_log_ident,ident_len ); mi->log_file_name[ident_len] = 0; mi->pos = 4; // skip magic number -- cgit v1.2.1 From 50159020c8f0f5b1f37ca29ccd81f086b7d32982 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Jun 2003 21:11:23 -0400 Subject: fixed bug with type of user variables (bug #551) mysql-test/r/user_var.result: added tests for user variables comparing (bug #551) mysql-test/t/user_var.test: added tests for user variables comparing (bug #551) BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- sql/item_func.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'sql') diff --git a/sql/item_func.cc b/sql/item_func.cc index 723585be0b1..217768db2c5 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1676,6 +1676,7 @@ bool Item_func_set_user_var::fix_fields(THD *thd,TABLE_LIST *tables) if (Item_func::fix_fields(thd,tables) || !(entry= get_variable(&thd->user_vars, name, 1))) return 1; + entry->type= cached_result_type; entry->update_query_id=thd->query_id; return 0; } -- cgit v1.2.1 From caddb5ea53cbde18bf0a915bc4867fecd93c55d5 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 29 Jun 2003 21:15:51 +0300 Subject: Fixed 'Unknown error' when doing ORDER BY on reference table which was used with NULL value on NOT NULL column. (Bug #479) mysql-test/r/order_by.result: Update of results mysql-test/t/order_by.test: Test of new code sql/sql_select.cc: Fixed problem with lookup on NULL --- sql/sql_select.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/sql_select.cc b/sql/sql_select.cc index cafafee243e..b9e9c0a14fa 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -5326,11 +5326,23 @@ create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit) can use. */ if (!(select->quick=get_ft_or_quick_select_for_ref(table, tab))) - goto err; + { + if (current_thd->fatal_error) + goto err; // End of memory + /* + Impossible range (for example lookup on NULL on not null field) + Create empty result set + */ + if (!(table->record_pointers= my_malloc(1, MYF(MY_WME)))) + goto err; + table->found_records= 0; + goto end; + } } } table->found_records=filesort(&table,sortorder,length, select, 0L, select_limit, &examined_rows); +end: delete select; // filesort did select tab->select=0; tab->select_cond=0; -- cgit v1.2.1