summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.fi>2001-05-09 23:02:36 +0300
committerunknown <monty@donna.mysql.fi>2001-05-09 23:02:36 +0300
commit0fece375f2ae4bb173357609b46924a997113593 (patch)
tree288f7cc7d0ca91ae340b7a568971bb02d8eb798d
parent2321260ff07b0a90e3f84c756370a328ac17f990 (diff)
downloadmariadb-git-0fece375f2ae4bb173357609b46924a997113593.tar.gz
Applied patches for BDB tables
Fixes to InnoDB to compile on Windows Fix for temporary InnoDB tables Fixed bug in REPLACE() Fixed sub char keys for InnoDB Docs/manual.texi: Changelog + update of table types bdb/include/log.h: Patch from Sleepycat bdb/log/log.c: Patch from Sleepycat bdb/log/log_rec.c: Patch from Sleepycat client/mysqladmin.c: Cleanup innobase/include/univ.i: Fix for compilation on Windows innobase/os/os0file.c: cleanup innobase/pars/pars0grm.y: Fix for compilation on Windows mysql-test/r/innodb.result: New test case mysql-test/t/innodb.test: New test case sql/ha_innobase.cc: cleanup sql/ha_innobase.h: Fix for prefix keys sql/handler.h: Fix for temporary Innodb tables sql/item_strfunc.cc: Fixed bug in REPLACE() sql/lock.cc: Fix for temporary Innodb tables sql/mysqld.cc: Added --skip-stack-trace sql/share/english/errmsg.txt: Better error messages sql/sql_base.cc: Fix for temporary Innodb tables sql/sql_select.cc: Fix for temporary Innodb tables sql/sql_table.cc: Fixed sub char keys for InnoDB sql/table.h: Fix for temporary Innodb tables
-rw-r--r--Docs/manual.texi135
-rw-r--r--bdb/include/log.h1
-rw-r--r--bdb/log/log.c14
-rw-r--r--bdb/log/log_rec.c2
-rw-r--r--client/mysqladmin.c1
-rw-r--r--innobase/include/univ.i6
-rw-r--r--innobase/os/os0file.c1
-rw-r--r--innobase/pars/pars0grm.y3
-rw-r--r--mysql-test/r/innodb.result9
-rw-r--r--mysql-test/t/innodb.test20
-rw-r--r--sql/ha_innobase.cc2
-rw-r--r--sql/ha_innobase.h4
-rw-r--r--sql/handler.h1
-rw-r--r--sql/item_strfunc.cc10
-rw-r--r--sql/lock.cc4
-rw-r--r--sql/mysqld.cc19
-rw-r--r--sql/share/english/errmsg.txt2
-rw-r--r--sql/sql_base.cc8
-rw-r--r--sql/sql_select.cc2
-rw-r--r--sql/sql_table.cc35
-rw-r--r--sql/table.h5
21 files changed, 193 insertions, 91 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi
index f69f811383c..3d9609e4fae 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -69,7 +69,7 @@ END-INFO-DIR-ENTRY
@sp 10
@center @titlefont{@strong{MySQL} Reference Manual}
@sp 10
-@center Copyright @copyright{} 1997-2001 TcX AB, Detron HB and MySQL Finland AB
+@center Copyright @copyright{} 1997-2001 MySQL AB
@c blank page after title page makes page 1 be a page front.
@c also makes the back of the title page blank.
@page
@@ -2223,7 +2223,7 @@ The Berkeley DB code is very stable, but we are still improving the interface
between @strong{MySQL} and BDB tables, so it will take some time before this
is as tested as the other table types.
-@item Innodb Tables -- Alpha
+@item InnoDB Tables -- Alpha
This is a very recent addition to @code{MySQL} and is not very tested yet.
@item Automatic recovery of MyISAM tables - Beta
@@ -10015,7 +10015,7 @@ yourself with the different BDB specific startup options. @xref{BDB start}.
If you are using Gemini tables, refer to the Gemini-specific startup options.
@xref{GEMINI start}.
-If you are using Innodb tables, refer to the Innodb-specific startup
+If you are using InnoDB tables, refer to the InnoDB-specific startup
options. @xref{InnoDB start}.
@node Automatic start, Command-line options, Starting server, Post-installation
@@ -10124,6 +10124,10 @@ Chroot mysqld daemon during startup. Recommended security measure. It will
somewhat limit @code{LOAD DATA INFILE} and @code{SELECT ... INTO OUTFILE}
though.
+@item --core-file
+Write a core file if @code{mysqld} dies. For some systems you must also
+specify @code{--core-file-size} to @code{safe_mysqld}. @xref{safe_mysqld}.
+
@item -h, --datadir=path
Path to the database root.
@@ -10278,6 +10282,10 @@ gives everyone @emph{full access} to all databases! (You can tell a running
server to start using the grant tables again by executing @code{mysqladmin
flush-privileges} or @code{mysqladmin reload}.)
+@item --skip-host-cache
+Never use host name cache for faster name-ip resolution, but query DNS server
+on every connect instead. @xref{DNS}.
+
@item --skip-locking
Don't use system locking. To use @code{isamchk} or @code{myisamchk} you must
shut down the server. @xref{Stability}. Note that in @strong{MySQL} Version
@@ -10293,14 +10301,14 @@ Don't listen for TCP/IP connections at all. All interaction with
@code{mysqld} must be made via Unix sockets. This option is highly
recommended for systems where only local requests are allowed. @xref{DNS}.
-@item --skip-host-cache
-Never use host name cache for faster name-ip resolution, but query DNS server
-on every connect instead. @xref{DNS}.
-
@item --skip-new
Don't use new, possible wrong routines. Implies @code{--skip-delay-key-write}.
This will also set default table type to @code{ISAM}. @xref{ISAM}.
+@item --skip-stack-trace
+Don't write stack traces. This option is useful when you are running
+@code{mysqld} under a debugger. @xref{Debugging server}.
+
@item --skip-safemalloc
If @strong{MySQL} is configured with @code{--with-debug=full}, all programs
will check the memory for overruns for every memory allocation and memory
@@ -18752,9 +18760,10 @@ When you insert a value of @code{NULL} (recommended) or @code{0} into an
@xref{mysql_insert_id, , @code{mysql_insert_id()}}.
If you delete the row containing the maximum value for an
-@code{AUTO_INCREMENT} column, the value will be reused with an ISAM
-table but not with a @code{MyISAM} table. If you delete all rows in the
-table with @code{DELETE FROM table_name} (without a @code{WHERE}) in
+@code{AUTO_INCREMENT} column, the value will be reused with an
+@code{ISAM}, @code{BDB} or @code{INNODB} table but not with a
+@code{MyISAM} table. If you delete all rows in the table with
+@code{DELETE FROM table_name} (without a @code{WHERE}) in
@code{AUTOCOMMIT} mode, the sequence starts over for both table types.
@strong{NOTE:} There can be only one @code{AUTO_INCREMENT} column per
@@ -21742,7 +21751,7 @@ if @code{--skip-bdb} is used.
@code{YES} if @code{mysqld} supports Gemini tables. @code{DISABLED}
if @code{--skip-gemini} is used.
@item @code{have_innodb}
-@code{YES} if @code{mysqld} supports Innodb tables. @code{DISABLED}
+@code{YES} if @code{mysqld} supports InnoDB tables. @code{DISABLED}
if @code{--skip-innodb} is used.
@item @code{have_raid}
@code{YES} if @code{mysqld} supports the @code{RAID} option.
@@ -23352,7 +23361,14 @@ the table type, the index and data will be stored in other files.
The default table type in @strong{MySQL} is @code{MyISAM}. If you are
trying to use a table type that is not compiled-in or activated,
-@strong{MySQL} will instead create a table of type @code{MyISAM}.
+@strong{MySQL} will instead create a table of type @code{MyISAM}. This
+is a very useful feature when you want to copy tables between different
+SQL servers that supports different table types (like copying tables to
+a slave that is optimized for speed by not having transactional tables).
+This automatic table changing can however also be very confusing for new
+@strong{MySQL} users. We plan to fix this by introducing warnings in
+@strong{MySQL} 4.0 and giving a warning when a table type is automaticly
+changed.
You can convert tables between different types with the @code{ALTER
TABLE} statement. @xref{ALTER TABLE, , @code{ALTER TABLE}}.
@@ -23452,7 +23468,7 @@ Internal handling of one @code{AUTO_INCREMENT} column. @code{MyISAM}
will automatically update this on @code{INSERT/UPDATE}. The
@code{AUTO_INCREMENT} value can be reset with @code{myisamchk}. This
will make @code{AUTO_INCREMENT} columns faster (at least 10 %) and old
-numbers will not be reused as with the old ISAM. Note that when an
+numbers will not be reused as with the old @code{ISAM}. Note that when an
@code{AUTO_INCREMENT} is defined on the end of a multi-part-key the old
behavior is still present.
@item
@@ -24086,20 +24102,20 @@ SUM_OVER_ALL_KEYS(max_length_of_key + sizeof(char*) * 2)
@section BDB or Berkeley_DB Tables
@menu
-* BDB overview::
-* BDB install::
-* BDB start::
-* BDB characteristic::
-* BDB TODO::
-* BDB portability::
-* BDB errors::
+* BDB overview:: Overview of BDB Tables
+* BDB install:: Installing BDB
+* BDB start:: BDB startup options
+* BDB characteristic:: Some characteristic of @code{BDB} tables:
+* BDB TODO:: Some things we need to fix for BDB in the near future:
+* BDB portability:: Operating systems supported by @strong{BDB}
+* BDB errors:: Errors You May Get When Using BDB Tables
@end menu
@node BDB overview, BDB install, BDB, BDB
@subsection Overview of BDB Tables
Support for BDB tables is included in the @strong{MySQL} source distribution
-starting from Version 3.23.34 and will be activated in the @strong{MySQL}-Max
+starting from Version 3.23.34 and is activated in the @strong{MySQL}-Max
binary.
BerkeleyDB, available at @uref{http://www.sleepycat.com/} has provided
@@ -25419,15 +25435,16 @@ they roll back the corresponding SQL statement.
@subsection Some restrictions on InnoDB tables
@itemize @bullet
-@item You cannot create an index on a prefix of a column:
+@item
+If you try to create an unique index on a prefix of a column you will get an
+error:
@example
-@code{CREATE TABLE T (A CHAR(20), B INT, INDEX T_IND (A(5))) TYPE = InnoDB;
-}
+CREATE TABLE T (A CHAR(20), B INT, UNIQUE (A(5))) TYPE = InnoDB;
@end example
-The above will not work. For a MyISAM table the above would create an index
-where only the first 5 characters from column @code{A} are stored.
+If you create a non unique index on a prefix of a column, InnoDB will
+create an index over the whole column.
@item
@code{INSERT DELAYED} is not supported for InnoDB tables.
@item
@@ -32277,9 +32294,9 @@ the @code{mysql} variables that affect your queries.
@cindex @code{safe-mode} command
A useful startup option for beginners (introduced in @strong{MySQL}
-Version 3.23.11) is @code{--safe-mode} (or @code{--i-am-a-dummy} for
+Version 3.23.11) is @code{--safe-updates} (or @code{--i-am-a-dummy} for
users that has at some time done a @code{DELETE FROM table_name} but
-forgot the @code{WHERE} clause. When using this option, @code{mysql}
+forgot the @code{WHERE} clause). When using this option, @code{mysql}
sends the following command to the @strong{MySQL} server when opening
the connection:
@@ -34587,12 +34604,13 @@ functions. Consult this file to see how UDF calling conventions work.
For mysqld to be able to use UDF functions, you should configure MySQL
with @code{--with-mysqld-ldflags=-rdynamic} The reason is that to on
-many platforms you can load a dynamic library (with @code{dlopen()})
-from a static linked program, which you would get if you are using
-@code{--with-mysqld-ldflags=-all-static} If you want to use an UDF that
-needs to access symbols from mysqld (like the @code{methaphone} example
-in @file{sql/udf_example.cc} that uses @code{default_charset_info}), you must
-link the program with @code{-rdynamic}. (see @code{man dlopen}).
+many platforms (including Linux) you can load a dynamic library (with
+@code{dlopen()}) from a static linked program, which you would get if
+you are using @code{--with-mysqld-ldflags=-all-static} If you want to
+use an UDF that needs to access symbols from mysqld (like the
+@code{methaphone} example in @file{sql/udf_example.cc} that uses
+@code{default_charset_info}), you must link the program with
+@code{-rdynamic}. (see @code{man dlopen}).
For each function that you want to use in SQL statements, you should define
corresponding C (or C++) functions. In the discussion below, the name
@@ -35009,12 +35027,13 @@ one that has been loaded with @code{CREATE FUNCTION} and not removed with
@node Adding native function, , Adding UDF, Adding functions
@section Adding a New Native Function
-The procedure for adding a new native function is described below. Note that
-you cannot add native functions to a binary distribution because the procedure
-involves modifying @strong{MySQL} source code. You must compile
-@strong{MySQL} yourself from a source distribution. Also note that if you
-migrate to another version of @strong{MySQL} (for example, when a new version is
-released), you will need to repeat the procedure with the new version.
+The procedure for adding a new native function is described below. Note
+that you cannot add native functions to a binary distribution because
+the procedure involves modifying @strong{MySQL} source code. You must
+compile @strong{MySQL} yourself from a source distribution. Also note
+that if you migrate to another version of @strong{MySQL} (for example,
+when a new version is released), you will need to repeat the procedure
+with the new version.
To add a new native @strong{MySQL} function, follow these steps:
@@ -44025,7 +44044,7 @@ A new ISAM library which is tuned for SQL and supports large files.
@item @strong{BerkeleyDB} or @strong{BDB}
Uses the Berkeley DB library from Sleepycat Software to implement
transaction-safe tables.
-@item @strong{Innodb}
+@item @strong{InnoDB}
A transaction-safe table handler that supports row level locking, and many
Oracle-like features.
@c change "three" to "four" above when uncommenting this
@@ -44102,6 +44121,16 @@ not yet 100% confident in this code.
@appendixsubsec Changes in release 3.23.38
@itemize @bullet
@item
+Fixed a bug in @code{REPLACE()} when using the ujis character set.
+@item
+Applied Sleepycat BDB patches 3.2.9.1 and 3.2.9.2.
+@item
+Added option @code{--skip-stack-trace} to @code{mysqld}.
+@item
+@code{CREATE TEMPORARY} now works with @code{InnoDB} tables.
+@item
+@code{InnoDB} now promotes sub keys to whole keys.
+@item
Added option @code{CONCURRENT} to @code{LOAD DATA}.
@item
Better error message when slave @code{max_allowed_packet} is to low to
@@ -49412,6 +49441,25 @@ Fail safe replication.
Subqueries.
@code{select id from t where grp in (select grp from g where u > 100)}
@item
+Derieved tables.
+@example
+select a.col1, b.col2 from (select max(col1) as col1 from root_table ) a,
+other_table b where a.col1=b.col1
+@end example
+
+This could be done by automaticly create temporary tables for the
+derived tables for the duration of the query.
+@item
+Add @code{PREPARE} of statements and sending of parameters to @code{mysqld}.
+@item
+Extend the server/client protocol to support warnings.
+@item
+Add options to the server/protocol protocol to get progress notes
+for long running commands.
+@item
+Add database and real table name (in case of alias) to the MYSQL_FIELD
+structure.
+@item
Don't allow more than a defined number of threads to run MyISAM recover
at the same time.
@item
@@ -49425,8 +49473,6 @@ Multiple result sets.
Change the protocol to allow binary transfer of values. To do this
efficiently, we need to add an API to allow binding of variables.
@item
-Add @code{PREPARE} of statements and sending of parameters to @code{mysqld}.
-@item
Make it possible to specify @code{long_query_time} with a granularity
in microseconds.
@item
@@ -49938,6 +49984,9 @@ With some older @code{gdb} versions on Linux you must use @code{run
--one-thread} if you want to be able to debug @code{mysqld} threads. In
this case you can only have one thread active at a time.
+When running @code{mysqld} under gdb, you should disable the stack trace
+with @code{--skip-stack-trace} to be able to catch segfaults within gdb.
+
It's very hard to debug @strong{MySQL} under @code{gdb} if you do a lot of
new connections the whole time as @code{gdb} doesn't free the memory for
old threads. You can avoid this problem by starting @code{mysqld} with
diff --git a/bdb/include/log.h b/bdb/include/log.h
index 1cac0492252..81ecb4174a6 100644
--- a/bdb/include/log.h
+++ b/bdb/include/log.h
@@ -198,6 +198,7 @@ struct __fname {
*/
typedef enum {
DB_LV_INCOMPLETE,
+ DB_LV_NONEXISTENT,
DB_LV_NORMAL,
DB_LV_OLD_READABLE,
DB_LV_OLD_UNREADABLE
diff --git a/bdb/log/log.c b/bdb/log/log.c
index 69af1624824..8ddb7bcaf7d 100644
--- a/bdb/log/log.c
+++ b/bdb/log/log.c
@@ -309,13 +309,13 @@ __log_find(dblp, find_first, valp, statusp)
int find_first, *valp;
logfile_validity *statusp;
{
- logfile_validity clv_status, status;
+ logfile_validity logval_status, status;
u_int32_t clv, logval;
int cnt, fcnt, ret;
const char *dir;
char **names, *p, *q, savech;
- clv_status = status = DB_LV_NORMAL;
+ logval_status = status = DB_LV_NONEXISTENT;
/* Return a value of 0 as the log file number on failure. */
*valp = 0;
@@ -385,10 +385,14 @@ __log_find(dblp, find_first, valp, statusp)
* as a valid log file.
*/
break;
+ case DB_LV_NONEXISTENT:
+ /* Should never happen. */
+ DB_ASSERT(0);
+ break;
case DB_LV_NORMAL:
case DB_LV_OLD_READABLE:
logval = clv;
- clv_status = status;
+ logval_status = status;
break;
case DB_LV_OLD_UNREADABLE:
/*
@@ -410,7 +414,7 @@ __log_find(dblp, find_first, valp, statusp)
*/
if (!find_first) {
logval = clv;
- clv_status = status;
+ logval_status = status;
}
break;
}
@@ -420,7 +424,7 @@ __log_find(dblp, find_first, valp, statusp)
err: __os_dirfree(names, fcnt);
__os_freestr(p);
- *statusp = clv_status;
+ *statusp = logval_status;
return (ret);
}
diff --git a/bdb/log/log_rec.c b/bdb/log/log_rec.c
index ad6d9f7ead2..493dd06d4c6 100644
--- a/bdb/log/log_rec.c
+++ b/bdb/log/log_rec.c
@@ -430,7 +430,7 @@ __log_add_logid(dbenv, logp, dbp, ndx)
TAILQ_INIT(&logp->dbentry[i].dblist);
else
TAILQ_REINSERT_HEAD(
- &logp->dbentry[i].dblist, dbp, links);
+ &logp->dbentry[i].dblist, dbtmp, links);
}
/* Initialize the new entries. */
diff --git a/client/mysqladmin.c b/client/mysqladmin.c
index 007be803cfc..1e6bf3c5219 100644
--- a/client/mysqladmin.c
+++ b/client/mysqladmin.c
@@ -417,7 +417,6 @@ static my_bool execute_commands(MYSQL *mysql,int argc, char **argv)
}
case ADMIN_DROP:
{
- char buff[FN_REFLEN+20];
if (argc < 2)
{
my_printf_error(0,"Too few arguments to drop",MYF(ME_BELL));
diff --git a/innobase/include/univ.i b/innobase/include/univ.i
index 253ef08c9f8..fa5a8aef389 100644
--- a/innobase/include/univ.i
+++ b/innobase/include/univ.i
@@ -9,7 +9,7 @@ Created 1/20/1994 Heikki Tuuri
#ifndef univ_i
#define univ_i
-#if (defined(_WIN32) || defined(_WIN64))
+#if (defined(_WIN32) || defined(_WIN64)) && !defined(MYSQL_SERVER)
#define __WIN__
#include <windows.h>
@@ -28,7 +28,7 @@ be defined:
/* The Unix version */
/* Most C compilers other than gcc do not know 'extern inline' */
-#ifndef __GNUC__
+#if !defined(__GNUC__) && !defined(__WIN__)
#define UNIV_MUST_NOT_INLINE
#endif
@@ -38,8 +38,10 @@ subdirectory of 'mysql'. */
#include <global.h>
#include <my_pthread.h>
+#ifndef __WIN__
/* Include <sys/stat.h> to get S_I... macros defined for os0file.c */
#include <sys/stat.h>
+#endif
#undef PACKAGE
#undef VERSION
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c
index 01fdf13b7d1..b3cb86a1178 100644
--- a/innobase/os/os0file.c
+++ b/innobase/os/os0file.c
@@ -167,7 +167,6 @@ os_file_handle_error(
err = os_file_get_last_error();
if (err == OS_FILE_DISK_FULL) {
-ask_again:
fprintf(stderr, "\n");
if (name) {
fprintf(stderr,
diff --git a/innobase/pars/pars0grm.y b/innobase/pars/pars0grm.y
index 681454f1d72..ae8c5ab91ec 100644
--- a/innobase/pars/pars0grm.y
+++ b/innobase/pars/pars0grm.y
@@ -10,9 +10,10 @@ Created 12/14/1997 Heikki Tuuri
/* The value of the semantic attribute is a pointer to a query tree node
que_node_t */
#define YYSTYPE que_node_t*
-#define alloca mem_alloc
#include "univ.i"
+#undef alloca
+#define alloca mem_alloc
#include <math.h>
#include "pars0pars.h"
#include "mem0mem.h"
diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result
index 319a9095cbc..f030b7fa763 100644
--- a/mysql-test/r/innodb.result
+++ b/mysql-test/r/innodb.result
@@ -466,3 +466,12 @@ id id3
1 1
2 2
100 2
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(20) default NULL,
+ KEY `a` (`a`)
+) TYPE=InnoDB
+a
+1
+2
+3
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index 60e29ca33c4..cef53ce8165 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -456,3 +456,23 @@ commit;
select id,id3 from t1;
UNLOCK TABLES;
DROP TABLE t1;
+
+#
+# Test prefix key
+#
+--error 1089
+create table t1 (a char(20), unique (a(5))) type=innodb;
+create table t1 (a char(20), index (a(5))) type=innodb;
+show create table t1;
+drop table t1;
+
+#
+# Test using temporary table and auto_increment
+#
+
+create temporary table t1 (a int not null auto_increment, primary key(a)) type=innodb;
+insert into t1 values (NULL),(NULL),(NULL);
+delete from t1 where a=3;
+insert into t1 values (NULL);
+select * from t1;
+drop table t1;
diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc
index 72857fc953f..8af9de0eaba 100644
--- a/sql/ha_innobase.cc
+++ b/sql/ha_innobase.cc
@@ -449,7 +449,7 @@ innobase_init(void)
if (!innobase_data_file_path)
{
fprintf(stderr,
- "Can't initialize InnoDB as 'innobase_data_file_path' is not set\n");
+ "Can't initialize InnoDB as 'innodb_data_file_path' is not set\n");
innodb_skip=1;
DBUG_RETURN(FALSE); // Continue without innobase
}
diff --git a/sql/ha_innobase.h b/sql/ha_innobase.h
index e85d73bdae5..429e47523dd 100644
--- a/sql/ha_innobase.h
+++ b/sql/ha_innobase.h
@@ -83,14 +83,14 @@ class ha_innobase: public handler
HA_NO_WRITE_DELAYED |
HA_PRIMARY_KEY_IN_READ_INDEX |
HA_DROP_BEFORE_CREATE |
- HA_NOT_READ_AFTER_KEY),
+ HA_NOT_READ_AFTER_KEY | HA_NO_PREFIX_CHAR_KEYS),
last_dup_key((uint) -1),
start_of_scan(0)
{
}
~ha_innobase() {}
- const char* table_type() const { return("Innobase");}
+ const char* table_type() const { return("InnoDB");}
const char** bas_ext() const;
ulong option_flag() const { return int_option_flag; }
uint max_record_length() const { return HA_MAX_REC_LENGTH; }
diff --git a/sql/handler.h b/sql/handler.h
index c7df6e2a915..076bf783f80 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -73,6 +73,7 @@
#define HA_NOT_READ_AFTER_KEY (HA_DROP_BEFORE_CREATE*2)
#define HA_NOT_DELETE_WITH_CACHE (HA_NOT_READ_AFTER_KEY*2)
#define HA_NO_TEMP_TABLES (HA_NOT_DELETE_WITH_CACHE*2)
+#define HA_NO_PREFIX_CHAR_KEYS (HA_NO_TEMP_TABLES*2)
/* Parameters for open() (in register form->filestat) */
/* HA_GET_INFO does a implicit HA_ABORT_IF_LOCKED */
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 82dcb0268b4..80f72c30e57 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -393,12 +393,14 @@ void Item_func_reverse::fix_length_and_dec()
String *Item_func_replace::val_str(String *str)
{
String *res,*res2,*res3;
- int offset=0;
+ int offset;
uint from_length,to_length;
bool alloced=0;
#ifdef USE_MB
const char *ptr,*end,*strend,*search,*search_end;
register uint32 l;
+ bool binary_str = (args[0]->binary || args[1]->binary ||
+ !use_mb(default_charset_info));
#endif
null_value=0;
@@ -415,7 +417,8 @@ String *Item_func_replace::val_str(String *str)
if ((offset=res->strstr(*res2)) < 0)
return res;
#else
- if (!use_mb(default_charset_info) && (offset=res->strstr(*res2)) < 0)
+ offset=0;
+ if (binary_str && (offset=res->strstr(*res2)) < 0)
return res;
#endif
if (!(res3=args[2]->val_str(&tmp_value2)))
@@ -424,7 +427,7 @@ String *Item_func_replace::val_str(String *str)
to_length= res3->length();
#ifdef USE_MB
- if (use_mb(default_charset_info))
+ if (!binary_str)
{
search=res2->ptr();
search_end=search+from_length;
@@ -449,6 +452,7 @@ redo:
res=copy_if_not_alloced(str,res,res->length()+to_length);
}
res->replace((uint) offset,from_length,*res3);
+ offset+=(int) to_length;
goto redo;
}
skipp:
diff --git a/sql/lock.cc b/sql/lock.cc
index 915f1831245..23f81c9c164 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -346,7 +346,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
*write_lock_used=0;
for (i=tables=lock_count=0 ; i < count ; i++)
{
- if (!table_ptr[i]->tmp_table)
+ if (table_ptr[i]->tmp_table != TMP_TABLE)
{
tables+=table_ptr[i]->file->lock_count();
lock_count++;
@@ -366,7 +366,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
for (i=0 ; i < count ; i++)
{
TABLE *table;
- if ((table=table_ptr[i])->tmp_table)
+ if ((table=table_ptr[i])->tmp_table == TMP_TABLE)
continue;
*to++=table;
enum thr_lock_type lock_type= table->reginfo.lock_type;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 3d42f59ff93..7c4b88d0170 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1222,7 +1222,8 @@ stack trace and/or the core file to produce a readable backtrace that may\n\
help in finding out why mysqld died.\n",sig);
#if defined(HAVE_LINUXTHREADS)
#ifdef __i386__
- trace_stack();
+ if (!(test_flags & TEST_NO_STACKTRACE))
+ trace_stack();
fflush(stderr);
#endif /* __i386__ */
if (test_flags & TEST_CORE_ON_SIGNAL)
@@ -1253,7 +1254,7 @@ static void init_signals(void)
struct sigaction sa; sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL);
- if (!(test_flags & TEST_NO_STACKTRACE))
+ if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL))
{
sa.sa_handler=handle_segfault;
sigaction(SIGSEGV, &sa, NULL);
@@ -2495,7 +2496,8 @@ enum options {
OPT_GEMINI_SKIP, OPT_INNODB_SKIP,
OPT_TEMP_POOL, OPT_TX_ISOLATION,
OPT_GEMINI_FLUSH_LOG, OPT_GEMINI_RECOVER,
- OPT_GEMINI_UNBUFFERED_IO, OPT_SKIP_SAFEMALLOC
+ OPT_GEMINI_UNBUFFERED_IO, OPT_SKIP_SAFEMALLOC,
+ OPT_SKIP_STACK_TRACE
};
static struct option long_options[] = {
@@ -2617,11 +2619,12 @@ static struct option long_options[] = {
{"skip-locking", no_argument, 0, (int) OPT_SKIP_LOCK},
{"skip-host-cache", no_argument, 0, (int) OPT_SKIP_HOST_CACHE},
{"skip-name-resolve", no_argument, 0, (int) OPT_SKIP_RESOLVE},
+ {"skip-networking", no_argument, 0, (int) OPT_SKIP_NETWORKING},
{"skip-new", no_argument, 0, (int) OPT_SKIP_NEW},
{"skip-safemalloc", no_argument, 0, (int) OPT_SKIP_SAFEMALLOC},
{"skip-show-database", no_argument, 0, (int) OPT_SKIP_SHOW_DB},
{"skip-slave-start", no_argument, 0, (int) OPT_SKIP_SLAVE_START},
- {"skip-networking", no_argument, 0, (int) OPT_SKIP_NETWORKING},
+ {"skip-stack-trace", no_argument, 0, (int) OPT_SKIP_STACK_TRACE},
{"skip-thread-priority", no_argument, 0, (int) OPT_SKIP_PRIOR},
{"sql-bin-update-same", no_argument, 0, (int) OPT_SQL_BIN_UPDATE_SAME},
#include "sslopt-longopts.h"
@@ -3047,15 +3050,16 @@ static void usage(void)
Don't use concurrent insert with MyISAM\n\
--skip-delay-key-write\n\
Ignore the delay_key_write option for all tables\n\
+ --skip-host-cache Don't cache host names\n\
--skip-locking Don't use system locking. To use isamchk one has\n\
to shut down the server.\n\
--skip-name-resolve Don't resolve hostnames.\n\
All hostnames are IP's or 'localhost'\n\
--skip-networking Don't allow connection with TCP/IP.\n\
- --skip-new Don't use new, possible wrong routines.\n\
- --skip-host-cache Don't cache host names\n");
+ --skip-new Don't use new, possible wrong routines.\n");
/* We have to break the string here because of VC++ limits */
puts("\
+ --skip-stack-trace Don't print a stack trace on failure\n\
--skip-show-database Don't allow 'SHOW DATABASE' commands\n\
--skip-thread-priority\n\
Don't give threads different priorities.\n\
@@ -3501,6 +3505,9 @@ static void get_options(int argc,char **argv)
case (int) OPT_WANT_CORE:
test_flags |= TEST_CORE_ON_SIGNAL;
break;
+ case (int) OPT_SKIP_STACK_TRACE:
+ test_flags|=TEST_NO_STACKTRACE;
+ break;
case (int) OPT_BIND_ADDRESS:
if (optarg && isdigit(optarg[0]))
{
diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt
index 74139b30a85..ff29fffe958 100644
--- a/sql/share/english/errmsg.txt
+++ b/sql/share/english/errmsg.txt
@@ -90,7 +90,7 @@
"File '%-.80s' already exists",
"Records: %ld Deleted: %ld Skipped: %ld Warnings: %ld",
"Records: %ld Duplicates: %ld",
-"Incorrect sub part key. The used key part isn't a string or the used length is longer than the key part",
+"Incorrect sub part key. The used key part isn't a string, the used length is longer than the key part or the table handler doesn't support unique sub keys",
"You can't delete all columns with ALTER TABLE. Use DROP TABLE instead",
"Can't DROP '%-.64s'. Check that column/key exists",
"Records: %ld Duplicates: %ld Warnings: %ld",
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index afff01e9a16..3c81723b61f 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1495,8 +1495,7 @@ TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
DBUG_RETURN(0); /* purecov: inspected */
if (openfrm(path, table_name,
- (uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE | HA_GET_INDEX |
- HA_TRY_READ_ONLY),
+ (uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE | HA_GET_INDEX),
READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD,
ha_open_options,
tmp_table))
@@ -1505,8 +1504,9 @@ TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
}
tmp_table->file->extra(HA_EXTRA_NO_READCHECK); // Not needed in SQL
- tmp_table->reginfo.lock_type=TL_WRITE; // Simulate locked
- tmp_table->tmp_table = 1;
+ tmp_table->reginfo.lock_type=TL_WRITE; // Simulate locked
+ tmp_table->tmp_table = (tmp_table->file->has_transactions() ?
+ TRANSACTIONAL_TMP_TABLE : TMP_TABLE);
tmp_table->table_cache_key=(char*) (tmp_table+1);
tmp_table->key_length= (uint) (strmov((tmp_table->real_name=
strmov(tmp_table->table_cache_key,db)
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 398a2ddeec9..95a87e06f2b 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -3358,7 +3358,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
table->db_stat=HA_OPEN_KEYFILE+HA_OPEN_RNDFILE;
table->blob_ptr_size=mi_portable_sizeof_char_ptr;
table->map=1;
- table->tmp_table=1;
+ table->tmp_table= TMP_TABLE;
table->db_low_byte_first=1; // True for HEAP and MyISAM
table->temp_pool_slot = temp_pool_slot;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 78721c3e8f9..ad39b91a5ca 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -479,12 +479,16 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
}
}
else if (column->length > length ||
- (f_is_packed(sql_field->pack_flag) && column->length != length))
+ ((f_is_packed(sql_field->pack_flag) ||
+ ((file->option_flag() & HA_NO_PREFIX_CHAR_KEYS) &&
+ (key_info->flags & HA_NOSAME))) &&
+ column->length != length))
{
my_error(ER_WRONG_SUB_KEY,MYF(0));
DBUG_RETURN(-1);
}
- length=column->length;
+ if (!(file->option_flag() & HA_NO_PREFIX_CHAR_KEYS))
+ length=column->length;
}
else if (length == 0)
{
@@ -1426,21 +1430,20 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
create_info,
create_list,key_list,1,1))) // no logging
DBUG_RETURN(error);
+
+ if (table->tmp_table)
+ new_table=open_table(thd,new_db,tmp_name,tmp_name,0);
+ else
{
- if (table->tmp_table)
- new_table=open_table(thd,new_db,tmp_name,tmp_name,0);
- else
- {
- char path[FN_REFLEN];
- (void) sprintf(path,"%s/%s/%s",mysql_data_home,new_db,tmp_name);
- fn_format(path,path,"","",4);
- new_table=open_temporary_table(thd, path, new_db, tmp_name,0);
- }
- if (!new_table)
- {
- VOID(quick_rm_table(new_db_type,new_db,tmp_name));
- goto err;
- }
+ char path[FN_REFLEN];
+ (void) sprintf(path,"%s/%s/%s",mysql_data_home,new_db,tmp_name);
+ fn_format(path,path,"","",4);
+ new_table=open_temporary_table(thd, path, new_db, tmp_name,0);
+ }
+ if (!new_table)
+ {
+ VOID(quick_rm_table(new_db_type,new_db,tmp_name));
+ goto err;
}
save_time_stamp=new_table->time_stamp;
diff --git a/sql/table.h b/sql/table.h
index a3b361742c5..b627a158556 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -41,6 +41,8 @@ typedef struct st_grant_info
uint want_privilege;
} GRANT_INFO;
+enum tmp_table_type {NO_TMP_TABLE=0, TMP_TABLE=1, TRANSACTIONAL_TMP_TABLE=2};
+
/* Table cache entry struct */
class Field_timestamp;
@@ -83,10 +85,11 @@ struct st_table {
uint blob_ptr_size; /* 4 or 8 */
uint next_number_key_offset;
int current_lock; /* Type of lock on table */
+ enum tmp_table_type tmp_table;
my_bool copy_blobs; /* copy_blobs when storing */
my_bool null_row; /* All columns are null */
my_bool maybe_null,outer_join; /* Used with OUTER JOIN */
- my_bool distinct,tmp_table,const_table;
+ my_bool distinct,const_table;
my_bool key_read;
my_bool crypted;
my_bool db_low_byte_first; /* Portable row format */