This commit is contained in:
guilhem@mysql.com 2005-02-05 18:07:50 +01:00
commit a70adb5d2a
6 changed files with 56 additions and 45 deletions

View File

@ -918,9 +918,11 @@ if test "$ac_cv_header_termio_h" = "no" -a "$ac_cv_header_termios_h" = "no"
then then
AC_CHECK_FUNC(gtty, , AC_CHECK_LIB(compat, gtty)) AC_CHECK_FUNC(gtty, , AC_CHECK_LIB(compat, gtty))
fi fi
# We make a special variable for client library's to avoid including
# thread libs in the client. # We make a special variable for non-threaded version of LIBS to avoid
NON_THREADED_CLIENT_LIBS="$LIBS $ZLIB_LIBS" # including thread libs into non-threaded version of MySQL client library.
# Later in this script LIBS will be augmented with a threads library.
NON_THREADED_LIBS="$LIBS"
AC_MSG_CHECKING([for int8]) AC_MSG_CHECKING([for int8])
case $SYSTEM_TYPE in case $SYSTEM_TYPE in
@ -1497,7 +1499,7 @@ then
if test -f /usr/lib/libxnet.so -a "$SYSTEM_TYPE" = "sni-sysv4" if test -f /usr/lib/libxnet.so -a "$SYSTEM_TYPE" = "sni-sysv4"
then then
LIBS="-lxnet $LIBS" LIBS="-lxnet $LIBS"
NON_THREADED_CLIENT_LIBS="$NON_THREADED_CLIENT_LIBS -lxnet" NON_THREADED_LIBS="-lxnet $NON_THREADED_LIBS"
with_named_thread="-Kthread $LDFLAGS -lxnet" with_named_thread="-Kthread $LDFLAGS -lxnet"
LD_FLAGS="" LD_FLAGS=""
CFLAGS="-Kthread $CFLAGS" CFLAGS="-Kthread $CFLAGS"
@ -2444,7 +2446,7 @@ dnl This probably should be cleaned up more - for now the threaded
dnl client is just using plain-old libs. dnl client is just using plain-old libs.
sql_client_dirs="libmysql strings regex client" sql_client_dirs="libmysql strings regex client"
linked_client_targets="linked_libmysql_sources" linked_client_targets="linked_libmysql_sources"
CLIENT_LIBS=$NON_THREADED_CLIENT_LIBS
if test "$THREAD_SAFE_CLIENT" != "no" if test "$THREAD_SAFE_CLIENT" != "no"
then then
sql_client_dirs="libmysql_r $sql_client_dirs" sql_client_dirs="libmysql_r $sql_client_dirs"
@ -2452,9 +2454,11 @@ then
AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe]) AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
fi fi
CLIENT_LIBS="$CLIENT_LIBS $STATIC_NSS_FLAGS" CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
AC_SUBST(CLIENT_LIBS) AC_SUBST(CLIENT_LIBS)
AC_SUBST(NON_THREADED_LIBS)
AC_SUBST(STATIC_NSS_FLAGS)
AC_SUBST(sql_client_dirs) AC_SUBST(sql_client_dirs)
AC_SUBST(linked_client_targets) AC_SUBST(linked_client_targets)

View File

@ -4,7 +4,9 @@ connection con1;
reset master; reset master;
create database `drop-temp+table-test`; create database `drop-temp+table-test`;
use `drop-temp+table-test`; use `drop-temp+table-test`;
create temporary table shortn1 (a int);
create temporary table `table:name` (a int); create temporary table `table:name` (a int);
create temporary table shortn2 (a int);
select get_lock("a",10); select get_lock("a",10);
disconnect con1; disconnect con1;
@ -15,5 +17,6 @@ connection con2;
select get_lock("a",10); select get_lock("a",10);
let $VERSION=`select version()`; let $VERSION=`select version()`;
--replace_result $VERSION VERSION --replace_result $VERSION VERSION
--replace_column 2 # 5 #
show binlog events; show binlog events;
drop database `drop-temp+table-test`; drop database `drop-temp+table-test`;

View File

@ -140,6 +140,9 @@ SUFFIXES = .sh
-e 's!@''IS_LINUX''@!@IS_LINUX@!' \ -e 's!@''IS_LINUX''@!@IS_LINUX@!' \
-e "s!@""CONF_COMMAND""@!@CONF_COMMAND@!" \ -e "s!@""CONF_COMMAND""@!@CONF_COMMAND@!" \
-e 's!@''MYSQLD_USER''@!@MYSQLD_USER@!' \ -e 's!@''MYSQLD_USER''@!@MYSQLD_USER@!' \
-e 's!@''STATIC_NSS_FLAGS''@!@STATIC_NSS_FLAGS@!' \
-e 's!@''NON_THREADED_LIBS''@!@NON_THREADED_LIBS@!' \
-e 's!@''ZLIB_DEPS''@!@ZLIB_DEPS@!' \
-e "s!@MAKE@!$(MAKE)!" \ -e "s!@MAKE@!$(MAKE)!" \
$< > $@-t $< > $@-t
@CHMOD@ +x $@-t @CHMOD@ +x $@-t

View File

@ -82,13 +82,14 @@ version='@VERSION@'
socket='@MYSQL_UNIX_ADDR@' socket='@MYSQL_UNIX_ADDR@'
port='@MYSQL_TCP_PORT@' port='@MYSQL_TCP_PORT@'
ldflags='@LDFLAGS@' ldflags='@LDFLAGS@'
client_libs='@CLIENT_LIBS@'
# Create options # Create options
libs="$ldflags -L$pkglibdir -lmysqlclient $client_libs" libs="$ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@"
libs="$libs @openssl_libs@ @STATIC_NSS_FLAGS@"
libs=`echo "$libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` libs=`echo "$libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
libs_r="$ldflags -L$pkglibdir -lmysqlclient_r @LIBS@ @ZLIB_LIBS@ @openssl_libs@"
libs_r="$ldflags -L$pkglibdir -lmysqlclient_r @ZLIB_DEPS@ @LIBS@ @openssl_libs@"
libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'`
cflags="-I$pkgincludedir @CFLAGS@ " #note: end space! cflags="-I$pkgincludedir @CFLAGS@ " #note: end space!
include="-I$pkgincludedir" include="-I$pkgincludedir"

View File

@ -497,51 +497,48 @@ void close_temporary(TABLE *table,bool delete_table)
void close_temporary_tables(THD *thd) void close_temporary_tables(THD *thd)
{ {
TABLE *table,*next; TABLE *table,*next;
char *query, *end; char *query, *name_in_query, *end;
uint query_buf_size; uint greatest_key_length= 0;
bool found_user_tables = 0;
if (!thd->temporary_tables) if (!thd->temporary_tables)
return; return;
LINT_INIT(end);
query_buf_size= 50; // Enough for DROP ... TABLE IF EXISTS
for (table=thd->temporary_tables ; table ; table=table->next)
/* /*
We are going to add 4 ` around the db/table names, so 1 does not look We write a DROP TEMPORARY TABLE for each temp table left, so that our
enough; indeed it is enough, because table->key_length is greater (by 8, replication slave can clean them up. Not one multi-table DROP TABLE binlog
because of server_id and thread_id) than db||table. event: this would cause problems if slave uses --replicate-*-table.
*/ */
query_buf_size+= table->s->key_length+1; LINT_INIT(end);
if ((query = alloc_root(thd->mem_root, query_buf_size))) /* We'll re-use always same buffer so make it big enough for longest name */
for (table=thd->temporary_tables ; table ; table=table->next)
greatest_key_length= max(greatest_key_length, table->s->key_length);
if ((query = alloc_root(thd->mem_root, greatest_key_length+50)))
// Better add "if exists", in case a RESET MASTER has been done // Better add "if exists", in case a RESET MASTER has been done
end=strmov(query, "DROP /*!40005 TEMPORARY */ TABLE IF EXISTS "); name_in_query= strmov(query, "DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `");
for (table=thd->temporary_tables ; table ; table=next) for (table=thd->temporary_tables ; table ; table=next)
{ {
if (query) // we might be out of memory, but this is not fatal /*
In we are OOM for 'query' this is not fatal. We skip temporary tables
not created directly by the user.
*/
if (query && mysql_bin_log.is_open() && (table->s->table_name[0] != '#'))
{ {
// skip temporary tables not created directly by the user /*
if (table->s->table_name[0] != '#') Here we assume table_cache_key always starts
found_user_tables = 1; with \0 terminated db name
end = strxmov(end,"`",table->s->db,"`.`", */
table->s->table_name,"`,", NullS); end = strxmov(name_in_query, table->s->db, "`.`",
} table->s->table_name, "`", NullS);
next=table->next; Query_log_event qinfo(thd, query, (ulong)(end-query), 0, FALSE);
close_temporary(table);
}
if (query && found_user_tables && mysql_bin_log.is_open())
{
/* The -1 is to remove last ',' */
thd->clear_error();
Query_log_event qinfo(thd, query, (ulong)(end-query)-1, 0, FALSE);
/* /*
Imagine the thread had created a temp table, then was doing a SELECT, and Imagine the thread had created a temp table, then was doing a SELECT, and
the SELECT was killed. Then it's not clever to mark the statement above as the SELECT was killed. Then it's not clever to mark the statement above as
"killed", because it's not really a statement updating data, and there "killed", because it's not really a statement updating data, and there
are 99.99% chances it will succeed on slave. are 99.99% chances it will succeed on slave. And, if thread is
killed now, it's not clever either.
If a real update (one updating a persistent table) was killed on the If a real update (one updating a persistent table) was killed on the
master, then this real update will be logged with error_code=killed, master, then this real update will be logged with error_code=killed,
rightfully causing the slave to stop. rightfully causing the slave to stop.
@ -549,6 +546,9 @@ void close_temporary_tables(THD *thd)
qinfo.error_code= 0; qinfo.error_code= 0;
mysql_bin_log.write(&qinfo); mysql_bin_log.write(&qinfo);
} }
next=table->next;
close_temporary(table);
}
thd->temporary_tables=0; thd->temporary_tables=0;
} }

View File

@ -16,7 +16,7 @@
# Process this file with automake to create Makefile.in # Process this file with automake to create Makefile.in
noinst_LTLIBRARIES=libz.la pkglib_LTLIBRARIES=libz.la
noinst_HEADERS= crc32.h deflate.h inffast.h inffixed.h inflate.h \ noinst_HEADERS= crc32.h deflate.h inffast.h inffixed.h inflate.h \
inftrees.h trees.h zconf.h zlib.h zutil.h inftrees.h trees.h zconf.h zlib.h zutil.h