Commit 2204baa5 authored by monty@mysql.com's avatar monty@mysql.com

Merge bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/home/my/mysql-4.1
parents 249f914c dcd75689
......@@ -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);
......
......@@ -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');
......
......@@ -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;
......@@ -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;
......@@ -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;
......@@ -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;
......@@ -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;
......@@ -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));
/*
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment