From edf2a160492093a89d77f8f674ee8bb59717f3e7 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Tue, 26 Apr 2005 21:27:06 +0300 Subject: [PATCH 01/98] union.result: Results for the above test case union.test: A test case for bug #10032 involving UNION's and ORDER BY clause sql_yacc.yy: Fix for a bug #10032 involving a parser bug with UNION's and ORDER BY --- mysql-test/r/union.result | 19 +++++++++++++++++++ mysql-test/t/union.test | 11 +++++++++++ sql/sql_yacc.yy | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index c140ecd26e1..b315ae9a3f5 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1235,3 +1235,22 @@ show columns from t2; Field Type Null Key Default Extra a varchar(3) YES NULL drop table t2, t1; +create table t1 ( id int not null auto_increment, primary key (id), col1 int); +insert into t1 (col1) values (2),(3),(4),(5),(6); +select 99 union all select id from t1 order by 1; +99 +1 +2 +3 +4 +5 +99 +select id from t1 union all select 99 order by 1; +id +1 +2 +3 +4 +5 +99 +drop table t1; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index b0446e1ea4a..ecd98428b5a 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -742,3 +742,14 @@ create table t2 select a from t1 union select c from t1; create table t2 select a from t1 union select b from t1; show columns from t2; drop table t2, t1; + + +# +# Bug #10032 Bug in parsing UNION with ORDER BY when one node does not use FROM +# + +create table t1 ( id int not null auto_increment, primary key (id), col1 int); +insert into t1 (col1) values (2),(3),(4),(5),(6); +select 99 union all select id from t1 order by 1; +select id from t1 union all select 99 order by 1; +drop table t1; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 594077dd4f3..8c9c845bbbd 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2449,7 +2449,7 @@ select_part2: select_into select_lock_type; select_into: - opt_limit_clause {} + opt_order_clause opt_limit_clause {} | into | select_from | into select_from From d37ca8bfa723c83fd10d87f399cc3259977bc9c8 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 17 May 2005 21:14:01 +0200 Subject: [PATCH 02/98] BUG#9879 delimiter command discrepancy (4.1 vs. 5.0, mysql vs. mysqltest) - Added testcases to test delimiters in 5.0 - In 5.0 it's allowed to have a up to 16 byte string as delimiter, everything after the delimiter token will be treated as the delimiter. It's even allowed to set delimiter to 'delimiter', ':;' or'MySQL' --- mysql-test/r/mysql.result | 50 ++++++++++++++++++++++++++++++++ mysql-test/t/mysql.test | 34 ++++++++++++++++++++++ mysql-test/t/mysql_delimiter.sql | 48 ++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 mysql-test/r/mysql.result create mode 100644 mysql-test/t/mysql.test create mode 100644 mysql-test/t/mysql_delimiter.sql diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result new file mode 100644 index 00000000000..feb0b2348cd --- /dev/null +++ b/mysql-test/r/mysql.result @@ -0,0 +1,50 @@ +drop table if exists t1; +create table t1(a int); +insert into t1 values(1); + +Test default delimiter ; +a +1 + +Test delimiter without arg + +Test delimiter : +a +1 + +Test delimiter : +a +1 + +Test delimiter :; +a +1 + +Test delimiter // +a +1 + +Test delimiter MySQL +a +1 + +Test delimiter delimiter +a +1 + +Test delimiter : from command line +a +1 + +Test delimiter :; from command line +a +1 + +Test 'go' command(vertical output) G +*************************** 1. row *************************** +a: 1 + +Test 'go' command g +a +1 +drop table t1; diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test new file mode 100644 index 00000000000..d30e5b65d8e --- /dev/null +++ b/mysql-test/t/mysql.test @@ -0,0 +1,34 @@ +# +# Testing the MySQL command line client(mysql) +# + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Test the "delimiter" functionality +# Bug#9879 +# +create table t1(a int); +insert into t1 values(1); + +# Test delimiters +--exec $MYSQL test < "./t/mysql_delimiter.sql" + +--disable_query_log +# Test delimiter : supplied on the command line +select "Test delimiter : from command line" as " "; +--exec $MYSQL test --delimiter=':' -e 'select * from t1:' +# Test delimiter :; supplied on the command line +select "Test delimiter :; from command line" as " "; +--exec $MYSQL test --delimiter=':;' -e 'select * from t1:;' +# Test 'go' command (vertical output) \G +select "Test 'go' command(vertical output) \G" as " "; +--exec $MYSQL test -e 'select * from t1\G' +# Test 'go' command \g +select "Test 'go' command \g" as " "; +--exec $MYSQL test -e 'select * from t1\g' +--enable_query_log + +drop table t1; diff --git a/mysql-test/t/mysql_delimiter.sql b/mysql-test/t/mysql_delimiter.sql new file mode 100644 index 00000000000..4ea481a84e2 --- /dev/null +++ b/mysql-test/t/mysql_delimiter.sql @@ -0,0 +1,48 @@ + +# Test default delimiter ; +select "Test default delimiter ;" as " "; +select * from t1; + +# Test delimiter without argument +select "Test delimiter without arg" as " "; +# Nothing should be displayed, error is returned +delimiter +delimiter ; # Reset delimiter + +# Test delimiter : +select "Test delimiter :" as " "; +delimiter : +select * from t1: +delimiter ; # Reset delimiter + +# Test delimiter ':' +select "Test delimiter :" as " "; +delimiter ':' +select * from t1: +delimiter ; # Reset delimiter + +# Test delimiter :; +select "Test delimiter :;" as " "; +delimiter :; +select * from t1 :; +delimiter ; # Reset delimiter + +## Test delimiter // +select "Test delimiter //" as " "; +delimiter // +select * from t1// +delimiter ; # Reset delimiter + +# Test delimiter 'MySQL' +select "Test delimiter MySQL" as " "; +delimiter 'MySQL' +select * from t1MySQL +delimiter ; # Reset delimiter + +# Test delimiter 'delimiter'(should be allowed according to the code) +select "Test delimiter delimiter" as " "; +delimiter delimiter +select * from t1 delimiter +delimiter ; # Reset delimiter + + From b6179919f3fbdc82e3bb7eb22ee639f2b7c6053c Mon Sep 17 00:00:00 2001 From: "sergefp@mysql.com" <> Date: Wed, 18 May 2005 05:39:10 +0200 Subject: [PATCH 03/98] Change Last_query_cost status variable from global to thread-local. --- sql/mysql_priv.h | 1 - sql/mysqld.cc | 3 +-- sql/sql_class.cc | 1 + sql/sql_class.h | 2 ++ sql/sql_select.cc | 3 +-- sql/sql_show.cc | 1 + 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 36fc315c3c0..312f665e22f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1048,7 +1048,6 @@ extern char language[FN_REFLEN], reg_ext[FN_EXTLEN]; extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN]; extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file; extern char log_error_file[FN_REFLEN], *opt_tc_log_file; -extern double last_query_cost; extern double log_10[32]; extern ulonglong log_10_int[20]; extern ulonglong keybuff_size; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 90d4f9b9a99..e45a61b0c04 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -345,7 +345,6 @@ ulong expire_logs_days = 0; ulong rpl_recovery_rank=0; ulong my_bind_addr; /* the address we bind to */ volatile ulong cached_thread_count= 0; -double last_query_cost= -1; /* -1 denotes that no query was compiled yet */ double log_10[32]; /* 10 potences */ time_t start_time; @@ -5714,7 +5713,7 @@ struct show_var_st status_vars[]= { {"Key_reads", (char*) &dflt_key_cache_var.global_cache_read, SHOW_KEY_CACHE_LONG}, {"Key_write_requests", (char*) &dflt_key_cache_var.global_cache_w_requests, SHOW_KEY_CACHE_LONG}, {"Key_writes", (char*) &dflt_key_cache_var.global_cache_write, SHOW_KEY_CACHE_LONG}, - {"Last_query_cost", (char*) &last_query_cost, SHOW_DOUBLE}, + {"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE}, {"Max_used_connections", (char*) &max_used_connections, SHOW_LONG}, #ifdef HAVE_NDBCLUSTER_DB {"Ndb_", (char*) &ndb_status_variables, SHOW_VARS}, diff --git a/sql/sql_class.cc b/sql/sql_class.cc index a6a1f4d60ef..8a43d80ba52 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -444,6 +444,7 @@ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var) while (to != end) *(to++)+= *(from++); + /* it doesn't make sense to add last_query_cost values */ } diff --git a/sql/sql_class.h b/sql/sql_class.h index 4393da6df2a..f1f0cc2bde5 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -635,6 +635,8 @@ typedef struct system_status_var ulong filesort_range_count; ulong filesort_rows; ulong filesort_scan_count; + + double last_query_cost; } STATUS_VAR; /* diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 25bd99ee194..7ccb67be9d3 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3739,8 +3739,7 @@ choose_plan(JOIN *join, table_map join_tables) Don't update last_query_cost for 'show status' command */ if (join->thd->lex->orig_sql_command != SQLCOM_SHOW_STATUS) - last_query_cost= join->best_read; - + join->thd->status_var.last_query_cost= join->best_read; DBUG_VOID_RETURN; } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 9e3f82f9fd6..a5d12dffc4b 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1358,6 +1358,7 @@ static bool show_status_array(THD *thd, const char *wild, } case SHOW_DOUBLE: { + value= ((char *) status_var + (ulong) value); end= buff + sprintf(buff, "%f", *(double*) value); break; } From 60021dbe02f0ea191c54da007b99d8f56647fd2a Mon Sep 17 00:00:00 2001 From: "lars@mysql.com" <> Date: Thu, 19 May 2005 12:34:15 +0200 Subject: [PATCH 04/98] CSC#4944: Adding File_size to output of SHOW BINARY lOGS --- mysql-test/r/rpl_log.result | 12 +++++------ mysql-test/r/rpl_rotate_logs.result | 30 +++++++++++++------------- sql/sql_repl.cc | 33 ++++++++++++++++++++++++++--- 3 files changed, 51 insertions(+), 24 deletions(-) diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result index 2f8a54369c9..7813d4d779d 100644 --- a/mysql-test/r/rpl_log.result +++ b/mysql-test/r/rpl_log.result @@ -67,14 +67,14 @@ master-bin.000002 110 Query 1 110 use `test`; create table t1 (n int) master-bin.000002 168 Query 1 168 use `test`; insert into t1 values (1) master-bin.000002 228 Query 1 228 use `test`; drop table t1 show binary logs; -Log_name -master-bin.000001 -master-bin.000002 +Log_name File_size +master-bin.000001 0 +master-bin.000002 276 start slave; show binary logs; -Log_name -slave-bin.000001 -slave-bin.000002 +Log_name File_size +slave-bin.000001 0 +slave-bin.000002 170 show binlog events in 'slave-bin.000001' from 4; Log_name Pos Event_type Server_id Orig_log_pos Info slave-bin.000001 4 Start 2 4 Server ver: VERSION, Binlog ver: 3 diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result index 62e5522fad9..66eef482a63 100644 --- a/mysql-test/r/rpl_rotate_logs.result +++ b/mysql-test/r/rpl_rotate_logs.result @@ -26,10 +26,10 @@ create table t2(m int not null auto_increment primary key); insert into t2 values (34),(67),(123); flush logs; show binary logs; -Log_name -master-bin.000001 -master-bin.000002 -master-bin.000003 +Log_name File_size +master-bin.000001 0 +master-bin.000002 0 +master-bin.000003 4 create table t3 select * from temp_table; select * from t3; a @@ -42,18 +42,18 @@ set global sql_slave_skip_counter=1; start slave; purge master logs to 'master-bin.000002'; show master logs; -Log_name -master-bin.000002 -master-bin.000003 +Log_name File_size +master-bin.000002 0 +master-bin.000003 229 purge binary logs to 'master-bin.000002'; show binary logs; -Log_name -master-bin.000002 -master-bin.000003 +Log_name File_size +master-bin.000002 0 +master-bin.000003 229 purge master logs before now(); show binary logs; -Log_name -master-bin.000003 +Log_name File_size +master-bin.000003 229 insert into t2 values (65); show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master @@ -73,9 +73,9 @@ count(*) 100 create table t4 select * from temp_table; show binary logs; -Log_name -master-bin.000003 -master-bin.000004 +Log_name File_size +master-bin.000003 0 +master-bin.000004 2886 show master status; File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000004 2886 diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index d02bb5ff0a3..24b78bc9a3d 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1337,6 +1337,11 @@ int show_binlog_info(THD* thd) int show_binlogs(THD* thd) { IO_CACHE *index_file; + LOG_INFO cur; + IO_CACHE log; + File file; + const char *errmsg= 0; + MY_STAT stat_area; char fname[FN_REFLEN]; List field_list; uint length; @@ -1351,20 +1356,42 @@ int show_binlogs(THD* thd) } field_list.push_back(new Item_empty_string("Log_name", 255)); + field_list.push_back(new Item_return_int("File_size", 20, + MYSQL_TYPE_LONGLONG)); if (protocol->send_fields(&field_list, 1)) DBUG_RETURN(1); mysql_bin_log.lock_index(); index_file=mysql_bin_log.get_index_file(); - + + mysql_bin_log.get_current_log(&cur); + int cur_dir_len = dirname_length(cur.log_file_name); + reinit_io_cache(index_file, READ_CACHE, (my_off_t) 0, 0, 0); /* The file ends with EOF or empty line */ while ((length=my_b_gets(index_file, fname, sizeof(fname))) > 1) { + fname[--length] = '\0'; /* remove the newline */ + protocol->prepare_for_resend(); int dir_len = dirname_length(fname); - /* The -1 is for removing newline from fname */ - protocol->store(fname + dir_len, length-1-dir_len, &my_charset_bin); + protocol->store(fname + dir_len, length-dir_len, &my_charset_bin); + if(!(strncmp(fname+dir_len, cur.log_file_name+cur_dir_len, length-dir_len))) + { + /* this is the active log, use the active position */ + protocol->store((ulonglong) cur.pos); + } else { + /* this is an old log, open it and find the size */ + if ((file=open_binlog(&log, fname+dir_len, &errmsg)) >= 0) + { + protocol->store((ulonglong) my_b_filelength(&log)); + end_io_cache(&log); + my_close(file, MYF(0)); + } else { + /* the file wasn't openable, but 0 is an invalid value anyway */ + protocol->store((ulonglong) 0); + } + } if (protocol->write()) goto err; } From 6182241268c5c53b1bcef47dc4cfd168a45f7b1e Mon Sep 17 00:00:00 2001 From: "brian@zim.(none)" <> Date: Fri, 20 May 2005 06:56:02 -0700 Subject: [PATCH 05/98] Additions for --add-drop-database --- client/client_priv.h | 2 +- client/mysqldump.c | 19 ++++++++++++++---- mysql-test/r/mysqldump.result | 38 +++++++++++++++++++++++++++++++++++ mysql-test/t/mysqldump.test | 9 +++++++++ 4 files changed, 63 insertions(+), 5 deletions(-) diff --git a/client/client_priv.h b/client/client_priv.h index 45806349d7d..5085c03e84f 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -49,5 +49,5 @@ enum options_client #ifdef HAVE_NDBCLUSTER_DB ,OPT_NDBCLUSTER,OPT_NDB_CONNECTSTRING #endif - ,OPT_IGNORE_TABLE,OPT_INSERT_IGNORE + ,OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_DROP_DATABASE }; diff --git a/client/mysqldump.c b/client/mysqldump.c index 493ef57a73b..7b18b1d92da 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -85,7 +85,7 @@ static my_bool verbose=0,tFlag=0,dFlag=0,quick= 1, extended_insert= 1, opt_delete_master_logs=0, tty_password=0, opt_single_transaction=0, opt_comments= 0, opt_compact= 0, opt_hex_blob=0, opt_order_by_primary=0, opt_ignore=0, - opt_complete_insert= 0; + opt_complete_insert= 0, opt_drop_database= 0; static ulong opt_max_allowed_packet, opt_net_buffer_length; static MYSQL mysql_connection,*sock=0; static my_bool insert_pat_inited=0; @@ -159,6 +159,9 @@ static struct my_option my_long_options[] = "Dump all the databases. This will be same as --databases with all databases selected.", (gptr*) &opt_alldbs, (gptr*) &opt_alldbs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"add-drop-database", OPT_DROP_DATABASE, "Add a 'DROP DATABASE' before each create.", + (gptr*) &opt_drop_database, (gptr*) &opt_drop_database, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, + 0}, {"add-drop-table", OPT_DROP, "Add a 'drop table' before each create.", (gptr*) &opt_drop, (gptr*) &opt_drop, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, @@ -1119,9 +1122,9 @@ static uint getTableStructure(char *table, char* db) else dynstr_set(&insert_pat, ""); - insert_option= (opt_delayed && opt_ignore) ? " DELAYED IGNORE " : - opt_delayed ? " DELAYED " : - opt_ignore ? " IGNORE " : ""; + insert_option= ((opt_delayed && opt_ignore) ? " DELAYED IGNORE " : + opt_delayed ? " DELAYED " : + opt_ignore ? " IGNORE " : ""); if (verbose) fprintf(stderr, "-- Retrieving table structure for table %s...\n", table); @@ -2043,12 +2046,20 @@ static int init_dumping(char *database) if (mysql_query(sock, qbuf) || !(dbinfo = mysql_store_result(sock))) { /* Old server version, dump generic CREATE DATABASE */ + if (opt_drop_database) + fprintf(md_result_file, + "\n/*!40000 DROP DATABASE IF EXISTS %s;*/\n", + qdatabase); fprintf(md_result_file, "\nCREATE DATABASE /*!32312 IF NOT EXISTS*/ %s;\n", qdatabase); } else { + if (opt_drop_database) + fprintf(md_result_file, + "\n/*!40000 DROP DATABASE IF EXISTS %s*/;\n", + qdatabase); row = mysql_fetch_row(dbinfo); if (row[1]) { diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 493c6d6404a..845b0d1da45 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -1311,3 +1311,41 @@ UNLOCK TABLES; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; drop table t1; +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1),(2),(3); + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +/*!40000 DROP DATABASE IF EXISTS `test`*/; + +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */; + +USE `test`; +DROP TABLE IF EXISTS `t1`; +CREATE TABLE `t1` ( + `a` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + + +/*!40000 ALTER TABLE `t1` DISABLE KEYS */; +LOCK TABLES `t1` WRITE; +INSERT INTO `t1` VALUES (1),(2),(3); +UNLOCK TABLES; +/*!40000 ALTER TABLE `t1` ENABLE KEYS */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +DROP TABLE t1; diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 2681e690ff5..9f3b412b814 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -534,3 +534,12 @@ create table t1 ( insert into t1 (F_8d3bba7425e7c98c50f52ca1b52d3735) values (1); --exec $MYSQL_DUMP --skip-comments -c test drop table t1; + +# +# Test for --add-drop-database +# + +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (1),(2),(3); +--exec $MYSQL_DUMP --add-drop-database --skip-comments --databases test +DROP TABLE t1; From a6a589ef76b5042b5567ac45f58c6fa798986247 Mon Sep 17 00:00:00 2001 From: "acurtis@xiphis.org" <> Date: Tue, 24 May 2005 11:44:34 +0100 Subject: [PATCH 06/98] Bug#7241 - Invalid response when DELETE .. USING and LOCK TABLES used. Only acquire necessary write lock for multi-delete --- mysql-test/r/lock.result | 10 ++++++++++ mysql-test/t/lock.test | 14 ++++++++++++++ sql/sql_parse.cc | 6 ++++++ 3 files changed, 30 insertions(+) diff --git a/mysql-test/r/lock.result b/mysql-test/r/lock.result index 429bc5ed352..54162a36d83 100644 --- a/mysql-test/r/lock.result +++ b/mysql-test/r/lock.result @@ -47,3 +47,13 @@ unlock tables; lock tables t1 write, t1 as t1_alias read; insert into t1 select index1,nr from t1 as t1_alias; drop table t1,t2; +create table t1 ( a int(11) not null auto_increment, primary key(a)); +create table t2 ( a int(11) not null auto_increment, primary key(a)); +lock tables t1 write, t2 read; +delete from t1 using t1,t2 where t1.a=t2.a; +delete t1 from t1,t2 where t1.a=t2.a; +delete from t2 using t1,t2 where t1.a=t2.a; +ERROR HY000: Table 't2' was locked with a READ lock and can't be updated +delete t2 from t1,t2 where t1.a=t2.a; +ERROR HY000: Table 't2' was locked with a READ lock and can't be updated +drop table t1,t2; diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test index 26fc4e32bda..261c01b405c 100644 --- a/mysql-test/t/lock.test +++ b/mysql-test/t/lock.test @@ -59,3 +59,17 @@ unlock tables; lock tables t1 write, t1 as t1_alias read; insert into t1 select index1,nr from t1 as t1_alias; drop table t1,t2; + +# +# Bug7241 - Invalid response when DELETE .. USING and LOCK TABLES used. +# +create table t1 ( a int(11) not null auto_increment, primary key(a)); +create table t2 ( a int(11) not null auto_increment, primary key(a)); +lock tables t1 write, t2 read; +delete from t1 using t1,t2 where t1.a=t2.a; +delete t1 from t1,t2 where t1.a=t2.a; +--error 1099 +delete from t2 using t1,t2 where t1.a=t2.a; +--error 1099 +delete t2 from t1,t2 where t1.a=t2.a; +drop table t1,t2; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c5b429ec8fc..2c1723be5d9 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4141,6 +4141,7 @@ void mysql_init_multi_delete(LEX *lex) lex->select_lex.select_limit= lex->unit.select_limit_cnt= HA_POS_ERROR; lex->select_lex.table_list.save_and_clear(&lex->auxilliary_table_list); + lex->lock_option= using_update_log ? TL_READ_NO_INSERT : TL_READ; } @@ -5437,6 +5438,11 @@ int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) } walk->lock_type= target_tbl->lock_type; target_tbl->table_list= walk; // Remember corresponding table + if (walk->table_list) + { + target_tbl->table_list= walk->table_list; + walk->table_list->lock_type= walk->lock_type; + } } DBUG_RETURN(0); } From f449519a47581b661f35ee4938a8e686314af835 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Tue, 24 May 2005 14:30:22 +0200 Subject: [PATCH 07/98] - Backport of the patch to fix BUG#10687 (Merge engine fails on Windows): applied required patches on top of the 4.1.12 release (will be published as 4.1.12a for Windows) --- myisammrg/myrg_open.c | 4 +++- mysys/my_getwd.c | 5 ++++- sql/ha_myisammrg.cc | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c index 0dc2f4f9768..f9cdc2bb205 100644 --- a/myisammrg/myrg_open.c +++ b/myisammrg/myrg_open.c @@ -67,7 +67,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) while ((length=my_b_gets(&file,buff,FN_REFLEN-1))) { if ((end=buff+length)[-1] == '\n') - end[-1]='\0'; + *--end='\0'; if (!buff[0]) continue; /* Skip empty lines */ if (buff[0] == '#') @@ -86,6 +86,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) sizeof(name_buff)-1-dir_length)); VOID(cleanup_dirname(buff,name_buff)); } + else + fn_format(buff, buff, "", "", 0); if (!(isam=mi_open(buff,mode,(handle_locking?HA_OPEN_WAIT_IF_LOCKED:0)))) goto err; if (!m_info) /* First file */ diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c index 89f949eca27..5663ceaa60e 100644 --- a/mysys/my_getwd.c +++ b/mysys/my_getwd.c @@ -208,7 +208,10 @@ int test_if_hard_path(register const char *dir_name) my_bool has_path(const char *name) { - return test(strchr(name, FN_LIBCHAR)) + return test(strchr(name, FN_LIBCHAR)) +#if FN_LIBCHAR != '/' + || test(strchr(name,'/')) +#endif #ifdef FN_DEVCHAR || test(strchr(name, FN_DEVCHAR)) #endif diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index 7a5d4fcf0a1..0b160d72aab 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -422,6 +422,7 @@ int ha_myisammrg::create(const char *name, register TABLE *form, } else table_name=(*tbl)->path; + DBUG_PRINT("info",("MyISAM table_name: '%s'", table_name)); *pos++= table_name; } *pos=0; From 72f9abbf76030ff9a7f6dd96696419e34302ea14 Mon Sep 17 00:00:00 2001 From: "acurtis@xiphis.org" <> Date: Tue, 24 May 2005 13:38:46 +0100 Subject: [PATCH 08/98] Add comments --- sql/sql_parse.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 2c1723be5d9..80c68dad247 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1992,6 +1992,10 @@ mysql_execute_command(THD *thd) #endif } #endif /* !HAVE_REPLICATION */ + + /* When subselects or time_zone info is used in a query + * we create a new TABLE_LIST containing all referenced tables + * and set local variable 'tables' to point to this list. */ if ((&lex->select_lex != lex->all_selects_list || lex->time_zone_tables_used) && lex->unit.create_total_list(thd, lex, &tables)) @@ -5438,6 +5442,9 @@ int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) } walk->lock_type= target_tbl->lock_type; target_tbl->table_list= walk; // Remember corresponding table + + /* in case of subselects, we need to set lock_type in + * corresponding table in list of all tables */ if (walk->table_list) { target_tbl->table_list= walk->table_list; From 236ca3626f394890ffb33af72d071f8147cd03ce Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Tue, 24 May 2005 14:46:28 +0200 Subject: [PATCH 09/98] - added the cp932 charset support to the Windows builds --- VC++Files/strings/strings.dsp | 4 ++++ include/config-win.h | 1 + 2 files changed, 5 insertions(+) diff --git a/VC++Files/strings/strings.dsp b/VC++Files/strings/strings.dsp index c8f3208e822..d1156702956 100644 --- a/VC++Files/strings/strings.dsp +++ b/VC++Files/strings/strings.dsp @@ -113,6 +113,10 @@ SOURCE=".\ctype-bin.c" # End Source File # Begin Source File +SOURCE=".\ctype-cp932.c" +# End Source File +# Begin Source File + SOURCE=".\ctype-czech.c" # End Source File # Begin Source File diff --git a/include/config-win.h b/include/config-win.h index b3865c1fda7..86704c4740b 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -393,6 +393,7 @@ inline double ulonglong2double(ulonglong value) /* #undef HAVE_CHARSET_cp850 */ /* #undef HAVE_CHARSET_cp852 */ /* #undef HAVE_CHARSET_cp866 */ +#define HAVE_CHARSET_cp932 1 /* #undef HAVE_CHARSET_dec8 */ #define HAVE_CHARSET_euckr 1 #define HAVE_CHARSET_gb2312 1 From 4a296d4f0016b32597624160d49860438c2862f9 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Tue, 24 May 2005 15:14:21 +0200 Subject: [PATCH 10/98] - bumped up version number string to 4.1.12a --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 52f368f0c2d..15e6e42138c 100644 --- a/configure.in +++ b/configure.in @@ -5,7 +5,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 4.1.12) +AM_INIT_AUTOMAKE(mysql, 4.1.12a) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 From 6726b9fd098b6031d3e7c17e5628839d301a1094 Mon Sep 17 00:00:00 2001 From: "reggie@mdk10.(none)" <> Date: Tue, 24 May 2005 09:01:06 -0500 Subject: [PATCH 11/98] removed unneeded reserved_win_names testcase --- mysql-test/r/reserved_win_names.require | 2 -- mysql-test/r/reserved_win_names.result | 7 ------- mysql-test/t/reserved_win_names.test | 12 ------------ 3 files changed, 21 deletions(-) delete mode 100644 mysql-test/r/reserved_win_names.require delete mode 100644 mysql-test/r/reserved_win_names.result delete mode 100644 mysql-test/t/reserved_win_names.test diff --git a/mysql-test/r/reserved_win_names.require b/mysql-test/r/reserved_win_names.require deleted file mode 100644 index 7f803aca482..00000000000 --- a/mysql-test/r/reserved_win_names.require +++ /dev/null @@ -1,2 +0,0 @@ -Variable_name Value -lower_case_table_names 1 diff --git a/mysql-test/r/reserved_win_names.result b/mysql-test/r/reserved_win_names.result deleted file mode 100644 index eaa0f71513f..00000000000 --- a/mysql-test/r/reserved_win_names.result +++ /dev/null @@ -1,7 +0,0 @@ -use COM1; -ERROR 42000: Unknown database 'com1' -use LPT1; -ERROR 42000: Unknown database 'lpt1' -use PRN; -ERROR 42000: Unknown database 'prn' - diff --git a/mysql-test/t/reserved_win_names.test b/mysql-test/t/reserved_win_names.test deleted file mode 100644 index d9b23935ddf..00000000000 --- a/mysql-test/t/reserved_win_names.test +++ /dev/null @@ -1,12 +0,0 @@ -# -# Test of reserved Windows names -# ---require r/reserved_win_names.require - ---error 1049 -use COM1; ---error 1049 -use LPT1; ---error 1049 -use PRN; - From 5254d52cb65f82d1f4864f346f5ab612dc6a4890 Mon Sep 17 00:00:00 2001 From: "jani@ua141d10.elisa.omakaista.fi" <> Date: Tue, 24 May 2005 17:50:17 +0300 Subject: [PATCH 12/98] Added a test case for Bug#8009. --- mysql-test/r/select.result | 6 ++++++ mysql-test/t/select.test | 9 +++++++++ sql/item.cc | 1 + 3 files changed, 16 insertions(+) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index c39d1a322e4..f828759672a 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2509,3 +2509,9 @@ AND FK_firma_id = 2; COUNT(*) 0 drop table t1; +CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); +INSERT INTO t1 VALUES (0x8000000000000000); +SELECT b FROM t1 WHERE b=0x8000000000000000; +b +9223372036854775808 +DROP TABLE t1; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 0634323cef7..3877e67de41 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2051,3 +2051,12 @@ SELECT COUNT(*) FROM t1 WHERE AND FK_firma_id = 2; drop table t1; + +# +# Test for Bug#8009, SELECT failed on bigint unsigned when using HEX +# + +CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); +INSERT INTO t1 VALUES (0x8000000000000000); +SELECT b FROM t1 WHERE b=0x8000000000000000; +DROP TABLE t1; diff --git a/sql/item.cc b/sql/item.cc index 59785813566..c43421117e5 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2107,6 +2107,7 @@ Item_varbinary::Item_varbinary(const char *str, uint str_length) *ptr=0; // Keep purify happy collation.set(&my_charset_bin, DERIVATION_COERCIBLE); fixed= 1; + unsigned_flag= 1; } longlong Item_varbinary::val_int() From bedc2e3d4c9f28eeff3965d974e55f8983d4abcc Mon Sep 17 00:00:00 2001 From: "kent@mysql.com" <> Date: Tue, 24 May 2005 18:51:53 +0200 Subject: [PATCH 13/98] ha_archive.cc: Use local seach path for "mysql_priv.h" mysqld.dsp: Added the ARCHIVE storage engine to max ha_archive.h: VC6, but not VC7, needs a cast of byte[] to char* to make the compile select the right conversion function in String --- VC++Files/sql/mysqld.dsp | 10 +++++++--- sql/examples/ha_archive.cc | 2 +- sql/examples/ha_archive.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/VC++Files/sql/mysqld.dsp b/VC++Files/sql/mysqld.dsp index a140b99080b..3642585b4d6 100644 --- a/VC++Files/sql/mysqld.dsp +++ b/VC++Files/sql/mysqld.dsp @@ -75,7 +75,7 @@ LINK32=xilink6.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../extra/yassl/include" /I "../zlib" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_BLACKHOLE_DB" /D "HAVE_FEDERATED_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../extra/yassl/include" /I "../zlib" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_ARCHIVE_DB" /D "HAVE_BLACKHOLE_DB" /D "HAVE_FEDERATED_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /FD /c # SUBTRACT CPP /Fr /YX # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" @@ -130,7 +130,7 @@ LINK32=xilink6.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /D "NDEBUG" /D "__NT__" /D "DBUG_OFF" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /FD /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../extra/yassl/include" /I "../zlib" /D "NDEBUG" /D "__NT__" /D "DBUG_OFF" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_BLACKHOLE_DB" /D "HAVE_FEDERATED_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-nt-max /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../extra/yassl/include" /I "../zlib" /D "NDEBUG" /D "__NT__" /D "DBUG_OFF" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_ARCHIVE_DB" /D "HAVE_BLACKHOLE_DB" /D "HAVE_FEDERATED_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-nt-max /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -159,7 +159,7 @@ LINK32=xilink6.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /D "NDEBUG" /D "DBUG_OFF" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /FD /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../extra/yassl/include" /I "../zlib" /D "NDEBUG" /D "DBUG_OFF" /D "USE_SYMDIR" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_BLACKHOLE_DB" /D "HAVE_FEDERATED_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-max /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../extra/yassl/include" /I "../zlib" /D "NDEBUG" /D "DBUG_OFF" /D "USE_SYMDIR" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "HAVE_ARCHIVE_DB" /D "HAVE_BLACKHOLE_DB" /D "HAVE_FEDERATED_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-max /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -452,6 +452,10 @@ SOURCE=.\gstream.cpp # End Source File # Begin Source File +SOURCE=.\examples\ha_archive.cpp +# End Source File +# Begin Source File + SOURCE=.\ha_blackhole.cpp # End Source File # Begin Source File diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index 231031c9834..f28ba79a00e 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -18,7 +18,7 @@ #pragma implementation // gcc: Class implementation #endif -#include +#include "../mysql_priv.h" #ifdef HAVE_ARCHIVE_DB #include "ha_archive.h" diff --git a/sql/examples/ha_archive.h b/sql/examples/ha_archive.h index c68462be1ab..2f310d8c69b 100644 --- a/sql/examples/ha_archive.h +++ b/sql/examples/ha_archive.h @@ -61,7 +61,7 @@ public: ha_archive(TABLE *table): handler(table), delayed_insert(0), bulk_insert(0) { /* Set our original buffer from pre-allocated memory */ - buffer.set(byte_buffer, IO_SIZE, system_charset_info); + buffer.set((char *)byte_buffer, IO_SIZE, system_charset_info); /* The size of the offset value we will use for position() */ ref_length = sizeof(z_off_t); From bd7775866c9ba18b57033dc910dd87cce6eff7fb Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Tue, 24 May 2005 11:02:39 -0700 Subject: [PATCH 14/98] Fix timeouts with SSL on Windows, and also sync the fastsend implementation with normal socket behavior. (Bug #8572) --- vio/viossl.c | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/vio/viossl.c b/vio/viossl.c index 773d444063b..043d23f0238 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -128,26 +128,32 @@ int vio_ssl_write(Vio * vio, const gptr buf, int size) int vio_ssl_fastsend(Vio * vio __attribute__((unused))) { - int r= 0; + int r=0; DBUG_ENTER("vio_ssl_fastsend"); -#ifdef IPTOS_THROUGHPUT +#if defined(IPTOS_THROUGHPUT) && !defined(__EMX__) { -#ifndef __EMX__ - int tos = IPTOS_THROUGHPUT; - if (!setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos))) -#endif /* !__EMX__ */ - { - int nodelay = 1; - if (setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void *) &nodelay, - sizeof(nodelay))) { - DBUG_PRINT("warning", - ("Couldn't set socket option for fast send")); - r= -1; - } - } + int tos= IPTOS_THROUGHPUT; + r= setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos)); + } +#endif /* IPTOS_THROUGHPUT && !__EMX__ */ + if (!r) + { +#ifdef __WIN__ + BOOL nodelay= 1; + r= setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (const char*) &nodelay, + sizeof(nodelay)); +#else + int nodelay= 1; + r= setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void*) &nodelay, + sizeof(nodelay)); +#endif /* __WIN__ */ + } + if (r) + { + DBUG_PRINT("warning", ("Couldn't set socket option for fast send")); + r= -1; } -#endif /* IPTOS_THROUGHPUT */ DBUG_PRINT("exit", ("%d", r)); DBUG_RETURN(r); } @@ -424,6 +430,11 @@ void vio_ssl_timeout(Vio *vio __attribute__((unused)), uint which __attribute__((unused)), uint timeout __attribute__((unused))) { - /* Not yet implemented (non critical) */ +#ifdef __WIN__ + ulong wait_timeout= (ulong) timeout * 1000; + (void) setsockopt(vio->sd, SOL_SOCKET, + which ? SO_SNDTIMEO : SO_RCVTIMEO, (char*) &wait_timeout, + sizeof(wait_timeout)); +#endif /* __WIN__ */ } #endif /* HAVE_OPENSSL */ From 2fde78052ba207dd89b03e1bfbafda88caa7707b Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Tue, 24 May 2005 11:11:40 -0700 Subject: [PATCH 15/98] Fix error reporting for 'OPTIMIZE TABLE' on InnoDB tables. (Bug #8135) --- sql/sql_table.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 67aade519f5..70b20c21cfb 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2052,6 +2052,28 @@ send_result_message: ((result_code= table->table->file->analyze(thd, check_opt)) > 0)) result_code= 0; // analyze went ok } + if (result_code) // either mysql_recreate_table or analyze failed + { + const char *err_msg; + if ((err_msg= thd->net.last_error)) + { + if (!thd->vio_ok()) + { + sql_print_error(err_msg); + } + else + { + /* Hijack the row already in-progress. */ + protocol->store("error", 5, system_charset_info); + protocol->store(err_msg, system_charset_info); + (void)protocol->write(); + /* Start off another row for HA_ADMIN_FAILED */ + protocol->prepare_for_resend(); + protocol->store(table_name, system_charset_info); + protocol->store(operator_name, system_charset_info); + } + } + } result_code= result_code ? HA_ADMIN_FAILED : HA_ADMIN_OK; table->next= save_next; goto send_result_message; From 007a20591892beb3734ed4d29fdfe28b750f435a Mon Sep 17 00:00:00 2001 From: "dlenev@brandersnatch.localdomain" <> Date: Tue, 24 May 2005 22:19:33 +0400 Subject: [PATCH 16/98] Fix for bugs: #5860 "Multi-table UPDATE does not activate update triggers" #6812 "Triggers are not activated for INSERT ... SELECT" #8755 "Trigger is not activated by LOAD DATA". This patch also implements proper handling of triggers for special forms of insert like REPLACE or INSERT ... ON DUPLICATE KEY UPDATE. Also now we don't call after trigger in case when we have failed to inserted/update or delete row. Trigger failure should stop statement execution. I have not properly tested handling of errors which happen inside of triggers in this patch, since it is simplier to do this once we will be able to access tables from triggers. --- mysql-test/r/trigger.result | 109 ++++++++++++++++++++++++ mysql-test/t/trigger.test | 118 ++++++++++++++++++++++++++ sql/item.cc | 43 +++++----- sql/item.h | 19 +++-- sql/mysql_priv.h | 12 ++- sql/sql_base.cc | 72 +++++++++++++++- sql/sql_delete.cc | 45 ++++++++-- sql/sql_insert.cc | 163 +++++++++++++++++++++++++++--------- sql/sql_load.cc | 30 +++++-- sql/sql_trigger.cc | 45 +++++----- sql/sql_trigger.h | 39 +++++++-- sql/sql_update.cc | 66 +++++++++++---- 12 files changed, 634 insertions(+), 127 deletions(-) diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index cf0e0e8f564..1d2fb5989a5 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -140,6 +140,48 @@ drop trigger t1.trg1; drop trigger t1.trg2; drop trigger t1.trg3; drop table t1; +create table t1 (id int not null primary key, data int); +create trigger t1_bi before insert on t1 for each row +set @log:= concat(@log, "(BEFORE_INSERT: new=(id=", new.id, ", data=", new.data,"))"); +create trigger t1_ai after insert on t1 for each row +set @log:= concat(@log, "(AFTER_INSERT: new=(id=", new.id, ", data=", new.data,"))"); +create trigger t1_bu before update on t1 for each row +set @log:= concat(@log, "(BEFORE_UPDATE: old=(id=", old.id, ", data=", old.data, +") new=(id=", new.id, ", data=", new.data,"))"); +create trigger t1_au after update on t1 for each row +set @log:= concat(@log, "(AFTER_UPDATE: old=(id=", old.id, ", data=", old.data, +") new=(id=", new.id, ", data=", new.data,"))"); +create trigger t1_bd before delete on t1 for each row +set @log:= concat(@log, "(BEFORE_DELETE: old=(id=", old.id, ", data=", old.data,"))"); +create trigger t1_ad after delete on t1 for each row +set @log:= concat(@log, "(AFTER_DELETE: old=(id=", old.id, ", data=", old.data,"))"); +set @log:= ""; +insert into t1 values (1, 1); +select @log; +@log +(BEFORE_INSERT: new=(id=1, data=1))(AFTER_INSERT: new=(id=1, data=1)) +set @log:= ""; +insert ignore t1 values (1, 2); +select @log; +@log +(BEFORE_INSERT: new=(id=1, data=2)) +set @log:= ""; +replace t1 values (1, 3), (2, 2); +select @log; +@log +(BEFORE_INSERT: new=(id=1, data=3))(BEFORE_UPDATE: old=(id=1, data=1) new=(id=1, data=3))(AFTER_UPDATE: old=(id=1, data=1) new=(id=1, data=3))(BEFORE_INSERT: new=(id=2, data=2))(AFTER_INSERT: new=(id=2, data=2)) +alter table t1 add ts timestamp default now(); +set @log:= ""; +replace t1 (id, data) values (1, 4); +select @log; +@log +(BEFORE_INSERT: new=(id=1, data=4))(BEFORE_DELETE: old=(id=1, data=3))(AFTER_DELETE: old=(id=1, data=3))(AFTER_INSERT: new=(id=1, data=4)) +set @log:= ""; +insert into t1 (id, data) values (1, 5), (3, 3) on duplicate key update data= data + 2; +select @log; +@log +(BEFORE_INSERT: new=(id=1, data=5))(BEFORE_UPDATE: old=(id=1, data=4) new=(id=1, data=6))(AFTER_UPDATE: old=(id=1, data=4) new=(id=1, data=6))(BEFORE_INSERT: new=(id=3, data=3))(AFTER_INSERT: new=(id=3, data=3)) +drop table t1; create table t1 (i int); create trigger trg before insert on t1 for each row set @a:= old.i; ERROR HY000: There is no OLD row in on INSERT trigger @@ -206,3 +248,70 @@ create table t1 (i int); create trigger trg1 before insert on t1 for each row set @a:= 1; drop database mysqltest; use test; +create table t1 (i int, j int default 10, k int not null, key (k)); +create table t2 (i int); +insert into t1 (i, k) values (1, 1); +insert into t2 values (1); +create trigger trg1 before update on t1 for each row set @a:= @a + new.j - old.j; +create trigger trg2 after update on t1 for each row set @b:= "Fired"; +set @a:= 0, @b:= ""; +update t1, t2 set j = j + 10 where t1.i = t2.i; +select @a, @b; +@a @b +10 Fired +insert into t1 values (2, 13, 2); +insert into t2 values (2); +set @a:= 0, @b:= ""; +update t1, t2 set j = j + 15 where t1.i = t2.i and t1.k >= 2; +select @a, @b; +@a @b +15 Fired +create trigger trg3 before delete on t1 for each row set @c:= @c + old.j; +create trigger trg4 before delete on t2 for each row set @d:= @d + old.i; +create trigger trg5 after delete on t1 for each row set @e:= "After delete t1 fired"; +create trigger trg6 after delete on t2 for each row set @f:= "After delete t2 fired"; +set @c:= 0, @d:= 0, @e:= "", @f:= ""; +delete t1, t2 from t1, t2 where t1.i = t2.i; +select @c, @d, @e, @f; +@c @d @e @f +48 3 After delete t1 fired After delete t2 fired +drop table t1, t2; +create table t1 (i int, j int default 10)| +create table t2 (i int)| +insert into t2 values (1), (2)| +create trigger trg1 before insert on t1 for each row +begin +if new.i = 1 then +set new.j := 1; +end if; +end| +create trigger trg2 after insert on t1 for each row set @a:= 1| +set @a:= 0| +insert into t1 (i) select * from t2| +select * from t1| +i j +1 1 +2 10 +select @a| +@a +1 +drop table t1, t2| +create table t1 (i int, j int, k int); +create trigger trg1 before insert on t1 for each row set new.k = new.i; +create trigger trg2 after insert on t1 for each row set @b:= "Fired"; +set @b:=""; +load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, i); +select *, @b from t1; +i j k @b +10 NULL 10 Fired +15 NULL 15 Fired +set @b:=""; +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, j); +select *, @b from t1; +i j k @b +10 NULL 10 Fired +15 NULL 15 Fired +1 2 1 Fired +3 4 3 Fired +5 6 5 Fired +drop table t1; diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 53144cf3591..79f65bba678 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -150,6 +150,55 @@ drop trigger t1.trg3; drop table t1; +# Let us test how triggers work for special forms of INSERT such as +# REPLACE and INSERT ... ON DUPLICATE KEY UPDATE +create table t1 (id int not null primary key, data int); +create trigger t1_bi before insert on t1 for each row + set @log:= concat(@log, "(BEFORE_INSERT: new=(id=", new.id, ", data=", new.data,"))"); +create trigger t1_ai after insert on t1 for each row + set @log:= concat(@log, "(AFTER_INSERT: new=(id=", new.id, ", data=", new.data,"))"); +create trigger t1_bu before update on t1 for each row + set @log:= concat(@log, "(BEFORE_UPDATE: old=(id=", old.id, ", data=", old.data, + ") new=(id=", new.id, ", data=", new.data,"))"); +create trigger t1_au after update on t1 for each row + set @log:= concat(@log, "(AFTER_UPDATE: old=(id=", old.id, ", data=", old.data, + ") new=(id=", new.id, ", data=", new.data,"))"); +create trigger t1_bd before delete on t1 for each row + set @log:= concat(@log, "(BEFORE_DELETE: old=(id=", old.id, ", data=", old.data,"))"); +create trigger t1_ad after delete on t1 for each row + set @log:= concat(@log, "(AFTER_DELETE: old=(id=", old.id, ", data=", old.data,"))"); +# Simple INSERT - both triggers should be called +set @log:= ""; +insert into t1 values (1, 1); +select @log; +# INSERT IGNORE for already existing key - only before trigger should fire +set @log:= ""; +insert ignore t1 values (1, 2); +select @log; +# REPLACE: before insert trigger should be called for both records, +# but then for first one update will be executed (and both update +# triggers should fire). For second after insert trigger will be +# called as for usual insert +set @log:= ""; +replace t1 values (1, 3), (2, 2); +select @log; +# Now let us change table in such way that REPLACE on won't be executed +# using update. +alter table t1 add ts timestamp default now(); +set @log:= ""; +# This REPLACE should be executed via DELETE and INSERT so proper +# triggers should be invoked. +replace t1 (id, data) values (1, 4); +select @log; +# Finally let us test INSERT ... ON DUPLICATE KEY UPDATE ... +set @log:= ""; +insert into t1 (id, data) values (1, 5), (3, 3) on duplicate key update data= data + 2; +select @log; + +# This also drops associated triggers +drop table t1; + + # # Test of wrong column specifiers in triggers # @@ -249,3 +298,72 @@ create trigger trg1 before insert on t1 for each row set @a:= 1; # This should succeed drop database mysqltest; use test; + +# Test for bug #5860 "Multi-table UPDATE does not activate update triggers" +# We will also test how delete triggers wor for multi-table DELETE. +create table t1 (i int, j int default 10, k int not null, key (k)); +create table t2 (i int); +insert into t1 (i, k) values (1, 1); +insert into t2 values (1); +create trigger trg1 before update on t1 for each row set @a:= @a + new.j - old.j; +create trigger trg2 after update on t1 for each row set @b:= "Fired"; +set @a:= 0, @b:= ""; +# Check that trigger works in case of update on the fly +update t1, t2 set j = j + 10 where t1.i = t2.i; +select @a, @b; +insert into t1 values (2, 13, 2); +insert into t2 values (2); +set @a:= 0, @b:= ""; +# And now let us check that triggers work in case of multi-update which +# is done through temporary tables... +update t1, t2 set j = j + 15 where t1.i = t2.i and t1.k >= 2; +select @a, @b; +# Let us test delete triggers for multi-delete now. +# We create triggers for both tables because we want test how they +# work in both on-the-fly and via-temp-tables cases. +create trigger trg3 before delete on t1 for each row set @c:= @c + old.j; +create trigger trg4 before delete on t2 for each row set @d:= @d + old.i; +create trigger trg5 after delete on t1 for each row set @e:= "After delete t1 fired"; +create trigger trg6 after delete on t2 for each row set @f:= "After delete t2 fired"; +set @c:= 0, @d:= 0, @e:= "", @f:= ""; +delete t1, t2 from t1, t2 where t1.i = t2.i; +select @c, @d, @e, @f; +# This also will drop triggers +drop table t1, t2; + +# Test for bug #6812 "Triggers are not activated for INSERT ... SELECT". +# (We also check the fact that trigger modifies some field does not affect +# value of next record inserted). +delimiter |; +create table t1 (i int, j int default 10)| +create table t2 (i int)| +insert into t2 values (1), (2)| +create trigger trg1 before insert on t1 for each row +begin + if new.i = 1 then + set new.j := 1; + end if; +end| +create trigger trg2 after insert on t1 for each row set @a:= 1| +set @a:= 0| +insert into t1 (i) select * from t2| +select * from t1| +select @a| +# This also will drop triggers +drop table t1, t2| +delimiter ;| + +# Test for bug #8755 "Trigger is not activated by LOAD DATA" +create table t1 (i int, j int, k int); +create trigger trg1 before insert on t1 for each row set new.k = new.i; +create trigger trg2 after insert on t1 for each row set @b:= "Fired"; +set @b:=""; +# Test triggers with file with separators +load data infile '../../std_data/rpl_loaddata.dat' into table t1 (@a, i); +select *, @b from t1; +set @b:=""; +# Test triggers with fixed size row file +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, j); +select *, @b from t1; +# This also will drop triggers +drop table t1; diff --git a/sql/item.cc b/sql/item.cc index 30c134ebdd5..7f241955ec4 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4546,40 +4546,40 @@ void Item_insert_value::print(String *str) /* - Bind item representing field of row being changed in trigger - to appropriate Field object. + Find index of Field object which will be appropriate for item + representing field of row being changed in trigger. SYNOPSIS setup_field() thd - current thread context table - table of trigger (and where we looking for fields) - event - type of trigger event NOTE This function does almost the same as fix_fields() for Item_field - but is invoked during trigger definition parsing and takes TABLE - object as its argument. If proper field was not found in table - error will be reported at fix_fields() time. + but is invoked right after trigger definition parsing. Since at + this stage we can't say exactly what Field object (corresponding + to TABLE::record[0] or TABLE::record[1]) should be bound to this + Item, we only find out index of the Field and then select concrete + Field object in fix_fields() (by that time Table_trigger_list::old_field/ + new_field should point to proper array of Fields). + It also binds Item_trigger_field to Table_triggers_list object for + table of trigger which uses this item. */ -void Item_trigger_field::setup_field(THD *thd, TABLE *table, - enum trg_event_type event) + +void Item_trigger_field::setup_field(THD *thd, TABLE *table) { - uint field_idx= (uint)-1; bool save_set_query_id= thd->set_query_id; /* TODO: Think more about consequences of this step. */ thd->set_query_id= 0; - - if (find_field_in_real_table(thd, table, field_name, - strlen(field_name), 0, 0, - &field_idx)) - { - field= (row_version == OLD_ROW && event == TRG_EVENT_UPDATE) ? - table->triggers->old_field[field_idx] : - table->field[field_idx]; - } - + /* + Try to find field by its name and if it will be found + set field_idx properly. + */ + (void)find_field_in_real_table(thd, table, field_name, strlen(field_name), + 0, 0, &field_idx); thd->set_query_id= save_set_query_id; + triggers= table->triggers; } @@ -4604,9 +4604,10 @@ bool Item_trigger_field::fix_fields(THD *thd, */ DBUG_ASSERT(fixed == 0); - if (field) + if (field_idx != (uint)-1) { - // QQ: May be this should be moved to setup_field? + field= (row_version == OLD_ROW) ? triggers->old_field[field_idx] : + triggers->new_field[field_idx]; set_field(field); fixed= 1; return 0; diff --git a/sql/item.h b/sql/item.h index 0e15e539067..7b2344f12d8 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1601,13 +1601,18 @@ enum trg_event_type TRG_EVENT_INSERT= 0 , TRG_EVENT_UPDATE= 1, TRG_EVENT_DELETE= 2 }; +class Table_triggers_list; + /* Represents NEW/OLD version of field of row which is changed/read in trigger. - Note: For this item actual binding to Field object happens not during - fix_fields() (like for Item_field) but during parsing of trigger - definition, when table is opened, with special setup_field() call. + Note: For this item main part of actual binding to Field object happens + not during fix_fields() call (like for Item_field) but right after + parsing of trigger definition, when table is opened, with special + setup_field() call. On fix_fields() stage we simply choose one of + two Field instances representing either OLD or NEW version of this + field. */ class Item_trigger_field : public Item_field { @@ -1617,13 +1622,17 @@ public: row_version_type row_version; /* Next in list of all Item_trigger_field's in trigger */ Item_trigger_field *next_trg_field; + /* Index of the field in the TABLE::field array */ + uint field_idx; + /* Pointer to Table_trigger_list object for table of this trigger */ + Table_triggers_list *triggers; Item_trigger_field(row_version_type row_ver_par, const char *field_name_par): Item_field((const char *)NULL, (const char *)NULL, field_name_par), - row_version(row_ver_par) + row_version(row_ver_par), field_idx((uint)-1) {} - void setup_field(THD *thd, TABLE *table, enum trg_event_type event); + void setup_field(THD *thd, TABLE *table); enum Type type() const { return TRIGGER_FIELD_ITEM; } bool eq(const Item *item, bool binary_cmp) const; bool fix_fields(THD *, struct st_table_list *, Item **); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 25490b04ab3..82dceb87ed4 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -924,10 +924,18 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table, bool return_if_owned_by_thd); bool close_cached_tables(THD *thd, bool wait_for_refresh, TABLE_LIST *tables); void copy_field_from_tmp_record(Field *field,int offset); -bool fill_record(THD *thd, List &fields, List &values, - bool ignore_errors); bool fill_record(THD *thd, Field **field, List &values, bool ignore_errors); +bool fill_record_n_invoke_before_triggers(THD *thd, List &fields, + List &values, + bool ignore_errors, + Table_triggers_list *triggers, + enum trg_event_type event); +bool fill_record_n_invoke_before_triggers(THD *thd, Field **field, + List &values, + bool ignore_errors, + Table_triggers_list *triggers, + enum trg_event_type event); OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild); inline TABLE_LIST *find_table_in_global_list(TABLE_LIST *table, diff --git a/sql/sql_base.cc b/sql/sql_base.cc index bda5700b273..d431bb7ddca 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -3813,7 +3813,7 @@ err_no_arena: TRUE error occured */ -bool +static bool fill_record(THD * thd, List &fields, List &values, bool ignore_errors) { @@ -3839,6 +3839,41 @@ fill_record(THD * thd, List &fields, List &values, } +/* + Fill fields in list with values from the list of items and invoke + before triggers. + + SYNOPSIS + fill_record_n_invoke_before_triggers() + thd thread context + fields Item_fields list to be filled + values values to fill with + ignore_errors TRUE if we should ignore errors + triggers object holding list of triggers to be invoked + event event type for triggers to be invoked + + NOTE + This function assumes that fields which values will be set and triggers + to be invoked belong to the same table, and that TABLE::record[0] and + record[1] buffers correspond to new and old versions of row respectively. + + RETURN + FALSE OK + TRUE error occured +*/ + +bool +fill_record_n_invoke_before_triggers(THD *thd, List &fields, + List &values, bool ignore_errors, + Table_triggers_list *triggers, + enum trg_event_type event) +{ + return (fill_record(thd, fields, values, ignore_errors) || + triggers && triggers->process_triggers(thd, event, + TRG_ACTION_BEFORE, TRUE)); +} + + /* Fill field buffer with values from Field list @@ -3875,6 +3910,41 @@ fill_record(THD *thd, Field **ptr, List &values, bool ignore_errors) } +/* + Fill fields in array with values from the list of items and invoke + before triggers. + + SYNOPSIS + fill_record_n_invoke_before_triggers() + thd thread context + ptr NULL-ended array of fields to be filled + values values to fill with + ignore_errors TRUE if we should ignore errors + triggers object holding list of triggers to be invoked + event event type for triggers to be invoked + + NOTE + This function assumes that fields which values will be set and triggers + to be invoked belong to the same table, and that TABLE::record[0] and + record[1] buffers correspond to new and old versions of row respectively. + + RETURN + FALSE OK + TRUE error occured +*/ + +bool +fill_record_n_invoke_before_triggers(THD *thd, Field **ptr, + List &values, bool ignore_errors, + Table_triggers_list *triggers, + enum trg_event_type event) +{ + return (fill_record(thd, ptr, values, ignore_errors) || + triggers && triggers->process_triggers(thd, event, + TRG_ACTION_BEFORE, TRUE)); +} + + static void mysql_rm_tmp_tables(void) { uint i, idx; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index cded9e2a13e..19e9866597a 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -176,13 +176,24 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, if (!(select && select->skip_record())&& !thd->net.report_error ) { - if (table->triggers) - table->triggers->process_triggers(thd, TRG_EVENT_DELETE, - TRG_ACTION_BEFORE); + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_DELETE, + TRG_ACTION_BEFORE, FALSE)) + { + error= 1; + break; + } if (!(error=table->file->delete_row(table->record[0]))) { deleted++; + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_DELETE, + TRG_ACTION_AFTER, FALSE)) + { + error= 1; + break; + } if (!--limit && using_limit) { error= -1; @@ -203,10 +214,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, error= 1; break; } - - if (table->triggers) - table->triggers->process_triggers(thd, TRG_EVENT_DELETE, - TRG_ACTION_AFTER); } else table->file->unlock_row(); // Row failed selection, release lock on it @@ -509,9 +516,19 @@ bool multi_delete::send_data(List &values) if (secure_counter < 0) { /* If this is the table we are scanning */ + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_DELETE, + TRG_ACTION_BEFORE, FALSE)) + DBUG_RETURN(1); table->status|= STATUS_DELETED; if (!(error=table->file->delete_row(table->record[0]))) + { deleted++; + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_DELETE, + TRG_ACTION_AFTER, FALSE)) + DBUG_RETURN(1); + } else if (!table_being_deleted->next_local || table_being_deleted->table->file->has_transactions()) { @@ -614,12 +631,26 @@ int multi_delete::do_deletes(bool from_send_error) info.ignore_not_found_rows= 1; while (!(local_error=info.read_record(&info)) && !thd->killed) { + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_DELETE, + TRG_ACTION_BEFORE, FALSE)) + { + local_error= 1; + break; + } if ((local_error=table->file->delete_row(table->record[0]))) { table->file->print_error(local_error,MYF(0)); break; } deleted++; + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_DELETE, + TRG_ACTION_AFTER, FALSE)) + { + local_error= 1; + break; + } } end_read_record(&info); if (thd->killed && !local_error) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index adb33af05b9..ce90b4ad3e0 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -398,7 +398,9 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, if (fields.elements || !value_count) { restore_record(table,s->default_values); // Get empty record - if (fill_record(thd, fields, *values, 0)) + if (fill_record_n_invoke_before_triggers(thd, fields, *values, 0, + table->triggers, + TRG_EVENT_INSERT)) { if (values_list.elements != 1 && !thd->net.report_error) { @@ -419,8 +421,17 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, if (thd->used_tables) // Column used in values() restore_record(table,s->default_values); // Get empty record else - table->record[0][0]= table->s->default_values[0]; // Fix delete marker - if (fill_record(thd, table->field, *values, 0)) + { + /* + Fix delete marker. No need to restore rest of record since it will + be overwritten by fill_record() anyway (and fill_record() does not + use default values in this case). + */ + table->record[0][0]= table->s->default_values[0]; + } + if (fill_record_n_invoke_before_triggers(thd, table->field, *values, 0, + table->triggers, + TRG_EVENT_INSERT)) { if (values_list.elements != 1 && ! thd->net.report_error) { @@ -432,14 +443,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, } } - /* - FIXME: Actually we should do this before - check_that_all_fields_are_given_values Or even go into write_record ? - */ - if (table->triggers) - table->triggers->process_triggers(thd, TRG_EVENT_INSERT, - TRG_ACTION_BEFORE); - if ((res= table_list->view_check_option(thd, (values_list.elements == 1 ? 0 : @@ -473,9 +476,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, if (error) break; thd->row_count++; - - if (table->triggers) - table->triggers->process_triggers(thd, TRG_EVENT_INSERT, TRG_ACTION_AFTER); } /* @@ -802,15 +802,35 @@ static int last_uniq_key(TABLE *table,uint keynr) /* - Write a record to table with optional deleting of conflicting records + Write a record to table with optional deleting of conflicting records, + invoke proper triggers if needed. - Sets thd->no_trans_update if table which is updated didn't have transactions + SYNOPSIS + write_record() + thd - thread context + table - table to which record should be written + info - COPY_INFO structure describing handling of duplicates + and which is used for counting number of records inserted + and deleted. + + NOTE + Once this record will be written to table after insert trigger will + be invoked. If instead of inserting new record we will update old one + then both on update triggers will work instead. Similarly both on + delete triggers will be invoked if we will delete conflicting records. + + Sets thd->no_trans_update if table which is updated didn't have + transactions. + + RETURN VALUE + 0 - success + non-0 - error */ int write_record(THD *thd, TABLE *table,COPY_INFO *info) { - int error; + int error, trg_error= 0; char *key=0; DBUG_ENTER("write_record"); @@ -881,25 +901,33 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) restore_record(table,record[1]); DBUG_ASSERT(info->update_fields->elements == info->update_values->elements); - if (fill_record(thd, *info->update_fields, *info->update_values, 0)) - goto err; + if (fill_record_n_invoke_before_triggers(thd, *info->update_fields, + *info->update_values, 0, + table->triggers, + TRG_EVENT_UPDATE)) + goto before_trg_err; /* CHECK OPTION for VIEW ... ON DUPLICATE KEY UPDATE ... */ if (info->view && (res= info->view->view_check_option(current_thd, info->ignore)) == VIEW_CHECK_SKIP) - break; + goto ok_or_after_trg_err; if (res == VIEW_CHECK_ERROR) - goto err; + goto before_trg_err; if ((error=table->file->update_row(table->record[1],table->record[0]))) { if ((error == HA_ERR_FOUND_DUPP_KEY) && info->ignore) - break; + goto ok_or_after_trg_err; goto err; } info->updated++; - break; + + trg_error= (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, + TRG_ACTION_AFTER, TRUE)); + info->copied++; + goto ok_or_after_trg_err; } else /* DUP_REPLACE */ { @@ -916,20 +944,48 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) (table->timestamp_field_type == TIMESTAMP_NO_AUTO_SET || table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH)) { + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, + TRG_ACTION_BEFORE, TRUE)) + goto before_trg_err; if ((error=table->file->update_row(table->record[1], table->record[0]))) goto err; info->deleted++; - break; /* Update logfile and count */ + trg_error= (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, + TRG_ACTION_AFTER, + TRUE)); + /* Update logfile and count */ + info->copied++; + goto ok_or_after_trg_err; + } + else + { + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_DELETE, + TRG_ACTION_BEFORE, TRUE)) + goto before_trg_err; + if ((error=table->file->delete_row(table->record[1]))) + goto err; + info->deleted++; + if (!table->file->has_transactions()) + thd->no_trans_update= 1; + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_DELETE, + TRG_ACTION_AFTER, TRUE)) + { + trg_error= 1; + goto ok_or_after_trg_err; + } + /* Let us attempt do write_row() once more */ } - else if ((error=table->file->delete_row(table->record[1]))) - goto err; - info->deleted++; - if (!table->file->has_transactions()) - thd->no_trans_update= 1; } } info->copied++; + trg_error= (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_INSERT, + TRG_ACTION_AFTER, TRUE)); } else if ((error=table->file->write_row(table->record[0]))) { @@ -939,18 +995,27 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) table->file->restore_auto_increment(); } else + { info->copied++; + trg_error= (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_INSERT, + TRG_ACTION_AFTER, TRUE)); + } + +ok_or_after_trg_err: if (key) my_safe_afree(key,table->s->max_unique_length,MAX_KEY_LENGTH); if (!table->file->has_transactions()) thd->no_trans_update= 1; - DBUG_RETURN(0); + DBUG_RETURN(trg_error); err: - if (key) - my_afree(key); info->last_errno= error; table->file->print_error(error,MYF(0)); + +before_trg_err: + if (key) + my_safe_afree(key, table->s->max_unique_length, MAX_KEY_LENGTH); DBUG_RETURN(1); } @@ -2013,12 +2078,27 @@ bool select_insert::send_data(List &values) DBUG_RETURN(1); } } - if (!(error= write_record(thd, table,&info)) && table->next_number_field) + if (!(error= write_record(thd, table, &info))) { - /* Clear for next record */ - table->next_number_field->reset(); - if (! last_insert_id && thd->insert_id_used) - last_insert_id=thd->insert_id(); + if (table->triggers) + { + /* + If triggers exist then whey can modify some fields which were not + originally touched by INSERT ... SELECT, so we have to restore + their original values for the next row. + */ + restore_record(table, s->default_values); + } + if (table->next_number_field) + { + /* + Clear auto-increment field for the next record, if triggers are used + we will clear it twice, but this should be cheap. + */ + table->next_number_field->reset(); + if (!last_insert_id && thd->insert_id_used) + last_insert_id= thd->insert_id(); + } } DBUG_RETURN(error); } @@ -2027,9 +2107,11 @@ bool select_insert::send_data(List &values) void select_insert::store_values(List &values) { if (fields->elements) - fill_record(thd, *fields, values, 1); + fill_record_n_invoke_before_triggers(thd, *fields, values, 1, + table->triggers, TRG_EVENT_INSERT); else - fill_record(thd, table->field, values, 1); + fill_record_n_invoke_before_triggers(thd, table->field, values, 1, + table->triggers, TRG_EVENT_INSERT); } void select_insert::send_error(uint errcode,const char *err) @@ -2172,7 +2254,8 @@ select_create::prepare(List &values, SELECT_LEX_UNIT *u) void select_create::store_values(List &values) { - fill_record(thd, field, values, 1); + fill_record_n_invoke_before_triggers(thd, field, values, 1, + table->triggers, TRG_EVENT_INSERT); } diff --git a/sql/sql_load.cc b/sql/sql_load.cc index c827bbace3e..1545055f475 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -21,6 +21,8 @@ #include #include #include "sql_repl.h" +#include "sp_head.h" +#include "sql_trigger.h" class READ_INFO { File file; @@ -568,7 +570,11 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, ER(ER_WARN_TOO_MANY_RECORDS), thd->row_count); } - if (fill_record(thd, set_fields, set_values, ignore_check_option_errors)) + if (thd->killed || + fill_record_n_invoke_before_triggers(thd, set_fields, set_values, + ignore_check_option_errors, + table->triggers, + TRG_EVENT_INSERT)) DBUG_RETURN(1); switch (table_list->view_check_option(thd, @@ -580,7 +586,7 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, DBUG_RETURN(-1); } - if (thd->killed || write_record(thd,table,&info)) + if (write_record(thd, table, &info)) DBUG_RETURN(1); thd->no_trans_update= no_trans_update; @@ -592,8 +598,10 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, */ if (!id && thd->insert_id_used) id= thd->last_insert_id; - if (table->next_number_field) - table->next_number_field->reset(); // Clear for next record + /* + We don't need to reset auto-increment field since we are restoring + its default value at the beginning of each loop iteration. + */ if (read_info.next_line()) // Skip to next line break; if (read_info.line_cuted) @@ -725,7 +733,11 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, } } - if (fill_record(thd, set_fields, set_values, ignore_check_option_errors)) + if (thd->killed || + fill_record_n_invoke_before_triggers(thd, set_fields, set_values, + ignore_check_option_errors, + table->triggers, + TRG_EVENT_INSERT)) DBUG_RETURN(1); switch (table_list->view_check_option(thd, @@ -738,7 +750,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, } - if (thd->killed || write_record(thd, table, &info)) + if (write_record(thd, table, &info)) DBUG_RETURN(1); /* If auto_increment values are used, save the first one @@ -748,8 +760,10 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, */ if (!id && thd->insert_id_used) id= thd->last_insert_id; - if (table->next_number_field) - table->next_number_field->reset(); // Clear for next record + /* + We don't need to reset auto-increment field since we are restoring + its default value at the beginning of each loop iteration. + */ thd->no_trans_update= no_trans_update; if (read_info.next_line()) // Skip to next line break; diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 670c618bec5..95524a6dfbf 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -85,7 +85,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) DBUG_RETURN(TRUE); } - if (!(table->triggers= new (&table->mem_root) Table_triggers_list())) + if (!(table->triggers= new (&table->mem_root) Table_triggers_list(table))) DBUG_RETURN(TRUE); } @@ -190,17 +190,16 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables) to other tables from trigger we won't be able to catch changes in other tables... - To simplify code a bit we have to create Fields for accessing to old row - values if we have ON UPDATE trigger. + Since we don't plan to access to contents of the fields it does not + matter that we choose for both OLD and NEW values the same versions + of Field objects here. */ - if (!old_field && lex->trg_chistics.event == TRG_EVENT_UPDATE && - prepare_old_row_accessors(table)) - return 1; + old_field= new_field= table->field; for (trg_field= (Item_trigger_field *)(lex->trg_table_fields.first); trg_field; trg_field= trg_field->next_trg_field) { - trg_field->setup_field(thd, table, lex->trg_chistics.event); + trg_field->setup_field(thd, table); if (!trg_field->fixed && trg_field->fix_fields(thd, (TABLE_LIST *)0, (Item **)0)) return 1; @@ -318,34 +317,35 @@ Table_triggers_list::~Table_triggers_list() for (int j= 0; j < 2; j++) delete bodies[i][j]; - if (old_field) - for (Field **fld_ptr= old_field; *fld_ptr; fld_ptr++) + if (record1_field) + for (Field **fld_ptr= record1_field; *fld_ptr; fld_ptr++) delete *fld_ptr; } /* - Prepare array of Field objects which will represent OLD.* row values in - ON UPDATE trigger (by referencing to record[1] instead of record[0]). + Prepare array of Field objects referencing to TABLE::record[1] instead + of record[0] (they will represent OLD.* row values in ON UPDATE trigger + and in ON DELETE trigger which will be called during REPLACE execution). SYNOPSIS - prepare_old_row_accessors() + prepare_record1_accessors() table - pointer to TABLE object for which we are creating fields. RETURN VALUE False - success True - error */ -bool Table_triggers_list::prepare_old_row_accessors(TABLE *table) +bool Table_triggers_list::prepare_record1_accessors(TABLE *table) { Field **fld, **old_fld; - if (!(old_field= (Field **)alloc_root(&table->mem_root, - (table->s->fields + 1) * - sizeof(Field*)))) + if (!(record1_field= (Field **)alloc_root(&table->mem_root, + (table->s->fields + 1) * + sizeof(Field*)))) return 1; - for (fld= table->field, old_fld= old_field; *fld; fld++, old_fld++) + for (fld= table->field, old_fld= record1_field; *fld; fld++, old_fld++) { /* QQ: it is supposed that it is ok to use this function for field @@ -406,7 +406,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, parser->type()->length)) { Table_triggers_list *triggers= - new (&table->mem_root) Table_triggers_list(); + new (&table->mem_root) Table_triggers_list(table); if (!triggers) DBUG_RETURN(1); @@ -417,8 +417,11 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, table->triggers= triggers; - /* TODO: This could be avoided if there is no ON UPDATE trigger. */ - if (triggers->prepare_old_row_accessors(table)) + /* + TODO: This could be avoided if there is no triggers + for UPDATE and DELETE. + */ + if (triggers->prepare_record1_accessors(table)) DBUG_RETURN(1); List_iterator_fast it(triggers->definitions_list); @@ -478,7 +481,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, (Item_trigger_field *)(lex.trg_table_fields.first); trg_field; trg_field= trg_field->next_trg_field) - trg_field->setup_field(thd, table, lex.trg_chistics.event); + trg_field->setup_field(thd, table); lex_end(&lex); } diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h index 90c906fc72f..d61da8ff06b 100644 --- a/sql/sql_trigger.h +++ b/sql/sql_trigger.h @@ -8,10 +8,20 @@ class Table_triggers_list: public Sql_alloc /* Triggers as SPs grouped by event, action_time */ sp_head *bodies[3][2]; /* - Copy of TABLE::Field array with field pointers set to old version - of record, used for OLD values in trigger on UPDATE. + Copy of TABLE::Field array with field pointers set to TABLE::record[1] + buffer instead of TABLE::record[0] (used for OLD values in on UPDATE + trigger and DELETE trigger when it is called for REPLACE). */ + Field **record1_field; + /* + During execution of trigger new_field and old_field should point to the + array of fields representing new or old version of row correspondingly + (so it can point to TABLE::field or to Tale_triggers_list::record1_field) + */ + Field **new_field; Field **old_field; + /* TABLE instance for which this triggers list object was created */ + TABLE *table; /* Names of triggers. Should correspond to order of triggers on definitions_list, @@ -26,8 +36,8 @@ public: */ List definitions_list; - Table_triggers_list(): - old_field(0) + Table_triggers_list(TABLE *table_arg): + record1_field(0), table(table_arg) { bzero((char *)bodies, sizeof(bodies)); } @@ -36,7 +46,8 @@ public: bool create_trigger(THD *thd, TABLE_LIST *table); bool drop_trigger(THD *thd, TABLE_LIST *table); bool process_triggers(THD *thd, trg_event_type event, - trg_action_time_type time_type) + trg_action_time_type time_type, + bool old_row_is_record1) { int res= 0; @@ -48,6 +59,17 @@ public: thd->net.no_send_ok= TRUE; #endif + if (old_row_is_record1) + { + old_field= record1_field; + new_field= table->field; + } + else + { + new_field= record1_field; + old_field= table->field; + } + /* FIXME: We should juggle with security context here (because trigger should be invoked with creator rights). @@ -79,8 +101,13 @@ public: bodies[TRG_EVENT_DELETE][TRG_ACTION_AFTER]); } + bool has_before_update_triggers() + { + return test(bodies[TRG_EVENT_UPDATE][TRG_ACTION_BEFORE]); + } + friend class Item_trigger_field; private: - bool prepare_old_row_accessors(TABLE *table); + bool prepare_record1_accessors(TABLE *table); }; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 95268c41aed..291f829a4e3 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -398,14 +398,13 @@ int mysql_update(THD *thd, if (!(select && select->skip_record())) { store_record(table,record[1]); - if (fill_record(thd, fields, values, 0)) + if (fill_record_n_invoke_before_triggers(thd, fields, values, 0, + table->triggers, + TRG_EVENT_UPDATE)) break; /* purecov: inspected */ found++; - if (table->triggers) - table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, TRG_ACTION_BEFORE); - if (compare_record(table, query_id)) { if ((res= table_list->view_check_option(thd, ignore)) != @@ -425,6 +424,14 @@ int mysql_update(THD *thd, { updated++; thd->no_trans_update= !transactional_table; + + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, + TRG_ACTION_AFTER, TRUE)) + { + error= 1; + break; + } } else if (!ignore || error != HA_ERR_FOUND_DUPP_KEY) { @@ -435,9 +442,6 @@ int mysql_update(THD *thd, } } - if (table->triggers) - table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, TRG_ACTION_AFTER); - if (!--limit && using_limit) { error= -1; // Simulate end of file @@ -1073,8 +1077,8 @@ multi_update::initialize_tables(JOIN *join) NOTES We can update the first table in join on the fly if we know that - a row in this tabel will never be read twice. This is true under - the folloing conditions: + a row in this table will never be read twice. This is true under + the following conditions: - We are doing a table scan and the data is in a separate file (MyISAM) or if we don't update a clustered key. @@ -1082,6 +1086,10 @@ multi_update::initialize_tables(JOIN *join) - We are doing a range scan and we don't update the scan key or the primary key for a clustered table handler. + When checking for above cases we also should take into account that + BEFORE UPDATE trigger potentially may change value of any field in row + being updated. + WARNING This code is a bit dependent of how make_join_readinfo() works. @@ -1099,15 +1107,21 @@ static bool safe_update_on_fly(JOIN_TAB *join_tab, List *fields) case JT_EQ_REF: return TRUE; // At most one matching row case JT_REF: - return !check_if_key_used(table, join_tab->ref.key, *fields); + return !check_if_key_used(table, join_tab->ref.key, *fields) && + !(table->triggers && + table->triggers->has_before_update_triggers()); case JT_ALL: /* If range search on index */ if (join_tab->quick) - return !join_tab->quick->check_if_keys_used(fields); + return !join_tab->quick->check_if_keys_used(fields) && + !(table->triggers && + table->triggers->has_before_update_triggers()); /* If scanning in clustered key */ if ((table->file->table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX) && table->s->primary_key < MAX_KEY) - return !check_if_key_used(table, table->s->primary_key, *fields); + return !check_if_key_used(table, table->s->primary_key, *fields) && + !(table->triggers && + table->triggers->has_before_update_triggers()); return TRUE; default: break; // Avoid compler warning @@ -1170,8 +1184,10 @@ bool multi_update::send_data(List ¬_used_values) { table->status|= STATUS_UPDATED; store_record(table,record[1]); - if (fill_record(thd, *fields_for_table[offset], - *values_for_table[offset], 0)) + if (fill_record_n_invoke_before_triggers(thd, *fields_for_table[offset], + *values_for_table[offset], 0, + table->triggers, + TRG_EVENT_UPDATE)) DBUG_RETURN(1); found++; @@ -1207,8 +1223,15 @@ bool multi_update::send_data(List ¬_used_values) DBUG_RETURN(1); } } - else if (!table->file->has_transactions()) - thd->no_trans_update= 1; + else + { + if (!table->file->has_transactions()) + thd->no_trans_update= 1; + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, + TRG_ACTION_AFTER, TRUE)) + DBUG_RETURN(1); + } } } else @@ -1329,6 +1352,11 @@ int multi_update::do_updates(bool from_send_error) copy_field_ptr++) (*copy_field_ptr->do_copy)(copy_field_ptr); + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, + TRG_ACTION_BEFORE, TRUE)) + goto err2; + if (compare_record(table, thd->query_id)) { if ((local_error=table->file->update_row(table->record[1], @@ -1338,6 +1366,11 @@ int multi_update::do_updates(bool from_send_error) goto err; } updated++; + + if (table->triggers && + table->triggers->process_triggers(thd, TRG_EVENT_UPDATE, + TRG_ACTION_AFTER, TRUE)) + goto err2; } } @@ -1360,6 +1393,7 @@ err: table->file->print_error(local_error,MYF(0)); } +err2: (void) table->file->ha_rnd_end(); (void) tmp_table->file->ha_rnd_end(); From e2c8f63ed4288f6b195002138dd419abdc1636f2 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Tue, 24 May 2005 21:02:42 +0200 Subject: [PATCH 17/98] simplifying new/my_arg_new wrapping --- include/my_global.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/my_global.h b/include/my_global.h index f059d603976..d7cda085353 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -289,12 +289,14 @@ C_MODE_START int __cxa_pure_virtual() {\ #endif #if defined(__ia64__) #define new my_arg_new +#define need_to_restore_new 1 #endif C_MODE_START #include C_MODE_END -#if defined(__ia64__) +#ifdef need_to_restore_new /* probably safer than #ifdef new */ #undef new +#undef need_to_restore_new #endif #endif #include /* Recommended by debian */ From 1dabee5aad6d4942c57014c9d9b548a0bb060c1d Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com" <> Date: Wed, 25 May 2005 00:15:06 +0500 Subject: [PATCH 18/98] Upgrade yaSSL to 0.9.9. --- extra/yassl/include/factory.hpp | 2 +- extra/yassl/include/yassl_int.hpp | 2 +- extra/yassl/include/yassl_types.hpp | 10 - extra/yassl/src/buffer.cpp | 12 +- extra/yassl/src/cert_wrapper.cpp | 24 +-- extra/yassl/src/crypto_wrapper.cpp | 58 +++--- extra/yassl/src/handshake.cpp | 30 +-- extra/yassl/src/ssl.cpp | 4 +- extra/yassl/src/yassl_imp.cpp | 79 ++++--- extra/yassl/src/yassl_int.cpp | 127 +++++------ extra/yassl/taocrypt/include/aes.hpp | 5 +- extra/yassl/taocrypt/include/algebra.hpp | 126 ++--------- extra/yassl/taocrypt/include/block.hpp | 20 +- extra/yassl/taocrypt/include/des.hpp | 5 +- extra/yassl/taocrypt/include/error.hpp | 3 +- extra/yassl/taocrypt/include/hash.hpp | 2 +- extra/yassl/taocrypt/include/integer.hpp | 10 +- extra/yassl/taocrypt/include/misc.hpp | 11 - extra/yassl/taocrypt/include/modarith.hpp | 13 +- extra/yassl/taocrypt/include/modes.hpp | 55 +++-- extra/yassl/taocrypt/src/algebra.cpp | 99 ++++----- extra/yassl/taocrypt/src/asn.cpp | 20 +- extra/yassl/taocrypt/src/dh.cpp | 1 - extra/yassl/taocrypt/src/dsa.cpp | 2 - extra/yassl/taocrypt/src/integer.cpp | 243 +--------------------- extra/yassl/taocrypt/src/misc.cpp | 27 --- extra/yassl/taocrypt/src/random.cpp | 1 - extra/yassl/taocrypt/src/rsa.cpp | 7 - 28 files changed, 283 insertions(+), 715 deletions(-) diff --git a/extra/yassl/include/factory.hpp b/extra/yassl/include/factory.hpp index 96798466352..7f7aaf8bd7f 100644 --- a/extra/yassl/include/factory.hpp +++ b/extra/yassl/include/factory.hpp @@ -67,7 +67,7 @@ public: init(*this); } - // reservce place in vector before registering, used by init funcion + // reserve place in vector before registering, used by init funcion void Reserve(size_t sz) { callbacks_.reserve(sz); diff --git a/extra/yassl/include/yassl_int.hpp b/extra/yassl/include/yassl_int.hpp index 02895d3897b..c9168254907 100644 --- a/extra/yassl/include/yassl_int.hpp +++ b/extra/yassl/include/yassl_int.hpp @@ -31,8 +31,8 @@ #include "yassl_imp.hpp" #include "crypto_wrapper.hpp" #include "cert_wrapper.hpp" -#include "lock.hpp" #include "log.hpp" +#include "lock.hpp" namespace yaSSL { diff --git a/extra/yassl/include/yassl_types.hpp b/extra/yassl/include/yassl_types.hpp index 1ad4998bade..28f673f920d 100644 --- a/extra/yassl/include/yassl_types.hpp +++ b/extra/yassl/include/yassl_types.hpp @@ -29,16 +29,6 @@ #include -namespace yaSSL { - -// library allocation -struct new_t {}; // yaSSL New type -extern new_t ys; // pass in parameter - -} // namespace yaSSL - -void* operator new (size_t, yaSSL::new_t); -void* operator new[](size_t, yaSSL::new_t); namespace yaSSL { diff --git a/extra/yassl/src/buffer.cpp b/extra/yassl/src/buffer.cpp index c97103c6f6d..6dc8845559c 100644 --- a/extra/yassl/src/buffer.cpp +++ b/extra/yassl/src/buffer.cpp @@ -62,13 +62,13 @@ input_buffer::input_buffer() input_buffer::input_buffer(uint s) - : size_(0), current_(0), buffer_(new (ys) byte[s]), end_(buffer_ + s) + : size_(0), current_(0), buffer_(new byte[s]), end_(buffer_ + s) {} // with assign input_buffer::input_buffer(uint s, const byte* t, uint len) - : size_(0), current_(0), buffer_(new (ys) byte[s]), end_(buffer_ + s) + : size_(0), current_(0), buffer_(new byte[s]), end_(buffer_ + s) { assign(t, len); } @@ -84,7 +84,7 @@ input_buffer::~input_buffer() void input_buffer::allocate(uint s) { assert(!buffer_); // find realloc error - buffer_ = new (ys) byte[s]; + buffer_ = new byte[s]; end_ = buffer_ + s; } @@ -198,13 +198,13 @@ output_buffer::output_buffer() // with allocate output_buffer::output_buffer(uint s) - : current_(0), buffer_(new (ys) byte[s]), end_(buffer_ + s) + : current_(0), buffer_(new byte[s]), end_(buffer_ + s) {} // with assign output_buffer::output_buffer(uint s, const byte* t, uint len) - : current_(0), buffer_(new (ys) byte[s]), end_(buffer_+ s) + : current_(0), buffer_(new byte[s]), end_(buffer_+ s) { write(t, len); } @@ -239,7 +239,7 @@ void output_buffer::set_current(uint c) void output_buffer::allocate(uint s) { assert(!buffer_); // find realloc error - buffer_ = new (ys) byte[s]; end_ = buffer_ + s; + buffer_ = new byte[s]; end_ = buffer_ + s; } diff --git a/extra/yassl/src/cert_wrapper.cpp b/extra/yassl/src/cert_wrapper.cpp index 98861d01287..33c1fee6ec3 100644 --- a/extra/yassl/src/cert_wrapper.cpp +++ b/extra/yassl/src/cert_wrapper.cpp @@ -39,7 +39,7 @@ namespace yaSSL { -x509::x509(uint sz) : length_(sz), buffer_(new (ys) opaque[sz]) +x509::x509(uint sz) : length_(sz), buffer_(new opaque[sz]) { } @@ -51,7 +51,7 @@ x509::~x509() x509::x509(const x509& that) : length_(that.length_), - buffer_(new (ys) opaque[length_]) + buffer_(new opaque[length_]) { memcpy(buffer_, that.buffer_, length_); } @@ -153,7 +153,7 @@ void CertManager::AddPeerCert(x509* x) void CertManager::CopySelfCert(const x509* x) { if (x) - list_.push_back(new (ys) x509(*x)); + list_.push_back(new x509(*x)); } @@ -165,7 +165,7 @@ int CertManager::CopyCaCert(const x509* x) if (!cert.GetError().What()) { const TaoCrypt::PublicKey& key = cert.GetPublicKey(); - signers_.push_back(new (ys) TaoCrypt::Signer(key.GetKey(), key.size(), + signers_.push_back(new TaoCrypt::Signer(key.GetKey(), key.size(), cert.GetCommonName(), cert.GetHash())); } return cert.GetError().What(); @@ -234,7 +234,7 @@ int CertManager::Validate() return err; const TaoCrypt::PublicKey& key = cert.GetPublicKey(); - signers_.push_back(new (ys) TaoCrypt::Signer(key.GetKey(), key.size(), + signers_.push_back(new TaoCrypt::Signer(key.GetKey(), key.size(), cert.GetCommonName(), cert.GetHash())); --last; --count; @@ -259,7 +259,7 @@ int CertManager::Validate() int iSz = cert.GetIssuer() ? strlen(cert.GetIssuer()) + 1 : 0; int sSz = cert.GetCommonName() ? strlen(cert.GetCommonName()) + 1 : 0; - peerX509_ = new (ys) X509(cert.GetIssuer(), iSz, cert.GetCommonName(), + peerX509_ = new X509(cert.GetIssuer(), iSz, cert.GetCommonName(), sSz); } return 0; @@ -273,13 +273,13 @@ int CertManager::SetPrivateKey(const x509& key) privateKey_.assign(key.get_buffer(), key.get_length()); // set key type - if (x509* cert509 = list_.front()) { - TaoCrypt::Source source(cert509->get_buffer(), cert509->get_length()); - TaoCrypt::CertDecoder cert(source, false); - cert.DecodeToKey(); - if (int err = cert.GetError().What()) + if (x509* cert = list_.front()) { + TaoCrypt::Source source(cert->get_buffer(), cert->get_length()); + TaoCrypt::CertDecoder cd(source, false); + cd.DecodeToKey(); + if (int err = cd.GetError().What()) return err; - if (cert.GetKeyType() == TaoCrypt::RSAk) + if (cd.GetKeyType() == TaoCrypt::RSAk) keyType_ = rsa_sa_algo; else keyType_ = dsa_sa_algo; diff --git a/extra/yassl/src/crypto_wrapper.cpp b/extra/yassl/src/crypto_wrapper.cpp index c083c56f313..e6b28cd9302 100644 --- a/extra/yassl/src/crypto_wrapper.cpp +++ b/extra/yassl/src/crypto_wrapper.cpp @@ -58,13 +58,13 @@ struct MD5::MD5Impl { }; -MD5::MD5() : pimpl_(new (ys) MD5Impl) {} +MD5::MD5() : pimpl_(new MD5Impl) {} MD5::~MD5() { delete pimpl_; } -MD5::MD5(const MD5& that) : Digest(), pimpl_(new (ys) +MD5::MD5(const MD5& that) : Digest(), pimpl_(new MD5Impl(that.pimpl_->md5_)) {} @@ -116,14 +116,13 @@ struct SHA::SHAImpl { }; -SHA::SHA() : pimpl_(new (ys) SHAImpl) {} +SHA::SHA() : pimpl_(new SHAImpl) {} SHA::~SHA() { delete pimpl_; } -SHA::SHA(const SHA& that) : Digest(), pimpl_(new (ys) - SHAImpl(that.pimpl_->sha_)) {} +SHA::SHA(const SHA& that) : Digest(), pimpl_(new SHAImpl(that.pimpl_->sha_)) {} SHA& SHA::operator=(const SHA& that) { @@ -174,14 +173,13 @@ struct RMD::RMDImpl { }; -RMD::RMD() : pimpl_(new (ys) RMDImpl) {} +RMD::RMD() : pimpl_(new RMDImpl) {} RMD::~RMD() { delete pimpl_; } -RMD::RMD(const RMD& that) : Digest(), pimpl_(new (ys) - RMDImpl(that.pimpl_->rmd_)) {} +RMD::RMD(const RMD& that) : Digest(), pimpl_(new RMDImpl(that.pimpl_->rmd_)) {} RMD& RMD::operator=(const RMD& that) { @@ -232,7 +230,7 @@ struct HMAC_MD5::HMAC_MD5Impl { HMAC_MD5::HMAC_MD5(const byte* secret, unsigned int len) - : pimpl_(new (ys) HMAC_MD5Impl) + : pimpl_(new HMAC_MD5Impl) { pimpl_->mac_.SetKey(secret, len); } @@ -282,7 +280,7 @@ struct HMAC_SHA::HMAC_SHAImpl { HMAC_SHA::HMAC_SHA(const byte* secret, unsigned int len) - : pimpl_(new (ys) HMAC_SHAImpl) + : pimpl_(new HMAC_SHAImpl) { pimpl_->mac_.SetKey(secret, len); } @@ -333,7 +331,7 @@ struct HMAC_RMD::HMAC_RMDImpl { HMAC_RMD::HMAC_RMD(const byte* secret, unsigned int len) - : pimpl_(new (ys) HMAC_RMDImpl) + : pimpl_(new HMAC_RMDImpl) { pimpl_->mac_.SetKey(secret, len); } @@ -381,7 +379,7 @@ struct DES::DESImpl { }; -DES::DES() : pimpl_(new (ys) DESImpl) {} +DES::DES() : pimpl_(new DESImpl) {} DES::~DES() { delete pimpl_; } @@ -417,7 +415,7 @@ struct DES_EDE::DES_EDEImpl { }; -DES_EDE::DES_EDE() : pimpl_(new (ys) DES_EDEImpl) {} +DES_EDE::DES_EDE() : pimpl_(new DES_EDEImpl) {} DES_EDE::~DES_EDE() { delete pimpl_; } @@ -455,7 +453,7 @@ struct RC4::RC4Impl { }; -RC4::RC4() : pimpl_(new (ys) RC4Impl) {} +RC4::RC4() : pimpl_(new RC4Impl) {} RC4::~RC4() { delete pimpl_; } @@ -497,7 +495,7 @@ struct AES::AESImpl { }; -AES::AES(unsigned int ks) : pimpl_(new (ys) AESImpl(ks)) {} +AES::AES(unsigned int ks) : pimpl_(new AESImpl(ks)) {} AES::~AES() { delete pimpl_; } @@ -538,7 +536,7 @@ struct RandomPool::RandomImpl { TaoCrypt::RandomNumberGenerator RNG_; }; -RandomPool::RandomPool() : pimpl_(new (ys) RandomImpl) {} +RandomPool::RandomPool() : pimpl_(new RandomImpl) {} RandomPool::~RandomPool() { delete pimpl_; } @@ -582,7 +580,7 @@ void DSS::DSSImpl::SetPrivate(const byte* key, unsigned int sz) // Set public or private key DSS::DSS(const byte* key, unsigned int sz, bool publicKey) - : pimpl_(new (ys) DSSImpl) + : pimpl_(new DSSImpl) { if (publicKey) pimpl_->SetPublic(key, sz); @@ -653,7 +651,7 @@ void RSA::RSAImpl::SetPrivate(const byte* key, unsigned int sz) // Set public or private key RSA::RSA(const byte* key, unsigned int sz, bool publicKey) - : pimpl_(new (ys) RSAImpl) + : pimpl_(new RSAImpl) { if (publicKey) pimpl_->SetPublic(key, sz); @@ -725,13 +723,13 @@ struct Integer::IntegerImpl { explicit IntegerImpl(const TaoCrypt::Integer& i) : int_(i) {} }; -Integer::Integer() : pimpl_(new (ys) IntegerImpl) {} +Integer::Integer() : pimpl_(new IntegerImpl) {} Integer::~Integer() { delete pimpl_; } -Integer::Integer(const Integer& other) : pimpl_(new (ys) +Integer::Integer(const Integer& other) : pimpl_(new IntegerImpl(other.pimpl_->int_)) {} @@ -770,9 +768,9 @@ struct DiffieHellman::DHImpl { void AllocKeys(unsigned int pubSz, unsigned int privSz, unsigned int agrSz) { - publicKey_ = new (ys) byte[pubSz]; - privateKey_ = new (ys) byte[privSz]; - agreedKey_ = new (ys) byte[agrSz]; + publicKey_ = new byte[pubSz]; + privateKey_ = new byte[privSz]; + agreedKey_ = new byte[agrSz]; } }; @@ -781,7 +779,7 @@ struct DiffieHellman::DHImpl { /* // server Side DH, server's view DiffieHellman::DiffieHellman(const char* file, const RandomPool& random) - : pimpl_(new (ys) DHImpl(random.pimpl_->RNG_)) + : pimpl_(new DHImpl(random.pimpl_->RNG_)) { using namespace TaoCrypt; Source source; @@ -805,12 +803,12 @@ DiffieHellman::DiffieHellman(const char* file, const RandomPool& random) DiffieHellman::DiffieHellman(const byte* p, unsigned int pSz, const byte* g, unsigned int gSz, const byte* pub, unsigned int pubSz, const RandomPool& random) - : pimpl_(new (ys) DHImpl(random.pimpl_->RNG_)) + : pimpl_(new DHImpl(random.pimpl_->RNG_)) { using TaoCrypt::Integer; pimpl_->dh_.Initialize(Integer(p, pSz).Ref(), Integer(g, gSz).Ref()); - pimpl_->publicKey_ = new (ys) opaque[pubSz]; + pimpl_->publicKey_ = new opaque[pubSz]; memcpy(pimpl_->publicKey_, pub, pubSz); } @@ -818,7 +816,7 @@ DiffieHellman::DiffieHellman(const byte* p, unsigned int pSz, const byte* g, // Server Side DH, server's view DiffieHellman::DiffieHellman(const Integer& p, const Integer& g, const RandomPool& random) -: pimpl_(new (ys) DHImpl(random.pimpl_->RNG_)) +: pimpl_(new DHImpl(random.pimpl_->RNG_)) { using TaoCrypt::Integer; @@ -836,7 +834,7 @@ DiffieHellman::~DiffieHellman() { delete pimpl_; } // Client side and view, use server that for p and g DiffieHellman::DiffieHellman(const DiffieHellman& that) - : pimpl_(new (ys) DHImpl(*that.pimpl_)) + : pimpl_(new DHImpl(*that.pimpl_)) { pimpl_->dh_.GenerateKeyPair(pimpl_->ranPool_, pimpl_->privateKey_, pimpl_->publicKey_); @@ -957,7 +955,7 @@ x509* PemToDer(const char* fname, CertType type) Base64Decoder b64Dec(der); uint sz = der.size(); - mySTL::auto_ptr x(new (ys) x509(sz)); + mySTL::auto_ptr x(new x509(sz)); memcpy(x->use_buffer(), der.get_buffer(), sz); fclose(file); @@ -971,8 +969,6 @@ x509* PemToDer(const char* fname, CertType type) template class TaoCrypt::HMAC; template class TaoCrypt::HMAC; template class TaoCrypt::HMAC; -template class TaoCrypt::Mode_BASE<16>; -template class TaoCrypt::Mode_BASE<8>; #endif #endif // !USE_CRYPTOPP_LIB diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp index 35c4cbd4922..28872e50063 100644 --- a/extra/yassl/src/handshake.cpp +++ b/extra/yassl/src/handshake.cpp @@ -362,9 +362,9 @@ void p_hash(output_buffer& result, const output_buffer& secret, if (lastLen) times += 1; if (hash == md5) - hmac.reset(new (ys) HMAC_MD5(secret.get_buffer(), secret.get_size())); + hmac.reset(new HMAC_MD5(secret.get_buffer(), secret.get_size())); else - hmac.reset(new (ys) HMAC_SHA(secret.get_buffer(), secret.get_size())); + hmac.reset(new HMAC_SHA(secret.get_buffer(), secret.get_size())); // A0 = seed hmac->get_digest(previous, seed.get_buffer(), seed.get_size());// A1 uint lastTime = times - 1; @@ -582,11 +582,11 @@ void TLS_hmac(SSL& ssl, byte* digest, const byte* buffer, uint sz, MACAlgorithm algo = ssl.getSecurity().get_parms().mac_algorithm_; if (algo == sha) - hmac.reset(new (ys) HMAC_SHA(ssl.get_macSecret(verify), SHA_LEN)); + hmac.reset(new HMAC_SHA(ssl.get_macSecret(verify), SHA_LEN)); else if (algo == rmd) - hmac.reset(new (ys) HMAC_RMD(ssl.get_macSecret(verify), RMD_LEN)); + hmac.reset(new HMAC_RMD(ssl.get_macSecret(verify), RMD_LEN)); else - hmac.reset(new (ys) HMAC_MD5(ssl.get_macSecret(verify), MD5_LEN)); + hmac.reset(new HMAC_MD5(ssl.get_macSecret(verify), MD5_LEN)); hmac->update(seq, SEQ_SZ); // seq_num inner[0] = content; // type @@ -687,7 +687,7 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr buffered) // make sure we have enough input in buffer to process this record if (hdr.length_ > buffer.get_remaining()) { uint sz = buffer.get_remaining() + RECORD_HEADER; - buffered.reset(new (ys) input_buffer(sz, buffer.get_buffer() + + buffered.reset(new input_buffer(sz, buffer.get_buffer() + buffer.get_current() - RECORD_HEADER, sz)); break; } @@ -760,7 +760,7 @@ void sendClientKeyExchange(SSL& ssl, BufferOutput buffer) RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new output_buffer); buildHeaders(ssl, hsHeader, rlHeader, ck); buildOutput(*out.get(), rlHeader, hsHeader, ck); hashHandShake(ssl, *out.get()); @@ -781,7 +781,7 @@ void sendServerKeyExchange(SSL& ssl, BufferOutput buffer) RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new output_buffer); buildHeaders(ssl, hsHeader, rlHeader, sk); buildOutput(*out.get(), rlHeader, hsHeader, sk); hashHandShake(ssl, *out.get()); @@ -806,7 +806,7 @@ void sendChangeCipher(SSL& ssl, BufferOutput buffer) ChangeCipherSpec ccs; RecordLayerHeader rlHeader; buildHeader(ssl, rlHeader, ccs); - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new output_buffer); buildOutput(*out.get(), rlHeader, ccs); if (buffer == buffered) @@ -823,7 +823,7 @@ void sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer) Finished fin; buildFinished(ssl, fin, side == client_end ? client : server); - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new output_buffer); cipherFinished(ssl, fin, *out.get()); // hashes handshake if (ssl.getSecurity().get_resuming()) { @@ -907,7 +907,7 @@ void sendServerHello(SSL& ssl, BufferOutput buffer) ServerHello sh(ssl.getSecurity().get_connection().version_); RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new output_buffer); buildServerHello(ssl, sh); ssl.set_random(sh.get_random(), server_end); @@ -930,7 +930,7 @@ void sendServerHelloDone(SSL& ssl, BufferOutput buffer) ServerHelloDone shd; RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new output_buffer); buildHeaders(ssl, hsHeader, rlHeader, shd); buildOutput(*out.get(), rlHeader, hsHeader, shd); @@ -951,7 +951,7 @@ void sendCertificate(SSL& ssl, BufferOutput buffer) Certificate cert(ssl.getCrypto().get_certManager().get_cert()); RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new output_buffer); buildHeaders(ssl, hsHeader, rlHeader, cert); buildOutput(*out.get(), rlHeader, hsHeader, cert); @@ -973,7 +973,7 @@ void sendCertificateRequest(SSL& ssl, BufferOutput buffer) request.Build(); RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new output_buffer); buildHeaders(ssl, hsHeader, rlHeader, request); buildOutput(*out.get(), rlHeader, hsHeader, request); @@ -995,7 +995,7 @@ void sendCertificateVerify(SSL& ssl, BufferOutput buffer) verify.Build(ssl); RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new (ys) output_buffer); + mySTL::auto_ptr out(new output_buffer); buildHeaders(ssl, hsHeader, rlHeader, verify); buildOutput(*out.get(), rlHeader, hsHeader, verify); diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp index 53bd8a75ab6..b0d9dcca902 100644 --- a/extra/yassl/src/ssl.cpp +++ b/extra/yassl/src/ssl.cpp @@ -443,7 +443,7 @@ int read_file(SSL_CTX* ctx, const char* file, int format, CertType type) fseek(input, 0, SEEK_END); long sz = ftell(input); rewind(input); - x = new (ys) x509(sz); // takes ownership + x = new x509(sz); // takes ownership size_t bytes = fread(x->use_buffer(), sz, 1, input); if (bytes != 1) { fclose(input); @@ -663,7 +663,7 @@ BIGNUM* BN_bin2bn(const unsigned char* num, int sz, BIGNUM* retVal) if (!retVal) { created = true; - bn.reset(new (ys) BIGNUM); + bn.reset(new BIGNUM); retVal = bn.get(); } diff --git a/extra/yassl/src/yassl_imp.cpp b/extra/yassl/src/yassl_imp.cpp index c1485cce986..02654727f78 100644 --- a/extra/yassl/src/yassl_imp.cpp +++ b/extra/yassl/src/yassl_imp.cpp @@ -134,10 +134,10 @@ void DH_Server::build(SSL& ssl) const CertManager& cert = ssl.getCrypto().get_certManager(); if (ssl.getSecurity().get_parms().sig_algo_ == rsa_sa_algo) - auth.reset(new (ys) RSA(cert.get_privateKey(), + auth.reset(new RSA(cert.get_privateKey(), cert.get_privateKeyLength(), false)); else { - auth.reset(new (ys) DSS(cert.get_privateKey(), + auth.reset(new DSS(cert.get_privateKey(), cert.get_privateKeyLength(), false)); sigSz += DSS_ENCODED_EXTRA; } @@ -168,7 +168,7 @@ void DH_Server::build(SSL& ssl) byte hash[FINISHED_SZ]; MD5 md5; SHA sha; - signature_ = new (ys) byte[sigSz]; + signature_ = new byte[sigSz]; const Connection& conn = ssl.getSecurity().get_connection(); // md5 @@ -199,7 +199,7 @@ void DH_Server::build(SSL& ssl) tmp.write(signature_, sigSz); // key message - keyMessage_ = new (ys) opaque[length_]; + keyMessage_ = new opaque[length_]; memcpy(keyMessage_, tmp.get_buffer(), tmp.get_size()); } @@ -253,7 +253,7 @@ opaque* EncryptedPreMasterSecret::get_clientKey() const void EncryptedPreMasterSecret::alloc(int sz) { length_ = sz; - secret_ = new (ys) opaque[sz]; + secret_ = new opaque[sz]; } @@ -303,7 +303,7 @@ opaque* ClientDiffieHellmanPublic::get_clientKey() const void ClientDiffieHellmanPublic::alloc(int sz, bool offset) { length_ = sz + (offset ? KEY_OFFSET : 0); - Yc_ = new (ys) opaque[length_]; + Yc_ = new opaque[length_]; } @@ -348,7 +348,7 @@ void DH_Server::read(SSL& ssl, input_buffer& input) tmp[1] = input[AUTO]; ato16(tmp, length); - signature_ = new (ys) byte[length]; + signature_ = new byte[length]; input.read(signature_, length); // verify signature @@ -386,7 +386,7 @@ void DH_Server::read(SSL& ssl, input_buffer& input) } // save input - ssl.useCrypto().SetDH(new (ys) DiffieHellman(parms_.get_p(), + ssl.useCrypto().SetDH(new DiffieHellman(parms_.get_p(), parms_.get_pSize(), parms_.get_g(), parms_.get_gSize(), parms_.get_pub(), parms_.get_pubSize(), ssl.getCrypto().get_random())); @@ -928,7 +928,7 @@ void Data::Process(input_buffer& input, SSL& ssl) // read data if (dataSz) { input_buffer* data; - ssl.addData(data = new (ys) input_buffer(dataSz)); + ssl.addData(data = new input_buffer(dataSz)); input.read(data->get_buffer(), dataSz); data->add_size(dataSz); @@ -1025,7 +1025,7 @@ void Certificate::Process(input_buffer& input, SSL& ssl) c24to32(tmp, cert_sz); x509* myCert; - cm.AddPeerCert(myCert = new (ys) x509(cert_sz)); + cm.AddPeerCert(myCert = new x509(cert_sz)); input.read(myCert->use_buffer(), myCert->get_length()); list_sz -= cert_sz + CERT_HEADER; @@ -1111,21 +1111,21 @@ const opaque* ServerDHParams::get_pub() const opaque* ServerDHParams::alloc_p(int sz) { - p_ = new (ys) opaque[pSz_ = sz]; + p_ = new opaque[pSz_ = sz]; return p_; } opaque* ServerDHParams::alloc_g(int sz) { - g_ = new (ys) opaque[gSz_ = sz]; + g_ = new opaque[gSz_ = sz]; return g_; } opaque* ServerDHParams::alloc_pub(int sz) { - Ys_ = new (ys) opaque[pubSz_ = sz]; + Ys_ = new opaque[pubSz_ = sz]; return Ys_; } @@ -1537,7 +1537,7 @@ void CertificateRequest::Build() for (int j = 0; j < authCount; j++) { int sz = REQUEST_HEADER + MIN_DIS_SIZE; DistinguishedName dn; - certificate_authorities_.push_back(dn = new (ys) byte[sz]); + certificate_authorities_.push_back(dn = new byte[sz]); opaque tmp[REQUEST_HEADER]; c16toa(MIN_DIS_SIZE, tmp); @@ -1584,7 +1584,7 @@ input_buffer& operator>>(input_buffer& input, CertificateRequest& request) ato16(tmp, dnSz); DistinguishedName dn; - request.certificate_authorities_.push_back(dn = new (ys) + request.certificate_authorities_.push_back(dn = new byte[REQUEST_HEADER + dnSz]); memcpy(dn, tmp, REQUEST_HEADER); input.read(&dn[REQUEST_HEADER], dnSz); @@ -1665,7 +1665,7 @@ void CertificateVerify::Build(SSL& ssl) RSA rsa(cert.get_privateKey(), cert.get_privateKeyLength(), false); sz = rsa.get_cipherLength() + VERIFY_HEADER; - sig.reset(new (ys) byte[sz]); + sig.reset(new byte[sz]); c16toa(sz - VERIFY_HEADER, len); memcpy(sig.get(), len, VERIFY_HEADER); @@ -1676,7 +1676,7 @@ void CertificateVerify::Build(SSL& ssl) DSS dss(cert.get_privateKey(), cert.get_privateKeyLength(), false); sz = DSS_SIG_SZ + DSS_ENCODED_EXTRA + VERIFY_HEADER; - sig.reset(new (ys) byte[sz]); + sig.reset(new byte[sz]); c16toa(sz - VERIFY_HEADER, len); memcpy(sig.get(), len, VERIFY_HEADER); @@ -1714,7 +1714,7 @@ input_buffer& operator>>(input_buffer& input, CertificateVerify& request) ato16(tmp, sz); request.set_length(sz); - request.signature_ = new (ys) byte[sz]; + request.signature_ = new byte[sz]; input.read(request.signature_, sz); return input; @@ -1975,7 +1975,7 @@ Connection::~Connection() void Connection::AllocPreSecret(uint sz) { - pre_master_secret_ = new (ys) opaque[pre_secret_len_ = sz]; + pre_master_secret_ = new opaque[pre_secret_len_ = sz]; } @@ -2011,35 +2011,35 @@ void Connection::CleanPreMaster() // Create functions for message factory -Message* CreateCipherSpec() { return new (ys) ChangeCipherSpec; } -Message* CreateAlert() { return new (ys) Alert; } -Message* CreateHandShake() { return new (ys) HandShakeHeader; } -Message* CreateData() { return new (ys) Data; } +Message* CreateCipherSpec() { return new ChangeCipherSpec; } +Message* CreateAlert() { return new Alert; } +Message* CreateHandShake() { return new HandShakeHeader; } +Message* CreateData() { return new Data; } // Create functions for handshake factory -HandShakeBase* CreateHelloRequest() { return new (ys) HelloRequest; } -HandShakeBase* CreateClientHello() { return new (ys) ClientHello; } -HandShakeBase* CreateServerHello() { return new (ys) ServerHello; } -HandShakeBase* CreateCertificate() { return new (ys) Certificate; } -HandShakeBase* CreateServerKeyExchange() { return new (ys) ServerKeyExchange;} -HandShakeBase* CreateCertificateRequest() { return new (ys) +HandShakeBase* CreateHelloRequest() { return new HelloRequest; } +HandShakeBase* CreateClientHello() { return new ClientHello; } +HandShakeBase* CreateServerHello() { return new ServerHello; } +HandShakeBase* CreateCertificate() { return new Certificate; } +HandShakeBase* CreateServerKeyExchange() { return new ServerKeyExchange;} +HandShakeBase* CreateCertificateRequest() { return new CertificateRequest; } -HandShakeBase* CreateServerHelloDone() { return new (ys) ServerHelloDone; } -HandShakeBase* CreateCertificateVerify() { return new (ys) CertificateVerify;} -HandShakeBase* CreateClientKeyExchange() { return new (ys) ClientKeyExchange;} -HandShakeBase* CreateFinished() { return new (ys) Finished; } +HandShakeBase* CreateServerHelloDone() { return new ServerHelloDone; } +HandShakeBase* CreateCertificateVerify() { return new CertificateVerify;} +HandShakeBase* CreateClientKeyExchange() { return new ClientKeyExchange;} +HandShakeBase* CreateFinished() { return new Finished; } // Create functions for server key exchange factory -ServerKeyBase* CreateRSAServerKEA() { return new (ys) RSA_Server; } -ServerKeyBase* CreateDHServerKEA() { return new (ys) DH_Server; } -ServerKeyBase* CreateFortezzaServerKEA() { return new (ys) Fortezza_Server; } +ServerKeyBase* CreateRSAServerKEA() { return new RSA_Server; } +ServerKeyBase* CreateDHServerKEA() { return new DH_Server; } +ServerKeyBase* CreateFortezzaServerKEA() { return new Fortezza_Server; } // Create functions for client key exchange factory -ClientKeyBase* CreateRSAClient() { return new (ys) +ClientKeyBase* CreateRSAClient() { return new EncryptedPreMasterSecret; } -ClientKeyBase* CreateDHClient() { return new (ys) +ClientKeyBase* CreateDHClient() { return new ClientDiffieHellmanPublic; } -ClientKeyBase* CreateFortezzaClient() { return new (ys) FortezzaKeys; } +ClientKeyBase* CreateFortezzaClient() { return new FortezzaKeys; } // Constructor calls this to Register compile time callbacks @@ -2115,4 +2115,3 @@ template yaSSL::del_ptr_zero mySTL::for_each: template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); } #endif - diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp index c552cfa7189..f32a8420b98 100644 --- a/extra/yassl/src/yassl_int.cpp +++ b/extra/yassl/src/yassl_int.cpp @@ -31,28 +31,6 @@ #include "openssl/ssl.h" // for DH -void* operator new(size_t sz, yaSSL::new_t) -{ - void* ptr = ::operator new(sz); - - if (!ptr) abort(); - - return ptr; -} - -void* operator new[](size_t sz, yaSSL::new_t n) -{ -#if defined(_MSC_VER) && (_MSC_VER < 1300) - void* ptr = ::operator new(sz); // no ::operator new[] -#else - void* ptr = ::operator new[](sz); -#endif - - if (!ptr) abort(); - - return ptr; -} - namespace yaSSL { @@ -60,8 +38,6 @@ namespace yaSSL { using mySTL::min; -new_t ys; // for library new - // convert a 32 bit integer into a 24 bit one void c32to24(uint32 u32, uint24& u24) @@ -308,8 +284,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = AES_256_KEY_SZ; parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; - crypto_.setDigest(new (ys) SHA); - crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); + crypto_.setDigest(new SHA); + crypto_.setCipher(new AES(AES_256_KEY_SZ)); strncpy(parms.cipher_name_, cipher_names[TLS_RSA_WITH_AES_256_CBC_SHA], MAX_SUITE_NAME); break; @@ -322,8 +298,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = AES_128_KEY_SZ; parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; - crypto_.setDigest(new (ys) SHA); - crypto_.setCipher(new (ys) AES); + crypto_.setDigest(new SHA); + crypto_.setCipher(new AES); strncpy(parms.cipher_name_, cipher_names[TLS_RSA_WITH_AES_128_CBC_SHA], MAX_SUITE_NAME); break; @@ -336,8 +312,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = DES_EDE_KEY_SZ; parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; - crypto_.setDigest(new (ys) SHA); - crypto_.setCipher(new (ys) DES_EDE); + crypto_.setDigest(new SHA); + crypto_.setCipher(new DES_EDE); strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_3DES_EDE_CBC_SHA] , MAX_SUITE_NAME); break; @@ -350,8 +326,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = DES_KEY_SZ; parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; - crypto_.setDigest(new (ys) SHA); - crypto_.setCipher(new (ys) DES); + crypto_.setDigest(new SHA); + crypto_.setCipher(new DES); strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_DES_CBC_SHA], MAX_SUITE_NAME); break; @@ -364,8 +340,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = RC4_KEY_SZ; parms.iv_size_ = 0; parms.cipher_type_ = stream; - crypto_.setDigest(new (ys) SHA); - crypto_.setCipher(new (ys) RC4); + crypto_.setDigest(new SHA); + crypto_.setCipher(new RC4); strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_RC4_128_SHA], MAX_SUITE_NAME); break; @@ -378,8 +354,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = RC4_KEY_SZ; parms.iv_size_ = 0; parms.cipher_type_ = stream; - crypto_.setDigest(new (ys) MD5); - crypto_.setCipher(new (ys) RC4); + crypto_.setDigest(new MD5); + crypto_.setCipher(new RC4); strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_RC4_128_MD5], MAX_SUITE_NAME); break; @@ -394,8 +370,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new (ys) SHA); - crypto_.setCipher(new (ys) DES); + crypto_.setDigest(new SHA); + crypto_.setCipher(new DES); strncpy(parms.cipher_name_, cipher_names[SSL_DHE_RSA_WITH_DES_CBC_SHA], MAX_SUITE_NAME); break; @@ -410,8 +386,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new (ys) SHA); - crypto_.setCipher(new (ys) DES_EDE); + crypto_.setDigest(new SHA); + crypto_.setCipher(new DES_EDE); strncpy(parms.cipher_name_, cipher_names[SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA], MAX_SUITE_NAME); break; @@ -426,8 +402,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new (ys) SHA); - crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); + crypto_.setDigest(new SHA); + crypto_.setCipher(new AES(AES_256_KEY_SZ)); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_RSA_WITH_AES_256_CBC_SHA], MAX_SUITE_NAME); break; @@ -442,8 +418,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new (ys) SHA); - crypto_.setCipher(new (ys) AES); + crypto_.setDigest(new SHA); + crypto_.setCipher(new AES); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_RSA_WITH_AES_128_CBC_SHA], MAX_SUITE_NAME); break; @@ -458,8 +434,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new (ys) SHA); - crypto_.setCipher(new (ys) DES); + crypto_.setDigest(new SHA); + crypto_.setCipher(new DES); strncpy(parms.cipher_name_, cipher_names[SSL_DHE_DSS_WITH_DES_CBC_SHA], MAX_SUITE_NAME); break; @@ -474,8 +450,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new (ys) SHA); - crypto_.setCipher(new (ys) DES_EDE); + crypto_.setDigest(new SHA); + crypto_.setCipher(new DES_EDE); strncpy(parms.cipher_name_, cipher_names[SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA], MAX_SUITE_NAME); break; @@ -490,8 +466,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new (ys) SHA); - crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); + crypto_.setDigest(new SHA); + crypto_.setCipher(new AES(AES_256_KEY_SZ)); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_DSS_WITH_AES_256_CBC_SHA], MAX_SUITE_NAME); break; @@ -506,8 +482,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new (ys) SHA); - crypto_.setCipher(new (ys) AES); + crypto_.setDigest(new SHA); + crypto_.setCipher(new AES); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_DSS_WITH_AES_128_CBC_SHA], MAX_SUITE_NAME); break; @@ -520,8 +496,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = AES_256_KEY_SZ; parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; - crypto_.setDigest(new (ys) RMD); - crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); + crypto_.setDigest(new RMD); + crypto_.setCipher(new AES(AES_256_KEY_SZ)); strncpy(parms.cipher_name_, cipher_names[TLS_RSA_WITH_AES_256_CBC_RMD160], MAX_SUITE_NAME); break; @@ -534,8 +510,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = AES_128_KEY_SZ; parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; - crypto_.setDigest(new (ys) RMD); - crypto_.setCipher(new (ys) AES); + crypto_.setDigest(new RMD); + crypto_.setCipher(new AES); strncpy(parms.cipher_name_, cipher_names[TLS_RSA_WITH_AES_128_CBC_RMD160], MAX_SUITE_NAME); break; @@ -548,8 +524,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = DES_EDE_KEY_SZ; parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; - crypto_.setDigest(new (ys) RMD); - crypto_.setCipher(new (ys) DES_EDE); + crypto_.setDigest(new RMD); + crypto_.setCipher(new DES_EDE); strncpy(parms.cipher_name_, cipher_names[TLS_RSA_WITH_3DES_EDE_CBC_RMD160], MAX_SUITE_NAME); break; @@ -564,8 +540,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new (ys) RMD); - crypto_.setCipher(new (ys) DES_EDE); + crypto_.setDigest(new RMD); + crypto_.setCipher(new DES_EDE); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_RSA_WITH_3DES_EDE_CBC_RMD160], MAX_SUITE_NAME); @@ -581,8 +557,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new (ys) RMD); - crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); + crypto_.setDigest(new RMD); + crypto_.setCipher(new AES(AES_256_KEY_SZ)); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_RSA_WITH_AES_256_CBC_RMD160], MAX_SUITE_NAME); @@ -598,8 +574,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new (ys) RMD); - crypto_.setCipher(new (ys) AES); + crypto_.setDigest(new RMD); + crypto_.setCipher(new AES); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_RSA_WITH_AES_128_CBC_RMD160], MAX_SUITE_NAME); @@ -615,8 +591,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new (ys) RMD); - crypto_.setCipher(new (ys) DES_EDE); + crypto_.setDigest(new RMD); + crypto_.setCipher(new DES_EDE); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_DSS_WITH_3DES_EDE_CBC_RMD160], MAX_SUITE_NAME); @@ -632,8 +608,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new (ys) RMD); - crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); + crypto_.setDigest(new RMD); + crypto_.setCipher(new AES(AES_256_KEY_SZ)); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_DSS_WITH_AES_256_CBC_RMD160], MAX_SUITE_NAME); @@ -649,8 +625,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new (ys) RMD); - crypto_.setCipher(new (ys) AES); + crypto_.setDigest(new RMD); + crypto_.setCipher(new AES); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_DSS_WITH_AES_128_CBC_RMD160], MAX_SUITE_NAME); @@ -936,12 +912,14 @@ struct SumBuffer { } // namespace for locals using namespace yassl_int_cpp_local1; + uint SSL::bufferedData() { return mySTL::for_each(buffers_.getData().begin(),buffers_.getData().end(), SumData()).total_; } + // use input buffer to fill data void SSL::fillData(Data& data) { @@ -1367,7 +1345,7 @@ typedef Mutex::Lock Lock; void Sessions::add(const SSL& ssl) { Lock guard(mutex_); - list_.push_back(new (ys) SSL_SESSION(ssl, random_)); + list_.push_back(new SSL_SESSION(ssl, random_)); } @@ -1397,6 +1375,7 @@ struct sess_match { } // local namespace using namespace yassl_int_cpp_local2; + // lookup session by id, return a copy if space provided SSL_SESSION* Sessions::lookup(const opaque* id, SSL_SESSION* copy) { @@ -1764,7 +1743,7 @@ void Crypto::SetDH(DiffieHellman* dh) void Crypto::SetDH(const DH_Parms& dh) { if (dh.set_) - dh_ = new (ys) DiffieHellman(dh.p_, dh.g_, random_); + dh_ = new DiffieHellman(dh.p_, dh.g_, random_); } @@ -1931,7 +1910,7 @@ X509_NAME::X509_NAME(const char* n, size_t sz) : name_(0) { if (sz) { - name_ = new (ys) char[sz]; + name_ = new char[sz]; memcpy(name_, n, sz); } } @@ -1952,7 +1931,7 @@ char* X509_NAME::GetName() X509::X509(const char* i, size_t iSz, const char* s, size_t sSz) : issuer_(i, iSz), subject_(s, sSz) {} - + X509_NAME* X509::GetIssuer() { diff --git a/extra/yassl/taocrypt/include/aes.hpp b/extra/yassl/taocrypt/include/aes.hpp index b2c93eff9fe..b8436d35c5f 100644 --- a/extra/yassl/taocrypt/include/aes.hpp +++ b/extra/yassl/taocrypt/include/aes.hpp @@ -37,11 +37,12 @@ enum { AES_BLOCK_SIZE = 16 }; // AES encryption and decryption, see FIPS-197 -class AES : public Mode_BASE { +class AES : public Mode_BASE { public: enum { BLOCK_SIZE = AES_BLOCK_SIZE }; - AES(CipherDir DIR, Mode MODE) : dir_(DIR), mode_(MODE) {} + AES(CipherDir DIR, Mode MODE) + : Mode_BASE(BLOCK_SIZE), dir_(DIR), mode_(MODE) {} void Process(byte*, const byte*, word32); void SetKey(const byte* iv, word32 sz, CipherDir fake = ENCRYPTION); diff --git a/extra/yassl/taocrypt/include/algebra.hpp b/extra/yassl/taocrypt/include/algebra.hpp index 74f244507f6..92cac607d97 100644 --- a/extra/yassl/taocrypt/include/algebra.hpp +++ b/extra/yassl/taocrypt/include/algebra.hpp @@ -24,11 +24,10 @@ #ifndef TAO_CRYPT_ALGEBRA_HPP #define TAO_CRYPT_ALGEBRA_HPP -#include "misc.hpp" +#include "integer.hpp" namespace TaoCrypt { -class Integer; // "const Element&" returned by member functions are references // to internal data members. Since each object may have only @@ -38,11 +37,11 @@ class Integer; // But this should be fine: // abcd = group.Add(a, group.Add(b, group.Add(c,d)); -//! Abstract Group -template class TAOCRYPT_NO_VTABLE AbstractGroup +// Abstract Group +class TAOCRYPT_NO_VTABLE AbstractGroup { public: - typedef T Element; + typedef Integer Element; virtual ~AbstractGroup() {} @@ -65,15 +64,14 @@ public: const Integer *exponents, unsigned int exponentsCount) const; }; -//! Abstract Ring -template class TAOCRYPT_NO_VTABLE AbstractRing - : public AbstractGroup +// Abstract Ring +class TAOCRYPT_NO_VTABLE AbstractRing : public AbstractGroup { public: - typedef T Element; + typedef Integer Element; AbstractRing() {m_mg.m_pRing = this;} - AbstractRing(const AbstractRing &source) {m_mg.m_pRing = this;} + AbstractRing(const AbstractRing &source) : AbstractGroup() {m_mg.m_pRing = this;} AbstractRing& operator=(const AbstractRing &source) {return *this;} virtual bool IsUnit(const Element &a) const =0; @@ -91,14 +89,14 @@ public: virtual void SimultaneousExponentiate(Element *results, const Element&, const Integer *exponents, unsigned int exponentsCount) const; - virtual const AbstractGroup& MultiplicativeGroup() const + virtual const AbstractGroup& MultiplicativeGroup() const {return m_mg;} private: - class MultiplicativeGroupT : public AbstractGroup + class MultiplicativeGroupT : public AbstractGroup { public: - const AbstractRing& GetRing() const + const AbstractRing& GetRing() const {return *m_pRing;} bool Equal(const Element &a, const Element &b) const @@ -137,44 +135,19 @@ private: {GetRing().SimultaneousExponentiate(results, base, exponents, exponentsCount);} - const AbstractRing *m_pRing; + const AbstractRing* m_pRing; }; MultiplicativeGroupT m_mg; }; -// ******************************************************** -//! Base and Exponent -template -struct BaseAndExponent +// Abstract Euclidean Domain +class TAOCRYPT_NO_VTABLE AbstractEuclideanDomain + : public AbstractRing { public: - BaseAndExponent() {} - BaseAndExponent(const T &base, const E &exponent) : base(base), - exponent(exponent) {} - bool operator<(const BaseAndExponent &rhs) const - {return exponent < rhs.exponent;} - T base; - E exponent; -}; - -// VC60 workaround: incomplete member template support -template - Element GeneralCascadeMultiplication(const AbstractGroup &group, - Iterator begin, Iterator end); -template - Element GeneralCascadeExponentiation(const AbstractRing &ring, - Iterator begin, Iterator end); - -// ******************************************************** - -//! Abstract Euclidean Domain -template class TAOCRYPT_NO_VTABLE AbstractEuclideanDomain - : public AbstractRing -{ -public: - typedef T Element; + typedef Integer Element; virtual void DivisionAlgorithm(Element &r, Element &q, const Element &a, const Element &d) const =0; @@ -186,13 +159,12 @@ protected: mutable Element result; }; -// ******************************************************** -//! EuclideanDomainOf -template class EuclideanDomainOf : public AbstractEuclideanDomain +// EuclideanDomainOf +class EuclideanDomainOf : public AbstractEuclideanDomain { public: - typedef T Element; + typedef Integer Element; EuclideanDomainOf() {} @@ -249,68 +221,8 @@ private: mutable Element result; }; -//! Quotient Ring -template class QuotientRing : public AbstractRing -{ -public: - typedef T EuclideanDomain; - typedef typename T::Element Element; - - QuotientRing(const EuclideanDomain &domain, const Element &modulus) - : m_domain(domain), m_modulus(modulus) {} - - const EuclideanDomain & GetDomain() const - {return m_domain;} - - const Element& GetModulus() const - {return m_modulus;} - - bool Equal(const Element &a, const Element &b) const - {return m_domain.Equal(m_domain.Mod(m_domain.Subtract(a, b), - m_modulus), m_domain.Identity());} - - const Element& Identity() const - {return m_domain.Identity();} - - const Element& Add(const Element &a, const Element &b) const - {return m_domain.Add(a, b);} - - Element& Accumulate(Element &a, const Element &b) const - {return m_domain.Accumulate(a, b);} - - const Element& Inverse(const Element &a) const - {return m_domain.Inverse(a);} - - const Element& Subtract(const Element &a, const Element &b) const - {return m_domain.Subtract(a, b);} - - Element& Reduce(Element &a, const Element &b) const - {return m_domain.Reduce(a, b);} - - const Element& Double(const Element &a) const - {return m_domain.Double(a);} - - bool IsUnit(const Element &a) const - {return m_domain.IsUnit(m_domain.Gcd(a, m_modulus));} - - const Element& MultiplicativeIdentity() const - {return m_domain.MultiplicativeIdentity();} - - const Element& Multiply(const Element &a, const Element &b) const - {return m_domain.Mod(m_domain.Multiply(a, b), m_modulus);} - - const Element& Square(const Element &a) const - {return m_domain.Mod(m_domain.Square(a), m_modulus);} - - const Element& MultiplicativeInverse(const Element &a) const; - -protected: - EuclideanDomain m_domain; - Element m_modulus; -}; } // namespace - #endif // TAO_CRYPT_ALGEBRA_HPP diff --git a/extra/yassl/taocrypt/include/block.hpp b/extra/yassl/taocrypt/include/block.hpp index f490fb0b6e7..f3c4415682d 100644 --- a/extra/yassl/taocrypt/include/block.hpp +++ b/extra/yassl/taocrypt/include/block.hpp @@ -34,10 +34,6 @@ #include // ptrdiff_t -#if defined(_MSC_VER) && defined(_CRTAPI1) -#define TAOCRYPT_MSVCRT6 -#endif - namespace TaoCrypt { @@ -47,13 +43,13 @@ template class AllocatorBase { public: - typedef T value_type; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef T* pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; + typedef T value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; pointer address(reference r) const {return (&r);} const_pointer address(const_reference r) const {return (&r); } @@ -104,7 +100,7 @@ public: CheckSize(n); if (n == 0) return 0; - return new (tc) T[n]; + return new T[n]; } void deallocate(void* p, size_type n) diff --git a/extra/yassl/taocrypt/include/des.hpp b/extra/yassl/taocrypt/include/des.hpp index e8100b4e198..127b8ddc6d5 100644 --- a/extra/yassl/taocrypt/include/des.hpp +++ b/extra/yassl/taocrypt/include/des.hpp @@ -36,12 +36,13 @@ namespace TaoCrypt { enum { DES_BLOCK_SIZE = 8 }; // Base for all DES types -class DES_BASE : public Mode_BASE { +class DES_BASE : public Mode_BASE { public: enum { BLOCK_SIZE = DES_BLOCK_SIZE, KEY_SIZE = 32, BOXES = 8, BOX_SIZE = 64 }; - DES_BASE(CipherDir DIR, Mode MODE) : dir_(DIR), mode_(MODE) {} + DES_BASE(CipherDir DIR, Mode MODE) + : Mode_BASE(BLOCK_SIZE), dir_(DIR), mode_(MODE) {} void Process(byte*, const byte*, word32); protected: diff --git a/extra/yassl/taocrypt/include/error.hpp b/extra/yassl/taocrypt/include/error.hpp index 6170d0349b5..55ab39313f5 100644 --- a/extra/yassl/taocrypt/include/error.hpp +++ b/extra/yassl/taocrypt/include/error.hpp @@ -65,7 +65,8 @@ UNKOWN_HASH_E = 1034, // "unknown hash OID" DSA_SZ_E = 1035, // "bad DSA r or s size" BEFORE_DATE_E = 1036, // "before date in the future" AFTER_DATE_E = 1037, // "after date in the past" -SIG_CONFIRM_E = 1038 // "bad signature confirmation" +SIG_CONFIRM_E = 1038, // "bad self signature confirmation" +SIG_OTHER_E = 1039 // "bad other signature confirmation" }; diff --git a/extra/yassl/taocrypt/include/hash.hpp b/extra/yassl/taocrypt/include/hash.hpp index 1703de23713..f01f343c2d1 100644 --- a/extra/yassl/taocrypt/include/hash.hpp +++ b/extra/yassl/taocrypt/include/hash.hpp @@ -50,7 +50,7 @@ public: class HASHwithTransform : public HASH { public: HASHwithTransform(word32 digSz, word32 buffSz) - : digest_(new (tc) word32[digSz]), buffer_(new (tc) byte[buffSz]) {} + : digest_(new word32[digSz]), buffer_(new byte[buffSz]) {} virtual ~HASHwithTransform() { delete[] buffer_; delete[] digest_; } virtual ByteOrder getByteOrder() const = 0; diff --git a/extra/yassl/taocrypt/include/integer.hpp b/extra/yassl/taocrypt/include/integer.hpp index 3713d09d9f9..6b1984e46ed 100644 --- a/extra/yassl/taocrypt/include/integer.hpp +++ b/extra/yassl/taocrypt/include/integer.hpp @@ -29,8 +29,8 @@ #include "block.hpp" #include "random.hpp" #include "file.hpp" -#include #include "algorithm.hpp" // mySTL::swap +#include #ifdef TAOCRYPT_X86ASM_AVAILABLE @@ -128,9 +128,6 @@ public: Integer(signed long value); Integer(Sign s, word highWord, word lowWord); - explicit Integer(const char* str); - explicit Integer(const wchar_t* str); - // BER Decode Source explicit Integer(Source&); @@ -254,15 +251,13 @@ public: private: friend class ModularArithmetic; friend class MontgomeryRepresentation; - friend class HalfMontgomeryRepresentation; - Integer(word value, unsigned int length); static const Integer zero; static const Integer one; static const Integer two; - int PositiveCompare(const Integer& t) const; + friend void PositiveAdd(Integer& sum, const Integer& a, const Integer& b); friend void PositiveSubtract(Integer& diff, const Integer& a, const Integer& b); @@ -308,6 +303,7 @@ inline void swap(Integer &a, Integer &b) Integer CRT(const Integer& xp, const Integer& p, const Integer& xq, const Integer& q, const Integer& u); + inline Integer ModularExponentiation(const Integer& a, const Integer& e, const Integer& m) { diff --git a/extra/yassl/taocrypt/include/misc.hpp b/extra/yassl/taocrypt/include/misc.hpp index b5b0a4575fc..de8cbb30fcb 100644 --- a/extra/yassl/taocrypt/include/misc.hpp +++ b/extra/yassl/taocrypt/include/misc.hpp @@ -28,17 +28,6 @@ #include #include -namespace TaoCrypt { - -// library allocation -struct new_t {}; // TaoCrypt New type -extern new_t tc; // pass in parameter - -} // namespace TaoCrypt - -void* operator new (size_t, TaoCrypt::new_t); -void* operator new[](size_t, TaoCrypt::new_t); - namespace TaoCrypt { diff --git a/extra/yassl/taocrypt/include/modarith.hpp b/extra/yassl/taocrypt/include/modarith.hpp index 88a2cc95c7c..66a841b05c3 100644 --- a/extra/yassl/taocrypt/include/modarith.hpp +++ b/extra/yassl/taocrypt/include/modarith.hpp @@ -27,14 +27,13 @@ #define TAO_CRYPT_MODARITH_HPP #include "misc.hpp" -#include "integer.hpp" #include "algebra.hpp" namespace TaoCrypt { -//! ModularArithmetic -class ModularArithmetic : public AbstractRing +// ModularArithmetic +class ModularArithmetic : public AbstractRing { public: @@ -45,7 +44,7 @@ public: : modulus(modulus), result((word)0, modulus.reg_.size()) {} ModularArithmetic(const ModularArithmetic &ma) - : AbstractRing(), + : AbstractRing(), modulus(ma.modulus), result((word)0, modulus.reg_.size()) {} const Integer& GetModulus() const {return modulus;} @@ -149,12 +148,12 @@ public: Integer CascadeExponentiate(const Integer &x, const Integer &e1, const Integer &y, const Integer &e2) const - {return AbstractRing::CascadeExponentiate(x, e1, y, e2);} + {return AbstractRing::CascadeExponentiate(x, e1, y, e2);} void SimultaneousExponentiate(Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const - {AbstractRing::SimultaneousExponentiate(results, base, - exponents, exponentsCount);} + {AbstractRing::SimultaneousExponentiate(results, base, + exponents, exponentsCount);} private: Integer u; diff --git a/extra/yassl/taocrypt/include/modes.hpp b/extra/yassl/taocrypt/include/modes.hpp index 2a21ad46b76..3f9878a9e62 100644 --- a/extra/yassl/taocrypt/include/modes.hpp +++ b/extra/yassl/taocrypt/include/modes.hpp @@ -56,10 +56,11 @@ private: // Mode Base for block ciphers, static size -template class Mode_BASE { public: - Mode_BASE() {} + enum { MaxBlockSz = 16 }; + + explicit Mode_BASE(int sz) : blockSz_(sz) { assert(sz <= MaxBlockSz); } virtual ~Mode_BASE() {} virtual void ProcessAndXorBlock(const byte*, const byte*, byte*) const = 0; @@ -68,10 +69,11 @@ public: void CBC_Encrypt(byte*, const byte*, word32); void CBC_Decrypt(byte*, const byte*, word32); - void SetIV(const byte* iv) { memcpy(reg_, iv, BLOCK_SIZE); } + void SetIV(const byte* iv) { memcpy(reg_, iv, blockSz_); } private: - byte reg_[BLOCK_SIZE]; - byte tmp_[BLOCK_SIZE]; + byte reg_[MaxBlockSz]; + byte tmp_[MaxBlockSz]; + int blockSz_; Mode_BASE(const Mode_BASE&); // hide copy Mode_BASE& operator=(const Mode_BASE&); // and assign @@ -79,51 +81,48 @@ private: // ECB Process blocks -template -void Mode_BASE::ECB_Process(byte* out, const byte* in, word32 sz) +inline void Mode_BASE::ECB_Process(byte* out, const byte* in, word32 sz) { - word32 blocks = sz / BLOCK_SIZE; + word32 blocks = sz / blockSz_; while (blocks--) { ProcessAndXorBlock(in, 0, out); - out += BLOCK_SIZE; - in += BLOCK_SIZE; + out += blockSz_; + in += blockSz_; } } // CBC Encrypt -template -void Mode_BASE::CBC_Encrypt(byte* out, const byte* in, word32 sz) +inline void Mode_BASE::CBC_Encrypt(byte* out, const byte* in, word32 sz) { - word32 blocks = sz / BLOCK_SIZE; + word32 blocks = sz / blockSz_; while (blocks--) { - xorbuf(reg_, in, BLOCK_SIZE); + xorbuf(reg_, in, blockSz_); ProcessAndXorBlock(reg_, 0, reg_); - memcpy(out, reg_, BLOCK_SIZE); - out += BLOCK_SIZE; - in += BLOCK_SIZE; + memcpy(out, reg_, blockSz_); + out += blockSz_; + in += blockSz_; } } // CBC Decrypt -template -void Mode_BASE::CBC_Decrypt(byte* out, const byte* in, word32 sz) +inline void Mode_BASE::CBC_Decrypt(byte* out, const byte* in, word32 sz) { - word32 blocks = sz / BLOCK_SIZE; - byte hold[BLOCK_SIZE]; + word32 blocks = sz / blockSz_; + byte hold[MaxBlockSz]; while (blocks--) { - memcpy(tmp_, in, BLOCK_SIZE); + memcpy(tmp_, in, blockSz_); ProcessAndXorBlock(tmp_, 0, out); - xorbuf(out, reg_, BLOCK_SIZE); - memcpy(hold, reg_, BLOCK_SIZE); // swap reg_ and tmp_ - memcpy(reg_, tmp_, BLOCK_SIZE); - memcpy(tmp_, hold, BLOCK_SIZE); - out += BLOCK_SIZE; - in += BLOCK_SIZE; + xorbuf(out, reg_, blockSz_); + memcpy(hold, reg_, blockSz_); // swap reg_ and tmp_ + memcpy(reg_, tmp_, blockSz_); + memcpy(tmp_, hold, blockSz_); + out += blockSz_; + in += blockSz_; } } diff --git a/extra/yassl/taocrypt/src/algebra.cpp b/extra/yassl/taocrypt/src/algebra.cpp index 1924be9b618..d70f8dd5d72 100644 --- a/extra/yassl/taocrypt/src/algebra.cpp +++ b/extra/yassl/taocrypt/src/algebra.cpp @@ -23,60 +23,58 @@ #include "runtime.hpp" #include "algebra.hpp" -#include "integer.hpp" #include "vector.hpp" // mySTL::vector (simple) namespace TaoCrypt { -template const T& AbstractGroup::Double(const Element &a) const + +const Integer& AbstractGroup::Double(const Element &a) const { return Add(a, a); } -template const T& AbstractGroup::Subtract(const Element &a, - const Element &b) const +const Integer& AbstractGroup::Subtract(const Element &a, const Element &b) const { // make copy of a in case Inverse() overwrites it Element a1(a); return Add(a1, Inverse(b)); } -template T& AbstractGroup::Accumulate(Element &a, - const Element &b) const +Integer& AbstractGroup::Accumulate(Element &a, const Element &b) const { return a = Add(a, b); } -template T& AbstractGroup::Reduce(Element &a, - const Element &b) const +Integer& AbstractGroup::Reduce(Element &a, const Element &b) const { return a = Subtract(a, b); } -template const T& AbstractRing::Square(const Element &a) const +const Integer& AbstractRing::Square(const Element &a) const { return Multiply(a, a); } -template const T& AbstractRing::Divide(const Element &a, - const Element &b) const + +const Integer& AbstractRing::Divide(const Element &a, const Element &b) const { // make copy of a in case MultiplicativeInverse() overwrites it Element a1(a); return Multiply(a1, MultiplicativeInverse(b)); } -template const T& AbstractEuclideanDomain::Mod(const Element &a, - const Element &b) const + +const Integer& AbstractEuclideanDomain::Mod(const Element &a, + const Element &b) const { Element q; DivisionAlgorithm(result, q, a, b); return result; } -template const T& AbstractEuclideanDomain::Gcd(const Element &a, - const Element &b) const +const Integer& AbstractEuclideanDomain::Gcd(const Element &a, + const Element &b) const { Element g[3]={b, a}; unsigned int i0=0, i1=1, i2=2; @@ -90,45 +88,17 @@ template const T& AbstractEuclideanDomain::Gcd(const Element &a, return result = g[i0]; } -template const typename - QuotientRing::Element& QuotientRing::MultiplicativeInverse( - const Element &a) const -{ - Element g[3]={m_modulus, a}; -#ifdef __BCPLUSPLUS__ - // BC++50 workaround - Element v[3]; - v[0]=m_domain.Identity(); - v[1]=m_domain.MultiplicativeIdentity(); -#else - Element v[3]={m_domain.Identity(), m_domain.MultiplicativeIdentity()}; -#endif - Element y; - unsigned int i0=0, i1=1, i2=2; - while (!Equal(g[i1], Identity())) - { - // y = g[i0] / g[i1]; - // g[i2] = g[i0] % g[i1]; - m_domain.DivisionAlgorithm(g[i2], y, g[i0], g[i1]); - // v[i2] = v[i0] - (v[i1] * y); - v[i2] = m_domain.Subtract(v[i0], m_domain.Multiply(v[i1], y)); - unsigned int t = i0; i0 = i1; i1 = i2; i2 = t; - } - - return m_domain.IsUnit(g[i0]) ? m_domain.Divide(v[i0], g[i0]) : - m_domain.Identity(); -} - -template T AbstractGroup::ScalarMultiply(const Element &base, - const Integer &exponent) const +Integer AbstractGroup::ScalarMultiply(const Element &base, + const Integer &exponent) const { Element result; SimultaneousMultiply(&result, base, &exponent, 1); return result; } -template T AbstractGroup::CascadeScalarMultiply(const Element &x, + +Integer AbstractGroup::CascadeScalarMultiply(const Element &x, const Integer &e1, const Element &y, const Integer &e2) const { const unsigned expLen = max(e1.BitCount(), e2.BitCount()); @@ -258,8 +228,8 @@ struct WindowSlider bool fastNegate, negateNext, firstTime, finished; }; -template -void AbstractGroup::SimultaneousMultiply(T *results, const T &base, + +void AbstractGroup::SimultaneousMultiply(Integer *results, const Integer &base, const Integer *expBegin, unsigned int expCount) const { mySTL::vector > buckets(expCount); @@ -321,34 +291,39 @@ void AbstractGroup::SimultaneousMultiply(T *results, const T &base, } } -template T AbstractRing::Exponentiate(const Element &base, - const Integer &exponent) const +Integer AbstractRing::Exponentiate(const Element &base, + const Integer &exponent) const { Element result; SimultaneousExponentiate(&result, base, &exponent, 1); return result; } -template T AbstractRing::CascadeExponentiate(const Element &x, + +Integer AbstractRing::CascadeExponentiate(const Element &x, const Integer &e1, const Element &y, const Integer &e2) const { - return MultiplicativeGroup().AbstractGroup::CascadeScalarMultiply( + return MultiplicativeGroup().AbstractGroup::CascadeScalarMultiply( x, e1, y, e2); } -template Element GeneralCascadeExponentiation( - const AbstractRing &ring, Iterator begin, Iterator end) -{ - return GeneralCascadeMultiplication(ring.MultiplicativeGroup(), - begin, end); -} -template -void AbstractRing::SimultaneousExponentiate(T *results, const T &base, +void AbstractRing::SimultaneousExponentiate(Integer *results, + const Integer &base, const Integer *exponents, unsigned int expCount) const { - MultiplicativeGroup().AbstractGroup::SimultaneousMultiply(results, base, + MultiplicativeGroup().AbstractGroup::SimultaneousMultiply(results, base, exponents, expCount); } + } // namespace + +#ifdef __GNUC__ +namespace mySTL { +template TaoCrypt::WindowSlider* uninit_copy(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*); +template vector* uninit_fill_n*, unsigned int, vector >(vector*, unsigned int, vector const&); +template void destroy(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*); +template void destroy*>(vector*, vector*); +} +#endif diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp index d0d22a6c61d..59c544bd633 100644 --- a/extra/yassl/taocrypt/src/asn.cpp +++ b/extra/yassl/taocrypt/src/asn.cpp @@ -187,7 +187,7 @@ PublicKey::PublicKey(const byte* k, word32 s) : key_(0), sz_(0) void PublicKey::SetSize(word32 s) { sz_ = s; - key_ = new (tc) byte[sz_]; + key_ = new byte[sz_]; } @@ -199,7 +199,7 @@ void PublicKey::SetKey(const byte* k) void PublicKey::AddToEnd(const byte* data, word32 len) { - mySTL::auto_ptr tmp(new (tc) byte[sz_ + len]); + mySTL::auto_ptr tmp(new byte[sz_ + len]); memcpy(tmp.get(), key_, sz_); memcpy(tmp.get() + sz_, data, len); @@ -218,7 +218,7 @@ Signer::Signer(const byte* k, word32 kSz, const char* n, const byte* h) { if (n) { int sz = strlen(n); - name_ = new (tc) char[sz + 1]; + name_ = new char[sz + 1]; memcpy(name_, n, sz); name_[sz] = 0; } @@ -480,7 +480,7 @@ void CertDecoder::Decode(SignerList* signers) } else if (!ValidateSignature(signers)) - source_.SetError(SIG_CONFIRM_E); + source_.SetError(SIG_OTHER_E); } @@ -632,7 +632,7 @@ word32 CertDecoder::GetSignature() } sigLength_--; - signature_ = new (tc) byte[sigLength_]; + signature_ = new byte[sigLength_]; memcpy(signature_, source_.get_current(), sigLength_); source_.advance(sigLength_); @@ -653,7 +653,7 @@ word32 CertDecoder::GetDigest() sigLength_ = GetLength(source_); - signature_ = new (tc) byte[sigLength_]; + signature_ = new byte[sigLength_]; memcpy(signature_, source_.get_current(), sigLength_); source_.advance(sigLength_); @@ -693,7 +693,7 @@ void CertDecoder::GetName(NameType nt) if (id == COMMON_NAME) { char*& ptr = (nt == ISSUER) ? issuer_ : subject_; - ptr = new (tc) char[strLen + 1]; + ptr = new char[strLen + 1]; memcpy(ptr, source_.get_current(), strLen); ptr[strLen] = 0; } @@ -810,15 +810,15 @@ bool CertDecoder::ConfirmSignature(Source& pub) mySTL::auto_ptr hasher; if (signatureOID_ == MD5wRSA) { - hasher.reset(new (tc) MD5); + hasher.reset(new MD5); ht = MD5h; } else if (signatureOID_ == MD2wRSA) { - hasher.reset(new (tc) MD2); + hasher.reset(new MD2); ht = MD2h; } else if (signatureOID_ == SHAwRSA || signatureOID_ == SHAwDSA) { - hasher.reset(new (tc) SHA); + hasher.reset(new SHA); ht = SHAh; } else { diff --git a/extra/yassl/taocrypt/src/dh.cpp b/extra/yassl/taocrypt/src/dh.cpp index af50d471b52..ea1b5846f7d 100644 --- a/extra/yassl/taocrypt/src/dh.cpp +++ b/extra/yassl/taocrypt/src/dh.cpp @@ -26,7 +26,6 @@ #include "runtime.hpp" #include "dh.hpp" #include "asn.hpp" -#include namespace TaoCrypt { diff --git a/extra/yassl/taocrypt/src/dsa.cpp b/extra/yassl/taocrypt/src/dsa.cpp index 4716ebb22df..5cb3018a402 100644 --- a/extra/yassl/taocrypt/src/dsa.cpp +++ b/extra/yassl/taocrypt/src/dsa.cpp @@ -27,8 +27,6 @@ #include "modarith.hpp" #include "stdexcept.hpp" -#include "algebra.cpp" // for GCC 3.2 on aix ? - namespace TaoCrypt { diff --git a/extra/yassl/taocrypt/src/integer.cpp b/extra/yassl/taocrypt/src/integer.cpp index 9be0a25b363..37cfe374451 100644 --- a/extra/yassl/taocrypt/src/integer.cpp +++ b/extra/yassl/taocrypt/src/integer.cpp @@ -38,11 +38,10 @@ #include "asn.hpp" #include "stdexcept.hpp" -#include "algebra.cpp" #ifdef __DECCXX - #include // for asm multiply overflow + #include // for asm overflow assembly #endif @@ -63,7 +62,7 @@ #pragma message("You do not seem to have the Visual C++ Processor Pack ") #pragma message("installed, so use of SSE2 intrinsics will be disabled.") #elif defined(__GNUC__) && defined(__i386__) -/* #warning You do not have GCC 3.3 or later, or did not specify the -msse2 \ +/* #warning You do not have GCC 3.3 or later, or did not specify the -msse2 \ compiler option. Use of SSE2 intrinsics will be disabled. */ #endif @@ -109,7 +108,7 @@ CPP_TYPENAME AllocatorBase::pointer AlignedAllocator::allocate( assert(IsAlignedOn(p, 16)); return (T*)p; } - return new (tc) T[n]; + return new T[n]; } @@ -178,7 +177,7 @@ DWord() {} #elif defined(__DECCXX) r.halfs_.high = asm("umulh %a0, %a1, %v0", a, b); #else - #error unsupported alpha compiler for asm multiply overflow + #error can not implement multiply overflow #endif #elif defined(__ia64__) r.halfs_.low = a*b; @@ -392,6 +391,7 @@ S DivideThreeWordsByTwo(S* A, S B0, S B1, D* dummy_VC6_WorkAround = 0) return Q; } + // do a 4 word by 2 word divide, returns 2 word quotient in Q0 and Q1 template inline D DivideFourWordsByTwo(S *T, const D &Al, const D &Ah, const D &B) @@ -470,66 +470,6 @@ static inline unsigned int RoundupSize(unsigned int n) } -template -static Integer StringToInteger(const T *str) -{ - word radix; - - unsigned int length; - for (length = 0; str[length] != 0; length++) {} - - Integer v; - - if (length == 0) - return v; - - switch (str[length-1]) - { - case 'h': - case 'H': - radix=16; - break; - case 'o': - case 'O': - radix=8; - break; - case 'b': - case 'B': - radix=2; - break; - default: - radix=10; - } - - if (length > 2 && str[0] == '0' && str[1] == 'x') - radix = 16; - - for (unsigned i=0; i= '0' && str[i] <= '9') - digit = str[i] - '0'; - else if (str[i] >= 'A' && str[i] <= 'F') - digit = str[i] - 'A' + 10; - else if (str[i] >= 'a' && str[i] <= 'f') - digit = str[i] - 'a' + 10; - else - digit = radix; - - if (digit < radix) - { - v *= radix; - v += digit; - } - } - - if (str[0] == '-') - v.Negate(); - - return v; -} - static int Compare(const word *A, const word *B, unsigned int N) { while (N--) @@ -2308,85 +2248,6 @@ void RecursiveMultiplyBottom(word *R, word *T, const word *A, const word *B, } } -/* -template -void RecursiveMultiplyTop(word *R, word *T, const word *L, const word *A, - const word *B, unsigned int N, const P *dummy=0) -{ - assert(N>=2 && N%2==0); - - if (N==4) - { - P::Multiply4(T, A, B); - ((dword *)R)[0] = ((dword *)T)[2]; - ((dword *)R)[1] = ((dword *)T)[3]; - } - else if (N==2) - { - P::Multiply2(T, A, B); - ((dword *)R)[0] = ((dword *)T)[1]; - } - else - { - const unsigned int N2 = N/2; - int carry; - - int aComp = Compare(A0, A1, N2); - int bComp = Compare(B0, B1, N2); - - switch (2*aComp + aComp + bComp) - { - case -4: - P::Subtract(R0, A1, A0, N2); - P::Subtract(R1, B0, B1, N2); - RecursiveMultiply

(T0, T2, R0, R1, N2); - P::Subtract(T1, T1, R0, N2); - carry = -1; - break; - case -2: - P::Subtract(R0, A1, A0, N2); - P::Subtract(R1, B0, B1, N2); - RecursiveMultiply

(T0, T2, R0, R1, N2); - carry = 0; - break; - case 2: - P::Subtract(R0, A0, A1, N2); - P::Subtract(R1, B1, B0, N2); - RecursiveMultiply

(T0, T2, R0, R1, N2); - carry = 0; - break; - case 4: - P::Subtract(R0, A1, A0, N2); - P::Subtract(R1, B0, B1, N2); - RecursiveMultiply

(T0, T2, R0, R1, N2); - P::Subtract(T1, T1, R1, N2); - carry = -1; - break; - default: - SetWords(T0, 0, N); - carry = 0; - } - - RecursiveMultiply

(T2, R0, A1, B1, N2); - - // now T[01] holds (A1-A0)*(B0-B1), T[23] holds A1*B1 - - word c2 = P::Subtract(R0, L+N2, L, N2); - c2 += P::Subtract(R0, R0, T0, N2); - word t = (Compare(R0, T2, N2) == -1); - - carry += t; - carry += Increment(R0, N2, c2+t); - carry += P::Add(R0, R0, T1, N2); - carry += P::Add(R0, R0, T3, N2); - assert (carry >= 0 && carry <= 2); - - CopyWords(R1, T3, N2); - Increment(R1, N2, carry); - } -} -*/ - void RecursiveMultiplyTop(word *R, word *T, const word *L, const word *A, const word *B, unsigned int N) @@ -2739,20 +2600,6 @@ Integer::Integer(word value, unsigned int length) } -Integer::Integer(const char *str) - : reg_(2), sign_(POSITIVE) -{ - *this = StringToInteger(str); -} - - -Integer::Integer(const wchar_t *str) - : reg_(2), sign_(POSITIVE) -{ - *this = StringToInteger(str); -} - - Integer::Integer(const byte *encodedInteger, unsigned int byteCount, Signedness s) { @@ -3358,76 +3205,6 @@ Integer Integer::Times(const Integer &b) const #undef R2 #undef R3 -/* -// do a 3 word by 2 word divide, returns quotient and leaves remainder in A -static word SubatomicDivide(word *A, word B0, word B1) -{ - // assert {A[2],A[1]} < {B1,B0}, so quotient can fit in a word - assert(A[2] < B1 || (A[2]==B1 && A[1] < B0)); - - dword p, u; - word Q; - - // estimate the quotient: do a 2 word by 1 word divide - if (B1+1 == 0) - Q = A[2]; - else - Q = word(MAKE_DWORD(A[1], A[2]) / (B1+1)); - - // now subtract Q*B from A - p = (dword) B0*Q; - u = (dword) A[0] - LOW_WORD(p); - A[0] = LOW_WORD(u); - u = (dword) A[1] - HIGH_WORD(p) - (word)(0-HIGH_WORD(u)) - (dword)B1*Q; - A[1] = LOW_WORD(u); - A[2] += HIGH_WORD(u); - - // Q <= actual quotient, so fix it - while (A[2] || A[1] > B1 || (A[1]==B1 && A[0]>=B0)) - { - u = (dword) A[0] - B0; - A[0] = LOW_WORD(u); - u = (dword) A[1] - B1 - (word)(0-HIGH_WORD(u)); - A[1] = LOW_WORD(u); - A[2] += HIGH_WORD(u); - Q++; - assert(Q); // shouldn't overflow - } - - return Q; -} -*/ - - -/* -// do a 4 word by 2 word divide, returns 2 word quotient in Q0 and Q1 -static inline void AtomicDivide(word *Q, const word *A, const word *B) -{ - if (!B[0] && !B[1]) // if divisor is 0, we assume divisor==2**(2*WORD_BITS) - { - Q[0] = A[2]; - Q[1] = A[3]; - } - else - { - word T[4]; - T[0] = A[0]; T[1] = A[1]; T[2] = A[2]; T[3] = A[3]; - Q[1] = SubatomicDivide(T+1, B[0], B[1]); - Q[0] = SubatomicDivide(T, B[0], B[1]); - -#ifndef NDEBUG - // multiply quotient and divisor and add remainder - // make sure it equals dividend - assert(!T[2] && !T[3] && (T[1] < B[1] || (T[1]==B[1] && T[0]().Gcd(a, b); + return EuclideanDomainOf().Gcd(a, b); } Integer Integer::InverseMod(const Integer &m) const @@ -3955,7 +3732,7 @@ Integer ModularArithmetic::CascadeExponentiate(const Integer &x, dr.ConvertIn(y), e2)); } else - return AbstractRing::CascadeExponentiate(x, e1, y, e2); + return AbstractRing::CascadeExponentiate(x, e1, y, e2); } void ModularArithmetic::SimultaneousExponentiate(Integer *results, @@ -3971,7 +3748,7 @@ void ModularArithmetic::SimultaneousExponentiate(Integer *results, results[i] = dr.ConvertOut(results[i]); } else - AbstractRing::SimultaneousExponentiate(results, base, + AbstractRing::SimultaneousExponentiate(results, base, exponents, exponentsCount); } @@ -4170,10 +3947,6 @@ Integer CRT(const Integer &xp, const Integer &p, const Integer &xq, } #ifdef __GNUC__ -template Integer StringToInteger(char const*); -template Integer StringToInteger(wchar_t const*); -template class EuclideanDomainOf; -template class AbstractEuclideanDomain; template unsigned int DivideThreeWordsByTwo(unsigned int*, unsigned int, unsigned int, DWord*); #endif diff --git a/extra/yassl/taocrypt/src/misc.cpp b/extra/yassl/taocrypt/src/misc.cpp index e4573abac3f..37d1bd1b14d 100644 --- a/extra/yassl/taocrypt/src/misc.cpp +++ b/extra/yassl/taocrypt/src/misc.cpp @@ -27,36 +27,9 @@ #include // for NewHandler -void* operator new(size_t sz, TaoCrypt::new_t) -{ - void* ptr = ::operator new(sz); - - if (!ptr) abort(); - - return ptr; -} - -void* operator new[](size_t sz, TaoCrypt::new_t tc) -{ -#if defined(_MSC_VER) && (_MSC_VER < 1300) - void* ptr = ::operator new(sz); // no ::operator new[] -#else - void* ptr = ::operator new[](sz); -#endif - - if (!ptr) abort(); - - return ptr; -} - - - namespace TaoCrypt { -new_t tc; // for library new - - inline void XorWords(word* r, const word* a, unsigned int n) { for (unsigned int i=0; i::pointer StdReallocate >(AllocatorWithCleanup&, unsigned char*, AllocatorWithCleanup::size_type, AllocatorWithCleanup::size_type, bool); template AllocatorWithCleanup::pointer StdReallocate >(AllocatorWithCleanup&, unsigned int*, AllocatorWithCleanup::size_type, AllocatorWithCleanup::size_type, bool); -template class AbstractGroup; -template class AbstractRing; template class RSA_Decryptor; template class RSA_Encryptor; template class RSA_Encryptor; @@ -227,11 +224,7 @@ template class RSA_Encryptor; namespace mySTL { template TaoCrypt::Integer* uninit_copy(TaoCrypt::Integer*, TaoCrypt::Integer*, TaoCrypt::Integer*); template TaoCrypt::Integer* uninit_fill_n(TaoCrypt::Integer*, unsigned int, TaoCrypt::Integer const&); -template TaoCrypt::WindowSlider* uninit_copy(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*); -template vector* uninit_fill_n*, unsigned int, vector >(vector*, unsigned int, vector const&); template void destroy(TaoCrypt::Integer*, TaoCrypt::Integer*); -template void destroy(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*); -template void destroy*>(vector*, vector*); } #endif From 6083014c4c7e5039c294bf38656c0d75fb226adc Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Tue, 24 May 2005 22:42:43 +0200 Subject: [PATCH 19/98] - applied more changes to enable the CP932 charset on Windows - fixed linking with zlib --- VC++Files/client/mysql.dsp | 6 +++--- VC++Files/client/mysql_ia64.dsp | 6 +++--- VC++Files/client/mysqladmin.dsp | 6 +++--- VC++Files/client/mysqladmin_ia64.dsp | 6 +++--- VC++Files/client/mysqlcheck.dsp | 2 +- VC++Files/client/mysqlcheck_ia64.dsp | 2 +- VC++Files/client/mysqlclient.dsp | 4 ++++ VC++Files/client/mysqlclient_ia64.dsp | 4 ++++ VC++Files/client/mysqldump.dsp | 6 +++--- VC++Files/client/mysqldump_ia64.dsp | 6 +++--- VC++Files/client/mysqlimport.dsp | 6 +++--- VC++Files/client/mysqlimport_ia64.dsp | 6 +++--- VC++Files/client/mysqlshow.dsp | 6 +++--- VC++Files/client/mysqlshow_ia64.dsp | 6 +++--- VC++Files/client/mysqltest.dsp | 4 ++-- VC++Files/client/mysqltest_ia64.dsp | 6 +++--- VC++Files/libmysql/libmysql.dsp | 4 ++++ VC++Files/libmysql/libmysql_ia64.dsp | 4 ++++ VC++Files/mysql-test/mysql_test_run_new.dsp | 4 ++-- VC++Files/mysql-test/mysql_test_run_new_ia64.dsp | 4 ++-- VC++Files/mysqlbinlog/mysqlbinlog.dsp | 6 +++--- VC++Files/mysqlbinlog/mysqlbinlog_ia64.dsp | 6 +++--- VC++Files/mysqlcheck/mysqlcheck.dsp | 6 +++--- VC++Files/mysqlcheck/mysqlcheck_ia64.dsp | 6 +++--- VC++Files/mysqlmanager/mysqlmanager.dsp | 4 ++-- VC++Files/strings/strings_ia64.dsp | 4 ++++ 26 files changed, 75 insertions(+), 55 deletions(-) diff --git a/VC++Files/client/mysql.dsp b/VC++Files/client/mysql.dsp index ec16e780d3e..8298e62d8ad 100644 --- a/VC++Files/client/mysql.dsp +++ b/VC++Files/client/mysql.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /incremental:yes !ELSEIF "$(CFG)" == "mysql - Win32 Debug" @@ -78,7 +78,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysql.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysql.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysql - Win32 classic" @@ -106,7 +106,7 @@ BSC32=bscmake.exe LINK32=xilink6.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" # SUBTRACT BASE LINK32 /incremental:yes -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_classic/mysql.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_classic/mysql.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /incremental:yes !ENDIF diff --git a/VC++Files/client/mysql_ia64.dsp b/VC++Files/client/mysql_ia64.dsp index 43bc9fa5b09..3fe2e2a2328 100644 --- a/VC++Files/client/mysql_ia64.dsp +++ b/VC++Files/client/mysql_ia64.dsp @@ -53,7 +53,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:IX86 /machine:IA64 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /debug /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysql - WinIA64 Debug" @@ -79,7 +79,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:IA64 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysql.exe" /libpath:"..\lib_debug\\" /machine:IA64 +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysql.exe" /libpath:"..\lib_debug\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysql - WinIA64 classic" @@ -107,7 +107,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" /machine:IA64 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /out:"../client_classic/mysql.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /debug /out:"../client_classic/mysql.exe" /libpath:"..\lib_release\\" /machine:IA64 !ENDIF diff --git a/VC++Files/client/mysqladmin.dsp b/VC++Files/client/mysqladmin.dsp index 7a0b3bec1a7..b473d104a76 100644 --- a/VC++Files/client/mysqladmin.dsp +++ b/VC++Files/client/mysqladmin.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqladmin.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqladmin.exe" /libpath:"..\lib_release\\" !ELSEIF "$(CFG)" == "mysqladmin - Win32 Debug" @@ -77,7 +77,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqladmin.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqladmin.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysqladmin - Win32 classic" @@ -104,7 +104,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqladmin.exe" /libpath:"..\lib_release\\" -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqladmin.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqladmin.exe" /libpath:"..\lib_release\\" !ENDIF diff --git a/VC++Files/client/mysqladmin_ia64.dsp b/VC++Files/client/mysqladmin_ia64.dsp index 5a5e4a99071..f7823479d5a 100644 --- a/VC++Files/client/mysqladmin_ia64.dsp +++ b/VC++Files/client/mysqladmin_ia64.dsp @@ -53,7 +53,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_release/mysqladmin.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_release/mysqladmin.exe" /libpath:"..\lib_release\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqladmin - WinIA64 Debug" @@ -79,7 +79,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:IA64 -# ADD LINK32 ..\lib_debug\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqladmin.exe" /libpath:"..\lib_debug\\" /machine:IA64 +# ADD LINK32 ..\lib_debug\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqladmin.exe" /libpath:"..\lib_debug\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqladmin - WinIA64 classic" @@ -107,7 +107,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /out:"../client_release/mysqladmin.exe" /libpath:"..\lib_release\\" /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_classic/mysqladmin.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_classic/mysqladmin.exe" /libpath:"..\lib_release\\" /machine:IA64 !ENDIF diff --git a/VC++Files/client/mysqlcheck.dsp b/VC++Files/client/mysqlcheck.dsp index 30e7a365f04..399b18d16fc 100644 --- a/VC++Files/client/mysqlcheck.dsp +++ b/VC++Files/client/mysqlcheck.dsp @@ -46,7 +46,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:"release/mysqlcheck.pdb" /machine:I386 /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /pdb:"release/mysqlcheck.pdb" /machine:I386 /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /pdb:none # Begin Target diff --git a/VC++Files/client/mysqlcheck_ia64.dsp b/VC++Files/client/mysqlcheck_ia64.dsp index 4b2c2bb4c46..aa49d86a523 100644 --- a/VC++Files/client/mysqlcheck_ia64.dsp +++ b/VC++Files/client/mysqlcheck_ia64.dsp @@ -49,7 +49,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:IA64 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /pdb:"release/mysqlcheck.pdb" /machine:IA64 /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" /incremental:no +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /pdb:"release/mysqlcheck.pdb" /machine:IA64 /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" /incremental:no # SUBTRACT LINK32 !ENDIF diff --git a/VC++Files/client/mysqlclient.dsp b/VC++Files/client/mysqlclient.dsp index 75008858e55..599bad92d7f 100644 --- a/VC++Files/client/mysqlclient.dsp +++ b/VC++Files/client/mysqlclient.dsp @@ -151,6 +151,10 @@ SOURCE="..\strings\ctype-czech.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-cp932.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-euc_kr.c" # End Source File # Begin Source File diff --git a/VC++Files/client/mysqlclient_ia64.dsp b/VC++Files/client/mysqlclient_ia64.dsp index e91245c12b2..3edc979b9dc 100644 --- a/VC++Files/client/mysqlclient_ia64.dsp +++ b/VC++Files/client/mysqlclient_ia64.dsp @@ -151,6 +151,10 @@ SOURCE="..\strings\ctype-czech.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-cp963.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-euc_kr.c" # End Source File # Begin Source File diff --git a/VC++Files/client/mysqldump.dsp b/VC++Files/client/mysqldump.dsp index 3c955639596..45d1d8777aa 100644 --- a/VC++Files/client/mysqldump.dsp +++ b/VC++Files/client/mysqldump.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqldump.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqldump.exe" /libpath:"..\lib_release\\" !ELSEIF "$(CFG)" == "mysqldump - Win32 Debug" @@ -77,7 +77,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqldump.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqldump.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysqldump - Win32 classic" @@ -104,7 +104,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqldump.exe" /libpath:"..\lib_release\\" -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqldump.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqldump.exe" /libpath:"..\lib_release\\" !ENDIF diff --git a/VC++Files/client/mysqldump_ia64.dsp b/VC++Files/client/mysqldump_ia64.dsp index 698cd0b9c2c..79a7059cae5 100644 --- a/VC++Files/client/mysqldump_ia64.dsp +++ b/VC++Files/client/mysqldump_ia64.dsp @@ -53,7 +53,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_release/mysqldump.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_release/mysqldump.exe" /libpath:"..\lib_release\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqldump - WinIA64 Debug" @@ -79,7 +79,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /debug /machine:IA64 -# ADD LINK32 ..\lib_debug\dbug.lib ..\lib_debug\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqldump.exe" /libpath:"..\lib_debug\\" /machine:IA64 +# ADD LINK32 ..\lib_debug\dbug.lib ..\lib_debug\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqldump.exe" /libpath:"..\lib_debug\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqldump - WinIA64 classic" @@ -107,7 +107,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib /nologo /subsystem:console /out:"../client_release/mysqldump.exe" /libpath:"..\lib_release\\" /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_classic/mysqldump.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysys.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_classic/mysqldump.exe" /libpath:"..\lib_release\\" /machine:IA64 !ENDIF diff --git a/VC++Files/client/mysqlimport.dsp b/VC++Files/client/mysqlimport.dsp index d5fd8557397..1a9b64a0383 100644 --- a/VC++Files/client/mysqlimport.dsp +++ b/VC++Files/client/mysqlimport.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /incremental:yes !ELSEIF "$(CFG)" == "mysqlimport - Win32 Debug" @@ -78,7 +78,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setargv.obj /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlimport.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib setargv.obj /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlimport.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysqlimport - Win32 classic" @@ -106,7 +106,7 @@ BSC32=bscmake.exe LINK32=xilink6.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" # SUBTRACT BASE LINK32 /incremental:yes -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlimport.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlimport.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /incremental:yes !ENDIF diff --git a/VC++Files/client/mysqlimport_ia64.dsp b/VC++Files/client/mysqlimport_ia64.dsp index cd8f5523efd..c6f51c0ef6f 100644 --- a/VC++Files/client/mysqlimport_ia64.dsp +++ b/VC++Files/client/mysqlimport_ia64.dsp @@ -53,7 +53,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqlimport - WinIA64 Debug" @@ -79,7 +79,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:IA64 -# ADD LINK32 setargv.obj ..\lib_debug\zlib.lib ..\lib_debug\dbug.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqlimport.exe" /libpath:"..\lib_debug\\" /machine:IA64 +# ADD LINK32 setargv.obj ..\lib_debug\zlib.lib ..\lib_debug\dbug.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqlimport.exe" /libpath:"..\lib_debug\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqlimport - WinIA64 classic" @@ -107,7 +107,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_classic/mysqlimport.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_classic/mysqlimport.exe" /libpath:"..\lib_release\\" /machine:IA64 !ENDIF diff --git a/VC++Files/client/mysqlshow.dsp b/VC++Files/client/mysqlshow.dsp index b9fd0d27e46..855c2dcdf34 100644 --- a/VC++Files/client/mysqlshow.dsp +++ b/VC++Files/client/mysqlshow.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" !ELSEIF "$(CFG)" == "mysqlshow - Win32 Debug" @@ -77,7 +77,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlshow.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlshow.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysqlshow - Win32 classic" @@ -104,7 +104,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlshow.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlshow.exe" /libpath:"..\lib_release\\" !ENDIF diff --git a/VC++Files/client/mysqlshow_ia64.dsp b/VC++Files/client/mysqlshow_ia64.dsp index dd83a3f1ef5..4995f3f9ae8 100644 --- a/VC++Files/client/mysqlshow_ia64.dsp +++ b/VC++Files/client/mysqlshow_ia64.dsp @@ -53,7 +53,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqlshow - WinIA64 Debug" @@ -79,7 +79,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:IA64 -# ADD LINK32 ..\lib_debug\zlib.lib ..\lib_debug\dbug.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqlshow.exe" /libpath:"..\lib_debug\\" /machine:IA64 +# ADD LINK32 ..\lib_debug\zlib.lib ..\lib_debug\dbug.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqlshow.exe" /libpath:"..\lib_debug\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqlshow - WinIA64 classic" @@ -107,7 +107,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_classic/mysqlshow.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_classic/mysqlshow.exe" /libpath:"..\lib_release\\" /machine:IA64 !ENDIF diff --git a/VC++Files/client/mysqltest.dsp b/VC++Files/client/mysqltest.dsp index d04dc5bfce8..e705b17b0f0 100644 --- a/VC++Files/client/mysqltest.dsp +++ b/VC++Files/client/mysqltest.dsp @@ -78,7 +78,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib /nologo /out:"..\client_classic\mysqltest.exe" /incremental:no /libpath:"..\lib_release\" /pdb:".\classic\mysqltest.pdb" /pdbtype:sept /subsystem:console /MACHINE:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib /nologo /out:"..\client_classic\mysqltest.exe" /incremental:no /libpath:"..\lib_release\" /pdb:".\classic\mysqltest.pdb" /pdbtype:sept /subsystem:console /MACHINE:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib zlib.lib /nologo /out:"..\client_classic\mysqltest.exe" /incremental:no /libpath:"..\lib_release\" /pdb:".\classic\mysqltest.pdb" /pdbtype:sept /subsystem:console /MACHINE:I386 !ELSEIF "$(CFG)" == "mysqltest - Win32 Release" @@ -103,7 +103,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib /nologo /out:"..\client_release\mysqltest.exe" /incremental:no /libpath:"..\lib_release\" /pdb:".\release\mysqltest.pdb" /pdbtype:sept /subsystem:console /MACHINE:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib /nologo /out:"..\client_release\mysqltest.exe" /incremental:no /libpath:"..\lib_release\" /pdb:".\release\mysqltest.pdb" /pdbtype:sept /subsystem:console /MACHINE:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib zlib.lib /nologo /out:"..\client_release\mysqltest.exe" /incremental:no /libpath:"..\lib_release\" /pdb:".\release\mysqltest.pdb" /pdbtype:sept /subsystem:console /MACHINE:I386 !ENDIF diff --git a/VC++Files/client/mysqltest_ia64.dsp b/VC++Files/client/mysqltest_ia64.dsp index 160683725e6..86edb4ab177 100644 --- a/VC++Files/client/mysqltest_ia64.dsp +++ b/VC++Files/client/mysqltest_ia64.dsp @@ -55,7 +55,7 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib /nologo /subsystem:console /debug /out:"..\client_debug\mysqltest.exe" /libpath:"..\lib_debug\\" # SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 ..\lib_debug\zlib.lib ..\lib_debug\dbug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /debug /out:"..\client_debug\mysqltest.exe" /libpath:"..\lib_debug\\" /machine:IA64 +# ADD LINK32 ..\lib_debug\zlib.lib ..\lib_debug\dbug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"..\client_debug\mysqltest.exe" /libpath:"..\lib_debug\\" /machine:IA64 # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "mysqltest - WinIA64 classic" @@ -84,7 +84,7 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib /nologo /subsystem:console /out:"..\client_classic\mysqltest.exe" /libpath:"..\lib_release\\" # SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 ..\lib_release\zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib bufferoverflowU.lib /nologo /subsystem:console /out:"..\client_classic\mysqltest.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"..\client_classic\mysqltest.exe" /libpath:"..\lib_release\\" /machine:IA64 # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "mysqltest - WinIA64 Release" @@ -113,7 +113,7 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib /nologo /subsystem:console /out:"..\client_release\mysqltest.exe" /libpath:"..\lib_release\\" # SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 ..\lib_release\zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib bufferoverflowU.lib /nologo /subsystem:console /out:"..\client_release\mysqltest.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib mysqlclient.lib wsock32.lib mysys.lib regex.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"..\client_release\mysqltest.exe" /libpath:"..\lib_release\\" /machine:IA64 # SUBTRACT LINK32 /pdb:none !ENDIF diff --git a/VC++Files/libmysql/libmysql.dsp b/VC++Files/libmysql/libmysql.dsp index ce81a3b7435..21e393f137d 100644 --- a/VC++Files/libmysql/libmysql.dsp +++ b/VC++Files/libmysql/libmysql.dsp @@ -143,6 +143,10 @@ SOURCE="..\strings\ctype-czech.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-cp932.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-euc_kr.c" # End Source File # Begin Source File diff --git a/VC++Files/libmysql/libmysql_ia64.dsp b/VC++Files/libmysql/libmysql_ia64.dsp index 4c4776dfc2f..12932ed3924 100644 --- a/VC++Files/libmysql/libmysql_ia64.dsp +++ b/VC++Files/libmysql/libmysql_ia64.dsp @@ -142,6 +142,10 @@ SOURCE="..\strings\ctype-czech.c" # End Source File # Begin Source File +SOURCE="..\strings\ctype-cp932.c" +# End Source File +# Begin Source File + SOURCE="..\strings\ctype-euc_kr.c" # End Source File # Begin Source File diff --git a/VC++Files/mysql-test/mysql_test_run_new.dsp b/VC++Files/mysql-test/mysql_test_run_new.dsp index 61392b00b94..7fa01d22d11 100644 --- a/VC++Files/mysql-test/mysql_test_run_new.dsp +++ b/VC++Files/mysql-test/mysql_test_run_new.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:yes /debug /pdb:".\Debug\mysql_test_run_new.pdb" /pdbtype:sept /map:".\Debug\mysql_test_run_new.map" /subsystem:console -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:yes /debug /pdb:".\Debug\mysql_test_run_new.pdb" /pdbtype:sept /map:".\Debug\mysql_test_run_new.map" /subsystem:console +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib zlib.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:yes /debug /pdb:".\Debug\mysql_test_run_new.pdb" /pdbtype:sept /map:".\Debug\mysql_test_run_new.map" /subsystem:console !ELSEIF "$(CFG)" == "mysql_test_run_new - Win32 Release" @@ -77,7 +77,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:no /pdb:".\Release\mysql_test_run_new.pdb" /pdbtype:sept /subsystem:console -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:no /pdb:".\Release\mysql_test_run_new.pdb" /pdbtype:sept /subsystem:console +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib zlib.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:no /pdb:".\Release\mysql_test_run_new.pdb" /pdbtype:sept /subsystem:console !ENDIF diff --git a/VC++Files/mysql-test/mysql_test_run_new_ia64.dsp b/VC++Files/mysql-test/mysql_test_run_new_ia64.dsp index a6252d0cb7b..d9bad07dad9 100644 --- a/VC++Files/mysql-test/mysql_test_run_new_ia64.dsp +++ b/VC++Files/mysql-test/mysql_test_run_new_ia64.dsp @@ -54,7 +54,7 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /map /debug /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 # SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /map /debug /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /map /debug /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "mysql_test_run_new - WinIA64 Release" @@ -83,7 +83,7 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 # SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 t kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 +# ADD LINK32 t kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 # SUBTRACT LINK32 /pdb:none !ENDIF diff --git a/VC++Files/mysqlbinlog/mysqlbinlog.dsp b/VC++Files/mysqlbinlog/mysqlbinlog.dsp index 8b8895d6f17..1b129072d8e 100644 --- a/VC++Files/mysqlbinlog/mysqlbinlog.dsp +++ b/VC++Files/mysqlbinlog/mysqlbinlog.dsp @@ -51,7 +51,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlbinlog.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlbinlog.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /pdb:none /debug !ELSEIF "$(CFG)" == "mysqlbinlog - Win32 Debug" @@ -76,7 +76,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlbinlog.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlbinlog.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysqlbinlog - Win32 classic" @@ -102,7 +102,7 @@ BSC32=bscmake.exe LINK32=xilink6.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlbinlog.exe" /libpath:"..\lib_release\\" # SUBTRACT BASE LINK32 /pdb:none /debug -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlbinlog.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlbinlog.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /pdb:none /debug !ENDIF diff --git a/VC++Files/mysqlbinlog/mysqlbinlog_ia64.dsp b/VC++Files/mysqlbinlog/mysqlbinlog_ia64.dsp index 334c5087365..0bb6e9ed747 100644 --- a/VC++Files/mysqlbinlog/mysqlbinlog_ia64.dsp +++ b/VC++Files/mysqlbinlog/mysqlbinlog_ia64.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_release/mysqlbinlog.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_release/mysqlbinlog.exe" /libpath:"..\lib_release\\" /machine:IA64 # SUBTRACT LINK32 /debug !ELSEIF "$(CFG)" == "mysqlbinlog - WinIA64 Debug" @@ -78,7 +78,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:IA64 -# ADD LINK32 ..\lib_debug\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqlbinlog.exe" /libpath:"..\lib_debug\\" /machine:IA64 +# ADD LINK32 ..\lib_debug\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqlbinlog.exe" /libpath:"..\lib_debug\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqlbinlog - WinIA64 classic" @@ -105,7 +105,7 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /out:"../client_release/mysqlbinlog.exe" /libpath:"..\lib_release\\" /machine:IA64 # SUBTRACT BASE LINK32 /debug -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_classic/mysqlbinlog.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_classic/mysqlbinlog.exe" /libpath:"..\lib_release\\" /machine:IA64 # SUBTRACT LINK32 /debug !ENDIF diff --git a/VC++Files/mysqlcheck/mysqlcheck.dsp b/VC++Files/mysqlcheck/mysqlcheck.dsp index bd24a14128d..51a817cc067 100644 --- a/VC++Files/mysqlcheck/mysqlcheck.dsp +++ b/VC++Files/mysqlcheck/mysqlcheck.dsp @@ -51,7 +51,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" !ELSEIF "$(CFG)" == "mysqlcheck - Win32 Debug" @@ -75,7 +75,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlcheck.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlcheck.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysqlcheck - Win32 classic" @@ -100,7 +100,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlcheck.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlcheck.exe" /libpath:"..\lib_release\\" !ENDIF diff --git a/VC++Files/mysqlcheck/mysqlcheck_ia64.dsp b/VC++Files/mysqlcheck/mysqlcheck_ia64.dsp index 1f1cf76276f..04f10a2ddb8 100644 --- a/VC++Files/mysqlcheck/mysqlcheck_ia64.dsp +++ b/VC++Files/mysqlcheck/mysqlcheck_ia64.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqlcheck - WinIA64 Debug" @@ -77,7 +77,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:IA64 -# ADD LINK32 ..\lib_debug\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqlcheck.exe" /libpath:"..\lib_debug\\" /machine:IA64 +# ADD LINK32 ..\lib_debug\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /out:"../client_debug/mysqlcheck.exe" /libpath:"..\lib_debug\\" /machine:IA64 !ELSEIF "$(CFG)" == "mysqlcheck - WinIA64 classic" @@ -103,7 +103,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" /machine:IA64 -# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib /nologo /subsystem:console /out:"../client_classic/mysqlcheck.exe" /libpath:"..\lib_release\\" /machine:IA64 +# ADD LINK32 ..\lib_release\zlib.lib mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"../client_classic/mysqlcheck.exe" /libpath:"..\lib_release\\" /machine:IA64 !ENDIF diff --git a/VC++Files/mysqlmanager/mysqlmanager.dsp b/VC++Files/mysqlmanager/mysqlmanager.dsp index 7f92e091904..27aa1a77024 100644 --- a/VC++Files/mysqlmanager/mysqlmanager.dsp +++ b/VC++Files/mysqlmanager/mysqlmanager.dsp @@ -54,7 +54,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 -# ADD LINK32 /nologo /subsystem:windows /machine:I386 /out:"../client_release/MySqlManager.exe" +# ADD LINK32 zlib.lib /nologo /subsystem:windows /machine:I386 /out:"../client_release/MySqlManager.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /nodefaultlib !ELSEIF "$(CFG)" == "MySqlManager - Win32 Debug" @@ -83,7 +83,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib /nologo /subsystem:windows /incremental:no /debug /machine:I386 /out:"../client_debug/MySqlManager.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib zlib.lib /nologo /subsystem:windows /incremental:no /debug /machine:I386 /out:"../client_debug/MySqlManager.exe" /pdbtype:sept /libpath:"..\lib_debug\\" # SUBTRACT LINK32 /pdb:none !ENDIF diff --git a/VC++Files/strings/strings_ia64.dsp b/VC++Files/strings/strings_ia64.dsp index 6449b2b1355..edbcdee2f11 100644 --- a/VC++Files/strings/strings_ia64.dsp +++ b/VC++Files/strings/strings_ia64.dsp @@ -116,6 +116,10 @@ SOURCE=".\ctype-czech.c" # End Source File # Begin Source File +SOURCE=".\ctype-cp932.c" +# End Source File +# Begin Source File + SOURCE=".\ctype-euc_kr.c" # End Source File # Begin Source File From 9c8b4c93bb08ed3ea3fa85cc311d90f36b484a6b Mon Sep 17 00:00:00 2001 From: "acurtis@xiphis.org" <> Date: Tue, 24 May 2005 22:31:57 +0100 Subject: [PATCH 20/98] Fix after merge --- mysql-test/r/rpl_log.result | 8 ++++++-- mysql-test/r/rpl_rotate_logs.result | 22 ++++++++++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result index d32956428a5..e150cf53585 100644 --- a/mysql-test/r/rpl_log.result +++ b/mysql-test/r/rpl_log.result @@ -70,12 +70,16 @@ master-bin.000002 434 Query 1 510 use `test`; drop table t1 show binary logs; Log_name File_size master-bin.000001 0 -master-bin.000002 276 +master-bin.000002 510 +Warnings: +Error 29 File 'master-bin.000001' not found (Errcode: 2) start slave; show binary logs; Log_name File_size slave-bin.000001 0 -slave-bin.000002 170 +slave-bin.000002 348 +Warnings: +Error 29 File 'slave-bin.000001' not found (Errcode: 2) show binlog events in 'slave-bin.000001' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 4 Format_desc 2 98 Server ver: VERSION, Binlog ver: 4 diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result index 098f8e4a5dd..b9724386909 100644 --- a/mysql-test/r/rpl_rotate_logs.result +++ b/mysql-test/r/rpl_rotate_logs.result @@ -29,7 +29,10 @@ show binary logs; Log_name File_size master-bin.000001 0 master-bin.000002 0 -master-bin.000003 4 +master-bin.000003 98 +Warnings: +Error 29 File 'master-bin.000001' not found (Errcode: 2) +Error 29 File 'master-bin.000002' not found (Errcode: 2) create table t3 select * from temp_table; select * from t3; a @@ -44,16 +47,20 @@ purge master logs to 'master-bin.000002'; show master logs; Log_name File_size master-bin.000002 0 -master-bin.000003 229 +master-bin.000003 407 +Warnings: +Error 29 File 'master-bin.000002' not found (Errcode: 2) purge binary logs to 'master-bin.000002'; show binary logs; Log_name File_size master-bin.000002 0 -master-bin.000003 229 +master-bin.000003 407 +Warnings: +Error 29 File 'master-bin.000002' not found (Errcode: 2) purge master logs before now(); show binary logs; Log_name File_size -master-bin.000003 229 +master-bin.000003 407 insert into t2 values (65); show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master @@ -75,8 +82,11 @@ create table t4 select * from temp_table; show binary logs; Log_name File_size master-bin.000003 0 -master-bin.000004 2886 -master-bin.000005 +master-bin.000004 0 +master-bin.000005 2032 +Warnings: +Error 29 File 'master-bin.000003' not found (Errcode: 2) +Error 29 File 'master-bin.000004' not found (Errcode: 2) show master status; File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000005 2032 From a6af23a046e8954b7726a5a63f14237b8c685b50 Mon Sep 17 00:00:00 2001 From: "patg@radha.local" <> Date: Wed, 25 May 2005 02:15:09 +0200 Subject: [PATCH 21/98] changes to fix joins not working (bug #10848). New tests, as well as table->status being set in index_read_idx --- BitKeeper/etc/logging_ok | 1 + mysql-test/r/federated.result | 52 +++++++++++++++++++++++++++++++++-- mysql-test/t/federated.test | 34 +++++++++++++++++++++-- sql/ha_federated.cc | 2 ++ 4 files changed, 85 insertions(+), 4 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index d8d16aaa1d8..3230f3c119f 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -205,6 +205,7 @@ patg@krsna. patg@krsna.patg.net patg@patrick-galbraiths-computer.local patg@pc248.lfp.kcls.org +patg@radha.local paul@central.snake.net paul@frost.snake.net paul@ice.local diff --git a/mysql-test/r/federated.result b/mysql-test/r/federated.result index 6c815e94b7c..ebf9b144eeb 100644 --- a/mysql-test/r/federated.result +++ b/mysql-test/r/federated.result @@ -906,9 +906,57 @@ INSERT INTO federated.t1 (name, country_id, other) VALUES ('Lenz', 2, 22222); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Marizio', 3, 33333); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Monty', 4, 33333); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Sanja', 5, 33333); +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1, federated.countries WHERE +federated.t1.country_id = federated.countries.id; +name country_id other country +Kumar 1 11111 India +Lenz 2 22222 Germany +Marizio 3 33333 Italy +Monty 4 33333 Finland +Sanja 5 33333 Ukraine +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id; +name country_id other country +Kumar 1 11111 India +Lenz 2 22222 Germany +Marizio 3 33333 Italy +Monty 4 33333 Finland +Sanja 5 33333 Ukraine +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id +WHERE federated.t1.name = 'Monty'; +name country_id other country +Monty 4 33333 Finland SELECT federated.t1.*, federated.countries.country -FROM federated.t1 left join federated.countries -ON federated.t1.country_id = federated.countries.id; +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.id; +id country_id name other country +1 1 Kumar 11111 India +2 2 Lenz 22222 Germany +3 3 Marizio 33333 Italy +4 4 Monty 33333 Finland +5 5 Sanja 33333 Ukraine +SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.country; +id country_id name other country +4 4 Monty 33333 Finland +2 2 Lenz 22222 Germany +1 1 Kumar 11111 India +3 3 Marizio 33333 Italy +5 5 Sanja 33333 Ukraine +SELECT federated.t1.*, federated.countries.country +FROM federated.t1 RIGHT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.t1.country_id; id country_id name other country 1 1 Kumar 11111 India 2 2 Lenz 22222 Germany diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test index 6a0e0bdac79..da8df543ed0 100644 --- a/mysql-test/t/federated.test +++ b/mysql-test/t/federated.test @@ -861,9 +861,39 @@ INSERT INTO federated.t1 (name, country_id, other) VALUES ('Marizio', 3, 33333); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Monty', 4, 33333); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Sanja', 5, 33333); +#inner join +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1, federated.countries WHERE +federated.t1.country_id = federated.countries.id; + +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id; + +SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id +WHERE federated.t1.name = 'Monty'; + +#left join SELECT federated.t1.*, federated.countries.country -FROM federated.t1 left join federated.countries -ON federated.t1.country_id = federated.countries.id; +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.id; + +SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.country; + +#right join +SELECT federated.t1.*, federated.countries.country +FROM federated.t1 RIGHT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.t1.country_id; DROP TABLE federated.countries; diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index 8cb6dcb7285..eab3e55c4a4 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -1526,6 +1526,8 @@ int ha_federated::index_read_idx(byte *buf, uint index, const byte *key, table->status= STATUS_NOT_FOUND; DBUG_RETURN(mysql_errno(mysql)); } + /* very important - joins will not work without this! */ + table->status=0; DBUG_RETURN(rnd_next(buf)); } From 274fee09c9960a31ae9af53b2abdee4743fafcc5 Mon Sep 17 00:00:00 2001 From: "stewart@mysql.com" <> Date: Wed, 25 May 2005 12:18:18 +1000 Subject: [PATCH 22/98] BUG#10796 Incorrect check-cpu result for ppc linux gcc --- BUILD/check-cpu | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BUILD/check-cpu b/BUILD/check-cpu index 7619224314b..0283c669fb2 100755 --- a/BUILD/check-cpu +++ b/BUILD/check-cpu @@ -72,6 +72,7 @@ case "$cpu_family--$model_name" in ;; *ppc) cpu_flag="powerpc"; + no_march=1; ;; *) cpu_flag=""; @@ -106,6 +107,9 @@ case "$cc_ver--$cc_verno" in cpu_flag="$cpu_flag_old" fi check_cpu_cflags="-mcpu=$cpu_flag -march=$cpu_flag" + if test -n "$no_march"; then + check_cpu_cflags="-mcpu=$cpu_flag" + fi ;; *) check_cpu_cflags="" From 119e500c80ba14d5f6262addc7020c310587207d Mon Sep 17 00:00:00 2001 From: "stewart@mysql.com" <> Date: Wed, 25 May 2005 15:35:51 +1000 Subject: [PATCH 23/98] BUG#10831 ndb mgmd LogDestination maxfiles does not rotate logs properly --- ndb/src/common/util/File.cpp | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/ndb/src/common/util/File.cpp b/ndb/src/common/util/File.cpp index 937b8c0fa59..e514ad8e122 100644 --- a/ndb/src/common/util/File.cpp +++ b/ndb/src/common/util/File.cpp @@ -28,29 +28,9 @@ bool File_class::exists(const char* aFileName) { - bool rc = true; -#ifdef USE_MY_STAT_STRUCT - struct my_stat stmp; -#else - struct stat stmp; -#endif - if (my_stat(aFileName, &stmp, MYF(0)) != 0) - { - rc = false; - } - - /* - File f; - if (!f.open(aFileName, "r")) - { - rc = (errno == ENOENT ? false : true); - } - else - { - f.close(); - } - */ - return rc; + MY_STAT stmp; + + return (my_stat(aFileName, &stmp, MYF(0))!=NULL); } long From 89e4e756c82f44fc03a3f649a60461779f1ed2fb Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Wed, 25 May 2005 10:55:21 +0200 Subject: [PATCH 24/98] - one more build fix for zlib.lib - added libpath to the mysql_test_run_new project files --- VC++Files/mysql-test/mysql_test_run_new.dsp | 4 ++-- VC++Files/mysql-test/mysql_test_run_new_ia64.dsp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/VC++Files/mysql-test/mysql_test_run_new.dsp b/VC++Files/mysql-test/mysql_test_run_new.dsp index 7fa01d22d11..467ff939502 100644 --- a/VC++Files/mysql-test/mysql_test_run_new.dsp +++ b/VC++Files/mysql-test/mysql_test_run_new.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:yes /debug /pdb:".\Debug\mysql_test_run_new.pdb" /pdbtype:sept /map:".\Debug\mysql_test_run_new.map" /subsystem:console -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib zlib.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:yes /debug /pdb:".\Debug\mysql_test_run_new.pdb" /pdbtype:sept /map:".\Debug\mysql_test_run_new.map" /subsystem:console +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib zlib.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:yes /libpath:"..\lib_debug\" /debug /pdb:".\Debug\mysql_test_run_new.pdb" /pdbtype:sept /map:".\Debug\mysql_test_run_new.map" /subsystem:console !ELSEIF "$(CFG)" == "mysql_test_run_new - Win32 Release" @@ -77,7 +77,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:no /pdb:".\Release\mysql_test_run_new.pdb" /pdbtype:sept /subsystem:console -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib zlib.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:no /pdb:".\Release\mysql_test_run_new.pdb" /pdbtype:sept /subsystem:console +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib zlib.lib /nologo /out:"..\mysql-test\mysql_test_run_new.exe" /incremental:no /libpath:"..\lib_release\" /pdb:".\Release\mysql_test_run_new.pdb" /pdbtype:sept /subsystem:console !ENDIF diff --git a/VC++Files/mysql-test/mysql_test_run_new_ia64.dsp b/VC++Files/mysql-test/mysql_test_run_new_ia64.dsp index d9bad07dad9..023b38bd3c6 100644 --- a/VC++Files/mysql-test/mysql_test_run_new_ia64.dsp +++ b/VC++Files/mysql-test/mysql_test_run_new_ia64.dsp @@ -54,7 +54,7 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /map /debug /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 # SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /map /debug /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /incremental:no /libpath:"..\lib_debug\" /map /debug /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 # SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "mysql_test_run_new - WinIA64 Release" @@ -83,7 +83,7 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 # SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 t kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 +# ADD LINK32 t kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib bufferoverflowU.lib zlib.lib /nologo /subsystem:console /libpath:"..\lib_release\" /out:"..\mysql-test\mysql_test_run_new.exe" /machine:IA64 # SUBTRACT LINK32 /pdb:none !ENDIF From 0ed2e577318c5121ac3509ce16b829f37f02a8ed Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 25 May 2005 11:10:10 +0200 Subject: [PATCH 25/98] Use one err file for each master --- mysql-test/mysql-test-run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 4fee560ee44..3f7e7d22200 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -1181,8 +1181,8 @@ start_master() $NOT_FIRST_MASTER_EXTRA_OPTS" fi - CUR_MYERR=$MASTER_MYERR - CUR_MYSOCK=$MASTER_MYSOCK + CUR_MYERR=$MASTER_MYERR$1 + CUR_MYSOCK=$MASTER_MYSOCK$1 # For embedded server we collect the server flags and return if [ "x$USE_EMBEDDED_SERVER" = "x1" ] ; then From 5a8cfc1541b8ba07e696f093e840bd2952a1adbe Mon Sep 17 00:00:00 2001 From: "marko@hundin.mysql.fi" <> Date: Wed, 25 May 2005 12:41:57 +0300 Subject: [PATCH 26/98] srv0start.c: innobase_shutdown_for_mysql(): Do very fast shutdown only if srv_fast_shutdown==2, not if srv_fast_shutdown!=0 (Bug #9673) --- innobase/srv/srv0start.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index e136aee43e8..541b73b831d 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -1736,7 +1736,7 @@ innobase_shutdown_for_mysql(void) " InnoDB: MySQL has requested a very fast shutdown without flushing " "the InnoDB buffer pool to data files. At the next mysqld startup " "InnoDB will do a crash recovery!\n"); - } + } #ifdef __NETWARE__ if(!panic_shutdown) @@ -1758,8 +1758,9 @@ innobase_shutdown_for_mysql(void) to die; all which counts is that we flushed the log; a 'very fast' shutdown is essentially a crash. */ - if (srv_fast_shutdown) - return((int) DB_SUCCESS); + if (srv_fast_shutdown == 2) { + return(DB_SUCCESS); + } /* All threads end up waiting for certain events. Put those events to the signaled state. Then the threads will exit themselves in From fb90aaa7b59d7437e9a76bc668e4b57e74d35afa Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Wed, 25 May 2005 12:56:47 +0300 Subject: [PATCH 27/98] Cleanup during code review Faster detection of wrong table names (like PRN) on windows --- include/my_sys.h | 1 + mysys/my_access.c | 120 ++++++++++++++++++++++++++++++++++++---------- mysys/my_fopen.c | 11 +++-- mysys/my_open.c | 13 +++-- sql/sql_lex.cc | 2 +- sql/sql_parse.cc | 5 +- sql/sql_repl.cc | 36 +++++++------- 7 files changed, 132 insertions(+), 56 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index a0a008056ae..70c410e66d8 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -578,6 +578,7 @@ extern int my_access(const char *path, int amode); #else #define my_access access #endif +extern int check_if_legal_filename(const char *path); #ifndef TERMINATE extern void TERMINATE(FILE *file); diff --git a/mysys/my_access.c b/mysys/my_access.c index 6a8887e42a6..28210bdfc7d 100644 --- a/mysys/my_access.c +++ b/mysys/my_access.c @@ -15,39 +15,107 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "mysys_priv.h" +#include #ifdef __WIN__ /* - * Check a file or path for accessability. - * - * SYNOPSIS - * file_access() - * pathpath to check - * amodemode to check - * - * DESCRIPTION - * This function wraps the normal access method because the access - * available in MSVCRT> +reports that filenames such as LPT1 and - * COM1 are valid (they are but should not be so for us). - * - * RETURN VALUES - * 0 ok - * -1 error - */ + Check a file or path for accessability. + + SYNOPSIS + file_access() + path Path to file + amode Access method + + DESCRIPTION + This function wraps the normal access method because the access + available in MSVCRT> +reports that filenames such as LPT1 and + COM1 are valid (they are but should not be so for us). + + RETURN VALUES + 0 ok + -1 error (We use -1 as my_access is mapped to access on other platforms) +*/ + int my_access(const char *path, int amode) { - WIN32_FILE_ATTRIBUTE_DATA fileinfo; - BOOL result; + WIN32_FILE_ATTRIBUTE_DATA fileinfo; + BOOL result; - result = GetFileAttributesEx(path, GetFileExInfoStandard, - &fileinfo); - if (! result) - return -1; - if ((fileinfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) && - (amode & 2)) - return -1; - return 0; + result= GetFileAttributesEx(path, GetFileExInfoStandard, &fileinfo); + if (! result || + (fileinfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) && (amode & W_OK)) + { + my_errno= errno= EACCES; + return -1; + } + return 0; } +#endif /* __WIN__ */ + +#if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) + +/* + List of file names that causes problem on windows + + NOTE that one can also not have file names of type CON.TXT +*/ + +static const char *reserved_names[]= +{ + "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", + "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", + "LPT7", "LPT8", "LPT9", "CLOCK$", + NullS +}; + +#define MAX_RESERVED_NAME_LENGTH 6 + +/* + Check if a path will access a reserverd file name that may cause problems + + SYNOPSIS + check_if_legal_filename + path Path to file + + RETURN + 0 ok + 1 reserved file name +*/ + +int check_if_legal_filename(const char *path) +{ + const char *end; + const char **reserved_name; + DBUG_ENTER("check_if_legal_filename"); + + path+= dirname_length(path); /* To start of filename */ + if (!(end= strchr(path, FN_EXTCHAR))) + end= strend(path); + if (path == end || (uint) (path - end) > MAX_RESERVED_NAME_LENGTH) + DBUG_RETURN(0); /* Simplify inner loop */ + + for (reserved_name= reserved_names; *reserved_name; reserved_name++) + { + const char *name= path; + while (name != end) + { + if (my_toupper(&my_charset_latin1, *path) != + my_toupper(&my_charset_latin1, *name)) + break; + if (name++ == end) + DBUG_RETURN(1); /* Found wrong path */ + } + } + DBUG_RETURN(0); +} #endif + + +#ifdef OS2 +int check_if_legal_filename(const char *path) +{ + return 0; +} +#endif /* OS2 */ diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c index 4310250bd0d..3c6f1b15384 100644 --- a/mysys/my_fopen.c +++ b/mysys/my_fopen.c @@ -39,13 +39,16 @@ FILE *my_fopen(const char *FileName, int Flags, myf MyFlags) very well */ #ifdef __WIN__ - if (! (Flags & O_CREAT) && my_access(FileName, F_OK)) - fd=0; + if (check_if_legal_filename(FileName)) + { + errno= EACCES; + fd= 0; + } else #endif { - make_ftype(type,Flags); - fd = fopen(FileName, type); + make_ftype(type,Flags); + fd = fopen(FileName, type); } if (fd != 0) diff --git a/mysys/my_open.c b/mysys/my_open.c index ea4d99c3e8c..7cf40b57403 100644 --- a/mysys/my_open.c +++ b/mysys/my_open.c @@ -47,12 +47,15 @@ File my_open(const char *FileName, int Flags, myf MyFlags) FileName, Flags, MyFlags)); #if defined(MSDOS) || defined(__WIN__) || defined(__EMX__) || defined(OS2) /* - if we are not creating, then we need to use my_access to make - sure the file exists since Windows doesn't handle files like - "com1.sym" very well + Check that we don't try to open or create a file name that may + cause problems for us in the future (like PRN) */ - if (! (Flags & O_CREAT) && my_access(FileName, F_OK)) - return -1; + if (check_if_legal_filename(FileName)) + { + errno= EACCES; + DBUG_RETURN(my_register_filename(-1, FileName, FILE_BY_OPEN, + EE_FILENOTFOUND, MyFlags)); + } if (Flags & O_SHARE) fd = sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO, MY_S_IREAD | MY_S_IWRITE); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index d6dcd9ce9ae..904b4675c74 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -420,7 +420,7 @@ static const uint signed_longlong_len=19; static const char *unsigned_longlong_str="18446744073709551615"; static const uint unsigned_longlong_len=20; -inline static uint int_token(const char *str,uint length) +static inline uint int_token(const char *str,uint length) { if (length < long_len) // quick normal case return NUM; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c5b429ec8fc..05838b340b8 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2819,8 +2819,8 @@ unsent_create_error: TABLE *table= tables->table; /* Skip first table, which is the table we are inserting in */ - lex->select_lex.table_list.first= (byte*) first_local_table->next; - tables= (TABLE_LIST *) lex->select_lex.table_list.first; + select_lex->table_list.first= (byte*) first_local_table->next; + tables= (TABLE_LIST *) select_lex->table_list.first; first_local_table->next= 0; if (!(res= mysql_prepare_insert(thd, tables, first_local_table, @@ -5389,6 +5389,7 @@ int multi_update_precheck(THD *thd, TABLE_LIST *tables) 1 error (message is sent to user) -1 error (message is not sent to user) */ + int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) { DBUG_ENTER("multi_delete_precheck"); diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 24b78bc9a3d..4249c9e1809 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -152,7 +152,8 @@ File open_binlog(IO_CACHE *log, const char *log_file_name, File file; DBUG_ENTER("open_binlog"); - if ((file = my_open(log_file_name, O_RDONLY | O_BINARY, MYF(MY_WME))) < 0) + if ((file = my_open(log_file_name, O_RDONLY | O_BINARY | O_SHARE, + MYF(MY_WME))) < 0) { sql_print_error("Failed to open log (\ file '%s', errno %d)", log_file_name, my_errno); @@ -1338,13 +1339,11 @@ int show_binlogs(THD* thd) { IO_CACHE *index_file; LOG_INFO cur; - IO_CACHE log; File file; - const char *errmsg= 0; - MY_STAT stat_area; char fname[FN_REFLEN]; List field_list; uint length; + int cur_dir_len; Protocol *protocol= thd->protocol; DBUG_ENTER("show_binlogs"); @@ -1364,34 +1363,35 @@ int show_binlogs(THD* thd) index_file=mysql_bin_log.get_index_file(); mysql_bin_log.get_current_log(&cur); - int cur_dir_len = dirname_length(cur.log_file_name); + cur_dir_len= dirname_length(cur.log_file_name); reinit_io_cache(index_file, READ_CACHE, (my_off_t) 0, 0, 0); /* The file ends with EOF or empty line */ while ((length=my_b_gets(index_file, fname, sizeof(fname))) > 1) { - fname[--length] = '\0'; /* remove the newline */ + int dir_len; + ulonglong file_length= 0; // Length if open fails + fname[--length] = '\0'; // remove the newline protocol->prepare_for_resend(); - int dir_len = dirname_length(fname); - protocol->store(fname + dir_len, length-dir_len, &my_charset_bin); - if(!(strncmp(fname+dir_len, cur.log_file_name+cur_dir_len, length-dir_len))) + dir_len= dirname_length(fname); + length-= dir_len; + protocol->store(fname + dir_len, length, &my_charset_bin); + + if (!(strncmp(fname+dir_len, cur.log_file_name+cur_dir_len, length))) + file_length= cur.pos; /* The active log, use the active position */ + else { - /* this is the active log, use the active position */ - protocol->store((ulonglong) cur.pos); - } else { /* this is an old log, open it and find the size */ - if ((file=open_binlog(&log, fname+dir_len, &errmsg)) >= 0) + if ((file= my_open(fname+dir_len, O_RDONLY | O_SHARE | O_BINARY, + MYF(0))) >= 0) { - protocol->store((ulonglong) my_b_filelength(&log)); - end_io_cache(&log); + file_length= (ulonglong) my_seek(file, 0L, MY_SEEK_END, MYF(0)); my_close(file, MYF(0)); - } else { - /* the file wasn't openable, but 0 is an invalid value anyway */ - protocol->store((ulonglong) 0); } } + protocol->store(file_length); if (protocol->write()) goto err; } From b763679f1c040ac21ac6e58e5272a5f53167af1d Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com" <> Date: Wed, 25 May 2005 19:11:36 +0500 Subject: [PATCH 28/98] WL#2286 - Compile MySQL w/YASSL support Merge with latest yaSSL, fix compilation error for SSE2 processors. --- extra/yassl/include/yassl_int.hpp | 6 ++++-- extra/yassl/src/log.cpp | 6 +++--- extra/yassl/src/yassl_int.cpp | 9 +++++---- extra/yassl/taocrypt/include/integer.hpp | 2 +- extra/yassl/taocrypt/src/integer.cpp | 3 +++ 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/extra/yassl/include/yassl_int.hpp b/extra/yassl/include/yassl_int.hpp index c9168254907..876f730a07d 100644 --- a/extra/yassl/include/yassl_int.hpp +++ b/extra/yassl/include/yassl_int.hpp @@ -122,7 +122,8 @@ public: friend sslFactory& GetSSL_Factory(); // singleton creator private: - static sslFactory instance; + static sslFactory instance_; + sslFactory(const sslFactory&); // hide copy sslFactory& operator=(const sslFactory&); // and assign }; @@ -207,9 +208,10 @@ public: friend Sessions& GetSessions(); // singleton creator private: + static Sessions instance_; + Sessions(const Sessions&); // hide copy Sessions& operator=(const Sessions&); // and assign - static Sessions instance; }; diff --git a/extra/yassl/src/log.cpp b/extra/yassl/src/log.cpp index eb4776d3d19..19072a5e09c 100644 --- a/extra/yassl/src/log.cpp +++ b/extra/yassl/src/log.cpp @@ -26,9 +26,9 @@ #include "log.hpp" #ifdef YASSL_LOG - #include - #include - #include + #include + #include + #include #endif diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp index f32a8420b98..718871a598b 100644 --- a/extra/yassl/src/yassl_int.cpp +++ b/extra/yassl/src/yassl_int.cpp @@ -1324,18 +1324,19 @@ SSL_SESSION::~SSL_SESSION() } -Sessions Sessions::instance; // simple singleton +Sessions Sessions::instance_; // simple singleton Sessions& GetSessions() { - return Sessions::instance; + return Sessions::instance_; } -sslFactory sslFactory::instance; + +sslFactory sslFactory::instance_; // simple singleton sslFactory& GetSSL_Factory() { - return sslFactory::instance; + return sslFactory::instance_; } diff --git a/extra/yassl/taocrypt/include/integer.hpp b/extra/yassl/taocrypt/include/integer.hpp index 6b1984e46ed..e9e4a7218bd 100644 --- a/extra/yassl/taocrypt/include/integer.hpp +++ b/extra/yassl/taocrypt/include/integer.hpp @@ -251,11 +251,11 @@ public: private: friend class ModularArithmetic; friend class MontgomeryRepresentation; - Integer(word value, unsigned int length); static const Integer zero; static const Integer one; static const Integer two; + Integer(word value, unsigned int length); int PositiveCompare(const Integer& t) const; friend void PositiveAdd(Integer& sum, const Integer& a, const Integer& b); diff --git a/extra/yassl/taocrypt/src/integer.cpp b/extra/yassl/taocrypt/src/integer.cpp index 37cfe374451..b6a1b72a41f 100644 --- a/extra/yassl/taocrypt/src/integer.cpp +++ b/extra/yassl/taocrypt/src/integer.cpp @@ -3948,6 +3948,9 @@ Integer CRT(const Integer &xp, const Integer &p, const Integer &xq, #ifdef __GNUC__ template unsigned int DivideThreeWordsByTwo(unsigned int*, unsigned int, unsigned int, DWord*); +#if defined(SSE2_INTRINSICS_AVAILABLE) +template AlignedAllocator::pointer StdReallocate >(AlignedAllocator&, unsigned int*, AlignedAllocator::size_type, AlignedAllocator::size_type, bool); +#endif #endif } // namespace From 0d121fe01ac1e784a43bf0833ecab17aac702e64 Mon Sep 17 00:00:00 2001 From: "joerg@mysql.com" <> Date: Wed, 25 May 2005 16:24:07 +0200 Subject: [PATCH 29/98] Added a missing "make clean" to the RPM "spec" file which had caused the original 4.1.12 RPMs to be broken. (bug#10674, bug#10681) --- support-files/mysql.spec.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 8b880c32051..2354b44f4fa 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -299,6 +299,9 @@ fi (cd libmysql/.libs; tar cf $RBR/shared-libs.tar *.so*) (cd libmysql_r/.libs; tar rf $RBR/shared-libs.tar *.so*) +# Now clean up +make clean + # RPM:s destroys Makefile.in files, so we generate them here # aclocal; autoheader; aclocal; automake; autoconf # (cd innobase && aclocal && autoheader && aclocal && automake && autoconf) @@ -584,6 +587,10 @@ fi # itself - note that they must be ordered by date (important when # merging BK trees) %changelog +* Wed May 25 2005 Joerg Bruehe + +- Added a "make clean" between separate calls to "BuildMySQL". + * Wed Apr 13 2005 Lenz Grimmer - removed the MySQL manual files (html/ps/texi) - they have been removed From 5f8f947f343f54d6a03a687ed8bbbf2dd56ceea7 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Wed, 25 May 2005 18:33:32 +0300 Subject: [PATCH 30/98] Cleanup's during review Added ASSERT() to detect wrongly packed fields --- sql/field.h | 10 ++++++---- sql/opt_range.cc | 40 +++++++++++++++++++--------------------- sql/sql_base.cc | 4 ++-- sql/sql_insert.cc | 7 ++++--- sql/sql_select.cc | 11 ++++------- sql/unireg.cc | 9 ++++++--- 6 files changed, 41 insertions(+), 40 deletions(-) diff --git a/sql/field.h b/sql/field.h index f68a2327dff..d58746b6068 100644 --- a/sql/field.h +++ b/sql/field.h @@ -439,10 +439,12 @@ public: /* The maximum number of decimal digits can be stored */ uint precision; uint bin_size; - /* Constructors take max_length of the field as a parameter - not the */ - /* precision as the number of decimal digits allowed */ - /* So for example we need to count length from precision handling */ - /* CREATE TABLE ( DECIMAL(x,y)) */ + /* + Constructors take max_length of the field as a parameter - not the + precision as the number of decimal digits allowed. + So for example we need to count length from precision handling + CREATE TABLE ( DECIMAL(x,y)) + */ Field_new_decimal(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ca3f5c5af87..0aa0468fc36 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3307,32 +3307,35 @@ QUICK_SELECT_I *TRP_ROR_UNION::make_quick(PARAM *param, /* - Build a SEL_TREE for <> predicate + Build a SEL_TREE for <> or NOT BETWEEN predicate SYNOPSIS get_ne_mm_tree() param PARAM from SQL_SELECT::test_quick_select cond_func item for the predicate field field in the predicate - value constant in the predicate + lt_value constant that field should be smaller + gt_value constant that field should be greaterr cmp_type compare type for the field RETURN - Pointer to tree built tree + # Pointer to tree built tree + 0 on error */ static SEL_TREE *get_ne_mm_tree(PARAM *param, Item_func *cond_func, - Field *field, Item *value, + Field *field, + Item *lt_value, Item *gt_value, Item_result cmp_type) { - SEL_TREE *tree= 0; + SEL_TREE *tree; tree= get_mm_parts(param, cond_func, field, Item_func::LT_FUNC, - value, cmp_type); + lt_value, cmp_type); if (tree) { tree= tree_or(param, tree, get_mm_parts(param, cond_func, field, Item_func::GT_FUNC, - value, cmp_type)); + gt_value, cmp_type)); } return tree; } @@ -3365,21 +3368,14 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func, switch (cond_func->functype()) { case Item_func::NE_FUNC: - tree= get_ne_mm_tree(param, cond_func, field, value, cmp_type); + tree= get_ne_mm_tree(param, cond_func, field, value, value, cmp_type); break; case Item_func::BETWEEN: if (inv) { - tree= get_mm_parts(param, cond_func, field, Item_func::LT_FUNC, - cond_func->arguments()[1],cmp_type); - if (tree) - { - tree= tree_or(param, tree, get_mm_parts(param, cond_func, field, - Item_func::GT_FUNC, - cond_func->arguments()[2], - cmp_type)); - } + tree= get_ne_mm_tree(param, cond_func, field, cond_func->arguments()[1], + cond_func->arguments()[2], cmp_type); } else { @@ -3402,7 +3398,8 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func, if (inv) { tree= get_ne_mm_tree(param, cond_func, field, - func->arguments()[1], cmp_type); + func->arguments()[1], func->arguments()[1], + cmp_type); if (tree) { Item **arg, **end; @@ -3410,7 +3407,7 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func, arg < end ; arg++) { tree= tree_and(param, tree, get_ne_mm_tree(param, cond_func, field, - *arg, cmp_type)); + *arg, *arg, cmp_type)); } } } @@ -3523,17 +3520,18 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) Item_func *cond_func= (Item_func*) cond; if (cond_func->functype() == Item_func::NOT_FUNC) { + /* Optimize NOT BETWEEN and NOT IN */ Item *arg= cond_func->arguments()[0]; if (arg->type() == Item::FUNC_ITEM) { cond_func= (Item_func*) arg; if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE) DBUG_RETURN(0); - inv= TRUE; + inv= TRUE; } else DBUG_RETURN(0); - } + } else if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE) DBUG_RETURN(0); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 29d9a7bf9c4..f5c4889cfe4 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1607,9 +1607,9 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, trying to discover the table at the same time. */ if (discover_retry_count++ != 0) - goto err; + goto err; if (ha_create_table_from_engine(thd, db, name, TRUE) != 0) - goto err; + goto err; mysql_reset_errors(thd, 1); // Clear warnings thd->clear_error(); // Clear error message diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 0bd9099ede1..ff07588c468 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -872,9 +872,10 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) if (info->handle_duplicates == DUP_UPDATE) { int res= 0; - /* we don't check for other UNIQUE keys - the first row - that matches, is updated. If update causes a conflict again, - an error is returned + /* + We don't check for other UNIQUE keys - the first row + that matches, is updated. If update causes a conflict again, + an error is returned */ DBUG_ASSERT(table->insert_values != NULL); store_record(table,insert_values); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 26e8b398844..3b4db62d1f4 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2825,17 +2825,14 @@ add_key_fields(KEY_FIELD **key_fields,uint *and_level, if (cond_func->functype() == Item_func::NOT_FUNC) { Item *item= cond_func->arguments()[0]; - /* - At this moment all NOT before simple comparison predicates - are eliminated. NOT IN and NOT BETWEEN are treated similar - IN and BETWEEN respectively. + /* + At this moment all NOT before simple comparison predicates + are eliminated. NOT IN and NOT BETWEEN are treated similar + IN and BETWEEN respectively. */ if (item->type() == Item::FUNC_ITEM && ((Item_func *) item)->select_optimize() == Item_func::OPTIMIZE_KEY) - { add_key_fields(key_fields,and_level,item,usable_tables); - return; - } return; } switch (cond_func->select_optimize()) { diff --git a/sql/unireg.cc b/sql/unireg.cc index 57d9fd07e51..123079291c2 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -73,6 +73,7 @@ bool mysql_create_frm(THD *thd, my_string file_name, handler *db_file) { uint reclength,info_length,screens,key_info_length,maxlength; + ulong key_buff_length; File file; ulong filepos, data_offset; uchar fileinfo[64],forminfo[288],*keybuff; @@ -119,7 +120,7 @@ bool mysql_create_frm(THD *thd, my_string file_name, DBUG_RETURN(1); } - uint key_buff_length=keys*(7+NAME_LEN+MAX_REF_PARTS*9)+16; + key_buff_length= uint4korr(fileinfo+47); keybuff=(uchar*) my_malloc(key_buff_length, MYF(0)); key_info_length= pack_keys(keybuff, keys, key_info, data_offset); VOID(get_form_pos(file,fileinfo,&formnames)); @@ -128,7 +129,6 @@ bool mysql_create_frm(THD *thd, my_string file_name, maxlength=(uint) next_io_size((ulong) (uint2korr(forminfo)+1000)); int2store(forminfo+2,maxlength); int4store(fileinfo+10,(ulong) (filepos+maxlength)); - int4store(fileinfo+47,key_buff_length); fileinfo[26]= (uchar) test((create_info->max_rows == 1) && (create_info->min_rows == 1) && (keys == 0)); int2store(fileinfo+28,key_info_length); @@ -411,7 +411,8 @@ static bool pack_header(uchar *forminfo, enum db_type table_type, DBUG_RETURN(1); } - totlength=reclength=0L; + totlength= 0L; + reclength= data_offset; no_empty=int_count=int_parts=int_length=time_stamp_pos=null_fields= com_length=0; n_length=2L; @@ -440,6 +441,8 @@ static bool pack_header(uchar *forminfo, enum db_type table_type, !time_stamp_pos) time_stamp_pos= (uint) field->offset+ (uint) data_offset + 1; length=field->pack_length; + /* Ensure we don't have any bugs when generating offsets */ + DBUG_ASSERT(reclength == field->offset + data_offset); if ((uint) field->offset+ (uint) data_offset+ length > reclength) reclength=(uint) (field->offset+ data_offset + length); n_length+= (ulong) strlen(field->field_name)+1; From cb7cd3322253e52602ae839923a89fafd65edb39 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Wed, 25 May 2005 18:33:36 +0300 Subject: [PATCH 31/98] Fix that we can read tables with the 'older' decimal format used in 5.0.3 & 5.0.4 We will however give a warning when opening such a table that users should use ALTER TABLE ... FORCE to fix the table. In future release we will fix that REPAIR TABLE will be able to handle this case --- sql/sql_lex.h | 1 + sql/sql_table.cc | 17 ++++++++++++-- sql/sql_yacc.yy | 4 ++++ sql/table.cc | 59 +++++++++++++++++++++++++++++++++++++++++++++--- sql/table.h | 2 +- 5 files changed, 77 insertions(+), 6 deletions(-) diff --git a/sql/sql_lex.h b/sql/sql_lex.h index fffb8ff9ae6..269f8b295f9 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -635,6 +635,7 @@ typedef class st_select_lex SELECT_LEX; #define ALTER_CHANGE_COLUMN_DEFAULT 256 #define ALTER_KEYS_ONOFF 512 #define ALTER_CONVERT 1024 +#define ALTER_FORCE 2048 typedef struct st_alter_info { diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4ddef3fc653..f44d3191375 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2202,12 +2202,14 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, if ((table->table->db_stat & HA_READ_ONLY) && open_for_modify) { char buff[FN_REFLEN + MYSQL_ERRMSG_SIZE]; + uint length; protocol->prepare_for_resend(); protocol->store(table_name, system_charset_info); protocol->store(operator_name, system_charset_info); protocol->store("error", 5, system_charset_info); - my_snprintf(buff, sizeof(buff), ER(ER_OPEN_AS_READONLY), table_name); - protocol->store(buff, system_charset_info); + length= my_snprintf(buff, sizeof(buff), ER(ER_OPEN_AS_READONLY), + table_name); + protocol->store(buff, length, system_charset_info); close_thread_tables(thd); table->table=0; // For query cache if (protocol->write()) @@ -2238,6 +2240,17 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, open_for_modify= 0; } + if (table->table->s->crashed && operator_func == &handler::check) + { + protocol->prepare_for_resend(); + protocol->store(table_name, system_charset_info); + protocol->store(operator_name, system_charset_info); + protocol->store("warning", 7, system_charset_info); + protocol->store("Table is marked as crashed", 26, system_charset_info); + if (protocol->write()) + goto err; + } + result_code = (table->table->file->*operator_func)(thd, check_opt); send_result: diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index f4af0dd1ded..8a37bfebccc 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3512,6 +3512,10 @@ alter_list_item: LEX *lex=Lex; lex->alter_info.flags|= ALTER_OPTIONS; } + | FORCE_SYM + { + Lex->alter_info.flags|= ALTER_FORCE; + } | order_clause { LEX *lex=Lex; diff --git a/sql/table.cc b/sql/table.cc index d3ba4056571..7755217532b 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -166,6 +166,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, share->db_type= ha_checktype((enum db_type) (uint) *(head+3)); share->db_create_options= db_create_options=uint2korr(head+30); share->db_options_in_use= share->db_create_options; + share->mysql_version= uint4korr(head+51); null_field_first= 0; if (!head[32]) // New frm file in 3.23 { @@ -572,6 +573,29 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, error= 4; goto err; /* purecov: inspected */ } +#ifndef TO_BE_DELETED_ON_PRODUCTION + if (field_type == FIELD_TYPE_NEWDECIMAL && !share->mysql_version) + { + /* + Fix pack length of old decimal values from 5.0.3 -> 5.0.4 + The difference is that in the old version we stored precision + in the .frm table while we now store the display_length + */ + Field_new_decimal *dec_field= (Field_new_decimal*) reg_field; + dec_field->bin_size= my_decimal_get_binary_size(field_length, + dec_field->dec); + dec_field->precision= field_length; + dec_field->field_length= + my_decimal_precision_to_length(field_length, dec_field->dec, + dec_field->unsigned_flag); + sql_print_error("Found incompatible DECIMAL field '%s' in %s; Please do \"ALTER TABLE '%s' FORCE\" to fix it!", dec_field->field_name, name, share->table_name); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_CRASHED_ON_USAGE, + "Found incompatible DECIMAL field '%s' in %s; Please do \"ALTER TABLE '%s' FORCE\" to fix it!", dec_field->field_name, name, share->table_name); + share->crashed= 1; // Marker for CHECK TABLE + } +#endif + reg_field->comment=comment; if (field_type == FIELD_TYPE_BIT && !f_bit_as_char(pack_flag)) { @@ -712,6 +736,28 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, } if (field->key_length() != key_part->length) { +#ifndef TO_BE_DELETED_ON_PRODUCTION + if (field->type() == FIELD_TYPE_NEWDECIMAL) + { + /* + Fix a fatal error in decimal key handling that causes crashes + on Innodb. We fix it by reducing the key length so that + InnoDB never gets a too big key when searching. + This allows the end user to do an ALTER TABLE to fix the + error. + */ + keyinfo->key_length-= (key_part->length - field->key_length()); + key_part->store_length-= (key_part->length - field->key_length()); + key_part->length= field->key_length(); + sql_print_error("Found wrong key definition in %s; Please do \"ALTER TABLE '%s' FORCE \" to fix it!", name, share->table_name); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_CRASHED_ON_USAGE, + "Found wrong key definition in %s; Please do \"ALTER TABLE '%s' FORCE\" to fix it!", name, share->table_name); + + share->crashed= 1; // Marker for CHECK TABLE + goto to_be_deleted; + } +#endif key_part->key_part_flag|= HA_PART_KEY_SEG; if (!(field->flags & BLOB_FLAG)) { // Create a new field @@ -720,6 +766,9 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, field->field_length=key_part->length; } } + + to_be_deleted: + /* If the field can be NULL, don't optimize away the test key_part_column = expression from the WHERE clause @@ -1298,7 +1347,6 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo, HA_CREATE_INFO *create_info, uint keys) { register File file; - uint key_length; ulong length; char fill[IO_SIZE]; int create_flags= O_RDWR | O_TRUNC; @@ -1321,6 +1369,8 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo, if ((file= my_create(name, CREATE_MODE, create_flags, MYF(MY_WME))) >= 0) { + uint key_length, tmp_key_length; + uint tmp; bzero((char*) fileinfo,64); /* header */ fileinfo[0]=(uchar) 254; @@ -1333,8 +1383,8 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo, key_length=keys*(7+NAME_LEN+MAX_REF_PARTS*9)+16; length=(ulong) next_io_size((ulong) (IO_SIZE+key_length+reclength)); int4store(fileinfo+10,length); - if (key_length > 0xffff) key_length=0xffff; - int2store(fileinfo+14,key_length); + tmp_key_length= (key_length < 0xffff) ? key_length : 0xffff; + int2store(fileinfo+14,tmp_key_length); int2store(fileinfo+16,reclength); int4store(fileinfo+18,create_info->max_rows); int4store(fileinfo+22,create_info->min_rows); @@ -1350,6 +1400,9 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo, fileinfo[41]= (uchar) create_info->raid_type; fileinfo[42]= (uchar) create_info->raid_chunks; int4store(fileinfo+43,create_info->raid_chunksize); + int4store(fileinfo+47, key_length); + tmp= MYSQL_VERSION_ID; // Store to avoid warning from int4store + int4store(fileinfo+51, tmp); bzero(fill,IO_SIZE); for (; length > IO_SIZE ; length-= IO_SIZE) { diff --git a/sql/table.h b/sql/table.h index 2e397ff95bf..8043429999b 100644 --- a/sql/table.h +++ b/sql/table.h @@ -126,7 +126,7 @@ typedef struct st_table_share key_map keys_for_keyread; ulong avg_row_length; /* create information */ ulong raid_chunksize; - ulong version, flush_version; + ulong version, flush_version, mysql_version; ulong timestamp_offset; /* Set to offset+1 of record */ ulong reclength; /* Recordlength */ From 264de67fc606af9aea193696290a8ad401369cc3 Mon Sep 17 00:00:00 2001 From: "tulin@mysql.com" <> Date: Wed, 25 May 2005 17:54:36 +0200 Subject: [PATCH 32/98] Bug #10838 CREATE TABLE produces strange DEFAULT value --- mysql-test/r/bugs.result | 138 +++++++++++++++++++++++++++++++++++++++ mysql-test/t/bugs.test | 85 ++++++++++++++++++++++++ sql/unireg.cc | 7 +- 3 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 mysql-test/r/bugs.result create mode 100644 mysql-test/t/bugs.test diff --git a/mysql-test/r/bugs.result b/mysql-test/r/bugs.result new file mode 100644 index 00000000000..7db20c2b096 --- /dev/null +++ b/mysql-test/r/bugs.result @@ -0,0 +1,138 @@ +drop table if exists t1,t2,t3,t4,t5,t6; +drop database if exists mysqltest; +CREATE TABLE t1 (a varchar(30) binary NOT NULL DEFAULT ' ', +b varchar(1) binary NOT NULL DEFAULT ' ', +c varchar(4) binary NOT NULL DEFAULT '0000', +d tinyblob NULL, +e tinyblob NULL, +f tinyblob NULL, +g tinyblob NULL, +h tinyblob NULL, +i tinyblob NULL, +j tinyblob NULL, +k tinyblob NULL, +l tinyblob NULL, +m tinyblob NULL, +n tinyblob NULL, +o tinyblob NULL, +p tinyblob NULL, +q varchar(30) binary NOT NULL DEFAULT ' ', +r varchar(30) binary NOT NULL DEFAULT ' ', +s tinyblob NULL, +t varchar(4) binary NOT NULL DEFAULT ' ', +u varchar(1) binary NOT NULL DEFAULT ' ', +v varchar(30) binary NOT NULL DEFAULT ' ', +w varchar(30) binary NOT NULL DEFAULT ' ', +x tinyblob NULL, +y varchar(5) binary NOT NULL DEFAULT ' ', +z varchar(20) binary NOT NULL DEFAULT ' ', +a1 varchar(30) binary NOT NULL DEFAULT ' ', +b1 tinyblob NULL) +ENGINE=InnoDB DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(30) collate latin1_bin NOT NULL default ' ', + `b` varchar(1) collate latin1_bin NOT NULL default ' ', + `c` varchar(4) collate latin1_bin NOT NULL default '0000', + `d` tinyblob, + `e` tinyblob, + `f` tinyblob, + `g` tinyblob, + `h` tinyblob, + `i` tinyblob, + `j` tinyblob, + `k` tinyblob, + `l` tinyblob, + `m` tinyblob, + `n` tinyblob, + `o` tinyblob, + `p` tinyblob, + `q` varchar(30) collate latin1_bin NOT NULL default ' ', + `r` varchar(30) collate latin1_bin NOT NULL default ' ', + `s` tinyblob, + `t` varchar(4) collate latin1_bin NOT NULL default ' ', + `u` varchar(1) collate latin1_bin NOT NULL default ' ', + `v` varchar(30) collate latin1_bin NOT NULL default ' ', + `w` varchar(30) collate latin1_bin NOT NULL default ' ', + `x` tinyblob, + `y` varchar(5) collate latin1_bin NOT NULL default ' ', + `z` varchar(20) collate latin1_bin NOT NULL default ' ', + `a1` varchar(30) collate latin1_bin NOT NULL default ' ', + `b1` tinyblob +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin +INSERT into t1 (b) values ('1'); +SHOW WARNINGS; +Level Code Message +SELECT * from t1; +a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1 + 1 0000 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +CREATE TABLE t2 (a varchar(30) binary NOT NULL DEFAULT ' ', +b varchar(1) binary NOT NULL DEFAULT ' ', +c varchar(4) binary NOT NULL DEFAULT '0000', +d tinyblob NULL, +e tinyblob NULL, +f tinyblob NULL, +g tinyblob NULL, +h tinyblob NULL, +i tinyblob NULL, +j tinyblob NULL, +k tinyblob NULL, +l tinyblob NULL, +m tinyblob NULL, +n tinyblob NULL, +o tinyblob NULL, +p tinyblob NULL, +q varchar(30) binary NOT NULL DEFAULT ' ', +r varchar(30) binary NOT NULL DEFAULT ' ', +s tinyblob NULL, +t varchar(4) binary NOT NULL DEFAULT ' ', +u varchar(1) binary NOT NULL DEFAULT ' ', +v varchar(30) binary NOT NULL DEFAULT ' ', +w varchar(30) binary NOT NULL DEFAULT ' ', +x tinyblob NULL, +y varchar(5) binary NOT NULL DEFAULT ' ', +z varchar(20) binary NOT NULL DEFAULT ' ', +a1 varchar(30) binary NOT NULL DEFAULT ' ', +b1 tinyblob NULL) +ENGINE=MyISAM DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(30) collate latin1_bin NOT NULL default ' ', + `b` varchar(1) collate latin1_bin NOT NULL default ' ', + `c` varchar(4) collate latin1_bin NOT NULL default '0000', + `d` tinyblob, + `e` tinyblob, + `f` tinyblob, + `g` tinyblob, + `h` tinyblob, + `i` tinyblob, + `j` tinyblob, + `k` tinyblob, + `l` tinyblob, + `m` tinyblob, + `n` tinyblob, + `o` tinyblob, + `p` tinyblob, + `q` varchar(30) collate latin1_bin NOT NULL default ' ', + `r` varchar(30) collate latin1_bin NOT NULL default ' ', + `s` tinyblob, + `t` varchar(4) collate latin1_bin NOT NULL default ' ', + `u` varchar(1) collate latin1_bin NOT NULL default ' ', + `v` varchar(30) collate latin1_bin NOT NULL default ' ', + `w` varchar(30) collate latin1_bin NOT NULL default ' ', + `x` tinyblob, + `y` varchar(5) collate latin1_bin NOT NULL default ' ', + `z` varchar(20) collate latin1_bin NOT NULL default ' ', + `a1` varchar(30) collate latin1_bin NOT NULL default ' ', + `b1` tinyblob +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin +INSERT into t2 (b) values ('1'); +SHOW WARNINGS; +Level Code Message +SELECT * from t2; +a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1 + 1 0000 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +drop table t1; +drop table t2; diff --git a/mysql-test/t/bugs.test b/mysql-test/t/bugs.test new file mode 100644 index 00000000000..3b842c06561 --- /dev/null +++ b/mysql-test/t/bugs.test @@ -0,0 +1,85 @@ +# +# test of already fixed bugs +# +--disable_warnings +drop table if exists t1,t2,t3,t4,t5,t6; +drop database if exists mysqltest; +--enable_warnings + +# +# Bug 10838 +# Insert causes warnings for no default values and corrupts tables +# +CREATE TABLE t1 (a varchar(30) binary NOT NULL DEFAULT ' ', + b varchar(1) binary NOT NULL DEFAULT ' ', + c varchar(4) binary NOT NULL DEFAULT '0000', + d tinyblob NULL, + e tinyblob NULL, + f tinyblob NULL, + g tinyblob NULL, + h tinyblob NULL, + i tinyblob NULL, + j tinyblob NULL, + k tinyblob NULL, + l tinyblob NULL, + m tinyblob NULL, + n tinyblob NULL, + o tinyblob NULL, + p tinyblob NULL, + q varchar(30) binary NOT NULL DEFAULT ' ', + r varchar(30) binary NOT NULL DEFAULT ' ', + s tinyblob NULL, + t varchar(4) binary NOT NULL DEFAULT ' ', + u varchar(1) binary NOT NULL DEFAULT ' ', + v varchar(30) binary NOT NULL DEFAULT ' ', + w varchar(30) binary NOT NULL DEFAULT ' ', + x tinyblob NULL, + y varchar(5) binary NOT NULL DEFAULT ' ', + z varchar(20) binary NOT NULL DEFAULT ' ', + a1 varchar(30) binary NOT NULL DEFAULT ' ', + b1 tinyblob NULL) +ENGINE=InnoDB DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin; + +SHOW CREATE TABLE t1; +INSERT into t1 (b) values ('1'); +SHOW WARNINGS; +SELECT * from t1; + +CREATE TABLE t2 (a varchar(30) binary NOT NULL DEFAULT ' ', + b varchar(1) binary NOT NULL DEFAULT ' ', + c varchar(4) binary NOT NULL DEFAULT '0000', + d tinyblob NULL, + e tinyblob NULL, + f tinyblob NULL, + g tinyblob NULL, + h tinyblob NULL, + i tinyblob NULL, + j tinyblob NULL, + k tinyblob NULL, + l tinyblob NULL, + m tinyblob NULL, + n tinyblob NULL, + o tinyblob NULL, + p tinyblob NULL, + q varchar(30) binary NOT NULL DEFAULT ' ', + r varchar(30) binary NOT NULL DEFAULT ' ', + s tinyblob NULL, + t varchar(4) binary NOT NULL DEFAULT ' ', + u varchar(1) binary NOT NULL DEFAULT ' ', + v varchar(30) binary NOT NULL DEFAULT ' ', + w varchar(30) binary NOT NULL DEFAULT ' ', + x tinyblob NULL, + y varchar(5) binary NOT NULL DEFAULT ' ', + z varchar(20) binary NOT NULL DEFAULT ' ', + a1 varchar(30) binary NOT NULL DEFAULT ' ', + b1 tinyblob NULL) +ENGINE=MyISAM DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin; + +SHOW CREATE TABLE t2; +INSERT into t2 (b) values ('1'); +SHOW WARNINGS; +SELECT * from t2; + +drop table t1; +drop table t2; + diff --git a/sql/unireg.cc b/sql/unireg.cc index da463885f85..a5c5da6ec26 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -755,8 +755,11 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type, } DBUG_ASSERT(data_offset == ((null_count + 7) / 8)); - /* Fill not used startpos */ - if (null_count) + /* + We need to set the unused bits to 1. If the number of bits is a multiple + of 8 there are no unused bits. + */ + if (null_count & 7) *(null_pos + null_count / 8)|= ~(((uchar) 1 << (null_count & 7)) - 1); error=(int) my_write(file,(byte*) buff, (uint) reclength,MYF_RW); From 7daf98db15dc2e203171dd50a915cff8b8c0fac4 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Thu, 26 May 2005 00:18:24 +0300 Subject: [PATCH 33/98] Move function from header file to make it easier to debug --- sql/item.cc | 16 ++++++++++++++++ sql/item.h | 15 +-------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index 69b1b78a961..182aef4c94c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -297,6 +297,22 @@ longlong Item::val_int_from_decimal() } +void *Item::operator new(size_t size, Item *reuse, uint *rsize) +{ + if (reuse && size <= reuse->rsize) + { + reuse->cleanup(); + TRASH((void *)reuse, size); + if (rsize) + (*rsize)= reuse->rsize; + return (void *)reuse; + } + if (rsize) + (*rsize)= size; + return (void *)sql_alloc((uint)size); +} + + Item::Item(): rsize(0), name(0), orig_name(0), name_length(0), fixed(0), collation(&my_charset_bin, DERIVATION_COERCIBLE) diff --git a/sql/item.h b/sql/item.h index f8fe05cfdb2..18b419dd6d5 100644 --- a/sql/item.h +++ b/sql/item.h @@ -233,20 +233,7 @@ public: static void *operator new(size_t size, MEM_ROOT *mem_root) { return (void*) alloc_root(mem_root, (uint) size); } /* Special for SP local variable assignment - reusing slots */ - static void *operator new(size_t size, Item *reuse, uint *rsize) - { - if (reuse && size <= reuse->rsize) - { - reuse->cleanup(); - TRASH((void *)reuse, size); - if (rsize) - (*rsize)= reuse->rsize; - return (void *)reuse; - } - if (rsize) - (*rsize)= size; - return (void *)sql_alloc((uint)size); - } + static void *operator new(size_t size, Item *reuse, uint *rsize); static void operator delete(void *ptr,size_t size) { TRASH(ptr, size); } static void operator delete(void *ptr, MEM_ROOT *mem_root) {} From 5905598e164d75ade5acdccd4765fc6ef69ac746 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Wed, 25 May 2005 14:41:50 -0700 Subject: [PATCH 34/98] Fix MERGE tables on Microsoft Windows. This a backport of the fix from the main 5.0 tree. (Bug #10687) --- myisammrg/myrg_open.c | 4 +++- mysys/my_getwd.c | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c index 0dc2f4f9768..f9cdc2bb205 100644 --- a/myisammrg/myrg_open.c +++ b/myisammrg/myrg_open.c @@ -67,7 +67,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) while ((length=my_b_gets(&file,buff,FN_REFLEN-1))) { if ((end=buff+length)[-1] == '\n') - end[-1]='\0'; + *--end='\0'; if (!buff[0]) continue; /* Skip empty lines */ if (buff[0] == '#') @@ -86,6 +86,8 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) sizeof(name_buff)-1-dir_length)); VOID(cleanup_dirname(buff,name_buff)); } + else + fn_format(buff, buff, "", "", 0); if (!(isam=mi_open(buff,mode,(handle_locking?HA_OPEN_WAIT_IF_LOCKED:0)))) goto err; if (!m_info) /* First file */ diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c index 89f949eca27..5663ceaa60e 100644 --- a/mysys/my_getwd.c +++ b/mysys/my_getwd.c @@ -208,7 +208,10 @@ int test_if_hard_path(register const char *dir_name) my_bool has_path(const char *name) { - return test(strchr(name, FN_LIBCHAR)) + return test(strchr(name, FN_LIBCHAR)) +#if FN_LIBCHAR != '/' + || test(strchr(name,'/')) +#endif #ifdef FN_DEVCHAR || test(strchr(name, FN_DEVCHAR)) #endif From e2955a2f13f4feb74c23a955a7c67e0d90903c2f Mon Sep 17 00:00:00 2001 From: "kent@mysql.com" <> Date: Thu, 26 May 2005 02:07:13 +0200 Subject: [PATCH 35/98] init_db.sql: Updated test data in system tables --- mysql-test/lib/init_db.sql | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mysql-test/lib/init_db.sql b/mysql-test/lib/init_db.sql index 18699497b64..9671de49ca5 100644 --- a/mysql-test/lib/init_db.sql +++ b/mysql-test/lib/init_db.sql @@ -50,6 +50,9 @@ CREATE TABLE host ( Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin @@ -489,10 +492,11 @@ CREATE TABLE procs_priv ( Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, + Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, - Timestamp timestamp(14), Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, - PRIMARY KEY (Host,Db,User,Routine_name), + Timestamp timestamp(14), + PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin From aac55df4f40e2531b13b35e308c9fe5d00d2acae Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Wed, 25 May 2005 20:26:40 -0700 Subject: [PATCH 36/98] Fix table renaming to not lowercase table names for all storage engines when lower_case_table_names == 2, as it did previously for InnoDB and MEMORY. (Bug #9660) --- mysql-test/r/lowercase_table2.result | 12 +-- sql/sql_table.cc | 126 ++++++++++++++++----------- 2 files changed, 79 insertions(+), 59 deletions(-) diff --git a/mysql-test/r/lowercase_table2.result b/mysql-test/r/lowercase_table2.result index 8361b66817a..1015990df9a 100644 --- a/mysql-test/r/lowercase_table2.result +++ b/mysql-test/r/lowercase_table2.result @@ -72,7 +72,7 @@ T1 CREATE TABLE `T1` ( RENAME TABLE T1 TO T2; SHOW TABLES LIKE "T2"; Tables_in_test (T2) -t2 +T2 SELECT * FROM t2; a 1 @@ -83,25 +83,25 @@ t3 RENAME TABLE T3 TO T1; SHOW TABLES LIKE "T1"; Tables_in_test (T1) -t1 +T1 ALTER TABLE T1 add b int; SHOW TABLES LIKE "T1"; Tables_in_test (T1) -t1 +T1 ALTER TABLE T1 RENAME T2; SHOW TABLES LIKE "T2"; Tables_in_test (T2) -t2 +T2 LOCK TABLE T2 WRITE; ALTER TABLE T2 drop b; SHOW TABLES LIKE "T2"; Tables_in_test (T2) -t2 +T2 UNLOCK TABLES; RENAME TABLE T2 TO T1; SHOW TABLES LIKE "T1"; Tables_in_test (T1) -t1 +T1 SELECT * from T1; a 1 diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 67aade519f5..951f89c4917 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -40,6 +40,34 @@ static int copy_data_between_tables(TABLE *from,TABLE *to, uint order_num, ORDER *order, ha_rows *copied,ha_rows *deleted); + +/* + Build the path to a file for a table (or the base path that can + then have various extensions stuck on to it). + + SYNOPSIS + build_table_path() + buff Buffer to build the path into + bufflen sizeof(buff) + db Name of database + table Name of table + ext Filename extension + + RETURN + FALSE Always -- see usage in mysql_create_indexes() + */ + +static bool build_table_path(char *buff, size_t bufflen, const char *db, + const char *table, const char *ext) +{ + strxnmov(buff, bufflen-1, mysql_data_home, "/", db, "/", table, ext, + NullS); + unpack_filename(buff,buff); + return FALSE; +} + + + /* delete (drop) tables. @@ -214,8 +242,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, DBUG_RETURN(-1); alias= (lower_case_table_names == 2) ? table->alias : table->real_name; /* remove form file and isam files */ - strxmov(path, mysql_data_home, "/", db, "/", alias, reg_ext, NullS); - (void) unpack_filename(path,path); + build_table_path(path, sizeof(path), db, alias, reg_ext); } if (drop_temporary || (access(path,F_OK) && ha_create_table_from_engine(thd,db,alias,TRUE))) @@ -295,13 +322,10 @@ int quick_rm_table(enum db_type base,const char *db, { char path[FN_REFLEN]; int error=0; - my_snprintf(path, sizeof(path), "%s/%s/%s%s", - mysql_data_home, db, table_name, reg_ext); - unpack_filename(path,path); + build_table_path(path, sizeof(path), db, table_name, reg_ext); if (my_delete(path,MYF(0))) error=1; /* purecov: inspected */ - my_snprintf(path, sizeof(path), "%s/%s/%s", mysql_data_home, db, table_name); - unpack_filename(path,path); + build_table_path(path, sizeof(path), db, table_name, ""); return ha_delete_table(base,path) || error; } @@ -1299,11 +1323,9 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, if (!create_info->default_table_charset) { HA_CREATE_INFO db_info; - uint length; char path[FN_REFLEN]; - strxmov(path, mysql_data_home, "/", db, NullS); - length= unpack_dirname(path,path); // Convert if not unix - strmov(path+length, MY_DB_OPT_FILE); + /* Abuse build_table_path() to build the path to the db.opt file */ + build_table_path(path, sizeof(path), db, MY_DB_OPT_FILE, ""); load_db_opt(thd, path, &db_info); create_info->default_table_charset= db_info.default_table_charset; } @@ -1317,17 +1339,18 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, /* Check if table exists */ if (create_info->options & HA_LEX_CREATE_TMP_TABLE) { - my_snprintf(path, sizeof(path), "%s%s%lx_%lx_%x%s", - mysql_tmpdir, tmp_file_prefix, current_pid, thd->thread_id, - thd->tmp_table++, reg_ext); + char tmp_table_name[NAME_LEN+1]; + my_snprintf(tmp_table_name, sizeof(tmp_table_name), "%s%lx_%lx_%x", + tmp_file_prefix, current_pid, thd->thread_id, + thd->tmp_table++); if (lower_case_table_names) - my_casedn_str(files_charset_info, path); + my_casedn_str(files_charset_info, tmp_table_name); create_info->table_options|=HA_CREATE_DELAY_KEY_WRITE; + build_table_path(path, sizeof(path), db, tmp_table_name, reg_ext); } else - my_snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home, db, - alias, reg_ext); - unpack_filename(path,path); + build_table_path(path, sizeof(path), db, alias, reg_ext); + /* Check if table already exists */ if ((create_info->options & HA_LEX_CREATE_TMP_TABLE) && find_temporary_table(thd,db,table_name)) @@ -1560,37 +1583,42 @@ mysql_rename_table(enum db_type base, const char *new_db, const char *new_name) { - char from[FN_REFLEN], to[FN_REFLEN]; - char tmp_from[NAME_LEN+1], tmp_to[NAME_LEN+1]; + char from[FN_REFLEN], to[FN_REFLEN], lc_from[FN_REFLEN], lc_to[FN_REFLEN]; + char *from_base= from, *to_base= to; + char tmp_name[NAME_LEN+1]; handler *file=get_new_handler((TABLE*) 0, base); int error=0; DBUG_ENTER("mysql_rename_table"); + build_table_path(from, sizeof(from), old_db, old_name, ""); + build_table_path(to, sizeof(to), new_db, new_name, ""); + + /* + If lower_case_table_names == 2 (case-preserving but case-insensitive + file system) and the storage is not HA_FILE_BASED, we need to provide + a lowercase file name, but we leave the .frm in mixed case. + */ if (lower_case_table_names == 2 && !(file->table_flags() & HA_FILE_BASED)) { - /* Table handler expects to get all file names as lower case */ - strmov(tmp_from, old_name); - my_casedn_str(files_charset_info, tmp_from); - old_name= tmp_from; + strmov(tmp_name, old_name); + my_casedn_str(files_charset_info, tmp_name); + build_table_path(lc_from, sizeof(lc_from), old_db, tmp_name, ""); + from_base= lc_from; - strmov(tmp_to, new_name); - my_casedn_str(files_charset_info, tmp_to); - new_name= tmp_to; + strmov(tmp_name, new_name); + my_casedn_str(files_charset_info, tmp_name); + build_table_path(lc_to, sizeof(lc_to), new_db, tmp_name, ""); + to_base= lc_to; } - my_snprintf(from, sizeof(from), "%s/%s/%s", - mysql_data_home, old_db, old_name); - my_snprintf(to, sizeof(to), "%s/%s/%s", - mysql_data_home, new_db, new_name); - fn_format(from,from,"","",4); - fn_format(to,to, "","",4); - if (!(error=file->rename_table((const char*) from,(const char *) to))) + if (!(error=file->rename_table((const char*) from_base, + (const char *) to_base))) { if (rename_file_ext(from,to,reg_ext)) { error=my_errno; /* Restore old file name */ - file->rename_table((const char*) to,(const char *) from); + file->rename_table((const char*) to_base, (const char *) from_base); } } delete file; @@ -1768,8 +1796,8 @@ static int prepare_for_repair(THD* thd, TABLE_LIST *table_list, if (!(table= table_list->table)) /* if open_ltable failed */ { char name[FN_REFLEN]; - strxmov(name, mysql_data_home, "/", table_list->db, "/", - table_list->real_name, NullS); + build_table_path(name, sizeof(name), table_list->db, + table_list->real_name, ""); if (openfrm(name, "", 0, 0, 0, &tmp_table)) DBUG_RETURN(0); // Can't open frm file table= &tmp_table; @@ -2570,11 +2598,9 @@ int mysql_create_indexes(THD *thd, TABLE_LIST *table_list, List &keys) else { if (table->file->add_index(table, key_info_buffer, key_count)|| - (my_snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home, - table_list->db, (lower_case_table_names == 2) ? - table_list->alias: table_list->real_name, reg_ext) >= - (int) sizeof(path)) || - ! unpack_filename(path, path) || + build_table_path(path, sizeof(path), table_list->db, + (lower_case_table_names == 2) ? + table_list->alias : table_list->real_name, reg_ext) || mysql_create_frm(thd, path, &create_info, fields, key_count, key_info_buffer, table->file)) /* don't need to free((gptr) key_info_buffer);*/ @@ -2672,11 +2698,9 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list, keys, /*tmp_table*/ 0, db_options, table->file, key_info_buffer, key_count, /*select_field_count*/ 0)|| - (snprintf(path, sizeof(path), "%s/%s/%s%s", mysql_data_home, - table_list->db, (lower_case_table_names == 2)? - table_list->alias: table_list->real_name, reg_ext)>= - (int)sizeof(path))|| - ! unpack_filename(path, path)|| + build_table_path(path, sizeof(path), table_list->db, + (lower_case_table_names == 2) ? + table_list->alias : table_list->real_name, reg_ext) || mysql_create_frm(thd, path, &create_info, fields, key_count, key_info_buffer, table->file)) /*don't need to free((gptr) key_numbers);*/ @@ -3199,9 +3223,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, else { char path[FN_REFLEN]; - my_snprintf(path, sizeof(path), "%s/%s/%s", mysql_data_home, - new_db, tmp_name); - fn_format(path,path,"","",4); + build_table_path(path, sizeof(path), new_db, tmp_name, ""); new_table=open_temporary_table(thd, path, new_db, tmp_name,0); } if (!new_table) @@ -3406,9 +3428,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, shutdown. */ char path[FN_REFLEN]; - my_snprintf(path, sizeof(path), "%s/%s/%s", mysql_data_home, - new_db, table_name); - fn_format(path,path,"","",4); + build_table_path(path, sizeof(path), new_db, table_name); table=open_temporary_table(thd, path, new_db, tmp_name,0); if (table) { From f3cc29e93b08f56d9c4fe7fae32fa5217a005f25 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 26 May 2005 11:36:01 +0200 Subject: [PATCH 37/98] Fix compiler warning --- ndb/src/common/debugger/SignalLoggerManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/src/common/debugger/SignalLoggerManager.cpp b/ndb/src/common/debugger/SignalLoggerManager.cpp index 1f0bd8974e7..d8710d2058f 100644 --- a/ndb/src/common/debugger/SignalLoggerManager.cpp +++ b/ndb/src/common/debugger/SignalLoggerManager.cpp @@ -395,7 +395,7 @@ SignalLoggerManager::log(BlockNumber bno, const char * msg, ...) va_start(ap, msg); fprintf(outputStream, "%s: ", getBlockName(bno, "API")); vfprintf(outputStream, msg, ap); - fprintf(outputStream, "\n", msg); + fprintf(outputStream, "\n"); va_end(ap); } } From 83d430353ea7e95ad83807c7ba079a4eafbd2740 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 26 May 2005 12:09:14 +0200 Subject: [PATCH 38/98] Add ifdefs to control when "#pragma implementation" should be used Added some more ifdefs for "#pragma interface" --- client/sql_string.cc | 2 +- client/sql_string.h | 2 +- include/my_global.h | 5 +++++ mysys/raid.cc | 2 +- sql/field.cc | 2 +- sql/ha_berkeley.cc | 2 +- sql/ha_blackhole.cc | 2 +- sql/ha_heap.cc | 2 +- sql/ha_innodb.cc | 2 +- sql/ha_isam.cc | 2 +- sql/ha_isammrg.cc | 2 +- sql/ha_myisam.cc | 2 +- sql/ha_myisammrg.cc | 2 +- sql/ha_ndbcluster.cc | 2 +- sql/handler.cc | 2 +- sql/hash_filo.cc | 2 +- sql/item.cc | 2 +- sql/item_cmpfunc.cc | 2 +- sql/item_func.cc | 2 +- sql/item_geofunc.cc | 2 +- sql/item_strfunc.cc | 2 +- sql/item_subselect.cc | 2 +- sql/item_sum.cc | 2 +- sql/item_timefunc.cc | 2 +- sql/item_uniq.cc | 2 +- sql/item_uniq.h | 2 +- sql/log_event.cc | 2 +- sql/log_event.h | 2 +- sql/opt_range.cc | 2 +- sql/procedure.cc | 2 +- sql/protocol.cc | 2 +- sql/protocol_cursor.cc | 2 +- sql/set_var.cc | 2 +- sql/sql_analyse.cc | 2 +- sql/sql_analyse.h | 2 +- sql/sql_class.cc | 2 +- sql/sql_crypt.cc | 2 +- sql/sql_crypt.h | 2 +- sql/sql_list.cc | 2 +- sql/sql_map.cc | 2 +- sql/sql_map.h | 2 +- sql/sql_olap.cc | 2 +- sql/sql_select.cc | 2 +- sql/sql_string.cc | 2 +- sql/sql_udf.cc | 2 +- sql/tztime.cc | 2 +- 46 files changed, 50 insertions(+), 45 deletions(-) diff --git a/client/sql_string.cc b/client/sql_string.cc index 9dcf19dad1d..690997152f1 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -16,7 +16,7 @@ /* This file is originally from the mysql distribution. Coded by monty */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/client/sql_string.h b/client/sql_string.h index aec40466d2b..fd6d3ef59d9 100644 --- a/client/sql_string.h +++ b/client/sql_string.h @@ -16,7 +16,7 @@ /* This file is originally from the mysql distribution. Coded by monty */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/include/my_global.h b/include/my_global.h index f059d603976..0f6d9ac13c6 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -48,6 +48,11 @@ #define USE_PRAGMA_INTERFACE #endif +/* Determine when to use "#pragma implementation" */ +#if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ < 3) +#define USE_PRAGMA_IMPLEMENTATION +#endif + #if defined(i386) && !defined(__i386__) #define __i386__ #endif diff --git a/mysys/raid.cc b/mysys/raid.cc index 0b688464fb3..62587c438ca 100644 --- a/mysys/raid.cc +++ b/mysys/raid.cc @@ -70,7 +70,7 @@ tonu@mysql.com & monty@mysql.com */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/field.cc b/sql/field.cc index d73257a673f..adb0368384e 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -19,7 +19,7 @@ ** This file implements classes defined in field.h *****************************************************************************/ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 626201a38a6..05cad23b176 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -47,7 +47,7 @@ */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_blackhole.cc b/sql/ha_blackhole.cc index c9c94b3a9d7..59b3f7102b5 100644 --- a/sql/ha_blackhole.cc +++ b/sql/ha_blackhole.cc @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index 033fe86720e..d584c33f061 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 2d2a8f2c3b4..bb3c359ccdb 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -28,7 +28,7 @@ have disables the InnoDB inlining in this file. */ in Windows? */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_isam.cc b/sql/ha_isam.cc index 9de532fa7b0..31e9236460f 100644 --- a/sql/ha_isam.cc +++ b/sql/ha_isam.cc @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_isammrg.cc b/sql/ha_isammrg.cc index 367607eef19..c0e6f665f08 100644 --- a/sql/ha_isammrg.cc +++ b/sql/ha_isammrg.cc @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 7ddb7ca25ed..d8608c6a599 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index 7a5d4fcf0a1..9ba853c49d0 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 53706b4a9ba..eaa0473df1b 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -20,7 +20,7 @@ NDB Cluster */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/handler.cc b/sql/handler.cc index f174f51514e..f14564b6629 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -17,7 +17,7 @@ /* Handler-calling-functions */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/hash_filo.cc b/sql/hash_filo.cc index b85f8054f10..ec200768222 100644 --- a/sql/hash_filo.cc +++ b/sql/hash_filo.cc @@ -20,7 +20,7 @@ ** to usage. */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item.cc b/sql/item.cc index 59785813566..98aeeaa4c99 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 8498ab4800e..337ac949d35 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -17,7 +17,7 @@ /* This file defines all compare functions */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_func.cc b/sql/item_func.cc index 05b76eb1604..3c50e750b41 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -17,7 +17,7 @@ /* This file defines all numerical functions */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index 2f00416bddf..c58a9e434c7 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -17,7 +17,7 @@ /* This file defines all spatial functions */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index baba4d9b786..5ca5caf6bdf 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -20,7 +20,7 @@ ** (This shouldn't be needed) */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 301740c50ef..2e4c70ecd5f 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -22,7 +22,7 @@ SUBSELECT TODO: (sql_select.h/sql_select.cc) */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_sum.cc b/sql/item_sum.cc index dd4cda4ff91..fb88fca9a2d 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -17,7 +17,7 @@ /* Sum functions (COUNT, MIN...) */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 23cd9c7ced2..a3cf69035f3 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -17,7 +17,7 @@ /* This file defines all time functions */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_uniq.cc b/sql/item_uniq.cc index 88e0cbbc0e6..0c757c0e3a3 100644 --- a/sql/item_uniq.cc +++ b/sql/item_uniq.cc @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* Compability file */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation #endif diff --git a/sql/item_uniq.h b/sql/item_uniq.h index 5582537bdbb..b7e00f9f080 100644 --- a/sql/item_uniq.h +++ b/sql/item_uniq.h @@ -16,7 +16,7 @@ /* Compability file ; This file only contains dummy functions */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface #endif diff --git a/sql/log_event.cc b/sql/log_event.cc index 8a949b81fc1..f2287857d37 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -16,7 +16,7 @@ #ifndef MYSQL_CLIENT -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif #include "mysql_priv.h" diff --git a/sql/log_event.h b/sql/log_event.h index f848f2ae1b9..7ae4e863fc2 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -22,7 +22,7 @@ #undef write // remove pthread.h macro definition, conflict with write() class member #endif -#if defined(__GNUC__) && !defined(MYSQL_CLIENT) +#if defined(USE_PRAGMA_INTERFACE) && !defined(MYSQL_CLIENT) #pragma interface /* gcc class implementation */ #endif diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 33223b83894..bd1befb436f 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -23,7 +23,7 @@ */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/procedure.cc b/sql/procedure.cc index 7779f5ce085..a0042dd879e 100644 --- a/sql/procedure.cc +++ b/sql/procedure.cc @@ -17,7 +17,7 @@ /* Procedures (functions with changes output of select) */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/protocol.cc b/sql/protocol.cc index 91061426f04..6a17ae2f95b 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -19,7 +19,7 @@ The actual communction is handled by the net_xxx functions in net_serv.cc */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc index 5f35552c562..b225e06ed32 100644 --- a/sql/protocol_cursor.cc +++ b/sql/protocol_cursor.cc @@ -19,7 +19,7 @@ The actual communction is handled by the net_xxx functions in net_serv.cc */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/set_var.cc b/sql/set_var.cc index 9f63188c28a..3d3ba6d6ab7 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -48,7 +48,7 @@ new attribute. */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 7ac9a0866df..fb5d0eb0a3f 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -23,7 +23,7 @@ ** - type set is out of optimization yet */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_analyse.h b/sql/sql_analyse.h index 3d1cffecaef..8523b05a1de 100644 --- a/sql/sql_analyse.h +++ b/sql/sql_analyse.h @@ -17,7 +17,7 @@ /* Analyse database */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sql_class.cc b/sql/sql_class.cc index c20d5f79277..805db107370 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -22,7 +22,7 @@ ** *****************************************************************************/ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_crypt.cc b/sql/sql_crypt.cc index b0b8050e311..f21a109e95d 100644 --- a/sql/sql_crypt.cc +++ b/sql/sql_crypt.cc @@ -23,7 +23,7 @@ needs something like 'ssh'. */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_crypt.h b/sql/sql_crypt.h index 1b27f0a4d27..25bc2d29e1d 100644 --- a/sql/sql_crypt.h +++ b/sql/sql_crypt.h @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sql_list.cc b/sql/sql_list.cc index c99cfb8c918..d57a7dfe4e3 100644 --- a/sql/sql_list.cc +++ b/sql/sql_list.cc @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_map.cc b/sql/sql_map.cc index e7e24f957c6..aac44949d89 100644 --- a/sql/sql_map.cc +++ b/sql/sql_map.cc @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_map.h b/sql/sql_map.h index 632eb6e4f64..bfa6011ac54 100644 --- a/sql/sql_map.h +++ b/sql/sql_map.h @@ -17,7 +17,7 @@ /* interface for memory mapped files */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc index 46f1e6c156e..024abb6c74b 100644 --- a/sql/sql_olap.cc +++ b/sql/sql_olap.cc @@ -28,7 +28,7 @@ #ifdef DISABLED_UNTIL_REWRITTEN_IN_4_1 -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_select.cc b/sql/sql_select.cc index fb7f10abb52..7b27879ae28 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -17,7 +17,7 @@ /* mysql_select and join optimization */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_string.cc b/sql/sql_string.cc index c1701e7e9bf..ab2db4aaf53 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -16,7 +16,7 @@ /* This file is originally from the mysql distribution. Coded by monty */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 126d2e5d894..f5b4775ee0b 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -28,7 +28,7 @@ ** dynamic functions, so this shouldn't be a real problem. */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: implement sql_udf.h #endif diff --git a/sql/tztime.cc b/sql/tztime.cc index c45271966f9..8fac054c49c 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -20,7 +20,7 @@ (We will refer to this code as to elsie-code further.) */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif From 6c00006d2c4f0875054693fe9fc7a5a1fb6f75d6 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 26 May 2005 12:12:36 +0200 Subject: [PATCH 39/98] Fix icc compiler warning --- ndb/src/kernel/blocks/dbtux/Dbtux.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ndb/src/kernel/blocks/dbtux/Dbtux.hpp b/ndb/src/kernel/blocks/dbtux/Dbtux.hpp index 2c96271eb5d..3d78fccb780 100644 --- a/ndb/src/kernel/blocks/dbtux/Dbtux.hpp +++ b/ndb/src/kernel/blocks/dbtux/Dbtux.hpp @@ -342,7 +342,6 @@ private: * Complete metadata for one index. The array of attributes has * variable size. */ - struct DescEnt; friend struct DescEnt; struct DescEnt { DescHead m_descHead; From f39f049041db3a4db7bea247955b43687b48254d Mon Sep 17 00:00:00 2001 From: "joerg@mysql.com" <> Date: Thu, 26 May 2005 12:55:31 +0200 Subject: [PATCH 40/98] Merge --- mysql-test/t/select.test | 217 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 206 insertions(+), 11 deletions(-) diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 3877e67de41..b6132d23d02 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -9,7 +9,8 @@ --disable_warnings drop table if exists t1,t2,t3,t4; # The following may be left from older tests -drop table if exists t1_1,t1_2,t9_1,t9_2; +drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa; +drop view if exists v1; --enable_warnings CREATE TABLE t1 ( @@ -1764,9 +1765,9 @@ DO benchmark(100,1+1),1,1; # Bug #6449: do default; # ---error 1064 +--error ER_PARSE_ERROR do default; ---error 1054 +--error ER_BAD_FIELD_ERROR do foobar; # @@ -1792,7 +1793,10 @@ CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned defa INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL); CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) ENGINE=MyISAM; INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35); +# Disable PS becasue we get more warnings from PS than from normal execution +--disable_ps_protocol SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; +--enable_ps_protocol # Testing the same select with NULL's instead of invalid datetime values SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid; DROP TABLE t1,t2; @@ -1935,6 +1939,205 @@ EXPLAIN SELECT i FROM t1 WHERE i=1; DROP TABLE t1; +# +# Test case for bug 7520: a wrong cost of the index for a BLOB field +# + +CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); +CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); + +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; + +DROP TABLE t1, t2; + + +# +# Test case for bug 7098: substitution of a constant for a string field +# + +CREATE TABLE t1 ( city char(30) ); +INSERT INTO t1 VALUES ('London'); +INSERT INTO t1 VALUES ('Paris'); + +SELECT * FROM t1 WHERE city='London'; +SELECT * FROM t1 WHERE city='london'; +EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london'; +SELECT * FROM t1 WHERE city='London' AND city='london'; +EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; + +DROP TABLE t1; + +# +# Bug#7425 inconsistent sort order on unsigned columns result of substraction +# + +create table t1 (a int(11) unsigned, b int(11) unsigned); +insert into t1 values (1,0), (1,1), (1,2); +select a-b from t1 order by 1; +select a-b , (a-b < 0) from t1 order by 1; +select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; +select cast((a - b) as unsigned) from t1 order by 1; +drop table t1; + + +# +# Bug#8733 server accepts malformed query (multiply mentioned distinct) +# +create table t1 (a int(11)); +select all all * from t1; +select distinct distinct * from t1; +--error 1221 +select all distinct * from t1; +--error 1221 +select distinct all * from t1; +drop table t1; + +# + +# +# Test for Bug#8009, SELECT failed on bigint unsigned when using HEX +# + +CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); +INSERT INTO t1 VALUES (0x8000000000000000); +SELECT b FROM t1 WHERE b=0x8000000000000000; +DROP TABLE t1; +# Test for bug #6474 +# + +CREATE TABLE t1 ( +K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', +K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', +F2I4 int(11) NOT NULL default '0' +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +INSERT INTO t1 VALUES +('W%RT', '0100', 1), +('W-RT', '0100', 1), +('WART', '0100', 1), +('WART', '0200', 1), +('WERT', '0100', 2), +('WORT','0200', 2), +('WT', '0100', 2), +('W_RT', '0100', 2), +('WaRT', '0100', 3), +('WART', '0300', 3), +('WRT' , '0400', 3), +('WURM', '0500', 3), +('W%T', '0600', 4), +('WA%T', '0700', 4), +('WA_T', '0800', 4); + +SELECT K2C4, K4N4, F2I4 FROM t1 + WHERE K2C4 = 'WART' AND + (F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200')); + +SELECT K2C4, K4N4, F2I4 FROM t1 + WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200'); + +DROP TABLE t1; + +# +# Test case for bug 7520: a wrong cost of the index for a BLOB field +# + +CREATE TABLE t1 ( a BLOB, INDEX (a(20)) ); +CREATE TABLE t2 ( a BLOB, INDEX (a(20)) ); + +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +INSERT INTO t2 VALUES ('one'),('two'),('three'),('four'),('five'); + +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USE INDEX (a) ON t1.a=t2.a; +EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; + +DROP TABLE t1, t2; + + +# +# Test case for bug 7098: substitution of a constant for a string field +# + +CREATE TABLE t1 ( city char(30) ); +INSERT INTO t1 VALUES ('London'); +INSERT INTO t1 VALUES ('Paris'); + +SELECT * FROM t1 WHERE city='London'; +SELECT * FROM t1 WHERE city='london'; +EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london'; +SELECT * FROM t1 WHERE city='London' AND city='london'; +EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; +SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; + +DROP TABLE t1; + +# +# Bug#7425 inconsistent sort order on unsigned columns result of substraction +# + +create table t1 (a int(11) unsigned, b int(11) unsigned); +insert into t1 values (1,0), (1,1), (1,2); +select a-b from t1 order by 1; +select a-b , (a-b < 0) from t1 order by 1; +select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; +select cast((a - b) as unsigned) from t1 order by 1; +drop table t1; + +# +# Bug#8670 +# +create table t1 (a int, b int); +create table t2 like t1; +select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1; +select t1.a from ((t1 inner join t2 on t1.a=t2.a)) where t2.a=1; +select x.a, y.a, z.a from ( (t1 x inner join t2 y on x.a=y.a) inner join t2 z on y.a=z.a) WHERE x.a=1; +drop table t1,t2; + +# +# Bug#9820 +# + +create table t1 (s1 varchar(5)); +insert into t1 values ('Wall'); +select min(s1) from t1 group by s1 with rollup; +drop table t1; + +# +# Bug#9799 +# + +create table t1 (s1 int) engine=myisam; +insert into t1 values (0); +select avg(distinct s1) from t1 group by s1 with rollup; +drop table t1; + +# +# Bug#9800 +# + +create table t1 (s1 int); +insert into t1 values (null),(1); +select distinct avg(s1) as x from t1 group by s1 with rollup; +drop table t1; + + +# +# Bug#8733 server accepts malformed query (multiply mentioned distinct) +# +create table t1 (a int(11)); +select all all * from t1; +select distinct distinct * from t1; +--error 1221 +select all distinct * from t1; +--error 1221 +select distinct all * from t1; +drop table t1; + + # # Test case for bug 7520: a wrong cost of the index for a BLOB field # @@ -2052,11 +2255,3 @@ AND FK_firma_id = 2; drop table t1; -# -# Test for Bug#8009, SELECT failed on bigint unsigned when using HEX -# - -CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); -INSERT INTO t1 VALUES (0x8000000000000000); -SELECT b FROM t1 WHERE b=0x8000000000000000; -DROP TABLE t1; From 4572248a84d965f041a62d72cdaf3e03cbe0b7ad Mon Sep 17 00:00:00 2001 From: "joerg@mysql.com" <> Date: Thu, 26 May 2005 12:58:55 +0200 Subject: [PATCH 41/98] Correction of merge mishandling in 'client/client_priv.h'. --- client/client_priv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/client_priv.h b/client/client_priv.h index a2f652af273..c8aa7385276 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -49,5 +49,5 @@ enum options_client #ifdef HAVE_NDBCLUSTER_DB OPT_NDBCLUSTER, OPT_NDB_CONNECTSTRING, #endif - ,OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_DROP_DATABASE,OPT_DROP_DATABASE + OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE }; From 206c0ebbc3269869114177cdf89fe49150c6c5a1 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Thu, 26 May 2005 14:00:47 +0300 Subject: [PATCH 42/98] Moved detection of wrong decimal fields before decimal field was created to avoid ASSERT() for DECIMAL(1) --- sql/table.cc | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/sql/table.cc b/sql/table.cc index 7755217532b..db753b2ed1c 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -554,6 +554,26 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, unhex_type2(interval); } +#ifndef TO_BE_DELETED_ON_PRODUCTION + if (field_type == FIELD_TYPE_NEWDECIMAL && !share->mysql_version) + { + /* + Fix pack length of old decimal values from 5.0.3 -> 5.0.4 + The difference is that in the old version we stored precision + in the .frm table while we now store the display_length + */ + uint decimals= f_decimals(pack_flag); + field_length= my_decimal_precision_to_length(field_length, + decimals, + f_is_dec(pack_flag) == 0); + sql_print_error("Found incompatible DECIMAL field '%s' in %s; Please do \"ALTER TABLE '%s' FORCE\" to fix it!", share->fieldnames.type_names[i], name, share->table_name); + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_CRASHED_ON_USAGE, + "Found incompatible DECIMAL field '%s' in %s; Please do \"ALTER TABLE '%s' FORCE\" to fix it!", share->fieldnames.type_names[i], name, share->table_name); + share->crashed= 1; // Marker for CHECK TABLE + } +#endif + *field_ptr=reg_field= make_field(record+recpos, (uint32) field_length, @@ -573,28 +593,6 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, error= 4; goto err; /* purecov: inspected */ } -#ifndef TO_BE_DELETED_ON_PRODUCTION - if (field_type == FIELD_TYPE_NEWDECIMAL && !share->mysql_version) - { - /* - Fix pack length of old decimal values from 5.0.3 -> 5.0.4 - The difference is that in the old version we stored precision - in the .frm table while we now store the display_length - */ - Field_new_decimal *dec_field= (Field_new_decimal*) reg_field; - dec_field->bin_size= my_decimal_get_binary_size(field_length, - dec_field->dec); - dec_field->precision= field_length; - dec_field->field_length= - my_decimal_precision_to_length(field_length, dec_field->dec, - dec_field->unsigned_flag); - sql_print_error("Found incompatible DECIMAL field '%s' in %s; Please do \"ALTER TABLE '%s' FORCE\" to fix it!", dec_field->field_name, name, share->table_name); - push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, - ER_CRASHED_ON_USAGE, - "Found incompatible DECIMAL field '%s' in %s; Please do \"ALTER TABLE '%s' FORCE\" to fix it!", dec_field->field_name, name, share->table_name); - share->crashed= 1; // Marker for CHECK TABLE - } -#endif reg_field->comment=comment; if (field_type == FIELD_TYPE_BIT && !f_bit_as_char(pack_flag)) From 2d5b96798fe3125e77bf214c2c189d66dd309cfd Mon Sep 17 00:00:00 2001 From: "marko@hundin.mysql.fi" <> Date: Thu, 26 May 2005 15:42:24 +0300 Subject: [PATCH 43/98] InnoDB: Check all referencing tables in DROP DATABASE (Bug #10335). --- innobase/row/row0mysql.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index a915200161f..86557315b71 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -2143,6 +2143,7 @@ row_drop_table_for_mysql( foreign = UT_LIST_GET_FIRST(table->referenced_list); while (foreign && foreign->foreign_table == table) { + check_next_foreign: foreign = UT_LIST_GET_NEXT(referenced_list, foreign); } @@ -2171,6 +2172,10 @@ row_drop_table_for_mysql( goto funct_exit; } + if (foreign && trx->check_foreigns) { + goto check_next_foreign; + } + if (table->n_mysql_handles_opened > 0) { ibool added; From 95edcc48af58f9778cdf2d3f7b50ca443adcce0e Mon Sep 17 00:00:00 2001 From: "joerg@mysql.com" <> Date: Thu, 26 May 2005 15:21:01 +0200 Subject: [PATCH 44/98] Added a missing "make clean" to the RPM "spec" file which had caused the original 4.1.12 RPMs to be broken. (bug#10674, bug#10681) --- support-files/mysql.spec.sh | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 5e7499c5e5c..dd25862004a 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -16,8 +16,8 @@ Name: MySQL Summary: MySQL: a very fast and reliable SQL database server Group: Applications/Databases -Summary(pt_BR): MySQL: Um servidor SQL rápido e confiável. -Group(pt_BR): Aplicações/Banco_de_Dados +Summary(pt_BR): MySQL: Um servidor SQL rápido e confiável. +Group(pt_BR): Aplicações/Banco_de_Dados Version: @MYSQL_NO_DASH_VERSION@ Release: %{release} License: GPL @@ -57,8 +57,8 @@ documentation and the manual for more information. Release: %{release} Summary: MySQL: a very fast and reliable SQL database server Group: Applications/Databases -Summary(pt_BR): MySQL: Um servidor SQL rápido e confiável. -Group(pt_BR): Aplicações/Banco_de_Dados +Summary(pt_BR): MySQL: Um servidor SQL rápido e confiável. +Group(pt_BR): Aplicações/Banco_de_Dados Requires: fileutils sh-utils Provides: msqlormysql mysql-server mysql MySQL Obsoletes: MySQL mysql mysql-server @@ -92,7 +92,7 @@ Release: %{release} Summary: MySQL - Client Group: Applications/Databases Summary(pt_BR): MySQL - Cliente -Group(pt_BR): Aplicações/Banco_de_Dados +Group(pt_BR): Aplicações/Banco_de_Dados Obsoletes: mysql-client Provides: mysql-client @@ -102,7 +102,7 @@ This package contains the standard MySQL clients and administration tools. %{see_base} %description client -l pt_BR -Este pacote contém os clientes padrão para o MySQL. +Este pacote contém os clientes padrão para o MySQL. %package ndb-storage Release: %{release} @@ -156,8 +156,8 @@ Release: %{release} Requires: %{name}-client perl-DBI perl Summary: MySQL - Benchmarks and test system Group: Applications/Databases -Summary(pt_BR): MySQL - Medições de desempenho -Group(pt_BR): Aplicações/Banco_de_Dados +Summary(pt_BR): MySQL - Medições de desempenho +Group(pt_BR): Aplicações/Banco_de_Dados Provides: mysql-bench Obsoletes: mysql-bench @@ -167,14 +167,14 @@ This package contains MySQL benchmark scripts and data. %{see_base} %description bench -l pt_BR -Este pacote contém medições de desempenho de scripts e dados do MySQL. +Este pacote contém medições de desempenho de scripts e dados do MySQL. %package devel Release: %{release} Summary: MySQL - Development header files and libraries Group: Applications/Databases -Summary(pt_BR): MySQL - Medições de desempenho -Group(pt_BR): Aplicações/Banco_de_Dados +Summary(pt_BR): MySQL - Medições de desempenho +Group(pt_BR): Aplicações/Banco_de_Dados Provides: mysql-devel Obsoletes: mysql-devel @@ -185,8 +185,8 @@ necessary to develop MySQL client applications. %{see_base} %description devel -l pt_BR -Este pacote contém os arquivos de cabeçalho (header files) e bibliotecas -necessárias para desenvolver aplicações clientes do MySQL. +Este pacote contém os arquivos de cabeçalho (header files) e bibliotecas +necessárias para desenvolver aplicações clientes do MySQL. %package shared Release: %{release} @@ -226,8 +226,8 @@ Release: %{release} Requires: %{name}-devel Summary: MySQL - embedded library Group: Applications/Databases -Summary(pt_BR): MySQL - Medições de desempenho -Group(pt_BR): Aplicações/Banco_de_Dados +Summary(pt_BR): MySQL - Medições de desempenho +Group(pt_BR): Aplicações/Banco_de_Dados Obsoletes: mysql-embedded %description embedded @@ -364,6 +364,9 @@ fi (cd libmysql/.libs; tar cf $RBR/shared-libs.tar *.so*) (cd libmysql_r/.libs; tar rf $RBR/shared-libs.tar *.so*) +# Now clean up +make clean + # # Only link statically on our i386 build host (which has a specially # patched static glibc installed) - ia64 and x86_64 run glibc-2.3 (unpatched) @@ -686,6 +689,10 @@ fi # itself - note that they must be ordered by date (important when # merging BK trees) %changelog +* Wed May 25 2005 Joerg Bruehe + +- Added a "make clean" between separate calls to "BuildMySQL". + * Wed Apr 20 2005 Lenz Grimmer - Enabled the "blackhole" storage engine for the Max RPM From db2ce1edf6e1f7e322b573f01a86bd18d55f9b59 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Thu, 26 May 2005 17:30:12 +0300 Subject: [PATCH 45/98] fixed problem with long string results of expressions in UNIONS (BUG#10025) --- mysql-test/r/union.result | 14 ++++++++++++++ mysql-test/t/union.test | 11 +++++++++++ sql/item.cc | 4 ++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index c140ecd26e1..57dfd48b6bd 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1235,3 +1235,17 @@ show columns from t2; Field Type Null Key Default Extra a varchar(3) YES NULL drop table t2, t1; +CREATE TABLE t1 (a mediumtext); +CREATE TABLE t2 (b varchar(20)); +INSERT INTO t1 VALUES ('a'),('b'); +SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2; +left(a,100000000) +a +b +create table t3 SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2; +show create table t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `left(a,100000000)` longtext +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop tables t1,t2,t3; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index b0446e1ea4a..ffc7e718e9d 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -742,3 +742,14 @@ create table t2 select a from t1 union select c from t1; create table t2 select a from t1 union select b from t1; show columns from t2; drop table t2, t1; + +# +# correct conversion long string to TEXT (BUG#10025) +# +CREATE TABLE t1 (a mediumtext); +CREATE TABLE t2 (b varchar(20)); +INSERT INTO t1 VALUES ('a'),('b'); +SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2; +create table t3 SELECT left(a,100000000) FROM t1 UNION SELECT b FROM t2; +show create table t3; +drop tables t1,t2,t3; diff --git a/sql/item.cc b/sql/item.cc index 59785813566..8bc26c8c679 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3099,8 +3099,8 @@ Field *Item_type_holder::make_field_by_type(TABLE *table) enum_set_typelib, collation.collation); case MYSQL_TYPE_VAR_STRING: table->db_create_options|= HA_OPTION_PACK_RECORD; - return new Field_string(max_length, maybe_null, name, table, - collation.collation); + fld_type= MYSQL_TYPE_STRING; + break; default: break; } From 8401cd5d790c02d7ae67137e3a9df88cf06484fd Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 26 May 2005 16:44:46 +0200 Subject: [PATCH 46/98] BUG#9993 2 unexpected warnings when dropping a routine and --skip-grant-tables - Dont perform automatic privilege handling for stored procedures when server is started --skip-grant-tables - Renamed view_skip_grants to skip_grants and added test cases for this --- .../r/{view_skip_grants.result => skip_grants.result} | 4 ++++ ...w_skip_grants-master.opt => skip_grants-master.opt} | 0 .../t/{view_skip_grants.test => skip_grants.test} | 10 +++++++++- sql/mysql_priv.h | 2 +- sql/mysqld.cc | 3 ++- sql/sql_parse.cc | 4 ++-- 6 files changed, 18 insertions(+), 5 deletions(-) rename mysql-test/r/{view_skip_grants.result => skip_grants.result} (61%) rename mysql-test/t/{view_skip_grants-master.opt => skip_grants-master.opt} (100%) rename mysql-test/t/{view_skip_grants.test => skip_grants.test} (59%) diff --git a/mysql-test/r/view_skip_grants.result b/mysql-test/r/skip_grants.result similarity index 61% rename from mysql-test/r/view_skip_grants.result rename to mysql-test/r/skip_grants.result index 48cb9f2aa25..c0c20eb25be 100644 --- a/mysql-test/r/view_skip_grants.result +++ b/mysql-test/r/skip_grants.result @@ -1,6 +1,10 @@ drop table if exists t1,v1; drop view if exists t1,v1; +drop procedure if exists f1; use test; create table t1 (field1 INT); CREATE VIEW v1 AS SELECT field1 FROM t1; drop view v1; +drop table t1; +create procedure f1() select 1; +drop procedure f1; diff --git a/mysql-test/t/view_skip_grants-master.opt b/mysql-test/t/skip_grants-master.opt similarity index 100% rename from mysql-test/t/view_skip_grants-master.opt rename to mysql-test/t/skip_grants-master.opt diff --git a/mysql-test/t/view_skip_grants.test b/mysql-test/t/skip_grants.test similarity index 59% rename from mysql-test/t/view_skip_grants.test rename to mysql-test/t/skip_grants.test index bfbaec44eb1..99223fa4756 100644 --- a/mysql-test/t/view_skip_grants.test +++ b/mysql-test/t/skip_grants.test @@ -1,6 +1,7 @@ --disable_warnings drop table if exists t1,v1; drop view if exists t1,v1; +drop procedure if exists f1; --enable_warnings use test; @@ -11,4 +12,11 @@ create table t1 (field1 INT); CREATE VIEW v1 AS SELECT field1 FROM t1; drop view v1; -drop table t1 +drop table t1; + +# +# Test that we can create and drop procedure without warnings +# see bug#9993 +# +create procedure f1() select 1; +drop procedure f1; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 25490b04ab3..7e6a611de2f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1095,7 +1095,7 @@ extern my_bool opt_slave_compressed_protocol, use_temp_pool; extern my_bool opt_readonly, lower_case_file_system; extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs; extern my_bool opt_secure_auth; -extern my_bool sp_automatic_privileges; +extern my_bool sp_automatic_privileges, opt_noacl; extern my_bool opt_old_style_user_limits, trust_routine_creators; extern uint opt_crash_binlog_innodb; extern char *shared_memory_base_name, *mysqld_unix_port; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 84a041167f1..39b6931ffba 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -310,6 +310,7 @@ my_bool opt_old_style_user_limits= 0, trust_routine_creators= 0; changed). False otherwise. */ volatile bool mqh_used = 0; +my_bool opt_noacl; my_bool sp_automatic_privileges= 1; #ifdef HAVE_INITGROUPS @@ -445,7 +446,7 @@ char *master_ssl_ca, *master_ssl_capath, *master_ssl_cipher; /* Static variables */ static bool kill_in_progress, segfaulted; -static my_bool opt_do_pstack, opt_noacl, opt_bootstrap, opt_myisam_log; +static my_bool opt_do_pstack, opt_bootstrap, opt_myisam_log; static int cleanup_done; static ulong opt_specialflag, opt_myisam_block_size; static char *opt_logname, *opt_update_logname, *opt_binlog_index_name; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 47ac8d3afc1..4751e8b6aa7 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3982,7 +3982,7 @@ unsent_create_error: lex->sphead= 0; #ifndef NO_EMBEDDED_ACCESS_CHECKS /* only add privileges if really neccessary */ - if (sp_automatic_privileges && + if (sp_automatic_privileges && !opt_noacl && check_procedure_access(thd, DEFAULT_CREATE_PROC_ACLS, db, name, 1)) { @@ -4247,7 +4247,7 @@ unsent_create_error: if (check_procedure_access(thd, ALTER_PROC_ACL, db, name, 0)) goto error; #ifndef NO_EMBEDDED_ACCESS_CHECKS - if (sp_automatic_privileges && + if (sp_automatic_privileges && !opt_noacl && sp_revoke_privileges(thd, db, name)) { push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, From 76b25fc1943e8356db550838950f48dbe78a4ffc Mon Sep 17 00:00:00 2001 From: "joerg@mysql.com" <> Date: Thu, 26 May 2005 16:47:44 +0200 Subject: [PATCH 47/98] Corrected merge error in 'mysql-test/r/select.result': two test blocks inserted in wrong order. --- mysql-test/r/select.result | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 6e19fa09d1b..eaed7719673 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2423,6 +2423,12 @@ ERROR HY000: Incorrect usage of ALL and DISTINCT select distinct all * from t1; ERROR HY000: Incorrect usage of ALL and DISTINCT drop table t1; +CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); +INSERT INTO t1 VALUES (0x8000000000000000); +SELECT b FROM t1 WHERE b=0x8000000000000000; +b +9223372036854775808 +DROP TABLE t1; CREATE TABLE t1 ( K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', @@ -2676,9 +2682,3 @@ AND FK_firma_id = 2; COUNT(*) 0 drop table t1; -CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b)); -INSERT INTO t1 VALUES (0x8000000000000000); -SELECT b FROM t1 WHERE b=0x8000000000000000; -b -9223372036854775808 -DROP TABLE t1; From 1cc23599c2076bff209f54c17d7e297bb497e5b2 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Thu, 26 May 2005 10:01:26 -0700 Subject: [PATCH 48/98] Cleanups to patch for bug #9660 after review by Monty. --- sql/sql_table.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 951f89c4917..411fb420895 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -54,16 +54,16 @@ static int copy_data_between_tables(TABLE *from,TABLE *to, ext Filename extension RETURN - FALSE Always -- see usage in mysql_create_indexes() + 0 Error + # Size of path */ -static bool build_table_path(char *buff, size_t bufflen, const char *db, +static uint build_table_path(char *buff, size_t bufflen, const char *db, const char *table, const char *ext) { strxnmov(buff, bufflen-1, mysql_data_home, "/", db, "/", table, ext, NullS); - unpack_filename(buff,buff); - return FALSE; + return unpack_filename(buff,buff); } @@ -1611,14 +1611,13 @@ mysql_rename_table(enum db_type base, to_base= lc_to; } - if (!(error=file->rename_table((const char*) from_base, - (const char *) to_base))) + if (!(error=file->rename_table(from_base, to_base))) { if (rename_file_ext(from,to,reg_ext)) { error=my_errno; /* Restore old file name */ - file->rename_table((const char*) to_base, (const char *) from_base); + file->rename_table(to_base, from_base); } } delete file; @@ -2600,7 +2599,8 @@ int mysql_create_indexes(THD *thd, TABLE_LIST *table_list, List &keys) if (table->file->add_index(table, key_info_buffer, key_count)|| build_table_path(path, sizeof(path), table_list->db, (lower_case_table_names == 2) ? - table_list->alias : table_list->real_name, reg_ext) || + table_list->alias : table_list->real_name, + reg_ext) != 0 || mysql_create_frm(thd, path, &create_info, fields, key_count, key_info_buffer, table->file)) /* don't need to free((gptr) key_info_buffer);*/ @@ -2700,7 +2700,8 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list, /*select_field_count*/ 0)|| build_table_path(path, sizeof(path), table_list->db, (lower_case_table_names == 2) ? - table_list->alias : table_list->real_name, reg_ext) || + table_list->alias : table_list->real_name, + reg_ext) != 0 || mysql_create_frm(thd, path, &create_info, fields, key_count, key_info_buffer, table->file)) /*don't need to free((gptr) key_numbers);*/ From 3eca4bf22e0f7ce74f04d17cd332096af92e6dc2 Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Thu, 26 May 2005 20:36:14 +0200 Subject: [PATCH 49/98] Fixed BUG#9937: Crash on call to stored procedure. This only showed up on two known platforms, both ia64 (one HP-UX and one Linux wich icc). For some reason, they only get half the stack size they are supposed to have, which makes deep SP recursion overrun the stack before check_stack_overrun() is triggered. Also made som minor fixes in the check_stack_overrun() definition, supporting variable margins. No test case added, but the reason for the bug report was a failed existing test case on these machines, which now works. --- sql/item_cmpfunc.cc | 2 +- sql/item_func.cc | 10 ++-------- sql/item_subselect.cc | 2 +- sql/mysql_priv.h | 4 ++-- sql/mysqld.cc | 24 +++++++++++++++++++++--- sql/sp_head.cc | 6 ++---- sql/sql_parse.cc | 4 ++-- sql/table.cc | 2 +- 8 files changed, 32 insertions(+), 22 deletions(-) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 89897a9d74f..078fcb14ca3 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2321,7 +2321,7 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) */ and_tables_cache= ~(table_map) 0; - if (check_stack_overrun(thd, buff)) + if (check_stack_overrun(thd, STACK_MIN_SIZE)) return TRUE; // Fatal error flag is set! /* The following optimization reduces the depth of an AND-OR tree. diff --git a/sql/item_func.cc b/sql/item_func.cc index db2aa735b0e..68f1cc52cff 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -293,14 +293,11 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) { DBUG_ASSERT(fixed == 0); Item **arg,**arg_end; -#ifndef EMBEDDED_LIBRARY // Avoid compiler warning - char buff[STACK_BUFF_ALLOC]; // Max argument in function -#endif used_tables_cache= not_null_tables_cache= 0; const_item_cache=1; - if (check_stack_overrun(thd, buff)) + if (check_stack_overrun(thd, STACK_MIN_SIZE+STACK_BUFF_ALLOC)) return TRUE; // Fatal error if flag is set! if (arg_count) { // Print purify happy @@ -2567,12 +2564,9 @@ bool udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, uint arg_count, Item **arguments) { -#ifndef EMBEDDED_LIBRARY // Avoid compiler warning - char buff[STACK_BUFF_ALLOC]; // Max argument in function -#endif DBUG_ENTER("Item_udf_func::fix_fields"); - if (check_stack_overrun(thd, buff)) + if (check_stack_overrun(thd, STACK_MIN_SIZE+STACK_BUFF_ALLOC)) DBUG_RETURN(TRUE); // Fatal error flag is set! udf_func *tmp_udf=find_udf(u_d->name.str,(uint) u_d->name.length,1); diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 0fbcf32a83c..55eb44c3c55 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -138,7 +138,7 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) DBUG_ASSERT(fixed == 0); engine->set_thd((thd= thd_param)); - if (check_stack_overrun(thd, (gptr)&res)) + if (check_stack_overrun(thd, STACK_MIN_SIZE)) return TRUE; res= engine->prepare(); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 5d11a047a8f..71c41547fe7 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1078,7 +1078,7 @@ extern ulong max_connections,max_connect_errors, connect_timeout; extern ulong slave_net_timeout, slave_trans_retries; extern uint max_user_connections; extern ulong what_to_log,flush_time; -extern ulong query_buff_size, thread_stack,thread_stack_min; +extern ulong query_buff_size, thread_stack; extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit; extern ulong max_binlog_size, max_relay_log_size; extern ulong rpl_recovery_rank, thread_cache_size; @@ -1430,7 +1430,7 @@ inline int hexchar_to_int(char c) #ifndef EMBEDDED_LIBRARY extern "C" void unireg_abort(int exit_code); void kill_delayed_threads(void); -bool check_stack_overrun(THD *thd,char *dummy); +bool check_stack_overrun(THD *thd, long margin); #else #define unireg_abort(exit_code) DBUG_RETURN(exit_code) inline void kill_delayed_threads(void) {} diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8c5ce22f7a6..ef8a80a1d1c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -348,7 +348,7 @@ uint tc_heuristic_recover= 0; uint volatile thread_count, thread_running; ulong back_log, connect_timeout, concurrency; ulong server_id, thd_startup_options; -ulong table_cache_size, thread_stack, thread_stack_min, what_to_log; +ulong table_cache_size, thread_stack, what_to_log; ulong query_buff_size, slow_launch_time, slave_open_temp_tables; ulong open_files_limit, max_binlog_size, max_relay_log_size; ulong slave_net_timeout, slave_trans_retries; @@ -2090,7 +2090,13 @@ static void start_signal_handler(void) (void) pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); if (!(opt_specialflag & SPECIAL_NO_PRIOR)) my_pthread_attr_setprio(&thr_attr,INTERRUPT_PRIOR); +#if defined(__ia64__) || defined(__ia64) + /* Peculiar things with ia64 platforms - it seems we only have half the + stack size in reality, so we have to double it here */ + pthread_attr_setstacksize(&thr_attr,thread_stack*2); +#else pthread_attr_setstacksize(&thr_attr,thread_stack); +#endif #endif (void) pthread_mutex_lock(&LOCK_thread_count); @@ -3011,23 +3017,35 @@ int main(int argc, char **argv) init_signals(); if (!(opt_specialflag & SPECIAL_NO_PRIOR)) my_pthread_setprio(pthread_self(),CONNECT_PRIOR); +#if defined(__ia64__) || defined(__ia64) + /* Peculiar things with ia64 platforms - it seems we only have half the + stack size in reality, so we have to double it here */ + pthread_attr_setstacksize(&connection_attrib,thread_stack*2); +#else pthread_attr_setstacksize(&connection_attrib,thread_stack); +#endif #ifdef HAVE_PTHREAD_ATTR_GETSTACKSIZE { /* Retrieve used stack size; Needed for checking stack overflows */ size_t stack_size= 0; pthread_attr_getstacksize(&connection_attrib, &stack_size); +#if defined(__ia64__) || defined(__ia64) + stack_size/= 2; +#endif /* We must check if stack_size = 0 as Solaris 2.9 can return 0 here */ if (stack_size && stack_size < thread_stack) { if (global_system_variables.log_warnings) sql_print_warning("Asked for %ld thread stack, but got %ld", - thread_stack, stack_size); + thread_stack, stack_size); +#if defined(__ia64__) || defined(__ia64) + thread_stack= stack_size*2; +#else thread_stack= stack_size; +#endif } } #endif - thread_stack_min=thread_stack - STACK_MIN_SIZE; (void) thr_setconcurrency(concurrency); // 10 by default diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 988345694b2..f9aeb1e1f20 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -564,13 +564,11 @@ sp_head::execute(THD *thd) Item_change_list old_change_list; String old_packet; - -#ifndef EMBEDDED_LIBRARY - if (check_stack_overrun(thd, olddb)) + /* Use some extra margin for possible SP recursion and functions */ + if (check_stack_overrun(thd, 4*STACK_MIN_SIZE)) { DBUG_RETURN(-1); } -#endif dbchanged= FALSE; if (m_db.length && diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7078c8e7181..298ecc06d20 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4985,11 +4985,11 @@ long max_stack_used; #endif #ifndef EMBEDDED_LIBRARY -bool check_stack_overrun(THD *thd,char *buf __attribute__((unused))) +bool check_stack_overrun(THD *thd, long margin) { long stack_used; if ((stack_used=used_stack(thd->thread_stack,(char*) &stack_used)) >= - (long) thread_stack_min) + thread_stack - margin) { sprintf(errbuff[0],ER(ER_STACK_OVERRUN),stack_used,thread_stack); my_message(ER_STACK_OVERRUN,errbuff[0],MYF(0)); diff --git a/sql/table.cc b/sql/table.cc index db753b2ed1c..bc31a38f24a 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1815,7 +1815,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds, bool res= FALSE; DBUG_ENTER("st_table_list::setup_ancestor"); - if (check_stack_overrun(thd, (char *)&res)) + if (check_stack_overrun(thd, STACK_MIN_SIZE)) return TRUE; for (tbl= ancestor; tbl; tbl= tbl->next_local) From 41c8f4616014fc7c2d656950c53ea85d97e4db77 Mon Sep 17 00:00:00 2001 From: "sergefp@mysql.com" <> Date: Thu, 26 May 2005 20:54:02 +0200 Subject: [PATCH 50/98] Post-review fixes: rename SHOW_DOUBLE to SHOW_DOUBLE_STATUS --- sql/mysqld.cc | 2 +- sql/sql_show.cc | 2 +- sql/structs.h | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e45a61b0c04..b6e80402114 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5713,7 +5713,7 @@ struct show_var_st status_vars[]= { {"Key_reads", (char*) &dflt_key_cache_var.global_cache_read, SHOW_KEY_CACHE_LONG}, {"Key_write_requests", (char*) &dflt_key_cache_var.global_cache_w_requests, SHOW_KEY_CACHE_LONG}, {"Key_writes", (char*) &dflt_key_cache_var.global_cache_write, SHOW_KEY_CACHE_LONG}, - {"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE}, + {"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS}, {"Max_used_connections", (char*) &max_used_connections, SHOW_LONG}, #ifdef HAVE_NDBCLUSTER_DB {"Ndb_", (char*) &ndb_status_variables, SHOW_VARS}, diff --git a/sql/sql_show.cc b/sql/sql_show.cc index a5d12dffc4b..3d23e22c590 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1356,7 +1356,7 @@ static bool show_status_array(THD *thd, const char *wild, end= strend(pos); break; } - case SHOW_DOUBLE: + case SHOW_DOUBLE_STATUS: { value= ((char *) status_var + (ulong) value); end= buff + sprintf(buff, "%f", *(double*) value); diff --git a/sql/structs.h b/sql/structs.h index 7a70bfc0f4f..306089016bc 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -164,7 +164,8 @@ typedef struct st_known_date_time_format { enum SHOW_TYPE { SHOW_UNDEF, - SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR, SHOW_DOUBLE, + SHOW_LONG, SHOW_LONGLONG, SHOW_INT, SHOW_CHAR, SHOW_CHAR_PTR, + SHOW_DOUBLE_STATUS, SHOW_BOOL, SHOW_MY_BOOL, SHOW_OPENTABLES, SHOW_STARTTIME, SHOW_QUESTION, SHOW_LONG_CONST, SHOW_INT_CONST, SHOW_HAVE, SHOW_SYS, SHOW_HA_ROWS, SHOW_VARS, From 90f971ae2c17889ba89ccb5af017bd210a904428 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 26 May 2005 21:01:54 +0200 Subject: [PATCH 51/98] Include fix to function open_binlog from 4.1 - Add O_SHARE when opening file. --- sql/log.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/log.cc b/sql/log.cc index 91428cf41be..db592649d13 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -232,7 +232,8 @@ File open_binlog(IO_CACHE *log, const char *log_file_name, const char **errmsg) File file; DBUG_ENTER("open_binlog"); - if ((file = my_open(log_file_name, O_RDONLY | O_BINARY, MYF(MY_WME))) < 0) + if ((file = my_open(log_file_name, O_RDONLY | O_BINARY | O_SHARE, + MYF(MY_WME))) < 0) { sql_print_error("Failed to open log (file '%s', errno %d)", log_file_name, my_errno); From f8cb00640f06230f0d8f200a04ccd91d02bb8bd3 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Thu, 26 May 2005 23:33:20 +0300 Subject: [PATCH 52/98] Fix broken test case (after merge) --- mysql-test/r/union.result | 10 +++++----- mysql-test/t/union.test | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 22417136f67..daa0a428577 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1201,27 +1201,27 @@ concat('value is: ', @val) value is: 6 some text CREATE TABLE t1 ( -a ENUM('ä','ö','ü') character set utf8 not null default 'ü', +a ENUM('ä','ö','ü') character set utf8 not null default 'ü', b ENUM("one", "two") character set utf8, c ENUM("one", "two") ); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` enum('ä','ö','ü') character set utf8 NOT NULL default 'ü', + `a` enum('ä','ö','ü') character set utf8 NOT NULL default 'ü', `b` enum('one','two') character set utf8 default NULL, `c` enum('one','two') default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -insert into t1 values ('ä', 'one', 'one'), ('ö', 'two', 'one'), ('ü', NULL, NULL); +insert into t1 values ('ä', 'one', 'one'), ('ö', 'two', 'one'), ('ü', NULL, NULL); create table t2 select NULL union select a from t1; show columns from t2; Field Type Null Key Default Extra -NULL enum('ä','ö','ü') YES NULL +NULL enum('ä','ö','ü') YES NULL drop table t2; create table t2 select a from t1 union select NULL; show columns from t2; Field Type Null Key Default Extra -a enum('ä','ö','ü') YES NULL +a enum('ä','ö','ü') YES NULL drop table t2; create table t2 select a from t1 union select a from t1; show columns from t2; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 42cdf54544a..af548074aa9 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -740,12 +740,12 @@ select concat('value is: ', @val) union select 'some text'; # Enum merging test # CREATE TABLE t1 ( - a ENUM('ä','ö','ü') character set utf8 not null default 'ü', + a ENUM('ä','ö','ü') character set utf8 not null default 'ü', b ENUM("one", "two") character set utf8, c ENUM("one", "two") ); show create table t1; -insert into t1 values ('ä', 'one', 'one'), ('ö', 'two', 'one'), ('ü', NULL, NULL); +insert into t1 values ('ä', 'one', 'one'), ('ö', 'two', 'one'), ('ü', NULL, NULL); create table t2 select NULL union select a from t1; show columns from t2; drop table t2; From 8a77c6f7417771efc826bd0595ca414ead94d582 Mon Sep 17 00:00:00 2001 From: "tim@siva.hindu.god" <> Date: Fri, 27 May 2005 12:44:06 +1200 Subject: [PATCH 53/98] scripts/mysqld_safe.sh Only add --defaults-extra-file=$DATADIR/my.cnf if $DATADIR/my.cnf is readable. --- scripts/mysqld_safe.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 9ec573737bd..3a06c4d1fb5 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -114,7 +114,7 @@ then MY_BASEDIR_VERSION=$MY_PWD # Where bin, share and data are ledir=$MY_BASEDIR_VERSION/bin # Where mysqld is DATADIR=$MY_BASEDIR_VERSION/data - if test -z "$defaults" + if test -z "$defaults" -a -r "$DATADIR/my.cnf" then defaults="--defaults-extra-file=$DATADIR/my.cnf" fi From aa99b05be799e34e1756425a124e2023e8909f39 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 27 May 2005 12:01:41 +0200 Subject: [PATCH 54/98] Fix rpl_log and rpl_rotate_logs test result - Remove the expected warrnings when "show binary logs" are called on zero size binary log files. --- mysql-test/r/rpl_log.result | 4 ---- mysql-test/r/rpl_rotate_logs.result | 10 ---------- 2 files changed, 14 deletions(-) diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result index e150cf53585..5e0eec6305d 100644 --- a/mysql-test/r/rpl_log.result +++ b/mysql-test/r/rpl_log.result @@ -71,15 +71,11 @@ show binary logs; Log_name File_size master-bin.000001 0 master-bin.000002 510 -Warnings: -Error 29 File 'master-bin.000001' not found (Errcode: 2) start slave; show binary logs; Log_name File_size slave-bin.000001 0 slave-bin.000002 348 -Warnings: -Error 29 File 'slave-bin.000001' not found (Errcode: 2) show binlog events in 'slave-bin.000001' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 4 Format_desc 2 98 Server ver: VERSION, Binlog ver: 4 diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result index b9724386909..a6d3697987a 100644 --- a/mysql-test/r/rpl_rotate_logs.result +++ b/mysql-test/r/rpl_rotate_logs.result @@ -30,9 +30,6 @@ Log_name File_size master-bin.000001 0 master-bin.000002 0 master-bin.000003 98 -Warnings: -Error 29 File 'master-bin.000001' not found (Errcode: 2) -Error 29 File 'master-bin.000002' not found (Errcode: 2) create table t3 select * from temp_table; select * from t3; a @@ -48,15 +45,11 @@ show master logs; Log_name File_size master-bin.000002 0 master-bin.000003 407 -Warnings: -Error 29 File 'master-bin.000002' not found (Errcode: 2) purge binary logs to 'master-bin.000002'; show binary logs; Log_name File_size master-bin.000002 0 master-bin.000003 407 -Warnings: -Error 29 File 'master-bin.000002' not found (Errcode: 2) purge master logs before now(); show binary logs; Log_name File_size @@ -84,9 +77,6 @@ Log_name File_size master-bin.000003 0 master-bin.000004 0 master-bin.000005 2032 -Warnings: -Error 29 File 'master-bin.000003' not found (Errcode: 2) -Error 29 File 'master-bin.000004' not found (Errcode: 2) show master status; File Position Binlog_Do_DB Binlog_Ignore_DB master-bin.000005 2032 From 34901082359dd2182343e0b155e172afb156a97f Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 27 May 2005 12:03:37 +0200 Subject: [PATCH 55/98] Add USE_PRAGMA_INTERFACE and USE_PRAGMA_IMPLEMENTATION to files not existsing in 4.1 --- sql/hash_filo.h | 2 +- sql/sp_cache.cc | 2 +- sql/sp_cache.h | 2 +- sql/sp_head.cc | 2 +- sql/sp_head.h | 2 +- sql/sp_pcontext.cc | 2 +- sql/sp_pcontext.h | 2 +- sql/sp_rcontext.cc | 2 +- sql/sp_rcontext.h | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sql/hash_filo.h b/sql/hash_filo.h index d1672e1a60c..fc48c3b1540 100644 --- a/sql/hash_filo.h +++ b/sql/hash_filo.h @@ -23,7 +23,7 @@ #ifndef HASH_FILO_H #define HASH_FILO_H -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class interface */ #endif diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index 056ac6d7e96..83811e76f9b 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation #endif diff --git a/sql/sp_cache.h b/sql/sp_cache.h index 754a987090e..e9efe5b2a8c 100644 --- a/sql/sp_cache.h +++ b/sql/sp_cache.h @@ -18,7 +18,7 @@ #ifndef _SP_CACHE_H_ #define _SP_CACHE_H_ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 988345694b2..cac7a64beea 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation #endif diff --git a/sql/sp_head.h b/sql/sp_head.h index ee41b1efc83..955007d1ea4 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -18,7 +18,7 @@ #ifndef _SP_HEAD_H_ #define _SP_HEAD_H_ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc index 26f576233f3..f95a43eb903 100644 --- a/sql/sp_pcontext.cc +++ b/sql/sp_pcontext.cc @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation #endif diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h index 749b99dcf14..0d218bc0538 100644 --- a/sql/sp_pcontext.h +++ b/sql/sp_pcontext.h @@ -18,7 +18,7 @@ #ifndef _SP_PCONTEXT_H_ #define _SP_PCONTEXT_H_ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index 49ead5d1585..2e79a1e2533 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation #endif diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h index 417c50d0f0f..ba5fa950dc3 100644 --- a/sql/sp_rcontext.h +++ b/sql/sp_rcontext.h @@ -18,7 +18,7 @@ #ifndef _SP_RCONTEXT_H_ #define _SP_RCONTEXT_H_ -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class implementation */ #endif From 0ef3267251c4f34d73aace0ddf3910841337ec1b Mon Sep 17 00:00:00 2001 From: "dlenev@brandersnatch.localdomain" <> Date: Fri, 27 May 2005 14:15:17 +0400 Subject: [PATCH 56/98] Fix for trigger.test failure in --debug mode. We can't have Item_trigger_field as aggregated object inside of sp_instr_set_trigger_field class since in this case its destructor will be called twice. So instead let us create this Item separately and store pointer to it in instruction object. --- sql/sp_head.cc | 6 +++--- sql/sp_head.h | 7 +++---- sql/sql_yacc.yy | 13 ++++++++----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 988345694b2..f680fc17d9a 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1499,8 +1499,8 @@ sp_instr_set_trigger_field::execute(THD *thd, uint *nextp) DBUG_ENTER("sp_instr_set_trigger_field::execute"); /* QQ: Still unsure what should we return in case of error 1 or -1 ? */ if (!value->fixed && value->fix_fields(thd, 0, &value) || - trigger_field.fix_fields(thd, 0, 0) || - (value->save_in_field(trigger_field.field, 0) < 0)) + trigger_field->fix_fields(thd, 0, 0) || + (value->save_in_field(trigger_field->field, 0) < 0)) res= -1; *nextp= m_ip + 1; DBUG_RETURN(res); @@ -1510,7 +1510,7 @@ void sp_instr_set_trigger_field::print(String *str) { str->append("set ", 4); - trigger_field.print(str); + trigger_field->print(str); str->append(":=", 2); value->print(str); } diff --git a/sql/sp_head.h b/sql/sp_head.h index ee41b1efc83..4e940c427bb 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -467,9 +467,9 @@ class sp_instr_set_trigger_field : public sp_instr public: sp_instr_set_trigger_field(uint ip, sp_pcontext *ctx, - LEX_STRING field_name, Item *val) + Item_trigger_field *trg_fld, Item *val) : sp_instr(ip, ctx), - trigger_field(Item_trigger_field::NEW_ROW, field_name.str), + trigger_field(trg_fld), value(val) {} @@ -480,9 +480,8 @@ public: virtual void print(String *str); - Item_trigger_field trigger_field; - private: + Item_trigger_field *trigger_field; Item *value; }; // class sp_instr_trigger_field : public sp_instr diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 99b0f43db2d..88109e61e5d 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7565,6 +7565,7 @@ sys_option_value: { /* We are in trigger and assigning value to field of new row */ Item *it; + Item_trigger_field *trg_fld; sp_instr_set_trigger_field *i; if ($1) { @@ -7585,17 +7586,19 @@ sys_option_value: it= new Item_null(); } - if (!(i= new sp_instr_set_trigger_field( - lex->sphead->instructions(), lex->spcont, - $2.base_name, it))) + if (!(trg_fld= new Item_trigger_field(Item_trigger_field::NEW_ROW, + $2.base_name.str)) || + !(i= new sp_instr_set_trigger_field( + lex->sphead->instructions(), lex->spcont, + trg_fld, it))) YYABORT; /* Let us add this item to list of all Item_trigger_field objects in trigger. */ - lex->trg_table_fields.link_in_list((byte *)&i->trigger_field, - (byte **)&i->trigger_field.next_trg_field); + lex->trg_table_fields.link_in_list((byte *)trg_fld, + (byte **)&trg_fld->next_trg_field); lex->sphead->add_instr(i); } From d21b8d10775f1996c6323aeb83d542731ea6faa9 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Fri, 27 May 2005 12:38:29 +0200 Subject: [PATCH 57/98] don't downgrade the lock for CREATE ... SELECT (bug#6678) --- sql/ha_innodb.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 2d2a8f2c3b4..f0a25fd4f98 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -5420,7 +5420,8 @@ ha_innobase::store_lock( if ((lock_type >= TL_WRITE_CONCURRENT_INSERT && lock_type <= TL_WRITE) && !thd->in_lock_tables - && !thd->tablespace_op) { + && !thd->tablespace_op + && thd->lex->sql_command != SQLCOM_CREATE_TABLE) { lock_type = TL_WRITE_ALLOW_WRITE; } From f9e9406b4044d5c243a91f3a849e2609d792a06f Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Fri, 27 May 2005 14:15:08 +0200 Subject: [PATCH 58/98] forgotten s/__GNUC__/USE_PRAGMA_INTERFACE/ causes compilation faliures --- sql/hash_filo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/hash_filo.h b/sql/hash_filo.h index d1672e1a60c..fc48c3b1540 100644 --- a/sql/hash_filo.h +++ b/sql/hash_filo.h @@ -23,7 +23,7 @@ #ifndef HASH_FILO_H #define HASH_FILO_H -#ifdef __GNUC__ +#ifdef USE_PRAGMA_INTERFACE #pragma interface /* gcc class interface */ #endif From fcb3b0326ed3c60019eef079576c06af7eeb5583 Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Fri, 27 May 2005 14:48:33 +0200 Subject: [PATCH 59/98] Fixed BUG#9559: Functions: Numeric Operations using -ve value gives incorrect results. Actually a problem when converting decimal to int for user variables. --- mysql-test/r/sp.result | 11 +++++++++++ mysql-test/t/sp.test | 19 +++++++++++++++++++ sql/item_func.cc | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index c1164380f09..da54c100178 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -3098,4 +3098,15 @@ call bug5963_2(1)| call bug5963_2(1)| drop procedure bug5963_2| drop table t3| +drop function if exists bug9559| +create function bug9559() +returns int +begin +set @y = -6/2; +return @y; +end| +select bug9559()| +bug9559() +-3 +drop function bug9559| drop table t1,t2; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 80acaacfdb3..18389f4d80a 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -3801,6 +3801,25 @@ call bug5963_2(1)| drop procedure bug5963_2| drop table t3| +# +# BUG#9559: Functions: Numeric Operations using -ve value gives incorrect +# results. +# +--disable_warnings +drop function if exists bug9559| +--enable_warnings +create function bug9559() + returns int +begin + set @y = -6/2; + return @y; +end| + +select bug9559()| + +drop function bug9559| + + # # BUG#NNNN: New bug synopsis # diff --git a/sql/item_func.cc b/sql/item_func.cc index 68f1cc52cff..92371e1a082 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3597,7 +3597,7 @@ longlong user_var_entry::val_int(my_bool *null_value) case DECIMAL_RESULT: { longlong result; - my_decimal2int(E_DEC_FATAL_ERROR, (my_decimal *)value, 1, &result); + my_decimal2int(E_DEC_FATAL_ERROR, (my_decimal *)value, 0, &result); return result; } case STRING_RESULT: From 26e9e13c2618aad057a369c32bbb622fe3b6726d Mon Sep 17 00:00:00 2001 From: "gluh@eagle.intranet.mysql.r18.ru" <> Date: Fri, 27 May 2005 18:01:09 +0500 Subject: [PATCH 60/98] Fix for bug #9992: mysql_next_result hangs on error set net->no_send_error to 0 before execution of each element of multiquery statement to provide the sending of error to client --- sql/sql_parse.cc | 1 + tests/mysql_client_test.c | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 5a06364cd22..7a3d3073520 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1655,6 +1655,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, while (!thd->killed && thd->lex->found_semicolon && !thd->net.report_error) { char *packet= thd->lex->found_semicolon; + net->no_send_error= 0; /* Multiple queries exits, execute them individually in embedded server - just store them to be executed later diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 95db383bbb6..9a8ee44c54c 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -233,7 +233,7 @@ mysql_simple_prepare(MYSQL *mysql, const char *query) /* Connect to the server */ -static void client_connect() +static void client_connect(ulong flag) { int rc; myheader_r("client_connect"); @@ -251,7 +251,7 @@ static void client_connect() if (!(mysql_real_connect(mysql, opt_host, opt_user, opt_password, opt_db ? opt_db:"test", opt_port, - opt_unix_socket, 0))) + opt_unix_socket, flag))) { opt_silent= 0; myerror("connection failed"); @@ -13478,6 +13478,22 @@ static void print_test_output() } +static void check_mupltiquery_bug9992() +{ + + MYSQL_RES* res ; + mysql_query(mysql,"SHOW TABLES;SHOW DATABASE;SELECT 1;"); + + fprintf(stdout, "\n\n!!! check_mupltiquery_bug9992 !!!\n"); + do + { + if (!(res= mysql_store_result(mysql))) + return; + mysql_free_result(res); + } while (!mysql_next_result(mysql)); + fprintf(stdout, "\n\n!!! SUCCESS !!!\n"); + return; +} /*************************************************************************** main routine ***************************************************************************/ @@ -13499,7 +13515,7 @@ int main(int argc, char **argv) (char**) embedded_server_groups)) DIE("Can't initialize MySQL server"); - client_connect(); /* connect to server */ + client_connect(0); /* connect to server */ total_time= 0; for (iter_count= 1; iter_count <= opt_count; iter_count++) @@ -13543,6 +13559,10 @@ int main(int argc, char **argv) } client_disconnect(); /* disconnect from server */ + + client_connect(CLIENT_MULTI_STATEMENTS); + check_mupltiquery_bug9992(); + client_disconnect(); free_defaults(defaults_argv); print_test_output(); From 4ea3ec87f3233051793eba5788f2c579a213a279 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Fri, 27 May 2005 17:04:50 +0300 Subject: [PATCH 61/98] ha_innodb.cc: Check in Jan's fix to bug #10746 and also add a note to ::start_stmt() that stored procs in 5.0 call it --- sql/ha_innodb.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 7614744ddf6..9f07532c227 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -5764,7 +5764,12 @@ MySQL calls this function at the start of each SQL statement inside LOCK TABLES. Inside LOCK TABLES the ::external_lock method does not work to mark SQL statement borders. Note also a special case: if a temporary table is created inside LOCK TABLES, MySQL has not called external_lock() at all -on that table. */ +on that table. +MySQL-5.0 also calls this before each statement in an execution of a stored +procedure. To make the execution more deterministic for binlogging, MySQL-5.0 +locks all tables involved in a stored procedure with full explicit table +locks (thd->in_lock_tables is true in ::store_lock()) before executing the +procedure. */ int ha_innobase::start_stmt( @@ -6443,10 +6448,8 @@ ha_innobase::store_lock( if (srv_locks_unsafe_for_binlog && prebuilt->trx->isolation_level != TRX_ISO_SERIALIZABLE && (lock_type == TL_READ || lock_type == TL_READ_NO_INSERT) && - thd->lex->sql_command != SQLCOM_SELECT && - thd->lex->sql_command != SQLCOM_UPDATE_MULTI && - thd->lex->sql_command != SQLCOM_DELETE_MULTI && - thd->lex->sql_command != SQLCOM_LOCK_TABLES) { + (thd->lex->sql_command == SQLCOM_INSERT_SELECT || + thd->lex->sql_command == SQLCOM_UPDATE)) { /* In case we have innobase_locks_unsafe_for_binlog option set and isolation level of the transaction From 4c49970e0f389983995a2f75fb72842bc598729e Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Fri, 27 May 2005 16:19:25 +0200 Subject: [PATCH 62/98] Fixed BUG#8409: Stored procedure crash if function contains FLUSH by simply disabling FLUSH for stored functions. (I can't really work.) --- mysql-test/r/sp-error.result | 8 ++++++++ mysql-test/t/sp-error.test | 15 +++++++++++++++ sql/sql_yacc.yy | 5 +++++ 3 files changed, 28 insertions(+) diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 7c19f60471a..5eb651e2fca 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -646,4 +646,12 @@ drop procedure if exists bug10537| create procedure bug10537() load data local infile '/tmp/somefile' into table t1| ERROR 0A000: LOAD DATA is not allowed in stored procedures +drop function if exists bug8409| +create function bug8409() +returns int +begin +flush tables; +return 5; +end| +ERROR 0A000: FLUSH is not allowed in stored procedures drop table t1| diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 67e9be5dd5d..78a6cdd49e1 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -905,6 +905,21 @@ create procedure bug10537() load data local infile '/tmp/somefile' into table t1| +# +# BUG#8409: Stored procedure crash if function contains FLUSH +# +--disable_warnings +drop function if exists bug8409| +--enable_warnings +--error ER_SP_BADSTATEMENT +create function bug8409() + returns int +begin + flush tables; + return 5; +end| + + # # BUG#NNNN: New bug synopsis # diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 6b9676c8124..feb9b9a6363 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -6511,6 +6511,11 @@ flush: FLUSH_SYM opt_no_write_to_binlog { LEX *lex=Lex; + if (lex->sphead && lex->sphead->m_type == TYPE_ENUM_FUNCTION) + { + my_error(ER_SP_BADSTATEMENT, MYF(0), "FLUSH"); + YYABORT; + } lex->sql_command= SQLCOM_FLUSH; lex->type=0; lex->no_write_to_binlog= $2; } From 8e09a3b8d1c35ad8dde5549a7558c1f4dc2c6382 Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Fri, 27 May 2005 19:20:29 +0200 Subject: [PATCH 63/98] - fixed the "test-force" target in the toplevel Makefile.am for systems on which "." is not in the PATH... --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index eec27484710..b5ebe8eb8ae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -104,8 +104,8 @@ test: test-force: cd mysql-test; \ - mysql-test-run --force ;\ - mysql-test-run --ps-protocol --force + ./mysql-test-run --force ;\ + ./mysql-test-run --ps-protocol --force # Don't update the files from bitkeeper %::SCCS/s.% From d3d727e32874b2c3392baab8188ebe17da7cc8b9 Mon Sep 17 00:00:00 2001 From: "patg@radha.local" <> Date: Fri, 27 May 2005 22:07:46 +0200 Subject: [PATCH 64/98] Comment and test changes per review request by Timour. All tests pass on production with this code. --- mysql-test/r/federated.result | 43 +++++++++++++++++++++++++++++++++++ mysql-test/t/federated.test | 33 ++++++++++++++++++++++++++- sql/ha_federated.cc | 6 ++++- 3 files changed, 80 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/federated.result b/mysql-test/r/federated.result index ebf9b144eeb..d9c86a89c75 100644 --- a/mysql-test/r/federated.result +++ b/mysql-test/r/federated.result @@ -906,6 +906,13 @@ INSERT INTO federated.t1 (name, country_id, other) VALUES ('Lenz', 2, 22222); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Marizio', 3, 33333); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Monty', 4, 33333); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Sanja', 5, 33333); +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1, federated.countries WHERE +federated.t1.country_id = federated.countries.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE countries ALL PRIMARY NULL NULL NULL 5 +1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 120 SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, federated.t1.other AS other, federated.countries.country AS country FROM federated.t1, federated.countries WHERE @@ -916,6 +923,13 @@ Lenz 2 22222 Germany Marizio 3 33333 Italy Monty 4 33333 Finland Sanja 5 33333 Ukraine +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE countries ALL PRIMARY NULL NULL NULL 5 +1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 120 SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, federated.t1.other AS other, federated.countries.country AS country FROM federated.t1 INNER JOIN federated.countries ON @@ -926,6 +940,14 @@ Lenz 2 22222 Germany Marizio 3 33333 Italy Monty 4 33333 Finland Sanja 5 33333 Ukraine +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id +WHERE federated.t1.name = 'Monty'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE countries ALL PRIMARY NULL NULL NULL 5 +1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 120 Using where SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, federated.t1.other AS other, federated.countries.country AS country FROM federated.t1 INNER JOIN federated.countries ON @@ -933,6 +955,13 @@ federated.t1.country_id = federated.countries.id WHERE federated.t1.name = 'Monty'; name country_id other country Monty 4 33333 Finland +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 Using temporary; Using filesort +1 SIMPLE countries eq_ref PRIMARY PRIMARY 4 federated.t1.country_id 1 SELECT federated.t1.*, federated.countries.country FROM federated.t1 LEFT JOIN federated.countries ON federated.t1.country_id = federated.countries.id @@ -943,6 +972,13 @@ id country_id name other country 3 3 Marizio 33333 Italy 4 4 Monty 33333 Finland 5 5 Sanja 33333 Ukraine +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.country; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 Using temporary; Using filesort +1 SIMPLE countries eq_ref PRIMARY PRIMARY 4 federated.t1.country_id 1 SELECT federated.t1.*, federated.countries.country FROM federated.t1 LEFT JOIN federated.countries ON federated.t1.country_id = federated.countries.id @@ -953,6 +989,13 @@ id country_id name other country 1 1 Kumar 11111 India 3 3 Marizio 33333 Italy 5 5 Sanja 33333 Ukraine +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 RIGHT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.t1.country_id; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE countries ALL NULL NULL NULL NULL 5 Using temporary; Using filesort +1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 120 SELECT federated.t1.*, federated.countries.country FROM federated.t1 RIGHT JOIN federated.countries ON federated.t1.country_id = federated.countries.id diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test index da8df543ed0..1e33efe1c0e 100644 --- a/mysql-test/t/federated.test +++ b/mysql-test/t/federated.test @@ -862,16 +862,32 @@ INSERT INTO federated.t1 (name, country_id, other) VALUES ('Monty', 4, 33333); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Sanja', 5, 33333); #inner join +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1, federated.countries WHERE +federated.t1.country_id = federated.countries.id; + SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, federated.t1.other AS other, federated.countries.country AS country FROM federated.t1, federated.countries WHERE federated.t1.country_id = federated.countries.id; +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id; + SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, federated.t1.other AS other, federated.countries.country AS country FROM federated.t1 INNER JOIN federated.countries ON federated.t1.country_id = federated.countries.id; +EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, +federated.t1.other AS other, federated.countries.country AS country +FROM federated.t1 INNER JOIN federated.countries ON +federated.t1.country_id = federated.countries.id +WHERE federated.t1.name = 'Monty'; + SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, federated.t1.other AS other, federated.countries.country AS country FROM federated.t1 INNER JOIN federated.countries ON @@ -879,17 +895,32 @@ federated.t1.country_id = federated.countries.id WHERE federated.t1.name = 'Monty'; #left join -SELECT federated.t1.*, federated.countries.country +EXPLAIN SELECT federated.t1.*, federated.countries.country FROM federated.t1 LEFT JOIN federated.countries ON federated.t1.country_id = federated.countries.id ORDER BY federated.countries.id; +SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.id; + +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 LEFT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.countries.country; + SELECT federated.t1.*, federated.countries.country FROM federated.t1 LEFT JOIN federated.countries ON federated.t1.country_id = federated.countries.id ORDER BY federated.countries.country; #right join +EXPLAIN SELECT federated.t1.*, federated.countries.country +FROM federated.t1 RIGHT JOIN federated.countries +ON federated.t1.country_id = federated.countries.id +ORDER BY federated.t1.country_id; + SELECT federated.t1.*, federated.countries.country FROM federated.t1 RIGHT JOIN federated.countries ON federated.t1.country_id = federated.countries.id diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index eab3e55c4a4..c76034c7986 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -1526,7 +1526,11 @@ int ha_federated::index_read_idx(byte *buf, uint index, const byte *key, table->status= STATUS_NOT_FOUND; DBUG_RETURN(mysql_errno(mysql)); } - /* very important - joins will not work without this! */ + /* + This basically says that the record in table->record[0] is legal, and that it is + ok to use this record, for whatever reason, such as with a join (without it, joins + will not work) + */ table->status=0; DBUG_RETURN(rnd_next(buf)); From 077086cd964a68eb826321e5e29ff2c7a1d0aa56 Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Mon, 30 May 2005 03:32:50 +0400 Subject: [PATCH 65/98] Fix bug #9593 "The combination of COUNT, DISTINCT and CONCAT seems to lock the server" Bug appears only on Windows platform. Freeing memory in TMP_TABLE_PARAM::cleanup() allocated by new Copy_fields[0] in setup_copy_fields() results in memory destruction. In test IF used instead of CONCAT because IF have more stable crash. --- mysql-test/r/count_distinct.result | 6 ++++++ mysql-test/t/count_distinct.test | 12 ++++++++++++ sql/sql_select.cc | 17 +++++++++++------ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/count_distinct.result b/mysql-test/r/count_distinct.result index 1bc1ad6a31e..a21748359b9 100644 --- a/mysql-test/r/count_distinct.result +++ b/mysql-test/r/count_distinct.result @@ -60,3 +60,9 @@ count(distinct a) 1 1 drop table t1; +create table t1 (f1 int, f2 int); +insert into t1 values (0,1),(1,2); +select count(distinct if(f1,3,f2)) from t1; +count(distinct if(f1,3,f2)) +2 +drop table t1; diff --git a/mysql-test/t/count_distinct.test b/mysql-test/t/count_distinct.test index 73c6951e78f..be67026e268 100644 --- a/mysql-test/t/count_distinct.test +++ b/mysql-test/t/count_distinct.test @@ -63,3 +63,15 @@ create table t1 (a char(3), b char(20), primary key (a, b)); insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English'); select count(distinct a) from t1 group by b; drop table t1; + +# +# Bug #9593 "The combination of COUNT, DISTINCT and CONCAT +# seems to lock the server" +# Bug appears only on Windows system +# + +create table t1 (f1 int, f2 int); +insert into t1 values (0,1),(1,2); +select count(distinct if(f1,3,f2)) from t1; +drop table t1; + diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c68379baa75..ffad69654ea 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -12313,7 +12313,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, { Item *pos; List_iterator_fast li(all_fields); - Copy_field *copy; + Copy_field *copy= NULL; res_selected_fields.empty(); res_all_fields.empty(); List_iterator_fast itr(res_all_fields); @@ -12321,7 +12321,8 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, uint i, border= all_fields.elements - elements; DBUG_ENTER("setup_copy_fields"); - if (!(copy=param->copy_field= new Copy_field[param->field_count])) + if (param->field_count && + !(copy=param->copy_field= new Copy_field[param->field_count])) goto err2; param->copy_funcs.empty(); @@ -12360,9 +12361,12 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, char *tmp=(char*) sql_alloc(field->pack_length()+1); if (!tmp) goto err; - copy->set(tmp, item->result_field); - item->result_field->move_field(copy->to_ptr,copy->to_null_ptr,1); - copy++; + if (copy) + { + copy->set(tmp, item->result_field); + item->result_field->move_field(copy->to_ptr,copy->to_null_ptr,1); + copy++; + } } } else if ((pos->type() == Item::FUNC_ITEM || @@ -12405,7 +12409,8 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, DBUG_RETURN(0); err: - delete [] param->copy_field; // This is never 0 + if (copy) + delete [] param->copy_field; // This is never 0 param->copy_field=0; err2: DBUG_RETURN(TRUE); From 10cc5a46df746dd3478c536c7e420d6b523c9897 Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Mon, 30 May 2005 03:01:51 -0700 Subject: [PATCH 66/98] olap.result, olap.test: Added test cases for bug #7894. sql_select.cc: Fixed bug #7894: GROUP BY queries with ROLLUP returned wrong results for expressions containing group by columns. The fix ensured correct results by replacement of all occurrences of group by fields in non-aggregate expressions for corresponding ref objects and preventing creation of fields in temporary tables for expression containing group by fields. --- mysql-test/r/olap.result | 68 +++++++++++++++++++++++++++- mysql-test/t/olap.test | 30 +++++++++++++ sql/sql_select.cc | 95 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 187 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index 013952403d7..ab84fa5739a 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -248,7 +248,7 @@ concat(':',product,':') sum(profit) avg(profit) :Computer: 6900 1380.0000 :Phone: 10 10.0000 :TV: 600 120.0000 -:TV: 7785 519.0000 +NULL 7785 519.0000 select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube; ERROR 42000: This version of MySQL doesn't yet support 'CUBE' explain select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube; @@ -438,3 +438,69 @@ a SUM(a) SUM(a)+1 CONCAT(SUM(a),'x') SUM(a)+SUM(a) SUM(a) 5 5 6 5x 10 5 NULL 8 9 8x 16 8 DROP TABLE t1; +CREATE TABLE t1 (a int(11)); +INSERT INTO t1 VALUES (1),(2); +SELECT a, a+1, SUM(a) FROM t1 GROUP BY a WITH ROLLUP; +a a+1 SUM(a) +1 2 1 +2 3 2 +NULL NULL 3 +SELECT a+1 FROM t1 GROUP BY a WITH ROLLUP; +a+1 +2 +3 +NULL +SELECT a+SUM(a) FROM t1 GROUP BY a WITH ROLLUP; +a+SUM(a) +2 +4 +NULL +SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING b > 2; +a b +2 3 +SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING a IS NULL; +a b +NULL NULL +SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING b IS NULL; +a b +NULL NULL +SELECT IFNULL(a, 'TEST') FROM t1 GROUP BY a WITH ROLLUP; +IFNULL(a, 'TEST') +1 +2 +TEST +CREATE TABLE t2 (a int, b int); +INSERT INTO t2 VALUES +(1,4), +(2,2), (2,2), +(4,1), (4,1), (4,1), (4,1), +(2,1), (2,1); +SELECT a,b,SUM(b) FROM t2 GROUP BY a,b WITH ROLLUP; +a b SUM(b) +1 4 4 +1 NULL 4 +2 1 2 +2 2 4 +2 NULL 6 +4 1 4 +4 NULL 4 +NULL NULL 14 +SELECT a,b,SUM(b), a+b as c FROM t2 +GROUP BY a,b WITH ROLLUP HAVING c IS NULL; +a b SUM(b) c +1 NULL 4 NULL +2 NULL 6 NULL +4 NULL 4 NULL +NULL NULL 14 NULL +SELECT IFNULL(a, 'TEST'), COALESCE(b, 'TEST') FROM t2 +GROUP BY a, b WITH ROLLUP; +IFNULL(a, 'TEST') COALESCE(b, 'TEST') +1 4 +1 TEST +2 1 +2 2 +2 TEST +4 1 +4 TEST +TEST TEST +DROP TABLE t1,t2; diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test index 09ba537bf3b..b9387d15320 100644 --- a/mysql-test/t/olap.test +++ b/mysql-test/t/olap.test @@ -208,3 +208,33 @@ SELECT a, SUM(a), SUM(a)+1, CONCAT(SUM(a),'x'), SUM(a)+SUM(a), SUM(a) DROP TABLE t1; +# +# Tests for bug #7894: ROLLUP over expressions on group by attributes +# + +CREATE TABLE t1 (a int(11)); +INSERT INTO t1 VALUES (1),(2); + +SELECT a, a+1, SUM(a) FROM t1 GROUP BY a WITH ROLLUP; +SELECT a+1 FROM t1 GROUP BY a WITH ROLLUP; +SELECT a+SUM(a) FROM t1 GROUP BY a WITH ROLLUP; +SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING b > 2; +SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING a IS NULL; +SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING b IS NULL; +SELECT IFNULL(a, 'TEST') FROM t1 GROUP BY a WITH ROLLUP; + +CREATE TABLE t2 (a int, b int); +INSERT INTO t2 VALUES + (1,4), + (2,2), (2,2), + (4,1), (4,1), (4,1), (4,1), + (2,1), (2,1); + +SELECT a,b,SUM(b) FROM t2 GROUP BY a,b WITH ROLLUP; +SELECT a,b,SUM(b), a+b as c FROM t2 + GROUP BY a,b WITH ROLLUP HAVING c IS NULL; +SELECT IFNULL(a, 'TEST'), COALESCE(b, 'TEST') FROM t2 + GROUP BY a, b WITH ROLLUP; + +DROP TABLE t1,t2; + diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7b27879ae28..4f192b9228e 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9164,6 +9164,79 @@ void free_underlaid_joins(THD *thd, SELECT_LEX *select) ROLLUP handling ****************************************************************************/ +/* + Replace occurences of group by fields in an expression by ref items + + SYNOPSIS + change_group_ref() + thd reference to the context + expr expression to make replacement + group_list list of references to group by items + changed out: returns 1 if item contains a replaced field item + + DESCRIPTION + The function replaces occurrences of group by fields in expr + by ref objects for these fields unless they are under aggregate + functions. + + IMPLEMENTATION + The function recursively traverses the tree of the expr expression, + looks for occurrences of the group by fields that are not under + aggregate functions and replaces them for the corresponding ref items. + + NOTES + This substitution is needed GROUP BY queries with ROLLUP if + SELECT list contains expressions over group by attributes. + + EXAMPLES + SELECT a+1 FROM t1 GROUP BY a WITH ROLLUP + SELECT SUM(a)+a FROM t1 GROUP BY a WITH ROLLUP + + RETURN + 0 if ok + 1 on error +*/ + +static bool change_group_ref(THD *thd, Item *expr, ORDER *group_list, + bool *changed) +{ + if (expr->type() != Item::FUNC_ITEM) + return 0; + Item_func *func_item= (Item_func *) expr; + if (func_item->arg_count) + { + Item **arg,**arg_end; + for (arg= func_item->arguments(), + arg_end= func_item->arguments()+func_item->arg_count; + arg != arg_end; arg++) + { + Item *item= *arg; + if (item->type() == Item::FIELD_ITEM || item->type() == Item::REF_ITEM) + { + ORDER *group_tmp; + for (group_tmp= group_list; group_tmp; group_tmp= group_tmp->next) + { + if (item->eq(*group_tmp->item,0)) + { + Item *new_item; + if(!(new_item= new Item_ref(group_tmp->item, 0, item->name))) + return 1; // fatal_error is set + thd->change_item_tree(arg, new_item); + *changed= TRUE; + } + } + } + else if (item->type() == Item::FUNC_ITEM) + { + if (change_group_ref(thd, item, group_list, changed)) + return 1; + } + } + } + return 0; +} + + /* Allocate memory needed for other rollup functions */ bool JOIN::rollup_init() @@ -9208,19 +9281,31 @@ bool JOIN::rollup_init() for (j=0 ; j < fields_list.elements ; j++) rollup.fields[i].push_back(rollup.null_items[i]); } - List_iterator_fast it(fields_list); + List_iterator_fast it(all_fields); Item *item; while ((item= it++)) { ORDER *group_tmp; for (group_tmp= group_list; group_tmp; group_tmp= group_tmp->next) { - if (*group_tmp->item == item) + if (item->eq(*group_tmp->item,0)) item->maybe_null= 1; } + if (item->type() == Item::FUNC_ITEM) + { + bool changed= 0; + if (change_group_ref(thd, item, group_list, &changed)) + return 1; + /* + We have to prevent creation of a field in a temporary table for + an expression that contains GROUP BY attributes. + Marking the expression item as 'with_sum_func' will ensure this. + */ + if (changed) + item->with_sum_func= 1; + } } return 0; - } @@ -9318,14 +9403,14 @@ bool JOIN::rollup_make_fields(List &fields_arg, List &sel_fields, *(*func)= (Item_sum*) item; (*func)++; } - else if (real_fields) + else { /* Check if this is something that is part of this group by */ ORDER *group_tmp; for (group_tmp= start_group, i= pos ; group_tmp ; group_tmp= group_tmp->next, i++) { - if (*group_tmp->item == item) + if (item->eq(*group_tmp->item,0)) { /* This is an element that is used by the GROUP BY and should be From e8a6fa42783a484a6bfef802feb987513d0ff0db Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Mon, 30 May 2005 05:25:12 -0700 Subject: [PATCH 67/98] sql_select.cc: Post-review modifications for the fix of bug #7894. --- sql/sql_select.cc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 4f192b9228e..0362f097cba 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9197,17 +9197,14 @@ void free_underlaid_joins(THD *thd, SELECT_LEX *select) 1 on error */ -static bool change_group_ref(THD *thd, Item *expr, ORDER *group_list, +static bool change_group_ref(THD *thd, Item_func *expr, ORDER *group_list, bool *changed) { - if (expr->type() != Item::FUNC_ITEM) - return 0; - Item_func *func_item= (Item_func *) expr; - if (func_item->arg_count) + if (expr->arg_count) { Item **arg,**arg_end; - for (arg= func_item->arguments(), - arg_end= func_item->arguments()+func_item->arg_count; + for (arg= expr->arguments(), + arg_end= expr->arguments()+expr->arg_count; arg != arg_end; arg++) { Item *item= *arg; @@ -9228,7 +9225,7 @@ static bool change_group_ref(THD *thd, Item *expr, ORDER *group_list, } else if (item->type() == Item::FUNC_ITEM) { - if (change_group_ref(thd, item, group_list, changed)) + if (change_group_ref(thd, (Item_func *) item, group_list, changed)) return 1; } } @@ -9294,7 +9291,7 @@ bool JOIN::rollup_init() if (item->type() == Item::FUNC_ITEM) { bool changed= 0; - if (change_group_ref(thd, item, group_list, &changed)) + if (change_group_ref(thd, (Item_func *) item, group_list, &changed)) return 1; /* We have to prevent creation of a field in a temporary table for From abfc5b3903a99410acbd90b5d88cae06d618db5c Mon Sep 17 00:00:00 2001 From: "dlenev@brandersnatch.localdomain" <> Date: Mon, 30 May 2005 18:55:56 +0400 Subject: [PATCH 68/98] Added test for bug #5894 "Triggers with altered tables cause corrupt databases" and basic handling of errors which happen in triggers. (The bug itself was fixed by several previous patches). Fixed bug in multi-delete which were exposed by these tests. --- mysql-test/r/trigger.result | 167 ++++++++++++++++++++++++++++++++++++ mysql-test/t/trigger.test | 127 +++++++++++++++++++++++++++ sql/sql_delete.cc | 4 +- 3 files changed, 296 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index 1d2fb5989a5..996a692d531 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -315,3 +315,170 @@ i j k @b 3 4 3 Fired 5 6 5 Fired drop table t1; +create table t1 (i int, at int, k int, key(k)) engine=myisam; +create table t2 (i int); +insert into t1 values (1, 1, 1); +insert into t2 values (1), (2), (3); +create trigger ai after insert on t1 for each row set @a:= new.at; +create trigger au after update on t1 for each row set @a:= new.at; +create trigger ad after delete on t1 for each row set @a:= old.at; +alter table t1 drop column at; +select * from t1; +i k +1 1 +insert into t1 values (2, 1); +ERROR 42S22: Unknown column 'at' in 'NEW' +select * from t1; +i k +1 1 +2 1 +update t1 set k = 2 where i = 2; +ERROR 42S22: Unknown column 'at' in 'NEW' +select * from t1; +i k +1 1 +2 2 +delete from t1 where i = 2; +ERROR 42S22: Unknown column 'at' in 'OLD' +select * from t1; +i k +1 1 +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); +ERROR 42S22: Unknown column 'at' in 'NEW' +select * from t1; +i k +1 1 +1 2 +insert into t1 select 3, 3; +ERROR 42S22: Unknown column 'at' in 'NEW' +select * from t1; +i k +1 1 +1 2 +3 3 +update t1, t2 set k = k + 10 where t1.i = t2.i; +ERROR 42S22: Unknown column 'at' in 'NEW' +select * from t1; +i k +1 11 +1 2 +3 3 +update t1, t2 set k = k + 10 where t1.i = t2.i and k < 3; +ERROR 42S22: Unknown column 'at' in 'NEW' +select * from t1; +i k +1 11 +1 12 +3 3 +delete t1, t2 from t1 straight_join t2 where t1.i = t2.i; +ERROR 42S22: Unknown column 'at' in 'OLD' +select * from t1; +i k +1 12 +3 3 +delete t2, t1 from t2 straight_join t1 where t1.i = t2.i; +ERROR 42S22: Unknown column 'at' in 'OLD' +select * from t1; +i k +3 3 +alter table t1 add primary key (i); +insert into t1 values (3, 4) on duplicate key update k= k + 10; +ERROR 42S22: Unknown column 'at' in 'NEW' +select * from t1; +i k +3 13 +replace into t1 values (3, 3); +ERROR 42S22: Unknown column 'at' in 'NEW' +select * from t1; +i k +3 3 +alter table t1 add ts timestamp default now(); +replace into t1 (i, k) values (3, 13); +ERROR 42S22: Unknown column 'at' in 'OLD' +select * from t1; +i k ts +drop table t1, t2; +create table t1 (i int, bt int, k int, key(k)) engine=myisam; +create table t2 (i int); +insert into t1 values (1, 1, 1), (2, 2, 2); +insert into t2 values (1), (2), (3); +create trigger bi before insert on t1 for each row set @a:= new.bt; +create trigger bu before update on t1 for each row set @a:= new.bt; +create trigger bd before delete on t1 for each row set @a:= old.bt; +alter table t1 drop column bt; +insert into t1 values (3, 3); +ERROR 42S22: Unknown column 'bt' in 'NEW' +select * from t1; +i k +1 1 +2 2 +update t1 set i = 2; +ERROR 42S22: Unknown column 'bt' in 'NEW' +select * from t1; +i k +1 1 +2 2 +delete from t1; +ERROR 42S22: Unknown column 'bt' in 'OLD' +select * from t1; +i k +1 1 +2 2 +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); +ERROR 42S22: Unknown column 'bt' in 'NEW' +select * from t1; +i k +1 1 +2 2 +insert into t1 select 3, 3; +ERROR 42S22: Unknown column 'bt' in 'NEW' +select * from t1; +i k +1 1 +2 2 +update t1, t2 set k = k + 10 where t1.i = t2.i; +ERROR 42S22: Unknown column 'bt' in 'NEW' +select * from t1; +i k +1 1 +2 2 +update t1, t2 set k = k + 10 where t1.i = t2.i and k < 2; +ERROR 42S22: Unknown column 'bt' in 'NEW' +select * from t1; +i k +1 1 +2 2 +delete t1, t2 from t1 straight_join t2 where t1.i = t2.i; +ERROR 42S22: Unknown column 'bt' in 'OLD' +select * from t1; +i k +1 1 +2 2 +delete t2, t1 from t2 straight_join t1 where t1.i = t2.i; +ERROR 42S22: Unknown column 'bt' in 'OLD' +select * from t1; +i k +1 1 +2 2 +alter table t1 add primary key (i); +drop trigger t1.bi; +insert into t1 values (2, 4) on duplicate key update k= k + 10; +ERROR 42S22: Unknown column 'bt' in 'NEW' +select * from t1; +i k +1 1 +2 2 +replace into t1 values (2, 4); +ERROR 42S22: Unknown column 'bt' in 'NEW' +select * from t1; +i k +1 1 +2 2 +alter table t1 add ts timestamp default now(); +replace into t1 (i, k) values (2, 11); +ERROR 42S22: Unknown column 'bt' in 'OLD' +select * from t1; +i k ts +1 1 0000-00-00 00:00:00 +2 2 0000-00-00 00:00:00 +drop table t1, t2; diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 79f65bba678..0c5ef077159 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -367,3 +367,130 @@ load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated select *, @b from t1; # This also will drop triggers drop table t1; + +# Test for bug #5894 "Triggers with altered tables cause corrupt databases" +# Also tests basic error handling for various kinds of triggers. +create table t1 (i int, at int, k int, key(k)) engine=myisam; +create table t2 (i int); +insert into t1 values (1, 1, 1); +# We need at least 3 elements in t2 to test multi-update properly +insert into t2 values (1), (2), (3); +# Create and then break "after" triggers +create trigger ai after insert on t1 for each row set @a:= new.at; +create trigger au after update on t1 for each row set @a:= new.at; +create trigger ad after delete on t1 for each row set @a:= old.at; +alter table t1 drop column at; +# We still should be able select data from tables. +select * from t1; +# The following statements changing t1 should fail, but still cause +# their main effect. This is because operation on the table row is +# executed before "after" trigger and its effect cannot be rolled back +# when whole statement fails, because t1 is MyISAM table. +--error 1054 +insert into t1 values (2, 1); +select * from t1; +--error 1054 +update t1 set k = 2 where i = 2; +select * from t1; +--error 1054 +delete from t1 where i = 2; +select * from t1; +# Should fail and insert only 1 row +--error 1054 +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); +select * from t1; +--error 1054 +insert into t1 select 3, 3; +select * from t1; +# Multi-update working on the fly, again it will update only +# one row even if more matches +--error 1054 +update t1, t2 set k = k + 10 where t1.i = t2.i; +select * from t1; +# The same for multi-update via temp table +--error 1054 +update t1, t2 set k = k + 10 where t1.i = t2.i and k < 3; +select * from t1; +# Multi-delete on the fly +--error 1054 +delete t1, t2 from t1 straight_join t2 where t1.i = t2.i; +select * from t1; +# And via temporary storage +--error 1054 +delete t2, t1 from t2 straight_join t1 where t1.i = t2.i; +select * from t1; +# Prepare table for testing of REPLACE and INSERT ... ON DUPLICATE KEY UPDATE +alter table t1 add primary key (i); +--error 1054 +insert into t1 values (3, 4) on duplicate key update k= k + 10; +select * from t1; +--error 1054 +replace into t1 values (3, 3); +select * from t1; +# Change table in such way that REPLACE will delete row +alter table t1 add ts timestamp default now(); +--error 1054 +replace into t1 (i, k) values (3, 13); +select * from t1; +# Also drops all triggers +drop table t1, t2; + +create table t1 (i int, bt int, k int, key(k)) engine=myisam; +create table t2 (i int); +insert into t1 values (1, 1, 1), (2, 2, 2); +insert into t2 values (1), (2), (3); +# Create and then break "before" triggers +create trigger bi before insert on t1 for each row set @a:= new.bt; +create trigger bu before update on t1 for each row set @a:= new.bt; +create trigger bd before delete on t1 for each row set @a:= old.bt; +alter table t1 drop column bt; +# The following statements changing t1 should fail and should not +# cause any effect on table, since "before" trigger is executed +# before operation on the table row. +--error 1054 +insert into t1 values (3, 3); +select * from t1; +--error 1054 +update t1 set i = 2; +select * from t1; +--error 1054 +delete from t1; +select * from t1; +--error 1054 +load data infile '../../std_data/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (i, k); +select * from t1; +--error 1054 +insert into t1 select 3, 3; +select * from t1; +# Both types of multi-update (on the fly and via temp table) +--error 1054 +update t1, t2 set k = k + 10 where t1.i = t2.i; +select * from t1; +--error 1054 +update t1, t2 set k = k + 10 where t1.i = t2.i and k < 2; +select * from t1; +# Both types of multi-delete +--error 1054 +delete t1, t2 from t1 straight_join t2 where t1.i = t2.i; +select * from t1; +--error 1054 +delete t2, t1 from t2 straight_join t1 where t1.i = t2.i; +select * from t1; +# Let us test REPLACE/INSERT ... ON DUPLICATE KEY UPDATE. +# To test properly code-paths different from those that are used +# in ordinary INSERT we need to drop "before insert" trigger. +alter table t1 add primary key (i); +drop trigger t1.bi; +--error 1054 +insert into t1 values (2, 4) on duplicate key update k= k + 10; +select * from t1; +--error 1054 +replace into t1 values (2, 4); +select * from t1; +# Change table in such way that REPLACE will delete row +alter table t1 add ts timestamp default now(); +--error 1054 +replace into t1 (i, k) values (2, 11); +select * from t1; +# Also drops all triggers +drop table t1, t2; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 97830f7ec8f..672972ccb72 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -696,11 +696,11 @@ bool multi_delete::send_eof() Note that if we deleted nothing we don't write to the binlog (TODO: fix this). */ - if (deleted && (error <= 0 || normal_tables)) + if (deleted && ((error <= 0 && !local_error) || normal_tables)) { if (mysql_bin_log.is_open()) { - if (error <= 0) + if (error <= 0 && !local_error) thd->clear_error(); Query_log_event qinfo(thd, thd->query, thd->query_length, transactional_tables, FALSE); From 2d6a70c42a4c63abb3653dd1b8f3287d4adc68f8 Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Mon, 30 May 2005 20:54:37 +0400 Subject: [PATCH 69/98] Preparatory (and the most problematic) patch for Bug#7306 "the server side preparedStatement error for LIMIT placeholder", which moves all uses of LIMIT clause from PREPARE to OPTIMIZE and later steps. After-review fixes. --- mysql-test/r/group_min_max.result | 12 +++++------ sql/item_subselect.cc | 21 ++++++++---------- sql/mysql_priv.h | 3 +-- sql/opt_range.cc | 11 +++++++++- sql/sp.cc | 2 +- sql/sql_base.cc | 19 +++++++--------- sql/sql_delete.cc | 5 ++--- sql/sql_help.cc | 2 +- sql/sql_insert.cc | 2 +- sql/sql_lex.cc | 8 ++----- sql/sql_lex.h | 4 ++-- sql/sql_load.cc | 2 +- sql/sql_olap.cc | 3 +-- sql/sql_parse.cc | 4 ++-- sql/sql_select.cc | 32 ++++++++++----------------- sql/sql_union.cc | 36 +++++++------------------------ sql/sql_update.cc | 7 +++--- 17 files changed, 69 insertions(+), 104 deletions(-) diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result index dea6bca2cdd..a43f1ee88a6 100644 --- a/mysql-test/r/group_min_max.result +++ b/mysql-test/r/group_min_max.result @@ -133,13 +133,13 @@ Table Op Msg_type Msg_text test.t3 analyze status Table is already up to date explain select a1, min(a2) from t1 group by a1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by +1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by explain select a1, max(a2) from t1 group by a1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by explain select a1, min(a2), max(a2) from t1 group by a1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by +1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by explain select a1, a2, b, min(c), max(c) from t1 group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by @@ -151,13 +151,13 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range NULL idx_t2_1 # NULL # Using index for group-by explain select min(a2), a1, max(a2), min(a2), a1 from t1 group by a1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by +1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by explain select a1, b, min(c), a1, max(c), b, a2, max(c), max(c) from t1 group by a1, a2, b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by explain select min(a2) from t1 group by a1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL idx_t1_1 65 NULL 5 Using index for group-by +1 SIMPLE t1 range NULL idx_t1_1 130 NULL 5 Using index for group-by explain select a2, min(c), max(c) from t1 group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL idx_t1_1 147 NULL 17 Using index for group-by @@ -1404,7 +1404,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by explain select a1,a2,b,min(c) from t2 where (a1 > 'a') and (a2 > 'a') and (b = 'c') group by a1,a2,b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 146 NULL # Using where; Using index for group-by +1 SIMPLE t2 range idx_t2_0,idx_t2_1,idx_t2_2 idx_t2_1 163 NULL # Using where; Using index for group-by select a1,a2,b,min(c),max(c) from t1 where (a1 >= 'c' or a2 < 'b') and (b > 'a') group by a1,a2,b; a1 a2 b min(c) max(c) a a b e112 h112 @@ -1838,7 +1838,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range idx_t1_0,idx_t1_1,idx_t1_2 idx_t1_1 147 NULL 10 Using where; Using index for group-by explain select concat(ord(min(b)),ord(max(b))),min(b),max(b) from t1 group by a1,a2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL idx_t1_1 130 NULL 9 Using index for group-by +1 SIMPLE t1 range NULL idx_t1_1 147 NULL 9 Using index for group-by select a1,a2,b, concat(min(c), max(c)) from t1 where a1 < 'd' group by a1,a2,b; a1 a2 b concat(min(c), max(c)) a a a a111d111 diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 0fbcf32a83c..8e5ae7c6a42 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -537,8 +537,6 @@ Item_exists_subselect::Item_exists_subselect(st_select_lex *select_lex): null_value= 0; //can't be NULL maybe_null= 0; //can't be NULL value= 0; - // We need only 1 row to determinate existence - select_lex->master_unit()->global_parameters->select_limit= 1; DBUG_VOID_RETURN; } @@ -605,6 +603,8 @@ void Item_exists_subselect::fix_length_and_dec() decimals= 0; max_length= 1; max_columns= engine->cols(); + /* We need only 1 row to determinate existence */ + unit->global_parameters->select_limit= 1; } double Item_exists_subselect::val_real() @@ -854,9 +854,6 @@ Item_in_subselect::single_value_transformer(JOIN *join, else { Item_maxmin_subselect *item; - // remove LIMIT placed by ALL/ANY subquery - select_lex->master_unit()->global_parameters->select_limit= - HA_POS_ERROR; subs= item= new Item_maxmin_subselect(thd, this, select_lex, func->l_op()); if (upper_item) upper_item->set_sub_test(item); @@ -1286,13 +1283,10 @@ subselect_single_select_engine(st_select_lex *select, select_subselect *result, Item_subselect *item) :subselect_engine(item, result), - prepared(0), optimized(0), executed(0), join(0) + prepared(0), optimized(0), executed(0), + select_lex(select), join(0) { - select_lex= select; - SELECT_LEX_UNIT *unit= select_lex->master_unit(); - unit->set_limit(unit->global_parameters, select_lex); - unit->item= item; - this->select_lex= select_lex; + select_lex->master_unit()->item= item; } @@ -1440,7 +1434,10 @@ int subselect_single_select_engine::exec() thd->lex->current_select= select_lex; if (!optimized) { - optimized=1; + SELECT_LEX_UNIT *unit= select_lex->master_unit(); + + optimized= 1; + unit->set_limit(unit->global_parameters); if (join->optimize()) { thd->where= save_where; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 5d11a047a8f..b1618adbfc5 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -884,8 +884,7 @@ bool insert_fields(THD *thd,TABLE_LIST *tables, List_iterator *it, bool any_privileges, bool allocate_view_names); bool setup_tables(THD *thd, TABLE_LIST *tables, Item **conds, - TABLE_LIST **leaves, bool refresh_only, - bool select_insert); + TABLE_LIST **leaves, bool select_insert); int setup_wild(THD *thd, TABLE_LIST *tables, List &fields, List *sum_func_list, uint wild_num); bool setup_fields(THD *thd, Item** ref_pointer_array, TABLE_LIST *tables, diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ca3f5c5af87..51da5783a04 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -7982,8 +7982,17 @@ void QUICK_GROUP_MIN_MAX_SELECT::update_key_stat() } } } - else if (have_min && min_max_arg_part && min_max_arg_part->field->is_null()) + else if (have_min && min_max_arg_part && + min_max_arg_part->field->real_maybe_null()) { + /* + If a MIN/MAX argument value is NULL, we can quickly determine + that we're in the beginning of the next group, because NULLs + are always < any other value. This allows us to quickly + determine the end of the current group and jump to the next + group (see next_min()) and thus effectively increases the + usable key length. + */ max_used_key_length+= min_max_arg_len; ++used_key_parts; } diff --git a/sql/sp.cc b/sql/sp.cc index 9a816f277ed..a5b1f062456 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -667,7 +667,7 @@ db_show_routine_status(THD *thd, int type, const char *wild) tables is not VIEW for sure => we can pass 0 as condition */ - setup_tables(thd, &tables, 0, &leaves, FALSE, FALSE); + setup_tables(thd, &tables, 0, &leaves, FALSE); for (used_field= &used_fields[0]; used_field->field_name; used_field++) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 2e9cf1ae40d..eb212e49aae 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -3208,7 +3208,7 @@ TABLE_LIST **make_leaves_list(TABLE_LIST **list, TABLE_LIST *tables) */ bool setup_tables(THD *thd, TABLE_LIST *tables, Item **conds, - TABLE_LIST **leaves, bool refresh, bool select_insert) + TABLE_LIST **leaves, bool select_insert) { uint tablenr= 0; DBUG_ENTER("setup_tables"); @@ -3261,17 +3261,14 @@ bool setup_tables(THD *thd, TABLE_LIST *tables, Item **conds, my_error(ER_TOO_MANY_TABLES,MYF(0),MAX_TABLES); DBUG_RETURN(1); } - if (!refresh) + for (TABLE_LIST *table_list= tables; + table_list; + table_list= table_list->next_local) { - for (TABLE_LIST *table_list= tables; - table_list; - table_list= table_list->next_local) - { - if (table_list->ancestor && - table_list->setup_ancestor(thd, conds, - table_list->effective_with_check)) - DBUG_RETURN(1); - } + if (table_list->ancestor && + table_list->setup_ancestor(thd, conds, + table_list->effective_with_check)) + DBUG_RETURN(1); } DBUG_RETURN(0); } diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 97830f7ec8f..4ec4258f412 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -300,8 +300,7 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds) SELECT_LEX *select_lex= &thd->lex->select_lex; DBUG_ENTER("mysql_prepare_delete"); - if (setup_tables(thd, table_list, conds, &select_lex->leaf_tables, - FALSE, FALSE) || + if (setup_tables(thd, table_list, conds, &select_lex->leaf_tables, FALSE) || setup_conds(thd, table_list, select_lex->leaf_tables, conds) || setup_ftfuncs(select_lex)) DBUG_RETURN(TRUE); @@ -358,7 +357,7 @@ bool mysql_multi_delete_prepare(THD *thd) lex->query_tables also point on local list of DELETE SELECT_LEX */ if (setup_tables(thd, lex->query_tables, &lex->select_lex.where, - &lex->select_lex.leaf_tables, FALSE, FALSE)) + &lex->select_lex.leaf_tables, FALSE)) DBUG_RETURN(TRUE); diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 3c8e8e55c1f..0cf8d1e93a7 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -651,7 +651,7 @@ bool mysqld_help(THD *thd, const char *mask) tables do not contain VIEWs => we can pass 0 as conds */ - setup_tables(thd, tables, 0, &leaves, FALSE, FALSE); + setup_tables(thd, tables, 0, &leaves, FALSE); memcpy((char*) used_fields, (char*) init_used_fields, sizeof(used_fields)); if (init_fields(thd, tables, used_fields, array_elements(used_fields))) goto error; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 6db7e6a6b18..4727f071c39 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -699,7 +699,7 @@ static bool mysql_prepare_insert_check_table(THD *thd, TABLE_LIST *table_list, DBUG_ENTER("mysql_prepare_insert_check_table"); if (setup_tables(thd, table_list, where, &thd->lex->select_lex.leaf_tables, - FALSE, select_insert)) + select_insert)) DBUG_RETURN(TRUE); if (insert_into_view && !fields.elements) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 7c7939eaf60..ec98bb38762 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1369,8 +1369,6 @@ bool st_select_lex::test_limit() "LIMIT & IN/ALL/ANY/SOME subquery"); return(1); } - // We need only 1 row to determinate existence - select_limit= 1; // no sense in ORDER BY without LIMIT order_list.empty(); return(0); @@ -1553,7 +1551,7 @@ void st_select_lex::print_limit(THD *thd, String *str) item->substype() == Item_subselect::IN_SUBS || item->substype() == Item_subselect::ALL_SUBS)) { - DBUG_ASSERT(select_limit == 1L && offset_limit == 0L); + DBUG_ASSERT(!item->fixed || select_limit == 1L && offset_limit == 0L); return; } @@ -1756,11 +1754,9 @@ bool st_lex::need_correct_ident() SYNOPSIS st_select_lex_unit::set_limit() values - SELECT_LEX with initial values for counters - sl - SELECT_LEX for options set */ -void st_select_lex_unit::set_limit(SELECT_LEX *values, - SELECT_LEX *sl) +void st_select_lex_unit::set_limit(SELECT_LEX *values) { offset_limit_cnt= values->offset_limit; select_limit_cnt= values->select_limit+values->offset_limit; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 3e463cb35ce..06da735c0f2 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -445,10 +445,10 @@ public: void print(String *str); - ulong init_prepare_fake_select_lex(THD *thd); + void init_prepare_fake_select_lex(THD *thd); inline bool is_prepared() { return prepared; } bool change_result(select_subselect *result, select_subselect *old_result); - void set_limit(st_select_lex *values, st_select_lex *sl); + void set_limit(st_select_lex *values); friend void lex_start(THD *thd, uchar *buf, uint length); friend int subselect_union_engine::exec(); diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 1545055f475..cc25839bcc9 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -150,7 +150,7 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, if (open_and_lock_tables(thd, table_list)) DBUG_RETURN(TRUE); if (setup_tables(thd, table_list, &unused_conds, - &thd->lex->select_lex.leaf_tables, FALSE, FALSE)) + &thd->lex->select_lex.leaf_tables, FALSE)) DBUG_RETURN(-1); if (!table_list->table || // do not suport join view !table_list->updatable || // and derived tables diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc index 07271d40492..06d66f8dfd2 100644 --- a/sql/sql_olap.cc +++ b/sql/sql_olap.cc @@ -153,8 +153,7 @@ int handle_olaps(LEX *lex, SELECT_LEX *select_lex) if (setup_tables(lex->thd, (TABLE_LIST *)select_lex->table_list.first - &select_lex->where, &select_lex->leaf_tables, - FALSE, FALSE) || + &select_lex->where, &select_lex->leaf_tables, FALSE) || setup_fields(lex->thd, 0, (TABLE_LIST *)select_lex->table_list.first, select_lex->item_list, 1, &all_fields,1) || setup_fields(lex->thd, 0, (TABLE_LIST *)select_lex->table_list.first, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7078c8e7181..84bf8f76d18 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2777,7 +2777,7 @@ mysql_execute_command(THD *thd) select_result *result; select_lex->options|= SELECT_NO_UNLOCK; - unit->set_limit(select_lex, select_lex); + unit->set_limit(select_lex); if (!(res= open_and_lock_tables(thd, select_tables))) { @@ -3175,7 +3175,7 @@ unsent_create_error: select_lex->options|= SELECT_NO_UNLOCK; select_result *result; - unit->set_limit(select_lex, select_lex); + unit->set_limit(select_lex); if (!(res= open_and_lock_tables(thd, all_tables))) { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 26e8b398844..1a06f80920e 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -233,7 +233,7 @@ bool handle_select(THD *thd, LEX *lex, select_result *result, else { SELECT_LEX_UNIT *unit= &lex->unit; - unit->set_limit(unit->global_parameters, select_lex); + unit->set_limit(unit->global_parameters); /* 'options' of mysql_select will be set in JOIN, as far as JOIN for every PS/SP execution new, we will not need reset this flag if @@ -342,7 +342,7 @@ JOIN::prepare(Item ***rref_pointer_array, if ((!(select_options & OPTION_SETUP_TABLES_DONE) && setup_tables(thd, tables_list, &conds, &select_lex->leaf_tables, - FALSE, FALSE)) || + FALSE)) || setup_wild(thd, tables_list, fields_list, &all_fields, wild_num) || select_lex->setup_ref_array(thd, og_num) || setup_fields(thd, (*rref_pointer_array), tables_list, fields_list, 1, @@ -465,13 +465,6 @@ JOIN::prepare(Item ***rref_pointer_array, count_field_types(&tmp_table_param, all_fields, 0); ref_pointer_array_size= all_fields.elements*sizeof(Item*); this->group= group_list != 0; - row_limit= ((select_distinct || order || group_list) ? HA_POS_ERROR : - unit_arg->select_limit_cnt); - /* select_limit is used to decide if we are likely to scan the whole table */ - select_limit= unit_arg->select_limit_cnt; - if (having || (select_options & OPTION_FOUND_ROWS)) - select_limit= HA_POS_ERROR; - do_send_rows = (unit_arg->select_limit_cnt) ? 1 : 0; unit= unit_arg; #ifdef RESTRICTED_GROUP @@ -550,6 +543,13 @@ JOIN::optimize() DBUG_RETURN(0); optimized= 1; + row_limit= ((select_distinct || order || group_list) ? HA_POS_ERROR : + unit->select_limit_cnt); + /* select_limit is used to decide if we are likely to scan the whole table */ + select_limit= unit->select_limit_cnt; + if (having || (select_options & OPTION_FOUND_ROWS)) + select_limit= HA_POS_ERROR; + do_send_rows = (unit->select_limit_cnt) ? 1 : 0; // Ignore errors of execution if option IGNORE present if (thd->lex->ignore) thd->lex->current_select->no_error= 1; @@ -1110,18 +1110,7 @@ int JOIN::reinit() { DBUG_ENTER("JOIN::reinit"); - /* TODO move to unit reinit */ - unit->set_limit(select_lex, select_lex); - /* conds should not be used here, it is added just for safety */ - if (tables_list) - { - if (setup_tables(thd, tables_list, &conds, &select_lex->leaf_tables, - TRUE, FALSE)) - DBUG_RETURN(1); - } - - /* Reset of sum functions */ first_record= 0; if (exec_tmp_table1) @@ -1147,6 +1136,7 @@ JOIN::reinit() if (tmp_join) restore_tmp(); + /* Reset of sum functions */ if (sum_funcs) { Item_sum *func, **func_ptr= sum_funcs; @@ -13485,7 +13475,7 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result) else { thd->lex->current_select= first; - unit->set_limit(unit->global_parameters, first); + unit->set_limit(unit->global_parameters); res= mysql_select(thd, &first->ref_pointer_array, (TABLE_LIST*) first->table_list.first, first->with_wild, first->item_list, diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 00770ba02a2..21549f76350 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -115,27 +115,15 @@ bool select_union::flush() options of SELECT */ -ulong +void st_select_lex_unit::init_prepare_fake_select_lex(THD *thd) { - ulong options_tmp= thd->options | fake_select_lex->options; thd->lex->current_select= fake_select_lex; - offset_limit_cnt= global_parameters->offset_limit; - select_limit_cnt= global_parameters->select_limit + - global_parameters->offset_limit; - - if (select_limit_cnt < global_parameters->select_limit) - select_limit_cnt= HA_POS_ERROR; // no limit - if (select_limit_cnt == HA_POS_ERROR) - options_tmp&= ~OPTION_FOUND_ROWS; - else if (found_rows_for_union && !thd->lex->describe) - options_tmp|= OPTION_FOUND_ROWS; fake_select_lex->ftfunc_list_alloc.empty(); fake_select_lex->ftfunc_list= &fake_select_lex->ftfunc_list_alloc; fake_select_lex->table_list.link_in_list((byte *)&result_table_list, (byte **) &result_table_list.next_local); - return options_tmp; } @@ -217,10 +205,9 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, goto err; thd_arg->lex->current_select= sl; - set_limit(sl, sl); can_skip_order_by= is_union && - (!sl->braces || select_limit_cnt == HA_POS_ERROR); + (!sl->braces || sl->select_limit == HA_POS_ERROR); res= join->prepare(&sl->ref_pointer_array, (TABLE_LIST*) sl->table_list.first, sl->with_wild, @@ -340,7 +327,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, if (arena->is_stmt_prepare()) { /* prepare fake select to initialize it correctly */ - (void) init_prepare_fake_select_lex(thd); + init_prepare_fake_select_lex(thd); /* Should be done only once (the only item_list per statement). */ @@ -429,12 +416,8 @@ bool st_select_lex_unit::exec() res= sl->join->reinit(); else { - if (sl != global_parameters && !describe) - { - offset_limit_cnt= sl->offset_limit; - select_limit_cnt= sl->select_limit+sl->offset_limit; - } - else + set_limit(sl); + if (sl == global_parameters || describe) { offset_limit_cnt= 0; /* @@ -443,11 +426,7 @@ bool st_select_lex_unit::exec() */ if (sl->order_list.first || describe) select_limit_cnt= HA_POS_ERROR; - else - select_limit_cnt= sl->select_limit+sl->offset_limit; - } - if (select_limit_cnt < sl->select_limit) - select_limit_cnt= HA_POS_ERROR; // no limit + } /* When using braces, SQL_CALC_FOUND_ROWS affects the whole query: @@ -512,7 +491,8 @@ bool st_select_lex_unit::exec() if (!thd->is_fatal_error) // Check if EOM { - ulong options_tmp= init_prepare_fake_select_lex(thd); + set_limit(global_parameters); + init_prepare_fake_select_lex(thd); JOIN *join= fake_select_lex->join; if (!join) { diff --git a/sql/sql_update.cc b/sql/sql_update.cc index a19a3e46798..0d00c38f638 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -557,8 +557,7 @@ bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list, tables.table= table; tables.alias= table_list->alias; - if (setup_tables(thd, table_list, conds, &select_lex->leaf_tables, - FALSE, FALSE) || + if (setup_tables(thd, table_list, conds, &select_lex->leaf_tables, FALSE) || setup_conds(thd, table_list, select_lex->leaf_tables, conds) || select_lex->setup_ref_array(thd, order_num) || setup_order(thd, select_lex->ref_pointer_array, @@ -644,7 +643,7 @@ bool mysql_multi_update_prepare(THD *thd) */ if (setup_tables(thd, table_list, &lex->select_lex.where, - &lex->select_lex.leaf_tables, FALSE, FALSE)) + &lex->select_lex.leaf_tables, FALSE)) DBUG_RETURN(TRUE); leaves= lex->select_lex.leaf_tables; @@ -764,7 +763,7 @@ bool mysql_multi_update_prepare(THD *thd) tbl->cleanup_items(); if (setup_tables(thd, table_list, &lex->select_lex.where, - &lex->select_lex.leaf_tables, FALSE, FALSE) || + &lex->select_lex.leaf_tables, FALSE) || (lex->select_lex.no_wrap_view_item= 1, res= setup_fields(thd, 0, table_list, *fields, 1, 0, 0), lex->select_lex.no_wrap_view_item= 0, From 19b8379af6d35ea6c0767b8ed05ebc49339bd7be Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Mon, 30 May 2005 21:49:59 +0400 Subject: [PATCH 70/98] One more post-review fix. --- sql/sql_union.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 21549f76350..8d36889df76 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -206,9 +206,8 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, thd_arg->lex->current_select= sl; - can_skip_order_by= is_union && - (!sl->braces || sl->select_limit == HA_POS_ERROR); - + can_skip_order_by= is_union && !(sl->braces && sl->explicit_limit); + res= join->prepare(&sl->ref_pointer_array, (TABLE_LIST*) sl->table_list.first, sl->with_wild, sl->where, From cc0061a122336a74b439d14d1d3d1a4528af0f0b Mon Sep 17 00:00:00 2001 From: "ramil@mysql.com" <> Date: Tue, 31 May 2005 10:54:33 +0500 Subject: [PATCH 71/98] a fix (bug #7405: group_concat with distinct and rollup => ignores distinct in some rows). --- mysql-test/r/func_gconcat.result | 23 +++++++++++++++++ mysql-test/t/func_gconcat.test | 12 +++++++++ sql/item_sum.cc | 43 +++++++++++--------------------- 3 files changed, 49 insertions(+), 29 deletions(-) diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index c1ac1c084df..057822839fa 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -469,3 +469,26 @@ x (select group_concat(x) from r2) 1 1,1 2 2,2 drop table r2; +create table t1 (d int, a int, b int, c int); +insert into t1(a,b) values (1,3), (1,4), (1,2), (2,7), (1,1), (1,2), (2,3), (2,3); +select a, group_concat(b) from t1 group by a with rollup; +a group_concat(b) +1 3,4,2,1,2 +2 7,3,3 +NULL 3,4,2,1,2,7,3,3 +select a, group_concat(distinct b) from t1 group by a with rollup; +a group_concat(distinct b) +1 3,4,2,1 +2 7,3 +NULL 3,4,2,1,7 +select a, group_concat(b order by b) from t1 group by a with rollup; +a group_concat(b order by b) +1 1,2,2,3,4 +2 3,3,7 +NULL 1,2,2,3,3,3,4,7 +select a, group_concat(distinct b order by b) from t1 group by a with rollup; +a group_concat(distinct b order by b) +1 1,2,3,4 +2 3,7 +NULL 1,2,3,4,7 +drop table t1; diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index d32c8796075..485e8ba143c 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -292,3 +292,15 @@ create table r2 (a int, b int); insert into r2 values (1,1), (2,2); select b x, (select group_concat(x) from r2) from r2; drop table r2; + +# +# Bug #7405: problems with rollup +# + +create table t1 (d int, a int, b int, c int); +insert into t1(a,b) values (1,3), (1,4), (1,2), (2,7), (1,1), (1,2), (2,3), (2,3); +select a, group_concat(b) from t1 group by a with rollup; +select a, group_concat(distinct b) from t1 group by a with rollup; +select a, group_concat(b order by b) from t1 group by a with rollup; +select a, group_concat(distinct b order by b) from t1 group by a with rollup; +drop table t1; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index fb88fca9a2d..0e252259f53 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1566,7 +1566,6 @@ int group_concat_key_cmp_with_distinct(void* arg, byte* key1, { Item_func_group_concat* grp_item= (Item_func_group_concat*)arg; Item **field_item, **end; - char *record= (char*) grp_item->table->record[0]; for (field_item= grp_item->args, end= field_item + grp_item->arg_count_field; field_item < end; @@ -1581,7 +1580,7 @@ int group_concat_key_cmp_with_distinct(void* arg, byte* key1, if (field) { int res; - uint offset= (uint) (field->ptr - record); + uint offset= field->offset(); if ((res= field->key_cmp(key1 + offset, key2 + offset))) return res; } @@ -1599,7 +1598,6 @@ int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2) { Item_func_group_concat* grp_item= (Item_func_group_concat*) arg; ORDER **order_item, **end; - char *record= (char*) grp_item->table->record[0]; for (order_item= grp_item->order, end=order_item+ grp_item->arg_count_order; order_item < end; @@ -1615,7 +1613,7 @@ int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2) if (field) { int res; - uint offset= (uint) (field->ptr - record); + uint offset= field->offset(); if ((res= field->key_cmp(key1 + offset, key2 + offset))) return (*order_item)->asc ? res : -res; } @@ -1657,7 +1655,6 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)), { char buff[MAX_FIELD_WIDTH]; String tmp((char *)&buff,sizeof(buff),default_charset_info), tmp2; - char *record= (char*) item->table->record[0]; if (item->result.length()) item->result.append(*item->separator); @@ -1677,9 +1674,8 @@ int dump_leaf_key(byte* key, uint32 count __attribute__((unused)), Field *field= show_item->get_tmp_table_field(); String *res; char *save_ptr= field->ptr; - uint offset= (uint) (save_ptr - record); - DBUG_ASSERT(offset < item->table->reclength); - field->ptr= (char *) key + offset; + DBUG_ASSERT(field->offset() < item->table->reclength); + field->ptr= (char *) key + field->offset(); res= field->val_str(&tmp,&tmp2); item->result.append(*res); field->ptr= save_ptr; @@ -1852,12 +1848,6 @@ void Item_func_group_concat::clear() result.copy(); null_value= TRUE; warning_for_row= FALSE; - if (table) - { - table->file->extra(HA_EXTRA_NO_CACHE); - table->file->delete_all_rows(); - table->file->extra(HA_EXTRA_WRITE_CACHE); - } if (tree_mode) reset_tree(tree); } @@ -1870,19 +1860,13 @@ bool Item_func_group_concat::add() copy_fields(tmp_table_param); copy_funcs(tmp_table_param->items_to_copy); - for (uint i= 0; i < arg_count_field; i++) + for (Item **arg= args, **arg_end= args + arg_count_field; + arg < arg_end; arg++) { - Item *show_item= args[i]; - if (!show_item->const_item()) - { - /* - Here we use real_item as we want the original field data that should - be written to table->record[0] - */ - Field *f= show_item->real_item()->get_tmp_table_field(); - if (f->is_null()) + if (!(*arg)->const_item() && + (*arg)->get_tmp_table_field()->is_null_in_record( + (const uchar*) table->record[0])) return 0; // Skip row if it contains null - } } null_value= FALSE; @@ -1945,10 +1929,6 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) null_value= 1; max_length= group_concat_max_len; thd->allow_sum_func= 1; - if (!(tmp_table_param= new TMP_TABLE_PARAM)) - return 1; - /* We'll convert all blobs to varchar fields in the temporary table */ - tmp_table_param->convert_blob_length= group_concat_max_len; tables_list= tables; fixed= 1; return 0; @@ -1967,6 +1947,11 @@ bool Item_func_group_concat::setup(THD *thd) if (select_lex->linkage == GLOBAL_OPTIONS_TYPE) DBUG_RETURN(1); + if (!(tmp_table_param= new TMP_TABLE_PARAM)) + return 1; + /* We'll convert all blobs to varchar fields in the temporary table */ + tmp_table_param->convert_blob_length= group_concat_max_len; + /* push all not constant fields to list and create temp table */ From ddf91f0689d6e066cd356e997a7aebd2aadc1c7b Mon Sep 17 00:00:00 2001 From: "gluh@eagle.intranet.mysql.r18.ru" <> Date: Tue, 31 May 2005 13:15:23 +0500 Subject: [PATCH 72/98] Fix for bug#10059: SHOW TABLE STATUS FROM `information_schema`; reports uppercase table names information schema table names are always upper case table names --- mysql-test/r/information_schema.result | 4 ++-- sql/sql_show.cc | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index ab57a918e98..872d1f6ea7f 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -470,7 +470,7 @@ s1 drop table t1; SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets; Table Create Table -character_sets CREATE TEMPORARY TABLE `character_sets` ( +CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` ( `CHARACTER_SET_NAME` varchar(64) NOT NULL default '', `DEFAULT_COLLATE_NAME` varchar(64) NOT NULL default '', `DESCRIPTION` varchar(60) NOT NULL default '', @@ -479,7 +479,7 @@ character_sets CREATE TEMPORARY TABLE `character_sets` ( set names latin2; SHOW CREATE TABLE INFORMATION_SCHEMA.character_sets; Table Create Table -character_sets CREATE TEMPORARY TABLE `character_sets` ( +CHARACTER_SETS CREATE TEMPORARY TABLE `CHARACTER_SETS` ( `CHARACTER_SET_NAME` varchar(64) NOT NULL default '', `DEFAULT_COLLATE_NAME` varchar(64) NOT NULL default '', `DESCRIPTION` varchar(60) NOT NULL default '', diff --git a/sql/sql_show.cc b/sql/sql_show.cc index c873b9be369..32ad85b88f7 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -396,7 +396,8 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) else { if (table_list->schema_table) - protocol->store(table_list->schema_table_name, system_charset_info); + protocol->store(table_list->schema_table->table_name, + system_charset_info); else protocol->store(table->alias, system_charset_info); if (store_create_info(thd, table_list, &buffer)) @@ -757,7 +758,7 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet) else packet->append("CREATE TABLE ", 13); if (table_list->schema_table) - alias= table_list->schema_table_name; + alias= table_list->schema_table->table_name; else alias= (lower_case_table_names == 2 ? table->alias : share->table_name); From 51d80960ea52e1c3c99bf6287f331a58e1c2b11c Mon Sep 17 00:00:00 2001 From: "ingo@mysql.com" <> Date: Tue, 31 May 2005 11:08:14 +0200 Subject: [PATCH 73/98] Bug#10224 - ANALYZE TABLE crashing with simultaneous CREATE ... SELECT statement. 1.) Added a new option to mysql_lock_tables() for ignoring FLUSH TABLES. Used the new option in create_table_from_items(). It is necessary to prevent the SELECT table from being reopend. It would get new storage assigned for its fields, while the SELECT part of the command would still use the old (freed) storage. 2.) Protected the CREATE TABLE and CREATE TABLE ... SELECT commands against a global read lock. This prevents a deadlock in CREATE TABLE ... SELECT in conjunction with FLUSH TABLES WITH READ LOCK and avoids the creation of new tables during a global read lock. 3.) Replaced set_protect_against_global_read_lock() and unset_protect_against_global_read_lock() by wait_if_global_read_lock() and start_waiting_global_read_lock() in the INSERT DELAYED handling. --- mysql-test/r/create.result | 8 +++++ mysql-test/t/create.test | 15 +++++++++ sql/lock.cc | 69 ++++++++++++-------------------------- sql/mysql_priv.h | 7 ++-- sql/sql_acl.cc | 4 +-- sql/sql_base.cc | 6 ++-- sql/sql_handler.cc | 2 +- sql/sql_insert.cc | 24 +++++++++---- sql/sql_parse.cc | 37 ++++++++++++++++++-- sql/sql_table.cc | 2 +- 10 files changed, 108 insertions(+), 66 deletions(-) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 7cb79d5a990..c99ad8960dc 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -228,3 +228,11 @@ create table t1 (a int,,b int); You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'b int)' at line 1 create table t1 (,b int); You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'b int)' at line 1 +create table t1 (a int); +create table t1 select * from t1; +INSERT TABLE 't1' isn't allowed in FROM table list +create table t2 union = (t1) select * from t1; +INSERT TABLE 't1' isn't allowed in FROM table list +flush tables with read lock; +unlock tables; +drop table t1; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index c71a1e0c177..ed2c76932da 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -203,3 +203,18 @@ create table t1 (a int,); create table t1 (a int,,b int); --error 1064 create table t1 (,b int); + +# +# Bug#10224 - ANALYZE TABLE crashing with simultaneous +# CREATE ... SELECT statement. +# This tests two additional possible errors and a hang if +# an improper fix is present. +# +create table t1 (a int); +--error 1093 +create table t1 select * from t1; +--error 1093 +create table t2 union = (t1) select * from t1; +flush tables with read lock; +unlock tables; +drop table t1; diff --git a/sql/lock.cc b/sql/lock.cc index 951b0e2ff6a..4c6d7c75ae2 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -79,8 +79,24 @@ static int unlock_external(THD *thd, TABLE **table,uint count); static void print_lock_error(int error); -MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, - bool ignore_global_read_lock) +/* + Lock tables. + + SYNOPSIS + mysql_lock_tables() + thd The current thread. + tables An array of pointers to the tables to lock. + count The number of tables to lock. + flags Options: + MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK Ignore a global read lock + MYSQL_LOCK_IGNORE_FLUSH Ignore a flush tables. + + RETURN + A lock structure pointer on success. + NULL on error. +*/ + +MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, uint flags) { MYSQL_LOCK *sql_lock; TABLE *write_lock_used; @@ -91,7 +107,8 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, if (!(sql_lock = get_lock_data(thd,tables,count, 0,&write_lock_used))) break; - if (global_read_lock && write_lock_used && ! ignore_global_read_lock) + if (global_read_lock && write_lock_used && + ! (flags & MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK)) { /* Someone has issued LOCK ALL TABLES FOR READ and we want a write lock @@ -125,7 +142,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, thd->some_tables_deleted=1; // Try again sql_lock->lock_count=0; // Locks are alread freed } - else if (!thd->some_tables_deleted) + else if (!thd->some_tables_deleted || (flags & MYSQL_LOCK_IGNORE_FLUSH)) { thd->locked=0; break; @@ -868,47 +885,3 @@ void make_global_read_lock_block_commit(THD *thd) } -/* - Set protection against global read lock. - - SYNOPSIS - set_protect_against_global_read_lock() - void - - RETURN - FALSE OK, no global read lock exists. - TRUE Error, global read lock exists already. -*/ - -my_bool set_protect_against_global_read_lock(void) -{ - my_bool global_read_lock_exists; - - pthread_mutex_lock(&LOCK_open); - if (! (global_read_lock_exists= test(global_read_lock))) - protect_against_global_read_lock++; - pthread_mutex_unlock(&LOCK_open); - return global_read_lock_exists; -} - - -/* - Unset protection against global read lock. - - SYNOPSIS - unset_protect_against_global_read_lock() - void - - RETURN - void -*/ - -void unset_protect_against_global_read_lock(void) -{ - pthread_mutex_lock(&LOCK_open); - protect_against_global_read_lock--; - pthread_mutex_unlock(&LOCK_open); - pthread_cond_broadcast(&COND_refresh); -} - - diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 6a25536b3f1..75ec3482d8d 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -766,8 +766,11 @@ extern pthread_t signal_thread; extern struct st_VioSSLAcceptorFd * ssl_acceptor_fd; #endif /* HAVE_OPENSSL */ -MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count, - bool ignore_global_read_lock= FALSE); +MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count, uint flags); +/* mysql_lock_tables() flags bits */ +#define MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK 0x0001 +#define MYSQL_LOCK_IGNORE_FLUSH 0x0002 + void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock); void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock); void mysql_unlock_some_tables(THD *thd, TABLE **table,uint count); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index acdd07b2fc5..46b29f252a6 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -177,7 +177,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) ptr[0]= tables[0].table; ptr[1]= tables[1].table; ptr[2]= tables[2].table; - if (!(lock=mysql_lock_tables(thd,ptr,3))) + if (! (lock= mysql_lock_tables(thd, ptr, 3, 0))) { sql_print_error("Fatal error: Can't lock privilege tables: %s", thd->net.last_error); @@ -2514,7 +2514,7 @@ my_bool grant_init(THD *org_thd) TABLE *ptr[2]; // Lock tables for quick update ptr[0]= tables[0].table; ptr[1]= tables[1].table; - if (!(lock=mysql_lock_tables(thd,ptr,2))) + if (! (lock= mysql_lock_tables(thd, ptr, 2, 0))) goto end; t_table = tables[0].table; c_table = tables[1].table; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index c8eb2338294..9c5f73697fd 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1161,7 +1161,7 @@ bool reopen_tables(THD *thd,bool get_locks,bool in_refresh) MYSQL_LOCK *lock; /* We should always get these locks */ thd->some_tables_deleted=0; - if ((lock=mysql_lock_tables(thd,tables,(uint) (tables_ptr-tables)))) + if ((lock= mysql_lock_tables(thd, tables, (uint) (tables_ptr-tables), 0))) { thd->locked_tables=mysql_lock_merge(thd->locked_tables,lock); } @@ -1602,7 +1602,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type) else { if ((table->reginfo.lock_type= lock_type) != TL_UNLOCK) - if (!(thd->lock=mysql_lock_tables(thd,&table_list->table,1))) + if (! (thd->lock= mysql_lock_tables(thd, &table_list->table, 1, 0))) table= 0; } } @@ -1653,7 +1653,7 @@ int lock_tables(THD *thd,TABLE_LIST *tables) return -1; for (table = tables ; table ; table=table->next) *(ptr++)= table->table; - if (!(thd->lock=mysql_lock_tables(thd,start,count))) + if (! (thd->lock= mysql_lock_tables(thd, start, count, 0))) return -1; /* purecov: inspected */ } else diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 5bfcc897fc7..fcdb2aeb668 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -448,7 +448,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, send_fields(thd,list,1); HANDLER_TABLES_HACK(thd); - lock= mysql_lock_tables(thd, &tables->table, 1); + lock= mysql_lock_tables(thd, &tables->table, 1, 0); HANDLER_TABLES_HACK(thd); byte *key; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index c6b7b1d6c15..b61c766120e 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -674,10 +674,13 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list) Avoid that a global read lock steps in while we are creating the new thread. It would block trying to open the table. Hence, the DI thread and this thread would wait until after the global - readlock is gone. If the read lock exists already, we leave with - no table and then switch to non-delayed insert. + readlock is gone. Since the insert thread needs to wait for a + global read lock anyway, we do it right now. Note that + wait_if_global_read_lock() sets a protection against a new + global read lock when it succeeds. This needs to be released by + start_waiting_global_read_lock(). */ - if (set_protect_against_global_read_lock()) + if (wait_if_global_read_lock(thd, 0, 1)) goto err; if (!(tmp=new delayed_insert())) { @@ -719,7 +722,11 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list) pthread_cond_wait(&tmp->cond_client,&tmp->mutex); } pthread_mutex_unlock(&tmp->mutex); - unset_protect_against_global_read_lock(); + /* + Release the protection against the global read lock and wake + everyone, who might want to set a global read lock. + */ + start_waiting_global_read_lock(thd); thd->proc_info="got old table"; if (tmp->thd.killed) { @@ -755,7 +762,11 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list) err1: thd->fatal_error= 1; - unset_protect_against_global_read_lock(); + /* + Release the protection against the global read lock and wake + everyone, who might want to set a global read lock. + */ + start_waiting_global_read_lock(thd); err: pthread_mutex_unlock(&LOCK_delayed_create); DBUG_RETURN(0); // Continue with normal insert @@ -1105,7 +1116,8 @@ extern "C" pthread_handler_decl(handle_delayed_insert,arg) handler will close the table and finish when the outstanding inserts are done. */ - if (! (thd->lock= mysql_lock_tables(thd, &di->table, 1, TRUE))) + if (! (thd->lock= mysql_lock_tables(thd, &di->table, 1, + MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK))) { di->dead=thd->killed=1; // Fatal error } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 8f56b7cfcff..aac442d35a2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1673,6 +1673,24 @@ mysql_execute_command(void) break; } #endif + /* + The create-select command will open and read-lock the select table + and then create, open and write-lock the new table. If a global + read lock steps in, we get a deadlock. The write lock waits for + the global read lock, while the global read lock waits for the + select table to be closed. So we wait until the global readlock is + gone before starting both steps. Note that + wait_if_global_read_lock() sets a protection against a new global + read lock when it succeeds. This needs to be released by + start_waiting_global_read_lock(). We protect the normal CREATE + TABLE in the same way. That way we avoid that a new table is + created during a gobal read lock. + */ + if (wait_if_global_read_lock(thd, 0, 1)) + { + res= -1; + break; + } if (select_lex->item_list.elements) // With select { select_result *result; @@ -1681,7 +1699,7 @@ mysql_execute_command(void) check_dup(tables->db, tables->real_name, tables->next)) { net_printf(&thd->net,ER_INSERT_TABLE_USED,tables->real_name); - DBUG_VOID_RETURN; + goto error1; } if (lex->create_info.used_fields & HA_CREATE_USED_UNION) { @@ -1692,7 +1710,7 @@ mysql_execute_command(void) (TABLE_LIST*)lex->create_info.merge_list.first)) { net_printf(&thd->net, ER_INSERT_TABLE_USED, tab->real_name); - DBUG_VOID_RETURN; + goto error1; } } } @@ -1700,7 +1718,7 @@ mysql_execute_command(void) { TABLE_LIST *table; if (check_table_access(thd, SELECT_ACL, tables->next)) - goto error; // Error message is given + goto error1; // Error message is given /* TODO: Delete the following loop when locks is set by sql_yacc */ for (table = tables->next ; table ; table=table->next) table->lock_type= lex->lock_option; @@ -1737,6 +1755,11 @@ mysql_execute_command(void) if (!res) send_ok(&thd->net); } + /* + Release the protection against the global read lock and wake + everyone, who might want to set a global read lock. + */ + start_waiting_global_read_lock(thd); break; } case SQLCOM_CREATE_INDEX: @@ -2674,6 +2697,14 @@ error: thd->lock= 0; } DBUG_VOID_RETURN; + + error1: + /* + Release the protection against the global read lock and wake + everyone, who might want to set a global read lock. + */ + start_waiting_global_read_lock(thd); + DBUG_VOID_RETURN; } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e275f902abd..a9af8144df0 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -896,7 +896,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, if (!table) DBUG_RETURN(0); table->reginfo.lock_type=TL_WRITE; - if (!((*lock)=mysql_lock_tables(thd,&table,1))) + if (! ((*lock)= mysql_lock_tables(thd, &table, 1, MYSQL_LOCK_IGNORE_FLUSH))) { VOID(pthread_mutex_lock(&LOCK_open)); hash_delete(&open_cache,(byte*) table); From 063896a6e72a663375211c1479bd8b21f8ed2385 Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Tue, 31 May 2005 12:06:15 +0200 Subject: [PATCH 74/98] Post-review fixes of BUG#9937: Crash on call to stored procedure. --- sql/item_cmpfunc.cc | 2 +- sql/item_func.cc | 10 ++++++++-- sql/item_subselect.cc | 2 +- sql/mysql_priv.h | 4 ++-- sql/mysqld.cc | 12 ++++++++---- sql/sp_head.cc | 2 +- sql/sql_parse.cc | 9 ++++++++- sql/table.cc | 2 +- 8 files changed, 30 insertions(+), 13 deletions(-) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 378d3645caf..66f0bf9c395 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2321,7 +2321,7 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) */ and_tables_cache= ~(table_map) 0; - if (check_stack_overrun(thd, STACK_MIN_SIZE)) + if (check_stack_overrun(thd, STACK_MIN_SIZE, buff)) return TRUE; // Fatal error flag is set! /* The following optimization reduces the depth of an AND-OR tree. diff --git a/sql/item_func.cc b/sql/item_func.cc index 13c9aa92d6e..47dffa679e9 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -293,11 +293,14 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) { DBUG_ASSERT(fixed == 0); Item **arg,**arg_end; +#ifndef EMBEDDED_LIBRARY // Avoid compiler warning + char buff[STACK_BUFF_ALLOC]; // Max argument in function +#endif used_tables_cache= not_null_tables_cache= 0; const_item_cache=1; - if (check_stack_overrun(thd, STACK_MIN_SIZE+STACK_BUFF_ALLOC)) + if (check_stack_overrun(thd, STACK_MIN_SIZE, buff)) return TRUE; // Fatal error if flag is set! if (arg_count) { // Print purify happy @@ -2564,9 +2567,12 @@ bool udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, uint arg_count, Item **arguments) { +#ifndef EMBEDDED_LIBRARY // Avoid compiler warning + char buff[STACK_BUFF_ALLOC]; // Max argument in function +#endif DBUG_ENTER("Item_udf_func::fix_fields"); - if (check_stack_overrun(thd, STACK_MIN_SIZE+STACK_BUFF_ALLOC)) + if (check_stack_overrun(thd, STACK_MIN_SIZE, buff)) DBUG_RETURN(TRUE); // Fatal error flag is set! udf_func *tmp_udf=find_udf(u_d->name.str,(uint) u_d->name.length,1); diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 328bc75757b..5c26f3c079c 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -138,7 +138,7 @@ bool Item_subselect::fix_fields(THD *thd_param, TABLE_LIST *tables, Item **ref) DBUG_ASSERT(fixed == 0); engine->set_thd((thd= thd_param)); - if (check_stack_overrun(thd, STACK_MIN_SIZE)) + if (check_stack_overrun(thd, STACK_MIN_SIZE, (gptr)&res)) return TRUE; res= engine->prepare(); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index e9a325f1fa7..eb7fa68e8e8 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1429,11 +1429,11 @@ inline int hexchar_to_int(char c) #ifndef EMBEDDED_LIBRARY extern "C" void unireg_abort(int exit_code); void kill_delayed_threads(void); -bool check_stack_overrun(THD *thd, long margin); +bool check_stack_overrun(THD *thd, long margin, char *dummy); #else #define unireg_abort(exit_code) DBUG_RETURN(exit_code) inline void kill_delayed_threads(void) {} -#define check_stack_overrun(A, B) 0 +#define check_stack_overrun(A, B, C) 0 #endif #endif /* MYSQL_CLIENT */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e3a74d378fa..5479a5466f0 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2091,8 +2091,10 @@ static void start_signal_handler(void) if (!(opt_specialflag & SPECIAL_NO_PRIOR)) my_pthread_attr_setprio(&thr_attr,INTERRUPT_PRIOR); #if defined(__ia64__) || defined(__ia64) - /* Peculiar things with ia64 platforms - it seems we only have half the - stack size in reality, so we have to double it here */ + /* + Peculiar things with ia64 platforms - it seems we only have half the + stack size in reality, so we have to double it here + */ pthread_attr_setstacksize(&thr_attr,thread_stack*2); #else pthread_attr_setstacksize(&thr_attr,thread_stack); @@ -3018,8 +3020,10 @@ int main(int argc, char **argv) if (!(opt_specialflag & SPECIAL_NO_PRIOR)) my_pthread_setprio(pthread_self(),CONNECT_PRIOR); #if defined(__ia64__) || defined(__ia64) - /* Peculiar things with ia64 platforms - it seems we only have half the - stack size in reality, so we have to double it here */ + /* + Peculiar things with ia64 platforms - it seems we only have half the + stack size in reality, so we have to double it here + */ pthread_attr_setstacksize(&connection_attrib,thread_stack*2); #else pthread_attr_setstacksize(&connection_attrib,thread_stack); diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 9d055d55f54..fcca1b51d1c 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -565,7 +565,7 @@ sp_head::execute(THD *thd) String old_packet; /* Use some extra margin for possible SP recursion and functions */ - if (check_stack_overrun(thd, 4*STACK_MIN_SIZE)) + if (check_stack_overrun(thd, 4*STACK_MIN_SIZE, olddb)) { DBUG_RETURN(-1); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7edd93f8d0d..e2746ffbdc8 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4986,7 +4986,14 @@ long max_stack_used; #endif #ifndef EMBEDDED_LIBRARY -bool check_stack_overrun(THD *thd, long margin) +/* + Note: The 'buf' parameter is necessary, even if it is unused here. + - fix_fields functions has a "dummy" buffer large enough for the + corresponding exec. (Thus we only have to check in fix_fields.) + - Passing to check_stack_overrun() prevents the compiler from removing it. + */ +bool check_stack_overrun(THD *thd, long margin, + char *buf __attribute__((unused))) { long stack_used; if ((stack_used=used_stack(thd->thread_stack,(char*) &stack_used)) >= diff --git a/sql/table.cc b/sql/table.cc index bc31a38f24a..eb4dbe5a1f3 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1815,7 +1815,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds, bool res= FALSE; DBUG_ENTER("st_table_list::setup_ancestor"); - if (check_stack_overrun(thd, STACK_MIN_SIZE)) + if (check_stack_overrun(thd, STACK_MIN_SIZE, (char *)&res)) return TRUE; for (tbl= ancestor; tbl; tbl= tbl->next_local) From 7eaf78de853ede1b3fb5e3cb0362a1b8f4a9b9f0 Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Tue, 31 May 2005 13:12:23 +0200 Subject: [PATCH 75/98] Small bug fix in SP item reusal (debug mode only). --- sql/item.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index bf62aa1ddad..52046b8eefb 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -301,10 +301,10 @@ void *Item::operator new(size_t size, Item *reuse, uint *rsize) { if (reuse && size <= reuse->rsize) { - reuse->cleanup(); - TRASH((void *)reuse, size); if (rsize) (*rsize)= reuse->rsize; + reuse->cleanup(); + TRASH((void *)reuse, size); return (void *)reuse; } if (rsize) From 13351aae48444e77961632ab5f3ab3c9aad63a3c Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Tue, 31 May 2005 04:49:52 -0700 Subject: [PATCH 76/98] olap.result: Post merge corrections. --- mysql-test/r/olap.result | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index 78326511f00..f3324838ef7 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -249,11 +249,11 @@ select product, country_id , year, sum(profit) from t1 group by product, country product country_id year sum(profit) select concat(':',product,':'), sum(profit),avg(profit) from t1 group by product with rollup; concat(':',product,':') sum(profit) avg(profit) -:Calculator: 275 68.7500 -:Computer: 6900 1380.0000 -:Phone: 10 10.0000 -:TV: 600 120.0000 -:TV: 7785 519.0000 +:Calculator: 275 68.75000 +:Computer: 6900 1380.00000 +:Phone: 10 10.00000 +:TV: 600 120.00000 +NULL 7785 519.00000 select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube; ERROR 42000: This version of MySQL doesn't yet support 'CUBE' explain select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube; @@ -503,7 +503,7 @@ a+1 NULL SELECT a+SUM(a) FROM t1 GROUP BY a WITH ROLLUP; a+SUM(a) -2 +3 4 NULL SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING b > 2; From a7d28e20aaaf86a6f4007aa1c3586ac9777a2b45 Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Tue, 31 May 2005 05:56:22 -0700 Subject: [PATCH 77/98] olap.result: Fixed bug #10982. item.cc: Fixed bug #10982. In the function Item_ref::val_decimal by mistake the method Item_ref::val_decimal was used instead of Item_ref::val_decimal_result. --- mysql-test/r/olap.result | 2 +- sql/item.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index f3324838ef7..5ba2bc80484 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -503,7 +503,7 @@ a+1 NULL SELECT a+SUM(a) FROM t1 GROUP BY a WITH ROLLUP; a+SUM(a) -3 +2 4 NULL SELECT a, a+1 as b FROM t1 GROUP BY a WITH ROLLUP HAVING b > 2; diff --git a/sql/item.cc b/sql/item.cc index bf62aa1ddad..ef358d084f9 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4358,7 +4358,7 @@ bool Item_ref::get_date(TIME *ltime,uint fuzzydate) my_decimal *Item_ref::val_decimal(my_decimal *decimal_value) { - my_decimal *val= (*ref)->val_decimal(decimal_value); + my_decimal *val= (*ref)->val_decimal_result(decimal_value); null_value= (*ref)->null_value; return val; } From 01f40369898b31172c0568bb9ebc3594ae6d2cad Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com" <> Date: Tue, 31 May 2005 20:56:32 +0500 Subject: [PATCH 78/98] WL#2286 - Compile MySQL w/YASSL support merge with latest yaSSL, move templates instantiation into separate file where it is possible --- extra/yassl/include/buffer.hpp | 3 +- extra/yassl/include/crypto_wrapper.hpp | 6 +- extra/yassl/include/socket_wrapper.hpp | 2 +- extra/yassl/include/yassl_imp.hpp | 10 +- extra/yassl/include/yassl_types.hpp | 45 ++++++ extra/yassl/mySTL/helpers.hpp | 1 + extra/yassl/mySTL/list.hpp | 32 ++-- extra/yassl/mySTL/memory.hpp | 41 ++++-- extra/yassl/mySTL/vector.hpp | 7 +- extra/yassl/src/Makefile.am | 2 +- extra/yassl/src/buffer.cpp | 19 ++- extra/yassl/src/cert_wrapper.cpp | 17 +-- extra/yassl/src/crypto_wrapper.cpp | 114 +++++++++------ extra/yassl/src/handshake.cpp | 42 +++--- extra/yassl/src/lock.cpp | 1 - extra/yassl/src/log.cpp | 1 - extra/yassl/src/socket_wrapper.cpp | 1 - extra/yassl/src/ssl.cpp | 35 +++-- extra/yassl/src/template_instnt.cpp | 67 +++++++++ extra/yassl/src/timer.cpp | 1 - extra/yassl/src/yassl_error.cpp | 1 - extra/yassl/src/yassl_imp.cpp | 134 +++++++---------- extra/yassl/src/yassl_int.cpp | 146 +++++++++++-------- extra/yassl/taocrypt/include/algebra.hpp | 6 +- extra/yassl/taocrypt/include/asn.hpp | 6 +- extra/yassl/taocrypt/include/block.hpp | 4 +- extra/yassl/taocrypt/include/hash.hpp | 8 +- extra/yassl/taocrypt/include/integer.hpp | 11 +- extra/yassl/taocrypt/include/misc.hpp | 106 ++++++-------- extra/yassl/taocrypt/include/modes.hpp | 2 +- extra/yassl/taocrypt/include/runtime.hpp | 24 --- extra/yassl/taocrypt/include/type_traits.hpp | 80 ++++++++++ extra/yassl/taocrypt/include/types.hpp | 99 +++++++++++++ extra/yassl/taocrypt/src/Makefile.am | 3 +- extra/yassl/taocrypt/src/aestables.cpp | 1 - extra/yassl/taocrypt/src/algebra.cpp | 2 - extra/yassl/taocrypt/src/arc4.cpp | 1 - extra/yassl/taocrypt/src/asn.cpp | 30 ++-- extra/yassl/taocrypt/src/coding.cpp | 1 - extra/yassl/taocrypt/src/dh.cpp | 1 - extra/yassl/taocrypt/src/dsa.cpp | 1 - extra/yassl/taocrypt/src/file.cpp | 1 - extra/yassl/taocrypt/src/integer.cpp | 24 +-- extra/yassl/taocrypt/src/misc.cpp | 61 +++++++- extra/yassl/taocrypt/src/random.cpp | 1 - extra/yassl/taocrypt/src/rsa.cpp | 18 --- extra/yassl/taocrypt/src/template_instnt.cpp | 31 ++++ 47 files changed, 793 insertions(+), 457 deletions(-) create mode 100644 extra/yassl/src/template_instnt.cpp create mode 100644 extra/yassl/taocrypt/include/type_traits.hpp create mode 100644 extra/yassl/taocrypt/include/types.hpp create mode 100644 extra/yassl/taocrypt/src/template_instnt.cpp diff --git a/extra/yassl/include/buffer.hpp b/extra/yassl/include/buffer.hpp index cdf44ee60a5..8d94675f5b0 100644 --- a/extra/yassl/include/buffer.hpp +++ b/extra/yassl/include/buffer.hpp @@ -28,6 +28,7 @@ #define yaSSL_BUFFER_HPP #include // assert +#include "yassl_types.hpp" // ysDelete #include "yassl_error.hpp" // Error #include "memory.hpp" // mySTL::auto_ptr #include "algorithm.hpp" // mySTL::swap @@ -183,7 +184,7 @@ inline void checked_delete(T* p) { typedef char complete_type[sizeof(T) ? 1 : -1]; (void)sizeof(complete_type); - delete p; + ysDelete(p); } diff --git a/extra/yassl/include/crypto_wrapper.hpp b/extra/yassl/include/crypto_wrapper.hpp index fa60c774cd9..ca9d870677e 100644 --- a/extra/yassl/include/crypto_wrapper.hpp +++ b/extra/yassl/include/crypto_wrapper.hpp @@ -43,7 +43,7 @@ namespace yaSSL { // Digest policy should implement a get_digest, update, and get sizes for pad and // digest -struct Digest { +struct Digest : public virtual_base { virtual void get_digest(byte*) = 0; virtual void get_digest(byte*, const byte*, unsigned int) = 0; virtual void update(const byte*, unsigned int) = 0; @@ -178,7 +178,7 @@ private: // BulkCipher policy should implement encrypt, decrypt, get block size, // and set keys for encrypt and decrypt -struct BulkCipher { +struct BulkCipher : public virtual_base { virtual void encrypt(byte*, const byte*, unsigned int) = 0; virtual void decrypt(byte*, const byte*, unsigned int) = 0; virtual void set_encryptKey(const byte*, const byte* = 0) = 0; @@ -308,7 +308,7 @@ private: // Authentication policy should implement sign, and verify -struct Auth { +struct Auth : public virtual_base { virtual void sign(byte*, const byte*, unsigned int, const RandomPool&) = 0; virtual bool verify(const byte*, unsigned int, const byte*, unsigned int) = 0; diff --git a/extra/yassl/include/socket_wrapper.hpp b/extra/yassl/include/socket_wrapper.hpp index 2a4ac142ec8..a103cca1b37 100644 --- a/extra/yassl/include/socket_wrapper.hpp +++ b/extra/yassl/include/socket_wrapper.hpp @@ -68,7 +68,7 @@ class Socket { socket_t socket_; // underlying socket descriptor public: explicit Socket(socket_t s = INVALID_SOCKET); - virtual ~Socket(); + ~Socket(); void set_fd(socket_t s); uint get_ready() const; diff --git a/extra/yassl/include/yassl_imp.hpp b/extra/yassl/include/yassl_imp.hpp index 52108b6aa1c..3de58901f8e 100644 --- a/extra/yassl/include/yassl_imp.hpp +++ b/extra/yassl/include/yassl_imp.hpp @@ -63,7 +63,7 @@ struct RecordLayerHeader { // base for all messages -struct Message { +struct Message : public virtual_base { virtual input_buffer& set(input_buffer&) =0; virtual output_buffer& get(output_buffer&) const =0; @@ -175,7 +175,7 @@ private: // Base Class for all handshake messages -class HandShakeBase { +class HandShakeBase : public virtual_base { int length_; public: int get_length() const; @@ -327,7 +327,7 @@ private: }; -struct ServerKeyBase { +struct ServerKeyBase : public virtual_base { virtual ~ServerKeyBase() {} virtual void build(SSL&) {} virtual void read(SSL&, input_buffer&) {} @@ -342,7 +342,7 @@ struct Fortezza_Server : public ServerKeyBase { }; -struct SignatureBase { +struct SignatureBase : public virtual_base { virtual ~SignatureBase() {} }; @@ -461,7 +461,7 @@ struct PreMasterSecret { }; -struct ClientKeyBase { +struct ClientKeyBase : public virtual_base { virtual ~ClientKeyBase() {} virtual void build(SSL&) {} virtual void read(SSL&, input_buffer&) {} diff --git a/extra/yassl/include/yassl_types.hpp b/extra/yassl/include/yassl_types.hpp index 28f673f920d..fc6bef89aab 100644 --- a/extra/yassl/include/yassl_types.hpp +++ b/extra/yassl/include/yassl_types.hpp @@ -28,10 +28,55 @@ #define yaSSL_TYPES_HPP #include +#include +#include "type_traits.hpp" namespace yaSSL { +// library allocation +struct new_t {}; // yaSSL New type +extern new_t ys; // pass in parameter + +} // namespace yaSSL + +void* operator new (size_t, yaSSL::new_t); +void* operator new[](size_t, yaSSL::new_t); + +void operator delete (void*, yaSSL::new_t); +void operator delete[](void*, yaSSL::new_t); + + +namespace yaSSL { + + +template +void ysDelete(T* ptr) +{ + if (ptr) ptr->~T(); + ::operator delete(ptr, yaSSL::ys); +} + +template +void ysArrayDelete(T* ptr) +{ + // can't do array placement destruction since not tracking size in + // allocation, only allow builtins to use array placement since they + // don't need destructors called + typedef char builtin[TaoCrypt::IsFundamentalType::Yes ? 1 : -1]; + (void)sizeof(builtin); + + ::operator delete[](ptr, yaSSL::ys); +} + + +// to resolve compiler generated operator delete on base classes with +// virtual destructors, make sure doesn't get called +class virtual_base { +public: + static void operator delete(void*) { assert(0); } +}; + typedef unsigned char uint8; typedef unsigned short uint16; diff --git a/extra/yassl/mySTL/helpers.hpp b/extra/yassl/mySTL/helpers.hpp index 779389e322a..5f9b4beaa40 100644 --- a/extra/yassl/mySTL/helpers.hpp +++ b/extra/yassl/mySTL/helpers.hpp @@ -28,6 +28,7 @@ #define mySTL_HELPERS_HPP #include +#include // placement new #ifdef __IBMCPP__ diff --git a/extra/yassl/mySTL/list.hpp b/extra/yassl/mySTL/list.hpp index be149b1a984..8aaeefaafe8 100644 --- a/extra/yassl/mySTL/list.hpp +++ b/extra/yassl/mySTL/list.hpp @@ -29,7 +29,7 @@ #include "helpers.hpp" -#include // ::operator new and delete, placement too +#include namespace mySTL { @@ -38,13 +38,15 @@ namespace mySTL { template class list { + #ifdef __SUNPRO_CC /* - Sun Forte 7 C++ v. 5.4 needs class 'node' be public to be visible to - the nested class 'iterator' (a non-standard behaviour). + Sun Forte 7 C++ v. 5.4 needs class 'node' public to be visible to + the nested class 'iterator' (a non-standard behaviour). */ public: #endif + struct node { node(T t) : prev_(0), next_(0), value_(t) {} @@ -94,22 +96,22 @@ public: return *this; } - iterator& operator++(int) + iterator operator++(int) { iterator tmp = *this; current_ = current_->next_; - return *this; + return tmp; } - iterator& operator--(int) + iterator operator--(int) { iterator tmp = *this; current_ = current_->prev_; - return *this; + return tmp; } bool operator==(const iterator& other) const - { + { return current_ == other.current_; } @@ -152,7 +154,7 @@ list::~list() for (; start; start = next_) { next_ = start->next_; destroy(start); - ::operator delete(start); + free(start); } } @@ -160,7 +162,7 @@ list::~list() template void list::push_front(T t) { - void* mem = ::operator new(sizeof(node)); + void* mem = malloc(sizeof(node)); if (!mem) abort(); node* add = new (mem) node(t); @@ -190,7 +192,7 @@ void list::pop_front() head_->prev_ = 0; } destroy(front); - ::operator delete(front); + free(front); --sz_; } @@ -206,7 +208,7 @@ T list::front() const template void list::push_back(T t) { - void* mem = ::operator new(sizeof(node)); + void* mem = malloc(sizeof(node)); if (!mem) abort(); node* add = new (mem) node(t); @@ -236,7 +238,7 @@ void list::pop_back() tail_->next_ = 0; } destroy(rear); - ::operator delete(rear); + free(rear); --sz_; } @@ -280,7 +282,7 @@ bool list::remove(T t) del->next_->prev_ = del->prev_; destroy(del); - ::operator delete(del); + free(del); --sz_; } return true; @@ -303,7 +305,7 @@ bool list::erase(iterator iter) del->next_->prev_ = del->prev_; destroy(del); - ::operator delete(del); + free(del); --sz_; } return true; diff --git a/extra/yassl/mySTL/memory.hpp b/extra/yassl/mySTL/memory.hpp index 4049ed80813..729abae7ebc 100644 --- a/extra/yassl/mySTL/memory.hpp +++ b/extra/yassl/mySTL/memory.hpp @@ -37,30 +37,42 @@ namespace mySTL { -template +template struct auto_ptr_ref { - T* ptr_; - explicit auto_ptr_ref(T* p) : ptr_(p) {} + T* ptr_; + Deletor del_; + auto_ptr_ref(T* p, Deletor d) : ptr_(p), del_(d) {} }; -template +template class auto_ptr { - T* ptr_; + T* ptr_; + Deletor del_; + + void Destroy() + { + del_(ptr_); + } public: - explicit auto_ptr(T* p = 0) : ptr_(p) {} + auto_ptr(T* p, Deletor d) : ptr_(p), del_(d) {} + + explicit auto_ptr(Deletor d) : ptr_(0), del_(d) {} + ~auto_ptr() { - delete ptr_; + Destroy(); } - auto_ptr(auto_ptr& other) : ptr_(other.release()) {} + auto_ptr(auto_ptr& other) : ptr_(other.release()), del_(other.del_) {} + auto_ptr& operator=(auto_ptr& that) { if (this != &that) { - delete ptr_; + Destroy(); ptr_ = that.release(); + del_ = that.del_; } return *this; } @@ -91,19 +103,20 @@ public: void reset(T* p = 0) { if (ptr_ != p) { - delete ptr_; + Destroy(); ptr_ = p; } } // auto_ptr_ref conversions - auto_ptr(auto_ptr_ref ref) : ptr_(ref.ptr_) {} + auto_ptr(auto_ptr_ref ref) : ptr_(ref.ptr_), del_(ref.del_) {} auto_ptr& operator=(auto_ptr_ref ref) { if (this->ptr_ != ref.ptr_) { - delete ptr_; + Destroy(); ptr_ = ref.ptr_; + del_ = ref.del_; } return *this; } @@ -111,13 +124,13 @@ public: template operator auto_ptr() { - return auto_ptr(this->release()); + return auto_ptr(this->release(), this->del_); } template operator auto_ptr_ref() { - return auto_ptr_ref(this->release()); + return auto_ptr_ref(this->release(), this->del_); } }; diff --git a/extra/yassl/mySTL/vector.hpp b/extra/yassl/mySTL/vector.hpp index 6d5a9b6c057..e7f63c37c7c 100644 --- a/extra/yassl/mySTL/vector.hpp +++ b/extra/yassl/mySTL/vector.hpp @@ -27,11 +27,10 @@ #ifndef mySTL_VECTOR_HPP #define mySTL_VECTOR_HPP - #include "helpers.hpp" // construct, destory, fill, etc. #include "algorithm.hpp" // swap -#include // ::operator new and delete, placement too #include // assert +#include // malloc namespace mySTL { @@ -46,13 +45,13 @@ struct vector_base { vector_base() : start_(0), finish_(0), end_of_storage_(0) {} vector_base(size_t n) { - start_ = static_cast(::operator new(n * sizeof(T))); + start_ = static_cast(malloc(n * sizeof(T))); if (!start_) abort(); finish_ = start_; end_of_storage_ = start_ + n; } - ~vector_base() { ::operator delete(start_); } + ~vector_base() { if (start_) free(start_); } void Swap(vector_base& that) { diff --git a/extra/yassl/src/Makefile.am b/extra/yassl/src/Makefile.am index 3dbd7bac03a..1f5f1ee7a4e 100644 --- a/extra/yassl/src/Makefile.am +++ b/extra/yassl/src/Makefile.am @@ -3,5 +3,5 @@ INCLUDES = -I../include -I../taocrypt/include -I../mySTL noinst_LIBRARIES = libyassl.a libyassl_a_SOURCES = buffer.cpp cert_wrapper.cpp crypto_wrapper.cpp \ handshake.cpp lock.cpp log.cpp socket_wrapper.cpp ssl.cpp \ - timer.cpp yassl_imp.cpp yassl_error.cpp yassl_int.cpp + template_instnt.cpp timer.cpp yassl_imp.cpp yassl_error.cpp yassl_int.cpp EXTRA_DIST = ../include/*.hpp ../include/openssl/*.h diff --git a/extra/yassl/src/buffer.cpp b/extra/yassl/src/buffer.cpp index 6dc8845559c..a3a09121800 100644 --- a/extra/yassl/src/buffer.cpp +++ b/extra/yassl/src/buffer.cpp @@ -24,7 +24,6 @@ * with SSL types and sockets */ -#include "runtime.hpp" #include "buffer.hpp" #include "yassl_types.hpp" @@ -62,13 +61,13 @@ input_buffer::input_buffer() input_buffer::input_buffer(uint s) - : size_(0), current_(0), buffer_(new byte[s]), end_(buffer_ + s) + : size_(0), current_(0), buffer_(new (ys) byte[s]), end_(buffer_ + s) {} // with assign input_buffer::input_buffer(uint s, const byte* t, uint len) - : size_(0), current_(0), buffer_(new byte[s]), end_(buffer_ + s) + : size_(0), current_(0), buffer_(new (ys) byte[s]), end_(buffer_ + s) { assign(t, len); } @@ -76,7 +75,7 @@ input_buffer::input_buffer(uint s, const byte* t, uint len) input_buffer::~input_buffer() { - delete [] buffer_; + ysArrayDelete(buffer_); } @@ -84,7 +83,7 @@ input_buffer::~input_buffer() void input_buffer::allocate(uint s) { assert(!buffer_); // find realloc error - buffer_ = new byte[s]; + buffer_ = new (ys) byte[s]; end_ = buffer_ + s; } @@ -96,7 +95,7 @@ byte* input_buffer::get_buffer() const } -// after a raw write user can set new size +// after a raw write user can set new (ys) size // if you know the size before the write use assign() void input_buffer::add_size(uint i) { @@ -198,13 +197,13 @@ output_buffer::output_buffer() // with allocate output_buffer::output_buffer(uint s) - : current_(0), buffer_(new byte[s]), end_(buffer_ + s) + : current_(0), buffer_(new (ys) byte[s]), end_(buffer_ + s) {} // with assign output_buffer::output_buffer(uint s, const byte* t, uint len) - : current_(0), buffer_(new byte[s]), end_(buffer_+ s) + : current_(0), buffer_(new (ys) byte[s]), end_(buffer_+ s) { write(t, len); } @@ -212,7 +211,7 @@ output_buffer::output_buffer(uint s, const byte* t, uint len) output_buffer::~output_buffer() { - delete [] buffer_; + ysArrayDelete(buffer_); } @@ -239,7 +238,7 @@ void output_buffer::set_current(uint c) void output_buffer::allocate(uint s) { assert(!buffer_); // find realloc error - buffer_ = new byte[s]; end_ = buffer_ + s; + buffer_ = new (ys) byte[s]; end_ = buffer_ + s; } diff --git a/extra/yassl/src/cert_wrapper.cpp b/extra/yassl/src/cert_wrapper.cpp index 33c1fee6ec3..7a8c7dfe253 100644 --- a/extra/yassl/src/cert_wrapper.cpp +++ b/extra/yassl/src/cert_wrapper.cpp @@ -24,7 +24,6 @@ * */ -#include "runtime.hpp" #include "cert_wrapper.hpp" #include "yassl_int.hpp" @@ -39,19 +38,19 @@ namespace yaSSL { -x509::x509(uint sz) : length_(sz), buffer_(new opaque[sz]) +x509::x509(uint sz) : length_(sz), buffer_(new (ys) opaque[sz]) { } x509::~x509() { - delete [] buffer_; + ysArrayDelete(buffer_); } x509::x509(const x509& that) : length_(that.length_), - buffer_(new opaque[length_]) + buffer_(new (ys) opaque[length_]) { memcpy(buffer_, that.buffer_, length_); } @@ -98,7 +97,7 @@ CertManager::CertManager() CertManager::~CertManager() { - delete peerX509_; + ysDelete(peerX509_); mySTL::for_each(signers_.begin(), signers_.end(), del_ptr_zero()) ; @@ -153,7 +152,7 @@ void CertManager::AddPeerCert(x509* x) void CertManager::CopySelfCert(const x509* x) { if (x) - list_.push_back(new x509(*x)); + list_.push_back(new (ys) x509(*x)); } @@ -165,7 +164,7 @@ int CertManager::CopyCaCert(const x509* x) if (!cert.GetError().What()) { const TaoCrypt::PublicKey& key = cert.GetPublicKey(); - signers_.push_back(new TaoCrypt::Signer(key.GetKey(), key.size(), + signers_.push_back(new (ys) TaoCrypt::Signer(key.GetKey(), key.size(), cert.GetCommonName(), cert.GetHash())); } return cert.GetError().What(); @@ -234,7 +233,7 @@ int CertManager::Validate() return err; const TaoCrypt::PublicKey& key = cert.GetPublicKey(); - signers_.push_back(new TaoCrypt::Signer(key.GetKey(), key.size(), + signers_.push_back(new (ys) TaoCrypt::Signer(key.GetKey(), key.size(), cert.GetCommonName(), cert.GetHash())); --last; --count; @@ -259,7 +258,7 @@ int CertManager::Validate() int iSz = cert.GetIssuer() ? strlen(cert.GetIssuer()) + 1 : 0; int sSz = cert.GetCommonName() ? strlen(cert.GetCommonName()) + 1 : 0; - peerX509_ = new X509(cert.GetIssuer(), iSz, cert.GetCommonName(), + peerX509_ = new (ys) X509(cert.GetIssuer(), iSz, cert.GetCommonName(), sSz); } return 0; diff --git a/extra/yassl/src/crypto_wrapper.cpp b/extra/yassl/src/crypto_wrapper.cpp index e6b28cd9302..ff1b4b630c2 100644 --- a/extra/yassl/src/crypto_wrapper.cpp +++ b/extra/yassl/src/crypto_wrapper.cpp @@ -58,13 +58,13 @@ struct MD5::MD5Impl { }; -MD5::MD5() : pimpl_(new MD5Impl) {} +MD5::MD5() : pimpl_(new (ys) MD5Impl) {} -MD5::~MD5() { delete pimpl_; } +MD5::~MD5() { ysDelete(pimpl_); } -MD5::MD5(const MD5& that) : Digest(), pimpl_(new +MD5::MD5(const MD5& that) : Digest(), pimpl_(new (ys) MD5Impl(that.pimpl_->md5_)) {} @@ -116,13 +116,13 @@ struct SHA::SHAImpl { }; -SHA::SHA() : pimpl_(new SHAImpl) {} +SHA::SHA() : pimpl_(new (ys) SHAImpl) {} -SHA::~SHA() { delete pimpl_; } +SHA::~SHA() { ysDelete(pimpl_); } -SHA::SHA(const SHA& that) : Digest(), pimpl_(new SHAImpl(that.pimpl_->sha_)) {} +SHA::SHA(const SHA& that) : Digest(), pimpl_(new (ys) SHAImpl(that.pimpl_->sha_)) {} SHA& SHA::operator=(const SHA& that) { @@ -173,13 +173,13 @@ struct RMD::RMDImpl { }; -RMD::RMD() : pimpl_(new RMDImpl) {} +RMD::RMD() : pimpl_(new (ys) RMDImpl) {} -RMD::~RMD() { delete pimpl_; } +RMD::~RMD() { ysDelete(pimpl_); } -RMD::RMD(const RMD& that) : Digest(), pimpl_(new RMDImpl(that.pimpl_->rmd_)) {} +RMD::RMD(const RMD& that) : Digest(), pimpl_(new (ys) RMDImpl(that.pimpl_->rmd_)) {} RMD& RMD::operator=(const RMD& that) { @@ -230,13 +230,13 @@ struct HMAC_MD5::HMAC_MD5Impl { HMAC_MD5::HMAC_MD5(const byte* secret, unsigned int len) - : pimpl_(new HMAC_MD5Impl) + : pimpl_(new (ys) HMAC_MD5Impl) { pimpl_->mac_.SetKey(secret, len); } -HMAC_MD5::~HMAC_MD5() { delete pimpl_; } +HMAC_MD5::~HMAC_MD5() { ysDelete(pimpl_); } uint HMAC_MD5::get_digestSize() const @@ -280,13 +280,13 @@ struct HMAC_SHA::HMAC_SHAImpl { HMAC_SHA::HMAC_SHA(const byte* secret, unsigned int len) - : pimpl_(new HMAC_SHAImpl) + : pimpl_(new (ys) HMAC_SHAImpl) { pimpl_->mac_.SetKey(secret, len); } -HMAC_SHA::~HMAC_SHA() { delete pimpl_; } +HMAC_SHA::~HMAC_SHA() { ysDelete(pimpl_); } uint HMAC_SHA::get_digestSize() const @@ -331,13 +331,13 @@ struct HMAC_RMD::HMAC_RMDImpl { HMAC_RMD::HMAC_RMD(const byte* secret, unsigned int len) - : pimpl_(new HMAC_RMDImpl) + : pimpl_(new (ys) HMAC_RMDImpl) { pimpl_->mac_.SetKey(secret, len); } -HMAC_RMD::~HMAC_RMD() { delete pimpl_; } +HMAC_RMD::~HMAC_RMD() { ysDelete(pimpl_); } uint HMAC_RMD::get_digestSize() const @@ -379,9 +379,9 @@ struct DES::DESImpl { }; -DES::DES() : pimpl_(new DESImpl) {} +DES::DES() : pimpl_(new (ys) DESImpl) {} -DES::~DES() { delete pimpl_; } +DES::~DES() { ysDelete(pimpl_); } void DES::set_encryptKey(const byte* k, const byte* iv) @@ -415,9 +415,9 @@ struct DES_EDE::DES_EDEImpl { }; -DES_EDE::DES_EDE() : pimpl_(new DES_EDEImpl) {} +DES_EDE::DES_EDE() : pimpl_(new (ys) DES_EDEImpl) {} -DES_EDE::~DES_EDE() { delete pimpl_; } +DES_EDE::~DES_EDE() { ysDelete(pimpl_); } void DES_EDE::set_encryptKey(const byte* k, const byte* iv) @@ -453,9 +453,9 @@ struct RC4::RC4Impl { }; -RC4::RC4() : pimpl_(new RC4Impl) {} +RC4::RC4() : pimpl_(new (ys) RC4Impl) {} -RC4::~RC4() { delete pimpl_; } +RC4::~RC4() { ysDelete(pimpl_); } void RC4::set_encryptKey(const byte* k, const byte*) @@ -495,9 +495,9 @@ struct AES::AESImpl { }; -AES::AES(unsigned int ks) : pimpl_(new AESImpl(ks)) {} +AES::AES(unsigned int ks) : pimpl_(new (ys) AESImpl(ks)) {} -AES::~AES() { delete pimpl_; } +AES::~AES() { ysDelete(pimpl_); } int AES::get_keySize() const @@ -536,9 +536,9 @@ struct RandomPool::RandomImpl { TaoCrypt::RandomNumberGenerator RNG_; }; -RandomPool::RandomPool() : pimpl_(new RandomImpl) {} +RandomPool::RandomPool() : pimpl_(new (ys) RandomImpl) {} -RandomPool::~RandomPool() { delete pimpl_; } +RandomPool::~RandomPool() { ysDelete(pimpl_); } int RandomPool::GetError() const { @@ -580,7 +580,7 @@ void DSS::DSSImpl::SetPrivate(const byte* key, unsigned int sz) // Set public or private key DSS::DSS(const byte* key, unsigned int sz, bool publicKey) - : pimpl_(new DSSImpl) + : pimpl_(new (ys) DSSImpl) { if (publicKey) pimpl_->SetPublic(key, sz); @@ -591,7 +591,7 @@ DSS::DSS(const byte* key, unsigned int sz, bool publicKey) DSS::~DSS() { - delete pimpl_; + ysDelete(pimpl_); } @@ -651,7 +651,7 @@ void RSA::RSAImpl::SetPrivate(const byte* key, unsigned int sz) // Set public or private key RSA::RSA(const byte* key, unsigned int sz, bool publicKey) - : pimpl_(new RSAImpl) + : pimpl_(new (ys) RSAImpl) { if (publicKey) pimpl_->SetPublic(key, sz); @@ -661,7 +661,7 @@ RSA::RSA(const byte* key, unsigned int sz, bool publicKey) RSA::~RSA() { - delete pimpl_; + ysDelete(pimpl_); } @@ -723,13 +723,13 @@ struct Integer::IntegerImpl { explicit IntegerImpl(const TaoCrypt::Integer& i) : int_(i) {} }; -Integer::Integer() : pimpl_(new IntegerImpl) {} +Integer::Integer() : pimpl_(new (ys) IntegerImpl) {} -Integer::~Integer() { delete pimpl_; } +Integer::~Integer() { ysDelete(pimpl_); } -Integer::Integer(const Integer& other) : pimpl_(new +Integer::Integer(const Integer& other) : pimpl_(new (ys) IntegerImpl(other.pimpl_->int_)) {} @@ -757,7 +757,12 @@ struct DiffieHellman::DHImpl { DHImpl(TaoCrypt::RandomNumberGenerator& r) : ranPool_(r), publicKey_(0), privateKey_(0), agreedKey_(0) {} - ~DHImpl() {delete[] agreedKey_; delete[] privateKey_; delete[] publicKey_;} + ~DHImpl() + { + ysArrayDelete(agreedKey_); + ysArrayDelete(privateKey_); + ysArrayDelete(publicKey_); + } DHImpl(const DHImpl& that) : dh_(that.dh_), ranPool_(that.ranPool_), publicKey_(0), privateKey_(0), agreedKey_(0) @@ -768,9 +773,9 @@ struct DiffieHellman::DHImpl { void AllocKeys(unsigned int pubSz, unsigned int privSz, unsigned int agrSz) { - publicKey_ = new byte[pubSz]; - privateKey_ = new byte[privSz]; - agreedKey_ = new byte[agrSz]; + publicKey_ = new (ys) byte[pubSz]; + privateKey_ = new (ys) byte[privSz]; + agreedKey_ = new (ys) byte[agrSz]; } }; @@ -779,7 +784,7 @@ struct DiffieHellman::DHImpl { /* // server Side DH, server's view DiffieHellman::DiffieHellman(const char* file, const RandomPool& random) - : pimpl_(new DHImpl(random.pimpl_->RNG_)) + : pimpl_(new (ys) DHImpl(random.pimpl_->RNG_)) { using namespace TaoCrypt; Source source; @@ -803,12 +808,12 @@ DiffieHellman::DiffieHellman(const char* file, const RandomPool& random) DiffieHellman::DiffieHellman(const byte* p, unsigned int pSz, const byte* g, unsigned int gSz, const byte* pub, unsigned int pubSz, const RandomPool& random) - : pimpl_(new DHImpl(random.pimpl_->RNG_)) + : pimpl_(new (ys) DHImpl(random.pimpl_->RNG_)) { using TaoCrypt::Integer; pimpl_->dh_.Initialize(Integer(p, pSz).Ref(), Integer(g, gSz).Ref()); - pimpl_->publicKey_ = new opaque[pubSz]; + pimpl_->publicKey_ = new (ys) opaque[pubSz]; memcpy(pimpl_->publicKey_, pub, pubSz); } @@ -816,7 +821,7 @@ DiffieHellman::DiffieHellman(const byte* p, unsigned int pSz, const byte* g, // Server Side DH, server's view DiffieHellman::DiffieHellman(const Integer& p, const Integer& g, const RandomPool& random) -: pimpl_(new DHImpl(random.pimpl_->RNG_)) +: pimpl_(new (ys) DHImpl(random.pimpl_->RNG_)) { using TaoCrypt::Integer; @@ -829,12 +834,12 @@ DiffieHellman::DiffieHellman(const Integer& p, const Integer& g, pimpl_->publicKey_); } -DiffieHellman::~DiffieHellman() { delete pimpl_; } +DiffieHellman::~DiffieHellman() { ysDelete(pimpl_); } // Client side and view, use server that for p and g DiffieHellman::DiffieHellman(const DiffieHellman& that) - : pimpl_(new DHImpl(*that.pimpl_)) + : pimpl_(new (ys) DHImpl(*that.pimpl_)) { pimpl_->dh_.GenerateKeyPair(pimpl_->ranPool_, pimpl_->privateKey_, pimpl_->publicKey_); @@ -955,7 +960,7 @@ x509* PemToDer(const char* fname, CertType type) Base64Decoder b64Dec(der); uint sz = der.size(); - mySTL::auto_ptr x(new x509(sz)); + mySTL::auto_ptr x(new (ys) x509(sz), ysDelete); memcpy(x->use_buffer(), der.get_buffer(), sz); fclose(file); @@ -965,10 +970,25 @@ x509* PemToDer(const char* fname, CertType type) } // namespace + #ifdef __GNUC__ -template class TaoCrypt::HMAC; -template class TaoCrypt::HMAC; -template class TaoCrypt::HMAC; -#endif +namespace yaSSL { +template void ysDelete(DiffieHellman::DHImpl*); +template void ysDelete(Integer::IntegerImpl*); +template void ysDelete(RSA::RSAImpl*); +template void ysDelete(DSS::DSSImpl*); +template void ysDelete(RandomPool::RandomImpl*); +template void ysDelete(AES::AESImpl*); +template void ysDelete(RC4::RC4Impl*); +template void ysDelete(DES_EDE::DES_EDEImpl*); +template void ysDelete(DES::DESImpl*); +template void ysDelete(HMAC_RMD::HMAC_RMDImpl*); +template void ysDelete(HMAC_SHA::HMAC_SHAImpl*); +template void ysDelete(HMAC_MD5::HMAC_MD5Impl*); +template void ysDelete(RMD::RMDImpl*); +template void ysDelete(SHA::SHAImpl*); +template void ysDelete(MD5::MD5Impl*); +} +#endif // __GNUC__ #endif // !USE_CRYPTOPP_LIB diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp index 28872e50063..e49d1ec76cc 100644 --- a/extra/yassl/src/handshake.cpp +++ b/extra/yassl/src/handshake.cpp @@ -357,14 +357,14 @@ void p_hash(output_buffer& result, const output_buffer& secret, uint lastLen = result.get_capacity() % len; opaque previous[SHA_LEN]; // max size opaque current[SHA_LEN]; // max size - mySTL::auto_ptr hmac; + mySTL::auto_ptr hmac(ysDelete); if (lastLen) times += 1; if (hash == md5) - hmac.reset(new HMAC_MD5(secret.get_buffer(), secret.get_size())); + hmac.reset(new (ys) HMAC_MD5(secret.get_buffer(), secret.get_size())); else - hmac.reset(new HMAC_SHA(secret.get_buffer(), secret.get_size())); + hmac.reset(new (ys) HMAC_SHA(secret.get_buffer(), secret.get_size())); // A0 = seed hmac->get_digest(previous, seed.get_buffer(), seed.get_size());// A1 uint lastTime = times - 1; @@ -571,7 +571,7 @@ void hmac(SSL& ssl, byte* digest, const byte* buffer, uint sz, void TLS_hmac(SSL& ssl, byte* digest, const byte* buffer, uint sz, ContentType content, bool verify) { - mySTL::auto_ptr hmac; + mySTL::auto_ptr hmac(ysDelete); opaque seq[SEQ_SZ] = { 0x00, 0x00, 0x00, 0x00 }; opaque length[LENGTH_SZ]; opaque inner[SIZEOF_ENUM + VERSION_SZ + LENGTH_SZ]; // type + version + len @@ -582,11 +582,11 @@ void TLS_hmac(SSL& ssl, byte* digest, const byte* buffer, uint sz, MACAlgorithm algo = ssl.getSecurity().get_parms().mac_algorithm_; if (algo == sha) - hmac.reset(new HMAC_SHA(ssl.get_macSecret(verify), SHA_LEN)); + hmac.reset(new (ys) HMAC_SHA(ssl.get_macSecret(verify), SHA_LEN)); else if (algo == rmd) - hmac.reset(new HMAC_RMD(ssl.get_macSecret(verify), RMD_LEN)); + hmac.reset(new (ys) HMAC_RMD(ssl.get_macSecret(verify), RMD_LEN)); else - hmac.reset(new HMAC_MD5(ssl.get_macSecret(verify), MD5_LEN)); + hmac.reset(new (ys) HMAC_MD5(ssl.get_macSecret(verify), MD5_LEN)); hmac->update(seq, SEQ_SZ); // seq_num inner[0] = content; // type @@ -648,7 +648,7 @@ void build_certHashes(SSL& ssl, Hashes& hashes) } -mySTL::auto_ptr null_buffer; +mySTL::auto_ptr null_buffer(ysDelete); // do process input requests mySTL::auto_ptr @@ -666,7 +666,7 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr buffered) buffered = null_buffer; } - // add new data + // add new (ys) data uint read = ssl.getSocket().receive(buffer.get_buffer() + buffSz, ready); buffer.add_size(read); uint offset = 0; @@ -687,7 +687,7 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr buffered) // make sure we have enough input in buffer to process this record if (hdr.length_ > buffer.get_remaining()) { uint sz = buffer.get_remaining() + RECORD_HEADER; - buffered.reset(new input_buffer(sz, buffer.get_buffer() + + buffered.reset(new (ys) input_buffer(sz, buffer.get_buffer() + buffer.get_current() - RECORD_HEADER, sz)); break; } @@ -696,7 +696,7 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr buffered) // each message in record if (ssl.getSecurity().get_parms().pending_ == false) // cipher on decrypt_message(ssl, buffer, hdr.length_); - mySTL::auto_ptr msg(mf.CreateObject(hdr.type_)); + mySTL::auto_ptr msg(mf.CreateObject(hdr.type_), ysDelete); if (!msg.get()) { ssl.SetError(factory_error); return buffered = null_buffer; @@ -715,7 +715,7 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr buffered) void processReply(SSL& ssl) { if (ssl.GetError()) return; - mySTL::auto_ptr buffered; + mySTL::auto_ptr buffered(ysDelete); for (;;) { mySTL::auto_ptr tmp = DoProcessReply(ssl, buffered); @@ -760,7 +760,7 @@ void sendClientKeyExchange(SSL& ssl, BufferOutput buffer) RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); buildHeaders(ssl, hsHeader, rlHeader, ck); buildOutput(*out.get(), rlHeader, hsHeader, ck); hashHandShake(ssl, *out.get()); @@ -781,7 +781,7 @@ void sendServerKeyExchange(SSL& ssl, BufferOutput buffer) RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); buildHeaders(ssl, hsHeader, rlHeader, sk); buildOutput(*out.get(), rlHeader, hsHeader, sk); hashHandShake(ssl, *out.get()); @@ -806,7 +806,7 @@ void sendChangeCipher(SSL& ssl, BufferOutput buffer) ChangeCipherSpec ccs; RecordLayerHeader rlHeader; buildHeader(ssl, rlHeader, ccs); - mySTL::auto_ptr out(new output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); buildOutput(*out.get(), rlHeader, ccs); if (buffer == buffered) @@ -823,7 +823,7 @@ void sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer) Finished fin; buildFinished(ssl, fin, side == client_end ? client : server); - mySTL::auto_ptr out(new output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); cipherFinished(ssl, fin, *out.get()); // hashes handshake if (ssl.getSecurity().get_resuming()) { @@ -907,7 +907,7 @@ void sendServerHello(SSL& ssl, BufferOutput buffer) ServerHello sh(ssl.getSecurity().get_connection().version_); RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); buildServerHello(ssl, sh); ssl.set_random(sh.get_random(), server_end); @@ -930,7 +930,7 @@ void sendServerHelloDone(SSL& ssl, BufferOutput buffer) ServerHelloDone shd; RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); buildHeaders(ssl, hsHeader, rlHeader, shd); buildOutput(*out.get(), rlHeader, hsHeader, shd); @@ -951,7 +951,7 @@ void sendCertificate(SSL& ssl, BufferOutput buffer) Certificate cert(ssl.getCrypto().get_certManager().get_cert()); RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); buildHeaders(ssl, hsHeader, rlHeader, cert); buildOutput(*out.get(), rlHeader, hsHeader, cert); @@ -973,7 +973,7 @@ void sendCertificateRequest(SSL& ssl, BufferOutput buffer) request.Build(); RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); buildHeaders(ssl, hsHeader, rlHeader, request); buildOutput(*out.get(), rlHeader, hsHeader, request); @@ -995,7 +995,7 @@ void sendCertificateVerify(SSL& ssl, BufferOutput buffer) verify.Build(ssl); RecordLayerHeader rlHeader; HandShakeHeader hsHeader; - mySTL::auto_ptr out(new output_buffer); + mySTL::auto_ptr out(new (ys) output_buffer, ysDelete); buildHeaders(ssl, hsHeader, rlHeader, verify); buildOutput(*out.get(), rlHeader, hsHeader, verify); diff --git a/extra/yassl/src/lock.cpp b/extra/yassl/src/lock.cpp index 221ec0cdb4f..b8f6212ad3f 100644 --- a/extra/yassl/src/lock.cpp +++ b/extra/yassl/src/lock.cpp @@ -22,7 +22,6 @@ /* Locking functions */ -#include "runtime.hpp" #include "lock.hpp" diff --git a/extra/yassl/src/log.cpp b/extra/yassl/src/log.cpp index 19072a5e09c..538b80b8280 100644 --- a/extra/yassl/src/log.cpp +++ b/extra/yassl/src/log.cpp @@ -22,7 +22,6 @@ /* Debug logging functions */ -#include "runtime.hpp" #include "log.hpp" #ifdef YASSL_LOG diff --git a/extra/yassl/src/socket_wrapper.cpp b/extra/yassl/src/socket_wrapper.cpp index 0dd30e6b696..f0d530f187c 100644 --- a/extra/yassl/src/socket_wrapper.cpp +++ b/extra/yassl/src/socket_wrapper.cpp @@ -26,7 +26,6 @@ */ -#include "runtime.hpp" #include "socket_wrapper.hpp" #include "yassl_error.hpp" diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp index b0d9dcca902..466884f3cd9 100644 --- a/extra/yassl/src/ssl.cpp +++ b/extra/yassl/src/ssl.cpp @@ -32,7 +32,6 @@ /* see man pages for function descriptions */ -#include "runtime.hpp" #include "openssl/ssl.h" #include "handshake.hpp" #include "yassl_int.hpp" @@ -52,25 +51,25 @@ SSL_METHOD* SSLv3_method() SSL_METHOD* SSLv3_server_method() { - return new SSL_METHOD(server_end, ProtocolVersion(3,0)); + return new (ys) SSL_METHOD(server_end, ProtocolVersion(3,0)); } SSL_METHOD* SSLv3_client_method() { - return new SSL_METHOD(client_end, ProtocolVersion(3,0)); + return new (ys) SSL_METHOD(client_end, ProtocolVersion(3,0)); } SSL_METHOD* TLSv1_server_method() { - return new SSL_METHOD(server_end, ProtocolVersion(3,1)); + return new (ys) SSL_METHOD(server_end, ProtocolVersion(3,1)); } SSL_METHOD* TLSv1_client_method() { - return new SSL_METHOD(client_end, ProtocolVersion(3,1)); + return new (ys) SSL_METHOD(client_end, ProtocolVersion(3,1)); } @@ -83,25 +82,25 @@ SSL_METHOD* SSLv23_server_method() SSL_CTX* SSL_CTX_new(SSL_METHOD* method) { - return new SSL_CTX(method); + return new (ys) SSL_CTX(method); } void SSL_CTX_free(SSL_CTX* ctx) { - delete ctx; + ysDelete(ctx); } SSL* SSL_new(SSL_CTX* ctx) { - return new SSL(ctx); + return new (ys) SSL(ctx); } void SSL_free(SSL* ssl) { - delete ssl; + ysDelete(ssl); } @@ -443,7 +442,7 @@ int read_file(SSL_CTX* ctx, const char* file, int format, CertType type) fseek(input, 0, SEEK_END); long sz = ftell(input); rewind(input); - x = new x509(sz); // takes ownership + x = new (ys) x509(sz); // takes ownership size_t bytes = fread(x->use_buffer(), sz, 1, input); if (bytes != 1) { fclose(input); @@ -638,7 +637,7 @@ void OpenSSL_add_all_algorithms() // compatibility only DH* DH_new(void) { - DH* dh = new DH; + DH* dh = new (ys) DH; if (dh) dh->p = dh->g = 0; return dh; @@ -647,9 +646,9 @@ DH* DH_new(void) void DH_free(DH* dh) { - delete dh->g; - delete dh->p; - delete dh; + ysDelete(dh->g); + ysDelete(dh->p); + ysDelete(dh); } @@ -659,11 +658,11 @@ BIGNUM* BN_bin2bn(const unsigned char* num, int sz, BIGNUM* retVal) { using mySTL::auto_ptr; bool created = false; - auto_ptr bn; + auto_ptr bn(ysDelete); if (!retVal) { created = true; - bn.reset(new BIGNUM); + bn.reset(new (ys) BIGNUM); retVal = bn.get(); } @@ -712,14 +711,14 @@ const char* X509_verify_cert_error_string(long /* error */) const EVP_MD* EVP_md5(void) { // TODO: FIX add to some list for destruction - return new MD5; + return new (ys) MD5; } const EVP_CIPHER* EVP_des_ede3_cbc(void) { // TODO: FIX add to some list for destruction - return new DES_EDE; + return new (ys) DES_EDE; } diff --git a/extra/yassl/src/template_instnt.cpp b/extra/yassl/src/template_instnt.cpp new file mode 100644 index 00000000000..4ad1ec29249 --- /dev/null +++ b/extra/yassl/src/template_instnt.cpp @@ -0,0 +1,67 @@ +#include "runtime.hpp" +#include "handshake.hpp" +#include "yassl_int.hpp" +#include "crypto_wrapper.hpp" +#include "hmac.hpp" +#include "md5.hpp" +#include "sha.hpp" +#include "ripemd.hpp" +#include "openssl/ssl.h" + +#ifdef __GNUC__ +#if !defined(USE_CRYPTOPP_LIB) +namespace TaoCrypt { +template class HMAC; +template class HMAC; +template class HMAC; +} +#endif + +namespace mySTL { +template class mySTL::list; +template yaSSL::del_ptr_zero mySTL::for_each(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); +template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); +template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); +template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); +template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); +template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); +template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); +template class mySTL::list; +template class mySTL::list; +template class mySTL::list; +template class mySTL::list; +template class mySTL::list; +template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); +template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); +} + +namespace yaSSL { +template void ysDelete(yaSSL::SSL_CTX*); +template void ysDelete(yaSSL::SSL*); +template void ysDelete(yaSSL::BIGNUM*); +template void ysDelete(unsigned char*); +template void ysDelete(yaSSL::DH*); +template void ysDelete(TaoCrypt::Signer*); +template void ysDelete(yaSSL::SSL_SESSION*); +template void ysDelete(input_buffer*); +template void ysDelete(output_buffer*); +template void ysDelete(x509*); +template void ysDelete(Auth*); +template void ysDelete(HandShakeBase*); +template void ysDelete(ServerKeyBase*); +template void ysDelete(ClientKeyBase*); +template void ysDelete(SSL_METHOD*); +template void ysDelete(DiffieHellman*); +template void ysDelete(BulkCipher*); +template void ysDelete(Digest*); +template void ysDelete(X509*); +template void ysDelete(Message*); +template void ysArrayDelete(unsigned char*); +template void ysArrayDelete(char*); +} +#endif diff --git a/extra/yassl/src/timer.cpp b/extra/yassl/src/timer.cpp index 49e7bb36776..547c31205c6 100644 --- a/extra/yassl/src/timer.cpp +++ b/extra/yassl/src/timer.cpp @@ -23,7 +23,6 @@ * */ -#include "runtime.hpp" #include "timer.hpp" namespace yaSSL { diff --git a/extra/yassl/src/yassl_error.cpp b/extra/yassl/src/yassl_error.cpp index c53aef2068d..6ae5a9f6663 100644 --- a/extra/yassl/src/yassl_error.cpp +++ b/extra/yassl/src/yassl_error.cpp @@ -23,7 +23,6 @@ /* yaSSL error implements and an exception class */ -#include "runtime.hpp" #include "yassl_error.hpp" namespace yaSSL { diff --git a/extra/yassl/src/yassl_imp.cpp b/extra/yassl/src/yassl_imp.cpp index 02654727f78..1d9db46816b 100644 --- a/extra/yassl/src/yassl_imp.cpp +++ b/extra/yassl/src/yassl_imp.cpp @@ -130,14 +130,14 @@ void DH_Server::build(SSL& ssl) parms_.alloc_pub(pubSz)); short sigSz = 0; - mySTL::auto_ptr auth; + mySTL::auto_ptr auth(ysDelete); const CertManager& cert = ssl.getCrypto().get_certManager(); if (ssl.getSecurity().get_parms().sig_algo_ == rsa_sa_algo) - auth.reset(new RSA(cert.get_privateKey(), + auth.reset(new (ys) RSA(cert.get_privateKey(), cert.get_privateKeyLength(), false)); else { - auth.reset(new DSS(cert.get_privateKey(), + auth.reset(new (ys) DSS(cert.get_privateKey(), cert.get_privateKeyLength(), false)); sigSz += DSS_ENCODED_EXTRA; } @@ -168,7 +168,7 @@ void DH_Server::build(SSL& ssl) byte hash[FINISHED_SZ]; MD5 md5; SHA sha; - signature_ = new byte[sigSz]; + signature_ = new (ys) byte[sigSz]; const Connection& conn = ssl.getSecurity().get_connection(); // md5 @@ -199,7 +199,7 @@ void DH_Server::build(SSL& ssl) tmp.write(signature_, sigSz); // key message - keyMessage_ = new opaque[length_]; + keyMessage_ = new (ys) opaque[length_]; memcpy(keyMessage_, tmp.get_buffer(), tmp.get_size()); } @@ -234,7 +234,7 @@ EncryptedPreMasterSecret::EncryptedPreMasterSecret() EncryptedPreMasterSecret::~EncryptedPreMasterSecret() { - delete[] secret_; + ysArrayDelete(secret_); } @@ -253,7 +253,7 @@ opaque* EncryptedPreMasterSecret::get_clientKey() const void EncryptedPreMasterSecret::alloc(int sz) { length_ = sz; - secret_ = new opaque[sz]; + secret_ = new (ys) opaque[sz]; } @@ -284,7 +284,7 @@ ClientDiffieHellmanPublic::ClientDiffieHellmanPublic() ClientDiffieHellmanPublic::~ClientDiffieHellmanPublic() { - delete[] Yc_; + ysArrayDelete(Yc_); } @@ -303,7 +303,7 @@ opaque* ClientDiffieHellmanPublic::get_clientKey() const void ClientDiffieHellmanPublic::alloc(int sz, bool offset) { length_ = sz + (offset ? KEY_OFFSET : 0); - Yc_ = new opaque[length_]; + Yc_ = new (ys) opaque[length_]; } @@ -348,7 +348,7 @@ void DH_Server::read(SSL& ssl, input_buffer& input) tmp[1] = input[AUTO]; ato16(tmp, length); - signature_ = new byte[length]; + signature_ = new (ys) byte[length]; input.read(signature_, length); // verify signature @@ -386,7 +386,7 @@ void DH_Server::read(SSL& ssl, input_buffer& input) } // save input - ssl.useCrypto().SetDH(new DiffieHellman(parms_.get_p(), + ssl.useCrypto().SetDH(new (ys) DiffieHellman(parms_.get_p(), parms_.get_pSize(), parms_.get_g(), parms_.get_gSize(), parms_.get_pub(), parms_.get_pubSize(), ssl.getCrypto().get_random())); @@ -400,8 +400,8 @@ DH_Server::DH_Server() DH_Server::~DH_Server() { - delete[] keyMessage_; - delete[] signature_; + ysArrayDelete(keyMessage_); + ysArrayDelete(signature_); } @@ -594,7 +594,7 @@ void HandShakeHeader::Process(input_buffer& input, SSL& ssl) { ssl.verifyState(*this); const HandShakeFactory& hsf = ssl.getFactory().getHandShake(); - mySTL::auto_ptr hs(hsf.CreateObject(type_)); + mySTL::auto_ptr hs(hsf.CreateObject(type_), ysDelete); if (!hs.get()) { ssl.SetError(factory_error); return; @@ -928,7 +928,7 @@ void Data::Process(input_buffer& input, SSL& ssl) // read data if (dataSz) { input_buffer* data; - ssl.addData(data = new input_buffer(dataSz)); + ssl.addData(data = new (ys) input_buffer(dataSz)); input.read(data->get_buffer(), dataSz); data->add_size(dataSz); @@ -1025,7 +1025,7 @@ void Certificate::Process(input_buffer& input, SSL& ssl) c24to32(tmp, cert_sz); x509* myCert; - cm.AddPeerCert(myCert = new x509(cert_sz)); + cm.AddPeerCert(myCert = new (ys) x509(cert_sz)); input.read(myCert->use_buffer(), myCert->get_length()); list_sz -= cert_sz + CERT_HEADER; @@ -1067,9 +1067,9 @@ ServerDHParams::ServerDHParams() ServerDHParams::~ServerDHParams() { - delete[] Ys_; - delete[] g_; - delete[] p_; + ysArrayDelete(Ys_); + ysArrayDelete(g_); + ysArrayDelete(p_); } @@ -1111,21 +1111,21 @@ const opaque* ServerDHParams::get_pub() const opaque* ServerDHParams::alloc_p(int sz) { - p_ = new opaque[pSz_ = sz]; + p_ = new (ys) opaque[pSz_ = sz]; return p_; } opaque* ServerDHParams::alloc_g(int sz) { - g_ = new opaque[gSz_ = sz]; + g_ = new (ys) opaque[gSz_ = sz]; return g_; } opaque* ServerDHParams::alloc_pub(int sz) { - Ys_ = new opaque[pubSz_ = sz]; + Ys_ = new (ys) opaque[pubSz_ = sz]; return Ys_; } @@ -1466,7 +1466,7 @@ ServerKeyExchange::ServerKeyExchange() ServerKeyExchange::~ServerKeyExchange() { - delete server_key_; + ysDelete(server_key_); } @@ -1537,7 +1537,7 @@ void CertificateRequest::Build() for (int j = 0; j < authCount; j++) { int sz = REQUEST_HEADER + MIN_DIS_SIZE; DistinguishedName dn; - certificate_authorities_.push_back(dn = new byte[sz]); + certificate_authorities_.push_back(dn = new (ys) byte[sz]); opaque tmp[REQUEST_HEADER]; c16toa(MIN_DIS_SIZE, tmp); @@ -1584,7 +1584,7 @@ input_buffer& operator>>(input_buffer& input, CertificateRequest& request) ato16(tmp, dnSz); DistinguishedName dn; - request.certificate_authorities_.push_back(dn = new + request.certificate_authorities_.push_back(dn = new (ys) byte[REQUEST_HEADER + dnSz]); memcpy(dn, tmp, REQUEST_HEADER); input.read(&dn[REQUEST_HEADER], dnSz); @@ -1647,7 +1647,7 @@ CertificateVerify::CertificateVerify() : signature_(0) CertificateVerify::~CertificateVerify() { - delete[] signature_; + ysArrayDelete(signature_); } @@ -1657,7 +1657,7 @@ void CertificateVerify::Build(SSL& ssl) uint16 sz = 0; byte len[VERIFY_HEADER]; - mySTL::auto_ptr sig; + mySTL::auto_ptr sig(ysArrayDelete); // sign const CertManager& cert = ssl.getCrypto().get_certManager(); @@ -1665,7 +1665,7 @@ void CertificateVerify::Build(SSL& ssl) RSA rsa(cert.get_privateKey(), cert.get_privateKeyLength(), false); sz = rsa.get_cipherLength() + VERIFY_HEADER; - sig.reset(new byte[sz]); + sig.reset(new (ys) byte[sz]); c16toa(sz - VERIFY_HEADER, len); memcpy(sig.get(), len, VERIFY_HEADER); @@ -1676,7 +1676,7 @@ void CertificateVerify::Build(SSL& ssl) DSS dss(cert.get_privateKey(), cert.get_privateKeyLength(), false); sz = DSS_SIG_SZ + DSS_ENCODED_EXTRA + VERIFY_HEADER; - sig.reset(new byte[sz]); + sig.reset(new (ys) byte[sz]); c16toa(sz - VERIFY_HEADER, len); memcpy(sig.get(), len, VERIFY_HEADER); @@ -1714,7 +1714,7 @@ input_buffer& operator>>(input_buffer& input, CertificateVerify& request) ato16(tmp, sz); request.set_length(sz); - request.signature_ = new byte[sz]; + request.signature_ = new (ys) byte[sz]; input.read(request.signature_, sz); return input; @@ -1796,7 +1796,7 @@ ClientKeyExchange::ClientKeyExchange() ClientKeyExchange::~ClientKeyExchange() { - delete client_key_; + ysDelete(client_key_); } @@ -1969,13 +1969,13 @@ Connection::Connection(ProtocolVersion v, RandomPool& ran) Connection::~Connection() { - CleanMaster(); CleanPreMaster(); delete[] pre_master_secret_; + CleanMaster(); CleanPreMaster(); ysArrayDelete(pre_master_secret_); } void Connection::AllocPreSecret(uint sz) { - pre_master_secret_ = new opaque[pre_secret_len_ = sz]; + pre_master_secret_ = new (ys) opaque[pre_secret_len_ = sz]; } @@ -2004,42 +2004,42 @@ void Connection::CleanPreMaster() volatile opaque* p = pre_master_secret_; clean(p, pre_secret_len_, random_); - delete[] pre_master_secret_; + ysArrayDelete(pre_master_secret_); pre_master_secret_ = 0; } } // Create functions for message factory -Message* CreateCipherSpec() { return new ChangeCipherSpec; } -Message* CreateAlert() { return new Alert; } -Message* CreateHandShake() { return new HandShakeHeader; } -Message* CreateData() { return new Data; } +Message* CreateCipherSpec() { return new (ys) ChangeCipherSpec; } +Message* CreateAlert() { return new (ys) Alert; } +Message* CreateHandShake() { return new (ys) HandShakeHeader; } +Message* CreateData() { return new (ys) Data; } // Create functions for handshake factory -HandShakeBase* CreateHelloRequest() { return new HelloRequest; } -HandShakeBase* CreateClientHello() { return new ClientHello; } -HandShakeBase* CreateServerHello() { return new ServerHello; } -HandShakeBase* CreateCertificate() { return new Certificate; } -HandShakeBase* CreateServerKeyExchange() { return new ServerKeyExchange;} -HandShakeBase* CreateCertificateRequest() { return new +HandShakeBase* CreateHelloRequest() { return new (ys) HelloRequest; } +HandShakeBase* CreateClientHello() { return new (ys) ClientHello; } +HandShakeBase* CreateServerHello() { return new (ys) ServerHello; } +HandShakeBase* CreateCertificate() { return new (ys) Certificate; } +HandShakeBase* CreateServerKeyExchange() { return new (ys) ServerKeyExchange;} +HandShakeBase* CreateCertificateRequest() { return new (ys) CertificateRequest; } -HandShakeBase* CreateServerHelloDone() { return new ServerHelloDone; } -HandShakeBase* CreateCertificateVerify() { return new CertificateVerify;} -HandShakeBase* CreateClientKeyExchange() { return new ClientKeyExchange;} -HandShakeBase* CreateFinished() { return new Finished; } +HandShakeBase* CreateServerHelloDone() { return new (ys) ServerHelloDone; } +HandShakeBase* CreateCertificateVerify() { return new (ys) CertificateVerify;} +HandShakeBase* CreateClientKeyExchange() { return new (ys) ClientKeyExchange;} +HandShakeBase* CreateFinished() { return new (ys) Finished; } // Create functions for server key exchange factory -ServerKeyBase* CreateRSAServerKEA() { return new RSA_Server; } -ServerKeyBase* CreateDHServerKEA() { return new DH_Server; } -ServerKeyBase* CreateFortezzaServerKEA() { return new Fortezza_Server; } +ServerKeyBase* CreateRSAServerKEA() { return new (ys) RSA_Server; } +ServerKeyBase* CreateDHServerKEA() { return new (ys) DH_Server; } +ServerKeyBase* CreateFortezzaServerKEA() { return new (ys) Fortezza_Server; } // Create functions for client key exchange factory -ClientKeyBase* CreateRSAClient() { return new +ClientKeyBase* CreateRSAClient() { return new (ys) EncryptedPreMasterSecret; } -ClientKeyBase* CreateDHClient() { return new +ClientKeyBase* CreateDHClient() { return new (ys) ClientDiffieHellmanPublic; } -ClientKeyBase* CreateFortezzaClient() { return new FortezzaKeys; } +ClientKeyBase* CreateFortezzaClient() { return new (ys) FortezzaKeys; } // Constructor calls this to Register compile time callbacks @@ -2089,29 +2089,5 @@ void InitClientKeyFactory(ClientKeyFactory& ckf) ckf.Register(fortezza_kea, CreateFortezzaClient); } -} // namespace -#ifdef __GNUC__ -namespace mySTL { -template class mySTL::list; -template yaSSL::del_ptr_zero mySTL::for_each(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); -template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); -template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); -template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); -template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); -template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); -template mySTL::pair* mySTL::uninit_copy*, mySTL::pair*>(mySTL::pair*, mySTL::pair*, mySTL::pair*); -template class mySTL::list; -template class mySTL::list; -template class mySTL::list; -template class mySTL::list; -template class mySTL::list; -template void mySTL::destroy*>(mySTL::pair*, mySTL::pair*); -template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -template yaSSL::del_ptr_zero mySTL::for_each::iterator, yaSSL::del_ptr_zero>(mySTL::list::iterator, mySTL::list::iterator, yaSSL::del_ptr_zero); -} -#endif +} // namespace diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp index 718871a598b..06be7a15503 100644 --- a/extra/yassl/src/yassl_int.cpp +++ b/extra/yassl/src/yassl_int.cpp @@ -24,19 +24,47 @@ * draft along with type conversion functions. */ -#include "runtime.hpp" #include "yassl_int.hpp" #include "handshake.hpp" #include "timer.hpp" #include "openssl/ssl.h" // for DH +void* operator new(size_t sz, yaSSL::new_t) +{ + void* ptr = malloc(sz ? sz : 1); + if (!ptr) abort(); + + return ptr; +} + +void* operator new[](size_t sz, yaSSL::new_t) +{ + void* ptr = malloc(sz ? sz : 1); + if (!ptr) abort(); + + return ptr; +} + +void operator delete(void* ptr, yaSSL::new_t) +{ + if (ptr) free(ptr); +} + +void operator delete[](void* ptr, yaSSL::new_t) +{ + if (ptr) free(ptr); +} + + namespace yaSSL { using mySTL::min; +new_t ys; // for yaSSL library new + // convert a 32 bit integer into a 24 bit one @@ -284,8 +312,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = AES_256_KEY_SZ; parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; - crypto_.setDigest(new SHA); - crypto_.setCipher(new AES(AES_256_KEY_SZ)); + crypto_.setDigest(new (ys) SHA); + crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); strncpy(parms.cipher_name_, cipher_names[TLS_RSA_WITH_AES_256_CBC_SHA], MAX_SUITE_NAME); break; @@ -298,8 +326,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = AES_128_KEY_SZ; parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; - crypto_.setDigest(new SHA); - crypto_.setCipher(new AES); + crypto_.setDigest(new (ys) SHA); + crypto_.setCipher(new (ys) AES); strncpy(parms.cipher_name_, cipher_names[TLS_RSA_WITH_AES_128_CBC_SHA], MAX_SUITE_NAME); break; @@ -312,8 +340,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = DES_EDE_KEY_SZ; parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; - crypto_.setDigest(new SHA); - crypto_.setCipher(new DES_EDE); + crypto_.setDigest(new (ys) SHA); + crypto_.setCipher(new (ys) DES_EDE); strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_3DES_EDE_CBC_SHA] , MAX_SUITE_NAME); break; @@ -326,8 +354,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = DES_KEY_SZ; parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; - crypto_.setDigest(new SHA); - crypto_.setCipher(new DES); + crypto_.setDigest(new (ys) SHA); + crypto_.setCipher(new (ys) DES); strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_DES_CBC_SHA], MAX_SUITE_NAME); break; @@ -340,8 +368,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = RC4_KEY_SZ; parms.iv_size_ = 0; parms.cipher_type_ = stream; - crypto_.setDigest(new SHA); - crypto_.setCipher(new RC4); + crypto_.setDigest(new (ys) SHA); + crypto_.setCipher(new (ys) RC4); strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_RC4_128_SHA], MAX_SUITE_NAME); break; @@ -354,8 +382,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = RC4_KEY_SZ; parms.iv_size_ = 0; parms.cipher_type_ = stream; - crypto_.setDigest(new MD5); - crypto_.setCipher(new RC4); + crypto_.setDigest(new (ys) MD5); + crypto_.setCipher(new (ys) RC4); strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_RC4_128_MD5], MAX_SUITE_NAME); break; @@ -370,8 +398,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new SHA); - crypto_.setCipher(new DES); + crypto_.setDigest(new (ys) SHA); + crypto_.setCipher(new (ys) DES); strncpy(parms.cipher_name_, cipher_names[SSL_DHE_RSA_WITH_DES_CBC_SHA], MAX_SUITE_NAME); break; @@ -386,8 +414,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new SHA); - crypto_.setCipher(new DES_EDE); + crypto_.setDigest(new (ys) SHA); + crypto_.setCipher(new (ys) DES_EDE); strncpy(parms.cipher_name_, cipher_names[SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA], MAX_SUITE_NAME); break; @@ -402,8 +430,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new SHA); - crypto_.setCipher(new AES(AES_256_KEY_SZ)); + crypto_.setDigest(new (ys) SHA); + crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_RSA_WITH_AES_256_CBC_SHA], MAX_SUITE_NAME); break; @@ -418,8 +446,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new SHA); - crypto_.setCipher(new AES); + crypto_.setDigest(new (ys) SHA); + crypto_.setCipher(new (ys) AES); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_RSA_WITH_AES_128_CBC_SHA], MAX_SUITE_NAME); break; @@ -434,8 +462,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new SHA); - crypto_.setCipher(new DES); + crypto_.setDigest(new (ys) SHA); + crypto_.setCipher(new (ys) DES); strncpy(parms.cipher_name_, cipher_names[SSL_DHE_DSS_WITH_DES_CBC_SHA], MAX_SUITE_NAME); break; @@ -450,8 +478,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new SHA); - crypto_.setCipher(new DES_EDE); + crypto_.setDigest(new (ys) SHA); + crypto_.setCipher(new (ys) DES_EDE); strncpy(parms.cipher_name_, cipher_names[SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA], MAX_SUITE_NAME); break; @@ -466,8 +494,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new SHA); - crypto_.setCipher(new AES(AES_256_KEY_SZ)); + crypto_.setDigest(new (ys) SHA); + crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_DSS_WITH_AES_256_CBC_SHA], MAX_SUITE_NAME); break; @@ -482,8 +510,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new SHA); - crypto_.setCipher(new AES); + crypto_.setDigest(new (ys) SHA); + crypto_.setCipher(new (ys) AES); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_DSS_WITH_AES_128_CBC_SHA], MAX_SUITE_NAME); break; @@ -496,8 +524,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = AES_256_KEY_SZ; parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; - crypto_.setDigest(new RMD); - crypto_.setCipher(new AES(AES_256_KEY_SZ)); + crypto_.setDigest(new (ys) RMD); + crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); strncpy(parms.cipher_name_, cipher_names[TLS_RSA_WITH_AES_256_CBC_RMD160], MAX_SUITE_NAME); break; @@ -510,8 +538,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = AES_128_KEY_SZ; parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; - crypto_.setDigest(new RMD); - crypto_.setCipher(new AES); + crypto_.setDigest(new (ys) RMD); + crypto_.setCipher(new (ys) AES); strncpy(parms.cipher_name_, cipher_names[TLS_RSA_WITH_AES_128_CBC_RMD160], MAX_SUITE_NAME); break; @@ -524,8 +552,8 @@ void SSL::set_pending(Cipher suite) parms.key_size_ = DES_EDE_KEY_SZ; parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; - crypto_.setDigest(new RMD); - crypto_.setCipher(new DES_EDE); + crypto_.setDigest(new (ys) RMD); + crypto_.setCipher(new (ys) DES_EDE); strncpy(parms.cipher_name_, cipher_names[TLS_RSA_WITH_3DES_EDE_CBC_RMD160], MAX_SUITE_NAME); break; @@ -540,8 +568,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new RMD); - crypto_.setCipher(new DES_EDE); + crypto_.setDigest(new (ys) RMD); + crypto_.setCipher(new (ys) DES_EDE); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_RSA_WITH_3DES_EDE_CBC_RMD160], MAX_SUITE_NAME); @@ -557,8 +585,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new RMD); - crypto_.setCipher(new AES(AES_256_KEY_SZ)); + crypto_.setDigest(new (ys) RMD); + crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_RSA_WITH_AES_256_CBC_RMD160], MAX_SUITE_NAME); @@ -574,8 +602,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new RMD); - crypto_.setCipher(new AES); + crypto_.setDigest(new (ys) RMD); + crypto_.setCipher(new (ys) AES); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_RSA_WITH_AES_128_CBC_RMD160], MAX_SUITE_NAME); @@ -591,8 +619,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = DES_IV_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new RMD); - crypto_.setCipher(new DES_EDE); + crypto_.setDigest(new (ys) RMD); + crypto_.setCipher(new (ys) DES_EDE); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_DSS_WITH_3DES_EDE_CBC_RMD160], MAX_SUITE_NAME); @@ -608,8 +636,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new RMD); - crypto_.setCipher(new AES(AES_256_KEY_SZ)); + crypto_.setDigest(new (ys) RMD); + crypto_.setCipher(new (ys) AES(AES_256_KEY_SZ)); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_DSS_WITH_AES_256_CBC_RMD160], MAX_SUITE_NAME); @@ -625,8 +653,8 @@ void SSL::set_pending(Cipher suite) parms.iv_size_ = AES_BLOCK_SZ; parms.cipher_type_ = block; secure_.use_connection().send_server_key_ = true; // eph - crypto_.setDigest(new RMD); - crypto_.setCipher(new AES); + crypto_.setDigest(new (ys) RMD); + crypto_.setCipher(new (ys) AES); strncpy(parms.cipher_name_, cipher_names[TLS_DHE_DSS_WITH_AES_128_CBC_RMD160], MAX_SUITE_NAME); @@ -940,7 +968,7 @@ void SSL::fillData(Data& data) if (readSz == frontSz) { buffers_.useData().pop_front(); - delete front; + ysDelete(front); } if (data.get_length() == dataSz) break; @@ -964,7 +992,7 @@ void SSL::flushBuffer() out.write(front->get_buffer(), front->get_size()); buffers_.useHandShake().pop_front(); - delete front; + ysDelete(front); } Send(out.get_buffer(), out.get_size()); } @@ -1346,7 +1374,7 @@ typedef Mutex::Lock Lock; void Sessions::add(const SSL& ssl) { Lock guard(mutex_); - list_.push_back(new SSL_SESSION(ssl, random_)); + list_.push_back(new (ys) SSL_SESSION(ssl, random_)); } @@ -1459,9 +1487,9 @@ SSL_CTX::SSL_CTX(SSL_METHOD* meth) SSL_CTX::~SSL_CTX() { - delete method_; - delete certificate_; - delete privateKey_; + ysDelete(method_); + ysDelete(certificate_); + ysDelete(privateKey_); mySTL::for_each(caList_.begin(), caList_.end(), del_ptr_zero()); } @@ -1667,9 +1695,9 @@ Crypto::Crypto() Crypto::~Crypto() { - delete dh_; - delete cipher_; - delete digest_; + ysDelete(dh_); + ysDelete(cipher_); + ysDelete(digest_); } @@ -1744,7 +1772,7 @@ void Crypto::SetDH(DiffieHellman* dh) void Crypto::SetDH(const DH_Parms& dh) { if (dh.set_) - dh_ = new DiffieHellman(dh.p_, dh.g_, random_); + dh_ = new (ys) DiffieHellman(dh.p_, dh.g_, random_); } @@ -1911,7 +1939,7 @@ X509_NAME::X509_NAME(const char* n, size_t sz) : name_(0) { if (sz) { - name_ = new char[sz]; + name_ = new (ys) char[sz]; memcpy(name_, n, sz); } } @@ -1919,7 +1947,7 @@ X509_NAME::X509_NAME(const char* n, size_t sz) X509_NAME::~X509_NAME() { - delete[] name_; + ysArrayDelete(name_); } diff --git a/extra/yassl/taocrypt/include/algebra.hpp b/extra/yassl/taocrypt/include/algebra.hpp index 92cac607d97..a09ac8dce16 100644 --- a/extra/yassl/taocrypt/include/algebra.hpp +++ b/extra/yassl/taocrypt/include/algebra.hpp @@ -38,7 +38,7 @@ namespace TaoCrypt { // abcd = group.Add(a, group.Add(b, group.Add(c,d)); // Abstract Group -class TAOCRYPT_NO_VTABLE AbstractGroup +class TAOCRYPT_NO_VTABLE AbstractGroup : public virtual_base { public: typedef Integer Element; @@ -70,8 +70,8 @@ class TAOCRYPT_NO_VTABLE AbstractRing : public AbstractGroup public: typedef Integer Element; - AbstractRing() {m_mg.m_pRing = this;} - AbstractRing(const AbstractRing &source) : AbstractGroup() {m_mg.m_pRing = this;} + AbstractRing() : AbstractGroup() {m_mg.m_pRing = this;} + AbstractRing(const AbstractRing &source) {m_mg.m_pRing = this;} AbstractRing& operator=(const AbstractRing &source) {return *this;} virtual bool IsUnit(const Element &a) const =0; diff --git a/extra/yassl/taocrypt/include/asn.hpp b/extra/yassl/taocrypt/include/asn.hpp index 974bbf4c86f..14fcf22d843 100644 --- a/extra/yassl/taocrypt/include/asn.hpp +++ b/extra/yassl/taocrypt/include/asn.hpp @@ -106,7 +106,7 @@ class DH; // General BER decoding -class BER_Decoder { +class BER_Decoder : public virtual_base { protected: Source& source_; public: @@ -184,7 +184,7 @@ class PublicKey { word32 sz_; public: explicit PublicKey(const byte* k = 0, word32 s = 0); - ~PublicKey() { delete[] key_; } + ~PublicKey() { tcArrayDelete(key_); } const byte* GetKey() const { return key_; } word32 size() const { return sz_; } @@ -287,7 +287,7 @@ word32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz); // General DER encoding -class DER_Encoder { +class DER_Encoder : public virtual_base { public: DER_Encoder() {} virtual ~DER_Encoder() {} diff --git a/extra/yassl/taocrypt/include/block.hpp b/extra/yassl/taocrypt/include/block.hpp index f3c4415682d..c5eec55d37e 100644 --- a/extra/yassl/taocrypt/include/block.hpp +++ b/extra/yassl/taocrypt/include/block.hpp @@ -100,13 +100,13 @@ public: CheckSize(n); if (n == 0) return 0; - return new T[n]; + return new (tc) T[n]; } void deallocate(void* p, size_type n) { memset(p, 0, n * sizeof(T)); - delete [] (T*)p; + tcArrayDelete((T*)p); } pointer reallocate(T* p, size_type oldSize, size_type newSize, diff --git a/extra/yassl/taocrypt/include/hash.hpp b/extra/yassl/taocrypt/include/hash.hpp index f01f343c2d1..257aa1be419 100644 --- a/extra/yassl/taocrypt/include/hash.hpp +++ b/extra/yassl/taocrypt/include/hash.hpp @@ -32,7 +32,7 @@ namespace TaoCrypt { // HASH -class HASH { +class HASH : public virtual_base { public: virtual ~HASH() {} @@ -50,9 +50,9 @@ public: class HASHwithTransform : public HASH { public: HASHwithTransform(word32 digSz, word32 buffSz) - : digest_(new word32[digSz]), buffer_(new byte[buffSz]) {} - virtual ~HASHwithTransform() { delete[] buffer_; delete[] digest_; } - + : digest_(new (tc) word32[digSz]), buffer_(new (tc) byte[buffSz]) {} + virtual ~HASHwithTransform() { tcArrayDelete(buffer_); + tcArrayDelete(digest_); } virtual ByteOrder getByteOrder() const = 0; virtual word32 getPadSize() const = 0; diff --git a/extra/yassl/taocrypt/include/integer.hpp b/extra/yassl/taocrypt/include/integer.hpp index e9e4a7218bd..f9ef267ce4c 100644 --- a/extra/yassl/taocrypt/include/integer.hpp +++ b/extra/yassl/taocrypt/include/integer.hpp @@ -136,9 +136,8 @@ public: ~Integer() {} - static const Integer &Zero(); - static const Integer &One(); - static const Integer &Two(); + static const Integer& Zero(); + static const Integer& One(); Integer& Ref() { return *this; } @@ -252,9 +251,6 @@ private: friend class ModularArithmetic; friend class MontgomeryRepresentation; - static const Integer zero; - static const Integer one; - static const Integer two; Integer(word value, unsigned int length); int PositiveCompare(const Integer& t) const; @@ -267,6 +263,9 @@ private: Integer& dividend, const Integer& divisor); AlignedWordBlock reg_; Sign sign_; + + static const Integer zero_; + static const Integer one_; }; inline bool operator==(const Integer& a, const Integer& b) diff --git a/extra/yassl/taocrypt/include/misc.hpp b/extra/yassl/taocrypt/include/misc.hpp index de8cbb30fcb..812cdd93879 100644 --- a/extra/yassl/taocrypt/include/misc.hpp +++ b/extra/yassl/taocrypt/include/misc.hpp @@ -27,75 +27,59 @@ #include #include #include +#include "types.hpp" +#include "type_traits.hpp" + +/* +namespace GCC_ABI { + extern "C" int __cxa_pure_virtual(); +} */ + +namespace TaoCrypt { + +// using GCC_ABI::__cxa_pure_virtual; + +// library allocation +struct new_t {}; // TaoCrypt New type +extern new_t tc; // pass in parameter + +} // namespace TaoCrypt + +void* operator new (size_t, TaoCrypt::new_t); +void* operator new[](size_t, TaoCrypt::new_t); + +void operator delete (void*, TaoCrypt::new_t); +void operator delete[](void*, TaoCrypt::new_t); namespace TaoCrypt { +template +void tcDelete(T* ptr) +{ + if (ptr) ptr->~T(); + ::operator delete(ptr, TaoCrypt::tc); +} -// define this if running on a big-endian CPU -#if !defined(LITTLE_ENDIAN_ORDER) && (defined(__BIG_ENDIAN__) || \ - defined(__sparc) || defined(__sparc__) || defined(__hppa__) || \ - defined(__mips__) || (defined(__MWERKS__) && !defined(__INTEL__))) - #define BIG_ENDIAN_ORDER -#endif +template +void tcArrayDelete(T* ptr) +{ + // can't do array placement destruction since not tracking size in + // allocation, only allow builtins to use array placement since they + // don't need destructors called + typedef char builtin[IsFundamentalType::Yes ? 1 : -1]; + (void)sizeof(builtin); -#ifndef BIG_ENDIAN_ORDER - #define LITTLE_ENDIAN_ORDER -#endif + ::operator delete[](ptr, TaoCrypt::tc); +} -typedef unsigned char byte; -typedef unsigned short word16; -typedef unsigned int word32; - -#if defined(__GNUC__) || defined(__MWERKS__) || defined(_LONGLONG_TYPE) - #define WORD64_AVAILABLE - typedef unsigned long long word64; - #define W64LIT(x) x##LL -#elif defined(_MSC_VER) || defined(__BCPLUSPLUS__) - #define WORD64_AVAILABLE - typedef unsigned __int64 word64; - #define W64LIT(x) x##ui64 -#elif defined(__DECCXX) - #define WORD64_AVAILABLE - typedef unsigned long word64; -#endif - -// define largest word type -#ifdef WORD64_AVAILABLE - typedef word64 lword; -#else - typedef word32 lword; -#endif - -// FIXME the !defined(__sun) is a temporarely solution until asm for -// __x86_64__ and Solaris is written -#if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || \ - defined(__mips64) || (defined(__x86_64__) && !defined(__sun)) -// These platforms have 64-bit CPU registers. Unfortunately most C++ compilers -// don't allow any way to access the 64-bit by 64-bit multiply instruction -// without using assembly, so in order to use word64 as word, the assembly -// instruction must be defined in Dword::Multiply(). - typedef word32 hword; - typedef word64 word; -#else - #define TAOCRYPT_NATIVE_DWORD_AVAILABLE - #ifdef WORD64_AVAILABLE - #define TAOCRYPT_SLOW_WORD64 - // define this if your CPU is not64-bit to use alternative code - // that avoids word64 - typedef word16 hword; - typedef word32 word; - typedef word64 dword; - #else - typedef byte hword; - typedef word16 word; - typedef word32 dword; - #endif -#endif - -const word32 WORD_SIZE = sizeof(word); -const word32 WORD_BITS = WORD_SIZE * 8; +// to resolve compiler generated operator delete on base classes with +// virtual destructors, make sure doesn't get called +class virtual_base { +public: + static void operator delete(void*) { assert(0); } +}; #if defined(_MSC_VER) || defined(__BCPLUSPLUS__) diff --git a/extra/yassl/taocrypt/include/modes.hpp b/extra/yassl/taocrypt/include/modes.hpp index 3f9878a9e62..585231c9b9e 100644 --- a/extra/yassl/taocrypt/include/modes.hpp +++ b/extra/yassl/taocrypt/include/modes.hpp @@ -56,7 +56,7 @@ private: // Mode Base for block ciphers, static size -class Mode_BASE { +class Mode_BASE : public virtual_base { public: enum { MaxBlockSz = 16 }; diff --git a/extra/yassl/taocrypt/include/runtime.hpp b/extra/yassl/taocrypt/include/runtime.hpp index 43f1b72fd51..01106b6f960 100644 --- a/extra/yassl/taocrypt/include/runtime.hpp +++ b/extra/yassl/taocrypt/include/runtime.hpp @@ -31,30 +31,6 @@ #if __GNUC__ > 2 -#include - - -static void* operator new (size_t sz) -{ - return malloc (sz ? sz : 1); -} - -static void* operator new[](size_t sz) -{ - return malloc (sz ? sz : 1); -} - -static void operator delete (void* ptr) -{ - if (ptr) free(ptr); -} - -static void operator delete[] (void* ptr) -{ - if (ptr) free(ptr); -} - - extern "C" { #include diff --git a/extra/yassl/taocrypt/include/type_traits.hpp b/extra/yassl/taocrypt/include/type_traits.hpp new file mode 100644 index 00000000000..caf71f90e11 --- /dev/null +++ b/extra/yassl/taocrypt/include/type_traits.hpp @@ -0,0 +1,80 @@ +/* type_traits.hpp + * + * Copyright (C) 2003 Sawtooth Consulting Ltd. + * + * This file is part of yaSSL. + * + * yaSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * yaSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/* type_traits defines fundamental types + * see discussion in C++ Templates, $19.1 +*/ + + +#ifndef TAO_CRYPT_TYPE_TRAITS_HPP +#define TAO_CRYPT_TYPE_TRAITS_HPP + +#include "types.hpp" + +namespace TaoCrypt { + + +// primary template: in general T is not a fundamental type + +template +class IsFundamentalType { + public: + enum { Yes = 0, No = 1 }; +}; + + +// macro to specialize for fundamental types +#define MK_FUNDAMENTAL_TYPE(T) \ + template<> class IsFundamentalType { \ + public: \ + enum { Yes = 1, No = 0 }; \ + }; + + +MK_FUNDAMENTAL_TYPE(void) + +MK_FUNDAMENTAL_TYPE(bool) +MK_FUNDAMENTAL_TYPE( char) +MK_FUNDAMENTAL_TYPE(signed char) +MK_FUNDAMENTAL_TYPE(unsigned char) + +MK_FUNDAMENTAL_TYPE(signed short) +MK_FUNDAMENTAL_TYPE(unsigned short) +MK_FUNDAMENTAL_TYPE(signed int) +MK_FUNDAMENTAL_TYPE(unsigned int) +MK_FUNDAMENTAL_TYPE(signed long) +MK_FUNDAMENTAL_TYPE(unsigned long) + +MK_FUNDAMENTAL_TYPE(float) +MK_FUNDAMENTAL_TYPE( double) +MK_FUNDAMENTAL_TYPE(long double) + +#ifdef WORD64_AVAILABLE + MK_FUNDAMENTAL_TYPE(word64) +#endif + + +#undef MK_FUNDAMENTAL_TYPE + + +} // namespace + +#endif // TAO_CRYPT_TYPE_TRAITS_HPP diff --git a/extra/yassl/taocrypt/include/types.hpp b/extra/yassl/taocrypt/include/types.hpp new file mode 100644 index 00000000000..0d57022a2d0 --- /dev/null +++ b/extra/yassl/taocrypt/include/types.hpp @@ -0,0 +1,99 @@ +/* types.hpp + * + * Copyright (C) 2003 Sawtooth Consulting Ltd. + * + * This file is part of yaSSL. + * + * yaSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * yaSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/* based on Wei Dai's misc.h from CryptoPP, basic crypt types */ + + +#ifndef TAO_CRYPT_TYPES_HPP +#define TAO_CRYPT_TYPES_HPP + +namespace TaoCrypt { + +// define this if running on a big-endian CPU +#if !defined(LITTLE_ENDIAN_ORDER) && (defined(__BIG_ENDIAN__) || \ + defined(__sparc) || defined(__sparc__) || defined(__hppa__) || \ + defined(__mips__) || (defined(__MWERKS__) && !defined(__INTEL__))) + #define BIG_ENDIAN_ORDER +#endif + +#ifndef BIG_ENDIAN_ORDER + #define LITTLE_ENDIAN_ORDER +#endif + + +typedef unsigned char byte; +typedef unsigned short word16; +typedef unsigned int word32; + +#if defined(__GNUC__) || defined(__MWERKS__) || defined(_LONGLONG_TYPE) + #define WORD64_AVAILABLE + typedef unsigned long long word64; + #define W64LIT(x) x##LL +#elif defined(_MSC_VER) || defined(__BCPLUSPLUS__) + #define WORD64_AVAILABLE + typedef unsigned __int64 word64; + #define W64LIT(x) x##ui64 +#elif defined(__DECCXX) + #define WORD64_AVAILABLE + typedef unsigned long word64; +#endif + +// define largest word type +#ifdef WORD64_AVAILABLE + typedef word64 lword; +#else + typedef word32 lword; +#endif + + +// TODO: FIXME, add asm multiply for x86_64 on Solaris and remove !__sun + +#if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || \ + defined(__mips64) || (defined(__x86_64__) && !defined(__sun)) +// These platforms have 64-bit CPU registers. Unfortunately most C++ compilers +// don't allow any way to access the 64-bit by 64-bit multiply instruction +// without using assembly, so in order to use word64 as word, the assembly +// instruction must be defined in Dword::Multiply(). + typedef word32 hword; + typedef word64 word; +#else + #define TAOCRYPT_NATIVE_DWORD_AVAILABLE + #ifdef WORD64_AVAILABLE + #define TAOCRYPT_SLOW_WORD64 + // define this if your CPU is not64-bit to use alternative code + // that avoids word64 + typedef word16 hword; + typedef word32 word; + typedef word64 dword; + #else + typedef byte hword; + typedef word16 word; + typedef word32 dword; + #endif +#endif + +const word32 WORD_SIZE = sizeof(word); +const word32 WORD_BITS = WORD_SIZE * 8; + + +} // namespace + +#endif // TAO_CRYPT_TYPES_HPP diff --git a/extra/yassl/taocrypt/src/Makefile.am b/extra/yassl/taocrypt/src/Makefile.am index b00e6081c23..4005be94fb2 100644 --- a/extra/yassl/taocrypt/src/Makefile.am +++ b/extra/yassl/taocrypt/src/Makefile.am @@ -3,5 +3,6 @@ INCLUDES = -I../include -I../../mySTL noinst_LIBRARIES = libtaocrypt.a libtaocrypt_a_SOURCES = aes.cpp aestables.cpp algebra.cpp arc4.cpp asn.cpp \ coding.cpp dh.cpp des.cpp dsa.cpp file.cpp hash.cpp integer.cpp \ - md2.cpp md5.cpp misc.cpp random.cpp ripemd.cpp rsa.cpp sha.cpp + md2.cpp md5.cpp misc.cpp random.cpp ripemd.cpp rsa.cpp sha.cpp \ + template_instnt.cpp EXTRA_DIST = ../include/*.hpp diff --git a/extra/yassl/taocrypt/src/aestables.cpp b/extra/yassl/taocrypt/src/aestables.cpp index 7ba25bc9ffb..5a125dfd44d 100644 --- a/extra/yassl/taocrypt/src/aestables.cpp +++ b/extra/yassl/taocrypt/src/aestables.cpp @@ -21,7 +21,6 @@ /* based on Wei Dai's aestables.cpp from CryptoPP */ -#include "runtime.hpp" #include "aes.hpp" diff --git a/extra/yassl/taocrypt/src/algebra.cpp b/extra/yassl/taocrypt/src/algebra.cpp index d70f8dd5d72..7608e78b0ed 100644 --- a/extra/yassl/taocrypt/src/algebra.cpp +++ b/extra/yassl/taocrypt/src/algebra.cpp @@ -322,8 +322,6 @@ void AbstractRing::SimultaneousExponentiate(Integer *results, #ifdef __GNUC__ namespace mySTL { template TaoCrypt::WindowSlider* uninit_copy(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*); -template vector* uninit_fill_n*, unsigned int, vector >(vector*, unsigned int, vector const&); template void destroy(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*); -template void destroy*>(vector*, vector*); } #endif diff --git a/extra/yassl/taocrypt/src/arc4.cpp b/extra/yassl/taocrypt/src/arc4.cpp index 1e521b48f0c..bbd77cd822c 100644 --- a/extra/yassl/taocrypt/src/arc4.cpp +++ b/extra/yassl/taocrypt/src/arc4.cpp @@ -21,7 +21,6 @@ /* based on Wei Dai's arc4.cpp from CryptoPP */ -#include "runtime.hpp" #include "arc4.hpp" diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp index 59c544bd633..720fe7cd532 100644 --- a/extra/yassl/taocrypt/src/asn.cpp +++ b/extra/yassl/taocrypt/src/asn.cpp @@ -187,7 +187,7 @@ PublicKey::PublicKey(const byte* k, word32 s) : key_(0), sz_(0) void PublicKey::SetSize(word32 s) { sz_ = s; - key_ = new byte[sz_]; + key_ = new (tc) byte[sz_]; } @@ -199,14 +199,14 @@ void PublicKey::SetKey(const byte* k) void PublicKey::AddToEnd(const byte* data, word32 len) { - mySTL::auto_ptr tmp(new byte[sz_ + len]); + mySTL::auto_ptr tmp(new (tc) byte[sz_ + len], tcArrayDelete); memcpy(tmp.get(), key_, sz_); memcpy(tmp.get() + sz_, data, len); byte* del = 0; mySTL::swap(del, key_); - delete[] del; + tcArrayDelete(del); key_ = tmp.release(); sz_ += len; @@ -218,7 +218,7 @@ Signer::Signer(const byte* k, word32 kSz, const char* n, const byte* h) { if (n) { int sz = strlen(n); - name_ = new char[sz + 1]; + name_ = new (tc) char[sz + 1]; memcpy(name_, n, sz); name_[sz] = 0; } @@ -228,7 +228,7 @@ Signer::Signer(const byte* k, word32 kSz, const char* n, const byte* h) Signer::~Signer() { - delete[] name_; + tcArrayDelete(name_); } @@ -433,9 +433,9 @@ CertDecoder::CertDecoder(Source& s, bool decode, SignerList* signers) CertDecoder::~CertDecoder() { - delete[] subject_; - delete[] issuer_; - delete[] signature_; + tcArrayDelete(subject_); + tcArrayDelete(issuer_); + tcArrayDelete(signature_); } @@ -632,7 +632,7 @@ word32 CertDecoder::GetSignature() } sigLength_--; - signature_ = new byte[sigLength_]; + signature_ = new (tc) byte[sigLength_]; memcpy(signature_, source_.get_current(), sigLength_); source_.advance(sigLength_); @@ -653,7 +653,7 @@ word32 CertDecoder::GetDigest() sigLength_ = GetLength(source_); - signature_ = new byte[sigLength_]; + signature_ = new (tc) byte[sigLength_]; memcpy(signature_, source_.get_current(), sigLength_); source_.advance(sigLength_); @@ -693,7 +693,7 @@ void CertDecoder::GetName(NameType nt) if (id == COMMON_NAME) { char*& ptr = (nt == ISSUER) ? issuer_ : subject_; - ptr = new char[strLen + 1]; + ptr = new (tc) char[strLen + 1]; memcpy(ptr, source_.get_current(), strLen); ptr[strLen] = 0; } @@ -807,18 +807,18 @@ bool CertDecoder::ValidateSignature(SignerList* signers) bool CertDecoder::ConfirmSignature(Source& pub) { HashType ht; - mySTL::auto_ptr hasher; + mySTL::auto_ptr hasher(tcDelete); if (signatureOID_ == MD5wRSA) { - hasher.reset(new MD5); + hasher.reset(new (tc) MD5); ht = MD5h; } else if (signatureOID_ == MD2wRSA) { - hasher.reset(new MD2); + hasher.reset(new (tc) MD2); ht = MD2h; } else if (signatureOID_ == SHAwRSA || signatureOID_ == SHAwDSA) { - hasher.reset(new SHA); + hasher.reset(new (tc) SHA); ht = SHAh; } else { diff --git a/extra/yassl/taocrypt/src/coding.cpp b/extra/yassl/taocrypt/src/coding.cpp index 944a47c288e..6514ed4d46d 100644 --- a/extra/yassl/taocrypt/src/coding.cpp +++ b/extra/yassl/taocrypt/src/coding.cpp @@ -22,7 +22,6 @@ /* coding.cpp implements hex and base64 encoding/decoing */ -#include "runtime.hpp" #include "coding.hpp" #include "file.hpp" diff --git a/extra/yassl/taocrypt/src/dh.cpp b/extra/yassl/taocrypt/src/dh.cpp index ea1b5846f7d..d5f93f6c0f6 100644 --- a/extra/yassl/taocrypt/src/dh.cpp +++ b/extra/yassl/taocrypt/src/dh.cpp @@ -23,7 +23,6 @@ /* dh.cpp implements Diffie-Hellman support */ -#include "runtime.hpp" #include "dh.hpp" #include "asn.hpp" diff --git a/extra/yassl/taocrypt/src/dsa.cpp b/extra/yassl/taocrypt/src/dsa.cpp index 5cb3018a402..b89b42ac9d8 100644 --- a/extra/yassl/taocrypt/src/dsa.cpp +++ b/extra/yassl/taocrypt/src/dsa.cpp @@ -20,7 +20,6 @@ */ -#include "runtime.hpp" #include "dsa.hpp" #include "sha.hpp" #include "asn.hpp" diff --git a/extra/yassl/taocrypt/src/file.cpp b/extra/yassl/taocrypt/src/file.cpp index 4d48b9e7bca..75df80608ae 100644 --- a/extra/yassl/taocrypt/src/file.cpp +++ b/extra/yassl/taocrypt/src/file.cpp @@ -22,7 +22,6 @@ /* file.cpp implements File Sources and Sinks */ -#include "runtime.hpp" #include "file.hpp" diff --git a/extra/yassl/taocrypt/src/integer.cpp b/extra/yassl/taocrypt/src/integer.cpp index b6a1b72a41f..67f3c963cac 100644 --- a/extra/yassl/taocrypt/src/integer.cpp +++ b/extra/yassl/taocrypt/src/integer.cpp @@ -32,7 +32,6 @@ # pragma warning(disable: 4250 4660 4661 4786 4355) #endif -#include "runtime.hpp" #include "integer.hpp" #include "modarith.hpp" #include "asn.hpp" @@ -108,7 +107,7 @@ CPP_TYPENAME AllocatorBase::pointer AlignedAllocator::allocate( assert(IsAlignedOn(p, 16)); return (T*)p; } - return new T[n]; + return new (tc) T[n]; } @@ -129,7 +128,7 @@ void AlignedAllocator::deallocate(void* p, size_type n) #endif } else - delete [] (T *)p; + tcArrayDelete((T *)p); } #endif // SSE2 @@ -2691,25 +2690,19 @@ unsigned int Integer::Encode(byte* output, unsigned int outputLen, } -const Integer Integer::zero(1,2); +const Integer Integer::zero_; const Integer &Integer::Zero() { - return zero; + return zero_; } -const Integer Integer::one(1,2); + +const Integer Integer::one_(1,2); const Integer &Integer::One() { - return one; -} - -const Integer Integer::two(1,2); - -const Integer &Integer::Two() -{ - return two; + return one_; } @@ -3948,9 +3941,6 @@ Integer CRT(const Integer &xp, const Integer &p, const Integer &xq, #ifdef __GNUC__ template unsigned int DivideThreeWordsByTwo(unsigned int*, unsigned int, unsigned int, DWord*); -#if defined(SSE2_INTRINSICS_AVAILABLE) -template AlignedAllocator::pointer StdReallocate >(AlignedAllocator&, unsigned int*, AlignedAllocator::size_type, AlignedAllocator::size_type, bool); -#endif #endif } // namespace diff --git a/extra/yassl/taocrypt/src/misc.cpp b/extra/yassl/taocrypt/src/misc.cpp index 37d1bd1b14d..1780b3050e9 100644 --- a/extra/yassl/taocrypt/src/misc.cpp +++ b/extra/yassl/taocrypt/src/misc.cpp @@ -22,14 +22,73 @@ /* based on Wei Dai's misc.cpp from CryptoPP */ -#include "runtime.hpp" #include "misc.hpp" #include // for NewHandler +void* operator new(size_t sz, TaoCrypt::new_t) +{ + void* ptr = malloc(sz ? sz : 1); + if (!ptr) abort(); + + return ptr; +} + +void* operator new[](size_t sz, TaoCrypt::new_t) +{ + void* ptr = malloc(sz ? sz : 1); + if (!ptr) abort(); + + return ptr; +} + +void operator delete(void* ptr, TaoCrypt::new_t) +{ + if (ptr) free(ptr); +} + +void operator delete[](void* ptr, TaoCrypt::new_t) +{ + if (ptr) free(ptr); +} + + +/* uncomment to test +// make sure not using globals anywhere by forgetting to use overloaded +void* operator new(size_t sz) +{ + assert(0); + return malloc(sz); +} + +void operator delete(void* ptr) +{ + assert(0); +} + +void* operator new[](size_t sz) +{ + assert(0); + return malloc(sz); +} + +void operator delete[](void* ptr) +{ + assert(0); +} +*/ + +/* namespace GCC_ABI { + extern "C" int __cxa_pure_virtual() { assert(0); return 0; } +} */ + + namespace TaoCrypt { +new_t tc; // for library new + + inline void XorWords(word* r, const word* a, unsigned int n) { for (unsigned int i=0; i::pointer StdReallocate >(AllocatorWithCleanup&, unsigned char*, AllocatorWithCleanup::size_type, AllocatorWithCleanup::size_type, bool); -template AllocatorWithCleanup::pointer StdReallocate >(AllocatorWithCleanup&, unsigned int*, AllocatorWithCleanup::size_type, AllocatorWithCleanup::size_type, bool); -template class RSA_Decryptor; -template class RSA_Encryptor; -template class RSA_Encryptor; -#endif } // namespace - -#ifdef __GNUC__ -namespace mySTL { -template TaoCrypt::Integer* uninit_copy(TaoCrypt::Integer*, TaoCrypt::Integer*, TaoCrypt::Integer*); -template TaoCrypt::Integer* uninit_fill_n(TaoCrypt::Integer*, unsigned int, TaoCrypt::Integer const&); -template void destroy(TaoCrypt::Integer*, TaoCrypt::Integer*); -} -#endif - - diff --git a/extra/yassl/taocrypt/src/template_instnt.cpp b/extra/yassl/taocrypt/src/template_instnt.cpp new file mode 100644 index 00000000000..28dbdc5c739 --- /dev/null +++ b/extra/yassl/taocrypt/src/template_instnt.cpp @@ -0,0 +1,31 @@ +#include "integer.hpp" +#include "rsa.hpp" +#include "algebra.hpp" +#include "vector.hpp" +#include "hash.hpp" + +#ifdef __GNUC__ +namespace TaoCrypt { +#if defined(SSE2_INTRINSICS_AVAILABLE) +template AlignedAllocator::pointer StdReallocate >(AlignedAllocator&, unsigned int*, AlignedAllocator::size_type, AlignedAllocator::size_type, bool); +#endif +template AllocatorWithCleanup::pointer StdReallocate >(AllocatorWithCleanup&, unsigned char*, AllocatorWithCleanup::size_type, AllocatorWithCleanup::size_type, bool); +template AllocatorWithCleanup::pointer StdReallocate >(AllocatorWithCleanup&, unsigned int*, AllocatorWithCleanup::size_type, AllocatorWithCleanup::size_type, bool); +template class RSA_Decryptor; +template class RSA_Encryptor; +template class RSA_Encryptor; +} + +namespace mySTL { +template vector* uninit_fill_n*, unsigned int, vector >(vector*, unsigned int, vector const&); +template void destroy*>(vector*, vector*); +template TaoCrypt::Integer* uninit_copy(TaoCrypt::Integer*, TaoCrypt::Integer*, TaoCrypt::Integer*); +template TaoCrypt::Integer* uninit_fill_n(TaoCrypt::Integer*, unsigned int, TaoCrypt::Integer const&); +template void destroy(TaoCrypt::Integer*, TaoCrypt::Integer*); +} + +template void TaoCrypt::tcDelete(TaoCrypt::HASH*); +template void TaoCrypt::tcArrayDelete(unsigned*); +template void TaoCrypt::tcArrayDelete(unsigned char*); +template void TaoCrypt::tcArrayDelete(char*); +#endif From 76073d7bf5878e77435406e3b24346a547ea1e14 Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Tue, 31 May 2005 18:36:32 +0200 Subject: [PATCH 79/98] Fixed BUG#9529: Stored Procedures: No Warning on truncation of procedure name during creation. Although it returns an error, consistent with the behaviour for other objects. (Unclear why we would allow the creation of SPs with truncated names.) --- mysql-test/r/sp-error.result | 4 ++++ mysql-test/t/sp-error.test | 10 ++++++++++ sql/sp.cc | 9 +++++++++ sql/sp.h | 1 + sql/sql_parse.cc | 6 ++++++ 5 files changed, 30 insertions(+) diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 5eb651e2fca..ccdb46f10d0 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -654,4 +654,8 @@ flush tables; return 5; end| ERROR 0A000: FLUSH is not allowed in stored procedures +create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890() +begin +end| +ERROR 42000: Identifier name 'bug9529_90123456789012345678901234567890123456789012345678901234567890' is too long drop table t1| diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 78a6cdd49e1..a2a43110b54 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -920,6 +920,16 @@ begin end| +# +# BUG#9529: Stored Procedures: No Warning on truncation of procedure name +# during creation. +# +--error ER_TOO_LONG_IDENT +create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890() +begin +end| + + # # BUG#NNNN: New bug synopsis # diff --git a/sql/sp.cc b/sql/sp.cc index a5b1f062456..4f89d6ba6da 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -120,6 +120,10 @@ db_find_routine_aux(THD *thd, int type, sp_name *name, 'db', 'name' and 'type' and the first key is the primary key over the same fields. */ + if (name->m_name.length > table->field[1]->field_length) + { + DBUG_RETURN(SP_KEY_NOT_FOUND); + } table->field[0]->store(name->m_db.str, name->m_db.length, &my_charset_bin); table->field[1]->store(name->m_name.str, name->m_name.length, &my_charset_bin); @@ -389,6 +393,11 @@ db_create_routine(THD *thd, int type, sp_head *sp) ret= SP_GET_FIELD_FAILED; goto done; } + if (sp->m_name.length > table->field[MYSQL_PROC_FIELD_NAME]->field_length) + { + ret= SP_BAD_IDENTIFIER; + goto done; + } table->field[MYSQL_PROC_FIELD_DB]-> store(sp->m_db.str, sp->m_db.length, system_charset_info); table->field[MYSQL_PROC_FIELD_NAME]-> diff --git a/sql/sp.h b/sql/sp.h index 00dd8416c1d..16d79026132 100644 --- a/sql/sp.h +++ b/sql/sp.h @@ -28,6 +28,7 @@ #define SP_PARSE_ERROR -6 #define SP_INTERNAL_ERROR -7 #define SP_NO_DB_ERROR -8 +#define SP_BAD_IDENTIFIER -9 /* Drop all routines in database 'db' */ int diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index b36f88cf8c8..2191eba2f3e 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4019,6 +4019,12 @@ unsent_create_error: delete lex->sphead; lex->sphead= 0; goto error; + case SP_BAD_IDENTIFIER: + my_error(ER_TOO_LONG_IDENT, MYF(0), name); + lex->unit.cleanup(); + delete lex->sphead; + lex->sphead= 0; + goto error; default: my_error(ER_SP_STORE_FAILED, MYF(0), SP_TYPE_STRING(lex), name); lex->unit.cleanup(); From c4f37eda6573e4c63d9d839b8a6c9396e729bb67 Mon Sep 17 00:00:00 2001 From: "acurtis@xiphis.org" <> Date: Tue, 31 May 2005 18:06:54 +0100 Subject: [PATCH 80/98] Bug#10413 - Invalid column name is not rejected Stop ignoring name parts and check for validity --- mysql-test/r/create.result | 9 +++++++++ mysql-test/t/create.test | 13 +++++++++++++ sql/sql_yacc.yy | 26 +++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 103bed598ef..cae5e24df18 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -563,3 +563,12 @@ select * from t2; b 1 drop table t1,t2; +create table t1(column.name int); +ERROR 42000: Incorrect table name 'column' +create table t1(test.column.name int); +ERROR 42000: Incorrect table name 'column' +create table t1(xyz.t1.name int); +ERROR 42000: Incorrect database name 'xyz' +create table t1(t1.name int); +create table t2(test.t2.name int); +drop table t1,t2; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index ce85e530569..dca662a415e 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -460,3 +460,16 @@ insert into t2 values (); select * from t1; select * from t2; drop table t1,t2; + +# +# Bug#10413: Invalid column name is not rejected +# +--error 1103 +create table t1(column.name int); +--error 1103 +create table t1(test.column.name int); +--error 1102 +create table t1(xyz.t1.name int); +create table t1(t1.name int); +create table t2(test.t2.name int); +drop table t1,t2; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index d8a2c997bf8..7585f0b10a0 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -5016,7 +5016,31 @@ simple_ident: field_ident: ident { $$=$1;} - | ident '.' ident { $$=$3;} /* Skip schema name in create*/ + | ident '.' ident '.' ident + { + TABLE_LIST *table= (TABLE_LIST*) Select->table_list.first; + if (my_strcasecmp(table_alias_charset, $1.str, table->db)) + { + net_printf(YYTHD, ER_WRONG_DB_NAME, $1.str); + YYABORT; + } + if (my_strcasecmp(table_alias_charset, $3.str, table->real_name)) + { + net_printf(YYTHD, ER_WRONG_TABLE_NAME, $3.str); + YYABORT; + } + $$=$5; + } + | ident '.' ident + { + TABLE_LIST *table= (TABLE_LIST*) Select->table_list.first; + if (my_strcasecmp(table_alias_charset, $1.str, table->alias)) + { + net_printf(YYTHD, ER_WRONG_TABLE_NAME, $1.str); + YYABORT; + } + $$=$3; + } | '.' ident { $$=$2;} /* For Delphi */; table_ident: From 40b53eab2389c3a73b25d26e278ac96abfc72c15 Mon Sep 17 00:00:00 2001 From: "ingo@mysql.com" <> Date: Tue, 31 May 2005 20:45:41 +0200 Subject: [PATCH 81/98] Bug#10224 - ANALYZE TABLE crashing with simultaneous CREATE ... SELECT statement. After merge fix. --- mysql-test/r/create.result | 5 +++-- mysql-test/t/create.test | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 7bec98b0687..cd8378a504d 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -563,11 +563,12 @@ select * from t2; b 1 drop table t1,t2; +use test; create table t1 (a int); create table t1 select * from t1; -INSERT TABLE 't1' isn't allowed in FROM table list +ERROR HY000: You can't specify target table 't1' for update in FROM clause create table t2 union = (t1) select * from t1; -INSERT TABLE 't1' isn't allowed in FROM table list +ERROR HY000: You can't specify target table 't1' for update in FROM clause flush tables with read lock; unlock tables; drop table t1; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 5677a9cccb2..c37fccef70b 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -467,6 +467,8 @@ drop table t1,t2; # This tests two additional possible errors and a hang if # an improper fix is present. # +connection default; +use test; create table t1 (a int); --error 1093 create table t1 select * from t1; From 85f19d5da53b842d4e68a7b2a5eac64aa7b655d2 Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Wed, 1 Jun 2005 12:18:41 +0200 Subject: [PATCH 82/98] Fixed BUG#10961: Stored procedures: crash if select * from dual Have to catch errors from SELECT when opening a cursor. --- mysql-test/r/sp.result | 29 +++++++++++++++++++++++++++++ mysql-test/t/sp.test | 29 +++++++++++++++++++++++++++++ sql/protocol.h | 4 ++-- sql/sp_head.cc | 14 +++++++++++++- 4 files changed, 73 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index da54c100178..3c6fa84882f 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -3109,4 +3109,33 @@ select bug9559()| bug9559() -3 drop function bug9559| +drop procedure if exists bug10961| +create procedure bug10961() +begin +declare v char; +declare x int; +declare c cursor for select * from dual; +declare continue handler for sqlexception select x; +set x = 1; +open c; +set x = 2; +fetch c into v; +set x = 3; +close c; +end| +call bug10961()| +x +1 +x +2 +x +3 +call bug10961()| +x +1 +x +2 +x +3 +drop procedure bug10961| drop table t1,t2; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 18389f4d80a..7acd4d81081 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -3801,6 +3801,7 @@ call bug5963_2(1)| drop procedure bug5963_2| drop table t3| + # # BUG#9559: Functions: Numeric Operations using -ve value gives incorrect # results. @@ -3820,6 +3821,34 @@ select bug9559()| drop function bug9559| +# +# BUG#10961: Stored procedures: crash if select * from dual +# +--disable_warnings +drop procedure if exists bug10961| +--enable_warnings +# "select * from dual" results in an error, so the cursor will not open +create procedure bug10961() +begin + declare v char; + declare x int; + declare c cursor for select * from dual; + declare continue handler for sqlexception select x; + + set x = 1; + open c; + set x = 2; + fetch c into v; + set x = 3; + close c; +end| + +call bug10961()| +call bug10961()| + +drop procedure bug10961| + + # # BUG#NNNN: New bug synopsis # diff --git a/sql/protocol.h b/sql/protocol.h index 01331ef64ba..5b402cb2669 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -159,8 +159,8 @@ public: MYSQL_ROWS **prev_record; ulong row_count; - Protocol_cursor() {} - Protocol_cursor(THD *thd_arg, MEM_ROOT *ini_alloc) :Protocol_simple(thd_arg), alloc(ini_alloc) {} + Protocol_cursor() :data(NULL) {} + Protocol_cursor(THD *thd_arg, MEM_ROOT *ini_alloc) :Protocol_simple(thd_arg), alloc(ini_alloc), data(NULL) {} bool prepare_for_send(List *item_list) { row_count= 0; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index fcca1b51d1c..c17c8b81cb2 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1913,7 +1913,19 @@ sp_instr_copen::execute(THD *thd, uint *nextp) else res= lex_keeper->reset_lex_and_exec_core(thd, nextp, FALSE, this); - c->post_open(thd, (lex_keeper ? TRUE : FALSE)); + /* + Work around the fact that errors in selects are not returned properly + (but instead converted into a warning), so if a condition handler + caught, we have lost the result code. + */ + if (!res) + { + uint dummy1, dummy2; + + if (thd->spcont->found_handler(&dummy1, &dummy2)) + res= -1; + } + c->post_open(thd, (lex_keeper && !res ? TRUE : FALSE)); } DBUG_RETURN(res); From 7bd3dd7cb319e901290846544c6a518dfcef0baa Mon Sep 17 00:00:00 2001 From: "lenz@mysql.com" <> Date: Wed, 1 Jun 2005 12:59:10 +0200 Subject: [PATCH 83/98] - removed references to some obsolete files (BUG#10824) - removed obsolete mysql-max.spec.sc RPM spec file (Max is built out of the standard spec file) --- configure.in | 8 +- scripts/make_binary_distribution.sh | 3 - support-files/mysql-max.spec.sh | 263 ---------------------------- 3 files changed, 1 insertion(+), 273 deletions(-) delete mode 100644 support-files/mysql-max.spec.sh diff --git a/configure.in b/configure.in index 938f2f5776f..b291200c114 100644 --- a/configure.in +++ b/configure.in @@ -1193,16 +1193,10 @@ EOF # echo -n "making sure specific build files are writable... " for file in \ - Docs/include.texi \ Docs/mysql.info \ - Docs/manual.txt \ - Docs/manual_toc.html \ - Docs/manual.html \ Docs/INSTALL-BINARY \ INSTALL-SOURCE \ - COPYING \ - COPYING.LIB \ - MIRRORS + COPYING do if test -e $file; then chmod +w $file diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 8ea9a16f56b..ffef1648954 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -74,9 +74,6 @@ if [ $BASE_SYSTEM != "netware" ] ; then fi for i in ChangeLog \ - Docs/manual.html \ - Docs/manual.txt \ - Docs/manual_toc.html \ Docs/mysql.info do if [ -f $i ] diff --git a/support-files/mysql-max.spec.sh b/support-files/mysql-max.spec.sh deleted file mode 100644 index 5c4b16f0e9d..00000000000 --- a/support-files/mysql-max.spec.sh +++ /dev/null @@ -1,263 +0,0 @@ -%define mysql_version @VERSION@ -%define shared_lib_version @SHARED_LIB_VERSION@ -%define release 2 -%define mysqld_user mysql - -%define see_base For a description of MySQL see the base MySQL RPM or http://www.mysql.com - -Name: MySQL -Summary: MySQL: a very fast and reliable SQL database engine -Group: Applications/Databases -Summary(pt_BR): MySQL: Um servidor SQL rápido e confiável. -Group(pt_BR): Aplicações/Banco_de_Dados -Version: @MYSQL_NO_DASH_VERSION@ -Release: %{release} -Copyright: GPL / LGPL -Source: http://www.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/mysql-%{mysql_version}.tar.gz -Icon: mysql.gif -URL: http://www.mysql.com/ -Packager: David Axmark , Monty -Provides: msqlormysql MySQL-server -Obsoletes: mysql - -# Think about what you use here since the first step is to -# run a rm -rf -BuildRoot: /var/tmp/mysql-max - -# From the manual -%description -MySQL is a true multi-user, multi-threaded SQL (Structured Query -Language) database server. MySQL is a client/server implementation -that consists of a server daemon (mysqld) and many different client -programs/libraries. - -The main goals of MySQL are speed, robustness and ease of use. MySQL -was originally developed because we needed a SQL server that could -handle very big databases with magnitude higher speed than what any -database vendor could offer to us. And since we did not need all the -features that made their server slow we made our own. We have now been -using MySQL since 1996 in a environment with more than 40 databases, -10,000 tables, of which more than 500 have more than 7 million -rows. This is about 200G of data. - -The base upon which MySQL is built is a set of routines that have been -used in a highly demanding production environment for many -years. While MySQL is still in development, it already offers a rich -and highly useful function set. - -The MySQL-max version differs from the normal MySQL server distribution -in that the BDB and Innobase table handlers are enabled by default. -You can use any normal MySQL client with the MySQL-max server. - -See the documentation for more information. - -%description -l pt_BR -O MySQL é um servidor de banco de dados SQL realmente multiusuário e\ -multi-tarefa. A linguagem SQL é a mais popular linguagem para banco de\ -dados no mundo. O MySQL é uma implementação cliente/servidor que\ -consiste de um servidor chamado mysqld e diversos\ -programas/bibliotecas clientes. Os principais objetivos do MySQL são:\ -velocidade, robustez e facilidade de uso. O MySQL foi originalmente\ -desenvolvido porque nós na Tcx precisávamos de um servidor SQL que\ -pudesse lidar com grandes bases de dados e com uma velocidade muito\ -maior do que a que qualquer vendedor podia nos oferecer. Estamos\ -usando\ -o MySQL desde 1996 em um ambiente com mais de 40 bases de dados com 10.000\ -tabelas, das quais mais de 500 têm mais de 7 milhões de linhas. Isto é o\ -equivalente a aproximadamente 50G de dados críticos. A base da construção do\ -MySQL é uma série de rotinas que foram usadas em um ambiente de produção com\ -alta demanda por muitos anos. Mesmo o MySQL estando ainda em desenvolvimento,\ -ele já oferece um conjunto de funções muito ricas e úteis. Veja a documentação\ -para maiores informações. - -%prep -%setup -n mysql-max-%{mysql_version} -# %setup -T -D -a 1 -n mysql-max-%{mysql_version} - -%build -# The all-static flag is to make the RPM work on different -# distributions. This version tries to put shared mysqlclient libraries -# in a separate package. - -BuildMySQL() { -# The --enable-assembler simply does nothing on systems that does not -# support assembler speedups. -sh -c "PATH=\"${MYSQL_BUILD_PATH:-/bin:/usr/bin}\" \ - CC=\"${MYSQL_BUILD_CC:-egcs}\" \ - CFLAGS=\"${MYSQL_BUILD_CFLAGS:- -O6 -fno-omit-frame-pointer}\" \ - CXX=\"${MYSQL_BUILD_CXX:-egcs}\" \ - CXXFLAGS=\"${MYSQL_BUILD_CXXFLAGS:- -O6 \ - -felide-constructors -fno-exceptions -fno-rtti \ - -fno-omit-frame-pointer}\" \ - ./configure \ - $* \ - --enable-assembler \ - --with-mysqld-user=%{mysqld_user} \ - --with-unix-socket-path=/var/lib/mysql/mysql.sock \ - --prefix=/ \ - --with-extra-charsets=complex \ - --exec-prefix=/usr \ - --libexecdir=/usr/sbin \ - --sysconfdir=/etc \ - --datadir=/usr/share \ - --localstatedir=/var/lib/mysql \ - --infodir=/usr/info \ - --includedir=/usr/include \ - --mandir=/usr/man \ - --with-berkeley-db \ - --with-innodb \ - --with-comment=\"Official MySQL-Max RPM\"; - # Add this for more debugging support - # --with-debug - # Add this for MyISAM RAID support: - # --with-raid - " - make -} - -# Use the build root for temporary storage of the shared libraries. - -RBR=$RPM_BUILD_ROOT -MBD=$RPM_BUILD_DIR/mysql-max-%{mysql_version} -if test -z "$RBR" -o "$RBR" = "/" -then - echo "RPM_BUILD_ROOT has stupid value" - exit 1 -fi -rm -rf $RBR -mkdir -p $RBR - -#cd $MBD/db-%{db_version}/dist -#./configure --prefix=$RBR/usr/BDB -#make install -# -#echo $RBR $MBD -#cd $MBD - -BuildMySQL "--disable-shared" \ - "--with-mysqld-ldflags='-all-static'" \ - "--with-client-ldflags='-all-static'" - -%install -n mysql-max-%{mysql_version} -RBR=$RPM_BUILD_ROOT -MBD=$RPM_BUILD_DIR/mysql-max-%{mysql_version} -# Ensure that needed directories exists -install -d $RBR/etc/{logrotate.d,rc.d/init.d} -install -d $RBR/var/lib/mysql/mysql -install -d $RBR/usr/share/sql-bench -install -d $RBR/usr/share/mysql-test -install -d $RBR/usr/{sbin,share,man,include} -install -d $RBR/usr/doc/MySQL-%{mysql_version} -install -d $RBR/usr/lib -# Make install -make install DESTDIR=$RBR benchdir_root=/usr/share/ - -# Install logrotate and autostart -install -m644 $MBD/support-files/mysql-log-rotate $RBR/etc/logrotate.d/mysql -install -m755 $MBD/support-files/mysql.server $RBR/etc/rc.d/init.d/mysql - -# Install docs -install -m644 $RPM_BUILD_DIR/mysql-max-%{mysql_version}/Docs/mysql.info \ - $RBR/usr/info/mysql.info -for file in README COPYING COPYING.LIB Docs/manual_toc.html Docs/manual.html \ - Docs/manual.txt Docs/manual.texi Docs/manual.ps \ - support-files/my-huge.cnf support-files/my-large.cnf \ - support-files/my-medium.cnf support-files/my-small.cnf -do - b=`basename $file` - install -m644 $MBD/$file $RBR/usr/doc/MySQL-%{mysql_version}/$b -done - -%pre -if test -x /etc/rc.d/init.d/mysql -then - /etc/rc.d/init.d/mysql stop > /dev/null 2>&1 - echo "Giving mysqld a couple of seconds to exit nicely" - sleep 5 -fi - -%post -mysql_datadir=/var/lib/mysql - -# Create data directory if needed -if test ! -d $mysql_datadir; then mkdir $mysql_datadir; fi -if test ! -d $mysql_datadir/mysql; then mkdir $mysql_datadir/mysql; fi -if test ! -d $mysql_datadir/test; then mkdir $mysql_datadir/test; fi - -# Make MySQL start/shutdown automatically when the machine does it. -/sbin/chkconfig --add mysql - -# Create a MySQL user. Do not report any problems if it already -# exists. This is redhat specific and should be handled more portable -useradd -M -r -d $mysql_datadir -s /bin/bash -c "MySQL server" mysql 2> /dev/null || true - -# Change permissions so that the user that will run the MySQL daemon -# owns all database files. -chown -R mysql $mysql_datadir - -# Initiate databases -mysql_install_db -IN-RPM - -# Change permissions again to fix any new files. -chown -R mysql $mysql_datadir - -# Fix permissions for the permission database so that only the user -# can read them. -chmod -R og-rw $mysql_datadir/mysql - -# Restart in the same way that mysqld will be started normally. -/etc/rc.d/init.d/mysql start - -# Allow mysqld_safe to start mysqld and print a message before we exit -sleep 2 - -%preun -if test -x /etc/rc.d/init.d/mysql -then - /etc/rc.d/init.d/mysql stop > /dev/null -fi -# Remove autostart of mysql -if test $1 = 0 -then - /sbin/chkconfig --del mysql -fi -# We do not remove the mysql user since it may still own a lot of -# database files. - -%files -%attr(-, root, root) %doc /usr/doc/MySQL-%{mysql_version}/ - -%attr(755, root, root) /usr/bin/isamchk -%attr(755, root, root) /usr/bin/isamlog -%attr(755, root, root) /usr/bin/pack_isam -%attr(755, root, root) /usr/bin/myisamchk -%attr(755, root, root) /usr/bin/myisamlog -%attr(755, root, root) /usr/bin/myisampack -%attr(755, root, root) /usr/bin/mysql_fix_privilege_tables -%attr(755, root, root) /usr/bin/mysql_convert_table_format -%attr(755, root, root) /usr/bin/mysql_install_db -%attr(755, root, root) /usr/bin/mysql_setpermission -%attr(755, root, root) /usr/bin/mysql_zap -%attr(755, root, root) /usr/bin/mysqlbug -%attr(755, root, root) /usr/bin/mysqltest -%attr(755, root, root) /usr/bin/mysqlhotcopy -%attr(755, root, root) /usr/bin/perror -%attr(755, root, root) /usr/bin/replace -%attr(755, root, root) /usr/bin/resolveip -%attr(755, root, root) /usr/bin/mysqld_safe -%attr(755, root, root) /usr/bin/mysqld_multi -%attr(755, root, root) /usr/bin/my_print_defaults - -%attr(644, root, root) /usr/info/mysql.info* - -%attr(755, root, root) /usr/sbin/mysqld - -%attr(644, root, root) /etc/logrotate.d/mysql -%attr(755, root, root) /etc/rc.d/init.d/mysql - -%attr(755, root, root) /usr/share/mysql/ - -%changelog - -* Fri Apr 13 2001 Monty - First version of mysql-max.spec.sh based on mysql.spec.sh From 4a25417394f8b5975a43b0c4e7eab4970a5d1515 Mon Sep 17 00:00:00 2001 From: "ingo@mysql.com" <> Date: Wed, 1 Jun 2005 13:22:17 +0200 Subject: [PATCH 84/98] Bug#10224 - ANALYZE TABLE crashing with simultaneous CREATE ... SELECT statement. After merge fixes. --- sql/sql_base.cc | 2 +- sql/sql_parse.cc | 14 ++++++++++++-- sql/sql_yacc.yy | 9 +++++---- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 0c6f7837235..5719f77e3ef 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1384,7 +1384,7 @@ bool reopen_tables(THD *thd,bool get_locks,bool in_refresh) MYSQL_LOCK *lock; /* We should always get these locks */ thd->some_tables_deleted=0; - if ((lock= mysql_lock_tables(thd, tables, (uint) (tables_ptr-tables), 0))) + if ((lock= mysql_lock_tables(thd, tables, (uint) (tables_ptr - tables), 0))) { thd->locked_tables=mysql_lock_merge(thd->locked_tables,lock); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 18594568a7a..b1863953e1d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2808,7 +2808,7 @@ mysql_execute_command(THD *thd) unique_table(create_table, select_tables)) { my_error(ER_UPDATE_TABLE_USED, MYF(0), create_table->table_name); - goto unsent_create_error; + goto unsent_create_error1; } /* If we create merge table, we have to test tables in merge, too */ if (lex->create_info.used_fields & HA_CREATE_USED_UNION) @@ -2821,7 +2821,7 @@ mysql_execute_command(THD *thd) if (unique_table(tab, select_tables)) { my_error(ER_UPDATE_TABLE_USED, MYF(0), tab->table_name); - goto unsent_create_error; + goto unsent_create_error1; } } } @@ -2872,6 +2872,13 @@ mysql_execute_command(THD *thd) lex->link_first_table_back(create_table, link_to_local); break; +unsent_create_error1: + /* + Release the protection against the global read lock and wake + everyone, who might want to set a global read lock. + */ + start_waiting_global_read_lock(thd); + /* put tables back for PS rexecuting */ unsent_create_error: lex->link_first_table_back(create_table, link_to_local); @@ -6959,6 +6966,8 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, { /* Check permissions for used tables in CREATE TABLE ... SELECT */ +#ifdef NOT_NECESSARY_TO_CHECK_CREATE_TABLE_EXIST_WHEN_PREPARING_STATEMENT + /* This code throws an ill error for CREATE TABLE t1 SELECT * FROM t1 */ /* Only do the check for PS, becasue we on execute we have to check that against the opened tables to ensure we don't use a table that is part @@ -6977,6 +6986,7 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, goto err; } } +#endif if (tables && check_table_access(thd, SELECT_ACL, tables,0)) goto err; } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 27d73e9ad0a..9b608c30ec9 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7083,12 +7083,13 @@ field_ident: TABLE_LIST *table= (TABLE_LIST*) Select->table_list.first; if (my_strcasecmp(table_alias_charset, $1.str, table->db)) { - net_printf(YYTHD, ER_WRONG_DB_NAME, $1.str); + my_error(ER_WRONG_DB_NAME, MYF(0), $1.str); YYABORT; } - if (my_strcasecmp(table_alias_charset, $3.str, table->real_name)) + if (my_strcasecmp(table_alias_charset, $3.str, + table->table_name)) { - net_printf(YYTHD, ER_WRONG_TABLE_NAME, $3.str); + my_error(ER_WRONG_TABLE_NAME, MYF(0), $3.str); YYABORT; } $$=$5; @@ -7098,7 +7099,7 @@ field_ident: TABLE_LIST *table= (TABLE_LIST*) Select->table_list.first; if (my_strcasecmp(table_alias_charset, $1.str, table->alias)) { - net_printf(YYTHD, ER_WRONG_TABLE_NAME, $1.str); + my_error(ER_WRONG_TABLE_NAME, MYF(0), $1.str); YYABORT; } $$=$3; From b28a44e99980d082d808d377324564d28d7adc82 Mon Sep 17 00:00:00 2001 From: "ingo@mysql.com" <> Date: Wed, 1 Jun 2005 14:20:16 +0200 Subject: [PATCH 85/98] Bug#10602 - LOAD INDEX INTO CACHE deadlocks Fixed two deadlocks. Made minor changes. --- mysys/mf_keycache.c | 121 +++++++++++++++++++++++++++++++++----------- 1 file changed, 91 insertions(+), 30 deletions(-) diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index cee1b7eb4e9..f14af44dbb9 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -184,10 +184,18 @@ static void test_key_cache(KEY_CACHE *keycache, static FILE *keycache_debug_log=NULL; static void keycache_debug_print _VARARGS((const char *fmt,...)); #define KEYCACHE_DEBUG_OPEN \ - if (!keycache_debug_log) keycache_debug_log=fopen(KEYCACHE_DEBUG_LOG, "w") + if (!keycache_debug_log) \ + { \ + keycache_debug_log= fopen(KEYCACHE_DEBUG_LOG, "w"); \ + (void) setvbuf(keycache_debug_log, NULL, _IOLBF, BUFSIZ); \ + } #define KEYCACHE_DEBUG_CLOSE \ - if (keycache_debug_log) { fclose(keycache_debug_log); keycache_debug_log=0; } + if (keycache_debug_log) \ + { \ + fclose(keycache_debug_log); \ + keycache_debug_log= 0; \ + } #else #define KEYCACHE_DEBUG_OPEN #define KEYCACHE_DEBUG_CLOSE @@ -213,7 +221,7 @@ static long keycache_thread_id; #define KEYCACHE_THREAD_TRACE_BEGIN(l) \ { struct st_my_thread_var *thread_var= my_thread_var; \ - keycache_thread_id= my_thread_var->id; \ + keycache_thread_id= thread_var->id; \ KEYCACHE_DBUG_PRINT(l,("[thread %ld",keycache_thread_id)) } #define KEYCACHE_THREAD_TRACE_END(l) \ @@ -240,12 +248,10 @@ static int keycache_pthread_cond_wait(pthread_cond_t *cond, static int keycache_pthread_mutex_lock(pthread_mutex_t *mutex); static void keycache_pthread_mutex_unlock(pthread_mutex_t *mutex); static int keycache_pthread_cond_signal(pthread_cond_t *cond); -static int keycache_pthread_cond_broadcast(pthread_cond_t *cond); #else #define keycache_pthread_mutex_lock pthread_mutex_lock #define keycache_pthread_mutex_unlock pthread_mutex_unlock #define keycache_pthread_cond_signal pthread_cond_signal -#define keycache_pthread_cond_broadcast pthread_cond_broadcast #endif /* defined(KEYCACHE_DEBUG) */ static uint next_power(uint value) @@ -508,6 +514,8 @@ int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, keycache->can_be_used= 0; while (keycache->cnt_for_resize_op) { + KEYCACHE_DBUG_PRINT("resize_key_cache: wait", + ("suspend thread %ld", thread->id)); keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); } @@ -520,7 +528,11 @@ finish: unlink_from_queue(wqueue, thread); /* Signal for the next resize request to proceeed if any */ if (wqueue->last_thread) + { + KEYCACHE_DBUG_PRINT("resize_key_cache: signal", + ("thread %ld", wqueue->last_thread->next->id)); keycache_pthread_cond_signal(&wqueue->last_thread->next->suspend); + } keycache_pthread_mutex_unlock(&keycache->cache_lock); return blocks; } @@ -544,7 +556,11 @@ static inline void dec_counter_for_resize_op(KEY_CACHE *keycache) struct st_my_thread_var *last_thread; if (!--keycache->cnt_for_resize_op && (last_thread= keycache->resize_queue.last_thread)) + { + KEYCACHE_DBUG_PRINT("dec_counter_for_resize_op: signal", + ("thread %ld", last_thread->next->id)); keycache_pthread_cond_signal(&last_thread->next->suspend); + } } /* @@ -761,8 +777,8 @@ static void release_queue(KEYCACHE_WQUEUE *wqueue) do { thread=next; - keycache_pthread_cond_signal(&thread->suspend); KEYCACHE_DBUG_PRINT("release_queue: signal", ("thread %ld", thread->id)); + keycache_pthread_cond_signal(&thread->suspend); next=thread->next; thread->next= NULL; } @@ -876,7 +892,8 @@ static void link_block(KEY_CACHE *keycache, BLOCK_LINK *block, my_bool hot, BLOCK_LINK **pins; KEYCACHE_DBUG_ASSERT(! (block->hash_link && block->hash_link->requests)); - if (!hot && keycache->waiting_for_block.last_thread) { + if (!hot && keycache->waiting_for_block.last_thread) + { /* Signal that in the LRU warm sub-chain an available block has appeared */ struct st_my_thread_var *last_thread= keycache->waiting_for_block.last_thread; @@ -894,6 +911,7 @@ static void link_block(KEY_CACHE *keycache, BLOCK_LINK *block, my_bool hot, */ if ((HASH_LINK *) thread->opt_info == hash_link) { + KEYCACHE_DBUG_PRINT("link_block: signal", ("thread %ld", thread->id)); keycache_pthread_cond_signal(&thread->suspend); unlink_from_queue(&keycache->waiting_for_block, thread); block->requests++; @@ -1000,11 +1018,10 @@ static void reg_requests(KEY_CACHE *keycache, BLOCK_LINK *block, int count) linking it to the LRU chain if it's the last request SYNOPSIS - - unreg_block() - keycache pointer to a key cache data structure - block pointer to the block to link to the LRU chain - at_end <-> to link the block at the end of the LRU chain + unreg_request() + keycache pointer to a key cache data structure + block pointer to the block to link to the LRU chain + at_end <-> to link the block at the end of the LRU chain RETURN VALUE none @@ -1086,6 +1103,9 @@ static inline void wait_for_readers(KEY_CACHE *keycache, BLOCK_LINK *block) struct st_my_thread_var *thread= my_thread_var; while (block->hash_link->requests) { + KEYCACHE_DBUG_PRINT("wait_for_readers: wait", + ("suspend thread %ld block %u", + thread->id, BLOCK_NUMBER(block))); block->condvar= &thread->suspend; keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); block->condvar= NULL; @@ -1143,6 +1163,7 @@ static void unlink_hash(KEY_CACHE *keycache, HASH_LINK *hash_link) */ if (page->file == hash_link->file && page->filepos == hash_link->diskpos) { + KEYCACHE_DBUG_PRINT("unlink_hash: signal", ("thread %ld", thread->id)); keycache_pthread_cond_signal(&thread->suspend); unlink_from_queue(&keycache->waiting_for_hash_link, thread); } @@ -1225,6 +1246,8 @@ restart: page.filepos= filepos; thread->opt_info= (void *) &page; link_into_queue(&keycache->waiting_for_hash_link, thread); + KEYCACHE_DBUG_PRINT("get_hash_link: wait", + ("suspend thread %ld", thread->id)); keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); thread->opt_info= NULL; @@ -1343,6 +1366,8 @@ restart: add_to_queue(&block->wqueue[COND_FOR_SAVED], thread); do { + KEYCACHE_DBUG_PRINT("find_key_block: wait", + ("suspend thread %ld", thread->id)); keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); } @@ -1360,7 +1385,9 @@ restart: /* This is a request for a page to be removed from cache */ KEYCACHE_DBUG_PRINT("find_key_block", - ("request for old page in block %u",BLOCK_NUMBER(block))); + ("request for old page in block %u " + "wrmode: %d block->status: %d", + BLOCK_NUMBER(block), wrmode, block->status)); /* Only reading requests can proceed until the old dirty page is flushed, all others are to be suspended, then resubmitted @@ -1379,6 +1406,8 @@ restart: /* Wait until the request can be resubmitted */ do { + KEYCACHE_DBUG_PRINT("find_key_block: wait", + ("suspend thread %ld", thread->id)); keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); } @@ -1448,6 +1477,8 @@ restart: link_into_queue(&keycache->waiting_for_block, thread); do { + KEYCACHE_DBUG_PRINT("find_key_block: wait", + ("suspend thread %ld", thread->id)); keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); } @@ -1528,9 +1559,13 @@ restart: else { /* This is for secondary requests for a new page only */ - page_status= block->hash_link == hash_link && - (block->status & BLOCK_READ) ? - PAGE_READ : PAGE_WAIT_TO_BE_READ; + KEYCACHE_DBUG_PRINT("find_key_block", + ("block->hash_link: %p hash_link: %p " + "block->status: %u", block->hash_link, + hash_link, block->status )); + page_status= (((block->hash_link == hash_link) && + (block->status & BLOCK_READ)) ? + PAGE_READ : PAGE_WAIT_TO_BE_READ); } } keycache->global_cache_read++; @@ -1538,17 +1573,22 @@ restart: else { reg_requests(keycache, block, 1); - page_status = block->hash_link == hash_link && - (block->status & BLOCK_READ) ? - PAGE_READ : PAGE_WAIT_TO_BE_READ; + KEYCACHE_DBUG_PRINT("find_key_block", + ("block->hash_link: %p hash_link: %p " + "block->status: %u", block->hash_link, + hash_link, block->status )); + page_status= (((block->hash_link == hash_link) && + (block->status & BLOCK_READ)) ? + PAGE_READ : PAGE_WAIT_TO_BE_READ); } } KEYCACHE_DBUG_ASSERT(page_status != -1); *page_st=page_status; KEYCACHE_DBUG_PRINT("find_key_block", - ("fd: %u pos %lu page_status %lu", - (uint) file,(ulong) filepos,(uint) page_status)); + ("fd: %u pos %lu block->status %u page_status %lu", + (uint) file, (ulong) filepos, block->status, + (uint) page_status)); #if !defined(DBUG_OFF) && defined(EXTRA_DEBUG) DBUG_EXECUTE("check_keycache2", @@ -1604,6 +1644,10 @@ static void read_block(KEY_CACHE *keycache, /* Page is not in buffer yet, is to be read from disk */ keycache_pthread_mutex_unlock(&keycache->cache_lock); + /* + Here other threads may step in and register as secondary readers. + They will register in block->wqueue[COND_FOR_REQUESTED]. + */ got_length= my_pread(block->hash_link->file, block->buffer, read_length, block->hash_link->diskpos, MYF(0)); keycache_pthread_mutex_lock(&keycache->cache_lock); @@ -1634,6 +1678,8 @@ static void read_block(KEY_CACHE *keycache, add_to_queue(&block->wqueue[COND_FOR_REQUESTED], thread); do { + KEYCACHE_DBUG_PRINT("read_block: wait", + ("suspend thread %ld", thread->id)); keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); } @@ -1855,6 +1901,10 @@ int key_cache_insert(KEY_CACHE *keycache, /* The requested page is to be read into the block buffer */ #if !defined(SERIALIZED_READ_FROM_CACHE) keycache_pthread_mutex_unlock(&keycache->cache_lock); + /* + Here other threads may step in and register as secondary readers. + They will register in block->wqueue[COND_FOR_REQUESTED]. + */ #endif /* Copy data from buff */ @@ -1865,9 +1915,15 @@ int key_cache_insert(KEY_CACHE *keycache, #if !defined(SERIALIZED_READ_FROM_CACHE) keycache_pthread_mutex_lock(&keycache->cache_lock); + /* Here we are alone again. */ #endif block->status= BLOCK_READ; block->length= read_length+offset; + KEYCACHE_DBUG_PRINT("key_cache_insert", + ("primary request: new page in cache")); + /* Signal that all pending requests for this now can be processed. */ + if (block->wqueue[COND_FOR_REQUESTED].last_thread) + release_queue(&block->wqueue[COND_FOR_REQUESTED]); } remove_reader(block); @@ -2074,9 +2130,16 @@ static void free_block(KEY_CACHE *keycache, BLOCK_LINK *block) { KEYCACHE_THREAD_TRACE("free block"); KEYCACHE_DBUG_PRINT("free_block", - ("block %u to be freed",BLOCK_NUMBER(block))); + ("block %u to be freed, hash_link %p", + BLOCK_NUMBER(block), block->hash_link)); if (block->hash_link) { + /* + While waiting for readers to finish, new readers might request the + block. But since we set block->status|= BLOCK_REASSIGNED, they + will wait on block->wqueue[COND_FOR_SAVED]. They must be signalled + later. + */ block->status|= BLOCK_REASSIGNED; wait_for_readers(keycache, block); unlink_hash(keycache, block->hash_link); @@ -2102,6 +2165,10 @@ static void free_block(KEY_CACHE *keycache, BLOCK_LINK *block) keycache->free_block_list= block; /* Keep track of the number of currently unused blocks. */ keycache->blocks_unused++; + + /* All pending requests for this page must be resubmitted. */ + if (block->wqueue[COND_FOR_SAVED].last_thread) + release_queue(&block->wqueue[COND_FOR_SAVED]); } @@ -2334,6 +2401,8 @@ restart: add_to_queue(&block->wqueue[COND_FOR_SAVED], thread); do { + KEYCACHE_DBUG_PRINT("flush_key_blocks_int: wait", + ("suspend thread %ld", thread->id)); keycache_pthread_cond_wait(&thread->suspend, &keycache->cache_lock); } @@ -2685,14 +2754,6 @@ static int keycache_pthread_cond_signal(pthread_cond_t *cond) } -static int keycache_pthread_cond_broadcast(pthread_cond_t *cond) -{ - int rc; - KEYCACHE_THREAD_TRACE("signal"); - rc= pthread_cond_broadcast(cond); - return rc; -} - #if defined(KEYCACHE_DEBUG_LOG) From 5afef58364d444f0b222c6e01d785335c7301815 Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Wed, 1 Jun 2005 15:42:40 +0200 Subject: [PATCH 86/98] Fixed BUG#10969: Stored procedures: crash if default() function Return an error if default() is used on a local variable. This is actaully a side-effect of BUG#5967: Stored procedure declared variable used instead of column (to be fixed later), so this is really a workaround until that is fixed. --- mysql-test/r/sp-error.result | 13 +++++++++++++ mysql-test/t/sp-error.test | 23 +++++++++++++++++++++++ sql/item.h | 7 +++++++ sql/sql_yacc.yy | 13 ++++++++++++- 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index ccdb46f10d0..1dc97124a07 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -658,4 +658,17 @@ create procedure bug9529_9012345678901234567890123456789012345678901234567890123 begin end| ERROR 42000: Identifier name 'bug9529_90123456789012345678901234567890123456789012345678901234567890' is too long +drop procedure if exists bug10969| +create procedure bug10969() +begin +declare s1 int default 0; +select default(s1) from t30; +end| +ERROR 42000: Incorrect column name 's1' +create procedure bug10969() +begin +declare s1 int default 0; +select default(t30.s1) from t30; +end| +drop procedure bug10969| drop table t1| diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index a2a43110b54..891e282e335 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -930,6 +930,29 @@ begin end| +# +# BUG#10969: Stored procedures: crash if default() function +# +--disable_warnings +drop procedure if exists bug10969| +--enable_warnings +--error ER_WRONG_COLUMN_NAME +create procedure bug10969() +begin + declare s1 int default 0; + select default(s1) from t30; +end| + +# This should work +create procedure bug10969() +begin + declare s1 int default 0; + select default(t30.s1) from t30; +end| + +drop procedure bug10969| + + # # BUG#NNNN: New bug synopsis # diff --git a/sql/item.h b/sql/item.h index 18b419dd6d5..f2e8e582780 100644 --- a/sql/item.h +++ b/sql/item.h @@ -584,6 +584,13 @@ public: Item::maybe_null= TRUE; } + /* For error printing */ + inline void my_name(char **strp, uint *lengthp) + { + *strp= m_name.str; + *lengthp= m_name.length; + } + bool is_splocal() { return 1; } /* Needed for error checking */ Item *this_item(); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 708dcb7a0d9..861216ebc96 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4343,7 +4343,18 @@ simple_expr: | CONVERT_SYM '(' expr USING charset_name ')' { $$= new Item_func_conv_charset($3,$5); } | DEFAULT '(' simple_ident ')' - { $$= new Item_default_value($3); } + { + if ($3->is_splocal()) + { + LEX_STRING name; + Item_splocal *il= static_cast($3); + + il->my_name(&name.str, &name.length); + my_error(ER_WRONG_COLUMN_NAME, MYF(0), name.str); + YYABORT; + } + $$= new Item_default_value($3); + } | VALUES '(' simple_ident ')' { $$= new Item_insert_value($3); } | FUNC_ARG0 '(' ')' From 5b54fcab6ad8e1b0cb154c69d653eb33f8af2f4d Mon Sep 17 00:00:00 2001 From: "mronstrom@mysql.com" <> Date: Wed, 1 Jun 2005 17:36:21 +0200 Subject: [PATCH 87/98] Renamed bugs.test to default.test Moved enabling of warnings to ensure that no warnings are generated when this test case is executed on a clone where InnoDB is not activated. This would fail the test case in those clones otherwise. --- mysql-test/r/{bugs.result => default.result} | 0 mysql-test/t/{bugs.test => default.test} | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename mysql-test/r/{bugs.result => default.result} (100%) rename mysql-test/t/{bugs.test => default.test} (100%) diff --git a/mysql-test/r/bugs.result b/mysql-test/r/default.result similarity index 100% rename from mysql-test/r/bugs.result rename to mysql-test/r/default.result diff --git a/mysql-test/t/bugs.test b/mysql-test/t/default.test similarity index 100% rename from mysql-test/t/bugs.test rename to mysql-test/t/default.test index 3b842c06561..42620a27b66 100644 --- a/mysql-test/t/bugs.test +++ b/mysql-test/t/default.test @@ -4,7 +4,6 @@ --disable_warnings drop table if exists t1,t2,t3,t4,t5,t6; drop database if exists mysqltest; ---enable_warnings # # Bug 10838 @@ -39,6 +38,7 @@ CREATE TABLE t1 (a varchar(30) binary NOT NULL DEFAULT ' ', a1 varchar(30) binary NOT NULL DEFAULT ' ', b1 tinyblob NULL) ENGINE=InnoDB DEFAULT CHARACTER SET = latin1 COLLATE latin1_bin; +--enable_warnings SHOW CREATE TABLE t1; INSERT into t1 (b) values ('1'); From 7ac7bfc3c8aa16055ea92d102ea07733bcb999ea Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Wed, 1 Jun 2005 09:48:25 -0700 Subject: [PATCH 88/98] Fix handling of NULL fields in FIELD(). (Bug #10944) --- mysql-test/r/func_str.result | 6 ++++++ mysql-test/t/func_str.test | 6 ++++++ sql/item_func.cc | 12 ++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 5405dbf53d9..ea1efbc7c0a 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -783,3 +783,9 @@ id aes_decrypt(str, 'bar') 1 foo 2 NULL DROP TABLE t1, t2; +select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0); +field(0,NULL,1,0) field("",NULL,"bar","") field(0.0,NULL,1.0,0.0) +3 3 3 +select field(NULL,1,2,NULL), field(NULL,1,2,0); +field(NULL,1,2,NULL) field(NULL,1,2,0) +0 0 diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 22028437111..a5536f7a0be 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -521,3 +521,9 @@ SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id DROP TABLE t1, t2; + +# +# Bug #10944: Mishandling of NULL arguments in FIELD() +# +select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0); +select field(NULL,1,2,NULL), field(NULL,1,2,0); diff --git a/sql/item_func.cc b/sql/item_func.cc index 3c50e750b41..1300dc6faac 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1488,6 +1488,10 @@ void Item_func_locate::print(String *str) longlong Item_func_field::val_int() { DBUG_ASSERT(fixed == 1); + + if (args[0]->null_value) + return 0; + if (cmp_type == STRING_RESULT) { String *field; @@ -1505,8 +1509,8 @@ longlong Item_func_field::val_int() longlong val= args[0]->val_int(); for (uint i=1; i < arg_count ; i++) { - if (val == args[i]->val_int()) - return (longlong) (i); + if (!args[i]->null_value && val == args[i]->val_int()) + return (longlong) (i); } } else @@ -1514,8 +1518,8 @@ longlong Item_func_field::val_int() double val= args[0]->val(); for (uint i=1; i < arg_count ; i++) { - if (val == args[i]->val()) - return (longlong) (i); + if (!args[i]->null_value && val == args[i]->val()) + return (longlong) (i); } } return 0; From fb51d6eca585af2e940c103f88f035300e399be5 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Wed, 1 Jun 2005 14:35:02 -0700 Subject: [PATCH 89/98] Update results of test after merge of bugfix --- mysql-test/r/rpl_failed_optimize.result | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/r/rpl_failed_optimize.result b/mysql-test/r/rpl_failed_optimize.result index 1576ec60500..120bb53ed25 100644 --- a/mysql-test/r/rpl_failed_optimize.result +++ b/mysql-test/r/rpl_failed_optimize.result @@ -9,6 +9,7 @@ BEGIN; INSERT INTO t1 VALUES (1); OPTIMIZE TABLE t1; Table Op Msg_type Msg_text +test.t1 optimize error Lock wait timeout exceeded; try restarting transaction test.t1 optimize status Operation failed OPTIMIZE TABLE non_existing; Table Op Msg_type Msg_text From f5f88703b2899bb67b63844ec88041476d73fa6d Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Wed, 1 Jun 2005 16:03:41 -0700 Subject: [PATCH 90/98] Fix compile error when HAVE_BERKELEY_DB --- sql/sql_table.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f277bc50462..7e80a71beb0 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3451,7 +3451,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, shutdown. */ char path[FN_REFLEN]; - build_table_path(path, sizeof(path), new_db, table_name); + build_table_path(path, sizeof(path), new_db, table_name, ""); table=open_temporary_table(thd, path, new_db, tmp_name,0); if (table) { From a60bdadb316dbcbcc6cd24367fd0db201664b9ca Mon Sep 17 00:00:00 2001 From: "tomas@poseidon.ndb.mysql.com" <> Date: Thu, 2 Jun 2005 01:13:23 +0200 Subject: [PATCH 91/98] Bug #11019 mgmapi start backup in some cases returns wrong backupid --- ndb/include/mgmapi/mgmapi.h | 2 ++ ndb/src/mgmsrv/Services.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ndb/include/mgmapi/mgmapi.h b/ndb/include/mgmapi/mgmapi.h index dca88e4950e..018e554de7c 100644 --- a/ndb/include/mgmapi/mgmapi.h +++ b/ndb/include/mgmapi/mgmapi.h @@ -915,6 +915,8 @@ extern "C" { * @param backup_id Backup ID is returned from function. * @param reply Reply message. * @return -1 on error. + * @note backup_id will not be returned if + * wait_completed == 0 */ int ndb_mgm_start_backup(NdbMgmHandle handle, int wait_completed, unsigned int* backup_id, diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp index bbd3db1e734..1a5101702a0 100644 --- a/ndb/src/mgmsrv/Services.cpp +++ b/ndb/src/mgmsrv/Services.cpp @@ -671,7 +671,8 @@ MgmApiSession::startBackup(Parser::Context &, } else{ m_output->println("result: Ok"); - m_output->println("id: %d", backupId); + if (completed) + m_output->println("id: %d", backupId); } m_output->println(""); DBUG_VOID_RETURN; From ed18369236539567856a193ea96b660838544ef2 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Wed, 1 Jun 2005 16:16:25 -0700 Subject: [PATCH 92/98] Fix --with-bdb to be --with-berkeley-db in BUILD/SETUP.sh --- BUILD/SETUP.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index 8bb281f20e9..3f8a9ccaf22 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -48,8 +48,8 @@ global_warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wch c_warnings="$global_warnings -Wunused" cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor" -base_max_configs="--with-innodb --with-bdb --with-ndbcluster --with-archive-storage-engine --with-raid --with-openssl --with-raid --with-vio" -max_leave_isam_configs="--with-innodb --with-bdb --with-ndbcluster --with-archive-storage-engine --with-raid --with-openssl --with-raid --with-vio --with-embedded-server" +base_max_configs="--with-innodb --with-berkeley-db --with-ndbcluster --with-archive-storage-engine --with-raid --with-openssl --with-raid --with-vio" +max_leave_isam_configs="--with-innodb --with-berkeley-db --with-ndbcluster --with-archive-storage-engine --with-raid --with-openssl --with-raid --with-vio --with-embedded-server" max_no_es_configs="$max_leave_isam_configs --without-isam" max_configs="$max_no_es_configs --with-embedded-server" From ba9b9f8993ac8d0fa8fc5abdaa670f9eaa548824 Mon Sep 17 00:00:00 2001 From: "brian@zim.(none)" <> Date: Wed, 1 Jun 2005 17:34:10 -0700 Subject: [PATCH 93/98] Mainly cleanups for gcc 4.0. Some small pieces from looking at -Wall. Removed a number of dumb things in ha_tina. --- client/mysqladmin.cc | 2 +- sql/examples/ha_archive.cc | 7 +++---- sql/examples/ha_example.cc | 4 +--- sql/examples/ha_tina.cc | 37 ++++++++++++------------------------- sql/ha_heap.cc | 1 - sql/item_subselect.cc | 3 --- sql/mysqld.cc | 8 +------- sql/opt_range.h | 2 +- sql/repl_failsafe.cc | 2 +- sql/slave.cc | 2 +- sql/sql_acl.cc | 10 +++++----- sql/sql_insert.cc | 2 +- sql/sql_parse.cc | 2 -- sql/sql_repl.cc | 1 - sql/sql_select.cc | 4 ++-- 15 files changed, 29 insertions(+), 58 deletions(-) diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 0da7d5b3acf..5a4690ea30e 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -271,7 +271,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), option_wait=1; } else - option_wait= ~0; + option_wait= ~(uint)0; break; case '?': case 'I': /* Info */ diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index bc4af0c7dc7..918d85d705d 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -575,7 +575,7 @@ int ha_archive::write_row(byte * buf) written= gzwrite(share->archive_write, buf, table->reclength); DBUG_PRINT("ha_archive::get_row", ("Wrote %d bytes expected %d", written, table->reclength)); share->dirty= TRUE; - if (written != table->reclength) + if (written != (z_off_t)table->reclength) goto error; /* We should probably mark the table as damagaged if the record is written @@ -590,7 +590,7 @@ int ha_archive::write_row(byte * buf) { (*field)->get_ptr(&ptr); written= gzwrite(share->archive_write, ptr, (unsigned)size); - if (written != size) + if (written != (z_off_t)size) goto error; } } @@ -613,7 +613,6 @@ error: int ha_archive::rnd_init(bool scan) { DBUG_ENTER("ha_archive::rnd_init"); - int read; // gzread() returns int, and we use this to check the header /* We rewind the file so that we can read from the beginning if scan */ if (scan) @@ -747,7 +746,7 @@ int ha_archive::rnd_pos(byte * buf, byte *pos) DBUG_ENTER("ha_archive::rnd_pos"); statistic_increment(ha_read_rnd_count,&LOCK_status); current_position= ha_get_ptr(pos, ref_length); - z_off_t seek= gzseek(archive, current_position, SEEK_SET); + (void)gzseek(archive, current_position, SEEK_SET); DBUG_RETURN(get_row(archive, buf)); } diff --git a/sql/examples/ha_example.cc b/sql/examples/ha_example.cc index cb0780ea74d..35034fc7b28 100644 --- a/sql/examples/ha_example.cc +++ b/sql/examples/ha_example.cc @@ -150,10 +150,8 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table) return share; -error2: - thr_lock_delete(&share->lock); - pthread_mutex_destroy(&share->mutex); error: + pthread_mutex_destroy(&share->mutex); pthread_mutex_unlock(&example_mutex); my_free((gptr) share, MYF(0)); diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc index 0345a170c3c..637ecde8f81 100644 --- a/sql/examples/ha_tina.cc +++ b/sql/examples/ha_tina.cc @@ -20,10 +20,10 @@ First off, this is a play thing for me, there are a number of things wrong with it: *) It was designed for csv and therefor its performance is highly questionable. *) Indexes have not been implemented. This is because the files can be traded in - and out of the table directory without having to worry about rebuilding anything. + and out of the table directory without having to worry about rebuilding anything. *) NULLs and "" are treated equally (like a spreadsheet). *) There was in the beginning no point to anyone seeing this other then me, so there - is a good chance that I haven't quite documented it well. + is a good chance that I haven't quite documented it well. *) Less design, more "make it work" Now there are a few cool things with it: @@ -89,12 +89,12 @@ int get_mmap(TINA_SHARE *share, int write) { if (write) share->mapped_file= (byte *)mmap(NULL, share->file_stat.st_size, - PROT_READ|PROT_WRITE, MAP_SHARED, - share->data_file, 0); + PROT_READ|PROT_WRITE, MAP_SHARED, + share->data_file, 0); else share->mapped_file= (byte *)mmap(NULL, share->file_stat.st_size, - PROT_READ, MAP_PRIVATE, - share->data_file, 0); + PROT_READ, MAP_PRIVATE, + share->data_file, 0); if ((share->mapped_file ==(caddr_t)-1)) { /* @@ -144,9 +144,9 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table) { char data_file_name[FN_REFLEN]; if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), - &share, sizeof(*share), - &tmp_name, length+1, - NullS)) + &share, sizeof(*share), + &tmp_name, length+1, + NullS)) { pthread_mutex_unlock(&tina_mutex); return NULL; @@ -341,7 +341,6 @@ int ha_tina::find_current_row(byte *buf) for (Field **field=table->field ; *field ; field++) { - int x; buffer.length(0); mapped_ptr++; // Increment past the first quote for(;mapped_ptr != end_ptr; mapped_ptr++) @@ -735,29 +734,17 @@ int ha_tina::rnd_end() beginning so that we move the smallest amount of data possible. */ qsort(chain, (size_t)(chain_ptr - chain), sizeof(tina_set), (qsort_cmp)sort_set); - for (ptr= chain; ptr < chain_ptr; ptr++) - printf("Chain %d, %d\n", (int)ptr->begin, (int)ptr->end); for (ptr= chain; ptr < chain_ptr; ptr++) { - //memmove(share->mapped_file + ptr->begin, share->mapped_file - //+ ptr->end, length - (size_t)ptr->end); /* We peek a head to see if this is the last chain */ - printf("Delete %d, %d, %d\n", (int)ptr->begin, (int)ptr->end, (int)length); if (ptr+1 == chain_ptr) - { - printf("Shiftina(end) %d(%d) to %d\n", (int)ptr->end, (int)(length - (size_t)ptr->end), (int)ptr->begin); memmove(share->mapped_file + ptr->begin, share->mapped_file + ptr->end, length - (size_t)ptr->end); - } else - { - printf("Shifting %d(%d) to %d\n", (int)ptr->end, (int)((ptr++)->begin - (size_t)ptr->end), (int)ptr->begin); - memmove(share->mapped_file + ptr->begin, share->mapped_file + ptr->end, - (size_t)(ptr++)->begin - (size_t)ptr->end); - } + memmove((caddr_t)share->mapped_file + ptr->begin, (caddr_t)share->mapped_file + ptr->end, + (size_t)((ptr++)->begin - ptr->end)); length= length - (size_t)(ptr->end - ptr->begin); } - printf("Buffer %s\n",share->mapped_file); /* Truncate the file to the new size */ if (my_chsize(share->data_file, length, 0, MYF(MY_WME))) @@ -840,7 +827,7 @@ int ha_tina::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_i DBUG_ENTER("ha_tina::create"); if ((create_file= my_create(fn_format(name_buff,name,"",".CSV",MY_REPLACE_EXT|MY_UNPACK_FILENAME),0, - O_RDWR | O_TRUNC,MYF(MY_WME))) < 0) + O_RDWR | O_TRUNC,MYF(MY_WME))) < 0) DBUG_RETURN(-1); my_close(create_file,MYF(0)); diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index 033fe86720e..d8e4b3d5a9f 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -484,7 +484,6 @@ int ha_heap::create(const char *name, TABLE *table_arg, for (; key_part != key_part_end; key_part++, seg++) { - uint flag= key_part->key_type; Field *field= key_part->field; if (pos->algorithm == HA_KEY_ALG_BTREE) seg->type= field->key_type(); diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 301740c50ef..23477481472 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -379,9 +379,6 @@ Item_singlerow_subselect::select_transformer(JOIN *join) return RES_REDUCE; } return RES_OK; - -err: - return RES_ERROR; } void Item_singlerow_subselect::store(uint i, Item *item) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8ade81401aa..5e3142ccf0e 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3355,7 +3355,7 @@ static int bootstrap(FILE *file) thd->client_capabilities=0; my_net_init(&thd->net,(st_vio*) 0); thd->max_client_packet_length= thd->net.max_packet; - thd->master_access= ~0; + thd->master_access= ~(ulong)0; thd->thread_id=thread_id++; thread_count++; @@ -5574,12 +5574,6 @@ static void print_version(void) server_version,SYSTEM_TYPE,MACHINE_TYPE, MYSQL_COMPILATION_COMMENT); } -static void use_help(void) -{ - print_version(); - printf("Use '--help' or '--no-defaults --help' for a list of available options\n"); -} - static void usage(void) { if (!(default_charset_info= get_charset_by_csname(default_character_set_name, diff --git a/sql/opt_range.h b/sql/opt_range.h index edecdcc6282..b55bb4708bf 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -143,7 +143,7 @@ class SQL_SELECT :public Sql_alloc { ~SQL_SELECT(); void cleanup(); bool check_quick(THD *thd, bool force_quick_range, ha_rows limit) - { return test_quick_select(thd, key_map(~0), 0, limit, force_quick_range) < 0; } + { return test_quick_select(thd, key_map(~(uint)0), 0, limit, force_quick_range) < 0; } inline bool skip_record() { return cond ? cond->val_int() == 0 : 0; } int test_quick_select(THD *thd, key_map keys, table_map prev_tables, ha_rows limit, bool force_quick_range=0); diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 85a51ba9b51..2d8e8a5bf81 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -71,7 +71,7 @@ static int init_failsafe_rpl_thread(THD* thd) my_net_init(&thd->net, 0); thd->net.read_timeout = slave_net_timeout; thd->max_client_packet_length=thd->net.max_packet; - thd->master_access= ~0; + thd->master_access= ~(ulong)0; thd->priv_user = 0; pthread_mutex_lock(&LOCK_thread_count); thd->thread_id = thread_id++; diff --git a/sql/slave.cc b/sql/slave.cc index 605f8289946..5a2d3af3845 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2577,7 +2577,7 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) thd->client_capabilities = 0; my_net_init(&thd->net, 0); thd->net.read_timeout = slave_net_timeout; - thd->master_access= ~0; + thd->master_access= ~(ulong)0; thd->priv_user = 0; thd->slave_thread = 1; /* diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 02da05d195f..84259b146ad 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1002,7 +1002,7 @@ static void acl_insert_db(const char *user, const char *host, const char *db, ulong acl_get(const char *host, const char *ip, const char *user, const char *db, my_bool db_is_pattern) { - ulong host_access= ~0,db_access= 0; + ulong host_access= ~(ulong)0,db_access= 0; uint i,key_length; char key[ACL_KEY_LENGTH],*tmp_db,*end; acl_entry *entry; @@ -3673,7 +3673,7 @@ int mysql_revoke_all(THD *thd, List &list) } if (replace_user_table(thd, tables[0].table, - *lex_user, ~0, 1, 0)) + *lex_user, ~(ulong)0, 1, 0)) { result= -1; continue; @@ -3700,7 +3700,7 @@ int mysql_revoke_all(THD *thd, List &list) if (!strcmp(lex_user->user.str,user) && !my_strcasecmp(system_charset_info, lex_user->host.str, host)) { - if (!replace_db_table(tables[1].table, acl_db->db, *lex_user, ~0, 1)) + if (!replace_db_table(tables[1].table, acl_db->db, *lex_user, ~(ulong)0, 1)) { /* Don't increment counter as replace_db_table deleted the @@ -3734,7 +3734,7 @@ int mysql_revoke_all(THD *thd, List &list) if (replace_table_table(thd,grant_table,tables[2].table,*lex_user, grant_table->db, grant_table->tname, - ~0, 0, 1)) + ~(ulong)0, 0, 1)) { result= -1; } @@ -3750,7 +3750,7 @@ int mysql_revoke_all(THD *thd, List &list) columns, grant_table->db, grant_table->tname, - ~0, 1)) + ~(ulong)0, 1)) { revoked= 1; continue; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 0258f2c3e07..1d7914c9c76 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1431,7 +1431,7 @@ bool delayed_insert::handle_inserts(void) if (thd.killed || table->version != refresh_version) { thd.killed=1; - max_rows= ~0; // Do as much as possible + max_rows= ~(uint)0; // Do as much as possible } /* diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 80c68dad247..0d67c25cee5 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -561,7 +561,6 @@ bool is_update_query(enum enum_sql_command command) static void time_out_user_resource_limits(THD *thd, USER_CONN *uc) { - bool error= 0; time_t check_time = thd->start_time ? thd->start_time : time(NULL); DBUG_ENTER("time_out_user_resource_limits"); @@ -587,7 +586,6 @@ static bool check_mqh(THD *thd, uint check_command) { #ifndef NO_EMBEDDED_ACCESS_CHECKS bool error= 0; - time_t check_time = thd->start_time ? thd->start_time : time(NULL); USER_CONN *uc=thd->user_connect; DBUG_ENTER("check_mqh"); DBUG_ASSERT(uc != 0); diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 24b78bc9a3d..310c2ea03cd 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1341,7 +1341,6 @@ int show_binlogs(THD* thd) IO_CACHE log; File file; const char *errmsg= 0; - MY_STAT stat_area; char fname[FN_REFLEN]; List field_list; uint length; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index fb7f10abb52..d53609ceaa5 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -34,7 +34,7 @@ const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref", }; const key_map key_map_empty(0); -const key_map key_map_full(~0); +const key_map key_map_full(~(uint)0); static void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array); static bool make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds, @@ -3450,7 +3450,7 @@ make_simple_join(JOIN *join,TABLE *tmp_table) join_tab->select_cond=0; join_tab->quick=0; join_tab->type= JT_ALL; /* Map through all records */ - join_tab->keys.init(~0); /* test everything in quick */ + join_tab->keys.init(~(uint)0); /* test everything in quick */ join_tab->info=0; join_tab->on_expr=0; join_tab->ref.key = -1; From bd48eed988f80005ea0f857e7b048cfade98f1c1 Mon Sep 17 00:00:00 2001 From: "kent@mysql.com" <> Date: Thu, 2 Jun 2005 02:43:32 +0200 Subject: [PATCH 94/98] tztime.cc: Set #pragma implementation" earlier Many files: Need to include before #ifdef USE_PRAGMA_IMPLEMENTATION --- client/sql_string.cc | 3 ++- mysys/raid.cc | 2 ++ sql/examples/ha_archive.cc | 4 +++- sql/examples/ha_example.cc | 4 +++- sql/examples/ha_tina.cc | 4 +++- sql/field.cc | 2 ++ sql/ha_berkeley.cc | 2 ++ sql/ha_blackhole.cc | 2 ++ sql/ha_heap.cc | 2 ++ sql/ha_innodb.cc | 2 ++ sql/ha_isam.cc | 2 ++ sql/ha_isammrg.cc | 2 ++ sql/ha_myisam.cc | 2 ++ sql/ha_myisammrg.cc | 2 ++ sql/ha_ndbcluster.cc | 2 ++ sql/handler.cc | 2 ++ sql/hash_filo.cc | 2 ++ sql/item.cc | 2 ++ sql/item_cmpfunc.cc | 2 ++ sql/item_func.cc | 2 ++ sql/item_geofunc.cc | 2 ++ sql/item_strfunc.cc | 2 ++ sql/item_subselect.cc | 2 ++ sql/item_sum.cc | 2 ++ sql/item_timefunc.cc | 2 ++ sql/item_uniq.cc | 3 +++ sql/log_event.cc | 3 +++ sql/opt_range.cc | 2 ++ sql/procedure.cc | 2 ++ sql/protocol.cc | 2 ++ sql/protocol_cursor.cc | 2 ++ sql/set_var.cc | 2 ++ sql/sql_analyse.cc | 2 ++ sql/sql_class.cc | 2 ++ sql/sql_crypt.cc | 2 ++ sql/sql_list.cc | 2 ++ sql/sql_map.cc | 2 ++ sql/sql_olap.cc | 2 ++ sql/sql_select.cc | 2 ++ sql/sql_string.cc | 3 ++- sql/sql_udf.cc | 2 ++ sql/tztime.cc | 12 +++++++----- 42 files changed, 94 insertions(+), 10 deletions(-) diff --git a/client/sql_string.cc b/client/sql_string.cc index 690997152f1..8f0e46c5eea 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -16,11 +16,12 @@ /* This file is originally from the mysql distribution. Coded by monty */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif -#include #include #include #include diff --git a/mysys/raid.cc b/mysys/raid.cc index 62587c438ca..20e70d2d102 100644 --- a/mysys/raid.cc +++ b/mysys/raid.cc @@ -70,6 +70,8 @@ tonu@mysql.com & monty@mysql.com */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index bc4af0c7dc7..51268fd60b3 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -14,7 +14,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/examples/ha_example.cc b/sql/examples/ha_example.cc index cb0780ea74d..b122c4dc83f 100644 --- a/sql/examples/ha_example.cc +++ b/sql/examples/ha_example.cc @@ -63,7 +63,9 @@ -Brian */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc index 0345a170c3c..44040ad3b61 100644 --- a/sql/examples/ha_tina.cc +++ b/sql/examples/ha_tina.cc @@ -38,7 +38,9 @@ TODO: -Brian */ -#ifdef __GNUC__ +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/field.cc b/sql/field.cc index adb0368384e..60287d4003b 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -19,6 +19,8 @@ ** This file implements classes defined in field.h *****************************************************************************/ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 05cad23b176..d4adea4a7b4 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -47,6 +47,8 @@ */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_blackhole.cc b/sql/ha_blackhole.cc index 59b3f7102b5..a5456d54c1b 100644 --- a/sql/ha_blackhole.cc +++ b/sql/ha_blackhole.cc @@ -15,6 +15,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index d584c33f061..83f5203324f 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -15,6 +15,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 3f2e11e8bd1..b3b82df5469 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -28,6 +28,8 @@ have disables the InnoDB inlining in this file. */ in Windows? */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_isam.cc b/sql/ha_isam.cc index 31e9236460f..b755c63698f 100644 --- a/sql/ha_isam.cc +++ b/sql/ha_isam.cc @@ -15,6 +15,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_isammrg.cc b/sql/ha_isammrg.cc index c0e6f665f08..7e14ccb43bf 100644 --- a/sql/ha_isammrg.cc +++ b/sql/ha_isammrg.cc @@ -15,6 +15,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index d8608c6a599..b4ac8cc777f 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -15,6 +15,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index edb3521470f..3374ee1271a 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -15,6 +15,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index eaa0473df1b..516703112dd 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -20,6 +20,8 @@ NDB Cluster */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/handler.cc b/sql/handler.cc index f14564b6629..d47bb02a58c 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -17,6 +17,8 @@ /* Handler-calling-functions */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/hash_filo.cc b/sql/hash_filo.cc index ec200768222..34f3cd6b035 100644 --- a/sql/hash_filo.cc +++ b/sql/hash_filo.cc @@ -20,6 +20,8 @@ ** to usage. */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item.cc b/sql/item.cc index bff8c1cace6..d32a6581049 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -15,6 +15,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 337ac949d35..f53dcb43e5c 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -17,6 +17,8 @@ /* This file defines all compare functions */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_func.cc b/sql/item_func.cc index 3c50e750b41..e9339877ab7 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -17,6 +17,8 @@ /* This file defines all numerical functions */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index c58a9e434c7..e907c5a0d45 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -17,6 +17,8 @@ /* This file defines all spatial functions */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 5ca5caf6bdf..725712f4e85 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -20,6 +20,8 @@ ** (This shouldn't be needed) */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 2e4c70ecd5f..553b309cfde 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -22,6 +22,8 @@ SUBSELECT TODO: (sql_select.h/sql_select.cc) */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 0e252259f53..9c35fb1d427 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -17,6 +17,8 @@ /* Sum functions (COUNT, MIN...) */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index a3cf69035f3..9f5cd61f95a 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -17,6 +17,8 @@ /* This file defines all time functions */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_uniq.cc b/sql/item_uniq.cc index 0c757c0e3a3..c83373bd8b0 100644 --- a/sql/item_uniq.cc +++ b/sql/item_uniq.cc @@ -15,6 +15,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* Compability file */ + +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation #endif diff --git a/sql/log_event.cc b/sql/log_event.cc index f2287857d37..9701ef2ff00 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -16,6 +16,9 @@ #ifndef MYSQL_CLIENT + +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/opt_range.cc b/sql/opt_range.cc index bd1befb436f..7b37f0ce4f7 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -23,6 +23,8 @@ */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/procedure.cc b/sql/procedure.cc index a0042dd879e..10689dd36f6 100644 --- a/sql/procedure.cc +++ b/sql/procedure.cc @@ -17,6 +17,8 @@ /* Procedures (functions with changes output of select) */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/protocol.cc b/sql/protocol.cc index 6a17ae2f95b..835bd986fb8 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -19,6 +19,8 @@ The actual communction is handled by the net_xxx functions in net_serv.cc */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc index b225e06ed32..53a03001544 100644 --- a/sql/protocol_cursor.cc +++ b/sql/protocol_cursor.cc @@ -19,6 +19,8 @@ The actual communction is handled by the net_xxx functions in net_serv.cc */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/set_var.cc b/sql/set_var.cc index 3d3ba6d6ab7..b006dde2b4b 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -48,6 +48,8 @@ new attribute. */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index fb5d0eb0a3f..678bdbb4588 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -23,6 +23,8 @@ ** - type set is out of optimization yet */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 805db107370..ff45b164893 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -22,6 +22,8 @@ ** *****************************************************************************/ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_crypt.cc b/sql/sql_crypt.cc index f21a109e95d..eda7f0f6bbb 100644 --- a/sql/sql_crypt.cc +++ b/sql/sql_crypt.cc @@ -23,6 +23,8 @@ needs something like 'ssh'. */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_list.cc b/sql/sql_list.cc index d57a7dfe4e3..485c569f49c 100644 --- a/sql/sql_list.cc +++ b/sql/sql_list.cc @@ -15,6 +15,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_map.cc b/sql/sql_map.cc index aac44949d89..9baacd1bc4b 100644 --- a/sql/sql_map.cc +++ b/sql/sql_map.cc @@ -15,6 +15,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc index 024abb6c74b..a365cbb0614 100644 --- a/sql/sql_olap.cc +++ b/sql/sql_olap.cc @@ -28,6 +28,8 @@ #ifdef DISABLED_UNTIL_REWRITTEN_IN_4_1 +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0362f097cba..1d42fe49283 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -17,6 +17,8 @@ /* mysql_select and join optimization */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_string.cc b/sql/sql_string.cc index ab2db4aaf53..e5339782f02 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -16,11 +16,12 @@ /* This file is originally from the mysql distribution. Coded by monty */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif -#include #include #include #include diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index f5b4775ee0b..deed806db2a 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -28,6 +28,8 @@ ** dynamic functions, so this shouldn't be a real problem. */ +#include + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: implement sql_udf.h #endif diff --git a/sql/tztime.cc b/sql/tztime.cc index 8fac054c49c..30ff25f080f 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -20,18 +20,20 @@ (We will refer to this code as to elsie-code further.) */ -#ifdef USE_PRAGMA_IMPLEMENTATION -#pragma implementation // gcc: Class implementation -#endif - /* We should not include mysql_priv.h in mysql_tzinfo_to_sql utility since it creates unsolved link dependencies on some platforms. */ + +#include + +#ifdef USE_PRAGMA_IMPLEMENTATION +#pragma implementation // gcc: Class implementation +#endif + #if !defined(TZINFO2SQL) && !defined(TESTTIME) #include "mysql_priv.h" #else -#include #include #include "tztime.h" #include From 1c387c8f712451e4f722cae5582ab6fbbfa50e29 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Wed, 1 Jun 2005 18:08:39 -0700 Subject: [PATCH 95/98] Restore a bit of code accidently deleted during merge --- sql/item_func.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/item_func.cc b/sql/item_func.cc index 4963476c114..fd0b2c196fd 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2329,6 +2329,8 @@ longlong Item_func_field::val_int() if (cmp_type == STRING_RESULT) { String *field; + if (!(field= args[0]->val_str(&value))) + return 0; for (uint i=1 ; i < arg_count ; i++) { String *tmp_value=args[i]->val_str(&tmp); From e686057259c7f1ee89dc3db16524852d4d9a5206 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Thu, 2 Jun 2005 16:17:44 +0500 Subject: [PATCH 96/98] item_func.cc: set_var.cc: variables.result variables.test Bug #10904 Illegal mix of collations between a system variable and a constant Changing coercibility of system variables to SYSCONST, to be the same with USER(), DATABASE(), etc. --- mysql-test/r/variables.result | 6 ++++++ mysql-test/t/variables.test | 7 +++++++ sql/item_func.cc | 2 +- sql/set_var.cc | 3 ++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 6d4f9055e4e..602750d5033 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -210,6 +210,12 @@ query_prealloc_size 8192 range_alloc_block_size 2048 transaction_alloc_block_size 8192 transaction_prealloc_size 4096 +SELECT @@version LIKE 'non-existent'; +@@version LIKE 'non-existent' +0 +SELECT @@version_compile_os LIKE 'non-existent'; +@@version_compile_os LIKE 'non-existent' +0 set big_tables=OFFF; ERROR 42000: Variable 'big_tables' can't be set to the value of 'OFFF' set big_tables="OFFF"; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 50bcc1c038c..e45218a9ed7 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -115,6 +115,13 @@ set @@query_alloc_block_size=default, @@query_prealloc_size=default; set transaction_alloc_block_size=default, @@transaction_prealloc_size=default; show variables like '%alloc%'; +# +# Bug #10904 Illegal mix of collations between +# a system variable and a constant +# +SELECT @@version LIKE 'non-existent'; +SELECT @@version_compile_os LIKE 'non-existent'; + # The following should give errors --error 1231 diff --git a/sql/item_func.cc b/sql/item_func.cc index 598439c60c1..ad8479c7b0b 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3369,7 +3369,7 @@ Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name, !my_strcasecmp(system_charset_info, name.str, "VERSION")) return new Item_string("@@VERSION", server_version, (uint) strlen(server_version), - system_charset_info); + system_charset_info, DERIVATION_SYSCONST); Item *item; sys_var *var; diff --git a/sql/set_var.cc b/sql/set_var.cc index b006dde2b4b..5564ba096ac 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1606,7 +1606,8 @@ Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base) Item_string *tmp; pthread_mutex_lock(&LOCK_global_system_variables); char *str= (char*) value_ptr(thd, var_type, base); - tmp= new Item_string(str, strlen(str), system_charset_info); + tmp= new Item_string(str, strlen(str), + system_charset_info, DERIVATION_SYSCONST); pthread_mutex_unlock(&LOCK_global_system_variables); return tmp; } From f89352602ca8d2b54b5714f4fdc3f3bc67debbbd Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Thu, 2 Jun 2005 17:00:07 +0400 Subject: [PATCH 97/98] Fix bug #9669 Ordering on IF function with FROM_UNIXTIME function fails Integer overflow results in wrong field sortlength. --- mysql-test/r/func_if.result | 17 +++++++++++++++++ mysql-test/t/func_if.test | 14 ++++++++++++++ sql/item_cmpfunc.cc | 9 ++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result index 4db31121756..3e72fb45a14 100644 --- a/mysql-test/r/func_if.result +++ b/mysql-test/r/func_if.result @@ -91,3 +91,20 @@ drop table t1; SELECT NULLIF(5,5) IS NULL, NULLIF(5,5) IS NOT NULL; NULLIF(5,5) IS NULL NULLIF(5,5) IS NOT NULL 1 0 +CREATE TABLE `t1` ( +`id` int(11) NOT NULL , +`date` int(10) default NULL, +`text` varchar(32) NOT NULL +); +INSERT INTO t1 VALUES (1,1110000000,'Day 1'),(2,1111000000,'Day 2'),(3,1112000000,'Day 3'); +SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord ASC; +id date_ord text +1 05-03-2005 Day 1 +2 16-03-2005 Day 2 +3 28-03-2005 Day 3 +SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord DESC; +id date_ord text +3 28-03-2005 Day 3 +2 16-03-2005 Day 2 +1 05-03-2005 Day 1 +DROP TABLE t1; diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test index a2ea26390ca..37556984f68 100644 --- a/mysql-test/t/func_if.test +++ b/mysql-test/t/func_if.test @@ -61,3 +61,17 @@ drop table t1; # Bug #5595 NULLIF() IS NULL returns false if NULLIF() returns NULL # SELECT NULLIF(5,5) IS NULL, NULLIF(5,5) IS NOT NULL; + +# +# Bug #9669 Ordering on IF function with FROM_UNIXTIME function fails +# +CREATE TABLE `t1` ( + `id` int(11) NOT NULL , + `date` int(10) default NULL, + `text` varchar(32) NOT NULL +); +INSERT INTO t1 VALUES (1,1110000000,'Day 1'),(2,1111000000,'Day 2'),(3,1112000000,'Day 3'); +SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord ASC; +SELECT id, IF(date IS NULL, '-', FROM_UNIXTIME(date, '%d-%m-%Y')) AS date_ord, text FROM t1 ORDER BY date_ord DESC; +DROP TABLE t1; + diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index a7abb5f9be8..eb0dddd3e28 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1227,9 +1227,16 @@ Item_func_if::fix_length_and_dec() { maybe_null=args[1]->maybe_null || args[2]->maybe_null; decimals= max(args[1]->decimals, args[2]->decimals); - max_length= (max(args[1]->max_length - args[1]->decimals, + if (decimals == NOT_FIXED_DEC) + { + max_length= max(args[1]->max_length, args[2]->max_length); + } + else + { + max_length= (max(args[1]->max_length - args[1]->decimals, args[2]->max_length - args[2]->decimals) + decimals); + } enum Item_result arg1_type=args[1]->result_type(); enum Item_result arg2_type=args[2]->result_type(); bool null1=args[1]->const_item() && args[1]->null_value; From 7d6b47c994dbf3ae2b7e581aee7367ad05448a05 Mon Sep 17 00:00:00 2001 From: "schwenke@lmy003.xl.local" <> Date: Thu, 2 Jun 2005 15:32:02 +0200 Subject: [PATCH 98/98] misc. fixes for windoze builds --- VC++Files/client/mysql.dsp | 8 ++++---- VC++Files/client/mysqladmin.dsp | 6 +++--- VC++Files/client/mysqlimport.dsp | 8 ++++---- VC++Files/client/mysqlshow.dsp | 8 ++++---- VC++Files/libmysql/libmysql.dsp | 4 ++-- VC++Files/mysql.dsw | 12 ++++++++++++ include/config-win.h | 1 + sql/sql_base.cc | 5 +++-- 8 files changed, 33 insertions(+), 19 deletions(-) diff --git a/VC++Files/client/mysql.dsp b/VC++Files/client/mysql.dsp index 8298e62d8ad..e9e79a49d0a 100644 --- a/VC++Files/client/mysql.dsp +++ b/VC++Files/client/mysql.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /incremental:yes !ELSEIF "$(CFG)" == "mysql - Win32 Debug" @@ -78,7 +78,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysql.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysql.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysql - Win32 classic" @@ -104,9 +104,9 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=xilink6.exe -# ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" +# ADD BASE LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" # SUBTRACT BASE LINK32 /incremental:yes -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_classic/mysql.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_classic/mysql.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /incremental:yes !ENDIF diff --git a/VC++Files/client/mysqladmin.dsp b/VC++Files/client/mysqladmin.dsp index b473d104a76..d713325b4e7 100644 --- a/VC++Files/client/mysqladmin.dsp +++ b/VC++Files/client/mysqladmin.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqladmin.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqladmin.exe" /libpath:"..\lib_release\\" !ELSEIF "$(CFG)" == "mysqladmin - Win32 Debug" @@ -77,7 +77,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqladmin.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqladmin.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysqladmin - Win32 classic" @@ -104,7 +104,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqladmin.exe" /libpath:"..\lib_release\\" -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqladmin.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqladmin.exe" /libpath:"..\lib_release\\" !ENDIF diff --git a/VC++Files/client/mysqlimport.dsp b/VC++Files/client/mysqlimport.dsp index 1a9b64a0383..1b650dab731 100644 --- a/VC++Files/client/mysqlimport.dsp +++ b/VC++Files/client/mysqlimport.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /incremental:yes !ELSEIF "$(CFG)" == "mysqlimport - Win32 Debug" @@ -78,7 +78,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib setargv.obj /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlimport.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib setargv.obj /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlimport.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysqlimport - Win32 classic" @@ -104,9 +104,9 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=xilink6.exe -# ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" +# ADD BASE LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" # SUBTRACT BASE LINK32 /incremental:yes -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlimport.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlimport.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /incremental:yes !ENDIF diff --git a/VC++Files/client/mysqlshow.dsp b/VC++Files/client/mysqlshow.dsp index 855c2dcdf34..f9377763c49 100644 --- a/VC++Files/client/mysqlshow.dsp +++ b/VC++Files/client/mysqlshow.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" !ELSEIF "$(CFG)" == "mysqlshow - Win32 Debug" @@ -77,7 +77,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlshow.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlshow.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ELSEIF "$(CFG)" == "mysqlshow - Win32 classic" @@ -103,8 +103,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=xilink6.exe -# ADD BASE LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlshow.exe" /libpath:"..\lib_release\\" +# ADD BASE LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" +# ADD LINK32 mysqlclient.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib zlib.lib /nologo /subsystem:console /machine:I386 /out:"../client_classic/mysqlshow.exe" /libpath:"..\lib_release\\" !ENDIF diff --git a/VC++Files/libmysql/libmysql.dsp b/VC++Files/libmysql/libmysql.dsp index 473aa60d8af..4f93ac93c40 100644 --- a/VC++Files/libmysql/libmysql.dsp +++ b/VC++Files/libmysql/libmysql.dsp @@ -54,7 +54,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /def:"libmysql.def" /out:"..\lib_release\libmysql.dll" /libpath:"." /libpath:"..\lib_release" +# ADD LINK32 mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /def:"libmysql.def" /out:"..\lib_release\libmysql.dll" /libpath:"." /libpath:"..\lib_release" # SUBTRACT LINK32 /pdb:none # Begin Special Build Tool SOURCE="$(InputPath)" @@ -87,7 +87,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 zlib.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:no /map /debug /machine:I386 /def:"libmysql.def" /out:"..\lib_debug\libmysql.dll" /pdbtype:sept /libpath:"." /libpath:"..\lib_debug" +# ADD LINK32 zlib.lib mysys.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /incremental:no /map /debug /machine:I386 /def:"libmysql.def" /out:"..\lib_debug\libmysql.dll" /pdbtype:sept /libpath:"." /libpath:"..\lib_debug" # SUBTRACT LINK32 /pdb:none # Begin Special Build Tool SOURCE="$(InputPath)" diff --git a/VC++Files/mysql.dsw b/VC++Files/mysql.dsw index 25bcab8338b..6ebda999c35 100644 --- a/VC++Files/mysql.dsw +++ b/VC++Files/mysql.dsw @@ -80,6 +80,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name zlib End Project Dependency + Begin Project Dependency + Project_Dep_Name mysys + End Project Dependency }}} ############################################################################### @@ -320,6 +323,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name zlib End Project Dependency + Begin Project Dependency + Project_Dep_Name mysys + End Project Dependency }}} ############################################################################### @@ -476,6 +482,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name mysqlclient End Project Dependency + Begin Project Dependency + Project_Dep_Name mysys + End Project Dependency }}} ############################################################################### @@ -533,6 +542,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name mysqlclient End Project Dependency + Begin Project Dependency + Project_Dep_Name mysys + End Project Dependency }}} ############################################################################### diff --git a/include/config-win.h b/include/config-win.h index bc14d3d3e53..b17e4df4e26 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -76,6 +76,7 @@ functions */ #define F_EXCLUSIVE 1 /* We have only exclusive locking */ #define F_TO_EOF (INT_MAX32/2) /* size for lock of all file */ #define F_OK 0 /* parameter to access() */ +#define W_OK 2 #define S_IROTH S_IREAD /* for my_lib */ diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 5719f77e3ef..036a838b6fc 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -3222,7 +3222,8 @@ bool setup_tables(THD *thd, TABLE_LIST *tables, Item **conds, if (!(*leaves)) make_leaves_list(leaves, tables); - for (TABLE_LIST *table_list= *leaves; + TABLE_LIST *table_list; + for (table_list= *leaves; table_list; table_list= table_list->next_leaf, tablenr++) { @@ -3261,7 +3262,7 @@ bool setup_tables(THD *thd, TABLE_LIST *tables, Item **conds, my_error(ER_TOO_MANY_TABLES,MYF(0),MAX_TABLES); DBUG_RETURN(1); } - for (TABLE_LIST *table_list= tables; + for (table_list= tables; table_list; table_list= table_list->next_local) {