diff options
-rw-r--r-- | innobase/os/os0file.c | 24 | ||||
-rw-r--r-- | mysql-test/r/ctype_utf8.result | 4 | ||||
-rw-r--r-- | mysql-test/r/show_check.result | 70 | ||||
-rw-r--r-- | mysql-test/r/type_float.result | 15 | ||||
-rw-r--r-- | mysql-test/r/type_float.result.es | 15 | ||||
-rw-r--r-- | mysql-test/t/show_check.test | 32 | ||||
-rw-r--r-- | mysql-test/t/type_float.test | 10 | ||||
-rw-r--r-- | sql/field.cc | 13 | ||||
-rw-r--r-- | sql/ha_berkeley.cc | 2 | ||||
-rw-r--r-- | sql/ha_innodb.cc | 9 | ||||
-rw-r--r-- | sql/sql_show.cc | 8 |
11 files changed, 184 insertions, 18 deletions
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 60760d1f8b8..cf36a22a33b 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -486,7 +486,7 @@ os_io_init_simple(void) } } -#ifndef UNIV_HOTBACKUP +#if !defined(UNIV_HOTBACKUP) && !defined(__NETWARE__) /************************************************************************* Creates a temporary file. This function is defined in ha_innodb.cc. */ @@ -494,7 +494,7 @@ int innobase_mysql_tmpfile(void); /*========================*/ /* out: temporary file descriptor, or < 0 on error */ -#endif /* !UNIV_HOTBACKUP */ +#endif /* !UNIV_HOTBACKUP && !__NETWARE__ */ /*************************************************************************** Creates a temporary file. */ @@ -504,9 +504,12 @@ os_file_create_tmpfile(void) /*========================*/ /* out: temporary file handle, or NULL on error */ { +#ifdef __NETWARE__ + FILE* file = tmpfile(); +#else /* __NETWARE__ */ FILE* file = NULL; int fd = -1; -#ifdef UNIV_HOTBACKUP +# ifdef UNIV_HOTBACKUP int tries; for (tries = 10; tries--; ) { char* name = tempnam(fil_path_to_mysql_datadir, "ib"); @@ -515,15 +518,15 @@ os_file_create_tmpfile(void) } fd = open(name, -# ifdef __WIN__ +# ifdef __WIN__ O_SEQUENTIAL | O_SHORT_LIVED | O_TEMPORARY | -# endif /* __WIN__ */ +# endif /* __WIN__ */ O_CREAT | O_EXCL | O_RDWR, S_IREAD | S_IWRITE); if (fd >= 0) { -# ifndef __WIN__ +# ifndef __WIN__ unlink(name); -# endif /* !__WIN__ */ +# endif /* !__WIN__ */ free(name); break; } @@ -534,22 +537,25 @@ os_file_create_tmpfile(void) name); free(name); } -#else /* UNIV_HOTBACKUP */ +# else /* UNIV_HOTBACKUP */ fd = innobase_mysql_tmpfile(); -#endif /* UNIV_HOTBACKUP */ +# endif /* UNIV_HOTBACKUP */ if (fd >= 0) { file = fdopen(fd, "w+b"); } +#endif /* __NETWARE__ */ if (!file) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error: unable to create temporary file;" " errno: %d\n", errno); +#ifndef __NETWARE__ if (fd >= 0) { close(fd); } +#endif /* !__NETWARE__ */ } return(file); diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 6e375b53d35..f62d754392b 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -412,7 +412,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c` char(10) character set utf8 default NULL, - UNIQUE KEY `a` (`c`(1)) + UNIQUE KEY `a` TYPE HASH (`c`(1)) ) ENGINE=HEAP DEFAULT CHARSET=latin1 insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); insert into t1 values ('aa'); @@ -570,7 +570,7 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c` char(10) character set utf8 collate utf8_bin default NULL, - UNIQUE KEY `a` (`c`(1)) + UNIQUE KEY `a` TYPE HASH (`c`(1)) ) ENGINE=HEAP DEFAULT CHARSET=latin1 insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); insert into t1 values ('aa'); diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index 0afe45eb5e5..37531f05f43 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -405,3 +405,73 @@ where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3'; delete from mysql.db where user='mysqltest_1' || user='mysqltest_2' || user='mysqltest_3'; flush privileges; +CREATE TABLE t1 (i int, KEY (i)) ENGINE=MEMORY; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) default NULL, + KEY `i` (`i`) +) ENGINE=HEAP DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (i int, KEY USING HASH (i)) ENGINE=MEMORY; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) default NULL, + KEY `i` TYPE HASH (`i`) +) ENGINE=HEAP DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (i int, KEY USING BTREE (i)) ENGINE=MEMORY; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) default NULL, + KEY `i` TYPE BTREE (`i`) +) ENGINE=HEAP DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (i int, KEY (i)) ENGINE=MyISAM; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) default NULL, + KEY `i` (`i`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (i int, KEY USING BTREE (i)) ENGINE=MyISAM; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) default NULL, + KEY `i` TYPE BTREE (`i`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (i int, KEY (i)) ENGINE=MyISAM; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) default NULL, + KEY `i` (`i`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +ALTER TABLE t1 ENGINE=MEMORY; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) default NULL, + KEY `i` (`i`) +) ENGINE=HEAP DEFAULT CHARSET=latin1 +DROP TABLE t1; +CREATE TABLE t1 (i int, KEY USING BTREE (i)) ENGINE=MyISAM; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) default NULL, + KEY `i` TYPE BTREE (`i`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +ALTER TABLE t1 ENGINE=MEMORY; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) default NULL, + KEY `i` TYPE BTREE (`i`) +) ENGINE=HEAP DEFAULT CHARSET=latin1 +DROP TABLE t1; diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index 9dd92c13c98..530eb32f77d 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -179,3 +179,18 @@ f 9.999 9.999 drop table if exists t1; +create table t1 (c char(20)); +insert into t1 values (5e-28); +select * from t1; +c +5e-28 +drop table t1; +create table t1 (c char(6)); +insert into t1 values (2e5),(2e6),(2e-4),(2e-5); +select * from t1; +c +200000 +2e+06 +0.0002 +2e-05 +drop table t1; diff --git a/mysql-test/r/type_float.result.es b/mysql-test/r/type_float.result.es index 64d9be7e30f..b93539b6bea 100644 --- a/mysql-test/r/type_float.result.es +++ b/mysql-test/r/type_float.result.es @@ -179,3 +179,18 @@ f 9.999 9.999 drop table if exists t1; +create table t1 (c char(20)); +insert into t1 values (5e-28); +select * from t1; +c +5e-28 +drop table t1; +create table t1 (c char(6)); +insert into t1 values (2e5),(2e6),(2e-4),(2e-5); +select * from t1; +c +200000 +2e+06 +0.0002 +2e-05 +drop table t1; diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index 7788215dd27..cd8d4dba6ab 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -321,3 +321,35 @@ flush privileges; #--replace_column 7 # 8 # 9 # #show table status from `ä` LIKE 'ä'; #drop database `ä`; + +# Test that USING <keytype> is always shown in SHOW CREATE TABLE when it was +# specified during table creation, but not otherwise. (Bug #7235) +CREATE TABLE t1 (i int, KEY (i)) ENGINE=MEMORY; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (i int, KEY USING HASH (i)) ENGINE=MEMORY; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (i int, KEY USING BTREE (i)) ENGINE=MEMORY; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (i int, KEY (i)) ENGINE=MyISAM; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (i int, KEY USING BTREE (i)) ENGINE=MyISAM; +SHOW CREATE TABLE t1; +DROP TABLE t1; +# Test that when an index is created with the default key algorithm and +# altered to another storage engine, it gets the default key algorithm +# for that storage engine, but when it is specified, the specified type is +# preserved. +CREATE TABLE t1 (i int, KEY (i)) ENGINE=MyISAM; +SHOW CREATE TABLE t1; +ALTER TABLE t1 ENGINE=MEMORY; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE TABLE t1 (i int, KEY USING BTREE (i)) ENGINE=MyISAM; +SHOW CREATE TABLE t1; +ALTER TABLE t1 ENGINE=MEMORY; +SHOW CREATE TABLE t1; +DROP TABLE t1; diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index 3fe3afa3fac..69cdeaa32a9 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -103,3 +103,13 @@ create table t1 (f double(4,3)); insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11"); select * from t1; drop table if exists t1; + +# Check conversion of floats to character field (Bug #7774) +create table t1 (c char(20)); +insert into t1 values (5e-28); +select * from t1; +drop table t1; +create table t1 (c char(6)); +insert into t1 values (2e5),(2e6),(2e-4),(2e-5); +select * from t1; +drop table t1; diff --git a/sql/field.cc b/sql/field.cc index 86073072a64..7357bc06f11 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4301,13 +4301,20 @@ int Field_str::store(double nr) char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; uint length; bool use_scientific_notation= TRUE; - use_scientific_notation= TRUE; - if (field_length < 32 && fabs(nr) < log_10[field_length]-1) + /* + Check fabs(nr) against longest value that can be stored in field, + which depends on whether the value is < 1 or not, and negative or not + */ + double anr= fabs(nr); + int neg= (nr < 0.0) ? 1 : 0; + if (field_length > 4 && field_length < 32 && + (anr < 1.0 ? anr > 1/(log_10[max(0,field_length-neg-2)]) /* -2 for "0." */ + : anr < log_10[field_length-neg]-1)) use_scientific_notation= FALSE; length= (uint) my_sprintf(buff, (buff, "%-.*g", (use_scientific_notation ? - max(0, (int)field_length-5) : + max(0, (int)field_length-neg-5) : field_length), nr)); /* diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 2c7cce4bcd0..e33cd3fca1b 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -165,11 +165,13 @@ bool berkeley_init(void) { db_env->close(db_env,0); /* purecov: inspected */ db_env=0; /* purecov: inspected */ + goto err; } (void) hash_init(&bdb_open_tables,system_charset_info,32,0,0, (hash_get_key) bdb_get_key,0,0); pthread_mutex_init(&bdb_mutex,MY_MUTEX_INIT_FAST); +err: DBUG_RETURN(db_env == 0); } diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 14b143ca04b..4c13902c31e 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -5265,7 +5265,9 @@ ha_innobase::store_lock( if ((lock_type == TL_READ && thd->in_lock_tables) || (lock_type == TL_READ_HIGH_PRIORITY && thd->in_lock_tables) || lock_type == TL_READ_WITH_SHARED_LOCKS || - lock_type == TL_READ_NO_INSERT) { + lock_type == TL_READ_NO_INSERT || + thd->lex->sql_command != SQLCOM_SELECT) { + /* The OR cases above are in this order: 1) MySQL is doing LOCK TABLES ... READ LOCAL, or 2) (we do not know when TL_READ_HIGH_PRIORITY is used), or @@ -5273,7 +5275,10 @@ ha_innobase::store_lock( 4) we are doing a complex SQL statement like INSERT INTO ... SELECT ... and the logical logging (MySQL binlog) requires the use of a locking read, or - MySQL is doing LOCK TABLES ... READ. */ + MySQL is doing LOCK TABLES ... READ. + 5) we let InnoDB do locking reads for all SQL statements that + are not simple SELECTs; note that select_lock_type in this + case may get strengthened in ::external_lock() to LOCK_X. */ prebuilt->select_lock_type = LOCK_S; prebuilt->stored_select_lock_type = LOCK_S; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 88a56d26e35..8929872c466 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1404,14 +1404,18 @@ store_create_info(THD *thd, TABLE *table, String *packet) if (!(thd->variables.sql_mode & MODE_NO_KEY_OPTIONS) && !limited_mysql_mode && !foreign_db_mode) { - if (table->db_type == DB_TYPE_HEAP && - key_info->algorithm == HA_KEY_ALG_BTREE) + if (key_info->algorithm == HA_KEY_ALG_BTREE) packet->append(" TYPE BTREE", 11); + if (key_info->algorithm == HA_KEY_ALG_HASH) + packet->append(" TYPE HASH", 10); + // +BAR: send USING only in non-default case: non-spatial rtree if ((key_info->algorithm == HA_KEY_ALG_RTREE) && !(key_info->flags & HA_SPATIAL)) packet->append(" TYPE RTREE", 11); + + // No need to send TYPE FULLTEXT, it is sent as FULLTEXT KEY } packet->append(" (", 2); |