From 6ca8d50cb14ac9171f4e3cf29483c414c93710e8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 Aug 2001 12:01:35 -0600 Subject: fixed bug in Item_func_div::val_int() that broke all functions that do val_int() on their arguments before starting the computation. Similar fixes are need for +-* and probably several other but I want to make sure Monty is fine with my fix approach before changing a lot of code. Amazingly, this bug is not as critical as you would expect since very few functions do val_int() on their arguments ( from_unixtime(), sec_to_time()), and those not very frequently perform a computation on their floating point arguments. which is probably why no one has yet reported this bug. Another possibility is that the result is usually wrong by no more than 5%, which makes it hard to catch it. I found it when trying to compute mile splits for 30:47 10K - it told me 5:07, and I knew it was wrong because 5:00 mile gives you 31:08. However, if I had not run as many 10K races, I would have easily believed that 30:47 10K is a 5:07 mile pace and would not have noticed the bug. mysql-test/r/func_time.result: another test for sec_to_time that exposes a long outstanding bug mysql-test/t/func_time.test: another test for sec_to_time that exposes a long outstanding bug sql/item_func.cc: fixed bug in Item_func_div::val_int() --- sql/item_func.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'sql') diff --git a/sql/item_func.cc b/sql/item_func.cc index 10298ce67f2..1d1a72d35eb 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -309,11 +309,14 @@ double Item_func_div::val() longlong Item_func_div::val_int() { - longlong value=args[0]->val_int(); - longlong val2=args[1]->val_int(); - if ((null_value= val2 == 0 || args[0]->null_value || args[1]->null_value)) - return 0; - return value/val2; + // the integer result of division of two arguments needs to be computed + // as a type-cast division of val(), not as diviion of val_int() of each + // argument. For example, val_int(41.5/3.4) = val_int(12.206) = 12, but + // if you do val_int(41.5)/val_int(3.4), as in the old code, we get 42/3= + // 14, which is wrong. This would break sec_to_time(a/b), + // from_unixtime(a/b), and + // all functions that do val_int() on their arguments + return (longlong)val(); } void Item_func_div::fix_length_and_dec() -- cgit v1.2.1 From 57b1a50c811964b9cf772e070b5e813347ab74b1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Aug 2001 21:19:10 +0300 Subject: ha_innobase.cc Impove ref length estimate in a handle to eliminate a warning in filesort sql/ha_innobase.cc: Impove ref length estimate in a handle to eliminate a warning in filesort --- sql/ha_innobase.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'sql') diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index d0cb8af906a..babe281bd4e 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -821,10 +821,6 @@ ha_innobase::open( DBUG_RETURN(1); } - /* MySQL allocates the buffer for ref */ - - ref_length = buff_len; - /* Get pointer to a table object in InnoDB dictionary cache */ if (NULL == (ib_table = dict_table_get(norm_name, NULL))) { @@ -861,10 +857,20 @@ ha_innobase::open( primary_key = 0; key_used_on_scan = 0; + + /* MySQL allocates the buffer for ref */ + + ref_length = table->key_info->key_length + + table->key_info->key_parts + 10; + + /* One byte per key field is consumed to the SQL NULL + info of the field; we add also 10 bytes of safety margin */ } else { ((row_prebuilt_t*)innobase_prebuilt) ->clust_index_was_generated = TRUE; + ref_length = DATA_ROW_ID_LEN + 10; + dbug_assert(key_used_on_scan == MAX_KEY); } -- cgit v1.2.1 From d01f2efebfd97c63b41f609bf887c92c883fc229 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 18 Aug 2001 10:49:00 +0300 Subject: Portability fixes. Let myisamchk generate a new checksum for compressed data. Don't unconditionally force filenames to lower case on windows. Update mysqltest to match 4.0 source (to get some of the new bug fixes into 3.23) Docs/manual.texi: Link changes, and new comments about IA64 and about Sun workshop client/mysqltest.c: Updated this to match the 4.0 source include/config-win.h: Don't unconditionally force filenames to lower case on windows. innobase/include/ut0ut.h: Portability fix myisam/mi_cache.c: Fix problem where reported error number was -1 myisam/mi_check.c: Let myisamchk generate a new checksum for compressed data. myisam/mi_packrec.c: Cleanup myisam/myisamchk.c: Report checksum for compressed tables mysql-test/t/bdb.test: Fix to match new mysqltest mysql-test/t/err000001.test: Fix to match new mysqltest mysql-test/t/fulltext.test: Fix to match new mysqltest mysql-test/t/innodb.test: Fix to match new mysqltest mysql-test/t/overflow.test: Fix to match new mysqltest sql/ha_gemini.cc: Fix false -> FALSE sql/share/estonian/errmsg.txt: Updated of translation sql/share/swedish/errmsg.txt: Updated of translation sql/sql_parse.cc: Don't unconditionally force filenames to lower case on windows. sql/sql_table.cc: Don't unconditionally force filenames to lower case on windows. sql/sql_test.cc: Write current directory when using 'mysqladmin debug' strings/strto.c: Portability fix strings/strtoll.c: Portability fix strings/strtoul.c: Portability fix strings/strtoull.c: Portability fix --- sql/ha_gemini.cc | 14 +++++++------- sql/share/estonian/errmsg.txt | 24 ++++++++++++------------ sql/share/swedish/errmsg.txt | 14 +++++++------- sql/sql_parse.cc | 2 +- sql/sql_table.cc | 8 ++++---- sql/sql_test.cc | 3 +++ 6 files changed, 34 insertions(+), 31 deletions(-) (limited to 'sql') diff --git a/sql/ha_gemini.cc b/sql/ha_gemini.cc index e80d9a001e6..75ffe4bd0ee 100644 --- a/sql/ha_gemini.cc +++ b/sql/ha_gemini.cc @@ -955,7 +955,7 @@ int ha_gemini::handleIndexEntry(const byte * record, dsmRecid_t recid, thd = current_thd; key_info=table->key_info+keynr; - thereIsAnull = false; + thereIsAnull = FALSE; rc = createKeyString(record, key_info, theKey.akey.keystr, sizeof(theKey.apad),&keyStringLen, (short)pindexNumbers[keynr], @@ -1067,7 +1067,7 @@ int ha_gemini::createKeyString(const byte * record, KEY *pkeyinfo, isNull = record[key_part->null_offset] & key_part->null_bit; if(isNull) - *thereIsAnull = true; + *thereIsAnull = TRUE; rc = gemFieldToIdxComponent(pos, (unsigned long) key_part_length, @@ -1107,7 +1107,7 @@ int ha_gemini::update_row(const byte * old_record, byte * new_record) } for (uint keynr=0 ; keynr < table->keys ; keynr++) { - if(key_cmp(keynr,old_record, new_record,false)) + if(key_cmp(keynr,old_record, new_record,FALSE)) { error = handleIndexEntry(old_record,lastRowid,KEY_DELETE,keynr); if(error) @@ -2430,8 +2430,8 @@ int ha_gemini::analyze(THD* thd, HA_CHECK_OPT* check_opt) uint saveIsolation; dsmMask_t saveLockMode; - check_opt->quick = true; - check_opt->optimize = true; // Tells check not to get table lock + check_opt->quick = TRUE; + check_opt->optimize = TRUE; // Tells check not to get table lock saveLockMode = lockMode; saveIsolation = thd->gemini.tx_isolation; thd->gemini.tx_isolation = ISO_READ_UNCOMMITTED; @@ -2503,7 +2503,7 @@ int ha_gemini::check(THD* thd, HA_CHECK_OPT* check_opt) error = fetch_row(thd->gemini.context,buf); if(!error) { - if(key_cmp(i,buf,indexBuf,false)) + if(key_cmp(i,buf,indexBuf,FALSE)) { gemini_msg((dsmContext_t *)thd->gemini.context, @@ -2534,7 +2534,7 @@ int ha_gemini::check(THD* thd, HA_CHECK_OPT* check_opt) } } - key_cmp(i,indexBuf,prevBuf,true); + key_cmp(i,indexBuf,prevBuf,TRUE); bcopy((void *)indexBuf,(void *)prevBuf,table->rec_buff_length); if(!error) diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index 816997f5266..59a8b156ab2 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -177,19 +177,19 @@ "Can't write, because of unique constraint, to table '%-.64s'", "BLOB column '%-.64s' used in key specification without a key length", "All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead", -"Result consisted of more than one row", +"Tulemis on rohkem kui üks kirje", "This table type requires a primary key", "Antud MySQL ei ole kompileeritud RAID-i toega", "You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column", "Key '%-.64s' doesn't exist in table '%-.64s'", -"Can't open table", -"The handler for the table doesn't support check/repair", -"You are not allowed to execute this command in a transaction", -"Got error %d during COMMIT", -"Got error %d during ROLLBACK", -"Got error %d during FLUSH_LOGS", -"Got error %d during CHECKPOINT", -"Aborted connection %ld to db: '%-.64s' user: '%-.32s' host: `%-.64s' (%-.64s)", +"Ei suuda tabelit avada", +"See tabelitüüp ei toeta käske CHECK/REPAIR", +"Puudub õigus selle transaktsioonikäsu andmiseks", +"Sain vea %d COMMIT käsu täitmisel", +"Sain vea %d ROLLBACK käsu täitmisel", +"Sain vea %d FLUSH_LOGS käsu täitmisel", +"Sain vea %d CHECKPOINT käsu täitmisel", +"Ühendus %ld katkestatud andmebaas: '%-.64s' kasutaja: '%-.32s' masin: `%-.64s' (%-.64s)", "The handler for the table does not support binary table dump", "Binlog closed while trying to FLUSH MASTER", "Failed rebuilding the index of dumped table '%-.64s'", @@ -198,9 +198,9 @@ "Net error writing to master", "Can't find FULLTEXT index matching the column list", "Can't execute the given command because you have active locked tables or an active transaction", -"Unknown system variable '%-.64'", -"Table '%-.64s' is marked as crashed and should be repaired", -"Table '%-.64s' is marked as crashed and last (automatic?) repair failed", +"Tundmatu süsteemne muutja '%-.64'", +"Tabel '%-.64s' on märgitud vigaseks ja tuleb parandada", +"Tabel '%-.64s' on märgitud vigaseks ja viimane (automaatne?) parandamiskatse ebaõnnestus", "Warning: Some non-transactional changed tables couldn't be rolled back", "Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage. Increase this mysqld variable and try again', "This operation cannot be performed with a running slave, run SLAVE STOP first", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 79380cbc501..5914ea31188 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -205,11 +205,11 @@ "Kunde inte initializera replications-strukturerna. Kontrollera privilegerna för 'master.info'", "Kunde inte starta en tråd för replikering", "Användare '%-.64s' har redan 'max_user_connections' aktiva inloggningar", -"Du kan endast använda konstant-uttryck med SET", -"Lock wait timeout exceeded", -"The total number of locks exceeds the lock table size", -"Update locks cannot be acquired during a READ UNCOMMITTED transaction", -"DROP DATABASE not allowed while thread is holding global read lock", -"CREATE DATABASE not allowed while thread is holding global read lock", +"Man kan endast använda konstant-uttryck med SET", +"Fick inte ett lås i tid", +"Antal lås överskrider antalet reserverade lås", +"Updaterings-lås kan inte göras när man använder READ UNCOMMITTED", +"DROP DATABASE är inte tillåtet när man har ett globalt läs-lås", +"CREATE DATABASE är inte tillåtet när man har ett globalt läs-lås", "Felaktiga argument till %s", -"%-.32s@%-.64s is not allowed to create new users", +"%-.32s@%-.64s har inte rättigheter att skapa nya användare", diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 1e42e776d44..8c3f2759e9a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2667,7 +2667,7 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias, DBUG_RETURN(0); } -#ifdef FN_LOWER_CASE +#ifdef FN_NO_CASE_SENCE if (!alias) /* Alias is case sensitive */ if (!(alias_str=sql_strmake(alias_str,table->table.length))) DBUG_RETURN(0); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 44372ad4800..ca703cca4c5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1125,7 +1125,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, { strmov(new_name_buff,new_name); fn_same(new_name_buff,table_name,3); -#ifdef FN_LOWER_CASE +#ifdef FN_NO_CASE_SENCE if (lower_case_table_names) casedn_str(new_name); if ((lower_case_table_names && @@ -1709,7 +1709,7 @@ copy_data_between_tables(TABLE *from,TABLE *to, /* Turn off recovery logging since rollback of an alter table is to delete the new table so there is no need to log the changes to it. */ - error = ha_recovery_logging(thd,false); + error = ha_recovery_logging(thd,FALSE); if (error) { error = 1; @@ -1761,7 +1761,7 @@ copy_data_between_tables(TABLE *from,TABLE *to, if (to->file->activate_all_index(thd)) error=1; - tmp_error = ha_recovery_logging(thd,true); + tmp_error = ha_recovery_logging(thd,TRUE); /* Ensure that the new table is saved properly to disk so that we can do a rename @@ -1773,7 +1773,7 @@ copy_data_between_tables(TABLE *from,TABLE *to, if (to->file->external_lock(thd,F_UNLCK)) error=1; err: - tmp_error = ha_recovery_logging(thd,true); + tmp_error = ha_recovery_logging(thd,TRUE); free_io_cache(from); *copied= found_count; *deleted=delete_count; diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 3edfdd3d5ef..c4c2855a63e 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -189,7 +189,10 @@ TEST_join(JOIN *join) void mysql_print_status(THD *thd) { + char current_dir[FN_REFLEN]; printf("\nStatus information:\n\n"); + my_getwd(current_dir, sizeof(current_dir),MYF(0)); + printf("Current dir: %s\n", current_dir); if (thd) thd->proc_info="locks"; thr_print_locks(); // Write some debug info -- cgit v1.2.1 From a14d63ba6e6b9ee411ac576e513fa31f652138e6 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 18 Aug 2001 14:24:01 +0300 Subject: Fix for handling of floats inside val_int() of +, - * and /. Build-tools/Do-compile: Make shutdown safer Docs/manual.texi: Fix of bad merge sql/log.cc: cleanup sql/sql_acl.cc: cleanup --- sql/item_func.cc | 54 ++++++++++++++++++++++++++++++++++-------------------- sql/log.cc | 10 +++++----- sql/sql_acl.cc | 2 +- 3 files changed, 40 insertions(+), 26 deletions(-) (limited to 'sql') diff --git a/sql/item_func.cc b/sql/item_func.cc index 1d1a72d35eb..ef3372629f6 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -259,10 +259,14 @@ double Item_func_plus::val() longlong Item_func_plus::val_int() { - longlong value=args[0]->val_int()+args[1]->val_int(); - if ((null_value=args[0]->null_value || args[1]->null_value)) - return 0; - return value; + if (hybrid_type == INT_RESULT) + { + longlong value=args[0]->val_int()+args[1]->val_int(); + if ((null_value=args[0]->null_value || args[1]->null_value)) + return 0; + return value; + } + return (longlong) Item_func_plus::val(); } double Item_func_minus::val() @@ -275,12 +279,17 @@ double Item_func_minus::val() longlong Item_func_minus::val_int() { - longlong value=args[0]->val_int() - args[1]->val_int(); - if ((null_value=args[0]->null_value || args[1]->null_value)) - return 0; - return value; + if (hybrid_type == INT_RESULT) + { + longlong value=args[0]->val_int() - args[1]->val_int(); + if ((null_value=args[0]->null_value || args[1]->null_value)) + return 0; + return value; + } + return (longlong) Item_func_minus::val(); } + double Item_func_mul::val() { double value=args[0]->val()*args[1]->val(); @@ -291,10 +300,14 @@ double Item_func_mul::val() longlong Item_func_mul::val_int() { - longlong value=args[0]->val_int()*args[1]->val_int(); - if ((null_value=args[0]->null_value || args[1]->null_value)) - return 0; /* purecov: inspected */ - return value; + if (hybrid_type == INT_RESULT) + { + longlong value=args[0]->val_int()*args[1]->val_int(); + if ((null_value=args[0]->null_value || args[1]->null_value)) + return 0; /* purecov: inspected */ + return value; + } + return (longlong) Item_func_mul::val(); } @@ -309,14 +322,15 @@ double Item_func_div::val() longlong Item_func_div::val_int() { - // the integer result of division of two arguments needs to be computed - // as a type-cast division of val(), not as diviion of val_int() of each - // argument. For example, val_int(41.5/3.4) = val_int(12.206) = 12, but - // if you do val_int(41.5)/val_int(3.4), as in the old code, we get 42/3= - // 14, which is wrong. This would break sec_to_time(a/b), - // from_unixtime(a/b), and - // all functions that do val_int() on their arguments - return (longlong)val(); + if (hybrid_type == INT_RESULT) + { + longlong value=args[0]->val_int(); + longlong val2=args[1]->val_int(); + if ((null_value= val2 == 0 || args[0]->null_value || args[1]->null_value)) + return 0; + return value/val2; + } + return (longlong) Item_func_div::val(); } void Item_func_div::fix_length_and_dec() diff --git a/sql/log.cc b/sql/log.cc index 33e6ba1de45..d7825ce0e93 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -149,11 +149,11 @@ void MYSQL_LOG::init(enum_log_type log_type_arg) void MYSQL_LOG::close_index() { - if(index_file >= 0) - { - my_close(index_file, MYF(0)); - index_file = -1; - } + if (index_file >= 0) + { + my_close(index_file, MYF(0)); + index_file = -1; + } } void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 86d3f61776c..798cd78cab1 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -354,7 +354,7 @@ static uint get_access(TABLE *form,uint fieldnr) /* - return a number with if sorted put string in this order: + return a number which, if sorted 'desc', puts strings in this order: no wildcards wildcards empty string -- cgit v1.2.1 From d61418b94fc2f377c11775039bfe5a7106541b3a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Aug 2001 20:06:00 +0300 Subject: Portability fixes. Patches required by Gemini Fix to properly detect if there is an active transaction in InnoDB Fix to not lock thread structure when doing automatic rollback when thread ends Allow -O lower_case_names=0 on UNIX Docs/manual.texi: Some updates from mailing list. Changelog client/mysqlbinlog.cc: Removed variables declared in net.c configure.in: Added test for strtoll and fixed test for gethostname_r for AIX mysql-test/t/innodb.test: Added test of active transactions sql/field.cc: Patch required by Gemini sql/field.h: Patch required by Gemini sql/filesort.cc: Patch required by Gemini sql/gen_lex_hash.cc: Update to support new syntax sql/ha_gemini.cc: Patch required by Gemini sql/ha_gemini.h: Patch required by Gemini sql/ha_innobase.cc: Fix to properly detect if there is an active transaction in InnoDB sql/handler.cc: Fix to properly detect if there is an active transaction in InnoDB sql/handler.h: Fix to properly detect if there is an active transaction in InnoDB. Fix for Gemini sql/lex.h: SHOW LOCKS sql/mysqld.cc: Fix to not lock thread structure when doing automatic rollback when thread ends. sql/share/portuguese/errmsg.txt: Update sql/sql_class.cc: Fix to not lock thread structure when doing automatic rollback when thread ends. sql/sql_class.h: Fix to properly detect if there is an active transaction in InnoDB sql/sql_delete.cc: Fix for Gemini sql/sql_parse.cc: Allow -O lower_case_names=0 on UNIX sql/sql_select.cc: Fix for Gemini sql/sql_table.cc: Allow -O lower_case_names=0 on UNIX sql/sql_update.cc: Fix for Gemini sql/sql_yacc.yy: For SHOW LOCKS strings/strto.c: Portability fix --- sql/field.cc | 2 +- sql/field.h | 8 +++++++ sql/filesort.cc | 2 ++ sql/gen_lex_hash.cc | 2 +- sql/ha_gemini.cc | 1 + sql/ha_gemini.h | 1 + sql/ha_innobase.cc | 2 +- sql/handler.cc | 2 ++ sql/handler.h | 2 ++ sql/lex.h | 1 + sql/mysqld.cc | 7 ++++++ sql/share/portuguese/errmsg.txt | 50 ++++++++++++++++++++--------------------- sql/sql_class.cc | 29 ++++++++++++++++-------- sql/sql_class.h | 5 +++-- sql/sql_delete.cc | 2 ++ sql/sql_parse.cc | 2 -- sql/sql_select.cc | 2 ++ sql/sql_table.cc | 4 ---- sql/sql_update.cc | 2 ++ sql/sql_yacc.yy | 2 ++ 20 files changed, 83 insertions(+), 45 deletions(-) (limited to 'sql') diff --git a/sql/field.cc b/sql/field.cc index 78f57c5ceb5..894ef2ab013 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4122,7 +4122,7 @@ ulonglong Field_blob::get_id(const char *from) ulonglong id = 0; ulong length=get_length(from); if (length) - longlongget(id, from+packlength); + uint8korr(id, from+packlength); return id; } diff --git a/sql/field.h b/sql/field.h index b5d7c613701..ee18d2fa7ae 100644 --- a/sql/field.h +++ b/sql/field.h @@ -874,6 +874,14 @@ public: uint max_length= ~(uint) 0); ulonglong get_id(const char *from); const char *unpack_id(char *to, const char *from, const char *bdata); + inline void get_ptr_from_key_image(char **str,char *key_str) + { + *str = key_str + sizeof(uint16); + } + inline uint get_length_from_key_image(char *key_str) + { + return uint2korr(key_str); + } enum_field_types blobtype() { return (packlength == 1 ? FIELD_TYPE_TINY_BLOB : FIELD_TYPE_BLOB);} #endif char *pack_key(char *to, const char *from, uint max_length); diff --git a/sql/filesort.cc b/sql/filesort.cc index 610fe2e966f..86c95395965 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -388,6 +388,8 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, } make_sortkey(param,sort_keys[idx++],ref_pos); } + else + file->unlock_row(); } (void) file->extra(HA_EXTRA_NO_CACHE); /* End cacheing of records */ file->rnd_end(); diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 4a923e039c4..6bb43ec2970 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -472,7 +472,7 @@ int main(int argc,char **argv) int error; MY_INIT(argv[0]); - start_value=2663113L; best_t1=1175350L; best_t2=7404531L; best_type=4; /* mode=4327 add=3 type: 0 */ + start_value=8214901L; best_t1=4099790L; best_t2=2406115L; best_type=4; /* mode=4799 add=2 type: 0 */ if (get_options(argc,(char **) argv)) exit(1); diff --git a/sql/ha_gemini.cc b/sql/ha_gemini.cc index 75ffe4bd0ee..e8130c55fc7 100644 --- a/sql/ha_gemini.cc +++ b/sql/ha_gemini.cc @@ -93,6 +93,7 @@ bool gemini_init(void) DBUG_ENTER("gemini_init"); + gemini_basedir=mysql_home; /* If datadir isn't set, bail out */ if (*mysql_real_data_home == '\0') { diff --git a/sql/ha_gemini.h b/sql/ha_gemini.h index 3bfe85bfba2..96c0cdd4241 100644 --- a/sql/ha_gemini.h +++ b/sql/ha_gemini.h @@ -205,3 +205,4 @@ int gemini_set_option_long(int optid, long optval); const int gemini_blocksize = BLKSIZE; const int gemini_recbits = DEFAULT_RECBITS; +extern "C" void uttrace(void); diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index babe281bd4e..fdbc0b107f5 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -2219,7 +2219,7 @@ ha_innobase::external_lock( if (trx->n_mysql_tables_in_use == 0) { trx_mark_sql_stat_end(trx); } - + thd->transaction.all.innodb_active_trans=1; trx->n_mysql_tables_in_use++; if (prebuilt->select_lock_type != LOCK_NONE) { diff --git a/sql/handler.cc b/sql/handler.cc index bac24a6dba7..bb17d8f2331 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -286,6 +286,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans) my_error(ER_ERROR_DURING_COMMIT, MYF(0), error); error=1; } + trans->innodb_active_trans=0; } #endif #ifdef HAVE_GEMINI_DB @@ -337,6 +338,7 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans) my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), error); error=1; } + trans->innodb_active_trans=0; } #endif #ifdef HAVE_GEMINI_DB diff --git a/sql/handler.h b/sql/handler.h index 7a28dc07a81..ef78f0af39b 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -128,6 +128,7 @@ typedef struct st_thd_trans { void *bdb_tid; void *innobase_tid; void *gemini_tid; + bool innodb_active_trans; } THD_TRANS; enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED, @@ -267,6 +268,7 @@ public: virtual int extra(enum ha_extra_function operation)=0; virtual int reset()=0; virtual int external_lock(THD *thd, int lock_type)=0; + virtual void unlock_row() {} virtual int start_stmt(THD *thd) {return 0;} virtual int delete_all_rows(); virtual longlong get_auto_increment(); diff --git a/sql/lex.h b/sql/lex.h index d5df5ed5511..ed97eea751f 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -196,6 +196,7 @@ static SYMBOL symbols[] = { { "LOAD", SYM(LOAD),0,0}, { "LOCAL", SYM(LOCAL_SYM),0,0}, { "LOCK", SYM(LOCK_SYM),0,0}, + { "LOCKS", SYM(LOCKS_SYM),0,0}, { "LOGS", SYM(LOGS_SYM),0,0}, { "LONG", SYM(LONG_SYM),0,0}, { "LONGBLOB", SYM(LONGBLOB),0,0}, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 800e1f038f3..57e65025c8f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -995,6 +995,7 @@ sig_handler end_thread_signal(int sig __attribute__((unused))) void end_thread(THD *thd, bool put_in_cache) { DBUG_ENTER("end_thread"); + thd->cleanup(); (void) pthread_mutex_lock(&LOCK_thread_count); thread_count--; delete thd; @@ -1189,8 +1190,13 @@ the thread stack. Please read http://www.mysql.com/doc/L/i/Linux.html\n\n", #ifdef HAVE_STACKTRACE if(!(test_flags & TEST_NO_STACKTRACE)) + { +#ifdef HAVE_GEMINI_DB + utrace(); +#endif print_stacktrace(thd ? (gptr) thd->thread_stack : (gptr) 0, thread_stack); + } if (thd) { fprintf(stderr, "Trying to get some variables.\n\ @@ -2054,6 +2060,7 @@ static int bootstrap(FILE *file) (void) pthread_mutex_unlock(&LOCK_thread_count); error= thd->fatal_error; net_end(&thd->net); + thd->cleanup(); delete thd; return error; } diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index ae36c738606..9bb32287543 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -1,6 +1,6 @@ /* Copyright Abandoned 1997 TCX DataKonsult AB & Monty Program KB & Detron HB This file is public domain and comes with NO WARRANTY of any kind */ -/* Updated by Roberto M. Serqueira - martinsc@uol.com.br - 05.24.2001 */ +/* Updated by Roberto de Martin Serqueira - martinsc@uol.com.br - 08.20.2001 */ "hashchk", "isamchk", "não", @@ -35,14 +35,14 @@ "Manipulador de tabela para '%-.64s' não tem esta opção", "Não pode encontrar registro em '%-.64s'", "Informação incorreta no arquivo '%-.64s'", -"Arquivo chave incorreto para tabela '%-.64s'. Tente reparar", +"Arquivo de índice incorreto para tabela '%-.64s'. Tente reparar", "Arquivo chave desatualizado para tabela '%-.64s'. Repare-o!", "Tabela '%-.64s' é somente para leitura", "Sem memória. Reinicie o programa e tente novamente (necessita de %d bytes)", "Sem memória para ordenação. Aumente tamanho do 'buffer' de ordenação", "Encontrado fim de arquivo inesperado ao ler arquivo '%-.64s' (erro no. %d)", "Excesso de conexões", -"Sem memória. Verifique se o mysqld ou algum outro processo está usando toda memória disponível. Se não, você pode ter que usar 'ulimit' para permitir ao mysqld usar mais memória ou se você pode adicionar mais área de 'swap'", +"Sem memória. Verifique se o mysqld ou algum outro processo está usando toda memória disponível. Se não, você pode ter que usar 'ulimit' para permitir ao mysqld usar mais memória ou você pode adicionar mais área de 'swap'", "Não pode obter nome do 'host' para seu endereço", "Negociação de acesso falhou", "Acesso negado para o usuário '%-.32s@%-.64s' ao banco de dados '%-.64s'", @@ -58,7 +58,7 @@ "Coluna '%-.64s' desconhecida em '%-.64s'", "'%-.64s' não está em 'GROUP BY'", "Não pode agrupar em '%-.64s'", -"Cláusula contém funções de soma e colunas juntos", +"Cláusula contém funções de soma e colunas juntas", "Contagem de colunas não confere com a contagem de valores", "Nome identificador '%-.100s' é longo demais", "Nome da coluna '%-.64s' duplicado", @@ -72,27 +72,27 @@ "Definida mais de uma chave primária", "Especificadas chaves demais. O máximo permitido são %d chaves", "Especificadas partes de chave demais. O máximo permitido são %d partes", -"Chave especificada longa demais. O comprimento máximo permitido é %d", +"Chave especificada longa demais. O comprimento de chave máximo permitido é %d", "Coluna chave '%-.64s' não existe na tabela", "Coluna BLOB '%-.64s' não pode ser utilizada na especificação de chave para o tipo de tabela usado", "Comprimento da coluna '%-.64s' grande demais (max = %d). Use BLOB em seu lugar", -"Definição incorreta de tabela. Somente é permitido um campo auto-incrementado e ele tem que ser definido como chave", +"Definição incorreta de tabela. Somente é permitido um único campo auto-incrementado e ele tem que ser definido como chave", "%s: Pronto para conexões\n", "%s: 'Shutdown' normal\n", "%s: Obteve sinal %d. Abortando!\n", "%s: 'Shutdown' completo\n", "%s: Forçando finalização da 'thread' %ld - usuário '%-.32s'\n", -"Não pode criar 'socket' IP", +"Não pode criar 'IP socket'", "Tabela '%-.64s' não possui um índice como o usado em CREATE INDEX. Recrie a tabela", "Argumento separador de campos não é o esperado. Confira no manual", "Você não pode usar comprimento de linha fixo com BLOBs. Favor usar 'fields terminated by'", -"Arquivo '%-.64s' tem que estar no diretório do banco de dados ou ter leitura permitida para todos", +"Arquivo '%-.64s' tem que estar no diretório do banco de dados ou ter leitura possível para todos", "Arquivo '%-.80s' já existe", "Registros: %ld - Deletados: %ld - Ignorados: %ld - Avisos: %ld", "Registros: %ld - Duplicados: %ld", -"Parte de chave incorreta. A parte de chave usada não é um 'string' ou o comprimento usado é maior do que a parte de chave", +"Parte de chave incorreta. A parte de chave usada não é um 'string' ou o comprimento usado é maior do que a parte de chave ou o manipulador de tabelas não aceita partes de chaves únicas", "Você não pode deletar todas as colunas com ALTER TABLE. Use DROP TABLE em seu lugar", -"Não pode fazer DROP '%-.64s'. Confira se este campo/chave existe", +"Não pode fazer DROP '%-.64s'. Confira se esta coluna/chave existe", "Registros: %ld - Duplicados: %ld - Avisos: %ld", "INSERT TABLE '%-.64s' não é permitido em lista de tabelas FROM", "'Id' de 'thread' %lu desconhecido", @@ -112,14 +112,14 @@ "Parâmetros incorretos para a 'procedure' '%-.64s'", "Tabela '%-.64s' desconhecida em '%-.32s'", "Coluna '%-.64s' especificada duas vezes", -"Uso inválido da função GROUP", +"Uso inválido de função de grupo", "Tabela '%-.64s' usa uma extensão que não existe nesta versão do MySQL", "Uma tabela tem que ter pelo menos uma (1) coluna", "Tabela '%-.64s' está cheia", "Conjunto de caracteres '%-.64s' desconhecido", "Tabelas demais. O MySQL pode usar somente %d tabelas em um JOIN", "Colunas demais", -"Tamanho de linha grande demais. O máximo tamanho de linha, não contando BLOBs, é de %d. Você tem que mudar alguns campos para BLOBs", +"Tamanho de linha grande demais. O máximo tamanho de linha, não contando BLOBs, é %d. Você tem que mudar alguns campos para BLOBs", "Estouro da pilha do 'thread'. Usados %ld de uma pilha de %ld . Use 'mysqld -O thread_stack=#' para especificar uma pilha maior, se necessário", "Dependência cruzada encontrada em OUTER JOIN. Examine suas condições ON", "Coluna '%-.64s' é usada com UNIQUE ou INDEX, mas não está definida como NOT NULL", @@ -136,7 +136,7 @@ "Você tem que ter o privilégio para atualizar tabelas no banco de dados mysql para ser capaz de mudar a senha de outros", "Não pode encontrar nenhuma linha que combine na tabela user", "Linhas que combinaram: %ld - Alteradas: %ld - Avisos: %ld", -"Não pode criar uma nova 'thread' (erro no. %d). Se você não estiver sem memória disponível, você pode consultar o manual sobre uma possível falha dependente do sistema operacional", +"Não pode criar uma nova 'thread' (erro no. %d). Se você não estiver sem memória disponível, você pode consultar o manual sobre um possível 'bug' dependente do sistema operacional", "Contagem de colunas não confere com a contagem de valores na linha %ld", "Não pode reabrir a tabela '%-.64s', "Uso inválido do valor NULL", @@ -151,22 +151,22 @@ "Não existe tal 'grant' definido para o usuário '%-.32s' no 'host' '%-.64s', na tabela '%-.64s'", "Comando usado não é permitido para esta versão do MySQL", "Você tem um erro de sintaxe no seu SQL", -"'Thread' de inserção retardada ('delayed') não conseguiu obter trava solicitada na tabela '%-.64s'", +"'Thread' de inserção retardada ('delayed') não conseguiu obter trava solicitada para tabela '%-.64s'", "Excesso de 'threads' retardadas ('delayed') em uso", "Conexão %ld abortou para o banco de dados '%-.64s' - usuário '%-.32s' (%-.64s)", "Obteve um pacote maior do que 'max_allowed_packet'", -"Obteve um erro de leitura no 'pipe' de conexão", +"Obteve um erro de leitura no 'pipe' da conexão", "Obteve um erro em fcntl()", "Obteve pacotes fora de ordem", "Não conseguiu descomprimir pacote de comunicação", "Obteve um erro na leitura de pacotes de comunicação", "Obteve expiração de tempo ('timeout') na leitura de pacotes de comunicação", -"Obteve um erro na gravação de pacotes de comunicação", +"Obteve um erro na escrita de pacotes de comunicação", "Obteve expiração de tempo ('timeout') na escrita de pacotes de comunicação", "'String' resultante é mais longa do que 'max_allowed_packet'", "Tipo de tabela usado não permite colunas BLOB/TEXT", "Tipo de tabela usado não permite colunas AUTO_INCREMENT", -"INSERT DELAYED não pode ser usado com a tabela '%-.64s', porque está travada com LOCK TABLES", +"INSERT DELAYED não pode ser usado com a tabela '%-.64s', porque ela está travada com LOCK TABLES", "Nome de coluna '%-.100s' incorreto", "O manipulador de tabela usado não pode indexar a coluna '%-.64s'", "Tabelas no MERGE não estão todas definidas identicamente", @@ -176,7 +176,7 @@ "O resultado consistiu em mais do que uma linha", "Este tipo de tabela requer uma chave primária", "Esta versão do MySQL não foi compilada com suporte a RAID", -"Você está usando modo de atualização seguro e tentou atualizar uma tabela sem um WHERE que use uma coluna tipo KEY", +"Você está usando modo de atualização seguro e tentou atualizar uma tabela sem um WHERE que use uma coluna de KEY", "Chave '%-.64s' não existe na tabela '%-.64s'", "Não pode abrir a tabela", "O manipulador de tabela não suporta check/repair", @@ -188,7 +188,7 @@ "Conexão %ld abortada ao banco de dados '%-.64s' - usuário '%-.32s' - 'host' `%-.64s' ('%-.64s')", "O manipulador de tabela não suporta DUMP binário de tabela", "Binlog fechado. Não pode fazer RESET MASTER", -"Falhou na reconstrução do índice da tabela 'dumped' '%-.64s'", +"Falhou na reconstrução do índice da tabela '%-.64s' 'dumped'", "Erro no 'master' '%-.64s'", "Erro de rede na leitura do 'master'", "Erro de rede na gravação do 'master'", @@ -207,9 +207,9 @@ "Usuário '%-.64s' já possui 'max_user_connections' conexões ativas", "Você pode usar apenas expressões de constante com SET", "Excedido tempo de espera (timeout) do travamento", -"O número total de travamentos excede o tamanho de travamento da tabela", -"Travamentos de atualização não podem ser obtidos durante um READ UNCOMMITTED na transação", -"DROP DATABASE não permitido enquanto uma 'thread' está assegurando um travamento global de leitura", -"CREATE DATABASE não permitido enquanto uma 'thread' está assegurando um travamento global de leitura", -"Wrong arguments to %s", -"%-.32s@%-.64s is not allowed to create new users", +"O número total de travamentos excede o tamanho da tabela de travamentos", +"Travamentos de atualização não podem ser obtidos durante uma transação de READ UNCOMMITTED", +"DROP DATABASE não permitido enquanto uma 'thread' está mantendo um travamento global de leitura", +"CREATE DATABASE não permitido enquanto uma 'thread' está mantendo um travamento global de leitura", +"Argumentos errados para %s", +"Não é permitido a %-.32s@%-.64s criar novos usuários", diff --git a/sql/sql_class.cc b/sql/sql_class.cc index efe0d7864b9..c57b59f55a6 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -101,7 +101,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0), mysys_var=0; net.vio=0; ull=0; - system_thread=0; + system_thread=cleanup_done=0; #ifdef __WIN__ real_id = 0; #endif @@ -149,15 +149,11 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0), #endif } -THD::~THD() +/* Do operations that may take a long time */ + +void THD::cleanup(void) { - DBUG_ENTER("~THD()"); - /* Close connection */ - if (net.vio) - { - vio_delete(net.vio); - net_end(&net); - } + DBUG_ENTER("THD::cleanup"); ha_rollback(this); if (locked_tables) { @@ -172,6 +168,21 @@ THD::~THD() ha_close_connection(this); } #endif + cleanup_done=1; + DBUG_VOID_RETURN; +} + +THD::~THD() +{ + DBUG_ENTER("~THD()"); + /* Close connection */ + if (net.vio) + { + vio_delete(net.vio); + net_end(&net); + } + if (!cleanup_done) + cleanup(); if (global_read_lock) { pthread_mutex_lock(&LOCK_open); diff --git a/sql/sql_class.h b/sql/sql_class.h index 4ccbeb6f01f..bbf6fe08d88 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -283,7 +283,7 @@ public: bool no_errors, allow_sum_func, password, fatal_error; bool query_start_used,last_insert_id_used,insert_id_used; bool system_thread,in_lock_tables,global_read_lock; - bool query_error, bootstrap; + bool query_error, bootstrap, cleanup_done; bool volatile killed; LOG_INFO* current_linfo; // if we do a purge of binary logs, log index info of the threads @@ -295,6 +295,7 @@ public: THD(); ~THD(); + void cleanup(void); bool store_globals(); #ifdef SIGNAL_WITH_VIO_CLOSE inline void set_active_vio(Vio* vio) @@ -360,7 +361,7 @@ public: { #ifdef USING_TRANSACTIONS return (transaction.all.bdb_tid != 0 || - transaction.all.innobase_tid != 0 || + transaction.all.innodb_active_trans != 0 || transaction.all.gemini_tid != 0); #else return 0; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 8b4b1b527ca..af658ad0346 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -216,6 +216,8 @@ int mysql_delete(THD *thd,TABLE_LIST *table_list,COND *conds,ha_rows limit, break; } } + else + table->file->unlock_row(); // Row failed selection, release lock on it } thd->proc_info="end"; end_read_record(&info); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 8c3f2759e9a..796b571722f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2667,13 +2667,11 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias, DBUG_RETURN(0); } -#ifdef FN_NO_CASE_SENCE if (!alias) /* Alias is case sensitive */ if (!(alias_str=sql_strmake(alias_str,table->table.length))) DBUG_RETURN(0); if (lower_case_table_names) casedn_str(table->table.str); -#endif if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST)))) DBUG_RETURN(0); /* purecov: inspected */ ptr->db= table->db.str; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 51020558f75..b30cb6bb639 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4130,6 +4130,8 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records) if (not_used_in_distinct && found_records != join->found_records) return 0; } + else + info->file->unlock_row(); } } while (!(error=info->read_record(info))); if (error > 0) // Fatal error diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ca703cca4c5..1728427370f 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1125,16 +1125,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, { strmov(new_name_buff,new_name); fn_same(new_name_buff,table_name,3); -#ifdef FN_NO_CASE_SENCE if (lower_case_table_names) casedn_str(new_name); if ((lower_case_table_names && !my_strcasecmp(new_name_buff,table_name)) || (!lower_case_table_names && !strcmp(new_name_buff,table_name))) -#else - if (!strcmp(new_name_buff,table_name)) // Check if name changed -#endif new_name=table_name; // No. Make later check easier else { diff --git a/sql/sql_update.cc b/sql/sql_update.cc index c41586c58c8..2e9a3c5e355 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -259,6 +259,8 @@ int mysql_update(THD *thd,TABLE_LIST *table_list,List &fields, } } } + else + table->file->unlock_row(); } end_read_record(&info); thd->proc_info="end"; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 9ab97d52650..5a1c6baf1e4 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -121,6 +121,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %token KILL_SYM %token LOAD %token LOCK_SYM +%token LOCKS_SYM %token UNLOCK_SYM %token ACTION @@ -2560,6 +2561,7 @@ keyword: | INNOBASE_SYM {} | LEVEL_SYM {} | LOCAL_SYM {} + | LOCKS_SYM {} | LOGS_SYM {} | MAX_ROWS {} | MASTER_SYM {} -- cgit v1.2.1 From 31b9e6e03f8fe4be1816c3f33aaefb9a931dcef3 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 22 Aug 2001 01:45:07 +0300 Subject: Fixes for OS2. Fix bug in isamlog Add argument types to function declarations. Docs/manual.texi: Updated credits client/mysql.cc: Fixes for OS2 client/mysqladmin.c: Fixes for OS2 client/mysqldump.c: Fixes for OS2 client/mysqlimport.c: Fixes for OS2 client/mysqltest.c: Fixes for OS2 dbug/dbug.c: Fixes for OS2. Use new C calling convention. dbug/factorial.c: Fixes for OS2. Use new C calling convention. include/errmsg.h: Fix for OS2 include/global.h: Fixes for OS2. include/my_pthread.h: Fixes for OS2. include/my_sys.h: Fixes for OS2. include/mysql_com.h: Move defines to global.h include/thr_alarm.h: Fixes for OS2. isam/isamchk.c: Fixes for OS2. Add arguments to function declarations. isam/isamlog.c: Fixes for OS2. Fix bug in logfile handling. isam/test1.c: Add arguments to function decl isam/test2.c: Add arguments to function declarations. isam/test_all.res: Update result libmysql/get_password.c: Fixes for OS2. libmysql/libmysql.c: Fixes for OS2. libmysql/net.c: Fixes for OS2. libmysql/violite.c: Add arguments to function declarations. merge/_locking.c: Add argument types to function declarations. merge/close.c: Add argument types to function declarations. merge/create.c: Add argument types to function declarations. merge/extra.c: Add argument types to function declarations. merge/open.c: Add argument types to function declarations. merge/panic.c: Add argument types to function declarations. merge/rsame.c: Add argument types to function declarations. merge/update.c: Add argument types to function declarations. myisam/ft_eval.c: Portability fix myisam/ft_search.c: Portability fix myisam/ft_test1.c: Portability fix myisam/ftdefs.h: Portability fix myisam/mi_check.c: Portability fix myisam/mi_test1.c: Portability fix myisam/mi_test2.c: Portability fix myisam/mi_test_all.sh: Update to test for MACH variable myisam/myisamlog.c: Cleanup myisam/myisampack.c: Don't use variable 'new' myisam/sort.c: Portability fix myisammrg/myrg_delete.c: Add argument types to function declarations. myisammrg/myrg_locking.c: Add argument types to function declarations. myisammrg/myrg_open.c: Add argument types to function declarations. myisammrg/myrg_panic.c: Add argument types to function declarations. mysql-test/t/backup.test: Fix for OS2 mysql-test/t/show_check.test: Fix for OS2 mysys/charset.c: Dont use variable 'new' mysys/default.c: Fixes for OS2. mysys/getopt.c: Fixes for OS2. mysys/getopt1.c: Fixes for OS2. mysys/list.c: Don't use variable 'new' mysys/mf_dirname.c: Fixes for OS2. mysys/mf_format.c: Fixes for OS2. mysys/mf_path.c: Fixes for OS2. mysys/mf_qsort.c: Portability fix mysys/mf_tempfile.c: Fixes for OS2. mysys/my_clock.c: Fixes for OS2. mysys/my_copy.c: Fixes for OS2. mysys/my_create.c: Fixes for OS2. mysys/my_getwd.c: Fixes for OS2. mysys/my_init.c: Fixes for OS2. mysys/my_lib.c: Fixes for OS2. mysys/my_lock.c: Fixes for OS2. mysys/my_malloc.c: Portability fix mysys/my_mkdir.c: Fixes for OS2. mysys/my_open.c: Fixes for OS2. mysys/my_pthread.c: Fixes for OS2. mysys/my_realloc.c: Fixes for OS2. mysys/my_redel.c: Fixes for OS2. mysys/my_static.c: Fixes for OS2. mysys/my_tempnam.c: Fixes for OS2. mysys/my_thr_init.c: Fixes for OS2. mysys/my_write.c: Fixes for OS2. mysys/test_charset.c: Fixes for OS2. mysys/thr_alarm.c: Fixes for OS2. mysys/tree.c: Fixes for OS2. sql/field.cc: Fixes for OS2. sql/field.h: Fixes for OS2. sql/gen_lex_hash.cc: Fixes for OS2. sql/hostname.cc: Fixes for OS2. sql/item_func.cc: Fixes for OS2. sql/item_strfunc.cc: Fixes for OS2. sql/log_event.cc: Fixes for OS2. sql/md5.c: Fixes for OS2. sql/mini_client.cc: Fixes for OS2. sql/mysql_priv.h: Fixes for OS2. sql/mysqld.cc: Fixes for OS2. sql/net_serv.cc: Fixes for OS2. sql/slave.cc: Fixes for OS2. sql/sql_base.cc: Fixes for OS2. sql/sql_db.cc: Portability fix sql/sql_insert.cc: Fixes for OS2. sql/sql_load.cc: Fixes for OS2. sql/sql_parse.cc: Fixes for OS2. sql/sql_table.cc: Fixes for OS2. sql/sql_udf.cc: Fixes for OS2. sql/violite.c: Fixes for OS2. strings/ctype-big5.c: Fixes for OS2. strings/ctype-gbk.c: Fixes for OS2. strings/ctype-sjis.c: Fixes for OS2. strings/ctype-tis620.c: Fixes for OS2. strings/ctype.c: Fixes for OS2. strings/strnlen.c: Fixes for OS2. --- sql/field.cc | 2 +- sql/field.h | 4 +- sql/gen_lex_hash.cc | 2 +- sql/hostname.cc | 2 +- sql/item_func.cc | 6 +++ sql/item_strfunc.cc | 6 +-- sql/log_event.cc | 2 +- sql/md5.c | 36 +++++++++--------- sql/mini_client.cc | 42 +++++++++++--------- sql/mysql_priv.h | 4 +- sql/mysqld.cc | 108 +++++++++++++++++++++++++++++++++++++++++++++------- sql/net_serv.cc | 22 +++++++---- sql/slave.cc | 2 +- sql/sql_base.cc | 4 +- sql/sql_db.cc | 4 +- sql/sql_insert.cc | 4 +- sql/sql_load.cc | 2 +- sql/sql_parse.cc | 16 +++++--- sql/sql_table.cc | 20 ++++++++-- sql/sql_udf.cc | 2 +- sql/violite.c | 32 ++++++++++------ 21 files changed, 225 insertions(+), 97 deletions(-) (limited to 'sql') diff --git a/sql/field.cc b/sql/field.cc index 894ef2ab013..01178efbdb1 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2295,7 +2295,7 @@ void Field_timestamp::store(longlong nr) } else #endif - longstore(ptr,timestamp); + longstore(ptr,(ulong)timestamp); } diff --git a/sql/field.h b/sql/field.h index ee18d2fa7ae..fc0bfdc75d5 100644 --- a/sql/field.h +++ b/sql/field.h @@ -38,8 +38,8 @@ public: static void operator delete(void *ptr_arg, size_t size) {} /*lint -e715 */ enum utype { NONE,DATE,SHIELD,NOEMPTY,CASEUP,PNR,BGNR,PGNR,YES,NO,REL, - CHECK,EMPTY,UNKNOWN,CASEDN,NEXT_NUMBER,INTERVAL_FIELD,BIT_FIELD, - TIMESTAMP_FIELD,CAPITALIZE,BLOB_FIELD}; + CHECK,EMPTY,UNKNOWN_FIELD,CASEDN,NEXT_NUMBER,INTERVAL_FIELD, + BIT_FIELD, TIMESTAMP_FIELD,CAPITALIZE,BLOB_FIELD}; char *ptr; // Position to field in record uchar *null_ptr; // Byte where null_bit is uint8 null_bit; // And position to it diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 6bb43ec2970..5eee5c6163a 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -472,7 +472,7 @@ int main(int argc,char **argv) int error; MY_INIT(argv[0]); - start_value=8214901L; best_t1=4099790L; best_t2=2406115L; best_type=4; /* mode=4799 add=2 type: 0 */ + start_value=487844L; best_t1=4969454L; best_t2=2266538L; best_type=2; /* mode=4567 add=5 type: 0 */ if (get_options(argc,(char **) argv)) exit(1); diff --git a/sql/hostname.cc b/sql/hostname.cc index fed9e60b574..bc812341337 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -26,7 +26,7 @@ #ifdef __cplusplus extern "C" { // Because of SCO 3.2V4.2 #endif -#ifndef __WIN__ +#if !defined( __WIN__) && !defined(OS2) #include #ifdef HAVE_SYS_UN_H #include diff --git a/sql/item_func.cc b/sql/item_func.cc index ef3372629f6..989d7709513 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1489,8 +1489,14 @@ longlong Item_func_get_lock::val_int() thd->mysys_var->current_cond= &ull->cond; pthread_mutex_unlock(&thd->mysys_var->mutex); +#ifdef HAVE_TIMESPEC_TS_SEC + abstime.ts_sec=time((time_t*) 0)+(time_t) timeout; + abstime.ts_nsec=0; +#else abstime.tv_sec=time((time_t*) 0)+(time_t) timeout; abstime.tv_nsec=0; +#endif + while ((error=pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime)) != ETIME && error != ETIMEDOUT && ull->locked) { diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 80f72c30e57..bd7fde79629 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1009,8 +1009,8 @@ String *Item_func_encrypt::val_str(String *str) if (arg_count == 1) { // generate random salt time_t timestamp=current_thd->query_start(); - salt[0] = bin_to_ascii(timestamp & 0x3f); - salt[1] = bin_to_ascii((timestamp >> 5) & 0x3f); + salt[0] = bin_to_ascii( (ulong) timestamp & 0x3f); + salt[1] = bin_to_ascii(( (ulong) timestamp >> 5) & 0x3f); salt[2] = 0; salt_ptr=salt; } @@ -1103,7 +1103,7 @@ void Item_func_soundex::fix_length_and_dec() */ extern "C" { -extern char *soundex_map; // In mysys/static.c +extern const char *soundex_map; // In mysys/static.c } static char get_scode(char *ptr) diff --git a/sql/log_event.cc b/sql/log_event.cc index 1263d361b7f..41efa0f5658 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -55,7 +55,7 @@ int Log_event::write_header(IO_CACHE* file) // make sure to change this when the header gets bigger char buf[LOG_EVENT_HEADER_LEN]; char* pos = buf; - int4store(pos, when); // timestamp + int4store(pos, (ulong) when); // timestamp pos += 4; *pos++ = get_type_code(); // event type code int4store(pos, server_id); diff --git a/sql/md5.c b/sql/md5.c index 0775ba3bd1a..4c2e80107b8 100644 --- a/sql/md5.c +++ b/sql/md5.c @@ -123,10 +123,10 @@ void MD5Init (MD5_CTX *context) /* context */ operation, processing another message block, and updating the context. */ -void MD5Update (context, input, inputLen) -MD5_CTX *context; /* context */ -unsigned char *input; /* input block */ -unsigned int inputLen; /* length of input block */ +void MD5Update ( +MD5_CTX *context, /* context */ +unsigned char *input, /* input block */ +unsigned int inputLen) /* length of input block */ { unsigned int i, idx, partLen; @@ -164,9 +164,9 @@ unsigned int inputLen; /* length of input block */ /* MD5 finalization. Ends an MD5 message-digest operation, writing the the message digest and zeroizing the context. */ -void MD5Final (digest, context) -unsigned char digest[16]; /* message digest */ -MD5_CTX *context; /* context */ +void MD5Final ( +unsigned char digest[16], /* message digest */ +MD5_CTX *context) /* context */ { unsigned char bits[8]; unsigned int idx, padLen; @@ -193,9 +193,9 @@ MD5_CTX *context; /* context */ /* MD5 basic transformation. Transforms state based on block. */ -static void MD5Transform (state, block) -UINT4 state[4]; -unsigned char block[64]; +static void MD5Transform ( +UINT4 state[4], +unsigned char block[64]) { UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; @@ -287,10 +287,10 @@ unsigned char block[64]; /* Encodes input (UINT4) into output (unsigned char). Assumes len is a multiple of 4. */ -static void Encode (output, input, len) -unsigned char *output; -UINT4 *input; -unsigned int len; +static void Encode ( +unsigned char *output, +UINT4 *input, +unsigned int len) { unsigned int i, j; @@ -306,10 +306,10 @@ unsigned int len; /* Decodes input (unsigned char) into output (UINT4). Assumes len is a multiple of 4. */ -static void Decode (output, input, len) -UINT4 *output; -unsigned char *input; -unsigned int len; +static void Decode ( +UINT4 *output, +unsigned char *input, +unsigned int len) { unsigned int i, j; diff --git a/sql/mini_client.cc b/sql/mini_client.cc index 2886b6e02d2..88a02e227a3 100644 --- a/sql/mini_client.cc +++ b/sql/mini_client.cc @@ -82,6 +82,9 @@ static void mc_free_old_query(MYSQL *mysql); #if defined(MSDOS) || defined(__WIN__) #define ERRNO WSAGetLastError() #define perror(A) +#elif defined(OS2) +#define ERRNO sock_errno() +#define SOCKET_ERROR -1 #else #include #define ERRNO errno @@ -235,7 +238,7 @@ static void mc_free_old_query(MYSQL *mysql) static int mc_sock_connect(my_socket s, const struct sockaddr *name, uint namelen, uint to) { -#if defined(__WIN__) +#if defined(__WIN__) || defined(OS2) return connect(s, (struct sockaddr*) name, namelen); #else int flags, res, s_err; @@ -330,18 +333,18 @@ mc_net_safe_read(MYSQL *mysql) { DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d", vio_description(net->vio),len)); - if(errno != EINTR) + if (socket_errno != EINTR) + { + mc_end_server(mysql); + if(net->last_errno != ER_NET_PACKET_TOO_LARGE) { - mc_end_server(mysql); - if(net->last_errno != ER_NET_PACKET_TOO_LARGE) - { - net->last_errno=CR_SERVER_LOST; - strmov(net->last_error,ER(net->last_errno)); - } - else - strmov(net->last_error, "Packet too large - increase \ + net->last_errno=CR_SERVER_LOST; + strmov(net->last_error,ER(net->last_errno)); + } + else + strmov(net->last_error, "Packet too large - increase \ max_allowed_packet on this server"); - } + } return(packet_error); } if (net->read_pos[0] == 255) @@ -451,7 +454,7 @@ mc_simple_command(MYSQL *mysql,enum enum_server_command command, if (net_write_command(net,(uchar) command,arg, length ? length :(uint) strlen(arg))) { - DBUG_PRINT("error",("Can't send command to server. Error: %d",errno)); + DBUG_PRINT("error",("Can't send command to server. Error: %d",socket_errno)); mc_end_server(mysql); if (mc_mysql_reconnect(mysql) || net_write_command(net,(uchar) command,arg, @@ -535,9 +538,9 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, if (mc_sock_connect(sock,(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr), mysql->options.connect_timeout) <0) { - DBUG_PRINT("error",("Got error %d on connect to local server",ERRNO)); + DBUG_PRINT("error",("Got error %d on connect to local server",socket_errno)); net->last_errno=CR_CONNECTION_ERROR; - sprintf(net->last_error,ER(net->last_errno),unix_socket,ERRNO); + sprintf(net->last_error,ER(net->last_errno),unix_socket,socket_errno); goto error; } } @@ -585,7 +588,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, if ((sock = socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR) { net->last_errno=CR_IPSOCK_ERROR; - sprintf(net->last_error,ER(net->last_errno),ERRNO); + sprintf(net->last_error,ER(net->last_errno),socket_errno); goto error; } net->vio = vio_new(sock,VIO_TYPE_TCPIP,FALSE); @@ -622,7 +625,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, if (!(hp=gethostbyname(host))) { net->last_errno=CR_UNKNOWN_HOST; - sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, errno); + sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, socket_errno); goto error; } memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length); @@ -630,11 +633,12 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, #endif sock_addr.sin_port = (ushort) htons((ushort) port); if (mc_sock_connect(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr), - mysql->options.connect_timeout) <0) + mysql->options.connect_timeout) <0) { - DBUG_PRINT("error",("Got error %d on connect to '%s'",ERRNO,host)); + DBUG_PRINT("error",("Got error %d on connect to '%s'", + socket_errno,host)); net->last_errno= CR_CONN_HOST_ERROR; - sprintf(net->last_error ,ER(CR_CONN_HOST_ERROR), host, ERRNO); + sprintf(net->last_error ,ER(CR_CONN_HOST_ERROR), host, socket_errno); if (thr_alarm_in_use(&alarmed)) thr_end_alarm(&alarmed); goto error; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 19af3af8c68..06d0b1528f4 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -28,7 +28,9 @@ #include #include +#ifdef __EMX__ #undef write // remove pthread.h macro definition for EMX +#endif typedef ulong table_map; /* Used for table bits in join */ typedef ulong key_map; /* Used for finding keys */ @@ -110,7 +112,7 @@ void kill_one_thread(THD *thd, ulong id); #define FLUSH_TIME 0 /* Don't flush tables */ #define MAX_CONNECT_ERRORS 10 // errors before disabling host -#ifdef __WIN__ +#if defined(__WIN__) || defined(OS2) #define IF_WIN(A,B) (A) #undef FLUSH_TIME #define FLUSH_TIME 1800 /* Flush every half hour */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 57e65025c8f..35aeaecc6e1 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -57,7 +57,9 @@ extern "C" { // Because of SCO 3.2V4.2 #include #endif -#ifndef __WIN__ +#if defined(OS2) +# include +#elif !defined( __WIN__) #include #ifdef HAVE_SYS_UN_H # include @@ -358,6 +360,10 @@ HANDLE hEventShutdown; static NTService Service; // Service object for WinNT #endif +#ifdef OS2 +pthread_cond_t eventShutdown; +#endif + static void start_signal_handler(void); static void *signal_hand(void *arg); static void set_options(void); @@ -405,7 +411,7 @@ static void close_connections(void) (void) pthread_mutex_unlock(&LOCK_manager); /* kill connection thread */ -#if !defined(__WIN__) && !defined(__EMX__) +#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) DBUG_PRINT("quit",("waiting for select thread: %lx",select_thread)); (void) pthread_mutex_lock(&LOCK_thread_count); @@ -576,6 +582,8 @@ void kill_mysql(void) // SetEvent(hEventShutdown); // CloseHandle(hEvent); } +#elif defined(OS2) + pthread_cond_signal( &eventShutdown); // post semaphore #elif defined(HAVE_PTHREAD_KILL) if (pthread_kill(signal_thread,MYSQL_KILL_SIGNAL))// End everything nicely { @@ -592,7 +600,10 @@ void kill_mysql(void) /* Force server down. kill all connections and threads and exit */ -#ifndef __WIN__ +#if defined(OS2) +extern "C" void kill_server(int sig_ptr) +#define RETURN_FROM_KILL_SERVER return +#elif !defined(__WIN__) static void *kill_server(void *sig_ptr) #define RETURN_FROM_KILL_SERVER return 0 #else @@ -615,7 +626,7 @@ static void __cdecl kill_server(int sig_ptr) else sql_print_error(ER(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */ -#if defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__) +#if defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__) && !defined(OS2) my_thread_init(); // If this is a new thread #endif close_connections(); @@ -623,7 +634,9 @@ static void __cdecl kill_server(int sig_ptr) unireg_abort(1); /* purecov: inspected */ else unireg_end(0); +#ifndef OS2 pthread_exit(0); /* purecov: deadcode */ +#endif RETURN_FROM_KILL_SERVER; } @@ -645,7 +658,7 @@ static sig_handler print_signal_warning(int sig) #ifdef DONT_REMEMBER_SIGNAL sigset(sig,print_signal_warning); /* int. thread system calls */ #endif -#ifndef __WIN__ +#if !defined(__WIN__) && !defined(OS2) if (sig == SIGALRM) alarm(2); /* reschedule alarm */ #endif @@ -655,7 +668,9 @@ static sig_handler print_signal_warning(int sig) void unireg_end(int signal_number __attribute__((unused))) { clean_up(); +#ifndef OS2 pthread_exit(0); // Exit is in main thread +#endif } @@ -746,7 +761,7 @@ static void set_ports() static void set_user(const char *user) { -#ifndef __WIN__ +#if !defined(__WIN__) && !defined(OS2) struct passwd *ent; // don't bother if we aren't superuser @@ -794,7 +809,7 @@ static void set_user(const char *user) static void set_root(const char *path) { -#if !defined(__WIN__) && !defined(__EMX__) +#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) if (chroot(path) == -1) { sql_perror("chroot"); @@ -853,7 +868,7 @@ static void server_init(void) } if (listen(ip_sock,(int) back_log) < 0) sql_print_error("Warning: listen() on TCP/IP failed with error %d", - errno); + socket_errno); } if (mysqld_chroot) @@ -940,7 +955,7 @@ static void server_init(void) #endif if (listen(unix_sock,(int) back_log) < 0) sql_print_error("Warning: listen() on Unix socket failed with error %d", - errno); + socket_errno); } #endif DBUG_PRINT("info",("server started")); @@ -1088,13 +1103,17 @@ static sig_handler abort_thread(int sig __attribute__((unused))) ** the signal thread is ready before continuing ******************************************************************************/ -#ifdef __WIN__ +#if defined(__WIN__) || defined(OS2) static void init_signals(void) { int signals[] = {SIGINT,SIGILL,SIGFPE,SIGSEGV,SIGTERM,SIGABRT } ; for (uint i=0 ; i < sizeof(signals)/sizeof(int) ; i++) signal( signals[i], kill_server) ; +#if defined(__WIN__) signal(SIGBREAK,SIG_IGN); //ignore SIGBREAK for NT +#else + signal(SIGBREAK, kill_server); +#endif } static void start_signal_handler(void) @@ -1473,6 +1492,29 @@ int __stdcall handle_kill(ulong ctrl_type) } #endif +#ifdef OS2 +pthread_handler_decl(handle_shutdown,arg) +{ + my_thread_init(); + + // wait semaphore + pthread_cond_wait( &eventShutdown, NULL); + + // close semaphore and kill server + pthread_cond_destroy( &eventShutdown); + + // exit main loop on main thread, so kill will be done from + // main thread (this is thread 2) + abort_loop = 1; + + // unblock select() + so_cancel( ip_sock); + so_cancel( unix_sock); + + return 0; +} +#endif + const char *load_default_groups[]= { "mysqld","server",0 }; #ifdef HAVE_LIBWRAP @@ -1558,7 +1600,7 @@ int main(int argc, char **argv) load_defaults("my",load_default_groups,&argc,&argv); defaults_argv=argv; mysql_tmpdir=getenv("TMPDIR"); /* Use this if possible */ -#ifdef __WIN__ +#if defined( __WIN__) || defined(OS2) if (!mysql_tmpdir) mysql_tmpdir=getenv("TEMP"); if (!mysql_tmpdir) @@ -1646,7 +1688,7 @@ int main(int argc, char **argv) my_pthread_attr_setprio(&connection_attrib,WAIT_PRIOR); pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM); -#ifdef SET_RLIMIT_NOFILE +#if defined( SET_RLIMIT_NOFILE) || defined( OS2) /* connections and databases neads lots of files */ { uint wanted_files=10+(uint) max(max_connections*5, @@ -1854,6 +1896,14 @@ The server will not act as a slave."); Service.SetShutdownEvent(hEventShutdown); } #endif +#ifdef OS2 + { + pthread_cond_init( &eventShutdown, NULL); + pthread_t hThread; + if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0)) + sql_print_error("Warning: Can't create thread to handle shutdown requests"); + } +#endif if ( #ifdef HAVE_BERKELEY_DB @@ -2192,7 +2242,9 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused))) } #ifdef HAVE_SYS_UN_H FD_SET(unix_sock,&clientFDs); +#ifdef HAVE_FCNTL socket_flags=fcntl(unix_sock, F_GETFL, 0); +#endif #endif DBUG_PRINT("general",("Waiting for connections.")); @@ -2205,10 +2257,10 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused))) #else if (select((int) max_used_connection,&readFDs,0,0,0) < 0) { - if (errno != EINTR) + if (socket_errno != EINTR) { if (!select_errors++ && !abort_loop) /* purecov: inspected */ - sql_print_error("mysqld: Got error %d from select",errno); /* purecov: inspected */ + sql_print_error("mysqld: Got error %d from select",socket_errno); /* purecov: inspected */ } continue; } @@ -2344,6 +2396,11 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused))) create_new_thread(thd); } +#ifdef OS2 + // kill server must be invoked from thread 1! + kill_server(MYSQL_KILL_SIGNAL); +#endif + #ifdef __NT__ pthread_mutex_lock(&LOCK_thread_count); handler_count--; @@ -4385,6 +4442,29 @@ static uint set_maximum_open_files(uint max_file_limit) } #endif +#ifdef OS2 +static uint set_maximum_open_files(uint max_file_limit) +{ + LONG cbReqCount; + ULONG cbCurMaxFH, cbCurMaxFH0; + APIRET ulrc; + + // get current limit + cbReqCount = 0; + DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH0); + + // set new limit + cbReqCount = max_file_limit - cbCurMaxFH0; + ulrc = DosSetRelMaxFH( &cbReqCount, &cbCurMaxFH); + if (ulrc) { + sql_print_error("Warning: DosSetRelMaxFH couldn't increase number of open files to more than %d", + cbCurMaxFH0); + cbCurMaxFH = cbCurMaxFH0; + } + + return cbCurMaxFH; +} +#endif /* Return a bitfield from a string of substrings separated by ',' diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 4c4642034e1..ba0944a2516 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -50,7 +50,7 @@ ulong net_buffer_length=8192; /* Default length. Enlarged if necessary */ #if !defined(__WIN__) && !defined(MSDOS) #include #else -#undef MYSQL_SERVER // Win32 can't handle interrupts +#undef MYSQL_SERVER /* Win32 can't handle interrupts */ #endif #if !defined(MSDOS) && !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__) #include @@ -68,9 +68,15 @@ void sql_print_error(const char *format,...); #define RETRY_COUNT mysqld_net_retry_count extern ulong mysqld_net_retry_count; #else + +#ifdef OS2 /* avoid name conflict */ +#define thr_alarm_t thr_alarm_t_net +#define ALARM ALARM_net +#endif + typedef my_bool thr_alarm_t; typedef my_bool ALARM; -#define thr_alarm_init(A) (*A)=0 +#define thr_alarm_init(A) (*(A))=0 #define thr_alarm_in_use(A) (*(A)) #define thr_end_alarm(A) #define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C)) @@ -124,7 +130,7 @@ int my_net_init(NET *net, Vio* vio) if (vio != 0) /* If real connection */ { net->fd = vio_fd(vio); /* For perl DBI/DBD */ -#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__) +#if defined(MYSQL_SERVER) && !defined(___WIN__) && !defined(__EMX__) && !defined(OS2) if (!(test_flags & TEST_BLOCKING)) vio_blocking(vio, FALSE); #endif @@ -271,7 +277,7 @@ net_real_write(NET *net,const char *packet,ulong len) int length; char *pos,*end; thr_alarm_t alarmed; -#if !defined(__WIN__) +#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) ALARM alarm_buff; #endif uint retry_count=0; @@ -329,7 +335,7 @@ net_real_write(NET *net,const char *packet,ulong len) if ((int) (length=vio_write(net->vio,pos,(int) (end-pos))) <= 0) { my_bool interrupted = vio_should_retry(net->vio); -#if (!defined(__WIN__) && !defined(__EMX__)) +#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) if ((interrupted || length==0) && !thr_alarm_in_use(&alarmed)) { if (!thr_alarm(&alarmed,(uint) net_write_timeout,&alarm_buff)) @@ -418,7 +424,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed) { if (!thr_alarm(alarmed,net->timeout,&alarm_buff) || (!vio_is_blocking(net->vio) && vio_blocking(net->vio,TRUE) < 0)) - return; // Can't setup, abort + return; /* Can't setup, abort */ } while (remain > 0) { @@ -448,7 +454,7 @@ my_real_read(NET *net, ulong *complen) uint i,retry_count=0; ulong len=packet_error; thr_alarm_t alarmed; -#if (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER) +#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) || defined(MYSQL_SERVER) ALARM alarm_buff; #endif my_bool net_blocking=vio_is_blocking(net->vio); @@ -475,7 +481,7 @@ my_real_read(NET *net, ulong *complen) DBUG_PRINT("info",("vio_read returned %d, errno: %d", length, vio_errno(net->vio))); -#if (!defined(__WIN__) && !defined(__EMX__)) || defined(MYSQL_SERVER) +#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) || defined(MYSQL_SERVER) /* We got an error that there was no data on the socket. We now set up an alarm to not 'read forever', change the socket to non blocking diff --git a/sql/slave.cc b/sql/slave.cc index 7cb9bdfd3fc..f6e8822ea14 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -703,7 +703,7 @@ static int init_slave_thread(THD* thd) thd->mysys_var=my_thread_var; thd->dbug_thread_id=my_thread_id(); -#ifndef __WIN__ +#if !defined(__WIN__) && !defined(OS2) sigset_t set; VOID(sigemptyset(&set)); // Get mask in use VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals)); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index a38829f3605..d885d308770 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1401,7 +1401,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type) { int error; -#ifdef __WIN__ +#if defined( __WIN__) || defined(OS2) /* Win32 can't drop a file that is open */ if (lock_type == TL_WRITE_ALLOW_READ #ifdef HAVE_GEMINI_DB @@ -1411,7 +1411,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type) { lock_type= TL_WRITE; } -#endif /* __WIN__ */ +#endif /* __WIN__ || OS2 */ table_list->table=table; table->grant= table_list->grant; diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 7cd892f6079..d0300b57bdb 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -338,7 +338,9 @@ bool mysql_change_db(THD *thd,const char *name) } (void) sprintf(path,"%s/%s",mysql_data_home,dbname); - unpack_dirname(path,path); // Convert if not unix + length=unpack_dirname(path,path); // Convert if not unix + if (length && path[length-1] == FN_LIBCHAR) + path[length-1]=0; // remove ending '\' if (access(path,F_OK)) { net_printf(&thd->net,ER_BAD_DB_ERROR,dbname); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 50e4a6dedd4..c14fbda3bc5 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -876,7 +876,7 @@ static pthread_handler_decl(handle_delayed_insert,arg) pthread_mutex_unlock(&LOCK_thread_count); pthread_mutex_lock(&di->mutex); -#ifndef __WIN__ /* Win32 calls this in pthread_create */ +#if !defined( __WIN__) && !defined(OS2) /* Win32 calls this in pthread_create */ if (my_thread_init()) { strmov(thd->net.last_error,ER(thd->net.last_errno=ER_OUT_OF_RESOURCES)); @@ -895,7 +895,7 @@ static pthread_handler_decl(handle_delayed_insert,arg) } thd->mysys_var=my_thread_var; thd->dbug_thread_id=my_thread_id(); -#ifndef __WIN__ +#if !defined(__WIN__) && !defined(OS2) sigset_t set; VOID(sigemptyset(&set)); // Get mask in use VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals)); diff --git a/sql/sql_load.cc b/sql/sql_load.cc index ce8e34b9265..274b1814674 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -156,7 +156,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, else { unpack_filename(name,ex->file_name); -#ifndef __WIN__ +#if !defined(__WIN__) && !defined(OS2) MY_STAT stat_info; if (!my_stat(name,&stat_info,MYF(MY_WME))) DBUG_RETURN(-1); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 796b571722f..2e5333925e7 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -62,9 +62,13 @@ extern VioSSLAcceptorFd* ssl_acceptor_fd; #ifdef __WIN__ static void test_signal(int sig_ptr) { -#ifndef DBUG_OFF +#if !defined( DBUG_OFF) MessageBox(NULL,"Test signal","DBUG",MB_OK); #endif +#if defined(OS2) + fprintf( stderr, "Test signal %d\n", sig_ptr); + fflush( stderr); +#endif } static void init_signals(void) { @@ -477,7 +481,7 @@ pthread_handler_decl(handle_one_connection,arg) pthread_detach_this_thread(); -#ifndef __WIN__ /* Win32 calls this in pthread_create */ +#if !defined( __WIN__) && !defined(OS2) /* Win32 calls this in pthread_create */ if (my_thread_init()) // needed to be called first before we call // DBUG_ macros { @@ -499,9 +503,9 @@ pthread_handler_decl(handle_one_connection,arg) thd->thread_id)); // now that we've called my_thread_init(), it is safe to call DBUG_* -#ifdef __WIN__ +#if defined(__WIN__) init_signals(); // IRENA; testing ? -#else +#elif !defined(OS2) sigset_t set; VOID(sigemptyset(&set)); // Get mask in use VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals)); @@ -602,7 +606,7 @@ pthread_handler_decl(handle_bootstrap,arg) thd->thread_stack= (char*) &thd; thd->mysys_var=my_thread_var; thd->dbug_thread_id=my_thread_id(); -#ifndef __WIN__ +#if !defined(__WIN__) && !defined(OS2) sigset_t set; VOID(sigemptyset(&set)); // Get mask in use VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals)); @@ -940,7 +944,9 @@ bool do_command(THD *thd) #ifdef __WIN__ sleep(1); // must wait after eof() #endif +#ifndef OS2 send_eof(net); // This is for 'quit request' +#endif close_connection(net); close_thread_tables(thd); // Free before kill free_root(&thd->mem_root,MYF(0)); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 1728427370f..5c3d8def542 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1073,19 +1073,31 @@ int mysql_optimize_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) int mysql_analyze_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt) { +#ifdef OS2 + thr_lock_type lock_type = TL_WRITE; +#else + thr_lock_type lock_type = TL_READ_NO_INSERT; +#endif + DBUG_ENTER("mysql_analyze_table"); DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, - "analyze",TL_READ_NO_INSERT, 1,0,0, + "analyze", lock_type, 1,0,0, &handler::analyze)); } int mysql_check_table(THD* thd, TABLE_LIST* tables,HA_CHECK_OPT* check_opt) { +#ifdef OS2 + thr_lock_type lock_type = TL_WRITE; +#else + thr_lock_type lock_type = TL_READ_NO_INSERT; +#endif + DBUG_ENTER("mysql_check_table"); DBUG_RETURN(mysql_admin_table(thd, tables, check_opt, - "check", - TL_READ_NO_INSERT, 0, 0, HA_OPEN_FOR_REPAIR, + "check", lock_type, + 0, 0, HA_OPEN_FOR_REPAIR, &handler::check)); } @@ -1543,7 +1555,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, } } -#if defined( __WIN__) || defined( __EMX__) +#if defined( __WIN__) || defined( __EMX__) || defined( OS2) // Win32 can't rename an open table, so we must close the org table! table_name=thd->strdup(table_name); // must be saved if (close_cached_table(thd,table)) diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 2ba937be50a..8184ae3b15e 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -53,7 +53,7 @@ extern "C" FreeLibrary((HMODULE)lib); } -#else +#elif !defined(OS2) #include #endif diff --git a/sql/violite.c b/sql/violite.c index 902110ff072..aff4224e5a3 100644 --- a/sql/violite.c +++ b/sql/violite.c @@ -39,7 +39,7 @@ #include #endif -#if defined(__EMX__) +#if defined(__EMX__) || defined(OS2) #define ioctlsocket ioctl #endif /* defined(__EMX__) */ @@ -105,7 +105,7 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost) sprintf(vio->desc, (vio->type == VIO_TYPE_SOCKET ? "socket (%d)" : "TCP/IP (%d)"), vio->sd); -#if !defined(___WIN__) && !defined(__EMX__) +#if !defined(___WIN__) && !defined(__EMX__) && !defined(OS2) #if !defined(NO_FCNTL_NONBLOCK) vio->fcntl_mode = fcntl(sd, F_GETFL); #elif defined(HAVE_SYS_IOCTL_H) /* hpux */ @@ -116,7 +116,7 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost) { /* set to blocking mode by default */ ulong arg=0, r; - r = ioctlsocket(sd,FIONBIO,(void*) &arg, sizeof(arg)); + r = ioctlsocket(vio->sd,FIONBIO,(void*) &arg, sizeof(arg)); } #endif } @@ -154,7 +154,7 @@ void vio_delete(Vio * vio) int vio_errno(Vio *vio __attribute__((unused))) { - return errno; /* On Win32 this mapped to WSAGetLastError() */ + return socket_errno; /* On Win32 this mapped to WSAGetLastError() */ } @@ -163,12 +163,17 @@ int vio_read(Vio * vio, gptr buf, int size) int r; DBUG_ENTER("vio_read"); DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size)); -#ifdef __WIN__ +#if defined( __WIN__) || defined(OS2) if (vio->type == VIO_TYPE_NAMEDPIPE) { DWORD length; +#ifdef OS2 + if (!DosRead((HFILE)vio->hPipe, buf, size, &length)) + DBUG_RETURN(-1); +#else if (!ReadFile(vio->hPipe, buf, size, &length, NULL)) DBUG_RETURN(-1); +#endif DBUG_RETURN(length); } r = recv(vio->sd, buf, size,0); @@ -179,7 +184,7 @@ int vio_read(Vio * vio, gptr buf, int size) #ifndef DBUG_OFF if (r < 0) { - DBUG_PRINT("vio_error", ("Got error %d during read",errno)); + DBUG_PRINT("vio_error", ("Got error %d during read",socket_errno)); } #endif /* DBUG_OFF */ DBUG_PRINT("exit", ("%d", r)); @@ -192,12 +197,17 @@ int vio_write(Vio * vio, const gptr buf, int size) int r; DBUG_ENTER("vio_write"); DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size)); -#ifdef __WIN__ +#if defined( __WIN__) || defined(OS2) if ( vio->type == VIO_TYPE_NAMEDPIPE) { DWORD length; +#ifdef OS2 + if (!DosWrite((HFILE)vio->hPipe, (char*) buf, size, &length)) + DBUG_RETURN(-1); +#else if (!WriteFile(vio->hPipe, (char*) buf, size, &length, NULL)) DBUG_RETURN(-1); +#endif DBUG_RETURN(length); } r = send(vio->sd, buf, size,0); @@ -207,7 +217,7 @@ int vio_write(Vio * vio, const gptr buf, int size) #ifndef DBUG_OFF if (r < 0) { - DBUG_PRINT("vio_error", ("Got error on write: %d",errno)); + DBUG_PRINT("vio_error", ("Got error on write: %d",socket_errno)); } #endif /* DBUG_OFF */ DBUG_PRINT("exit", ("%d", r)); @@ -221,7 +231,7 @@ int vio_blocking(Vio * vio, my_bool set_blocking_mode) DBUG_ENTER("vio_blocking"); DBUG_PRINT("enter", ("set_blocking_mode: %d", (int) set_blocking_mode)); -#if !defined(___WIN__) && !defined(__EMX__) +#if !defined(___WIN__) && !defined(__EMX__) && !defined(OS2) #if !defined(NO_FCNTL_NONBLOCK) if (vio->sd >= 0) @@ -346,7 +356,7 @@ int vio_close(Vio * vio) } if (r) { - DBUG_PRINT("vio_error", ("close() failed, error: %d",errno)); + DBUG_PRINT("vio_error", ("close() failed, error: %d",socket_errno)); /* FIXME: error handling (not critical for MySQL) */ } vio->type= VIO_CLOSED; @@ -385,7 +395,7 @@ my_bool vio_peer_addr(Vio * vio, char *buf) if (getpeername(vio->sd, (struct sockaddr *) (& (vio->remote)), &addrLen) != 0) { - DBUG_PRINT("exit", ("getpeername, error: %d", errno)); + DBUG_PRINT("exit", ("getpeername, error: %d", socket_errno)); DBUG_RETURN(1); } my_inet_ntoa(vio->remote.sin_addr,buf); -- cgit v1.2.1 From 2e6a193c0f1987094471361f72094fe659852d92 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 22 Aug 2001 12:22:46 +0300 Subject: Fix to get core files on Solaris BUILD/compile-solaris-sparc-purify: Added -g --- sql/mysqld.cc | 8 +++++--- sql/stacktrace.c | 10 ++++++++-- sql/stacktrace.h | 7 +------ 3 files changed, 14 insertions(+), 11 deletions(-) (limited to 'sql') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 35aeaecc6e1..b484eee3480 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1247,12 +1247,14 @@ static void init_signals(void) sigset(THR_KILL_SIGNAL,end_thread_signal); sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called! - struct sigaction sa; sa.sa_flags = 0; - sigemptyset(&sa.sa_mask); - sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL); if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL)) { + struct sigaction sa; + sa.sa_flags = SA_RESETHAND | SA_NODEFER; + sigemptyset(&sa.sa_mask); + sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL); + init_stacktrace(); sa.sa_handler=handle_segfault; sigaction(SIGSEGV, &sa, NULL); diff --git a/sql/stacktrace.c b/sql/stacktrace.c index ab1113f74cf..408006dac93 100644 --- a/sql/stacktrace.c +++ b/sql/stacktrace.c @@ -205,11 +205,17 @@ resolve it\n"); /* Produce a core for the thread */ -#ifdef HAVE_WRITE_CORE +#ifdef HAVE_LINUXTHREADS void write_core(int sig) { signal(sig, SIG_DFL); if (fork() != 0) exit(1); // Abort main program // Core will be written at exit } -#endif /* HAVE_WRITE_CORE */ +#else +void write_core(int sig) +{ + signal(sig, SIG_DFL); + pthread_kill(pthread_self(), sig); +} +#endif diff --git a/sql/stacktrace.h b/sql/stacktrace.h index b6c0ec43a0f..980e1ea07eb 100644 --- a/sql/stacktrace.h +++ b/sql/stacktrace.h @@ -30,9 +30,6 @@ extern char* heap_start; void print_stacktrace(gptr stack_bottom, ulong thread_stack); void safe_print_str(const char* name, const char* val, int max_len); #endif /* (defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) */ - -#define HAVE_WRITE_CORE -void write_core(int sig); #endif /* HAVE_LINUXTHREADS */ /* Define empty prototypes for functions that are not implemented */ @@ -42,9 +39,7 @@ void write_core(int sig); #define safe_print_str(A,B,C) {} #endif /* HAVE_STACKTRACE */ -#ifndef HAVE_WRITE_CORE -#define write_core(A) {} -#endif +void write_core(int sig); #ifdef __cplusplus } -- cgit v1.2.1 From 29ebdeb11ccbf43c5b0a3179bed602828eb36149 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 Aug 2001 00:55:48 +0300 Subject: Portability fixes Docs/manual.texi: Small changes because of user request. heap/heapdef.h: Portability fix include/global.h: Portability fix myisam/myisamlog.c: Portability fix sql/mini_client.cc: Fix for windows sql/sql_repl.cc: Fix for windows sql/violite.c: Fix for windows --- sql/mini_client.cc | 19 +++++++++++++++---- sql/sql_repl.cc | 3 +++ sql/violite.c | 14 +++----------- 3 files changed, 21 insertions(+), 15 deletions(-) (limited to 'sql') diff --git a/sql/mini_client.cc b/sql/mini_client.cc index 88a02e227a3..3a2305aa69c 100644 --- a/sql/mini_client.cc +++ b/sql/mini_client.cc @@ -23,10 +23,23 @@ */ #define DONT_USE_RAID -#if defined(__WIN__) || defined(WIN32) +#if defined(__WIN__) #include #include +/* Disable alarms */ +typedef my_bool ALARM; +#define thr_alarm_init(A) (*(A))=0 +#define thr_alarm_in_use(A) (*(A)) +#define thr_end_alarm(A) +#define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C)) +inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused))) +{ + *A=1; + return 0; +} +#define thr_got_alarm(A) 0 #endif + #include #include #include @@ -62,7 +75,7 @@ extern "C" { // Because of SCO 3.2V4.2 #ifdef HAVE_SYS_UN_H # include #endif -#if defined(THREAD) && !defined(__WIN__) +#if defined(THREAD) #include /* because of signal() */ #include #endif @@ -486,9 +499,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, uint pkt_length; NET *net= &mysql->net; thr_alarm_t alarmed; -#if !defined(__WIN__) ALARM alarm_buff; -#endif #ifdef __WIN__ HANDLE hPipe=INVALID_HANDLE_VALUE; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 32c4c5c6509..b9ba284ab27 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -620,6 +620,9 @@ int stop_slave(THD* thd, bool net_report ) #ifdef HAVE_TIMESPEC_TS_SEC abstime.ts_sec=time(NULL)+2; abstime.ts_nsec=0; +#elif defined(__WIN__) + abstime.tv_sec=time((time_t*) 0)+2; + abstime.tv_nsec=0; #else struct timeval tv; gettimeofday(&tv,0); diff --git a/sql/violite.c b/sql/violite.c index aff4224e5a3..0d96c71969c 100644 --- a/sql/violite.c +++ b/sql/violite.c @@ -44,18 +44,10 @@ #endif /* defined(__EMX__) */ #if defined(MSDOS) || defined(__WIN__) -#ifdef __WIN__ -#undef errno -#undef EINTR -#undef EAGAIN -#define errno WSAGetLastError() -#define EINTR WSAEINTR -#define EAGAIN WSAEINPROGRESS -#endif /* __WIN__ */ #define O_NONBLOCK 1 /* For emulation of fcntl() */ #endif #ifndef EWOULDBLOCK -#define EWOULDBLOCK EAGAIN +#define SOCKET_EWOULDBLOCK SOCKET_EAGAIN #endif #ifndef __WIN__ @@ -327,8 +319,8 @@ int vio_keepalive(Vio* vio, my_bool set_keep_alive) my_bool vio_should_retry(Vio * vio __attribute__((unused))) { - int en = errno; - return en == EAGAIN || en == EINTR || en == EWOULDBLOCK; + int en = socket_errno; + return en == SOCKET_EAGAIN || en == SOCKET_EINTR || en == SOCKET_EWOULDBLOCK; } -- cgit v1.2.1 From 30774b35493d3ad14ee40b73d4b9ffff51dd6cd1 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 26 Aug 2001 23:24:48 +0300 Subject: Fixed bug in auto-increment handling with InnoDB Some small speedups Docs/manual.texi: Changelog client/mysqldump.c: Fixed quoting problem for table names when using --opt mysys/mf_casecnv.c: Speed up some common string functions sql-bench/test-insert.sh: Small changes that shouldn't affect results sql-bench/test-select.sh: Small changes that shouldn't affect results sql/field.h: Added reset() functions to speed up some common things sql/gen_lex_hash.cc: Smaller hash table sql/ha_innobase.cc: Fixed bug in auto-increment handling with InnoDB --- sql/field.h | 14 ++++++++++++++ sql/gen_lex_hash.cc | 2 +- sql/ha_innobase.cc | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/field.h b/sql/field.h index fc0bfdc75d5..b9d8e1957c9 100644 --- a/sql/field.h +++ b/sql/field.h @@ -300,6 +300,7 @@ public: void store(const char *to,uint length); void store(double nr); void store(longlong nr); + void reset(void) { ptr[0]=0; } double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -328,6 +329,7 @@ public: void store(const char *to,uint length); void store(double nr); void store(longlong nr); + void reset(void) { ptr[0]=ptr[1]=0; } double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -356,6 +358,7 @@ public: void store(const char *to,uint length); void store(double nr); void store(longlong nr); + void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; } double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -389,6 +392,7 @@ public: void store(const char *to,uint length); void store(double nr); void store(longlong nr); + void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; } double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -423,6 +427,7 @@ public: void store(const char *to,uint length); void store(double nr); void store(longlong nr); + void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; } double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -449,6 +454,7 @@ public: void store(const char *to,uint length); void store(double nr); void store(longlong nr); + void reset(void) { bzero(ptr,sizeof(float)); } double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -480,6 +486,7 @@ public: void store(const char *to,uint length); void store(double nr); void store(longlong nr); + void reset(void) { bzero(ptr,sizeof(double)); } double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -505,6 +512,7 @@ public: void store(const char *to, uint length) { null[0]=1; } void store(double nr) { null[0]=1; } void store(longlong nr) { null[0]=1; } + void reset(void) {} double val_real(void) { return 0.0;} longlong val_int(void) { return 0;} String *val_str(String *value,String *value2) @@ -528,6 +536,7 @@ public: void store(const char *to,uint length); void store(double nr); void store(longlong nr); + void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; } double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -588,6 +597,7 @@ public: void store(const char *to,uint length); void store(double nr); void store(longlong nr); + void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=0; } double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -615,6 +625,7 @@ public: void store(double nr); void store(longlong nr); void store_time(TIME *ltime,timestamp_type type); + void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; } double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -643,6 +654,7 @@ public: void store(const char *to,uint length); void store(double nr); void store(longlong nr); + void reset(void) { ptr[0]=ptr[1]=ptr[2]=0; } double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -673,6 +685,7 @@ public: void store(double nr); void store(longlong nr); void store_time(TIME *ltime,timestamp_type type); + void reset(void) { ptr[0]=ptr[1]=ptr[2]=ptr[3]=ptr[4]=ptr[5]=ptr[6]=ptr[7]=0; } double val_real(void); longlong val_int(void); String *val_str(String*,String *); @@ -922,6 +935,7 @@ public: void store(const char *to,uint length); void store(double nr); void store(longlong nr); + void reset() { bzero(ptr,packlength); } 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 5eee5c6163a..d55197a8b60 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -472,7 +472,7 @@ int main(int argc,char **argv) int error; MY_INIT(argv[0]); - start_value=487844L; best_t1=4969454L; best_t2=2266538L; best_type=2; /* mode=4567 add=5 type: 0 */ + start_value=4597269L; best_t1=6001982L; best_t2=5063828L; best_type=4; /* mode=4513 add=8 type: 0 */ if (get_options(argc,(char **) argv)) exit(1); diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index fdbc0b107f5..061371eb5d4 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -1334,6 +1334,8 @@ ha_innobase::write_row( autoincrement field */ auto_inc = table->next_number_field->val_int(); + if (auto_inc == 0) + auto_inc= user_thd->next_insert_id; if (auto_inc != 0) { /* This call will calculate the max of the -- cgit v1.2.1 From bfe2213babce74eac616dd3be0c8ac5bce16f032 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 28 Aug 2001 06:43:55 +0300 Subject: Fixed that LOAD DATA INFILE works with transactions. Fix for lower case filenames BitKeeper/deleted/.del-select.tst~2e626fa07144d2c8: Delete: mysql-test/misc/select.tst Docs/manual.texi: Better examples for sub selects bdb/lock/lock_region.c: Fixed not critical error mysql-test/r/gemini.result: Testcase for load data infile mysql-test/t/gemini.test: Testcase for load data infile sql/sql_load.cc: Fixed that LOAD DATA INFILE works with transactions sql/sql_show.cc: Fix for lower case filenames sql/sql_string.cc: cleanup --- sql/sql_load.cc | 15 ++++++++++++--- sql/sql_show.cc | 16 +++++++++++++--- sql/sql_string.cc | 6 +++--- 3 files changed, 28 insertions(+), 9 deletions(-) (limited to 'sql') diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 274b1814674..9d3b899d31b 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -71,6 +71,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, String *field_term=ex->field_term,*escaped=ex->escaped, *enclosed=ex->enclosed; bool is_fifo=0; + bool using_transactions; + DBUG_ENTER("mysql_load"); if (escaped->length() > 1 || enclosed->length() > 1) @@ -239,8 +241,13 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, free_blobs(table); /* if pack_blob was used */ table->copy_blobs=0; thd->count_cuted_fields=0; /* Don`t calc cuted fields */ + using_transactions = table->file->has_transactions(); if (error) - DBUG_RETURN(-1); // Error on read + { + if (using_transactions) + ha_autocommit_or_rollback(thd,error); + DBUG_RETURN(-1); // Error on read + } sprintf(name,ER(ER_LOAD_INFO),info.records,info.deleted, info.records-info.copied,thd->cuted_fields); send_ok(&thd->net,info.copied+info.deleted,0L,name); @@ -248,7 +255,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, if(!thd->slave_thread) mysql_update_log.write(thd,thd->query,thd->query_length); - if (!table->file->has_transactions()) + if (!using_transactions) thd->options|=OPTION_STATUS_NO_TRANS_UPDATE; if (!read_file_from_client && mysql_bin_log.is_open()) { @@ -257,7 +264,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, handle_duplicates); mysql_bin_log.write(&qinfo); } - DBUG_RETURN(0); + if (using_transactions) + error=ha_autocommit_or_rollback(thd,error); + DBUG_RETURN(error); } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 71ee60e1eca..5869feefdc3 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -182,6 +182,8 @@ mysql_find_files(THD *thd,List *files, const char *db,const char *path, TABLE_LIST table_list; DBUG_ENTER("mysql_find_files"); + if (wild && !wild[0]) + wild=0; bzero((char*) &table_list,sizeof(table_list)); if (!(dirp = my_dir(path,MYF(MY_WME | (dir ? MY_WANT_STAT : 0))))) @@ -200,7 +202,7 @@ mysql_find_files(THD *thd,List *files, const char *db,const char *path, #endif { if (file->name[0] == '.' || !MY_S_ISDIR(file->mystat.st_mode) || - (wild && wild[0] && wild_compare(file->name,wild))) + (wild && wild_compare(file->name,wild))) continue; } } @@ -211,8 +213,16 @@ mysql_find_files(THD *thd,List *files, const char *db,const char *path, is_prefix(file->name,tmp_file_prefix)) continue; *ext=0; - if (wild && wild[0] && wild_compare(file->name,wild)) - continue; + if (wild) + { + if (lower_case_table_names) + { + if (wild_case_compare(file->name,wild)) + continue; + } + else if (wild_compare(file->name,wild)) + continue; + } } /* Don't show tables where we don't have any privileges */ if (db && !(col_access & TABLE_ACLS)) diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 174d07d8ec4..e6cdd089bf1 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -542,8 +542,8 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length) #endif int wild_case_compare(const char *str,const char *str_end, - const char *wildstr,const char *wildend, - char escape) + const char *wildstr,const char *wildend, + char escape) { int result= -1; // Not found, using wildcards #ifdef USE_MB @@ -677,7 +677,7 @@ int wild_case_compare(String &match,String &wild, char escape) */ int wild_compare(const char *str,const char *str_end, - const char *wildstr,const char *wildend,char escape) + const char *wildstr,const char *wildend,char escape) { int result= -1; // Not found, using wildcards while (wildstr != wildend) -- cgit v1.2.1 From 1241395fce6c953f38b5940978593f3705e2666d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Aug 2001 17:33:41 +0300 Subject: Test that all MERGE tables comes from the same database Docs/manual.texi: Changelog and more documentation about ALTER TABLE include/mysqld_error.h: New error message mysql-test/t/merge.test: Test of error conditions sql/gen_lex_hash.cc: Smaller array sql/ha_myisammrg.cc: Cleanup sql/share/czech/errmsg.txt: New message sql/share/danish/errmsg.txt: New message sql/share/dutch/errmsg.txt: New message sql/share/english/errmsg.txt: New message sql/share/estonian/errmsg.txt: New message sql/share/french/errmsg.txt: New message sql/share/german/errmsg.txt: New message sql/share/greek/errmsg.txt: New message sql/share/hungarian/errmsg.txt: New message sql/share/italian/errmsg.txt: New message sql/share/japanese/errmsg.txt: New message sql/share/korean/errmsg.txt: New message sql/share/norwegian-ny/errmsg.txt: New message sql/share/norwegian/errmsg.txt: New message sql/share/polish/errmsg.txt: New message sql/share/portuguese/errmsg.txt: New message sql/share/romanian/errmsg.txt: New message sql/share/russian/errmsg.txt: New message sql/share/slovak/errmsg.txt: New message sql/share/spanish/errmsg.txt: New message sql/share/swedish/errmsg.txt: New message --- sql/gen_lex_hash.cc | 2 +- sql/ha_myisammrg.cc | 6 ------ sql/share/czech/errmsg.txt | 1 + sql/share/danish/errmsg.txt | 1 + sql/share/dutch/errmsg.txt | 1 + sql/share/english/errmsg.txt | 1 + sql/share/estonian/errmsg.txt | 1 + sql/share/french/errmsg.txt | 1 + sql/share/german/errmsg.txt | 1 + sql/share/greek/errmsg.txt | 1 + sql/share/hungarian/errmsg.txt | 1 + sql/share/italian/errmsg.txt | 1 + sql/share/japanese/errmsg.txt | 1 + sql/share/korean/errmsg.txt | 1 + sql/share/norwegian-ny/errmsg.txt | 1 + sql/share/norwegian/errmsg.txt | 1 + sql/share/polish/errmsg.txt | 1 + sql/share/portuguese/errmsg.txt | 1 + sql/share/romanian/errmsg.txt | 1 + sql/share/russian/errmsg.txt | 1 + sql/share/slovak/errmsg.txt | 1 + sql/share/spanish/errmsg.txt | 1 + sql/share/swedish/errmsg.txt | 1 + sql/sql_parse.cc | 12 ++++++++++-- 24 files changed, 32 insertions(+), 9 deletions(-) (limited to 'sql') diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index d55197a8b60..e05fdafcbc4 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -472,7 +472,7 @@ int main(int argc,char **argv) int error; MY_INIT(argv[0]); - start_value=4597269L; best_t1=6001982L; best_t2=5063828L; best_type=4; /* mode=4513 add=8 type: 0 */ + start_value=6130115L; best_t1=3632784L; best_t2=86437L; best_type=3; /* mode=4229 add=2 type: 0 */ if (get_options(argc,(char **) argv)) exit(1); diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index 866fd1e69f9..1feaa4e5d66 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -86,7 +86,6 @@ int ha_myisammrg::delete_row(const byte * buf) int ha_myisammrg::index_read(byte * buf, const byte * key, uint key_len, enum ha_rkey_function find_flag) { -// return (my_errno=HA_ERR_WRONG_COMMAND); statistic_increment(ha_read_key_count,&LOCK_status); int error=myrg_rkey(file,buf,active_index, key, key_len, find_flag); table->status=error ? STATUS_NOT_FOUND: 0; @@ -96,7 +95,6 @@ int ha_myisammrg::index_read(byte * buf, const byte * key, int ha_myisammrg::index_read_idx(byte * buf, uint index, const byte * key, uint key_len, enum ha_rkey_function find_flag) { -// return (my_errno=HA_ERR_WRONG_COMMAND); statistic_increment(ha_read_key_count,&LOCK_status); int error=myrg_rkey(file,buf,index, key, key_len, find_flag); table->status=error ? STATUS_NOT_FOUND: 0; @@ -105,7 +103,6 @@ int ha_myisammrg::index_read_idx(byte * buf, uint index, const byte * key, int ha_myisammrg::index_next(byte * buf) { -// return (my_errno=HA_ERR_WRONG_COMMAND); statistic_increment(ha_read_next_count,&LOCK_status); int error=myrg_rnext(file,buf,active_index); table->status=error ? STATUS_NOT_FOUND: 0; @@ -114,7 +111,6 @@ int ha_myisammrg::index_next(byte * buf) int ha_myisammrg::index_prev(byte * buf) { -// return (my_errno=HA_ERR_WRONG_COMMAND); statistic_increment(ha_read_prev_count,&LOCK_status); int error=myrg_rprev(file,buf, active_index); table->status=error ? STATUS_NOT_FOUND: 0; @@ -123,7 +119,6 @@ int ha_myisammrg::index_prev(byte * buf) int ha_myisammrg::index_first(byte * buf) { -// return (my_errno=HA_ERR_WRONG_COMMAND); statistic_increment(ha_read_first_count,&LOCK_status); int error=myrg_rfirst(file, buf, active_index); table->status=error ? STATUS_NOT_FOUND: 0; @@ -132,7 +127,6 @@ int ha_myisammrg::index_first(byte * buf) int ha_myisammrg::index_last(byte * buf) { -// return (my_errno=HA_ERR_WRONG_COMMAND); statistic_increment(ha_read_last_count,&LOCK_status); int error=myrg_rlast(file, buf, active_index); table->status=error ? STATUS_NOT_FOUND: 0; diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index f67496da923..1ca2aa9b02b 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -222,3 +222,4 @@ "CREATE DATABASE not allowed while thread is holding global read lock", "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", diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 34c3d8ed95d..e6c828625eb 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -216,3 +216,4 @@ "CREATE DATABASE er ikke tilladt mens en tråd holder på globalt read lock", "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", diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index b4573a551dc..abaa475402e 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -217,3 +217,4 @@ "CREATE DATABASE niet toegestaan terwijl thread een globale 'read lock' bezit", "Foutieve parameters voor %s", "%-.32s@%-.64s is not allowed to create new users", +"Incorrect table definition; All MERGE tables must be in the same database", diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index 80b99c58940..7fc0928d67d 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -213,3 +213,4 @@ "CREATE DATABASE not allowed while thread is holding global read lock", "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", diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index 59a8b156ab2..d9c98fa919d 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -217,3 +217,4 @@ "CREATE DATABASE not allowed while thread is holding global read lock", "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", diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index 98902e847b9..6dc6f150d57 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -213,3 +213,4 @@ "CREATE DATABASE not allowed while thread is holding global read lock", "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", diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index 1d9e770ea8d..262390d42ea 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -216,3 +216,4 @@ "CREATE DATABASE not allowed while thread is holding global read lock", "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", diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index f879c281422..146f196852b 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -213,3 +213,4 @@ "CREATE DATABASE not allowed while thread is holding global read lock", "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", diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 303032d73b2..1d76fd1d898 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -215,3 +215,4 @@ "CREATE DATABASE not allowed while thread is holding global read lock", "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", diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index c927eceb163..79e8c8aed8b 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -213,3 +213,4 @@ "CREATE DATABASE not allowed while thread is holding global read lock", "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", diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index a177fcf81a8..2971882d431 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -215,3 +215,4 @@ "CREATE DATABASE not allowed while thread is holding global read lock", "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", diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index 5c12cbf7d42..7fbc60b8953 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -213,3 +213,4 @@ "CREATE DATABASE not allowed while thread is holding global read lock", "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", diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index 05562e675bb..9fb3f5f5666 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -215,3 +215,4 @@ "CREATE DATABASE not allowed while thread is holding global read lock", "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", diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index 8d973a57137..cc04859d99d 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -215,3 +215,4 @@ "CREATE DATABASE not allowed while thread is holding global read lock", "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", diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index 705eb7f86ef..989c1f7f45d 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -217,3 +217,4 @@ "CREATE DATABASE not allowed while thread is holding global read lock", "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", diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index 9bb32287543..82670f503b0 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -213,3 +213,4 @@ "CREATE DATABASE não permitido enquanto uma 'thread' está mantendo um travamento global de leitura", "Argumentos errados para %s", "Não é permitido a %-.32s@%-.64s criar novos usuários", +"Incorrect table definition; All MERGE tables must be in the same database", diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 2364bbb6d7d..ba214e540e6 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -217,3 +217,4 @@ "CREATE DATABASE not allowed while thread is holding global read lock", "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", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 0d778d67f11..94889100847 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -216,3 +216,4 @@ "CREATE DATABASE not allowed while thread is holding global read lock", "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", diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index e990e00722b..652f50c77c8 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -221,3 +221,4 @@ "CREATE DATABASE not allowed while thread is holding global read lock", "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", diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 35788a72935..271b362f63f 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -214,3 +214,4 @@ "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", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 5914ea31188..1eb3e9db1e7 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -213,3 +213,4 @@ "CREATE DATABASE är inte tillåtet när man har ett globalt läs-lås", "Felaktiga argument till %s", "%-.32s@%-.64s har inte rättigheter att skapa nya användare", +"Felaktig tabell definition: Alla tabeller i en MERGE tabell måste vara i samma databas", diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 2e5333925e7..99fc0fc8fbf 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2178,10 +2178,18 @@ static bool check_merge_table_access(THD *thd, char *db, int error=0; if (table_list) { - /* Force all tables to use the current database */ + /* Check that all tables use the current database */ TABLE_LIST *tmp; for (tmp=table_list; tmp ; tmp=tmp->next) - tmp->db=db; + { + if (!tmp->db || !tmp->db[0]) + tmp->db=db; + else if (!strcmp(tmp->db,db)) + { + send_error(&thd->net,ER_UNION_TABLES_IN_DIFFERENT_DIR); + return 1; + } + } error=check_table_access(thd, SELECT_ACL | UPDATE_ACL | DELETE_ACL, table_list); } -- cgit v1.2.1 From dd9fa926b390d59a13f4d2a8e2fef6d653372651 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Aug 2001 19:42:23 +0300 Subject: trx0roll.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints trx0sys.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints trx0trx.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints row0mysql.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints row0purge.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints row0sel.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints row0uins.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints row0umod.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints row0upd.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints srv0srv.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints srv0start.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints sync0arr.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints fil0fil.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints ibuf0ibuf.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints lock0lock.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints os0file.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints btr0btr.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints btr0cur.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints btr0sea.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints buf0buf.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints data0data.c Fix the primary key update + BLOB bug, improve InnoDB Monitor prints srv0srv.h Fix the primary key update + BLOB bug, improve InnoDB Monitor prints trx0sys.h Fix the primary key update + BLOB bug, improve InnoDB Monitor prints trx0trx.h Fix the primary key update + BLOB bug, improve InnoDB Monitor prints btr0cur.h Fix the primary key update + BLOB bug, improve InnoDB Monitor prints buf0buf.h Fix the primary key update + BLOB bug, improve InnoDB Monitor prints data0data.h Fix the primary key update + BLOB bug, improve InnoDB Monitor prints ha_innobase.cc Fix the auto-inc+REPLACE+replication bug, improve InnoDB Monitor prints sql/ha_innobase.cc: Fix the auto-inc+REPLACE+replication bug, improve InnoDB Monitor prints innobase/include/btr0cur.h: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/include/buf0buf.h: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/include/data0data.h: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/include/srv0srv.h: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/include/trx0sys.h: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/include/trx0trx.h: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/btr/btr0btr.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/btr/btr0cur.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/btr/btr0sea.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/buf/buf0buf.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/data/data0data.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/fil/fil0fil.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/ibuf/ibuf0ibuf.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/lock/lock0lock.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/os/os0file.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/row/row0mysql.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/row/row0purge.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/row/row0sel.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/row/row0uins.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/row/row0umod.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/row/row0upd.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/srv/srv0srv.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/srv/srv0start.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/sync/sync0arr.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/trx/trx0roll.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/trx/trx0sys.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints innobase/trx/trx0trx.c: Fix the primary key update + BLOB bug, improve InnoDB Monitor prints --- sql/ha_innobase.cc | 104 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 90 insertions(+), 14 deletions(-) (limited to 'sql') diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 061371eb5d4..5f76ec39ce3 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -180,6 +180,47 @@ convert_error_code_to_mysql( } } +extern "C" { +/***************************************************************** +Prints info of a THD object (== user session thread) to the +standatd output. NOTE that mysql/innobase/trx/trx0trx.c must contain +the prototype for this function! */ + +void +innobase_mysql_print_thd( +/*=====================*/ + void* input_thd)/* in: pointer to a MySQL THD object */ +{ + THD* thd; + + thd = (THD*) input_thd; + + printf("MySQL thread id %lu, query id %lu", + thd->thread_id, thd->query_id); + if (thd->host) { + printf(" %s", thd->host); + } + + if (thd->ip) { + printf(" %s", thd->ip); + } + + if (thd->user) { + printf(" %s", thd->user); + } + + if (thd->proc_info) { + printf(" %s", thd->proc_info); + } + + if (thd->query) { + printf(" %0.100s", thd->query); + } + + printf("\n"); +} +} + /************************************************************************* Gets the InnoDB transaction handle for a MySQL handler object, creates an InnoDB transaction struct if the corresponding MySQL thread struct still @@ -199,6 +240,8 @@ check_trx_exists( dbug_assert(thd != NULL); trx = trx_allocate_for_mysql(); + trx->mysql_thd = thd; + thd->transaction.all.innobase_tid = trx; /* The execution of a single SQL statement is denoted by @@ -633,7 +676,7 @@ innobase_commit( if (trx_handle != (void*)&innodb_dummy_stmt_trx_handle) { trx_commit_for_mysql(trx); - trx_mark_sql_stat_end(trx); + trx_mark_sql_stat_end_do_not_start_new(trx); } else { trx_mark_sql_stat_end(trx); } @@ -672,6 +715,7 @@ innobase_rollback( if (trx_handle != (void*)&innodb_dummy_stmt_trx_handle) { error = trx_rollback_for_mysql(trx); + trx_mark_sql_stat_end_do_not_start_new(trx); } else { error = trx_rollback_last_sql_stat_for_mysql(trx); trx_mark_sql_stat_end(trx); @@ -1334,8 +1378,15 @@ ha_innobase::write_row( autoincrement field */ auto_inc = table->next_number_field->val_int(); - if (auto_inc == 0) - auto_inc= user_thd->next_insert_id; + + /* In replication and also otherwise the auto-inc column + can be set with SET INSERT_ID. Then we must look at + user_thd->next_insert_id. If it is nonzero and the user + has not supplied a value, we must use it. */ + + if (auto_inc == 0 && user_thd->next_insert_id != 0) { + auto_inc = user_thd->next_insert_id; + } if (auto_inc != 0) { /* This call will calculate the max of the @@ -2221,29 +2272,29 @@ ha_innobase::external_lock( if (trx->n_mysql_tables_in_use == 0) { trx_mark_sql_stat_end(trx); } - thd->transaction.all.innodb_active_trans=1; + thd->transaction.all.innodb_active_trans = 1; trx->n_mysql_tables_in_use++; if (prebuilt->select_lock_type != LOCK_NONE) { - trx->mysql_n_tables_locked++; + trx->mysql_n_tables_locked++; } } else { trx->n_mysql_tables_in_use--; if (trx->n_mysql_tables_in_use == 0) { - trx->mysql_n_tables_locked = 0; + trx->mysql_n_tables_locked = 0; - if (trx->has_search_latch) { + if (trx->has_search_latch) { - trx_search_latch_release_if_reserved(trx); - } + trx_search_latch_release_if_reserved(trx); + } - if (!(thd->options - & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN))) { - innobase_commit(thd, trx); - } + if (!(thd->options + & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN))) { + innobase_commit(thd, trx); + } } } @@ -2639,6 +2690,10 @@ ha_innobase::records_in_range( DBUG_ENTER("records_in_range"); + if (prebuilt->trx) { + prebuilt->trx->op_info = "estimating range size"; + } + active_index = keynr; key = table->key_info + active_index; @@ -2671,6 +2726,10 @@ ha_innobase::records_in_range( my_free((char*) key_val_buff2, MYF(0)); + if (prebuilt->trx) { + prebuilt->trx->op_info = ""; + } + DBUG_RETURN((ha_rows) n_rows); } @@ -2690,10 +2749,15 @@ ha_innobase::estimate_number_of_rows(void) row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; dict_table_t* ib_table; + if (prebuilt->trx) { + prebuilt->trx->op_info = + "estimating upper bound of table size"; + } + DBUG_ENTER("info"); ib_table = prebuilt->table; - + dict_update_statistics(ib_table); data_file_length = ((ulonglong) @@ -2702,6 +2766,10 @@ ha_innobase::estimate_number_of_rows(void) /* The minimum clustered index record size is 20 bytes */ + if (prebuilt->trx) { + prebuilt->trx->op_info = ""; + } + return((ha_rows) (1000 + data_file_length / 20)); } @@ -2740,6 +2808,10 @@ ha_innobase::info( DBUG_ENTER("info"); + if (prebuilt->trx) { + prebuilt->trx->op_info = "calculating table stats"; + } + ib_table = prebuilt->table; if (flag & HA_STATUS_TIME) { @@ -2802,6 +2874,10 @@ ha_innobase::info( trx_get_error_info(prebuilt->trx)); } + if (prebuilt->trx) { + prebuilt->trx->op_info = ""; + } + DBUG_VOID_RETURN; } -- cgit v1.2.1 From 9a4aac7e23446427ec705d3b65095b8a8f956aee Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 30 Aug 2001 01:22:02 +0300 Subject: Fix for OS2 Docs/manual.texi: Cleanup --- sql/mini_client.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sql') diff --git a/sql/mini_client.cc b/sql/mini_client.cc index 3a2305aa69c..fe8a0a161b3 100644 --- a/sql/mini_client.cc +++ b/sql/mini_client.cc @@ -52,6 +52,11 @@ inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __a #include "errmsg.h" #include +#if defined( OS2) && defined( MYSQL_SERVER) +#undef ER +#define ER CER +#endif + extern ulong net_read_timeout; extern "C" { // Because of SCO 3.2V4.2 -- cgit v1.2.1 From 18cd5fe5e0dbb43367623a6e4a96d757edd0c78d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 30 Aug 2001 20:38:46 +0300 Subject: Increase version number sql/ha_myisam.cc: Added comments --- sql/ha_myisam.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sql') diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 8be62920308..a429d5308dd 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -231,8 +231,16 @@ int ha_myisam::close(void) int ha_myisam::write_row(byte * buf) { statistic_increment(ha_write_count,&LOCK_status); + + /* If we have a timestamp column, update it to the current time */ + if (table->time_stamp) update_timestamp(buf+table->time_stamp-1); + + /* + If we have an auto_increment column and we are writing a changed row + or a new row, then update the auto_increment value in the record. + */ if (table->next_number_field && buf == table->record[0]) update_auto_increment(); return mi_write(file,buf); -- cgit v1.2.1 From 83c86c854a1b40bfe46e0464de63e97a75a9b030 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 30 Aug 2001 21:16:39 +0300 Subject: Portability fixes Docs/manual.texi: Changelog client/mysqlbinlog.cc: Portability fix myisam/ft_test1.c: Portability fix sql/log_event.cc: Portability fix --- sql/log_event.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sql') diff --git a/sql/log_event.cc b/sql/log_event.cc index 41efa0f5658..6e99e031f4a 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -277,7 +277,11 @@ void Log_event::print_timestamp(FILE* file, time_t* ts) { ts = &when; } +#ifdef MYSQL_SERVER localtime_r(ts,&tm_tmp); +#else + localtime(ts); +#endif fprintf(file,"%02d%02d%02d %2d:%02d:%02d", tm_tmp.tm_year % 100, -- cgit v1.2.1 From 421e64ae356a1633ea50294b48c5025ea387a64d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 31 Aug 2001 10:30:38 +0300 Subject: ix compilition for computer in a previous timezone Build-tools/Do-compile: Fix compilition for computer in a previous timezone sql/net_serv.cc: Added comment sql/sql_parse.cc: Cleanup --- sql/net_serv.cc | 2 +- sql/sql_parse.cc | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'sql') diff --git a/sql/net_serv.cc b/sql/net_serv.cc index ba0944a2516..c9bfd977e78 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -177,7 +177,7 @@ static my_bool net_realloc(NET *net, ulong length) void net_clear(NET *net) { #ifndef EXTRA_DEBUG - int count; + int count; // One may get 'unused' warning bool is_blocking=vio_is_blocking(net->vio); if (is_blocking) vio_blocking(net->vio, FALSE); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 99fc0fc8fbf..816825c8cc1 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -174,7 +174,6 @@ static bool check_user(THD *thd,enum_server_command command, const char *user, */ static HASH hash_user_connections; -static DYNAMIC_ARRAY user_conn_array; extern pthread_mutex_t LOCK_user_conn; struct user_conn { -- cgit v1.2.1 From e19a292c56c3c613a798f612a73ff4b9e62eb911 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 31 Aug 2001 16:50:57 +0300 Subject: ha_innobase.cc Add better error message if innodb_data_file_path is not set ha_innobase.h Remove HA_NOT_READ_AFTER_KEY from table han ha_innobase.h dler flags: it prevented the use of an index in MAX() sql/ha_innobase.h: Remove HA_NOT_READ_AFTER_KEY from table han dler flags: it prevented the use of an index in MAX() sql/ha_innobase.cc: Add better error message if innodb_data_file_path is not set --- sql/ha_innobase.cc | 10 +++++++++- sql/ha_innobase.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'sql') diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 5f76ec39ce3..2eed5ada680 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -542,7 +542,15 @@ innobase_init(void) if (!innobase_data_file_path) { fprintf(stderr, - "Can't initialize InnoDB as 'innodb_data_file_path' is not set\n"); + "Cannot initialize InnoDB as 'innodb_data_file_path' is not set.\n" + "If you do not want to use transactional InnoDB tables, add a line\n" + "skip-innodb\n" + "to the [mysqld] section of init parameters in your my.cnf\n" + "or my.ini. If you want to use InnoDB tables, add for example,\n" + "innodb_data_file_path = /mysql/data/ibdata1:20M\n" + "More information on setting the parameters you find in the\n" + "manual.\n"); + innodb_skip=1; DBUG_RETURN(FALSE); // Continue without innobase } diff --git a/sql/ha_innobase.h b/sql/ha_innobase.h index d129e00ba6e..daa987dd757 100644 --- a/sql/ha_innobase.h +++ b/sql/ha_innobase.h @@ -83,7 +83,7 @@ class ha_innobase: public handler HA_NO_WRITE_DELAYED | HA_PRIMARY_KEY_IN_READ_INDEX | HA_DROP_BEFORE_CREATE | - HA_NOT_READ_AFTER_KEY | HA_NO_PREFIX_CHAR_KEYS), + HA_NO_PREFIX_CHAR_KEYS), last_dup_key((uint) -1), start_of_scan(0) { -- cgit v1.2.1 From 4295917682a23b6f8d493d9433b0b7c1f244c421 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 31 Aug 2001 23:02:09 +0300 Subject: Fixed problem with INSERT DELAYED Make killing threads safer Docs/manual.texi: Portability fix mysys/thr_lock.c: Fixed problem with INSERT DELAYED sql/mysqld.cc: Make shutdown safer sql/sql_class.cc: Make kill thread safer sql/sql_insert.cc: Make kill thread safer --- sql/mysqld.cc | 4 +++- sql/sql_class.cc | 12 ++++++------ sql/sql_insert.cc | 8 +++++--- 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'sql') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b484eee3480..1255b55a81c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -509,12 +509,14 @@ static void close_connections(void) if (tmp->mysys_var) { tmp->mysys_var->abort=1; - if (tmp->mysys_var->current_mutex) + pthread_mutex_lock(&tmp->mysys_var->mutex); + if (tmp->mysys_var->current_cond) { pthread_mutex_lock(tmp->mysys_var->current_mutex); pthread_cond_broadcast(tmp->mysys_var->current_cond); pthread_mutex_unlock(tmp->mysys_var->current_mutex); } + pthread_mutex_unlock(&tmp->mysys_var->mutex); } } (void) pthread_mutex_unlock(&LOCK_thread_count); // For unlink from list diff --git a/sql/sql_class.cc b/sql/sql_class.cc index c57b59f55a6..ace7c291ed3 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -226,12 +226,12 @@ void THD::prepare_to_die() pthread_mutex_lock(&mysys_var->mutex); if (!system_thread) // Don't abort locks mysys_var->abort=1; - if (mysys_var->current_mutex) - { - pthread_mutex_lock(mysys_var->current_mutex); - pthread_cond_broadcast(mysys_var->current_cond); - pthread_mutex_unlock(mysys_var->current_mutex); - } + if (mysys_var->current_cond) + { + pthread_mutex_lock(mysys_var->current_mutex); + pthread_cond_broadcast(mysys_var->current_cond); + pthread_mutex_unlock(mysys_var->current_mutex); + } pthread_mutex_unlock(&mysys_var->mutex); } } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index c14fbda3bc5..e6872fa1696 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -511,10 +511,12 @@ public: delayed_row *row; while ((row=rows.get())) delete row; - pthread_mutex_destroy(&mutex); if (table) close_thread_tables(&thd); VOID(pthread_mutex_lock(&LOCK_thread_count)); + pthread_mutex_destroy(&mutex); + pthread_cond_destroy(&cond); + pthread_cond_destroy(&cond_client); thd.unlink(); // Must be unlinked under lock x_free(thd.query); thd.user=thd.host=0; @@ -842,7 +844,7 @@ void kill_delayed_threads(void) if (tmp->thd.mysys_var) { pthread_mutex_lock(&tmp->thd.mysys_var->mutex); - if (tmp->thd.mysys_var->current_mutex) + if (tmp->thd.mysys_var->current_cond) { if (&tmp->mutex != tmp->thd.mysys_var->current_mutex) pthread_mutex_lock(tmp->thd.mysys_var->current_mutex); @@ -970,7 +972,7 @@ static pthread_handler_decl(handle_delayed_insert,arg) di->thd.proc_info=0; DBUG_PRINT("info",("Waiting for someone to insert rows")); - for ( ; ;) + while (!thd->killed) { int error; #if (defined(HAVE_BROKEN_COND_TIMEDWAIT) || defined(HAVE_LINUXTHREADS)) -- cgit v1.2.1 From 09c35c69634c23765aee861639c111c34c1589e7 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 31 Aug 2001 15:55:58 -0600 Subject: replicated get_lock() properly sql/item_func.cc: log all lock releases to binary log for safe handling of get_lock() in updates --- sql/item_func.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'sql') diff --git a/sql/item_func.cc b/sql/item_func.cc index 989d7709513..47adb902107 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1399,6 +1399,23 @@ void item_user_lock_free(void) void item_user_lock_release(ULL *ull) { ull->locked=0; + if (mysql_bin_log.is_open()) + { + THD *thd = current_thd; + int save_errno; + char buf[256]; + String tmp(buf,sizeof(buf)); + tmp.length(0); + tmp.append("SELECT release_lock(\""); + tmp.append(ull->key,ull->key_length); + tmp.append("\")"); + save_errno=thd->net.last_errno; + thd->net.last_errno=0; + thd->query_length=tmp.length(); + Query_log_event qev(thd,tmp.ptr()); + mysql_bin_log.write(&qev); + thd->net.last_errno=save_errno; + } if (--ull->count) pthread_cond_signal(&ull->cond); else -- cgit v1.2.1 From 9591abbd399bb4b85db9da458fba5ed972c97afa Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 1 Sep 2001 10:38:16 +0300 Subject: Make killing of threads safer Docs/manual.texi: Changelog sql/sql_insert.cc: Fix problem with INSERT DELAYED during shutdown --- sql/item_func.cc | 16 +++++----------- sql/lock.cc | 2 -- sql/sql_base.cc | 9 +++------ sql/sql_class.h | 2 -- sql/sql_insert.cc | 22 ++++++++++++---------- sql/sql_repl.cc | 9 ++++----- sql/sql_table.cc | 2 -- 7 files changed, 24 insertions(+), 38 deletions(-) (limited to 'sql') diff --git a/sql/item_func.cc b/sql/item_func.cc index 989d7709513..308597c5247 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1483,11 +1483,9 @@ longlong Item_func_get_lock::val_int() /* structure is now initialized. Try to get the lock */ /* Set up control struct to allow others to abort locks */ - pthread_mutex_lock(&thd->mysys_var->mutex); thd->proc_info="User lock"; thd->mysys_var->current_mutex= &LOCK_user_locks; thd->mysys_var->current_cond= &ull->cond; - pthread_mutex_unlock(&thd->mysys_var->mutex); #ifdef HAVE_TIMESPEC_TS_SEC abstime.ts_sec=time((time_t*) 0)+(time_t) timeout; @@ -1497,15 +1495,11 @@ longlong Item_func_get_lock::val_int() abstime.tv_nsec=0; #endif - while ((error=pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime)) - != ETIME && error != ETIMEDOUT && ull->locked) - { - if (thd->killed || abort_loop) - { - error=EINTR; // Return NULL - break; - } - } + while (!thd->killed && + (error=pthread_cond_timedwait(&ull->cond,&LOCK_user_locks,&abstime)) + != ETIME && error != ETIMEDOUT && ull->locked) ; + if (thd->killed) + error=EINTR; // Return NULL if (ull->locked) { if (!--ull->count) diff --git a/sql/lock.cc b/sql/lock.cc index 1d9aca66e74..a8b26c3b17d 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -65,11 +65,9 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **tables,uint count) } pthread_mutex_lock(&LOCK_open); - pthread_mutex_lock(&thd->mysys_var->mutex); thd->mysys_var->current_mutex= &LOCK_open; thd->mysys_var->current_cond= &COND_refresh; thd->proc_info="Waiting for table"; - pthread_mutex_unlock(&thd->mysys_var->mutex); while (global_read_lock && ! thd->killed && thd->version == refresh_version) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index d885d308770..16495ab03b0 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -358,11 +358,9 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh, */ if (!tables) kill_delayed_threads(); - pthread_mutex_lock(&thd->mysys_var->mutex); thd->mysys_var->current_mutex= &LOCK_open; thd->mysys_var->current_cond= &COND_refresh; thd->proc_info="Flushing tables"; - pthread_mutex_unlock(&thd->mysys_var->mutex); close_old_data_files(thd,thd->open_tables,1,1); bool found=1; @@ -667,13 +665,12 @@ void wait_for_refresh(THD *thd) { /* Wait until the current table is up to date */ const char *proc_info; - pthread_mutex_lock(&thd->mysys_var->mutex); thd->mysys_var->current_mutex= &LOCK_open; thd->mysys_var->current_cond= &COND_refresh; proc_info=thd->proc_info; thd->proc_info="Waiting for table"; - pthread_mutex_unlock(&thd->mysys_var->mutex); - (void) pthread_cond_wait(&COND_refresh,&LOCK_open); + if (!thd->killed) + (void) pthread_cond_wait(&COND_refresh,&LOCK_open); pthread_mutex_unlock(&LOCK_open); // Must be unlocked first pthread_mutex_lock(&thd->mysys_var->mutex); @@ -2182,7 +2179,7 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, { in_use->killed=1; pthread_mutex_lock(&in_use->mysys_var->mutex); - if (in_use->mysys_var->current_mutex) + if (in_use->mysys_var->current_cond) { pthread_mutex_lock(in_use->mysys_var->current_mutex); pthread_cond_broadcast(in_use->mysys_var->current_cond); diff --git a/sql/sql_class.h b/sql/sql_class.h index bbf6fe08d88..3d218a06d0c 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -326,11 +326,9 @@ public: const char* msg) { const char* old_msg = proc_info; - pthread_mutex_lock(&mysys_var->mutex); mysys_var->current_mutex = mutex; mysys_var->current_cond = cond; proc_info = msg; - pthread_mutex_unlock(&mysys_var->mutex); return old_msg; } inline void exit_cond(const char* old_msg) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index e6872fa1696..cd738999383 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -482,7 +482,7 @@ public: COPY_INFO info; I_List rows; uint group_count; - TABLE_LIST *table_list; // Argument + TABLE_LIST table_list; // Argument delayed_insert() :locks_in_memory(0), @@ -611,7 +611,9 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list) pthread_mutex_unlock(&LOCK_delayed_create); DBUG_RETURN(0); } - tmp->table_list=table_list; // Needed to open table + tmp->table_list= *table_list; // Needed to open table + tmp->table_list.db= tmp->thd.db; + tmp->table_list.name= tmp->table_list.real_name=tmp->thd.query; tmp->lock(); pthread_mutex_lock(&tmp->mutex); if ((error=pthread_create(&tmp->thd.real_id,&connection_attrib, @@ -846,11 +848,9 @@ void kill_delayed_threads(void) pthread_mutex_lock(&tmp->thd.mysys_var->mutex); if (tmp->thd.mysys_var->current_cond) { - if (&tmp->mutex != tmp->thd.mysys_var->current_mutex) - pthread_mutex_lock(tmp->thd.mysys_var->current_mutex); + pthread_mutex_lock(tmp->thd.mysys_var->current_mutex); pthread_cond_broadcast(tmp->thd.mysys_var->current_cond); - if (&tmp->mutex != tmp->thd.mysys_var->current_mutex) - pthread_mutex_unlock(tmp->thd.mysys_var->current_mutex); + pthread_mutex_unlock(tmp->thd.mysys_var->current_mutex); } pthread_mutex_unlock(&tmp->thd.mysys_var->mutex); } @@ -875,6 +875,7 @@ static pthread_handler_decl(handle_delayed_insert,arg) thd->thread_id=thread_id++; thd->end_time(); threads.append(thd); + thd->killed=abort_loop; pthread_mutex_unlock(&LOCK_thread_count); pthread_mutex_lock(&di->mutex); @@ -905,7 +906,7 @@ static pthread_handler_decl(handle_delayed_insert,arg) /* open table */ - if (!(di->table=open_ltable(thd,di->table_list,TL_WRITE_DELAYED))) + if (!(di->table=open_ltable(thd,&di->table_list,TL_WRITE_DELAYED))) { thd->fatal_error=1; // Abort waiting inserts goto end; @@ -913,7 +914,7 @@ static pthread_handler_decl(handle_delayed_insert,arg) if (di->table->file->has_transactions()) { thd->fatal_error=1; - my_error(ER_ILLEGAL_HA, MYF(0), di->table_list->real_name); + my_error(ER_ILLEGAL_HA, MYF(0), di->table_list.real_name); goto end; } di->table->copy_blobs=1; @@ -965,10 +966,8 @@ static pthread_handler_decl(handle_delayed_insert,arg) #endif /* Information for pthread_kill */ - pthread_mutex_lock(&di->thd.mysys_var->mutex); di->thd.mysys_var->current_mutex= &di->mutex; di->thd.mysys_var->current_cond= &di->cond; - pthread_mutex_unlock(&di->thd.mysys_var->mutex); di->thd.proc_info=0; DBUG_PRINT("info",("Waiting for someone to insert rows")); @@ -996,10 +995,13 @@ static pthread_handler_decl(handle_delayed_insert,arg) break; } } + /* We can't lock di->mutex and mysys_var->mutex at the same time */ + pthread_mutex_unlock(&di->mutex); pthread_mutex_lock(&di->thd.mysys_var->mutex); di->thd.mysys_var->current_mutex= 0; di->thd.mysys_var->current_cond= 0; pthread_mutex_unlock(&di->thd.mysys_var->mutex); + pthread_mutex_lock(&di->mutex); } if (di->tables_in_use && ! thd->lock) diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index b9ba284ab27..7d4a7847eb1 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -414,12 +414,10 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags) log.error=0; // tell the kill thread how to wake us up - pthread_mutex_lock(&thd->mysys_var->mutex); thd->mysys_var->current_mutex = log_lock; thd->mysys_var->current_cond = &COND_binlog_update; const char* proc_info = thd->proc_info; thd->proc_info = "Slave connection: waiting for binlog update"; - pthread_mutex_unlock(&thd->mysys_var->mutex); bool read_packet = 0, fatal_error = 0; @@ -444,7 +442,8 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags) break; case LOG_READ_EOF: DBUG_PRINT("wait",("waiting for data on binary log")); - pthread_cond_wait(&COND_binlog_update, log_lock); + if (!thd->killed) + pthread_cond_wait(&COND_binlog_update, log_lock); break; default: @@ -694,9 +693,9 @@ void kill_zombie_dump_threads(uint32 slave_server_id) thr_alarm_kill(tmp->real_id); tmp->killed = 1; - pthread_mutex_lock(&tmp->mysys_var->mutex); tmp->mysys_var->abort = 1; - if(tmp->mysys_var->current_mutex) + pthread_mutex_lock(&tmp->mysys_var->mutex); + if(tmp->mysys_var->current_cond) { pthread_mutex_lock(tmp->mysys_var->current_mutex); pthread_cond_broadcast(tmp->mysys_var->current_cond); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 5c3d8def542..8f4082c6688 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -53,11 +53,9 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) /* mark for close and remove all cached entries */ - pthread_mutex_lock(&thd->mysys_var->mutex); thd->mysys_var->current_mutex= &LOCK_open; thd->mysys_var->current_cond= &COND_refresh; VOID(pthread_mutex_lock(&LOCK_open)); - pthread_mutex_unlock(&thd->mysys_var->mutex); if (global_read_lock) { -- cgit v1.2.1 From 992e7da03a64a12ed4bcd180dda45cb91e94a4ee Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 2 Sep 2001 16:03:37 +0300 Subject: Added testing of IN(value-list) Portability fixes Build-tools/Do-compile: Fix for Linux ia64 sql-bench/bench-init.pl.sh: Added help function time_fetch_all_rows sql-bench/test-insert.sh: Added testing of IN(value-list) sql/item_func.cc: Cleanup sql/mysqld.cc: Portability fix sql/stacktrace.c: Portability fix --- sql/item_func.cc | 2 +- sql/mysqld.cc | 6 ++++++ sql/stacktrace.c | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/item_func.cc b/sql/item_func.cc index ac12adb50e0..56e3d562ee8 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1462,7 +1462,7 @@ longlong Item_func_get_lock::val_int() struct timespec abstime; THD *thd=current_thd; ULL *ull; - int error; + int error=0; pthread_mutex_lock(&LOCK_user_locks); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1255b55a81c..7d6863cb6eb 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1241,6 +1241,12 @@ information that should help you find out what is causing the crash\n"); exit(1); } +#ifndef SA_RESETHAND +#define SA_RESETHAND 0 +#endif +#ifndef SA_NODEFER +#define SA_NODEFER 0 +#endif static void init_signals(void) { diff --git a/sql/stacktrace.c b/sql/stacktrace.c index 408006dac93..81d8debc27a 100644 --- a/sql/stacktrace.c +++ b/sql/stacktrace.c @@ -17,6 +17,7 @@ #include #include "stacktrace.h" #include +#include #ifdef HAVE_STACKTRACE #include -- cgit v1.2.1