summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Docs/Makefile.am22
-rw-r--r--Makefile.am6
-rw-r--r--acinclude.m416
-rw-r--r--bdb/dist/gen_rec.awk2
-rw-r--r--client/mysqltest.c89
-rw-r--r--configure.in6
-rw-r--r--include/mysql.h6
-rw-r--r--include/mysql_h.ic1
-rw-r--r--libmysql/libmysql.c7
-rw-r--r--libmysql_r/Makefile.am10
-rw-r--r--libmysqld/Makefile.am24
-rw-r--r--libmysqld/lib_sql.cc10
-rw-r--r--mysql-test/lib/mtr_unique.pl156
-rwxr-xr-xmysql-test/mysql-test-run.pl12
-rw-r--r--mysql-test/r/order_by.result27
-rw-r--r--mysql-test/r/subselect.result32
-rw-r--r--mysql-test/t/bdb-deadlock.test8
-rw-r--r--mysql-test/t/flush.test8
-rw-r--r--mysql-test/t/flush_block_commit.test3
-rw-r--r--mysql-test/t/innodb-deadlock.test2
-rw-r--r--mysql-test/t/innodb-lock.test2
-rw-r--r--mysql-test/t/lock_multi.test8
-rw-r--r--mysql-test/t/mysql_client.test35
-rw-r--r--mysql-test/t/order_by.test16
-rw-r--r--mysql-test/t/rename.test4
-rw-r--r--mysql-test/t/show_check.test3
-rw-r--r--mysql-test/t/status.test7
-rw-r--r--mysql-test/t/subselect.test33
-rw-r--r--ndb/config/common.mk.am2
-rw-r--r--ndb/config/type_kernel.mk.am5
-rw-r--r--ndb/config/type_ndbapi.mk.am6
-rw-r--r--ndb/config/type_ndbapitest.mk.am5
-rw-r--r--ndb/config/type_ndbapitools.mk.am5
-rw-r--r--ndb/config/type_util.mk.am5
-rw-r--r--ndb/src/kernel/Makefile.am30
-rw-r--r--sql-common/client.c2
-rw-r--r--sql/item.cc33
-rw-r--r--sql/item_subselect.cc37
-rw-r--r--sql/item_subselect.h7
-rw-r--r--sql/protocol.cc18
-rw-r--r--sql/protocol.h1
-rw-r--r--sql/sql_class.h6
-rw-r--r--support-files/mysql.spec.sh23
43 files changed, 589 insertions, 151 deletions
diff --git a/Docs/Makefile.am b/Docs/Makefile.am
index 685eaeef7d1..85a362133a1 100644
--- a/Docs/Makefile.am
+++ b/Docs/Makefile.am
@@ -26,7 +26,7 @@ all-local: $(TXT_FILES)
# make sure that "make install" installs the info page, too
# automake only seems to take care of this automatically,
# if we're building the info page from texi directly.
-install-data-hook: mysql.info
+install-data-hook: $(srcdir)/mysql.info
$(mkinstalldirs) $(DESTDIR)$(infodir)
$(INSTALL_DATA) $(srcdir)/mysql.info $(DESTDIR)$(infodir)
@@ -39,23 +39,23 @@ CLEAN_FILES: $(TXT_FILES)
GT = $(srcdir)/Support/generate-text-files.pl
-../INSTALL-SOURCE: mysql.info $(GT)
- perl -w $(GT) $< "installing-source" "windows-source-build" > $@
+../INSTALL-SOURCE: $(srcdir)/mysql.info $(GT)
+ perl -w $(GT) $(srcdir)/mysql.info "installing-source" "windows-source-build" > $@
-../INSTALL-WIN-SOURCE: mysql.info $(GT)
- perl -w $(GT) $< "windows-source-build" "post-installation" > $@
+../INSTALL-WIN-SOURCE: $(srcdir)/mysql.info $(GT)
+ perl -w $(GT) $(srcdir)/mysql.info "windows-source-build" "post-installation" > $@
# We put the description for the binary installation here so that
# people who download source wont have to see it. It is moved up to
# the toplevel by the script that makes the binary tar files.
-INSTALL-BINARY: mysql.info $(GT)
- perl -w $(GT) $< "installing-binary" "installing-source" > $@
+INSTALL-BINARY: $(srcdir)/mysql.info $(GT)
+ perl -w $(GT) $(srcdir)/mysql.info "installing-binary" "installing-source" > $@
-../EXCEPTIONS-CLIENT: mysql.info $(GT)
- perl -w $(GT) $< "mysql-floss-license-exception" "function-index" > $@
+../EXCEPTIONS-CLIENT: $(srcdir)/mysql.info $(GT)
+ perl -w $(GT) $(srcdir)/mysql.info "mysql-floss-license-exception" "function-index" > $@
-../support-files/MacOSX/ReadMe.txt: mysql.info $(GT)
- perl -w $(GT) $< "mac-os-x-installation" "netware-installation" > $@
+../support-files/MacOSX/ReadMe.txt: $(srcdir)/mysql.info $(GT)
+ perl -w $(GT) $(srcdir)/mysql.info "mac-os-x-installation" "netware-installation" > $@
# Don't update the files from bitkeeper
%::SCCS/s.%
diff --git a/Makefile.am b/Makefile.am
index ab9a7a33a44..19d7678e611 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -131,3 +131,9 @@ test-force-pl:
./mysql-test-run.pl --force && \
./mysql-test-run.pl --ps-protocol --force
+#used by autopush.pl to run memory based tests
+test-force-pl-mem:
+ cd mysql-test; \
+ ./mysql-test-run.pl --force --mem && \
+ ./mysql-test-run.pl --ps-protocol --force --mem
+
diff --git a/acinclude.m4 b/acinclude.m4
index 0337b9de0cd..811e9c0b183 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1448,20 +1448,20 @@ bdb_version_ok=yes
])
AC_DEFUN([MYSQL_TOP_BUILDDIR], [
+ # Remove trailing "./" if any
+ [$1]=`echo $[$1] | sed -e 's,^\./,,'`
case "$[$1]" in
- /* ) ;; # don't do anything with an absolute path
- "$srcdir"/* )
+ "bdb" | "$srcdir/bdb" | "$top_srcdir/bdb" | "$abs_top_srcdir/bdb" )
# If BDB is under the source directory, we need to look under the
# build directory for bdb/build_unix.
- # NOTE: I'm being lazy, and assuming the user did not specify
- # something like --with-berkeley-db=bdb (it would be missing "./").
- [$1]="\$(top_builddir)/"`echo "$[$1]" | sed -e "s,^$srcdir/,,"`
+ [$1]="\$(top_builddir)/bdb"
;;
+ /* ) ;; # Other absolute path is assume to be external BDB directory
* )
AC_MSG_ERROR([The BDB directory must be directly under the MySQL source directory, or be specified using the full path. ('$srcdir'; '$[$1]')])
;;
esac
- if test X"$[$1]" != "/"
+ if test X"$[$1]" != X"/"
then
[$1]=`echo $[$1] | sed -e 's,/$,,'`
fi
@@ -1493,7 +1493,7 @@ AC_DEFUN([MYSQL_CHECK_INNODB], [
AC_MSG_RESULT([Using Innodb])
AC_DEFINE([HAVE_INNOBASE_DB], [1], [Using Innobase DB])
have_innodb="yes"
- innodb_includes="-I../innobase/include"
+ innodb_includes="-I\$(top_builddir)/innobase/include -I\$(top_srcdir)/innobase/include"
innodb_system_libs=""
dnl Some libs are listed several times, in order for gcc to sort out
dnl circular references.
@@ -1812,7 +1812,7 @@ AC_DEFUN([MYSQL_CHECK_NDBCLUSTER], [
AC_MSG_RESULT([Using NDB Cluster])
AC_DEFINE([HAVE_NDBCLUSTER_DB], [1], [Using Ndb Cluster DB])
have_ndbcluster="yes"
- ndbcluster_includes="-I../ndb/include -I../ndb/include/ndbapi"
+ ndbcluster_includes="-I\$(top_builddir)/ndb/include -I\$(top_srcdir)/ndb/include -I\$(top_srcdir)/ndb/include/ndbapi"
ndbcluster_libs="\$(top_builddir)/ndb/src/.libs/libndbclient.a"
ndbcluster_system_libs=""
ndb_mgmclient_libs="\$(top_builddir)/ndb/src/mgmclient/libndbmgmclient.la"
diff --git a/bdb/dist/gen_rec.awk b/bdb/dist/gen_rec.awk
index 75f2e86ca9e..e1b75699027 100644
--- a/bdb/dist/gen_rec.awk
+++ b/bdb/dist/gen_rec.awk
@@ -180,7 +180,7 @@ BEGIN {
t = types[i];
if (modes[i] == "POINTER") {
ndx = index(t, "*");
- t = substr(types[i], 0, ndx - 2);
+ t = substr(types[i], 1, ndx - 2);
}
printf("\t%s\t%s;\n", t, vars[i]) >> HFILE
}
diff --git a/client/mysqltest.c b/client/mysqltest.c
index c303493c7f5..78e74c23e54 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -29,6 +29,7 @@
Matt Wagner <matt@mysql.com>
Monty
Jani
+ Holyfoot
*/
#define MTEST_VERSION "3.0"
@@ -220,6 +221,12 @@ struct st_connection
MYSQL* util_mysql;
char *name;
MYSQL_STMT* stmt;
+
+ const char *cur_query;
+ int cur_query_len;
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+ int query_done;
};
struct st_connection connections[128];
struct st_connection* cur_con, *next_con, *connections_end;
@@ -458,7 +465,6 @@ void mysql_disable_rpl_parse(MYSQL* mysql __attribute__((unused))) {}
int mysql_rpl_parse_enabled(MYSQL* mysql __attribute__((unused))) { return 1; }
my_bool mysql_rpl_probe(MYSQL *mysql __attribute__((unused))) { return 1; }
#endif
-
void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val,
int len);
void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val);
@@ -470,6 +476,56 @@ void handle_error(struct st_command*,
void handle_no_error(struct st_command*);
+#ifdef EMBEDDED_LIBRARY
+/*
+ send_one_query executes query in separate thread what is
+ necessary in embedded library to run 'send' in proper way.
+ This implementation doesn't handle errors returned
+ by mysql_send_query. It's technically possible, though
+ i don't see where it is needed.
+*/
+pthread_handler_decl(send_one_query, arg)
+{
+ struct st_connection *cn= (struct st_connection*)arg;
+
+ mysql_thread_init();
+ VOID(mysql_send_query(&cn->mysql, cn->cur_query, cn->cur_query_len));
+
+ mysql_thread_end();
+ pthread_mutex_lock(&cn->mutex);
+ cn->query_done= 1;
+ VOID(pthread_cond_signal(&cn->cond));
+ pthread_mutex_unlock(&cn->mutex);
+ pthread_exit(0);
+ return 0;
+}
+
+static int do_send_query(struct st_connection *cn, const char *q, int q_len,
+ int flags)
+{
+ pthread_t tid;
+
+ if (flags & QUERY_REAP_FLAG)
+ return mysql_send_query(&cn->mysql, q, q_len);
+
+ if (pthread_mutex_init(&cn->mutex, NULL) ||
+ pthread_cond_init(&cn->cond, NULL))
+ die("Error in the thread library");
+
+ cn->cur_query= q;
+ cn->cur_query_len= q_len;
+ cn->query_done= 0;
+ if (pthread_create(&tid, NULL, send_one_query, (void*)cn))
+ die("Cannot start new thread for query");
+
+ return 0;
+}
+
+#else /*EMBEDDED_LIBRARY*/
+
+#define do_send_query(cn,q,q_len,flags) mysql_send_query(&cn->mysql, q, q_len)
+
+#endif /*EMBEDDED_LIBRARY*/
void do_eval(DYNAMIC_STRING *query_eval, const char *query,
const char *query_end, my_bool pass_through_escape_chars)
@@ -4506,7 +4562,6 @@ int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql)
}
-
/*
Run query using MySQL C API
@@ -4523,10 +4578,11 @@ int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql)
error - function will not return
*/
-void run_query_normal(MYSQL *mysql, struct st_command *command,
+void run_query_normal(struct st_connection *cn, struct st_command *command,
int flags, char *query, int query_len,
DYNAMIC_STRING *ds, DYNAMIC_STRING *ds_warnings)
{
+ MYSQL *mysql= &cn->mysql;
MYSQL_RES *res= 0;
int err= 0, counter= 0;
DBUG_ENTER("run_query_normal");
@@ -4538,14 +4594,26 @@ void run_query_normal(MYSQL *mysql, struct st_command *command,
/*
Send the query
*/
- if (mysql_send_query(mysql, query, query_len))
+ if (do_send_query(cn, query, query_len, flags))
{
handle_error(command, mysql_errno(mysql), mysql_error(mysql),
mysql_sqlstate(mysql), ds);
goto end;
}
}
-
+#ifdef EMBEDDED_LIBRARY
+ /*
+ Here we handle 'reap' command, so we need to check if the
+ query's thread was finished and probably wait
+ */
+ else if (flags & QUERY_REAP_FLAG)
+ {
+ pthread_mutex_lock(&cn->mutex);
+ while (!cn->query_done)
+ pthread_cond_wait(&cn->cond, &cn->mutex);
+ pthread_mutex_unlock(&cn->mutex);
+ }
+#endif /*EMBEDDED_LIBRARY*/
if (!(flags & QUERY_REAP_FLAG))
DBUG_VOID_RETURN;
@@ -5036,8 +5104,9 @@ int util_query(MYSQL* org_mysql, const char* query){
*/
-void run_query(MYSQL *mysql, struct st_command *command, int flags)
+void run_query(struct st_connection *cn, struct st_command *command, int flags)
{
+ MYSQL *mysql= &cn->mysql;
DYNAMIC_STRING *ds;
DYNAMIC_STRING ds_result;
DYNAMIC_STRING ds_warnings;
@@ -5194,7 +5263,7 @@ void run_query(MYSQL *mysql, struct st_command *command, int flags)
match_re(&ps_re, query))
run_query_stmt(mysql, command, query, query_len, ds, &ds_warnings);
else
- run_query_normal(mysql, command, flags, query, query_len,
+ run_query_normal(cn, command, flags, query, query_len,
ds, &ds_warnings);
if (sp_created)
@@ -5659,7 +5728,7 @@ int main(int argc, char **argv)
strmake(command->require_file, save_file, sizeof(save_file));
save_file[0]= 0;
}
- run_query(&cur_con->mysql, command, QUERY_REAP_FLAG|QUERY_SEND_FLAG);
+ run_query(cur_con, command, QUERY_REAP_FLAG|QUERY_SEND_FLAG);
display_result_vertically= old_display_result_vertically;
command->last_argument= command->end;
command_executed++;
@@ -5690,7 +5759,7 @@ int main(int argc, char **argv)
strmake(command->require_file, save_file, sizeof(save_file));
save_file[0]= 0;
}
- run_query(&cur_con->mysql, command, flags);
+ run_query(cur_con, command, flags);
command_executed++;
command->last_argument= command->end;
break;
@@ -5716,7 +5785,7 @@ int main(int argc, char **argv)
the query and read the result some time later when reap instruction
is given on this connection.
*/
- run_query(&cur_con->mysql, command, QUERY_SEND_FLAG);
+ run_query(cur_con, command, QUERY_SEND_FLAG);
command_executed++;
command->last_argument= command->end;
break;
diff --git a/configure.in b/configure.in
index a8eed676756..4ac0637e42c 100644
--- a/configure.in
+++ b/configure.in
@@ -46,12 +46,14 @@ do
case $host_os in
netware* | modesto*)
echo "$i/errmsg.sys: $i/errmsg.txt
- \$(top_builddir)/extra/comp_err.linux -C\$(srcdir)/charsets/ $i/errmsg.txt $i/errmsg.sys" \
+ mkdir -p $i
+ \$(top_builddir)/extra/comp_err.linux -C\$(srcdir)/charsets/ \$(srcdir)/$i/errmsg.txt $i/errmsg.sys" \
>> $AVAILABLE_LANGUAGES_ERRORS_RULES
;;
*)
echo "$i/errmsg.sys: $i/errmsg.txt
- \$(top_builddir)/extra/comp_err -C\$(srcdir)/charsets/ $i/errmsg.txt $i/errmsg.sys" \
+ mkdir -p $i
+ \$(top_builddir)/extra/comp_err -C\$(srcdir)/charsets/ \$(srcdir)/$i/errmsg.txt $i/errmsg.sys" \
>> $AVAILABLE_LANGUAGES_ERRORS_RULES
;;
esac
diff --git a/include/mysql.h b/include/mysql.h
index bc99b6f6ba1..55ef6ee6d10 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -281,12 +281,6 @@ typedef struct st_mysql
from mysql_stmt_close if close had to cancel result set of this object.
*/
my_bool *unbuffered_fetch_owner;
- /*
- In embedded server it points to the statement that is processed
- in the current query. We store some results directly in statement
- fields then.
- */
- struct st_mysql_stmt *current_stmt;
} MYSQL;
typedef struct st_mysql_res {
diff --git a/include/mysql_h.ic b/include/mysql_h.ic
index 30ef44a1ccb..44c36c84747 100644
--- a/include/mysql_h.ic
+++ b/include/mysql_h.ic
@@ -154,7 +154,6 @@ struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned
struct st_mysql_methods const * methods;
void * thd;
my_bool * unbuffered_fetch_owner;
- struct st_mysql_stmt * current_stmt;
};
# 571 "mysql.h"
struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_bind
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 91c0b6b8864..5577ecdb556 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -4395,13 +4395,6 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
set_stmt_error(stmt, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate);
DBUG_RETURN(1);
}
- if (result->data)
- {
- free_root(&result->alloc, MYF(MY_KEEP_PREALLOC));
- result->data= NULL;
- result->rows= 0;
- stmt->data_cursor= NULL;
- }
if (stmt->update_max_length && !stmt->bind_result_done)
{
diff --git a/libmysql_r/Makefile.am b/libmysql_r/Makefile.am
index f7cf00321cb..31f6fdffd53 100644
--- a/libmysql_r/Makefile.am
+++ b/libmysql_r/Makefile.am
@@ -31,8 +31,6 @@ INCLUDES = @MT_INCLUDES@ \
## automake barfs if you don't use $(srcdir) or $(top_srcdir) in include
include $(top_srcdir)/libmysql/Makefile.shared
-libmysql_dir = $(top_srcdir)/libmysql
-
libmysqlclient_r_la_SOURCES = $(target_sources)
libmysqlclient_r_la_LIBADD = $(target_libadd)
libmysqlclient_r_la_LDFLAGS = $(target_ldflags)
@@ -40,7 +38,9 @@ libmysqlclient_r_la_LDFLAGS = $(target_ldflags)
# This is called from the toplevel makefile
link_sources:
set -x; \
- for f in `cd $(libmysql_dir) && echo *.[ch]`; do \
- rm -f $$f; \
- @LN_CP_F@ $(libmysql_dir)/$$f $$f; \
+ for d in $(top_srcdir)/libmysql $(top_builddir)/libmysql; do \
+ for f in `cd $$d && echo *.[ch]`; do \
+ rm -f $$f; \
+ @LN_CP_F@ $$d/$$f $$f; \
+ done; \
done
diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am
index e121e4b8d6e..9582084ba5d 100644
--- a/libmysqld/Makefile.am
+++ b/libmysqld/Makefile.am
@@ -25,9 +25,11 @@ DEFS = -DEMBEDDED_LIBRARY -DMYSQL_SERVER \
-DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \
-DDATADIR="\"$(MYSQLDATAdir)\"" \
-DSHAREDIR="\"$(MYSQLSHAREdir)\""
-INCLUDES= @MT_INCLUDES@ @bdb_includes@ \
+INCLUDES= @MT_INCLUDES@ @bdb_includes@ @innodb_includes@ @ndbcluster_includes@ \
-I$(top_builddir)/include -I$(top_srcdir)/include \
- -I$(top_srcdir)/sql -I$(top_srcdir)/sql/examples -I$(top_srcdir)/regex \
+ -I$(top_builddir)/sql -I$(top_srcdir)/sql \
+ -I$(top_srcdir)/sql/examples \
+ -I$(top_srcdir)/regex \
$(openssl_includes) @ZLIB_INCLUDES@
noinst_LIBRARIES = libmysqld_int.a
@@ -118,16 +120,28 @@ endif
#libmysqld_la_LDFLAGS = -version-info @SHARED_LIB_VERSION@
#CLEANFILES = $(libmysqld_la_LIBADD) libmysqld.la
-# This is called from the toplevel makefile
+# This is called from the toplevel makefile. If we can link now
+# to an existing file in source, we do that, else we assume it
+# will show up in the build tree eventually (generated file).
link_sources:
set -x; \
for f in $(sqlsources); do \
rm -f $$f; \
- @LN_CP_F@ $(top_srcdir)/sql/$$f $$f; \
+ if test -e $(top_srcdir)/sql/$$f ; \
+ then \
+ @LN_CP_F@ $(top_srcdir)/sql/$$f $$f; \
+ else \
+ @LN_CP_F@ $(top_builddir)/sql/$$f $$f; \
+ fi ; \
done; \
for f in $(libmysqlsources); do \
rm -f $$f; \
- @LN_CP_F@ $(top_srcdir)/libmysql/$$f $$f; \
+ if test -e $(top_srcdir)/libmysql/$$f ; \
+ then \
+ @LN_CP_F@ $(top_srcdir)/libmysql/$$f $$f; \
+ else \
+ @LN_CP_F@ $(top_builddir)/libmysql/$$f $$f; \
+ fi ; \
done; \
for f in $(sqlexamplessources); do \
rm -f $$f; \
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index 1a3e10f08a8..64bc37fb40d 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -94,7 +94,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
mysql->affected_rows= ~(my_ulonglong) 0;
mysql->field_count= 0;
net->last_errno= 0;
- mysql->current_stmt= stmt;
+ thd->current_stmt= stmt;
thd->store_globals(); // Fix if more than one connect
/*
@@ -644,8 +644,8 @@ bool Protocol::send_fields(List<Item> *list, uint flag)
DBUG_RETURN(0);
field_count= list->elements;
- field_alloc= mysql->current_stmt ? &mysql->current_stmt->mem_root :
- &mysql->field_alloc;
+ field_alloc= thd->current_stmt ? &thd->current_stmt->mem_root :
+ &mysql->field_alloc;
if (!(client_field= mysql->fields=
(MYSQL_FIELD *)alloc_root(field_alloc,
sizeof(MYSQL_FIELD) * field_count)))
@@ -751,8 +751,8 @@ bool Protocol_prep::write()
{
MYSQL *mysql= thd->mysql;
- if (mysql->current_stmt)
- data= &mysql->current_stmt->result;
+ if (thd->current_stmt)
+ data= &thd->current_stmt->result;
else
{
if (!(data= (MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA),
diff --git a/mysql-test/lib/mtr_unique.pl b/mysql-test/lib/mtr_unique.pl
new file mode 100644
index 00000000000..a8fb320c773
--- /dev/null
+++ b/mysql-test/lib/mtr_unique.pl
@@ -0,0 +1,156 @@
+#
+# This file is used from mysql-test-run.pl when choosing
+# port numbers and directories to use for running mysqld.
+#
+
+use strict;
+use Fcntl ':flock';
+
+#
+# Requested IDs are stored in a hash and released upon END.
+#
+my %mtr_unique_assigned_ids = ();
+END {
+ while(my ($id,$file) = each(%mtr_unique_assigned_ids)) {
+ print "Autoreleasing $file:$id\n";
+ mtr_release_unique_id($file, $id);
+ }
+}
+
+#
+# Require a unique, numerical ID, given a file name (where all
+# requested IDs are stored), a minimum and a maximum value.
+#
+# We use flock to implement locking for the ID file and ignore
+# possible problems arising from lack of support for it on
+# some platforms (it should work on most, and the possible
+# race condition would occur rarely). The proper solution for
+# this is a daemon that manages IDs, of course.
+#
+# If no unique ID within the specified parameters can be
+# obtained, return undef.
+#
+sub mtr_require_unique_id($$$) {
+ my $file = shift;
+ my $min = shift;
+ my $max = shift;
+ my $ret = undef;
+ my $changed = 0;
+
+ my $can_use_ps = `ps -e | grep '^[ ]*$$ '`;
+
+ if(eval("readlink '$file'") || eval("readlink '$file.sem'")) {
+ die 'lock file is a symbolic link';
+ }
+
+ chmod 0777, "$file.sem";
+ open SEM, ">", "$file.sem" or die "can't write to $file.sem";
+ flock SEM, LOCK_EX or die "can't lock $file.sem";
+ if(! -e $file) {
+ open FILE, ">", $file or die "can't create $file";
+ close FILE;
+ }
+
+ if(eval("readlink '$file'") || eval("readlink '$file.sem'")) {
+ die 'lock file is a symbolic link';
+ }
+
+ chmod 0777, $file;
+ open FILE, "+<", $file or die "can't open $file";
+ select undef,undef,undef,0.2;
+ seek FILE, 0, 0;
+ my %taken = ();
+ while(<FILE>) {
+ chomp;
+ my ($id, $pid) = split / /;
+ $taken{$id} = $pid;
+ if($can_use_ps) {
+ my $res = `ps -e | grep '^[ ]*$pid '`;
+ if(!$res) {
+ print "Ignoring slot $id used by missing process $pid.\n";
+ delete $taken{$id};
+ ++$changed;
+ }
+ }
+ }
+ for(my $i=$min; $i<=$max; ++$i) {
+ if(! exists $taken{$i}) {
+ $ret = $i;
+ $taken{$i} = $$;
+ ++$changed;
+ last;
+ }
+ }
+ if($changed) {
+ seek FILE, 0, 0;
+ truncate FILE, 0 or die "can't truncate $file";
+ for my $k (keys %taken) {
+ print FILE $k . ' ' . $taken{$k} . "\n";
+ }
+ }
+ close FILE;
+ flock SEM, LOCK_UN or warn "can't unlock $file.sem";
+ close SEM;
+ $mtr_unique_assigned_ids{$ret} = $file if defined $ret;
+ return $ret;
+}
+
+#
+# Require a unique ID like above, but sleep if no ID can be
+# obtained immediately.
+#
+sub mtr_require_unique_id_and_wait($$$) {
+ my $ret = mtr_require_unique_id($_[0],$_[1],$_[2]);
+ while(! defined $ret) {
+ sleep 30;
+ $ret = mtr_require_unique_id($_[0],$_[1],$_[2]);
+ print "Waiting for unique id to become available...\n" unless $ret;
+ }
+ return $ret;
+}
+
+#
+# Release a unique ID.
+#
+sub mtr_release_unique_id($$) {
+ my $file = shift;
+ my $myid = shift;
+
+ if(eval("readlink '$file'") || eval("readlink '$file.sem'")) {
+ die 'lock file is a symbolic link';
+ }
+
+ open SEM, ">", "$file.sem" or die "can't write to $file.sem";
+ flock SEM, LOCK_EX or die "can't lock $file.sem";
+
+ if(eval("readlink '$file'") || eval("readlink '$file.sem'")) {
+ die 'lock file is a symbolic link';
+ }
+
+ if(! -e $file) {
+ open FILE, ">", $file or die "can't create $file";
+ close FILE;
+ }
+ open FILE, "+<", $file or die "can't open $file";
+ select undef,undef,undef,0.2;
+ seek FILE, 0, 0;
+ my %taken = ();
+ while(<FILE>) {
+ chomp;
+ my ($id, $pid) = split / /;
+ $taken{$id} = $pid;
+ }
+ delete $taken{$myid};
+ seek FILE, 0, 0;
+ truncate FILE, 0 or die "can't truncate $file";
+ for my $k (keys %taken) {
+ print FILE $k . ' ' . $taken{$k} . "\n";
+ }
+ close FILE;
+ flock SEM, LOCK_UN or warn "can't unlock $file.sem";
+ close SEM;
+ delete $mtr_unique_assigned_ids{$myid};
+}
+
+1;
+
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 10b8e84184a..4ef2eb2a758 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -87,6 +87,7 @@ require "lib/mtr_diff.pl";
require "lib/mtr_match.pl";
require "lib/mtr_misc.pl";
require "lib/mtr_stress.pl";
+require "lib/mtr_unique.pl";
$Devel::Trace::TRACE= 1;
@@ -437,6 +438,7 @@ sub main () {
mtr_exit(0);
}
+
##############################################################################
#
# Default settings
@@ -472,6 +474,16 @@ sub command_line_setup () {
# differs between operating systems and configuration, see
# http://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports.html
# But a fairly safe range seems to be 5001 - 32767
+
+ # If so requested, we try to avail ourselves of a unique build thread number.
+ if ( $ENV{'MTR_BUILD_THREAD'} ) {
+ if ( lc($ENV{'MTR_BUILD_THREAD'}) eq 'auto' ) {
+ print "Requesting build thread... ";
+ $ENV{'MTR_BUILD_THREAD'} = mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299);
+ print "got ".$ENV{'MTR_BUILD_THREAD'}."\n";
+ }
+ }
+
if ( $ENV{'MTR_BUILD_THREAD'} )
{
# Up to two masters, up to three slaves
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result
index 8126e223f55..320bb89b62e 100644
--- a/mysql-test/r/order_by.result
+++ b/mysql-test/r/order_by.result
@@ -820,3 +820,30 @@ b a
20 1
10 2
DROP TABLE t1;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2);
+SELECT a + 1 AS num FROM t1 ORDER BY 30 - num;
+num
+3
+2
+SELECT CONCAT('test', a) AS str FROM t1 ORDER BY UPPER(str);
+str
+test1
+test2
+SELECT a + 1 AS num FROM t1 GROUP BY 30 - num;
+num
+3
+2
+SELECT a + 1 AS num FROM t1 HAVING 30 - num;
+num
+2
+3
+SELECT a + 1 AS num, num + 1 FROM t1;
+ERROR 42S22: Unknown column 'num' in 'field list'
+SELECT a + 1 AS num, (select num + 2 FROM t1 LIMIT 1) FROM t1;
+num (select num + 2 FROM t1 LIMIT 1)
+2 4
+3 5
+SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a;
+ERROR 42S22: Unknown column 'num' in 'on clause'
+DROP TABLE t1;
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index e16a605434e..89315342f5e 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -2981,3 +2981,35 @@ field1 field2
1 1
1 3
DROP TABLE t1, t2;
+CREATE TABLE t1(a int, INDEX (a));
+INSERT INTO t1 VALUES (1), (3), (5), (7);
+INSERT INTO t1 VALUES (NULL);
+CREATE TABLE t2(a int);
+INSERT INTO t2 VALUES (1),(2),(3);
+EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 3
+2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 2 Using index
+SELECT a, a IN (SELECT a FROM t1) FROM t2;
+a a IN (SELECT a FROM t1)
+1 1
+2 NULL
+3 1
+DROP TABLE t1,t2;
+CREATE TABLE t1 (a DATETIME);
+INSERT INTO t1 VALUES ('1998-09-23'), ('2003-03-25');
+CREATE TABLE t2 AS SELECT
+(SELECT a FROM t1 WHERE a < '2000-01-01') AS sub_a
+FROM t1 WHERE a > '2000-01-01';
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `sub_a` datetime default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+CREATE TABLE t3 AS (SELECT a FROM t1 WHERE a < '2000-01-01') UNION (SELECT a FROM t1 WHERE a > '2000-01-01');
+SHOW CREATE TABLE t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `a` datetime default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1,t2,t3;
diff --git a/mysql-test/t/bdb-deadlock.test b/mysql-test/t/bdb-deadlock.test
index 88243cfc860..b48648e0fd0 100644
--- a/mysql-test/t/bdb-deadlock.test
+++ b/mysql-test/t/bdb-deadlock.test
@@ -1,11 +1,3 @@
-# This test doesn't work with the embedded version as this code
-# assumes that one query is running while we are doing queries on
-# a second connection.
-# This would work if mysqltest run would be threaded and handle each
-# connection in a separate thread.
-#
-
--- source include/not_embedded.inc
-- source include/have_bdb.inc
connect (con1,localhost,root,,);
diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test
index aedf8e85b65..8fe62ecac01 100644
--- a/mysql-test/t/flush.test
+++ b/mysql-test/t/flush.test
@@ -1,11 +1,3 @@
-# This test doesn't work with the embedded version as this code
-# assumes that one query is running while we are doing queries on
-# a second connection.
-# This would work if mysqltest run would be threaded and handle each
-# connection in a separate thread.
-#
--- source include/not_embedded.inc
-
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
diff --git a/mysql-test/t/flush_block_commit.test b/mysql-test/t/flush_block_commit.test
index 1e7ecd2548c..0c1d2b82df6 100644
--- a/mysql-test/t/flush_block_commit.test
+++ b/mysql-test/t/flush_block_commit.test
@@ -3,9 +3,6 @@
# We verify that we did not introduce a deadlock.
# This is intended to mimick how mysqldump and innobackup work.
-# This test doesn't work with the embedded server
--- source include/not_embedded.inc
-
# And it requires InnoDB
-- source include/have_innodb.inc
diff --git a/mysql-test/t/innodb-deadlock.test b/mysql-test/t/innodb-deadlock.test
index 41741942963..81acfba5c93 100644
--- a/mysql-test/t/innodb-deadlock.test
+++ b/mysql-test/t/innodb-deadlock.test
@@ -1,6 +1,4 @@
-- source include/have_innodb.inc
-# Can't test this with embedded server
--- source include/not_embedded.inc
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
diff --git a/mysql-test/t/innodb-lock.test b/mysql-test/t/innodb-lock.test
index 55a712fef9b..eacf7e562be 100644
--- a/mysql-test/t/innodb-lock.test
+++ b/mysql-test/t/innodb-lock.test
@@ -1,6 +1,4 @@
-- source include/have_innodb.inc
-# Can't test this with embedded server
--- source include/not_embedded.inc
#
# Check and select innodb lock type
diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test
index 2e40aeaccb7..32e7f4234c4 100644
--- a/mysql-test/t/lock_multi.test
+++ b/mysql-test/t/lock_multi.test
@@ -1,11 +1,3 @@
-# This test doesn't work with the embedded version as this code
-# assumes that one query is running while we are doing queries on
-# a second connection.
-# This would work if mysqltest run would be threaded and handle each
-# connection in a separate thread.
-#
--- source include/not_embedded.inc
-
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
diff --git a/mysql-test/t/mysql_client.test b/mysql-test/t/mysql_client.test
index 2a7f4a935bb..505ca5d4b21 100644
--- a/mysql-test/t/mysql_client.test
+++ b/mysql-test/t/mysql_client.test
@@ -35,6 +35,24 @@
--exec echo 'help ' | $MYSQL > $MYSQLTEST_VARDIR/tmp/bug20328.tmp
#
+# Bug #19216: Client crashes on long SELECT
+#
+--exec echo "select" > $MYSQLTEST_VARDIR/tmp/b19216.tmp
+# 3400 * 20 makes 68000 columns that is more than the max number that can fit
+# in a 16 bit number.
+let $i= 3400;
+while ($i)
+{
+ --exec echo "'a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a'," >> $MYSQLTEST_VARDIR/tmp/b19216.tmp
+ dec $i;
+}
+
+--exec echo "'b';" >> $MYSQLTEST_VARDIR/tmp/b19216.tmp
+--disable_query_log
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/b19216.tmp >/dev/null
+--enable_query_log
+
+#
# Bug#17583: mysql drops connection when stdout is not writable
#
create table t17583 (a int);
@@ -51,4 +69,21 @@ select count(*) from t17583;
--exec echo "select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; select count(*) from t17583; " |$MYSQL test >&-
drop table t17583;
+#
+# Bug #19216: Client crashes on long SELECT
+#
+--exec echo "select" > $MYSQLTEST_VARDIR/tmp/b19216.tmp
+# 3400 * 20 makes 68000 columns that is more than the max number that can fit
+# in a 16 bit number.
+let $i= 3400;
+while ($i)
+{
+ --exec echo "'a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a'," >> $MYSQLTEST_VARDIR/tmp/b19216.tmp
+ dec $i;
+}
+
+--exec echo "'b';" >> $MYSQLTEST_VARDIR/tmp/b19216.tmp
+--disable_query_log
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/b19216.tmp >/dev/null
+--enable_query_log
--echo End of 4.1 tests.
diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test
index 1664afc70f9..a8024be7032 100644
--- a/mysql-test/t/order_by.test
+++ b/mysql-test/t/order_by.test
@@ -559,4 +559,20 @@ INSERT INTO t1 VALUES (1,30), (2,20), (1,10), (2,30), (1,20), (2,10);
DROP TABLE t1;
+#
+# Bug #22457: Column alias in ORDER BY works, but not if in an expression
+#
+
+CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2);
+SELECT a + 1 AS num FROM t1 ORDER BY 30 - num;
+SELECT CONCAT('test', a) AS str FROM t1 ORDER BY UPPER(str);
+SELECT a + 1 AS num FROM t1 GROUP BY 30 - num;
+SELECT a + 1 AS num FROM t1 HAVING 30 - num;
+--error 1054
+SELECT a + 1 AS num, num + 1 FROM t1;
+SELECT a + 1 AS num, (select num + 2 FROM t1 LIMIT 1) FROM t1;
+--error 1054
+SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a;
+DROP TABLE t1;
+
# End of 4.1 tests
diff --git a/mysql-test/t/rename.test b/mysql-test/t/rename.test
index c32184645c1..cd1cc1e66b8 100644
--- a/mysql-test/t/rename.test
+++ b/mysql-test/t/rename.test
@@ -2,10 +2,6 @@
# Test of rename table
#
-# Test requires concurrent connections, which can't be tested on embedded
-# server
--- source include/not_embedded.inc
-
--disable_warnings
drop table if exists t0,t1,t2,t3,t4;
# Clear up from other tests (to ensure that SHOW TABLES below is right)
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index d70903adbc4..8be676d9a35 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -1,5 +1,4 @@
-# Requires use of multiple simultaneous connections, not supported with
-# embedded server testing
+# Uses GRANT commands that usually disabled in embedded server
-- source include/not_embedded.inc
#
diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test
index 7fea51c9327..df8da26df57 100644
--- a/mysql-test/t/status.test
+++ b/mysql-test/t/status.test
@@ -1,10 +1,3 @@
-# This test doesn't work with the embedded version as this code
-# assumes that one query is running while we are doing queries on
-# a second connection.
-# This would work if mysqltest run would be threaded and handle each
-# connection in a separate thread.
-#
---source include/not_embedded.inc
# PS causes different statistics
--disable_ps_protocol
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index f3877b301d6..804cc2274c9 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -1948,4 +1948,37 @@ SELECT field1, field2
DROP TABLE t1, t2;
+#
+# Bug #23478: not top-level IN subquery returning a non-empty result set
+# with possible NULL values by index access from the outer query
+#
+
+CREATE TABLE t1(a int, INDEX (a));
+INSERT INTO t1 VALUES (1), (3), (5), (7);
+INSERT INTO t1 VALUES (NULL);
+
+CREATE TABLE t2(a int);
+INSERT INTO t2 VALUES (1),(2),(3);
+
+EXPLAIN SELECT a, a IN (SELECT a FROM t1) FROM t2;
+SELECT a, a IN (SELECT a FROM t1) FROM t2;
+
+DROP TABLE t1,t2;
+
+#
+# Bug #11302: getObject() returns a String for a sub-query of type datetime
+#
+CREATE TABLE t1 (a DATETIME);
+INSERT INTO t1 VALUES ('1998-09-23'), ('2003-03-25');
+
+CREATE TABLE t2 AS SELECT
+ (SELECT a FROM t1 WHERE a < '2000-01-01') AS sub_a
+ FROM t1 WHERE a > '2000-01-01';
+SHOW CREATE TABLE t2;
+
+CREATE TABLE t3 AS (SELECT a FROM t1 WHERE a < '2000-01-01') UNION (SELECT a FROM t1 WHERE a > '2000-01-01');
+SHOW CREATE TABLE t3;
+
+DROP TABLE t1,t2,t3;
+
# End of 4.1 tests
diff --git a/ndb/config/common.mk.am b/ndb/config/common.mk.am
index 4df1b0e289a..d0b7e753285 100644
--- a/ndb/config/common.mk.am
+++ b/ndb/config/common.mk.am
@@ -7,6 +7,6 @@ ndbapiincludedir = "$(pkgincludedir)/ndb/ndbapi"
mgmapiincludedir = "$(pkgincludedir)/ndb/mgmapi"
INCLUDES = $(INCLUDES_LOC)
-LDADD = $(LDADD_LOC) -L$(top_srcdir)/ndb/src/common/portlib -lmygcc
+LDADD = $(LDADD_LOC) -L$(top_builddir)/ndb/src/common/portlib -lmygcc
DEFS = @DEFS@ @NDB_DEFS@ $(DEFS_LOC) $(NDB_EXTRA_FLAGS)
NDB_CXXFLAGS=@ndb_cxxflags_fix@ $(NDB_CXXFLAGS_LOC)
diff --git a/ndb/config/type_kernel.mk.am b/ndb/config/type_kernel.mk.am
index 703876ee2e9..ccb01709dfb 100644
--- a/ndb/config/type_kernel.mk.am
+++ b/ndb/config/type_kernel.mk.am
@@ -1,6 +1,9 @@
INCLUDES += \
- -I$(srcdir) -I$(top_srcdir)/include \
+ -I$(srcdir) \
+ -I$(top_builddir)/include \
+ -I$(top_builddir)/ndb/include \
+ -I$(top_srcdir)/include \
-I$(top_srcdir)/ndb/include \
-I$(top_srcdir)/ndb/src/kernel/vm \
-I$(top_srcdir)/ndb/src/kernel/error \
diff --git a/ndb/config/type_ndbapi.mk.am b/ndb/config/type_ndbapi.mk.am
index ed648273aea..8b447bd693d 100644
--- a/ndb/config/type_ndbapi.mk.am
+++ b/ndb/config/type_ndbapi.mk.am
@@ -1,6 +1,10 @@
INCLUDES += \
- -I$(srcdir) -I$(top_srcdir)/include -I$(top_srcdir)/ndb/include \
+ -I$(srcdir) \
+ -I$(top_builddir)/include \
+ -I$(top_builddir)/ndb/include \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/ndb/include \
-I$(top_srcdir)/ndb/include/kernel \
-I$(top_srcdir)/ndb/include/transporter \
-I$(top_srcdir)/ndb/include/debugger \
diff --git a/ndb/config/type_ndbapitest.mk.am b/ndb/config/type_ndbapitest.mk.am
index 392c4e9fc70..e9a383eaad7 100644
--- a/ndb/config/type_ndbapitest.mk.am
+++ b/ndb/config/type_ndbapitest.mk.am
@@ -5,7 +5,10 @@ LDADD += $(top_builddir)/ndb/test/src/libNDBT.a \
$(top_builddir)/mysys/libmysys.a \
$(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
-INCLUDES += -I$(top_srcdir) -I$(top_srcdir)/include \
+INCLUDES += -I$(top_srcdir) \
+ -I$(top_builddir)/include \
+ -I$(top_builddir)/ndb/include \
+ -I$(top_srcdir)/include \
-I$(top_srcdir)/ndb/include \
-I$(top_srcdir)/ndb/include/ndbapi \
-I$(top_srcdir)/ndb/include/util \
diff --git a/ndb/config/type_ndbapitools.mk.am b/ndb/config/type_ndbapitools.mk.am
index 679dac09f47..1f4d93af618 100644
--- a/ndb/config/type_ndbapitools.mk.am
+++ b/ndb/config/type_ndbapitools.mk.am
@@ -5,7 +5,10 @@ LDADD += \
$(top_builddir)/mysys/libmysys.a \
$(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@ -lmygcc
-INCLUDES += -I$(srcdir) -I$(top_srcdir)/include \
+INCLUDES += -I$(srcdir) \
+ -I$(top_builddir)/include \
+ -I$(top_builddir)/ndb/include \
+ -I$(top_srcdir)/include \
-I$(top_srcdir)/ndb/include \
-I$(top_srcdir)/ndb/include/ndbapi \
-I$(top_srcdir)/ndb/include/util \
diff --git a/ndb/config/type_util.mk.am b/ndb/config/type_util.mk.am
index 0dfa77b7a7c..b92501faee9 100644
--- a/ndb/config/type_util.mk.am
+++ b/ndb/config/type_util.mk.am
@@ -1,5 +1,8 @@
-INCLUDES += -I$(srcdir) -I$(top_srcdir)/include \
+INCLUDES += -I$(srcdir) \
+ -I$(top_builddir)/include \
+ -I$(top_builddir)/ndb/include \
+ -I$(top_srcdir)/include \
-I$(top_srcdir)/ndb/include \
-I$(top_srcdir)/ndb/include/util \
-I$(top_srcdir)/ndb/include/portlib \
diff --git a/ndb/src/kernel/Makefile.am b/ndb/src/kernel/Makefile.am
index 5b55238c262..c9e590835db 100644
--- a/ndb/src/kernel/Makefile.am
+++ b/ndb/src/kernel/Makefile.am
@@ -9,21 +9,21 @@ ndbd_SOURCES = main.cpp SimBlockList.cpp
include $(top_srcdir)/ndb/config/type_kernel.mk.am
INCLUDES += \
- -Iblocks/cmvmi \
- -Iblocks/dbacc \
- -Iblocks/dbdict \
- -Iblocks/dbdih \
- -Iblocks/dblqh \
- -Iblocks/dbtc \
- -Iblocks/dbtup \
- -Iblocks/ndbfs \
- -Iblocks/ndbcntr \
- -Iblocks/qmgr \
- -Iblocks/trix \
- -Iblocks/backup \
- -Iblocks/dbutil \
- -Iblocks/suma \
- -Iblocks/dbtux
+ -I$(srcdir)/blocks/cmvmi \
+ -I$(srcdir)/blocks/dbacc \
+ -I$(srcdir)/blocks/dbdict \
+ -I$(srcdir)/blocks/dbdih \
+ -I$(srcdir)/blocks/dblqh \
+ -I$(srcdir)/blocks/dbtc \
+ -I$(srcdir)/blocks/dbtup \
+ -I$(srcdir)/blocks/ndbfs \
+ -I$(srcdir)/blocks/ndbcntr \
+ -I$(srcdir)/blocks/qmgr \
+ -I$(srcdir)/blocks/trix \
+ -I$(srcdir)/blocks/backup \
+ -I$(srcdir)/blocks/dbutil \
+ -I$(srcdir)/blocks/suma \
+ -I$(srcdir)/blocks/dbtux
LDADD += \
blocks/cmvmi/libcmvmi.a \
diff --git a/sql-common/client.c b/sql-common/client.c
index 3acd763c054..87e22624dd9 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -1173,6 +1173,8 @@ unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
for (row=data->data; row ; row = row->next,field++)
{
uchar *pos;
+ /* fields count may be wrong */
+ DBUG_ASSERT ((field - result) < fields);
cli_fetch_lengths(&lengths[0], row->data, default_value ? 8 : 7);
field->catalog = strdup_root(alloc,(char*) row->data[0]);
field->db = strdup_root(alloc,(char*) row->data[1]);
diff --git a/sql/item.cc b/sql/item.cc
index 94f0a24fcc3..45d7856b2c1 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1761,10 +1761,37 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
Item** res= find_item_in_list(this, thd->lex->current_select->item_list,
&counter, REPORT_EXCEPT_NOT_FOUND,
&not_used);
- if (res != (Item **)not_found_item && (*res)->type() == Item::FIELD_ITEM)
+ if (res != (Item **)not_found_item)
{
- set_field((*((Item_field**)res))->field);
- return 0;
+ if ((*res)->type() == Item::FIELD_ITEM)
+ {
+ /*
+ It's an Item_field referencing another Item_field in the select
+ list.
+ use the field from the Item_field in the select list and leave
+ the Item_field instance in place.
+ */
+ set_field((*((Item_field**)res))->field);
+ return 0;
+ }
+ else
+ {
+ /*
+ It's not an Item_field in the select list so we must make a new
+ Item_ref to point to the Item in the select list and replace the
+ Item_field created by the parser with the new Item_ref.
+ */
+ Item_ref *rf= new Item_ref(db_name,table_name,field_name);
+ if (!rf)
+ return 1;
+ thd->change_item_tree(ref, rf);
+ /*
+ Because Item_ref never substitutes itself with other items
+ in Item_ref::fix_fields(), we can safely use the original
+ pointer to it even after fix_fields()
+ */
+ return rf->fix_fields(thd, tables, ref) || rf->check_cols(1);
+ }
}
}
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index f3be0663af8..cd1f8f83821 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -391,6 +391,15 @@ enum Item_result Item_singlerow_subselect::result_type() const
return engine->type();
}
+/*
+ Don't rely on the result type to calculate field type.
+ Ask the engine instead.
+*/
+enum_field_types Item_singlerow_subselect::field_type() const
+{
+ return engine->field_type();
+}
+
void Item_singlerow_subselect::fix_length_and_dec()
{
if ((max_columns= engine->cols()) == 1)
@@ -610,6 +619,7 @@ double Item_in_subselect::val()
*/
DBUG_ASSERT(0);
DBUG_ASSERT(fixed == 1);
+ null_value= 0;
if (exec())
{
reset();
@@ -625,6 +635,7 @@ double Item_in_subselect::val()
longlong Item_in_subselect::val_int()
{
DBUG_ASSERT(fixed == 1);
+ null_value= 0;
if (exec())
{
reset();
@@ -645,6 +656,7 @@ String *Item_in_subselect::val_str(String *str)
*/
DBUG_ASSERT(0);
DBUG_ASSERT(fixed == 1);
+ null_value= 0;
if (exec())
{
reset();
@@ -1354,31 +1366,35 @@ int subselect_uniquesubquery_engine::prepare()
return 1;
}
-static Item_result set_row(List<Item> &item_list, Item *item,
- Item_cache **row, bool *maybe_null)
+/*
+ makes storage for the output values for the subquery and calcuates
+ their data and column types and their nullability.
+*/
+void subselect_engine::set_row(List<Item> &item_list, Item_cache **row)
{
- Item_result res_type= STRING_RESULT;
Item *sel_item;
List_iterator_fast<Item> li(item_list);
+ res_type= STRING_RESULT;
+ res_field_type= FIELD_TYPE_VAR_STRING;
for (uint i= 0; (sel_item= li++); i++)
{
item->max_length= sel_item->max_length;
res_type= sel_item->result_type();
+ res_field_type= sel_item->field_type();
item->decimals= sel_item->decimals;
- *maybe_null= sel_item->maybe_null;
+ maybe_null= sel_item->maybe_null;
if (!(row[i]= Item_cache::get_cache(res_type)))
- return STRING_RESULT; // we should return something
+ return;
row[i]->setup(sel_item);
}
if (item_list.elements > 1)
res_type= ROW_RESULT;
- return res_type;
}
void subselect_single_select_engine::fix_length_and_dec(Item_cache **row)
{
DBUG_ASSERT(row || select_lex->item_list.elements==1);
- res_type= set_row(select_lex->item_list, item, row, &maybe_null);
+ set_row(select_lex->item_list, row);
item->collation.set(row[0]->collation);
if (cols() != 1)
maybe_null= 0;
@@ -1390,13 +1406,14 @@ void subselect_union_engine::fix_length_and_dec(Item_cache **row)
if (unit->first_select()->item_list.elements == 1)
{
- res_type= set_row(unit->types, item, row, &maybe_null);
+ set_row(unit->types, row);
item->collation.set(row[0]->collation);
}
else
{
- bool fake= 0;
- res_type= set_row(unit->types, item, row, &fake);
+ bool maybe_null_saved= maybe_null;
+ set_row(unit->types, row);
+ maybe_null= maybe_null_saved;
}
}
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index 93171ad64a1..7b064bfe92c 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -142,6 +142,7 @@ public:
longlong val_int ();
String *val_str (String *);
enum Item_result result_type() const;
+ enum_field_types field_type() const;
void fix_length_and_dec();
uint cols();
@@ -273,6 +274,7 @@ protected:
THD *thd; /* pointer to current THD */
Item_subselect *item; /* item, that use this engine */
enum Item_result res_type; /* type of results */
+ enum_field_types res_field_type; /* column type of the results */
bool maybe_null; /* may be null (first item in select) */
public:
@@ -282,6 +284,7 @@ public:
result= res;
item= si;
res_type= STRING_RESULT;
+ res_field_type= FIELD_TYPE_VAR_STRING;
maybe_null= 0;
}
virtual ~subselect_engine() {}; // to satisfy compiler
@@ -296,6 +299,7 @@ public:
virtual uint cols()= 0; /* return number of columnss in select */
virtual uint8 uncacheable()= 0; /* query is uncacheable */
enum Item_result type() { return res_type; }
+ enum_field_types field_type() { return res_field_type; }
virtual void exclude()= 0;
bool may_be_null() { return maybe_null; };
virtual table_map upper_select_const_tables()= 0;
@@ -303,6 +307,9 @@ public:
virtual void print(String *str)= 0;
virtual int change_item(Item_subselect *si, select_subselect *result)= 0;
virtual bool no_tables()= 0;
+
+protected:
+ void set_row(List<Item> &item_list, Item_cache **row);
};
diff --git a/sql/protocol.cc b/sql/protocol.cc
index a2287740f1e..7c7dfaf7bef 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -43,7 +43,7 @@ bool Protocol_prep::net_store_data(const char *from, uint length)
packet->realloc(packet_length+9+length))
return 1;
char *to=(char*) net_store_length((char*) packet->ptr()+packet_length,
- (ulonglong) length);
+ length);
memcpy(to,from,length);
packet->length((uint) (to+length-packet->ptr()));
return 0;
@@ -297,8 +297,8 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message)
DBUG_VOID_RETURN;
buff[0]=0; // No fields
- pos=net_store_length(buff+1,(ulonglong) affected_rows);
- pos=net_store_length(pos, (ulonglong) id);
+ pos=net_store_length(buff+1,affected_rows);
+ pos=net_store_length(pos, id);
if (thd->client_capabilities & CLIENT_PROTOCOL_41)
{
DBUG_PRINT("info",
@@ -416,7 +416,7 @@ bool send_old_password_request(THD *thd)
ulonglong for bigger numbers.
*/
-char *net_store_length(char *pkg, uint length)
+static char *net_store_length_fast(char *pkg, uint length)
{
uchar *packet=(uchar*) pkg;
if (length < 251)
@@ -439,7 +439,7 @@ char *net_store_length(char *pkg, uint length)
char *net_store_data(char *to,const char *from, uint length)
{
- to=net_store_length(to,length);
+ to=net_store_length_fast(to,length);
memcpy(to,from,length);
return to+length;
}
@@ -448,7 +448,7 @@ char *net_store_data(char *to,int32 from)
{
char buff[20];
uint length=(uint) (int10_to_str(from,buff,10)-buff);
- to=net_store_length(to,length);
+ to=net_store_length_fast(to,length);
memcpy(to,buff,length);
return to+length;
}
@@ -457,7 +457,7 @@ char *net_store_data(char *to,longlong from)
{
char buff[22];
uint length=(uint) (longlong10_to_str(from,buff,10)-buff);
- to=net_store_length(to,length);
+ to=net_store_length_fast(to,length);
memcpy(to,buff,length);
return to+length;
}
@@ -520,7 +520,7 @@ bool Protocol::send_fields(List<Item> *list, uint flag)
if (flag & 1)
{ // Packet with number of elements
- char *pos=net_store_length(buff, (uint) list->elements);
+ char *pos=net_store_length(buff, list->elements);
(void) my_net_write(&thd->net, buff,(uint) (pos-buff));
}
@@ -648,7 +648,7 @@ bool Protocol::send_records_num(List<Item> *list, ulonglong records)
{
char *pos;
char buff[20];
- pos=net_store_length(buff, (uint) list->elements);
+ pos=net_store_length(buff, list->elements);
pos=net_store_length(pos, records);
return my_net_write(&thd->net, buff,(uint) (pos-buff));
}
diff --git a/sql/protocol.h b/sql/protocol.h
index 32d6acccddf..ce3adb41df5 100644
--- a/sql/protocol.h
+++ b/sql/protocol.h
@@ -177,7 +177,6 @@ void send_ok(THD *thd, ha_rows affected_rows=0L, ulonglong id=0L,
const char *info=0);
void send_eof(THD *thd, bool no_flush=0);
bool send_old_password_request(THD *thd);
-char *net_store_length(char *packet,uint length);
char *net_store_data(char *to,const char *from, uint length);
char *net_store_data(char *to,int32 from);
char *net_store_data(char *to,longlong from);
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 7cf0b474ed7..16abfe2b6b6 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -686,6 +686,12 @@ public:
char *extra_data;
ulong extra_length;
String query_rest;
+ /*
+ In embedded server it points to the statement that is processed
+ in the current query. We store some results directly in statement
+ fields then.
+ */
+ struct st_mysql_stmt *current_stmt;
#endif
NET net; // client connection descriptor
MEM_ROOT warn_root; // For warnings and errors
diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh
index 1daac2d0e95..b14ffd24894 100644
--- a/support-files/mysql.spec.sh
+++ b/support-files/mysql.spec.sh
@@ -170,6 +170,8 @@ necessary to develop MySQL client applications.
%package shared
Summary: MySQL - Shared libraries
Group: Applications/Databases
+Provides: mysql-shared
+Obsoletes: mysql-shared
%description shared
This package contains the shared libraries (*.so*) which certain
@@ -317,7 +319,10 @@ then
cp -fp config.log "$MYSQL_MAXCONFLOG_DEST"
fi
-make -i test-force || true
+( cd mysql-test
+ perl ./mysql-test-run.pl --force --report-features
+ perl ./mysql-test-run.pl --force --ps-protocol
+ true )
# Save mysqld-max
./libtool --mode=execute cp sql/mysqld sql/mysqld-max
@@ -380,7 +385,10 @@ then
cp -fp config.log "$MYSQL_CONFLOG_DEST"
fi
-make -i test-force || true
+( cd mysql-test
+ perl ./mysql-test-run.pl --force --report-features
+ perl ./mysql-test-run.pl --force --ps-protocol
+ true )
%install
RBR=$RPM_BUILD_ROOT
@@ -716,6 +724,17 @@ fi
# itself - note that they must be ordered by date (important when
# merging BK trees)
%changelog
+* Thu Nov 16 2006 Joerg Bruehe <joerg@mysql.com>
+
+- Explicitly note that the "MySQL-shared" RPMs (as built by MySQL AB)
+ replace "mysql-shared" (as distributed by SuSE) to allow easy upgrading
+ (bug#22081).
+
+* Wed Nov 15 2006 Joerg Bruehe <joerg@mysql.com>
+
+- Switch from "make test*" to explicit calls of the test suite,
+ so that "report features" can be used.
+
* Tue Jun 27 2006 Joerg Bruehe <joerg@mysql.com>
- move "mysqldumpslow" from the client RPM to the server RPM (bug#20216)