From be9a61f17541339a2d5ac71f48cf2cb1cb78d305 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Feb 2003 11:20:07 +0200 Subject: [PATCH 1/5] Add missing SIGNAL_WITH_VIO_CLOSE to fix problem with SLAVE STOP on windows --- include/config-win.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/config-win.h b/include/config-win.h index b4b9a59a067..74b2ae71017 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -135,6 +135,11 @@ typedef uint rf_SetTimer; #define HAVE_NAMED_PIPE /* We can only create pipes on NT */ #endif +/* We need to close files to break connections on shutdown */ +#ifndef SIGNAL_WITH_VIO_CLOSE +#define SIGNAL_WITH_VIO_CLOSE +#endif + /* Use all character sets in MySQL */ #define USE_MB 1 #define USE_MB_IDENT 1 From e6dad7043682a140ed907b3dd5a79904603fde33 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Feb 2003 17:35:51 +0200 Subject: [PATCH 2/5] Added detection if pthread_attr_getstacksize() exists Fixed bug in RAND() usage in mysqlbinlog configure.in: Added detection if pthread_attr_getstacksize() exists include/thr_lock.h: Fixed wrong comment sql/log_event.cc: Fixed bug in RAND() usage in mysqlbinlog sql/mysqld.cc: Portablity fix sql/repl_failsafe.cc: Set host_or_ip for system threads (to make other code simpler) sql/slave.cc: Set host_or_ip for system threads (to make other code simpler) sql/sql_class.cc: Set host_or_ip for system threads (to make other code simpler) sql/sql_insert.cc: Set host_or_ip for system threads (to make other code simpler) sql/sql_show.cc: Set host_or_ip for system threads (to make other code simpler) --- configure.in | 1 + include/thr_lock.h | 4 ++-- sql/log_event.cc | 4 ++-- sql/mysqld.cc | 2 ++ sql/repl_failsafe.cc | 2 +- sql/slave.cc | 2 +- sql/sql_class.cc | 2 +- sql/sql_insert.cc | 1 + sql/sql_show.cc | 5 +---- 9 files changed, 12 insertions(+), 11 deletions(-) diff --git a/configure.in b/configure.in index b5cf42a7a2e..56a3dbd8bd1 100644 --- a/configure.in +++ b/configure.in @@ -1796,6 +1796,7 @@ AC_CHECK_FUNCS(alarm bmove \ sigset sigthreadmask pthread_sigmask pthread_setprio pthread_setprio_np \ pthread_setschedparam pthread_attr_setprio pthread_attr_setschedparam \ pthread_attr_create pthread_getsequence_np pthread_attr_setstacksize \ + pthread_attr_getstacksize \ pthread_condattr_create rwlock_init pthread_rwlock_rdlock \ fchmod getpass getpassphrase initgroups mlockall) diff --git a/include/thr_lock.h b/include/thr_lock.h index 7459849cb04..6650d25e145 100644 --- a/include/thr_lock.h +++ b/include/thr_lock.h @@ -43,8 +43,8 @@ enum thr_lock_type { TL_IGNORE=-1, */ TL_WRITE_ALLOW_WRITE, /* - Write lock, but allow other threads to read / write. - Used by ALTER TABLE in MySQL to mark to allow readers + Write lock, but allow other threads to read. + Used by ALTER TABLE in MySQL to allow readers to use the table until ALTER TABLE is finished. */ TL_WRITE_ALLOW_READ, diff --git a/sql/log_event.cc b/sql/log_event.cc index e243a953c63..645ac8076df 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -972,14 +972,14 @@ int Rand_log_event::write_data(IO_CACHE* file) #ifdef MYSQL_CLIENT void Rand_log_event::print(FILE* file, bool short_form, char* last_db) { - char llbuff[22]; + char llbuff[22],llbuff2[22]; if (!short_form) { print_header(file); fprintf(file, "\tRand\n"); } fprintf(file, "SET @@RAND_SEED1=%s, @@RAND_SEED2=%s;\n", - llstr(seed1, llbuff),llstr(seed2, llbuff)); + llstr(seed1, llbuff),llstr(seed2, llbuff2)); fflush(file); } #endif diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 72d3295dad4..2e47312f588 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2099,6 +2099,7 @@ int main(int argc, char **argv) (void) pthread_attr_setdetachstate(&connection_attrib, PTHREAD_CREATE_DETACHED); pthread_attr_setstacksize(&connection_attrib,thread_stack); +#ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE { /* Retrieve used stack size; Needed for checking stack overflows */ size_t stack_size; @@ -2110,6 +2111,7 @@ int main(int argc, char **argv) thread_stack= stack_size; } } +#endif if (!(opt_specialflag & SPECIAL_NO_PRIOR)) my_pthread_attr_setprio(&connection_attrib,WAIT_PRIOR); pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM); diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index cbb30cafdc4..e263ca7adeb 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -57,13 +57,13 @@ static int init_failsafe_rpl_thread(THD* thd) { DBUG_ENTER("init_failsafe_rpl_thread"); thd->system_thread = thd->bootstrap = 1; + thd->host_or_ip= ""; thd->client_capabilities = 0; my_net_init(&thd->net, 0); thd->net.read_timeout = slave_net_timeout; thd->max_client_packet_length=thd->net.max_packet; thd->master_access= ~0; thd->priv_user = 0; - thd->system_thread = 1; pthread_mutex_lock(&LOCK_thread_count); thd->thread_id = thread_id++; pthread_mutex_unlock(&LOCK_thread_count); diff --git a/sql/slave.cc b/sql/slave.cc index 64d54be113e..efab5b4c6b9 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1783,6 +1783,7 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) { DBUG_ENTER("init_slave_thread"); thd->system_thread = thd->bootstrap = 1; + thd->host_or_ip= ""; thd->client_capabilities = 0; my_net_init(&thd->net, 0); thd->net.read_timeout = slave_net_timeout; @@ -1790,7 +1791,6 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) thd->priv_user = 0; thd->slave_thread = 1; thd->options = (((opt_log_slave_updates) ? OPTION_BIN_LOG:0) | OPTION_AUTO_IS_NULL) ; - thd->system_thread = 1; thd->client_capabilities = CLIENT_LOCAL_FILES; thd->real_id=pthread_self(); pthread_mutex_lock(&LOCK_thread_count); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 727807415da..e5ba58a0543 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -83,7 +83,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0), global_read_lock(0),bootstrap(0) { host=user=priv_user=db=query=ip=0; - host_or_ip="unknown ip"; + host_or_ip= "connecting host"; locked=killed=count_cuted_fields=some_tables_deleted=no_errors=password= query_start_used=safe_to_cache_query=0; db_length=query_length=col_access=0; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 23563239558..32071e5b083 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -535,6 +535,7 @@ public: bzero((char*) &thd.net,sizeof(thd.net)); // Safety thd.system_thread=1; + thd.host_or_ip= ""; bzero((char*) &info,sizeof(info)); pthread_mutex_init(&mutex,MY_MUTEX_INIT_FAST); pthread_cond_init(&cond,NULL); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 4fca236b165..bf553113d53 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1059,10 +1059,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) thd_info->user=thd->strdup(tmp->user ? tmp->user : (tmp->system_thread ? "system user" : "unauthenticated user")); - thd_info->host=thd->strdup(tmp->host ? tmp->host : - (tmp->ip ? tmp->ip : - (tmp->system_thread ? "none" : - "connecting host"))); + thd_info->host= thd->strdup(tmp->host_or_ip); if ((thd_info->db=tmp->db)) // Safe test thd_info->db=thd->strdup(thd_info->db); thd_info->command=(int) tmp->command; From 41e10e728ea3ad663020e9f0afb21a1fa6532385 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Feb 2003 12:32:37 +0200 Subject: [PATCH 3/5] Added copying of *.slave-mi mysql-test files --- mysql-test/Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index a91baa1538e..d897bdecb59 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -27,7 +27,7 @@ CLEANFILES = $(test_SCRIPTS) dist-hook: mkdir -p $(distdir)/t $(distdir)/r $(distdir)/include \ $(distdir)/std_data - $(INSTALL_DATA) $(srcdir)/t/*.test $(srcdir)/t/*.opt $(srcdir)/t/*.sh $(distdir)/t + $(INSTALL_DATA) $(srcdir)/t/*.test $(srcdir)/t/*.opt $(srcdir)/t/*.sh $(srcdir)/t/*.slave-mi $(distdir)/t $(INSTALL_DATA) $(srcdir)/include/*.inc $(distdir)/include $(INSTALL_DATA) $(srcdir)/r/*.result $(srcdir)/r/*.require $(distdir)/r $(INSTALL_DATA) $(srcdir)/std_data/*.dat $(srcdir)/std_data/*.001 $(distdir)/std_data @@ -41,6 +41,8 @@ install-data-local: $(INSTALL_DATA) $(srcdir)/README $(DESTDIR)$(testdir) $(INSTALL_DATA) $(srcdir)/t/*.test $(DESTDIR)$(testdir)/t $(INSTALL_DATA) $(srcdir)/t/*.opt $(DESTDIR)$(testdir)/t + $(INSTALL_DATA) $(srcdir)/t/*.sh $(DESTDIR)$(testdir)/t + $(INSTALL_DATA) $(srcdir)/t/*.slave-mi $(DESTDIR)$(testdir)/t $(INSTALL_DATA) $(srcdir)/r/*.result $(DESTDIR)$(testdir)/r $(INSTALL_DATA) $(srcdir)/r/*.require $(DESTDIR)$(testdir)/r $(INSTALL_DATA) $(srcdir)/include/*.inc $(DESTDIR)$(testdir)/include From 352beccce6144db231222f32a38595798f77fbe1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Feb 2003 13:27:48 +0200 Subject: [PATCH 4/5] Portability fixes include/config-win.h: Removed wrong ; include/my_global.h: Portability fix for AIX --- include/config-win.h | 2 +- include/my_global.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/config-win.h b/include/config-win.h index c1939e9116f..558fde52e65 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -324,4 +324,4 @@ inline double ulonglong2double(ulonglong value) #define statistic_increment(V,L) thread_safe_increment((V),(L)) #define shared_memory_buffer_length 16000 -#define default_shared_memory_base_name "MYSQL"; +#define default_shared_memory_base_name "MYSQL" diff --git a/include/my_global.h b/include/my_global.h index 60fd8f162ae..f9ce10336d5 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -117,7 +117,7 @@ do the following: */ #if !defined(_XOPEN_SOURCE_EXTENDED) && ! defined(__cplusplus) -#define _XOPEN_SOURCE_EXTENDED +#define _XOPEN_SOURCE_EXTENDED 1 #endif /* Fix type of socklen as this is depending on the above define */ From 2ef62c12aaa7593bff731ccf31575678652141fc Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Feb 2003 14:32:40 +0200 Subject: [PATCH 5/5] Portability fixes cmd-line-utils/libedit/readline.c: Portability fix (For IRIX) include/my_global.h: Portability fix (For Tru64) include/my_xml.h: Portability fix (True64) ('leave' is already defined) strings/xml.c: Portability fix (True64) --- cmd-line-utils/libedit/readline.c | 4 +-- include/my_global.h | 2 +- include/my_xml.h | 26 ++++++++++++------- strings/xml.c | 43 ++++++++++++++++++++++++------- 4 files changed, 53 insertions(+), 22 deletions(-) diff --git a/cmd-line-utils/libedit/readline.c b/cmd-line-utils/libedit/readline.c index 863ee064ab0..9069b46d1f8 100644 --- a/cmd-line-utils/libedit/readline.c +++ b/cmd-line-utils/libedit/readline.c @@ -1239,7 +1239,7 @@ filename_completion_function(const char *text, int state) /* otherwise, get first entry where first */ /* filename_len characters are equal */ if (entry->d_name[0] == filename[0] -#if defined(__SVR4) || defined(__linux__) +#ifdef HAVE_DIRENT_H && strlen(entry->d_name) >= filename_len #else && entry->d_namlen >= filename_len @@ -1252,7 +1252,7 @@ filename_completion_function(const char *text, int state) if (entry) { /* match found */ struct stat stbuf; -#if defined(__SVR4) || defined(__linux__) +#ifdef HAVE_DIRENT_H len = strlen(entry->d_name) + #else len = entry->d_namlen + diff --git a/include/my_global.h b/include/my_global.h index f9ce10336d5..dd1e8986ae2 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -110,6 +110,7 @@ #define __STDC_EXT__ 1 /* To get large file support on hpux */ #endif +#ifdef HPUX11 /* Fix warnings on HPUX11 There is something really strange with HPUX11 include files as you get @@ -121,7 +122,6 @@ #endif /* Fix type of socklen as this is depending on the above define */ -#ifdef HPUX11 #undef SOCKET_SIZE_TYPE #ifdef _XOPEN_SOURCE_EXTENDED #define SOCKET_SIZE_TYPE socklen_t diff --git a/include/my_xml.h b/include/my_xml.h index 0d968ab38c7..82de995e700 100644 --- a/include/my_xml.h +++ b/include/my_xml.h @@ -37,20 +37,26 @@ typedef struct xml_stack_st void *user_data; int (*enter)(struct xml_stack_st *st,const char *val, uint len); int (*value)(struct xml_stack_st *st,const char *val, uint len); - int (*leave)(struct xml_stack_st *st,const char *val, uint len); + int (*leave_xml)(struct xml_stack_st *st,const char *val, uint len); } MY_XML_PARSER; -void my_xml_parser_create(MY_XML_PARSER *st); -void my_xml_parser_free(MY_XML_PARSER *st); -int my_xml_parse(MY_XML_PARSER *st,const char *str, uint len); +void my_xml_parser_create(MY_XML_PARSER *st); +void my_xml_parser_free(MY_XML_PARSER *st); +int my_xml_parse(MY_XML_PARSER *st,const char *str, uint len); -void my_xml_set_value_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *, const char *, uint len)); -void my_xml_set_enter_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *, const char *, uint len)); -void my_xml_set_leave_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *, const char *, uint len)); -void my_xml_set_user_data(MY_XML_PARSER *st, void *); +void my_xml_set_value_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *, + const char *, + uint len)); +void my_xml_set_enter_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *, + const char *, + uint len)); +void my_xml_set_leave_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *, + const char *, + uint len)); +void my_xml_set_user_data(MY_XML_PARSER *st, void *); -uint my_xml_error_pos(MY_XML_PARSER *st); -uint my_xml_error_lineno(MY_XML_PARSER *st); +uint my_xml_error_pos(MY_XML_PARSER *st); +uint my_xml_error_lineno(MY_XML_PARSER *st); const char *my_xml_error_string(MY_XML_PARSER *st); diff --git a/strings/xml.c b/strings/xml.c index 4f6301249ae..793c155ea63 100644 --- a/strings/xml.c +++ b/strings/xml.c @@ -37,6 +37,7 @@ typedef struct xml_attr_st const char *end; } MY_XML_ATTR; + static const char *lex2str(int lex) { switch(lex) @@ -97,7 +98,8 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a) else if ( (p->cur[0]=='"') || (p->cur[0]=='\'') ) { p->cur++; - for( ; ( p->cur < p->end ) && (p->cur[0]!=a->beg[0]); p->cur++); + for( ; ( p->cur < p->end ) && (p->cur[0] != a->beg[0]); p->cur++) + {} a->end=p->cur; if (a->beg[0]==p->cur[0])p->cur++; a->beg++; @@ -106,7 +108,10 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a) } else { - for( ; (p->cur < p->end) && !strchr("?'\"=/<> \t\r\n", p->cur[0]); p->cur++); + for(; + (p->cur < p->end) && !strchr("?'\"=/<> \t\r\n", p->cur[0]); + p->cur++) + {} a->end=p->cur; my_xml_norm_text(a); lex=MY_XML_IDENT; @@ -145,6 +150,7 @@ static int my_xml_enter(MY_XML_PARSER *st, const char *str, uint len) return st->enter ? st->enter(st,st->attr,st->attrend-st->attr) : MY_XML_OK; } + static void mstr(char *s,const char *src,uint l1, uint l2) { l1 = l1leave ? p->leave(p,p->attr,p->attrend-p->attr) : MY_XML_OK; + rc = p->leave_xml ? p->leave_xml(p,p->attr,p->attrend-p->attr) : MY_XML_OK; *e='\0'; p->attrend=e; @@ -237,7 +244,8 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) } else { - sprintf(p->errstr,"3: %s unexpected (ident or '/' wanted)",lex2str(lex)); + sprintf(p->errstr,"3: %s unexpected (ident or '/' wanted)", + lex2str(lex)); return MY_XML_ERROR; } @@ -256,7 +264,8 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) } else { - sprintf(p->errstr,"4: %s unexpected (ident or string wanted)",lex2str(lex)); + sprintf(p->errstr,"4: %s unexpected (ident or string wanted)", + lex2str(lex)); return MY_XML_ERROR; } } @@ -318,35 +327,47 @@ gt: return MY_XML_OK; } + void my_xml_parser_create(MY_XML_PARSER *p) { bzero((void*)p,sizeof(p[0])); } + void my_xml_parser_free(MY_XML_PARSER *p __attribute__((unused))) { } -void my_xml_set_value_handler(MY_XML_PARSER *p, int (*action)(MY_XML_PARSER *p, const char *s, uint l)) + +void my_xml_set_value_handler(MY_XML_PARSER *p, + int (*action)(MY_XML_PARSER *p, const char *s, + uint l)) { p->value=action; } -void my_xml_set_enter_handler(MY_XML_PARSER *p, int (*action)(MY_XML_PARSER *p, const char *s, uint l)) +void my_xml_set_enter_handler(MY_XML_PARSER *p, + int (*action)(MY_XML_PARSER *p, const char *s, + uint l)) { p->enter=action; } -void my_xml_set_leave_handler(MY_XML_PARSER *p, int (*action)(MY_XML_PARSER *p, const char *s, uint l)) + +void my_xml_set_leave_handler(MY_XML_PARSER *p, + int (*action)(MY_XML_PARSER *p, const char *s, + uint l)) { - p->leave=action; + p->leave_xml=action; } + void my_xml_set_user_data(MY_XML_PARSER *p, void *user_data) { p->user_data=user_data; } + const char *my_xml_error_string(MY_XML_PARSER *p) { return p->errstr; @@ -358,8 +379,10 @@ uint my_xml_error_pos(MY_XML_PARSER *p) const char *beg=p->beg; const char *s; for ( s=p->beg ; scur; s++) + { if (s[0]=='\n') beg=s; + } return p->cur-beg; } @@ -368,7 +391,9 @@ uint my_xml_error_lineno(MY_XML_PARSER *p) uint res=0; const char *s; for ( s=p->beg ; scur; s++) + { if (s[0]=='\n') res++; + } return res; }