1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

Merge work.mysql.com:/home/bk/mysql

into threads.polyesthetic.msg:/usr/local/src/my/work


BitKeeper/etc/logging_ok:
  auto-union
sql/sql_select.cc:
  Auto merged
This commit is contained in:
unknown
2001-04-19 15:15:34 -04:00
47 changed files with 674 additions and 275 deletions

View File

@@ -244,3 +244,6 @@ bdb/build_win32/libdb.rc
bdb/db/crdel_auto.c
bdb/db/db_auto.c
bdb/dist/config.hin
innobase/ib_config.h
innobase/ib_config.h.in
mysql.proj

View File

@@ -1,4 +1,7 @@
heikki@donna.mysql.fi
jcole@abel.spaceapes.com
monty@donna.mysql.fi
monty@work.mysql.com
sasha@mysql.sashanet.com
serg@serg.mysql.com
tim@threads.polyesthetic.msg

View File

@@ -14,6 +14,7 @@ OLD="mysql-$PVER.tar.gz"
RESULT="mysql-$PVER-$VER.patch.gz"
PATCH_DIR=/my/web/Downloads-live/Patches
RESULT_DIR=/my/web/Downloads-live/MySQL-3.23
RESULT_DIR_MAX=/my/web/Downloads-live/MySQL-Max-3.23
if test ! -f $NEWDIR/$NEW
then
@@ -39,4 +40,5 @@ chmod a+r,o-w $RESULT binary/*
mv $RESULT $PATCH_DIR
cp binary/mysqlcom-* binary/mysql*win* /net/web/home/production/data/nweb/customer/Downloads
rm binary/mysqlcom-*
mv binary/*Max* $RESULT_DIR_MAX
cp binary/* $RESULT_DIR

View File

@@ -531,10 +531,20 @@ GEMINI Tables
InnoDB Tables
* InnoDB overview::
* InnoDB overview:: InnoDB tables overview
* InnoDB start:: InnoDB startup options
* Using InnoDB tables:: Using InnoDB tables
* InnoDB restrictions:: Some restrictions on @code{InnoDB} tables:
* Creating an InnoDB database:: Creating an InnoDB database. Creating an InnoDB database
* Using InnoDB tables:: Creating InnoDB tables
* Adding and removing:: Adding and removing InnoDB data and log files
* Backing up:: Backing up and recovering an InnoDB database
* Moving:: Moving an InnoDB database to another machine
* InnoDB transaction model:: InnoDB transaction model. InnoDB transaction model
* Implementation:: Implementation of multiversioning
* Table and index:: Table and index structures
* File space management:: File space management and disk i/o
* Error handling:: Error handling
* InnoDB restrictions:: Some restrictions on InnoDB tables
* InnoDB contact information:: InnoDB contact information. InnoDB contact information
MySQL Tutorial
@@ -606,7 +616,6 @@ Replication in MySQL
MySQL Full-text Search
* Fulltext Search::
* Fulltext Fine-tuning::
* Fulltext Features to Appear in MySQL 4.0::
* Fulltext TODO::
@@ -917,6 +926,7 @@ Changes in release 4.0.x (Development; Alpha)
Changes in release 3.23.x (Stable)
* News-3.23.38::
* News-3.23.37:: Changes in release 3.23.37
* News-3.23.36:: Changes in release 3.23.36
* News-3.23.35:: Changes in release 3.23.35
@@ -5461,7 +5471,7 @@ shell> ln -s mysql-VERSION-OS mysql
shell> cd mysql
shell> scripts/mysql_install_db
shell> chown -R root /usr/local/mysql
shell> chown -R mysql /usr/local/mysql/var
shell> chown -R mysql /usr/local/mysql/data
shell> chgrp -R mysql /usr/local/mysql
shell> chown -R root /usr/local/mysql/bin/
shell> bin/safe_mysqld --user=mysql &
@@ -22501,6 +22511,9 @@ locks while the thread is waiting for the @code{WRITE} lock. You should only
use @code{LOW_PRIORITY WRITE} locks if you are sure that there will
eventually be a time when no threads will have a @code{READ} lock.
@code{LOCK TABLES} and @code{UNLOCK TABLES} both commits any active
transactions.
When you use @code{LOCK TABLES}, you must lock all tables that you are
going to use and you must use the same alias that you are going to use
in your queries! If you are using a table multiple times in a query
@@ -24354,24 +24367,24 @@ limited by @code{gemini_connection_limit}. The default is 100 users.
NuSphere is working on removing these limitations.
@node InnoDB, , GEMINI, Table types
@node InnoDB, , GEMINI, Table types
@section InnoDB Tables
@menu
* InnoDB overview:: InnoDB tables overview
* InnoDB start:: InnoDB startup options
* Creating an InnoDB database:: Creating an InnoDB database
* Using InnoDB tables:: Creating InnoDB tables
* Adding and removing:: Adding and removing InnoDB data and log files
* Backing up:: Backing up and recovering an InnoDB database
* Moving:: Moving an InnoDB database to another machine
* InnoDB transaction model:: InnoDB transaction model
* Implementation:: Implementation of multiversioning
* Table and index:: Table and index structures
* File space management:: File space management and disk i/o
* Error handling:: Error handling
* InnoDB restrictions:: Some restrictions on InnoDB tables
* InnoDB contact information:: InnoDB contact information
* InnoDB overview:: InnoDB tables overview
* InnoDB start:: InnoDB startup options
* Creating an InnoDB database:: Creating an InnoDB database. Creating an InnoDB database
* Using InnoDB tables:: Creating InnoDB tables
* Adding and removing:: Adding and removing InnoDB data and log files
* Backing up:: Backing up and recovering an InnoDB database
* Moving:: Moving an InnoDB database to another machine
* InnoDB transaction model:: InnoDB transaction model. InnoDB transaction model
* Implementation:: Implementation of multiversioning
* Table and index:: Table and index structures
* File space management:: File space management and disk i/o
* Error handling:: Error handling
* InnoDB restrictions:: Some restrictions on InnoDB tables
* InnoDB contact information:: InnoDB contact information. InnoDB contact information
@end menu
@node InnoDB overview, InnoDB start, InnoDB, InnoDB
@@ -24413,7 +24426,7 @@ may consist of several files. This is different from, for example,
InnoDB is distributed under the GNU GPL License Version 2 (of June 1991).
In the source distribution of MySQL, InnoDB appears as a subdirectory.
@node InnoDB start
@node InnoDB start, Creating an InnoDB database, InnoDB overview, InnoDB
@subsection InnoDB startup options
Beginning from MySQL-3.23.37 the prefix of the options is changed
@@ -24551,7 +24564,7 @@ InnoDB cannot notice. In cases like this the timeout is useful to
resolve the situation.
@end multitable
@node Creating an InnoDB database
@node Creating an InnoDB database, Using InnoDB tables, InnoDB start, InnoDB
@subsection Creating an InnoDB database
Suppose you have installed MySQL and have edited @file{my.cnf} so that
@@ -24621,7 +24634,7 @@ some InnoDB tables, delete also the corresponding @file{.frm}
files for these tables from the MySQL database directories. Then you can
try the InnoDB database creation again.
@node Using InnoDB tables
@node Using InnoDB tables, Adding and removing, Creating an InnoDB database, InnoDB
@subsection Creating InnoDB tables
Suppose you have started the MySQL client with the command
@@ -24664,7 +24677,7 @@ InnoDB has its own internal data dictionary, and you will get problems
if the MySQL @file{.frm} files are out of 'sync' with the InnoDB
internal data dictionary.
@node Adding and removing
@node Adding and removing, Backing up, Using InnoDB tables, InnoDB
@subsection Adding and removing InnoDB data and log files
You cannot increase the size of an InnoDB data file. To add more into
@@ -24686,7 +24699,7 @@ database. Delete then the old log files from the log file directory,
edit @file{my.cnf}, and start MySQL again. InnoDB will tell
you at the startup that it is creating new log files.
@node Backing up
@node Backing up, Moving, Adding and removing, InnoDB
@subsection Backing up and recovering an InnoDB database
The key to safe database management is taking regular backups.
@@ -24798,7 +24811,7 @@ the total size of the log files as big as the buffer pool or even bigger.
The drawback in big log files is that crash recovery can last longer
because there will be more log to apply to the database.
@node Moving
@node Moving, InnoDB transaction model, Backing up, InnoDB
@subsection Moving an InnoDB database to another machine
InnoDB data and log files are binary-compatible on all platforms
@@ -24818,7 +24831,7 @@ the big rollback segment the big import transaction will generate.
Do the commit only after importing a whole table or a segment of
a table.
@node InnoDB transaction model
@node InnoDB transaction model, Implementation, Moving, InnoDB
@subsection InnoDB transaction model
In the InnoDB transaction model the goal has been to combine the best
@@ -25046,7 +25059,7 @@ set by the SQL statement may be preserved. This is because InnoDB
stores row locks in a format where it cannot afterwards know which was
set by which SQL statement.
@node Implementation
@node Implementation, Table and index, InnoDB transaction model, InnoDB
@subsection Implementation of multiversioning
Since InnoDB is a multiversioned database, it must keep information
@@ -25095,7 +25108,7 @@ its index records from the database. This removal operation is
called a purge, and it is quite fast, usually taking the same order of
time as the SQL statement which did the deletion.
@node Table and index
@node Table and index, File space management, Implementation, InnoDB
@subsection Table and index structures
Every InnoDB table has a special index called the clustered index
@@ -25208,7 +25221,7 @@ If the total length of the fields in a record is < 256 bytes, then
the pointer is 1 byte, else 2 bytes.
@end itemize
@node File space management
@node File space management, Error handling, Table and index, InnoDB
@subsection File space management and disk i/o
@subsubsection Disk i/o
@@ -25287,7 +25300,7 @@ but remember that deleted rows can be physically removed only in a
purge operation after they are no longer needed in transaction rollback or
consistent read.
@node Error handling
@node Error handling, InnoDB restrictions, File space management, InnoDB
@subsection Error handling
The error handling in InnoDB is not always the same as
@@ -25373,7 +25386,7 @@ The maximum tablespace size is 4 billion database pages. This is also
the maximum size for a table.
@end itemize
@node InnoDB contact information, , InnoDB restrictions, InnoDB
@node InnoDB contact information, , InnoDB restrictions, InnoDB
@subsection InnoDB contact information
Contact information of Innobase Oy, producer of the InnoDB engine:
@@ -29202,7 +29215,7 @@ have been assigned a low semantical value in @strong{a particular dataset}.
* Fulltext TODO::
@end menu
@node Fulltext Fine-tuning, Fulltext Features to Appear in MySQL 4.0, , Fulltext Search
@node Fulltext Fine-tuning, Fulltext Features to Appear in MySQL 4.0, Fulltext Search, Fulltext Search
@section Fine-tuning MySQL Full-text Search
Unfortunately, full-text search has no user-tunable parameters yet,
@@ -30038,9 +30051,14 @@ mysql> TRUNCATE TABLE insert_table;
mysql> UNLOCK TABLES;
@end example
You can use the @code{LOW_PRIORITY} options with @code{INSERT} if you
want to prioritize retrieval in some specific cases. @xref{INSERT, ,
@code{INSERT}}.
You can use the @code{LOW_PRIORITY} options with @code{INSERT},
@code{UPDATE} or @code{DELETE} or @code{HIGH_PRIORITY} with
@code{SELECT} if you want to prioritize retrieval in some specific
cases. You can also start @code{mysqld} with @code{--low-priority-updates}
to get the same behaveour.
Using @code{SQL_BUFFER_RESULT} can also help making table locks shorter.
@xref{SELECT}.
You could also change the locking code in @file{mysys/thr_lock.c} to use a
single queue. In this case, write locks and read locks would have the same
@@ -30058,9 +30076,11 @@ high lock speed. For large tables, table locking is MUCH better than
row locking for most applications, but there are, of course, some
pitfalls.
For @code{BDB} tables, @strong{MySQL} only uses table locking if you
explicitely lock the table with @code{LOCK TABLES} or execute a command that
will modify every row in the table, like @code{ALTER TABLE}.
For @code{BDB} and @code{InnoDB} tables, @strong{MySQL} only uses table
locking if you explicitely lock the table with @code{LOCK TABLES} or
execute a command that will modify every row in the table, like
@code{ALTER TABLE}. For these table types we recommend you to not use
@code{LOCK TABLES} at all.
In @strong{MySQL} Version 3.23.7 and above, you can insert rows into
@code{MyISAM} tables at the same time other threads are reading from the
@@ -31577,12 +31597,40 @@ the following configure options:
@multitable @columnfractions .3 .7
@item @strong{Option} @tab @strong{Comment}
@item --with-server-suffix=-max @tab Add a suffix to the @code{mysqld} version string.
@item --with-server-suffix=-Max @tab Add a suffix to the @code{mysqld} version string.
@item --with-bdb @tab Support for Berkeley DB (BDB) tables
@item --with-innodb @tab Support for InnoDB tables.
@item CFLAGS=-DUSE_SYMDIR @tab Symbolic links support for Windows.
@end multitable
Note that as Berkeley DB and InnoDB are not available for all platforms,
some of the @code{Max} binaries may not have support for both of these.
You can check which table types are supported by doing the following
query:
@example
mysql> show variables like "have_%";
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_bdb | YES |
| have_gemini | NO |
| have_innodb | NO |
| have_isam | YES |
| have_raid | YES |
| have_ssl | NO |
+---------------+-------+
@end example
The meaning of the values are:
@multitable @columnfractions .3 .7
@item @strong{Value} @tab @strong{Meaning}.
@item YES @tab The option is activated and usable.
@item NO @tab @strong{MySQL} is not compiled with support for this option.
@item DISABLED @tab The xxxx option is disabled because one started @code{mysqld} with @code{--skip-xxxx} or because one didn't start @code{mysqld} with all needed options to enable the option. In this case the @code{hostname.err} file should contain a reason for why the option is disabled.
@end multitable
@code{safe_mysqld} will automaticly try to start any @code{mysqld} binary
with the @code{-max} prefix. This makes it very easy to test out a
another @code{mysqld} binary in an existing installation. Just
@@ -31590,9 +31638,10 @@ run @code{configure} with the options you want and then install the
new @code{mysqld} binary as @code{mysqld-max} in the same directory
where your old @code{mysqld} binary is. @xref{safe_mysqld}.
The @code{mysqld-max} RPM uses this @code{safe_mysqld} feature. It just
installs the @code{mysqld-max} executable and @code{safe_mysqld} will
automaticly use this when @code{mysqld} is restarted.
The @code{mysqld-max} RPM uses the above mentioned @code{safe_mysqld}
feature. It just installs the @code{mysqld-max} executable and
@code{safe_mysqld} will automaticly use this executable when
@code{safe_mysqld} is restarted.
@cindex tools, safe_mysqld
@cindex scripts
@@ -37469,13 +37518,16 @@ default port number and socket file pathname, and the @code{--prefix} value
should specify an installation directory different than the one under which
the existing @strong{MySQL} installation is located.
You can check the socket and port used by any currently executing
@strong{MySQL} server with this command:
You can check the socket used by any currently executing @strong{MySQL} server
with this command:
@example
shell> mysqladmin -h hostname --port=port_number variables
@end example
Note that if you specify ``@code{localhost}'' as a hostname, @code{mysqladmin}
will default to using Unix sockets instead of TCP/IP.
If you have a @strong{MySQL} server running on the port you used, you will
get a list of some of the most important configurable variables in
@strong{MySQL}, including the socket name.
@@ -37526,16 +37578,17 @@ can use one of the following methods:
@itemize @bullet
@item
Start the client with @code{--host 'hostname' --port=port_numer} or
@code{[--host localhost] --socket=file_name}.
Start the client with @code{--host 'hostname' --port=port_number} to connect
with TCP/IP, or @code{[--host localhost] --socket=file_name} to connect via
a Unix socket.
@item
In your C or Perl programs, you can give the port and socket arguments
In your C or Perl programs, you can give the port or socket arguments
when connecting to the @strong{MySQL} server.
@item
If your are using the @strong{MySQL} perl DBD module you can read the options
from the @strong{MySQL} option files. @xref{Option files}.
If your are using the Perl @code{DBD::mysql} module you can read the options
from the @strong{MySQL} option files. @xref{Option files}.
@example
$dsn = "DBI:mysql:test;mysql_read_default_group=client;mysql_read_default_file=/usr/local/mysql/data/my.cnf"
@@ -37545,8 +37598,8 @@ $dbh = DBI->connect($dsn, $user, $password);
@item
@tindex MYSQL_UNIX_PORT environment variable
@tindex MYSQL_TCP_PORT environment variable
@tindex Environment variable, MYSQL_UNIX_PORT
@tindex Environment variable, MYSQL_TCP_PORT
@tindex environment variable, MYSQL_UNIX_PORT
@tindex environment variable, MYSQL_TCP_PORT
Set the @code{MYSQL_UNIX_PORT} and @code{MYSQL_TCP_PORT} environment variables
to point to the Unix socket and TCP/IP port before you start your clients.
If you normally use a specific socket or port, you should place commands
@@ -41788,7 +41841,7 @@ This is a relatively low traffic list, in comparison with
* MySQL test suite:: MySQL test suite
@end menu
@node MySQL threads, MySQL test suite, , MySQL internals
@node MySQL threads, MySQL test suite, MySQL internals, MySQL internals
@section MySQL Threads
The @strong{MySQL} server creates the following threads:
@@ -43844,6 +43897,7 @@ users uses this code as the rest of the code and because of this we are
not yet 100% confident in this code.
@menu
* News-3.23.38::
* News-3.23.37:: Changes in release 3.23.37
* News-3.23.36:: Changes in release 3.23.36
* News-3.23.35:: Changes in release 3.23.35
@@ -43885,10 +43939,29 @@ not yet 100% confident in this code.
* News-3.23.0:: Changes in release 3.23.0
@end menu
@node News-3.23.37, News-3.23.36, News-3.23.x, News-3.23.x
@node News-3.23.38, News-3.23.37, News-3.23.x, News-3.23.x
@appendixsubsec Changes in release 3.23.38
@itemize @bullet
@item
Lots of portability fixes for InnoDB.
@item
Changed optimizer so that queries like
@code{SELECT * FROM table_name,table_name2 ... ORDER BY key_part1 LIMIT #}
will use index on @code{key_part1} instead of @code{filesort}.
@item
Fixed bug when doing
@code{LOCK TABLE to_table WRITE,...; INSERT INTO to_table... SELECT ...}
when to_table was empty.
@item
Fixed bug with @code{LOCK TABLE} and BDB tables.
@end itemize
@node News-3.23.37, News-3.23.36, News-3.23.38, News-3.23.x
@appendixsubsec Changes in release 3.23.37
@itemize @bullet
@item
Fixed a bug when using @code{MATCH} in @code{HAVING} clause.
@item
Fixed a bug when using @code{HEAP} tables with @code{LIKE}.
@item
Added @code{--mysql-version} to @code{safe_mysqld}
@@ -43911,7 +43984,7 @@ with @code{SET SQL_SLAVE_SKIP_COUNTER=1; SLAVE START} after a manual sanity
check/correction of data integrity
@item
Fixed bug that erroneously logged a drop of internal temporary table
on thread termination to the binary log - bug affected replication
on thread termination to the binary log - bug affected replication
@item
Fixed a bug in @code{REGEXP()} on 64-bit machines.
@item

View File

@@ -114,6 +114,12 @@
/* pthread_attr_setscope */
#undef HAVE_PTHREAD_ATTR_SETSCOPE
/* pthread_yield that doesn't take any arguments */
#undef HAVE_PTHREAD_YIELD_ZERO_ARG
/* pthread_yield function with one argument */
#undef HAVE_PTHREAD_YIELD_ONE_ARG
/* POSIX readdir_r */
#undef HAVE_READDIR_R

View File

@@ -196,6 +196,42 @@ then
fi
])
AC_DEFUN(MYSQL_PTHREAD_YIELD,
[AC_CACHE_CHECK([if pthread_yield takes zero arguments], ac_cv_pthread_yield_zero_arg,
[AC_TRY_COMPILE([#define _GNU_SOURCE
#include <pthread.h>
#ifdef __cplusplus
extern "C"
#endif
],
[
pthread_yield();
], ac_cv_pthread_yield_zero_arg=yes, ac_cv_pthread_yield_zero_arg=yeso)])
if test "$ac_cv_pthread_yield_zero_arg" = "yes"
then
AC_DEFINE(HAVE_PTHREAD_YIELD_ZERO_ARG)
fi
]
[AC_CACHE_CHECK([if pthread_yield takes 1 argument], ac_cv_pthread_yield_one_arg,
[AC_TRY_COMPILE([#define _GNU_SOURCE
#include <pthread.h>
#ifdef __cplusplus
extern "C"
#endif
],
[
pthread_yield(0);
], ac_cv_pthread_yield_one_arg=yes, ac_cv_pthread_yield_one_arg=no)])
if test "$ac_cv_pthread_yield_one_arg" = "yes"
then
AC_DEFINE(HAVE_PTHREAD_YIELD_ONE_ARG)
fi
]
)
#---END:
AC_DEFUN(MYSQL_CHECK_FP_EXCEPT,

View File

@@ -53,6 +53,7 @@
#include <m_ctype.h>
#include <my_config.h>
#include <my_dir.h>
#include <hash.h>
#include <mysqld_error.h>
#include <stdio.h>
#include <stdlib.h>
@@ -128,6 +129,7 @@ const char* result_file = 0; /* if set, all results are concated and
typedef struct
{
char* name;
int name_len;
char* str_val;
int str_val_len;
int int_val;
@@ -137,10 +139,31 @@ typedef struct
VAR var_reg[10];
/*Perl/shell-like variable registers */
HASH var_hash;
struct connection cons[MAX_CONS];
struct connection* cur_con, *next_con, *cons_end;
/* Add new commands before Q_UNKNOWN !*/
enum enum_commands {
Q_CONNECTION=1, Q_QUERY,
Q_CONNECT, Q_SLEEP,
Q_INC, Q_DEC,
Q_SOURCE, Q_DISCONNECT,
Q_LET, Q_ECHO,
Q_WHILE, Q_END_BLOCK,
Q_SYSTEM, Q_RESULT,
Q_REQUIRE, Q_SAVE_MASTER_POS,
Q_SYNC_WITH_MASTER, Q_ERROR,
Q_SEND, Q_REAP,
Q_DIRTY_CLOSE, Q_REPLACE,
Q_PING, Q_EVAL,
Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */
Q_COMMENT_WITH_COMMAND
};
/* this should really be called command */
struct st_query
{
@@ -149,23 +172,7 @@ struct st_query
my_bool abort_on_error, require_file;
uint expected_errno[MAX_EXPECTED_ERRORS];
char record_file[FN_REFLEN];
/* Add new commands before Q_UNKNOWN */
enum { Q_CONNECTION=1, Q_QUERY,
Q_CONNECT, Q_SLEEP,
Q_INC, Q_DEC,
Q_SOURCE, Q_DISCONNECT,
Q_LET, Q_ECHO,
Q_WHILE, Q_END_BLOCK,
Q_SYSTEM, Q_RESULT,
Q_REQUIRE, Q_SAVE_MASTER_POS,
Q_SYNC_WITH_MASTER, Q_ERROR,
Q_SEND, Q_REAP,
Q_DIRTY_CLOSE, Q_REPLACE,
Q_PING, Q_EVAL,
Q_UNKNOWN, /* Unknown command. */
Q_COMMENT, /* Comments, ignored. */
Q_COMMENT_WITH_COMMAND
} type;
enum enum_commands type;
};
const char *command_names[] = {
@@ -189,6 +196,13 @@ TYPELIB command_typelib= {array_elements(command_names),"",
DYNAMIC_STRING ds_res;
static void die(const char* fmt, ...);
static void init_var_hash();
static byte* get_var_key(const byte* rec, uint* len,
my_bool __attribute__((unused)) t);
static VAR* var_init(const char* name, int name_len, const char* val,
int val_len);
static void var_free(void* v);
int dyn_string_cmp(DYNAMIC_STRING* ds, const char* fname);
void reject_dump(const char* record_file, char* buf, int size);
@@ -287,6 +301,8 @@ static void free_used_memory()
DBUG_ENTER("free_used_memory");
close_cons();
close_files();
hash_free(&var_hash);
for (i=0 ; i < q_lines.elements ; i++)
{
struct st_query **q= dynamic_element(&q_lines, i, struct st_query**);
@@ -428,10 +444,29 @@ VAR* var_get(const char* var_name, const char** var_name_end, int raw)
digit = *var_name - '0';
if (!(digit < 10 && digit >= 0))
{
const char* save_var_name = var_name, *end;
end = (var_name_end) ? *var_name_end : 0;
while(isalnum(*var_name) || *var_name == '_')
{
if(end && var_name == end)
break;
++var_name;
}
if(var_name == save_var_name)
die("Empty variable");
if(!(v = (VAR*)hash_search(&var_hash, save_var_name,
var_name - save_var_name)))
{
if (end)
*(char*)end = 0;
die("Variable '%s' used uninitialized", save_var_name);
}
--var_name;
goto err;
}
v = var_reg + digit;
else
v = var_reg + digit;
if (!raw && v->int_dirty)
{
sprintf(v->str_val, "%d", v->int_val);
@@ -448,6 +483,16 @@ err:
return 0;
}
static VAR* var_obtain(char* name, int len)
{
VAR* v;
if((v = (VAR*)hash_search(&var_hash, name, len)))
return v;
v = var_init(name, len, "", 0);
hash_insert(&var_hash, (byte*)v);
return v;
}
int var_set(char* var_name, char* var_name_end, char* var_val,
char* var_val_end)
{
@@ -463,10 +508,10 @@ int var_set(char* var_name, char* var_name_end, char* var_val,
digit = *var_name - '0';
if (!(digit < 10 && digit >= 0))
{
*var_name_end = 0;
die("Unsupported variable name: %s", var_name);
v = var_obtain(var_name, var_name_end - var_name);
}
v = var_reg + digit;
else
v = var_reg + digit;
if (v->alloced_len < (val_len = (int)(var_val_end - var_val)+1))
{
v->alloced_len = (val_len < MIN_VAR_ALLOC) ? MIN_VAR_ALLOC : val_len;
@@ -475,10 +520,12 @@ int var_set(char* var_name, char* var_name_end, char* var_val,
my_malloc(v->alloced_len, MYF(MY_WME))))
die("Out of memory");
}
memcpy(v->str_val, var_val, val_len-1);
v->str_val_len = val_len - 1;
val_len--;
memcpy(v->str_val, var_val, val_len);
v->str_val_len = val_len;
v->str_val[val_len] = 0;
v->int_val = atoi(v->str_val);
v->int_dirty=0;
return 0;
}
@@ -515,7 +562,7 @@ int eval_expr(VAR* v, const char* p, const char** p_end)
{
if ((vp = var_get(p,p_end,0)))
{
memcpy(v, vp, sizeof(VAR));
memcpy(v, vp, sizeof(*v));
return 0;
}
}
@@ -523,6 +570,8 @@ int eval_expr(VAR* v, const char* p, const char** p_end)
{
v->str_val = (char*)p;
v->str_val_len = (p_end && *p_end) ? *p_end - p : strlen(p);
v->int_val=atoi(p);
v->int_dirty=0;
return 0;
}
@@ -557,7 +606,7 @@ int do_system(struct st_query* q)
char* p=q->first_argument;
VAR v;
eval_expr(&v, p, 0); /* NULL terminated */
if (v.str_val_len > 1)
if (v.str_val_len)
{
char expr_buf[512];
if ((uint)v.str_val_len > sizeof(expr_buf) - 1)
@@ -576,11 +625,11 @@ int do_echo(struct st_query* q)
char* p=q->first_argument;
VAR v;
eval_expr(&v, p, 0); /* NULL terminated */
if (v.str_val_len > 1)
{
fflush(stdout);
write(1, v.str_val, v.str_val_len - 1);
}
if (v.str_val_len)
{
fflush(stdout);
write(1, v.str_val, v.str_val_len);
}
write(1, "\n", 1);
return 0;
}
@@ -671,15 +720,15 @@ int do_sleep(struct st_query* q)
p++;
if (*p == '.')
{
char c;
int c;
char *p_end;
p++;
p_end = p + 6;
for(;p <= p_end; ++p)
{
c = *p - '0';
if (c < 10 && c >= 0)
c = (int) (*p - '0');
if (c < 10 && (int) c >= 0)
{
t.tv_usec = t.tv_usec * 10 + c;
dec_mul /= 10;
@@ -1027,7 +1076,6 @@ int do_while(struct st_query* q)
expr_end = strrchr(expr_start, ')');
if (!expr_end)
die("missing ')' in while");
--expr_end;
eval_expr(&v, ++expr_start, &expr_end);
*cur_block++ = parser.current_line++;
if (!v.int_val)
@@ -1228,7 +1276,7 @@ static char read_query_buf[MAX_QUERY];
int read_query(struct st_query** q_ptr)
{
char *p = read_query_buf, * p1 ;
int c, expected_errno;
int expected_errno;
struct st_query* q;
if (parser.current_line < parser.read_lines)
@@ -1283,8 +1331,8 @@ int read_query(struct st_query** q_ptr)
{
p++;
p1 = q->record_file;
while(!isspace(c = *p) &&
p1 < q->record_file + sizeof(q->record_file) - 1)
while (!isspace(*p) &&
p1 < q->record_file + sizeof(q->record_file) - 1)
*p1++ = *p++;
*p1 = 0;
}
@@ -1487,7 +1535,6 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
unsigned long* lengths;
char* val;
int len;
int q_error = 0 ;
DYNAMIC_STRING *ds;
DYNAMIC_STRING ds_tmp;
DYNAMIC_STRING eval_query;
@@ -1516,8 +1563,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
else
ds= &ds_res;
if ((flags & QUERY_SEND) &&
(q_error = mysql_send_query(mysql, query, query_len)))
if ((flags & QUERY_SEND) && mysql_send_query(mysql, query, query_len))
die("At line %u: unable to send query '%s'", start_lineno, query);
if(!(flags & QUERY_REAP))
return 0;
@@ -1660,9 +1706,67 @@ void get_query_type(struct st_query* q)
type=find_type(q->query, &command_typelib, 1+2);
q->query[q->first_word_len]=save;
if (type > 0)
q->type=type; /* Found command */
q->type=(enum enum_commands) type; /* Found command */
}
static byte* get_var_key(const byte* var, uint* len,
my_bool __attribute__((unused)) t)
{
register char* key;
key = ((VAR*)var)->name;
*len = ((VAR*)var)->name_len;
return (byte*)key;
}
static VAR* var_init(const char* name, int name_len, const char* val,
int val_len)
{
int val_alloc_len;
VAR* tmp_var;
if(!name_len)
name_len = strlen(name);
if(!val_len)
val_len = strlen(val) ;
val_alloc_len = val_len + 16; /* room to grow */
if(!(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var) + val_alloc_len
+ name_len, MYF(MY_WME))))
die("Out of memory");
tmp_var->name = (char*)tmp_var + sizeof(*tmp_var);
tmp_var->str_val = tmp_var->name + name_len;
memcpy(tmp_var->name, name, name_len);
memcpy(tmp_var->str_val, val, val_len + 1);
tmp_var->name_len = name_len;
tmp_var->str_val_len = val_len;
tmp_var->alloced_len = val_alloc_len;
tmp_var->int_val = atoi(val);
tmp_var->int_dirty = 0;
return tmp_var;
}
static void var_free(void* v)
{
my_free(v, MYF(MY_WME));
}
static void var_from_env(const char* name, const char* def_val)
{
const char* tmp;
VAR* v;
if(!(tmp = getenv(name)))
tmp = def_val;
v = var_init(name, 0, tmp, 0);
hash_insert(&var_hash, (byte*)v);
}
static void init_var_hash()
{
if(hash_init(&var_hash, 1024, 0, 0, get_var_key, var_free, MYF(0)))
die("Variable hash initialization failed");
var_from_env("MASTER_MYPORT", "9306");
var_from_env("SLAVE_MYPORT", "9307");
}
int main(int argc, char** argv)
{
@@ -1678,7 +1782,7 @@ int main(int argc, char** argv)
cons_end = cons + MAX_CONS;
next_con = cons + 1;
cur_con = cons;
memset(file_stack, 0, sizeof(file_stack));
memset(&master_pos, 0, sizeof(master_pos));
file_stack_end = file_stack + MAX_INCLUDE_DEPTH;
@@ -1691,6 +1795,7 @@ int main(int argc, char** argv)
cur_block = block_stack;
init_dynamic_string(&ds_res, "", 0, 65536);
parse_args(argc, argv);
init_var_hash();
if (!*cur_file)
*cur_file = stdin;
*lineno=1;
@@ -1784,7 +1889,7 @@ int main(int argc, char** argv)
case Q_REPLACE:
get_replace(q);
break;
case Q_SAVE_MASTER_POS: do_save_master_pos(q); break;
case Q_SAVE_MASTER_POS: do_save_master_pos(); break;
case Q_SYNC_WITH_MASTER: do_sync_with_master(q); break;
case Q_COMMENT: /* Ignore row */
case Q_COMMENT_WITH_COMMAND:

View File

@@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_INIT(sql/mysqld.cc)
AC_CANONICAL_SYSTEM
# The Docs Makefile.am parses this line!
AM_INIT_AUTOMAKE(mysql, 3.23.37)
AM_INIT_AUTOMAKE(mysql, 3.23.38)
AM_CONFIG_HEADER(config.h)
PROTOCOL_VERSION=10
@@ -1293,10 +1293,11 @@ MYSQL_CXX_BOOL
MYSQL_CHECK_LONGLONG_TO_FLOAT
if test "$ac_cv_conv_longlong_to_float" != "yes"
then
AC_MSG_ERROR([Your compiler can't convert a longlong value to a float!
AC_MSG_ERROR([Your compiler cannot convert a longlong value to a float!
If you are using gcc 2.8.# you should upgrade to egcs 1.0.3 or newer and try
again]);
fi
MYSQL_PTHREAD_YIELD
######################################################################
# For readline-4.0 (We simply move the mimimum amount of stuff from
@@ -1353,7 +1354,7 @@ AC_CHECK_FUNCS(alarm bmove \
sigset sigthreadmask pthread_sigmask pthread_setprio pthread_setprio_np \
pthread_setschedparam pthread_attr_setprio pthread_attr_setschedparam \
pthread_attr_create pthread_getsequence_np pthread_attr_setstacksize \
pthread_condattr_create rwlock_init pthread_rwlock_rdlock pthread_yield\
pthread_condattr_create rwlock_init pthread_rwlock_rdlock \
fchmod getpass getpassphrase initgroups mlockall)
# Sanity check: We chould not have any fseeko symbol unless

View File

@@ -7,14 +7,59 @@ AM_INIT_AUTOMAKE(ib, 0.90)
AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_CHECK_HEADERS(aio.h)
AC_CHECK_HEADERS(aio.h sched.h)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_FUNCS(sched_yield)
AC_C_INLINE
AC_C_BIGENDIAN
# Build optimized or debug version ?
# First check for gcc and g++
if test "$ac_cv_prog_gcc" = "yes"
then
DEBUG_CFLAGS="-g"
DEBUG_OPTIMIZE_CC="-O"
OPTIMIZE_CFLAGS="$MAX_C_OPTIMIZE"
else
DEBUG_CFLAGS="-g"
DEBUG_OPTIMIZE_CC=""
OPTIMIZE_CFLAGS="-O"
fi
if test "$ac_cv_prog_cxx_g" = "yes"
then
DEBUG_CXXFLAGS="-g"
DEBUG_OPTIMIZE_CXX="-O"
OPTIMIZE_CXXFLAGS="-O3"
else
DEBUG_CXXFLAGS="-g"
DEBUG_OPTIMIZE_CXX=""
OPTIMIZE_CXXFLAGS="-O"
fi
AC_ARG_WITH(debug,
[ --without-debug Build a production version without debugging code],
[with_debug=$withval],
[with_debug=no])
if test "$with_debug" = "yes"
then
# Medium debug.
CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC -DDBUG_ON -DSAFE_MUTEX $CFLAGS"
CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DSAFE_MUTEX $CXXFLAGS"
elif test "$with_debug" = "full"
then
# Full debug. Very slow in some cases
CFLAGS="$DEBUG_CFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS"
CXXFLAGS="$DEBUG_CXXFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS"
else
# Optimized version. No debug
CFLAGS="$OPTIMIZE_CFLAGS -DDBUG_OFF $CFLAGS -DDEBUG_OFF"
CXXFLAGS="$OPTIMIZE_CXXFLAGS -DDBUG_OFF $CXXFLAGS -DDEBUG_OFF"
fi
case "$target_os" in
hp*) AC_DEFINE(UNIV_MUST_NOT_INLINE, 1,
No inlining because gcc broken on HP-UX);;
*sgi-irix*) AC_DEFINE(UNIV_MUST_NOT_INLINE, 1,
No inlining because cc broken on irix);;
esac
AC_OUTPUT(Makefile os/Makefile ut/Makefile btr/Makefile

View File

@@ -1,25 +0,0 @@
/* ib_config.h. Generated automatically by configure. */
/* ib_config.h.in. Generated automatically from configure.in by autoheader. */
/* Define as __inline if that's what the C compiler calls it. */
/* #undef inline */
/* Define if your processor stores words with the most significant
byte first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef WORDS_BIGENDIAN */
/* The number of bytes in a int. */
#define SIZEOF_INT 4
/* Define if you have the <aio.h> header file. */
#define HAVE_AIO_H 1
/* Name of package */
#define PACKAGE "ib"
/* Version number of package */
#define VERSION "0.90"
/* No inlining because gcc broken on HP-UX */
/* #undef UNIV_MUST_NOT_INLINE */

View File

@@ -1,24 +0,0 @@
/* ib_config.h.in. Generated automatically from configure.in by autoheader. */
/* Define as __inline if that's what the C compiler calls it. */
#undef inline
/* Define if your processor stores words with the most significant
byte first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
/* The number of bytes in a int. */
#undef SIZEOF_INT
/* Define if you have the <aio.h> header file. */
#undef HAVE_AIO_H
/* Name of package */
#undef PACKAGE
/* Version number of package */
#undef VERSION
/* No inlining because gcc broken on HP-UX */
#undef UNIV_MUST_NOT_INLINE

View File

@@ -4,7 +4,5 @@ libsdir = ../libs
INCLUDES = -I../../include -I../include
CFLAGS= -g -O2 -DDEBUG_OFF
# Don't update the files from bitkeeper
%::SCCS/s.%

View File

@@ -117,7 +117,6 @@ que_thr_stop(
/**************************************************************************
Moves a thread from another state to the QUE_THR_RUNNING state. Increments
the n_active_thrs counters of the query graph and transaction. */
UNIV_INLINE
void
que_thr_move_to_run_state_for_mysql(
/*================================*/
@@ -126,7 +125,6 @@ que_thr_move_to_run_state_for_mysql(
/**************************************************************************
A patch for MySQL used to 'stop' a dummy query thread used in MySQL
select, when there is no error or lock wait. */
UNIV_INLINE
void
que_thr_stop_for_mysql_no_error(
/*============================*/

View File

@@ -256,49 +256,3 @@ que_graph_is_select(
return(FALSE);
}
/**************************************************************************
Moves a thread from another state to the QUE_THR_RUNNING state. Increments
the n_active_thrs counters of the query graph and transaction if thr was
not active. */
UNIV_INLINE
void
que_thr_move_to_run_state_for_mysql(
/*================================*/
que_thr_t* thr, /* in: an query thread */
trx_t* trx) /* in: transaction */
{
if (!thr->is_active) {
(thr->graph)->n_active_thrs++;
trx->n_active_thrs++;
thr->is_active = TRUE;
ut_ad((thr->graph)->n_active_thrs == 1);
ut_ad(trx->n_active_thrs == 1);
}
thr->state = QUE_THR_RUNNING;
}
/**************************************************************************
A patch for MySQL used to 'stop' a dummy query thread used in MySQL
select, when there is no error or lock wait. */
UNIV_INLINE
void
que_thr_stop_for_mysql_no_error(
/*============================*/
que_thr_t* thr, /* in: query thread */
trx_t* trx) /* in: transaction */
{
ut_ad(thr->state == QUE_THR_RUNNING);
thr->state = QUE_THR_COMPLETED;
thr->is_active = FALSE;
(thr->graph)->n_active_thrs--;
trx->n_active_thrs--;
}

View File

@@ -55,6 +55,7 @@ Calling this function is obligatory only if the memory buffer containing
the mutex is freed. Removes a mutex object from the mutex list. The mutex
is checked to be in the reset state. */
#undef mutex_free /* Fix for MacOS X */
void
mutex_free(
/*=======*/

View File

@@ -39,6 +39,10 @@ subdirectory of 'mysql'. */
/* Include the header file generated by GNU autoconf */
#include "../ib_config.h"
#ifdef HAVE_SCHED_H
#include <sched.h>
#endif
#ifdef HAVE_PREAD
#define HAVE_PWRITE
#endif

View File

@@ -137,8 +137,12 @@ os_thread_yield(void)
{
#if defined(__WIN__)
Sleep(0);
#elif defined(HAVE_PTHREAD_YIELD)
#elif (defined(HAVE_SCHED_YIELD) && defined(HAVE_SCHED_H))
sched_yield();
#elif defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
pthread_yield();
#elif defined(HAVE_PTHREAD_YIELD_ONE_ARG)
pthread_yield(0);
#else
os_thread_sleep(0);
#endif

View File

@@ -1068,6 +1068,51 @@ que_thr_stop_for_mysql(
mutex_exit(&kernel_mutex);
}
/**************************************************************************
Moves a thread from another state to the QUE_THR_RUNNING state. Increments
the n_active_thrs counters of the query graph and transaction if thr was
not active. */
void
que_thr_move_to_run_state_for_mysql(
/*================================*/
que_thr_t* thr, /* in: an query thread */
trx_t* trx) /* in: transaction */
{
if (!thr->is_active) {
(thr->graph)->n_active_thrs++;
trx->n_active_thrs++;
thr->is_active = TRUE;
ut_ad((thr->graph)->n_active_thrs == 1);
ut_ad(trx->n_active_thrs == 1);
}
thr->state = QUE_THR_RUNNING;
}
/**************************************************************************
A patch for MySQL used to 'stop' a dummy query thread used in MySQL
select, when there is no error or lock wait. */
void
que_thr_stop_for_mysql_no_error(
/*============================*/
que_thr_t* thr, /* in: query thread */
trx_t* trx) /* in: transaction */
{
ut_ad(thr->state == QUE_THR_RUNNING);
thr->state = QUE_THR_COMPLETED;
thr->is_active = FALSE;
(thr->graph)->n_active_thrs--;
trx->n_active_thrs--;
}
/**************************************************************************
Prints info of an SQL query graph node. */

View File

@@ -83,9 +83,9 @@ ctype_extra_sources.c: conf_to_src
$(srcdir)/ctype_extra_sources.c
conf_to_src_SOURCES = conf_to_src.c
conf_to_src_LDADD=
#for --with-other-libc to ensure static linking
#note -all-static rather than -static
#this is needed for libtool to work right
conf_to_src_LDFLAGS=-all-static
#force static linking of conf_to_src - essential when linking against
#custom installation of libc
conf_to_src_LDFLAGS=@NOINST_LDFLAGS@
# Don't update the files from bitkeeper
%::SCCS/s.%

View File

@@ -335,11 +335,10 @@ int _mi_readinfo(register MI_INFO *info, int lock_type, int check_keybuffer)
int _mi_writeinfo(register MI_INFO *info, uint operation)
{
int error,olderror;
MYISAM_SHARE *share;
MYISAM_SHARE *share=info->s;
DBUG_ENTER("_mi_writeinfo");
error=0;
share=info->s;
if (share->r_locks == 0 && share->w_locks == 0)
{
olderror=my_errno; /* Remember last error */
@@ -368,7 +367,7 @@ int _mi_writeinfo(register MI_INFO *info, uint operation)
{
share->changed= 1; /* Mark keyfile changed */
}
DBUG_RETURN(error);
DBUG_RETURN(error);
} /* _mi_writeinfo */

View File

@@ -27,7 +27,7 @@ CLEANFILES = $(test_SCRIPTS)
dist-hook:
mkdir -p $(distdir)/t $(distdir)/r $(distdir)/include \
$(distdir)/std_data
$(INSTALL_DATA) $(srcdir)/t/*.test $(srcdir)/t/*.opt $(distdir)/t
$(INSTALL_DATA) $(srcdir)/t/*.test $(srcdir)/t/*.opt $(srcdir)/t/*.sh $(distdir)/t
$(INSTALL_DATA) $(srcdir)/include/*.inc $(distdir)/include
$(INSTALL_DATA) $(srcdir)/r/*.result $(srcdir)/r/*.require $(distdir)/r
$(INSTALL_DATA) $(srcdir)/std_data/*.dat $(distdir)/std_data

View File

@@ -1,3 +0,0 @@
-- require r/have_default_master.require
connection master;
show variables like "port";

View File

@@ -202,6 +202,9 @@ SLAVE_MYERR="$MYSQL_TEST_DIR/var/log/mysqld-slave.err"
SMALL_SERVER="-O key_buffer_size=1M -O sort_buffer=256K -O max_heap_table_size=1M"
export MASTER_MYPORT
export SLAVE_MYPORT
if [ x$SOURCE_DIST = x1 ] ; then
MY_BASEDIR=$MYSQL_TEST_DIR
else

View File

@@ -492,3 +492,20 @@ a 1
a 2
MIN(B) MAX(b)
1 1
id
0
1
2
id
0
1
2
id
0
1
2
id id3
0 0
1 1
2 2
100 2

View File

@@ -1,2 +0,0 @@
Variable_name Value
port 9306

View File

@@ -449,3 +449,20 @@ a
1
table type possible_keys key key_len ref rows Extra
t1 range PRIMARY PRIMARY 4 NULL 1 where used
id
0
1
2
id
0
1
2
id
0
1
2
id id3
0 0
1 1
2 2
100 2

View File

@@ -1,2 +1,6 @@
dummy1 count(distinct id)
NULL 1
Table Op Msg_type Msg_text
test.t1 check status OK
Table Op Msg_type Msg_text
test.t2 check error Table 't2' was not locked with LOCK TABLES

View File

@@ -5,8 +5,6 @@ sum(length(word))
71
(@id := id) - id
0
Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter
127.0.0.1 root 9999 1 master-bin.001 939 No 1053 Slave: query ' update t1 set n = n + get_lock('crash_lock', 2)' partially completed on the master and was aborted. There is a chance that your master is inconsistent at this point. If you are sure that your master is ok, run this query manually on the slave and then restart the slave with SET SQL_SLAVE_SKIP_COUNTER=1; SLAVE START; 0
count(*)
10
n

View File

@@ -678,3 +678,30 @@ CREATE TABLE t1 (
INSERT INTO t1 VALUES (1, 1);
SELECT MIN(B),MAX(b) FROM t1 WHERE t1.a = 1;
drop table t1;
#
# Test problem with BDB and lock tables with duplicate write.
#
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) type=bdb;
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
LOCK TABLES t1 WRITE;
--error 690
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
select id from t1;
select id from t1;
UNLOCK TABLES;
DROP TABLE t1;
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) type=bdb;
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
LOCK TABLES t1 WRITE;
begin;
--error 690
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
select id from t1;
insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
commit;
select id,id3 from t1;
UNLOCK TABLES;
DROP TABLE t1;

View File

@@ -429,3 +429,30 @@ create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h
insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
explain select * from t1 where a > 0 and a < 50;
drop table t1;
#
# Test lock tables
#
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) type=innodb;
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
LOCK TABLES t1 WRITE;
--error 690
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
select id from t1;
select id from t1;
UNLOCK TABLES;
DROP TABLE t1;
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) type=innodb;
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
LOCK TABLES t1 WRITE;
begin;
--error 690
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
select id from t1;
insert ignore into t1 values (100,1,2,'D'),(1,1,99,'D');
commit;
select id,id3 from t1;
UNLOCK TABLES;
DROP TABLE t1;

View File

@@ -21,3 +21,35 @@ LOCK TABLE t1 WRITE,t2 write;
insert into t2 SELECT * from t1;
update t1 set id=1 where id=-1;
drop table t1,t2;
#
# Check bug with INSERT ... SELECT with lock tables
#
CREATE TABLE t1 (
index1 smallint(6) default NULL,
nr smallint(6) default NULL,
KEY index1(index1)
) TYPE=MyISAM;
CREATE TABLE t2 (
nr smallint(6) default NULL,
name varchar(20) default NULL
) TYPE=MyISAM;
INSERT INTO t2 VALUES (1,'item1');
INSERT INTO t2 VALUES (2,'item2');
# problem begins here!
lock tables t1 write, t2 read;
insert into t1 select 1,nr from t2 where name='item1';
insert into t1 select 2,nr from t2 where name='item2';
unlock tables;
check table t1;
# Check error message
lock tables t1 write;
check table t2;
unlock tables;
drop table t1,t2;

View File

@@ -1,22 +1,21 @@
source include/master-slave.inc;
connection master;
use test;
drop table if exists t1;
drop table if exists t1,t3;
create table t1 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t1;
drop table if exists foo;
set password = password('foo');
set password = password('');
create table foo(n int);
insert into foo values(1),(2);
create table t3(n int);
insert into t3 values(1),(2);
save_master_pos;
connection slave;
sync_with_master;
use test;
select * from foo;
select * from t3;
select sum(length(word)) from t1;
connection master;
drop table t1;
drop table t1,t3;
save_master_pos;
connection slave;
sync_with_master;
@@ -59,8 +58,12 @@ connection slave;
sync_with_master ;
#give the slave a chance to exit
sleep 0.5;
--replace_result 9306 9999 3334 9999 3335 9999
show slave status;
# The following test can't be done because the result of Pos will differ
# on different computers
# --replace_result 9306 9999 3334 9999 3335 9999
# show slave status;
set sql_slave_skip_counter=1;
slave start;
select count(*) from t1;

View File

@@ -1,5 +1,4 @@
source include/master-slave.inc;
source include/have_default_master.inc;
connection master;
show master status;
save_master_pos;

View File

@@ -1,6 +1,5 @@
connect (master,localhost,root,,test,0,mysql-master.sock);
connect (slave,localhost,root,,test,0, mysql-slave.sock);
source include/have_default_master.inc;
connection master;
reset master;
show master status;
@@ -10,22 +9,22 @@ reset slave;
show slave status;
change master to master_host='127.0.0.1';
show slave status;
change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=9306;
eval change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=$MASTER_MYPORT;
show slave status;
slave start;
sync_with_master;
show slave status;
connection master;
drop table if exists foo;
create table foo (n int);
insert into foo values (10),(45),(90);
drop table if exists t1;
create table t1 (n int);
insert into t1 values (10),(45),(90);
save_master_pos;
connection slave;
sync_with_master;
select * from foo;
select * from t1;
connection master;
drop table foo;
drop table t1;
save_master_pos;
connection slave;
sync_with_master;

View File

@@ -1,15 +1,16 @@
connect (master,localhost,root,,test,0,mysql-master.sock);
connect (slave,localhost,root,,test,0,mysql-slave.sock);
source include/have_default_master.inc;
system cat /dev/null > var/slave-data/master.info;
system chmod 000 var/slave-data/master.info;
connection slave;
!slave start;
system chmod 600 var/slave-data/master.info;
!slave start;
!change master to master_host='127.0.0.1',master_port=9306,master_user='root';
!eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT,
master_user='root';
reset slave;
!change master to master_host='127.0.0.1',master_port=9306,master_user='root';
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT,
master_user='root';
connection master;
reset master;
connection slave;

View File

@@ -105,7 +105,7 @@ $CP mysql-test/mysql-test-run mysql-test/install_test_db $BASE/mysql-test/
$CP mysql-test/README $BASE/mysql-test/README
$CP mysql-test/include/*.inc $BASE/mysql-test/include
$CP mysql-test/std_data/*.dat $BASE/mysql-test/std_data
$CP mysql-test/t/*.test mysql-test/t/*.opt $BASE/mysql-test/t
$CP mysql-test/t/*.test mysql-test/t/*.opt mysql-test/t/*.sh $BASE/mysql-test/t
$CP mysql-test/r/*.result mysql-test/r/*.require $BASE/mysql-test/r
$CP scripts/* $BASE/bin

View File

@@ -85,6 +85,7 @@ if test -x "$basedir/libexec/mysqld"
then
execdir="$basedir/libexec"
elif test -x "@libexecdir@/mysqld"
then
execdir="@libexecdir@"
else
execdir="$basedir/bin"

View File

@@ -36,7 +36,7 @@ while ($#ARGV >= $[ && $ARGV[0] =~ /^-/) {
{
$opt_a = 1;
}
elsif ($ARGV[0] eq "-?" || $ARGV[0] eq "-I")
elsif ($ARGV[0] eq "-?" || $ARGV[0] eq "-I" || $ARGV[0] eq "--help")
{
&usage;
}
@@ -107,7 +107,7 @@ EOF
sub usage {
print <<EOF;
Usage: $0 [-signal] [-?Ift] pattern
Usage: $0 [-signal] [-?Ift] [--help] pattern
Options: -I or -? "info" -f "force" -t "test".
Version 1.0

View File

@@ -39,11 +39,6 @@ $opt_read_key_loop_count=$opt_loop_count;
chomp($pwd = `pwd`); $pwd = "." if ($pwd eq '');
require "$pwd/bench-init.pl" || die "Can't read Configuration file: $!\n";
if ($opt_loop_count < 256)
{
$opt_loop_count=256; # Some tests must have some data to work!
}
if ($opt_small_test)
{
$opt_loop_count/=100;
@@ -62,6 +57,13 @@ elsif ($opt_small_key_tables)
$many_keys_loop_count/=10;
}
if ($opt_loop_count < 100)
{
$opt_loop_count=100; # Some tests must have some data to work!
}
$range_loop_count=min($opt_loop_count,$range_loop_count);
print "Testing the speed of inserting data into 1 table and do some selects on it.\n";
print "The tests are done with a table that has $opt_loop_count rows.\n\n";

View File

@@ -41,10 +41,9 @@
from the updated tables.
Testing of:
- LOCK TABLES
- Mark tables that participate in a transaction so that they are not
closed during the transaction. We need to test what happens if
MySQL closes a table that is updated by a not commit transaction.
MySQL closes a table that is updated by a not commited transaction.
*/
@@ -1701,12 +1700,35 @@ int ha_berkeley::external_lock(THD *thd, int lock_type)
DBUG_PRINT("trans",("commiting non-updating transaction"));
error=txn_commit((DB_TXN*) thd->transaction.stmt.bdb_tid,0);
thd->transaction.stmt.bdb_tid=0;
transaction=0;
}
}
}
DBUG_RETURN(error);
}
/*
When using LOCK TABLE's external_lock is only called when the actual
TABLE LOCK is done.
Under LOCK TABLES, each used tables will force a call to start_stmt.
*/
int ha_berkeley::start_stmt(THD *thd)
{
int error=0;
DBUG_ENTER("ha_berkeley::start_stmt");
if (!thd->transaction.stmt.bdb_tid)
{
error=txn_begin(db_env, (DB_TXN*) thd->transaction.all.bdb_tid,
(DB_TXN**) &thd->transaction.stmt.bdb_tid,
0);
transaction= (DB_TXN*) thd->transaction.stmt.bdb_tid;
}
DBUG_RETURN(error);
}
/*
The idea with handler::store_lock() is the following:

View File

@@ -136,6 +136,7 @@ class ha_berkeley: public handler
int extra(enum ha_extra_function operation);
int reset(void);
int external_lock(THD *thd, int lock_type);
int start_stmt(THD *thd);
void position(byte *record);
int analyze(THD* thd,HA_CHECK_OPT* check_opt);
int optimize(THD* thd, HA_CHECK_OPT* check_opt);

View File

@@ -533,7 +533,8 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
VOID(fn_format(fixed_name,file->filename,"",MI_NAME_IEXT,
4+ (param.opt_follow_links ? 16 : 0)));
if (mi_lock_database(file,F_WRLCK))
// Don't lock tables if we have used LOCK TABLE
if (!thd->locked_tables && mi_lock_database(file,F_WRLCK))
{
mi_check_print_error(&param,ER(ER_CANT_LOCK),my_errno);
DBUG_RETURN(HA_ADMIN_FAILED);
@@ -615,7 +616,8 @@ int ha_myisam::repair(THD *thd, MI_CHECK &param, bool optimize)
update_state_info(&param, file, 0);
}
thd->proc_info=old_proc_info;
mi_lock_database(file,F_UNLCK);
if (!thd->locked_tables)
mi_lock_database(file,F_UNLCK);
DBUG_RETURN(error ? HA_ADMIN_FAILED :
!optimize_done ? HA_ADMIN_ALREADY_DONE : HA_ADMIN_OK);
}

View File

@@ -265,6 +265,7 @@ public:
virtual int extra(enum ha_extra_function operation)=0;
virtual int reset()=0;
virtual int external_lock(THD *thd, int lock_type)=0;
virtual int start_stmt(THD *thd) {return 0;}
virtual int delete_all_rows();
virtual longlong get_auto_increment();
virtual void update_create_info(HA_CREATE_INFO *create_info) {}
@@ -344,6 +345,7 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info,
bool update_create_info);
int ha_delete_table(enum db_type db_type, const char *path);
void ha_key_cache(void);
int ha_start_stmt(THD *thd);
int ha_commit_trans(THD *thd, THD_TRANS *trans);
int ha_rollback_trans(THD *thd, THD_TRANS *trans);
int ha_autocommit_or_rollback(THD *thd, int error);

View File

@@ -1399,6 +1399,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
&refresh)) && refresh) ;
if (table)
{
int error;
table_list->table=table;
table->grant= table_list->grant;
if (thd->locked_tables)
@@ -1410,7 +1411,12 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
my_printf_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,
ER(ER_TABLE_NOT_LOCKED_FOR_WRITE),
MYF(0),table_list->name);
DBUG_RETURN(0);
table=0;
}
else if ((error=table->file->start_stmt(thd)))
{
table->file->print_error(error,MYF(0));
table=0;
}
thd->proc_info=0;
DBUG_RETURN(table);
@@ -1437,10 +1443,10 @@ int open_and_lock_tables(THD *thd,TABLE_LIST *tables)
int lock_tables(THD *thd,TABLE_LIST *tables)
{
TABLE_LIST *table;
if (tables && !thd->locked_tables)
{
uint count=0;
TABLE_LIST *table;
for (table = tables ; table ; table=table->next)
count++;
TABLE **start,**ptr;
@@ -1451,6 +1457,18 @@ int lock_tables(THD *thd,TABLE_LIST *tables)
if (!(thd->lock=mysql_lock_tables(thd,start,count)))
return -1; /* purecov: inspected */
}
else
{
for (table = tables ; table ; table=table->next)
{
int error;
if ((error=table->table->file->start_stmt(thd)))
{
table->table->file->print_error(error,MYF(0));
return -1;
}
}
}
return 0;
}

View File

@@ -1830,6 +1830,7 @@ mysql_execute_command(void)
{
thd->lock=thd->locked_tables;
thd->locked_tables=0; // Will be automaticly closed
end_active_trans(thd);
}
if (thd->global_read_lock)
{

View File

@@ -528,9 +528,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
if (order &&
(join.const_tables == join.tables ||
test_if_skip_sort_order(&join.join_tab[join.const_tables], order,
(having || group ||
join.const_tables != join.tables - 1) ?
HA_POS_ERROR : thd->select_limit)))
(group ? HA_POS_ERROR : thd->select_limit))))
order=0;
select_describe(&join,need_tmp,
(order != 0 &&
@@ -2527,7 +2525,6 @@ join_free(JOIN *join)
delete tab->select;
delete tab->quick;
x_free(tab->cache.buff);
end_read_record(&tab->read_record);
if (tab->table)
{
if (tab->table->key_read)
@@ -2535,8 +2532,11 @@ join_free(JOIN *join)
tab->table->key_read=0;
tab->table->file->extra(HA_EXTRA_NO_KEYREAD);
}
tab->table->file->index_end();
/* Don't free index if we are using read_record */
if (!tab->read_record.table)
tab->table->file->index_end();
}
end_read_record(&tab->read_record);
}
join->table=0;
}

View File

@@ -66,22 +66,22 @@ uchar NEAR to_lower_ujis[]=
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', '{', '|', '}', '~', '\177',
'\200','\201','\202','\203','\204','\205','\206','\207',
'\210','\211','\212','\213','\214','\215','\216','\217',
'\220','\221','\222','\223','\224','\225','\226','\227',
'\230','\231','\232','\233','\234','\235','\236','\237',
'\240','\241','\242','\243','\244','\245','\246','\247',
'\250','\251','\252','\253','\254','\255','\256','\257',
'\260','\261','\262','\263','\264','\265','\266','\267',
'\270','\271','\272','\273','\274','\275','\276','\277',
'\300','\301','\302','\303','\304','\305','\306','\307',
'\310','\311','\312','\313','\314','\315','\316','\317',
'\320','\321','\322','\323','\324','\325','\326','\327',
'\330','\331','\332','\333','\334','\335','\336','\337',
'\340','\341','\342','\343','\344','\345','\346','\347',
'\350','\351','\352','\353','\354','\355','\356','\357',
'\360','\361','\362','\363','\364','\365','\366','\367',
'\370','\371','\372','\373','\374','\375','\376','\377',
(uchar) '\200',(uchar) '\201',(uchar) '\202',(uchar) '\203',(uchar) '\204',(uchar) '\205',(uchar) '\206',(uchar) '\207',
(uchar) '\210',(uchar) '\211',(uchar) '\212',(uchar) '\213',(uchar) '\214',(uchar) '\215',(uchar) '\216',(uchar) '\217',
(uchar) '\220',(uchar) '\221',(uchar) '\222',(uchar) '\223',(uchar) '\224',(uchar) '\225',(uchar) '\226',(uchar) '\227',
(uchar) '\230',(uchar) '\231',(uchar) '\232',(uchar) '\233',(uchar) '\234',(uchar) '\235',(uchar) '\236',(uchar) '\237',
(uchar) '\240',(uchar) '\241',(uchar) '\242',(uchar) '\243',(uchar) '\244',(uchar) '\245',(uchar) '\246',(uchar) '\247',
(uchar) '\250',(uchar) '\251',(uchar) '\252',(uchar) '\253',(uchar) '\254',(uchar) '\255',(uchar) '\256',(uchar) '\257',
(uchar) '\260',(uchar) '\261',(uchar) '\262',(uchar) '\263',(uchar) '\264',(uchar) '\265',(uchar) '\266',(uchar) '\267',
(uchar) '\270',(uchar) '\271',(uchar) '\272',(uchar) '\273',(uchar) '\274',(uchar) '\275',(uchar) '\276',(uchar) '\277',
(uchar) '\300',(uchar) '\301',(uchar) '\302',(uchar) '\303',(uchar) '\304',(uchar) '\305',(uchar) '\306',(uchar) '\307',
(uchar) '\310',(uchar) '\311',(uchar) '\312',(uchar) '\313',(uchar) '\314',(uchar) '\315',(uchar) '\316',(uchar) '\317',
(uchar) '\320',(uchar) '\321',(uchar) '\322',(uchar) '\323',(uchar) '\324',(uchar) '\325',(uchar) '\326',(uchar) '\327',
(uchar) '\330',(uchar) '\331',(uchar) '\332',(uchar) '\333',(uchar) '\334',(uchar) '\335',(uchar) '\336',(uchar) '\337',
(uchar) '\340',(uchar) '\341',(uchar) '\342',(uchar) '\343',(uchar) '\344',(uchar) '\345',(uchar) '\346',(uchar) '\347',
(uchar) '\350',(uchar) '\351',(uchar) '\352',(uchar) '\353',(uchar) '\354',(uchar) '\355',(uchar) '\356',(uchar) '\357',
(uchar) '\360',(uchar) '\361',(uchar) '\362',(uchar) '\363',(uchar) '\364',(uchar) '\365',(uchar) '\366',(uchar) '\367',
(uchar) '\370',(uchar) '\371',(uchar) '\372',(uchar) '\373',(uchar) '\374',(uchar) '\375',(uchar) '\376',(uchar) '\377'
};
uchar NEAR to_upper_ujis[]=
@@ -117,7 +117,7 @@ uchar NEAR to_upper_ujis[]=
(uchar) '\340',(uchar) '\341',(uchar) '\342',(uchar) '\343',(uchar) '\344',(uchar) '\345',(uchar) '\346',(uchar) '\347',
(uchar) '\350',(uchar) '\351',(uchar) '\352',(uchar) '\353',(uchar) '\354',(uchar) '\355',(uchar) '\356',(uchar) '\357',
(uchar) '\360',(uchar) '\361',(uchar) '\362',(uchar) '\363',(uchar) '\364',(uchar) '\365',(uchar) '\366',(uchar) '\367',
(uchar) '\370',(uchar) '\371',(uchar) '\372',(uchar) '\373',(uchar) '\374',(uchar) '\375',(uchar) '\376',(uchar) '\377',
(uchar) '\370',(uchar) '\371',(uchar) '\372',(uchar) '\373',(uchar) '\374',(uchar) '\375',(uchar) '\376',(uchar) '\377'
};
uchar NEAR sort_order_ujis[]=
@@ -153,7 +153,7 @@ uchar NEAR sort_order_ujis[]=
(uchar) '\340',(uchar) '\341',(uchar) '\342',(uchar) '\343',(uchar) '\344',(uchar) '\345',(uchar) '\346',(uchar) '\347',
(uchar) '\350',(uchar) '\351',(uchar) '\352',(uchar) '\353',(uchar) '\354',(uchar) '\355',(uchar) '\356',(uchar) '\357',
(uchar) '\360',(uchar) '\361',(uchar) '\362',(uchar) '\363',(uchar) '\364',(uchar) '\365',(uchar) '\366',(uchar) '\367',
(uchar) '\370',(uchar) '\371',(uchar) '\372',(uchar) '\373',(uchar) '\374',(uchar) '\375', (uchar) (uchar) '\376', (uchar) '\377',
(uchar) '\370',(uchar) '\371',(uchar) '\372',(uchar) '\373',(uchar) '\374',(uchar) '\375', (uchar) (uchar) '\376', (uchar) '\377'
};