diff options
author | monty@mysql.com <> | 2004-09-03 02:26:00 +0300 |
---|---|---|
committer | monty@mysql.com <> | 2004-09-03 02:26:00 +0300 |
commit | 936eb4b4f4d7bc1a8f83fdfeda2c445315819dc3 (patch) | |
tree | e958f1bab0d9af79473522448e052009f5315c5c /sql | |
parent | 5bd4d59508909facecda6cdb160264a4aca51d37 (diff) | |
parent | bb4ccdb1772ba979d132aeda270288033ff86fd2 (diff) | |
download | mariadb-git-936eb4b4f4d7bc1a8f83fdfeda2c445315819dc3.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/my/mysql-4.1
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.h | 4 | ||||
-rw-r--r-- | sql/gen_lex_hash.cc | 2 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 1 | ||||
-rw-r--r-- | sql/lock.cc | 3 | ||||
-rw-r--r-- | sql/log.cc | 157 | ||||
-rw-r--r-- | sql/log_event.cc | 4 | ||||
-rw-r--r-- | sql/mysqld.cc | 14 | ||||
-rw-r--r-- | sql/sql_base.cc | 22 | ||||
-rw-r--r-- | sql/sql_class.cc | 3 | ||||
-rw-r--r-- | sql/sql_load.cc | 2 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 7 | ||||
-rw-r--r-- | sql/sql_select.cc | 4 | ||||
-rw-r--r-- | sql/sql_table.cc | 2 | ||||
-rw-r--r-- | sql/table.cc | 11 |
14 files changed, 138 insertions, 98 deletions
diff --git a/sql/field.h b/sql/field.h index 9cce7b9541b..e12dd60c13b 100644 --- a/sql/field.h +++ b/sql/field.h @@ -908,7 +908,7 @@ public: void reset(void) { charset()->cset->fill(charset(),ptr,field_length,' '); } int store(const char *to,uint length,CHARSET_INFO *charset); int store(longlong nr); - int store(double nr) { return Field_str::store(nr); } + int store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */ double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -955,7 +955,7 @@ public: uint32 key_length() const { return (uint32) field_length; } int store(const char *to,uint length,CHARSET_INFO *charset); int store(longlong nr); - int store(double nr) { return Field_str::store(nr); } + int store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */ double val_real(void); longlong val_int(void); String *val_str(String*,String *); diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index cb97febea32..0bbdf84c8d6 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -362,7 +362,7 @@ static int get_options(int argc, char **argv) { int ho_error; - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, 0))) + if ((ho_error= handle_options(&argc, &argv, my_long_options, get_one_option))) exit(ho_error); if (argc >= 1) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 4ddb648399a..f473d242b07 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2752,7 +2752,6 @@ longlong Item_cond_xor::val_int() Item *Item_func_not::neg_transformer(THD *thd) /* NOT(x) -> x */ { - // We should apply negation elimination to the argument of the NOT function return args[0]; } diff --git a/sql/lock.cc b/sql/lock.cc index fab0a61e506..215059b8a46 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -779,7 +779,8 @@ void unlock_global_read_lock(THD *thd) (is_not_commit || \ global_read_lock_blocks_commit)) -bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh, bool is_not_commit) +bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh, + bool is_not_commit) { const char *old_message; bool result= 0, need_exit_cond; diff --git a/sql/log.cc b/sql/log.cc index f4ec5d9c731..08c1b31ed0d 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -43,37 +43,41 @@ static bool test_if_number(const char *str, #ifdef __NT__ static int eventSource = 0; -void setupWindowsEventSource() -{ - if (eventSource) return; - - eventSource = 1; - HKEY hRegKey = NULL; - DWORD dwError = 0; - TCHAR szPath[ MAX_PATH ]; - // Create the event source registry key - dwError = RegCreateKey(HKEY_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\MySQL", - &hRegKey); +void setup_windows_event_source() +{ + HKEY hRegKey= NULL; + DWORD dwError= 0; + TCHAR szPath[MAX_PATH]; + DWORD dwTypes; + + if (eventSource) // Ensure that we are only called once + return; + eventSource= 1; - // Name of the PE module that contains the message resource - GetModuleFileName(NULL, szPath, MAX_PATH); + // Create the event source registry key + dwError= RegCreateKey(HKEY_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\MySQL", + &hRegKey); - // Register EventMessageFile - dwError = RegSetValueEx(hRegKey, "EventMessageFile", 0, REG_EXPAND_SZ, - (PBYTE) szPath, strlen(szPath)+1); + /* Name of the PE module that contains the message resource */ + GetModuleFileName(NULL, szPath, MAX_PATH); + /* Register EventMessageFile */ + dwError = RegSetValueEx(hRegKey, "EventMessageFile", 0, REG_EXPAND_SZ, + (PBYTE) szPath, strlen(szPath)+1); + - // Register supported event types - DWORD dwTypes = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE; - dwError = RegSetValueEx(hRegKey, "TypesSupported", 0, REG_DWORD, - (LPBYTE) &dwTypes, sizeof dwTypes); + /* Register supported event types */ + dwTypes= (EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | + EVENTLOG_INFORMATION_TYPE); + dwError= RegSetValueEx(hRegKey, "TypesSupported", 0, REG_DWORD, + (LPBYTE) &dwTypes, sizeof dwTypes); - RegCloseKey(hRegKey); + RegCloseKey(hRegKey); } -#endif +#endif /* __NT__ */ /**************************************************************************** @@ -1413,12 +1417,24 @@ COLLATION_CONNECTION=%u,COLLATION_DATABASE=%u,COLLATION_SERVER=%u", /* Write log events to reset the 'run environment' of the SQL command */ - if (thd && thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) + if (thd) { - Query_log_event e(thd, "SET FOREIGN_KEY_CHECKS=1", 24, 0); - e.set_log_pos(this); - if (e.write(file)) - goto err; + if (thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) + { + Query_log_event e(thd, "SET FOREIGN_KEY_CHECKS=1", 24, 0); + e.set_log_pos(this); + if (e.write(file)) + goto err; + } +#if MYSQL_VERSION_ID < 40100 + if (thd->variables.convert_set) + { + Query_log_event e(thd, "SET CHARACTER SET DEFAULT", 25, 0); + e.set_log_pos(this); + if (e.write(file)) + goto err; + } +#endif } /* @@ -1984,8 +2000,8 @@ void print_buffer_to_file(enum loglevel level, const char *buffer) time_t skr; struct tm tm_tmp; struct tm *start; - - DBUG_ENTER("print_buffer_to_log"); + DBUG_ENTER("print_buffer_to_file"); + DBUG_PRINT("enter",("buffer: %s", buffer)); VOID(pthread_mutex_lock(&LOCK_error_log)); @@ -1999,13 +2015,13 @@ void print_buffer_to_file(enum loglevel level, const char *buffer) start->tm_hour, start->tm_min, start->tm_sec, - level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ? "WARNING" : "INFORMATION", - buffer); + (level == ERROR_LEVEL ? "ERROR" : level == WARNING_LEVEL ? + "WARNING" : "INFORMATION"), + buffer); fflush(stderr); VOID(pthread_mutex_unlock(&LOCK_error_log)); - DBUG_VOID_RETURN; } @@ -2019,6 +2035,7 @@ void sql_perror(const char *message) #endif } + bool flush_error_log() { bool result=0; @@ -2204,93 +2221,95 @@ void MYSQL_LOG::report_pos_in_innodb() } #ifdef __NT__ -void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, int buffLen) +void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, + uint length, int buffLen) { HANDLE event; char *buffptr; LPCSTR *buffmsgptr; - DBUG_ENTER("print_buffer_to_nt_eventlog"); - buffptr = buff; - if (strlen(buff) > (uint)(buffLen-4)) + buffptr= buff; + if (length > (uint)(buffLen-4)) { - char *newBuff = new char[ strlen(buff) + 4 ]; + char *newBuff= new char[length + 4]; strcpy(newBuff, buff); - buffptr = newBuff; + buffptr= newBuff; } - strcat(buffptr, "\r\n\r\n"); - buffmsgptr = (LPCSTR*)&buffptr; + strmov(buffptr+length, "\r\n\r\n"); + buffmsgptr= (LPCSTR*) &buffptr; // Keep windows happy - setupWindowsEventSource(); - if (event = RegisterEventSource(NULL,"MySQL")) + setup_windows_event_source(); + if ((event= RegisterEventSource(NULL,"MySQL"))) { - switch (level){ + switch (level) { case ERROR_LEVEL: - ReportEvent(event, EVENTLOG_ERROR_TYPE, 0, MSG_DEFAULT, NULL, 1, 0, buffmsgptr, NULL); + ReportEvent(event, EVENTLOG_ERROR_TYPE, 0, MSG_DEFAULT, NULL, 1, 0, + buffmsgptr, NULL); break; case WARNING_LEVEL: - ReportEvent(event, EVENTLOG_WARNING_TYPE, 0, MSG_DEFAULT, NULL, 1, 0, buffmsgptr, NULL); + ReportEvent(event, EVENTLOG_WARNING_TYPE, 0, MSG_DEFAULT, NULL, 1, 0, + buffmsgptr, NULL); break; case INFORMATION_LEVEL: - ReportEvent(event, EVENTLOG_INFORMATION_TYPE, 0, MSG_DEFAULT, NULL, 1, 0, buffmsgptr, NULL); + ReportEvent(event, EVENTLOG_INFORMATION_TYPE, 0, MSG_DEFAULT, NULL, 1, + 0, buffmsgptr, NULL); break; } DeregisterEventSource(event); } - // if we created a string buffer, then delete it + /* if we created a string buffer, then delete it */ if (buffptr != buff) delete[] buffptr; DBUG_VOID_RETURN; } -#endif +#endif /* __NT__ */ + /* - Prints a printf style message to the error log and, under NT, to the Windows event log. + Prints a printf style message to the error log and, under NT, to the + Windows event log. SYNOPSIS vprint_msg_to_log() - event_type Type of event to write (Error, Warning, or Info) - format Printf style format of message - args va_list list of arguments for the message + event_type Type of event to write (Error, Warning, or Info) + format Printf style format of message + args va_list list of arguments for the message NOTE IMPLEMENTATION - This function prints the message into a buffer and then sends that buffer to other - functions to write that message to other logging sources. + This function prints the message into a buffer and then sends that buffer + to other functions to write that message to other logging sources. RETURN VALUES void */ + void vprint_msg_to_log(enum loglevel level, const char *format, va_list args) { char buff[1024]; + uint length; DBUG_ENTER("vprint_msg_to_log"); - my_vsnprintf(buff, sizeof(buff)-5, format, args); - + length= my_vsnprintf(buff, sizeof(buff)-5, format, args); print_buffer_to_file(level, buff); -#ifndef DBUG_OFF - DBUG_PRINT("error",("%s",buff)); -#endif - #ifdef __NT__ - print_buffer_to_nt_eventlog(level, buff, sizeof(buff)); + print_buffer_to_nt_eventlog(level, buff, length, sizeof(buff)); #endif DBUG_VOID_RETURN; } -void sql_print_error(const char *format, ...) +void sql_print_error(const char *format, ...) { + va_list args; DBUG_ENTER("sql_print_error"); - va_list args; va_start(args, format); vprint_msg_to_log(ERROR_LEVEL, format, args); va_end(args); @@ -2298,11 +2317,12 @@ void sql_print_error(const char *format, ...) DBUG_VOID_RETURN; } -void sql_print_warning(const char *format, ...) + +void sql_print_warning(const char *format, ...) { + va_list args; DBUG_ENTER("sql_print_warning"); - va_list args; va_start(args, format); vprint_msg_to_log(WARNING_LEVEL, format, args); va_end(args); @@ -2310,11 +2330,12 @@ void sql_print_warning(const char *format, ...) DBUG_VOID_RETURN; } -void sql_print_information(const char *format, ...) + +void sql_print_information(const char *format, ...) { + va_list args; DBUG_ENTER("sql_print_information"); - va_list args; va_start(args, format); vprint_msg_to_log(INFORMATION_LEVEL, format, args); va_end(args); diff --git a/sql/log_event.cc b/sql/log_event.cc index d10b83d550a..ef77aa6603b 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1084,10 +1084,6 @@ end: thd->query= 0; // just to be sure thd->query_length= 0; VOID(pthread_mutex_unlock(&LOCK_thread_count)); - // assume no convert for next query unless set explictly -#ifdef TO_BE_REMOVED - thd->variables.convert_set = 0; -#endif close_thread_tables(thd); free_root(&thd->mem_root,MYF(MY_KEEP_PREALLOC)); return (thd->query_error ? thd->query_error : Log_event::exec_event(rli)); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e7638f13526..7fb9f5f8348 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6108,14 +6108,16 @@ mysql_getopt_value(const char *keyname, uint key_length, return option->value; } -void option_error_reporter( enum loglevel level, const char *format, ... ) + +void option_error_reporter(enum loglevel level, const char *format, ...) { va_list args; - va_start( args, format ); - vprint_msg_to_log( level, format, args ); - va_end( args ); + va_start(args, format); + vprint_msg_to_log(level, format, args); + va_end(args); } + static void get_options(int argc,char **argv) { int ho_error; @@ -6123,7 +6125,9 @@ static void get_options(int argc,char **argv) my_getopt_register_get_addr(mysql_getopt_value); strmake(def_ft_boolean_syntax, ft_boolean_syntax, sizeof(ft_boolean_syntax)-1); - if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option, option_error_reporter))) + my_getopt_error_reporter= option_error_reporter; + if ((ho_error= handle_options(&argc, &argv, my_long_options, + get_one_option))) exit(ho_error); if (argc > 0) { diff --git a/sql/sql_base.cc b/sql/sql_base.cc index ea7b4521247..ac5008717e6 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2138,7 +2138,10 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter, select list over other fields from the tables participating in this select in case of ambiguity. - QQ: Why do we use simple strcmp for table name comparison here ? + We use strcmp for table names and database names as these may be + case sensitive. + In cases where they are not case sensitive, they are always in lower + case. */ if (!my_strcasecmp(system_charset_info, item_field->field_name, field_name) && @@ -2157,10 +2160,12 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter, } found= li.ref(); *counter= i; + if (db_name) + break; // Perfect match } } else if (!my_strcasecmp(system_charset_info, item_field->name, - field_name)) + field_name)) { /* If table name was not given we should scan through aliases @@ -2230,7 +2235,7 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter, } if (found) return found; - else if (report_error != REPORT_EXCEPT_NOT_FOUND) + if (report_error != REPORT_EXCEPT_NOT_FOUND) { if (report_error == REPORT_ALL_ERRORS) my_printf_error(ER_BAD_FIELD_ERROR, ER(ER_BAD_FIELD_ERROR), MYF(0), @@ -2445,13 +2450,16 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name, uint found; DBUG_ENTER("insert_fields"); - if (db_name && lower_case_table_names) { - /* convert database to lower case for comparison */ + /* + convert database to lower case for comparison + We can't do this in Item_field as this would change the + 'name' of the item which may be used in the select list + */ strmake(name_buff, db_name, sizeof(name_buff)-1); - my_casedn_str(system_charset_info,name_buff); - db_name = name_buff; + my_casedn_str(files_charset_info, name_buff); + db_name= name_buff; } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 36b1b89f6bf..b103ee29095 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -891,7 +891,8 @@ static File create_file(THD *thd, char *path, sql_exchange *exchange, option|= MY_REPLACE_DIR; // Force use of db directory #endif - strxnmov(path, FN_REFLEN, mysql_real_data_home, thd->db ? thd->db : ""); + strxnmov(path, FN_REFLEN, mysql_real_data_home, thd->db ? thd->db : "", + NullS); (void) fn_format(path, exchange->file_name, path, "", option); if (!access(path, F_OK)) { diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 1f4905837f0..1ad9a6aa952 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -183,7 +183,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, strlen(ex->file_name)+strlen(mysql_real_data_home)+strlen(tdb)+3 < FN_REFLEN) { - (void) sprintf(name,"%s/%s/%s",mysql_data_home,tdb,ex->file_name); + (void) sprintf(name,"%s%s/%s",mysql_real_data_home,tdb,ex->file_name); unpack_filename(name,name); /* Convert to system format */ } else diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 25b6434c184..1b6c7dbc9bc 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1051,7 +1051,7 @@ static int mysql_test_select(Prepared_statement *stmt, THD *thd= stmt->thd; LEX *lex= stmt->lex; SELECT_LEX_UNIT *unit= &lex->unit; - + int result= 1; DBUG_ENTER("mysql_test_select"); #ifndef NO_EMBEDDED_ACCESS_CHECKS @@ -1097,13 +1097,12 @@ static int mysql_test_select(Prepared_statement *stmt, goto err_prep; } } - unit->cleanup(); - DBUG_RETURN(0); + result= 0; // ok err_prep: unit->cleanup(); err: - DBUG_RETURN(1); + DBUG_RETURN(result); } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 72e169c77af..f3eed672231 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3220,7 +3220,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse, store_key **ref_key= j->ref.key_copy; byte *key_buff=j->ref.key_buff, *null_ref_key= 0; - bool keyuse_uses_no_tables= true; + bool keyuse_uses_no_tables= TRUE; if (ftkey) { j->ref.items[0]=((Item_func*)(keyuse->val))->key_item(); @@ -3240,7 +3240,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse, uint maybe_null= test(keyinfo->key_part[i].null_bit); j->ref.items[i]=keyuse->val; // Save for cond removal - keyuse_uses_no_tables= keyuse_uses_no_tables & !keyuse->used_tables; + keyuse_uses_no_tables= keyuse_uses_no_tables && !keyuse->used_tables; if (!keyuse->used_tables && !(join->select_options & SELECT_DESCRIBE)) { // Compare against constant diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 408f3408346..58e3bc1d9ac 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1579,7 +1579,7 @@ static int prepare_for_restore(THD* thd, TABLE_LIST* table, reg_ext)) DBUG_RETURN(-1); // protect buffer overflow - my_snprintf(dst_path, sizeof(dst_path), "%s/%s/%s", + my_snprintf(dst_path, sizeof(dst_path), "%s%s/%s", mysql_real_data_home, db, table_name); if (lock_and_wait_for_table_name(thd,table)) diff --git a/sql/table.cc b/sql/table.cc index 7d1c733b116..8b018d61e5a 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1084,6 +1084,17 @@ void append_unescaped(String *res, const char *pos, uint length) for (; pos != end ; pos++) { +#if defined(USE_MB) && MYSQL_VERSION_ID < 40100 + uint mblen; + if (use_mb(default_charset_info) && + (mblen= my_ismbchar(default_charset_info, pos, end))) + { + res->append(pos, mblen); + pos+= mblen; + continue; + } +#endif + switch (*pos) { case 0: /* Must be escaped for 'mysql' */ res->append('\\'); |