Commit e971334e authored by unknown's avatar unknown
Browse files

Merge mysql.com:/home/hf/work/mysql-4.1-mrg

into  mysql.com:/home/hf/work/mysql-5.0-mrg


client/mysqltest.c:
  Auto merged
mysql-test/t/flush.test:
  Auto merged
mysql-test/t/flush_block_commit.test:
  Auto merged
mysql-test/t/innodb-deadlock.test:
  Auto merged
mysql-test/t/innodb-lock.test:
  Auto merged
mysql-test/t/lock_multi.test:
  Auto merged
mysql-test/t/rename.test:
  Auto merged
mysql-test/t/show_check.test:
  Auto merged
mysql-test/t/status.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/protocol.h:
  Auto merged
sql-common/client.c:
  Auto merged
Makefile.am:
  merging
BitKeeper/deleted/.del-mysql_client.test:
  merging
include/mysql.h:
  SCCS merged
libmysql/libmysql.c:
  merging
libmysqld/lib_sql.cc:
  merging
mysql-test/r/order_by.result:
  SCCS merged
mysql-test/r/subselect.result:
  SCCS merged
mysql-test/t/order_by.test:
  merging
mysql-test/t/subselect.test:
  SCCS merged
sql/item_subselect.cc:
  merging
sql/item_subselect.h:
  merging
sql/protocol.cc:
  merging
sql/sql_class.h:
  merging
parents daaddeb6 e78fd1d1
Loading
Loading
Loading
Loading
+79 −10
Original line number Diff line number Diff line
@@ -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)
@@ -4498,7 +4554,6 @@ int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql)
}



/*
  Run query using MySQL C API

@@ -4515,10 +4570,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");
@@ -4530,14 +4586,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;

@@ -5028,8 +5096,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;
@@ -5186,7 +5255,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)
@@ -5651,7 +5720,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++;
@@ -5682,7 +5751,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;
@@ -5708,7 +5777,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;
+1 −0
Original line number Diff line number Diff line
@@ -100,6 +100,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;
  thd->current_stmt= stmt;

  thd->store_globals();				// Fix if more than one connect
  /* 
+27 −0
Original line number Diff line number Diff line
@@ -854,6 +854,33 @@ 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;
CREATE TABLE t1 (a int, b int, PRIMARY KEY  (a));
INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
explain SELECT t1.b as a, t2.b as c FROM 
+32 −0
Original line number Diff line number Diff line
@@ -3001,6 +3001,38 @@ 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;
create table t1 (df decimal(5,1));
insert into t1 values(1.1);
insert into t1 values(2.2);
+0 −8
Original line number Diff line number Diff line
# 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,,);
Loading