Merge mysql.com:/home/jimw/my/mysql-5.0-12318

into  mysql.com:/home/jimw/my/mysql-5.0-clean


sql/mysql_priv.h:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
This commit is contained in:
unknown 2005-08-15 12:39:36 -07:00
commit d6a6a48861
147 changed files with 5446 additions and 2640 deletions

View file

@ -1121,3 +1121,5 @@ vio/test-ssl
vio/test-sslclient
vio/test-sslserver
vio/viotest-ssl
support-files/MacOSX/postflight
support-files/MacOSX/preflight

View file

@ -624,7 +624,7 @@ static struct my_option my_long_options[] =
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port,
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0,
(gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
0},
{"prompt", OPT_PROMPT, "Set the mysql prompt to this value.",
(gptr*) &current_prompt, (gptr*) &current_prompt, 0, GET_STR_ALLOC,

View file

@ -575,8 +575,13 @@ static void print_result()
if (status)
{
/*
if there was an error with the table, we have --auto-repair set,
and this isn't a repair op, then add the table to the tables4repair
list
*/
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR &&
(!opt_fast || strcmp(row[3],"OK")))
strcmp(row[3],"OK"))
insert_dynamic(&tables4repair, prev);
found_error=0;
if (opt_silent)
@ -595,8 +600,8 @@ static void print_result()
strmov(prev, row[0]);
putchar('\n');
}
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR &&
!opt_fast)
/* add the last table to be repaired to the list */
if (found_error && opt_auto_repair && what_to_do != DO_REPAIR)
insert_dynamic(&tables4repair, prev);
mysql_free_result(res);
}

View file

@ -5,12 +5,9 @@ extra/yassl/src/Makefile)
AC_DEFUN([MYSQL_CHECK_YASSL], [
AC_MSG_CHECKING(for yaSSL)
AC_ARG_WITH([yassl],
[ --with-yassl Include the yaSSL support],
[yassl=yes],
[yassl=no])
AC_ARG_WITH([yassl], [ --with-yassl Include the yaSSL support],,)
if test "$yassl" = "yes"
if test "$with_yassl" = "yes"
then
if test "$openssl" != "no"
then
@ -30,5 +27,5 @@ AC_DEFUN([MYSQL_CHECK_YASSL], [
AC_SUBST(openssl_libs)
AC_SUBST(openssl_includes)
AC_SUBST(yassl_dir)
AM_CONDITIONAL([HAVE_YASSL], [ test "$yassl" = "yes" ])
AM_CONDITIONAL([HAVE_YASSL], [ test "with_yassl" = "yes" ])
])

View file

@ -1,7 +1,7 @@
dnl -*- ksh -*-
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)dnl Minimum Autoconf version required.
AC_PREREQ(2.52)dnl Minimum Autoconf version required.
AC_INIT(sql/mysqld.cc)
AC_CANONICAL_SYSTEM
@ -130,6 +130,7 @@ AC_PROG_MAKE_SET
# Hack for OS X/Darwin and Metrowerks CodeWarrior
AC_ARG_WITH(darwin-mwcc,
[ --with-darwin-mwcc Use Metrowerks CodeWarrior wrappers on OS X/Darwin],[
if [ "with_darwin_mwcc" = yes ] ; then
builddir=`pwd`
ccwrapper="$builddir/support-files/MacOSX/mwcc-wrapper"
arwrapper="$builddir/support-files/MacOSX/mwar-wrapper"
@ -141,7 +142,7 @@ AC_ARG_WITH(darwin-mwcc,
export CC CXX LD AR RANLIB
AC_SUBST(AR)
AC_SUBST(RANLIB)
with_darwin_mwcc=yes
fi
])
AM_CONDITIONAL(DARWIN_MWCC, test x$with_darwin_mwcc = xyes)

View file

@ -36,7 +36,7 @@ extern void list_free(LIST *root,unsigned int free_data);
extern unsigned int list_length(LIST *);
extern int list_walk(LIST *,list_walk_action action,gptr argument);
#define rest(a) ((a)->next)
#define list_rest(a) ((a)->next)
#define list_push(a,b) (a)=list_cons((b),(a))
#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; my_free((gptr) old,MYF(MY_FAE)); }

View file

@ -210,7 +210,7 @@ btr_pcur_restore_position(
&& cursor->pos_state != BTR_PCUR_IS_POSITIONED)) {
ut_print_buf(stderr, (const byte*)cursor, sizeof(btr_pcur_t));
if (cursor->trx_if_known) {
trx_print(stderr, cursor->trx_if_known);
trx_print(stderr, cursor->trx_if_known, 0);
}
ut_error;

View file

@ -329,17 +329,20 @@ trx_commit_step(
/*============*/
/* out: query thread to run next, or NULL */
que_thr_t* thr); /* in: query thread */
/**************************************************************************
Prints info about a transaction to the standard output. The caller must
own the kernel mutex and must have called
innobase_mysql_prepare_print_arbitrary_thd(), unless he knows that MySQL or
InnoDB cannot meanwhile change the info printed here. */
Prints info about a transaction to the given file. The caller must own the
kernel mutex and must have called
innobase_mysql_prepare_print_arbitrary_thd(), unless he knows that MySQL
or InnoDB cannot meanwhile change the info printed here. */
void
trx_print(
/*======*/
FILE* f, /* in: output stream */
trx_t* trx); /* in: transaction */
FILE* f, /* in: output stream */
trx_t* trx, /* in: transaction */
uint max_query_len); /* in: max query length to print, or 0 to
use the default max length */
#ifndef UNIV_HOTBACKUP
/**************************************************************************

View file

@ -3297,7 +3297,7 @@ lock_deadlock_recursive(
fputs("\n*** (1) TRANSACTION:\n", ef);
trx_print(ef, wait_lock->trx);
trx_print(ef, wait_lock->trx, 3000);
fputs(
"*** (1) WAITING FOR THIS LOCK TO BE GRANTED:\n", ef);
@ -3310,7 +3310,7 @@ lock_deadlock_recursive(
fputs("*** (2) TRANSACTION:\n", ef);
trx_print(ef, lock->trx);
trx_print(ef, lock->trx, 3000);
fputs("*** (2) HOLDS THE LOCK(S):\n", ef);
@ -4207,7 +4207,7 @@ lock_print_info_all_transactions(
while (trx) {
if (trx->conc_state == TRX_NOT_STARTED) {
fputs("---", file);
trx_print(file, trx);
trx_print(file, trx, 600);
}
trx = UT_LIST_GET_NEXT(mysql_trx_list, trx);
@ -4239,7 +4239,7 @@ loop:
if (nth_lock == 0) {
fputs("---", file);
trx_print(file, trx);
trx_print(file, trx, 600);
if (trx->read_view) {
fprintf(file,

View file

@ -602,7 +602,7 @@ row_ins_foreign_report_err(
rewind(ef);
ut_print_timestamp(ef);
fputs(" Transaction:\n", ef);
trx_print(ef, trx);
trx_print(ef, trx, 600);
fputs("Foreign key constraint fails for table ", ef);
ut_print_name(ef, trx, foreign->foreign_table_name);
@ -653,7 +653,7 @@ row_ins_foreign_report_add_err(
rewind(ef);
ut_print_timestamp(ef);
fputs(" Transaction:\n", ef);
trx_print(ef, trx);
trx_print(ef, trx, 600);
fputs("Foreign key constraint fails for table ", ef);
ut_print_name(ef, trx, foreign->foreign_table_name);
fputs(":\n", ef);
@ -1228,7 +1228,7 @@ run_again:
rewind(ef);
ut_print_timestamp(ef);
fputs(" Transaction:\n", ef);
trx_print(ef, trx);
trx_print(ef, trx, 600);
fputs("Foreign key constraint fails for table ", ef);
ut_print_name(ef, trx, foreign->foreign_table_name);
fputs(":\n", ef);

View file

@ -2685,7 +2685,7 @@ row_sel_get_clust_rec_for_mysql(
"InnoDB: clust index record ", stderr);
rec_print(stderr, clust_rec, clust_index);
putc('\n', stderr);
trx_print(stderr, trx);
trx_print(stderr, trx, 600);
fputs("\n"
"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr);
@ -3128,7 +3128,7 @@ row_search_for_mysql(
"InnoDB: Error: MySQL is trying to perform a SELECT\n"
"InnoDB: but it has not locked any tables in ::external_lock()!\n",
stderr);
trx_print(stderr, trx);
trx_print(stderr, trx, 600);
fputc('\n', stderr);
}
@ -3455,7 +3455,7 @@ shortcut_fails_too_big_rec:
fputs(
"InnoDB: Error: MySQL is trying to perform a consistent read\n"
"InnoDB: but the read view is not assigned!\n", stderr);
trx_print(stderr, trx);
trx_print(stderr, trx, 600);
fputc('\n', stderr);
ut_a(0);
}

View file

@ -431,7 +431,7 @@ row_undo_mod_del_unmark_sec_and_undo_update(
"InnoDB: record ", stderr);
rec_print(stderr, btr_pcur_get_rec(&pcur), index);
putc('\n', stderr);
trx_print(stderr, trx);
trx_print(stderr, trx, 0);
fputs("\n"
"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr);
} else {

View file

@ -1279,7 +1279,7 @@ row_upd_sec_index_entry(
rec_print(stderr, rec, index);
putc('\n', stderr);
trx_print(stderr, trx);
trx_print(stderr, trx, 0);
fputs("\n"
"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr);

View file

@ -1000,7 +1000,7 @@ retry:
fputs(
" InnoDB: Error: trying to declare trx to enter InnoDB, but\n"
"InnoDB: it already is declared.\n", stderr);
trx_print(stderr, trx);
trx_print(stderr, trx, 0);
putc('\n', stderr);
os_fast_mutex_unlock(&srv_conc_mutex);

View file

@ -30,8 +30,9 @@ Created 3/26/1996 Heikki Tuuri
copy MUST be equal to the one in mysql/sql/ha_innodb.cc ! */
void innobase_mysql_print_thd(
FILE* f,
void* thd);
FILE* f,
void* thd,
uint max_query_len);
/* Dummy session used currently in MySQL interface */
sess_t* trx_dummy_sess = NULL;
@ -262,7 +263,7 @@ trx_free(
fputs(
" InnoDB: Error: Freeing a trx which is declared to be processing\n"
"InnoDB: inside InnoDB.\n", stderr);
trx_print(stderr, trx);
trx_print(stderr, trx, 600);
putc('\n', stderr);
}
@ -277,7 +278,7 @@ trx_free(
(ulong)trx->n_mysql_tables_in_use,
(ulong)trx->mysql_n_tables_locked);
trx_print(stderr, trx);
trx_print(stderr, trx, 600);
ut_print_buf(stderr, (byte*)trx, sizeof(trx_t));
}
@ -1651,16 +1652,18 @@ trx_mark_sql_stat_end(
}
/**************************************************************************
Prints info about a transaction to the standard output. The caller must
own the kernel mutex and must have called
innobase_mysql_prepare_print_arbitrary_thd(), unless he knows that MySQL or
InnoDB cannot meanwhile change the info printed here. */
Prints info about a transaction to the given file. The caller must own the
kernel mutex and must have called
innobase_mysql_prepare_print_arbitrary_thd(), unless he knows that MySQL
or InnoDB cannot meanwhile change the info printed here. */
void
trx_print(
/*======*/
FILE* f, /* in: output stream */
trx_t* trx) /* in: transaction */
FILE* f, /* in: output stream */
trx_t* trx, /* in: transaction */
uint max_query_len) /* in: max query length to print, or 0 to
use the default max length */
{
ibool newline;
@ -1755,7 +1758,7 @@ trx_print(
}
if (trx->mysql_thd != NULL) {
innobase_mysql_print_thd(f, trx->mysql_thd);
innobase_mysql_print_thd(f, trx->mysql_thd, max_query_len);
}
}

View file

@ -695,14 +695,22 @@ static int compress(PACK_MRG_INFO *mrg,char *result_table)
else
error=my_rename(new_name,org_name,MYF(MY_WME));
if (!error)
{
VOID(my_copystat(temp_name,org_name,MYF(MY_COPYTIME)));
if (tmp_dir[0])
VOID(my_delete(new_name,MYF(MY_WME)));
}
}
}
else
{
if (tmp_dir[0])
{
error=my_copy(new_name,org_name,
MYF(MY_WME | MY_HOLD_ORIGINAL_MODES | MY_COPYTIME));
if (!error)
VOID(my_delete(new_name,MYF(MY_WME)));
}
else
error=my_redel(org_name,new_name,MYF(MY_WME | MY_COPYTIME));
}

View file

@ -349,14 +349,14 @@ drop table if exists t2 ;
--enable_warnings
create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 order by a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) order by a ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 order by a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) order by a ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 order by a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) order by a ' ;
let $1= 9 ;
while ($1)
{

View file

@ -229,6 +229,7 @@ drop table t1;
#
# Bug #9489: problem with hash indexes
# Bug #10802: Index is not used if table using BDB engine on HP-UX
#
create table t1(a int, b varchar(12), key ba(b, a));

View file

@ -732,7 +732,7 @@ drop table t1;
set @a:=now();
CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=bdb;
insert into t1 (a) values(1),(2),(3);
select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a;
select a from t1 natural join t1 as t2 where b >= @a order by a;
a
1
2
@ -906,7 +906,7 @@ create temporary table tmp1
select branch_id, target_id, platform_id, product_id
from t1, t2, t3, t4 ;
create temporary table tmp2
select tmp1.branch_id, tmp1.target_id, tmp1.platform_id, tmp1.product_id
select branch_id, target_id, platform_id, product_id
from tmp1 left join t8
using (branch_id,target_id,platform_id,product_id)
where t8.archive_id is null ;

View file

@ -111,7 +111,7 @@ a b
1 a
2 b
3 c
explain select * from (select * from t1,t2 where t1.a=t2.a) t1;
explain select * from (select t1.*, t2.a as t2a from t1,t2 where t1.a=t2.a) t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> system NULL NULL NULL NULL 1
2 DERIVED t2 system NULL NULL NULL NULL 1
@ -149,8 +149,8 @@ SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
(SELECT * FROM (SELECT 1 as a) as a )
1
select * from (select 1 as a) b left join (select 2 as a) c using(a);
a a
1 NULL
a
1
SELECT * FROM (SELECT 1 UNION SELECT a) b;
ERROR 42S22: Unknown column 'a' in 'field list'
SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
@ -363,3 +363,8 @@ a
3
3
drop table t1, t2, t3;
create table t1 (a int);
create table t2 (a int);
select * from (select * from t1,t2) foo;
ERROR 42S21: Duplicate column name 'a'
drop table t1,t2;

View file

@ -9,9 +9,9 @@ create table t1 (a int);
select count(test.t1.b) from t1;
ERROR 42S22: Unknown column 'test.t1.b' in 'field list'
select count(not_existing_database.t1) from t1;
ERROR 42S02: Unknown table 'not_existing_database' in field list
ERROR 42S22: Unknown column 'not_existing_database.t1' in 'field list'
select count(not_existing_database.t1.a) from t1;
ERROR 42S02: Unknown table 'not_existing_database.t1' in field list
ERROR 42S22: Unknown column 'not_existing_database.t1.a' in 'field list'
select count(not_existing_database.t1.a) from not_existing_database.t1;
Got one of the listed errors
select 1 from t1 order by 2;

View file

@ -221,14 +221,14 @@ select t1.id FROM t2 as ttxt,t1,t1 as ticket2
WHERE ticket2.id = ttxt.ticket AND t1.id = ticket2.ticket and
match(ttxt.inhalt) against ('foobar');
id
select t1.id FROM t2 as ttxt,t1 INNER JOIN t1 as ticket2 ON
ticket2.id = ttxt.ticket
WHERE t1.id = ticket2.ticket and match(ttxt.inhalt) against ('foobar');
select ticket2.id FROM t2 as ttxt,t2 INNER JOIN t1 as ticket2 ON
ticket2.id = t2.ticket
WHERE ticket2.id = ticket2.ticket and match(ttxt.inhalt) against ('foobar');
id
INSERT INTO t1 VALUES (3,3);
select t1.id FROM t2 as ttxt,t1
INNER JOIN t1 as ticket2 ON ticket2.id = ttxt.ticket
WHERE t1.id = ticket2.ticket and
select ticket2.id FROM t2 as ttxt,t2
INNER JOIN t1 as ticket2 ON ticket2.id = t2.ticket
WHERE ticket2.id = ticket2.ticket and
match(ttxt.inhalt) against ('foobar');
id
3
@ -337,8 +337,8 @@ insert into t2 values (1, 1, 'xxfoo');
insert into t2 values (2, 1, 'xxbar');
insert into t2 values (3, 1, 'xxbuz');
select * from t1 join t2 using(`t1_id`) where match (t1.name, t2.name) against('xxfoo' in boolean mode);
t1_id name t2_id t1_id name
1 data1 1 1 xxfoo
t1_id name t2_id name
1 data1 1 xxfoo
select * from t2 where match name against ('*a*b*c*d*e*f*' in boolean mode);
t2_id t1_id name
drop table t1,t2;

View file

@ -126,7 +126,7 @@ group by
a.text, b.id, b.betreff
order by
match(b.betreff) against ('+abc' in boolean mode) desc;
ERROR 42S02: Unknown table 'b' in order clause
ERROR 42S22: Unknown column 'b.betreff' in 'order clause'
select a.text, b.id, b.betreff
from
t2 a inner join t3 b on a.id = b.forum inner join
@ -142,7 +142,7 @@ where
match(c.beitrag) against ('+abc' in boolean mode)
order by
match(b.betreff) against ('+abc' in boolean mode) desc;
ERROR 42S02: Unknown table 'b' in order clause
ERROR 42S22: Unknown column 'b.betreff' in 'order clause'
select a.text, b.id, b.betreff
from
t2 a inner join t3 b on a.id = b.forum inner join

View file

@ -45,3 +45,29 @@ visitor_id mts
465931136 2000-03-18 16:09:53
1092858576 2000-03-19 01:34:45
drop table t1;
set sql_mode='traditional';
create table t1 (d date);
insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR);
ERROR 22008: Datetime function: datetime field overflow
insert into t1 (d) select date_add('2000-01-01',interval 8000 year);
ERROR 22008: Datetime function: datetime field overflow
insert into t1 values (date_add(NULL, INTERVAL 1 DAY));
insert into t1 values (date_add('2000-01-04', INTERVAL NULL DAY));
set sql_mode='';
insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR);
Warnings:
Warning 1437 Datetime function: datetime field overflow
insert into t1 (d) select date_add('2000-01-01',interval 8000 year);
Warnings:
Warning 1437 Datetime function: datetime field overflow
insert into t1 values (date_add(NULL, INTERVAL 1 DAY));
insert into t1 values (date_add('2000-01-04', INTERVAL NULL DAY));
select * from t1;
d
NULL
NULL
NULL
NULL
NULL
NULL
drop table t1;

View file

@ -59,3 +59,14 @@ t1 CREATE TABLE `t1` (
`length(uuid())` int(10) NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a timestamp default '2005-05-05 01:01:01',
b timestamp default '2005-05-05 01:01:01');
insert into t1 set a = now();
select sleep(3);
sleep(3)
0
update t1 set b = now();
select timediff(b, a) >= '00:00:03' from t1;
timediff(b, a) >= '00:00:03'
1
drop table t1;

View file

@ -68,6 +68,21 @@ drop table t1;
select TRUE,FALSE,NULL;
TRUE FALSE NULL
1 0 NULL
create table t1 (c1 char(5)) character set=latin1;
insert into t1 values('row 1');
insert into t1 values('row 2');
insert into t1 values('row 3');
select concat(user(), '--', c1) from t1;
concat(user(), '--', c1)
root@localhost--row 1
root@localhost--row 2
root@localhost--row 3
select concat(database(), '--', c1) from t1;
concat(database(), '--', c1)
test--row 1
test--row 2
test--row 3
drop table t1;
create table t1 (a char(10)) character set latin1;
select * from t1 where a=version();
a

View file

@ -687,7 +687,7 @@ timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select timestamp_diff(WEEK,_latin1'2001-02-01',_latin1'2001-05-01') AS `a1`,timestamp_diff(SECOND_FRAC,_latin1'2001-02-01 12:59:59.120000',_latin1'2001-05-01 12:58:58.119999') AS `a2`
Note 1003 select timestampdiff(WEEK,_latin1'2001-02-01',_latin1'2001-05-01') AS `a1`,timestampdiff(SECOND_FRAC,_latin1'2001-02-01 12:59:59.120000',_latin1'2001-05-01 12:58:58.119999') AS `a2`
select last_day('2005-00-00');
last_day('2005-00-00')
NULL

View file

@ -958,3 +958,12 @@ trigger_schema trigger_name
test tr1
use test;
drop table t1;
create table t1 (a int not null, b int);
use information_schema;
select column_name, column_default from columns
where table_schema='test' and table_name='t1';
column_name column_default
a NULL
b NULL
use test;
drop table t1;

View file

@ -750,7 +750,7 @@ drop table t1;
set @a:=now();
CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=innodb;
insert into t1 (a) values(1),(2),(3);
select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a;
select a from t1 natural join t1 as t2 where b >= @a order by a;
a
1
2
@ -1377,7 +1377,7 @@ ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fail
update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
ERROR 42S02: Unknown table 't1' in where clause
ERROR 42S22: Unknown column 't1.id' in 'where clause'
drop table t3,t2,t1;
create table t1(
id int primary key,

View file

@ -664,7 +664,7 @@ insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= a +
insert into t1 select t2.a from t2 on duplicate key update a= a + t2.b;
ERROR 23000: Column 'a' in field list is ambiguous
insert into t1 select t2.a from t2 on duplicate key update t2.a= a + t2.b;
ERROR 42S02: Unknown table 't2' in field list
ERROR 42S22: Unknown column 't2.a' in 'field list'
insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= t1.a + t2.b;
ERROR 42S02: Unknown table 't2' in field list
ERROR 42S22: Unknown column 't2.b' in 'field list'
drop table t1,t2,t3;

View file

@ -10,21 +10,21 @@ SELECT * FROM t1 INNER JOIN t2;
S1 S1
1 2
SELECT * from t1 JOIN t2 USING (S1);
S1 S1
S1
SELECT * FROM t1 INNER JOIN t2 USING (S1);
S1 S1
S1
SELECT * from t1 CROSS JOIN t2;
S1 S1
1 2
SELECT * from t1 LEFT JOIN t2 USING(S1);
S1 S1
1 NULL
S1
1
SELECT * from t1 LEFT JOIN t2 ON(t2.S1=2);
S1 S1
1 2
SELECT * from t1 RIGHT JOIN t2 USING(S1);
S1 S1
NULL 2
S1
2
SELECT * from t1 RIGHT JOIN t2 ON(t1.S1=1);
S1 S1
1 2
@ -121,11 +121,7 @@ id catid stateid countyid
drop table t1, t2;
create table t1 (a int primary key);
insert into t1 values(1),(2);
select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a);
a
1
2
select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a);
select a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a);
ERROR HY000: Too many tables; MySQL can only use XX tables in a join
drop table t1;
CREATE TABLE t1 (
@ -145,10 +141,9 @@ DROP TABLE t1, t2;
CREATE TABLE t1 (d DATE NOT NULL);
CREATE TABLE t2 (d DATE NOT NULL);
INSERT INTO t1 (d) VALUES ('2001-08-01'),('0000-00-00');
SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE t2.d IS NULL;
d d
2001-08-01 NULL
0000-00-00 NULL
SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE d IS NULL;
d
0000-00-00
SELECT * from t1 WHERE t1.d IS NULL;
d
0000-00-00
@ -265,10 +260,10 @@ PRIMARY KEY (siteid,rate_code),
FULLTEXT KEY rate_code (rate_code)
) ENGINE=MyISAM;
INSERT INTO t2 VALUES ('rivercats','cust',20);
SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE emp.emp_id = 'psmith' AND lr.siteid = 'rivercats';
SELECT rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE emp.emp_id = 'psmith' AND siteid = 'rivercats';
rate_code base_rate
cust 20
SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE lr.siteid = 'rivercats' AND emp.emp_id = 'psmith';
SELECT rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE siteid = 'rivercats' AND emp.emp_id = 'psmith';
rate_code base_rate
cust 20
drop table t1,t2;
@ -296,79 +291,79 @@ insert into t1 values(1),(2);
insert into t2 values(2),(3);
insert into t3 values (2),(4);
select * from t1 natural left join t2;
i i
1 NULL
2 2
i
1
2
select * from t1 left join t2 on (t1.i=t2.i);
i i
1 NULL
2 2
select * from t1 natural left join t2 natural left join t3;
i i i
1 NULL NULL
2 2 2
i
1
2
select * from t1 left join t2 on (t1.i=t2.i) left join t3 on (t2.i=t3.i);
i i i
1 NULL NULL
2 2 2
select * from t3 natural right join t2;
i i
2 2
NULL 3
i
2
3
select * from t3 right join t2 on (t3.i=t2.i);
i i
2 2
NULL 3
select * from t3 natural right join t2 natural right join t1;
i i i
NULL NULL 1
2 2 2
i
1
2
select * from t3 right join t2 on (t3.i=t2.i) right join t1 on (t2.i=t1.i);
i i i
NULL NULL 1
2 2 2
select * from t1,t2 natural left join t3 order by t1.i,t2.i,t3.i;
i i i
1 2 2
1 3 NULL
2 2 2
2 3 NULL
select * from t1,t2 natural left join t3 order by 1,2;
i i
1 2
1 3
2 2
2 3
select * from t1,t2 left join t3 on (t2.i=t3.i) order by t1.i,t2.i,t3.i;
i i i
1 2 2
1 3 NULL
2 2 2
2 3 NULL
select t1.i,t2.i,t3.i from t2 natural left join t3,t1 order by t1.i,t2.i,t3.i;
i i i
1 2 2
1 3 NULL
2 2 2
2 3 NULL
select * from t2 natural left join t3,t1 order by t1.i;
i i
2 1
3 1
2 2
3 2
select t1.i,t2.i,t3.i from t2 left join t3 on (t2.i=t3.i),t1 order by t1.i,t2.i,t3.i;
i i i
1 2 2
1 3 NULL
2 2 2
2 3 NULL
select * from t1,t2 natural right join t3 order by t1.i,t2.i,t3.i;
i i i
1 NULL 4
1 2 2
2 NULL 4
2 2 2
select * from t1,t2 natural right join t3 order by 1,2;
i i
1 2
1 4
2 2
2 4
select * from t1,t2 right join t3 on (t2.i=t3.i) order by t1.i,t2.i,t3.i;
i i i
1 NULL 4
1 2 2
2 NULL 4
2 2 2
select t1.i,t2.i,t3.i from t2 natural right join t3,t1 order by t1.i,t2.i,t3.i;
i i i
1 NULL 4
1 2 2
2 NULL 4
2 2 2
select * from t2 natural right join t3,t1 order by t1.i;
i i
2 1
4 1
2 2
4 2
select t1.i,t2.i,t3.i from t2 right join t3 on (t2.i=t3.i),t1 order by t1.i,t2.i,t3.i;
i i i
1 NULL 4

View file

@ -75,18 +75,11 @@ t1.client_ptr as client_ptr,
t1.comments as comments,
sum( t3.amount_received ) + sum( t3.adjustment ) as total_budget
from
t1 ,
t2 as client_period ,
t2 as project_period
left join
t3
on
t3.project_ptr = t1.project_id
and t3.date_received <= '2001-03-22 14:15:09'
left join
t4
on
t4.client_id = t1.client_ptr
t2 as project_period,
t3 left join t1 on (t3.project_ptr = t1.project_id and
t3.date_received <= '2001-03-22 14:15:09')
left join t4 on t4.client_id = t1.client_ptr
where
1
and ( client_period.period_type = 'client_table'

View file

@ -223,8 +223,7 @@ a b
1 2
EXPLAIN EXTENDED
SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
FROM t6,
t7
FROM (t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10;
@ -235,8 +234,7 @@ id select_type table type possible_keys key key_len ref rows Extra
Warnings:
Note 1003 select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t6` join `test`.`t7` left join `test`.`t8` on(((`test`.`t7`.`b` = `test`.`t8`.`b`) and (`test`.`t6`.`b` < 10))) where 1
SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
FROM t6,
t7
FROM (t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10;
@ -260,8 +258,7 @@ SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
FROM t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -279,8 +276,7 @@ SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
FROM t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -312,8 +308,7 @@ ON t3.a=1 AND t2.b=t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -357,8 +352,7 @@ ON t3.a=1 AND t2.b=t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -397,8 +391,7 @@ ON t3.a=1 AND t2.b=t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -470,8 +463,7 @@ ON t3.a=1 AND t2.b=t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -537,8 +529,7 @@ ON t3.a=1 AND t2.b=t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -575,8 +566,7 @@ ON t3.a=1 AND t2.b=t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -625,8 +615,7 @@ ON t3.a=1 AND t2.b=t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -679,8 +668,7 @@ ON t3.a=1 AND t2.b=t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -825,44 +813,38 @@ a b a b a b a b
1 3 5 3 NULL NULL NULL NULL
2 2 5 3 NULL NULL NULL NULL
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
FROM t1, t3, t4
FROM t1, (t3, t4)
RIGHT JOIN
t2
ON t3.a=1 AND t2.b=t4.b
WHERE t1.a <= 2;
a b a b a b a b
1 3 3 3 1 2 NULL NULL
1 3 3 3 2 2 NULL NULL
2 2 3 3 1 2 NULL NULL
2 2 3 3 2 2 NULL NULL
1 3 3 3 NULL NULL NULL NULL
2 2 3 3 NULL NULL NULL NULL
1 3 4 2 1 2 3 2
1 3 4 2 1 2 4 2
1 3 4 2 2 2 NULL NULL
2 2 4 2 1 2 3 2
2 2 4 2 1 2 4 2
2 2 4 2 2 2 NULL NULL
1 3 5 3 1 2 NULL NULL
1 3 5 3 2 2 NULL NULL
2 2 5 3 1 2 NULL NULL
2 2 5 3 2 2 NULL NULL
1 3 5 3 NULL NULL NULL NULL
2 2 5 3 NULL NULL NULL NULL
EXPLAIN EXTENDED
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
FROM t1, t3, t4
FROM t1, (t3, t4)
RIGHT JOIN
t2
ON t3.a=1 AND t2.b=t4.b
WHERE t1.a <= 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 3
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
1 SIMPLE t4 ALL NULL NULL NULL NULL 2
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t3` join `test`.`t2` left join `test`.`t4` on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) where (`test`.`t1`.`a` <= 2)
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(((`test`.`t4`.`b` = `test`.`t2`.`b`) and (`test`.`t3`.`a` = 1))) where (`test`.`t1`.`a` <= 2)
CREATE INDEX idx_b ON t2(b);
EXPLAIN EXTENDED
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
FROM t3,t4
FROM (t3,t4)
LEFT JOIN
(t1,t2)
ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b;
@ -874,7 +856,7 @@ id select_type table type possible_keys key key_len ref rows Extra
Warnings:
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(((`test`.`t3`.`a` = 1) and (`test`.`t3`.`b` = `test`.`t2`.`b`) and (`test`.`t2`.`b` = `test`.`t4`.`b`))) where 1
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
FROM t3,t4
FROM (t3,t4)
LEFT JOIN
(t1,t2)
ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b;
@ -900,8 +882,7 @@ ON t3.a=1 AND t2.b=t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -951,8 +932,7 @@ ON t3.a=1 AND t2.b=t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -1001,8 +981,7 @@ ON t3.a=1 AND t2.b=t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -1052,8 +1031,7 @@ ON t3.a=1 AND t2.b=t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -1100,8 +1078,7 @@ ON t3.a=1 AND t2.b=t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -1176,13 +1153,13 @@ a b a1 b
4 2 1 2
4 2 2 2
5 3 NULL NULL
SELECT t2.a,t2.b,t3.a1,t3.b
SELECT *
FROM t2 NATURAL LEFT JOIN t3
WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL);
a b a1 b
4 2 1 2
4 2 2 2
5 3 NULL NULL
b a c a1 c1
2 4 0 1 0
2 4 0 2 0
3 5 0 NULL NULL
DROP TABLE t0,t1,t2,t3,t4,t5,t6,t7,t8,t9;
CREATE TABLE t1 (a int);
CREATE TABLE t2 (a int);

View file

@ -36,7 +36,16 @@ grp a c id a c d
3 5 C 3 5 B 5
3 6 D 3 6 C 6
NULL NULL NULL 4 7 D 7
select t1.*,t2.* from t1 left join t2 using (a);
select * from t1 left join t2 using (a);
a grp c id c d
1 1 a 1 a 1
2 2 b NULL NULL NULL
3 2 c NULL NULL NULL
4 3 E 3 A 4
5 3 C 3 B 5
6 3 D 3 C 6
NULL NULL NULL NULL NULL
select t1.*,t2.* from t1 left join t2 on t1.a=t2.a;
grp a c id a c d
1 1 a 1 1 a 1
2 2 b NULL NULL NULL NULL
@ -45,40 +54,34 @@ grp a c id a c d
3 5 C 3 5 B 5
3 6 D 3 6 C 6
NULL NULL NULL NULL NULL NULL
select t1.*,t2.* from t1 left join t2 using (a) where t1.a=t2.a;
grp a c id a c d
1 1 a 1 1 a 1
3 4 E 3 4 A 4
3 5 C 3 5 B 5
3 6 D 3 6 C 6
select t1.*,t2.* from t1 left join t2 using (a,c);
grp a c id a c d
1 1 a 1 1 a 1
2 2 b NULL NULL NULL NULL
2 3 c NULL NULL NULL NULL
3 4 E NULL NULL NULL NULL
3 5 C NULL NULL NULL NULL
3 6 D NULL NULL NULL NULL
NULL NULL NULL NULL NULL NULL
select t1.*,t2.* from t1 left join t2 using (c);
grp a c id a c d
1 1 a 1 1 a 1
1 1 a 3 4 A 4
2 2 b 3 5 B 5
2 3 c 3 6 C 6
3 4 E NULL NULL NULL NULL
3 5 C 3 6 C 6
3 6 D 4 7 D 7
NULL NULL NULL NULL NULL NULL
select t1.*,t2.* from t1 natural left outer join t2;
grp a c id a c d
1 1 a 1 1 a 1
2 2 b NULL NULL NULL NULL
2 3 c NULL NULL NULL NULL
3 4 E NULL NULL NULL NULL
3 5 C NULL NULL NULL NULL
3 6 D NULL NULL NULL NULL
NULL NULL NULL NULL NULL NULL
select * from t1 left join t2 using (a,c);
a c grp id d
1 a 1 1 1
2 b 2 NULL NULL
3 c 2 NULL NULL
4 E 3 NULL NULL
5 C 3 NULL NULL
6 D 3 NULL NULL
NULL NULL NULL NULL
select * from t1 left join t2 using (c);
c grp a id a d
a 1 1 1 1 1
a 1 1 3 4 4
b 2 2 3 5 5
c 2 3 3 6 6
E 3 4 NULL NULL NULL
C 3 5 3 6 6
D 3 6 4 7 7
NULL NULL NULL NULL NULL
select * from t1 natural left outer join t2;
a c grp id d
1 a 1 1 1
2 b 2 NULL NULL
3 c 2 NULL NULL
4 E 3 NULL NULL
5 C 3 NULL NULL
6 D 3 NULL NULL
NULL NULL NULL NULL
select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id=3;
grp a c id a c d
3 4 E 3 4 A 4
@ -106,26 +109,26 @@ grp a c id a c d a
3 6 D 3 6 C 6 6
NULL NULL NULL NULL NULL NULL NULL
explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a);
ERROR 42000: Cross dependency found in OUTER JOIN; examine your ON conditions
ERROR 42S22: Unknown column 't3.a' in 'on clause'
select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a);
ERROR 42000: Cross dependency found in OUTER JOIN; examine your ON conditions
ERROR 42S22: Unknown column 't3.a' in 'on clause'
select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
ERROR 42000: Cross dependency found in OUTER JOIN; examine your ON conditions
select t1.*,t2.* from t1 inner join t2 using (a);
grp a c id a c d
1 1 a 1 1 a 1
3 4 E 3 4 A 4
3 5 C 3 5 B 5
3 6 D 3 6 C 6
ERROR 42S22: Unknown column 't3.a' in 'on clause'
select * from t1 inner join t2 using (a);
a grp c id c d
1 1 a 1 a 1
4 3 E 3 A 4
5 3 C 3 B 5
6 3 D 3 C 6
select t1.*,t2.* from t1 inner join t2 on (t1.a=t2.a);
grp a c id a c d
1 1 a 1 1 a 1
3 4 E 3 4 A 4
3 5 C 3 5 B 5
3 6 D 3 6 C 6
select t1.*,t2.* from t1 natural join t2;
grp a c id d
1 1 a 1 1
select * from t1 natural join t2;
a c grp id d
1 a 1 1 1
drop table t1,t2;
CREATE TABLE t1 (
usr_id INT unsigned NOT NULL,
@ -400,7 +403,7 @@ insert into t3 values (1);
insert into t4 values (1,1);
insert into t5 values (1,1);
explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23;
ERROR 42000: Cross dependency found in OUTER JOIN; examine your ON conditions
ERROR 42S22: Unknown column 't2.t2_id' in 'on clause'
drop table t1,t2,t3,t4,t5;
create table t1 (n int, m int, o int, key(n));
create table t2 (n int not null, m int, o int, primary key(n));
@ -432,7 +435,7 @@ INSERT INTO t2 VALUES (3,'z');
SELECT t2.id2 FROM t2 LEFT OUTER JOIN t1 ON t1.id2 = t2.id2 WHERE id1 IS NULL;
id2
3
SELECT t2.id2 FROM t2 NATURAL LEFT OUTER JOIN t1 WHERE id1 IS NULL;
SELECT id2 FROM t2 NATURAL LEFT OUTER JOIN t1 WHERE id1 IS NULL;
id2
3
drop table t1,t2;
@ -461,10 +464,10 @@ count color
15 white
7 green
select * from t2 natural join t1;
count color name
10 green lime
7 green lime
5 black grape
color count name
green 10 lime
green 7 lime
black 5 grape
select t2.count, t1.name from t2 natural join t1;
count name
10 lime
@ -647,16 +650,15 @@ insert into t1 values(1),(2);
insert into t2 values(2),(3);
insert into t3 values(2),(4);
select * from t1 natural left join t2 natural left join t3;
i i i
1 NULL NULL
2 2 2
select * from t1 natural left join t2 where (t2.i is not null)=0;
i i
1 NULL
select * from t1 natural left join t2 where (t2.i is not null) is not null;
i i
1 NULL
2 2
i
1
2
select * from t1 natural left join t2 where (i is not null)=0;
i
select * from t1 natural left join t2 where (i is not null) is not null;
i
1
2
drop table t1,t2,t3;
create table t1 (f1 integer,f2 integer,f3 integer);
create table t2 (f2 integer,f4 integer);
@ -664,7 +666,7 @@ create table t3 (f3 integer,f5 integer);
select * from t1
left outer join t2 using (f2)
left outer join t3 using (f3);
ERROR 42S22: Unknown column 'test.t2.f3' in 'on clause'
f3 f2 f1 f4 f5
drop table t1,t2,t3;
create table t1 (a1 int, a2 int);
create table t2 (b1 int not null, b2 int);
@ -929,13 +931,13 @@ create table t1 (a int, b varchar(20));
create table t2 (a int, c varchar(20));
insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb");
insert into t2 values (1,"cccccccccc"),(2,"dddddddddd");
select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a;
select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by a;
group_concat(t1.b,t2.c)
aaaaa
bbbbb
Warnings:
Warning 1260 2 line(s) were cut by GROUP_CONCAT()
select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a;
select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by a;
group_concat(t1.b,t2.c)
aaaaa
bbbbb

View file

@ -85,3 +85,14 @@ def aaa 1 1 8 20 1 N 32769 0 63
1
1
drop table t1;
create table t1 (i int);
insert into t1 values (1),(2),(3);
select * from t1 where i = 2;
drop table t1;//
affected rows: 0
affected rows: 3
info: Records: 3 Duplicates: 0 Warnings: 0
i
2
affected rows: 1
affected rows: 0

View file

@ -135,16 +135,16 @@ create table t1 (n numeric(10));
create table t2 (n numeric(10));
insert into t2 values (1),(2),(4),(8),(16),(32);
select * from t2 left outer join t1 using (n);
n n
1 NULL
2 NULL
4 NULL
8 NULL
16 NULL
32 NULL
n
1
2
4
8
16
32
delete t1,t2 from t2 left outer join t1 using (n);
select * from t2 left outer join t1 using (n);
n n
n
drop table t1,t2 ;
create table t1 (n int(10) not null primary key, d int(10));
create table t2 (n int(10) not null primary key, d int(10));

View file

@ -313,12 +313,16 @@ INSERT INTO t1 (order_id, product_id, product_type) VALUES
('9d9aad7764b5b2c53004348ef8d34500',2315652, 3);
INSERT INTO t2 (order_id, product_id, product_type) VALUES
('9d9aad7764b5b2c53004348ef8d34500',2315652, 3);
select t1.* from t1
left join t2 using(order_id, product_id, product_type)
where t2.order_id=NULL;
select t1.* from t1 left join t2
on (t1.order_id = t2.order_id and
t1.product_id = t2.product_id and
t1.product_type = t2.product_type)
where t2.order_id = NULL;
order_id product_id product_type
select t1.* from t1
left join t2 using(order_id, product_id, product_type)
select t1.* from t1 left join t2
on (t1.order_id = t2.order_id and
t1.product_id = t2.product_id and
t1.product_type = t2.product_type)
where t2.order_id is NULL;
order_id product_id product_type
3d7ce39b5d4b3e3d22aaafe9b633de51 1206029 3

View file

@ -180,7 +180,7 @@ INSERT INTO t3 VALUES (1,'123 Park Place');
INSERT INTO t3 VALUES (2,'453 Boardwalk');
SELECT a,b,if(b = 1,i,if(b = 2,v,''))
FROM t1
LEFT JOIN t2 USING(c)
LEFT JOIN t2 ON t1.c = t2.c
LEFT JOIN t3 ON t3.c = t1.c;
a b if(b = 1,i,if(b = 2,v,''))
1 1 50
@ -189,7 +189,7 @@ a b if(b = 1,i,if(b = 2,v,''))
4 2 453 Boardwalk
SELECT a,b,if(b = 1,i,if(b = 2,v,''))
FROM t1
LEFT JOIN t2 USING(c)
LEFT JOIN t2 ON t1.c = t2.c
LEFT JOIN t3 ON t3.c = t1.c
ORDER BY a;
a b if(b = 1,i,if(b = 2,v,''))
@ -523,10 +523,10 @@ KEY `pseudo` (`pseudo`)
);
INSERT INTO t1 (titre,auteur,dest) VALUES ('test','joce','bug');
INSERT INTO t2 (numeropost,pseudo) VALUES (1,'joce'),(1,'bug');
SELECT titre,t1.numeropost,auteur,icone,nbrep,0,date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30;
SELECT titre,numeropost,auteur,icone,nbrep,0,date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30;
titre numeropost auteur icone nbrep 0 date vue ouvert lastauteur dest
test 1 joce 0 0 0 0000-00-00 00:00:00 0 1 bug
SELECT titre,t1.numeropost,auteur,icone,nbrep,'0',date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30;
SELECT titre,numeropost,auteur,icone,nbrep,'0',date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30;
titre numeropost auteur icone nbrep 0 date vue ouvert lastauteur dest
test 1 joce 0 0 0 0000-00-00 00:00:00 0 1 bug
drop table t1,t2;

View file

@ -519,56 +519,56 @@ a ? a
drop table if exists t2 ;
create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 order by a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) order by a ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 order by a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) order by a ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 order by a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) order by a ' ;
the join statement is:
SELECT * FROM t2 right join t1 using(a) order by t2.a
SELECT * FROM t2 right join t1 using(a) order by a
prepare stmt1 from @query9 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural right join t1 order by t2.a
SELECT * FROM t2 natural right join t1 order by a
prepare stmt1 from @query8 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
the join statement is:
SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query7 ;
@ -591,47 +591,47 @@ a b a b
3 three 3 three
4 four 4 four
the join statement is:
SELECT * FROM t2 left join t1 using(a) order by t2.a
SELECT * FROM t2 left join t1 using(a) order by a
prepare stmt1 from @query6 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural left join t1 order by t2.a
SELECT * FROM t2 natural left join t1 order by a
prepare stmt1 from @query5 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
the join statement is:
SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query4 ;
@ -654,28 +654,28 @@ a b a b
3 three 3 three
4 four 4 four
the join statement is:
SELECT * FROM t2 join t1 using(a) order by t2.a
SELECT * FROM t2 join t1 using(a) order by a
prepare stmt1 from @query3 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural join t1 order by t2.a
SELECT * FROM t2 natural join t1 order by a
prepare stmt1 from @query2 ;
execute stmt1 ;
a b

View file

@ -519,56 +519,56 @@ a ? a
drop table if exists t2 ;
create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 order by a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) order by a ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 order by a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) order by a ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 order by a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) order by a ' ;
the join statement is:
SELECT * FROM t2 right join t1 using(a) order by t2.a
SELECT * FROM t2 right join t1 using(a) order by a
prepare stmt1 from @query9 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural right join t1 order by t2.a
SELECT * FROM t2 natural right join t1 order by a
prepare stmt1 from @query8 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
the join statement is:
SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query7 ;
@ -591,47 +591,47 @@ a b a b
3 three 3 three
4 four 4 four
the join statement is:
SELECT * FROM t2 left join t1 using(a) order by t2.a
SELECT * FROM t2 left join t1 using(a) order by a
prepare stmt1 from @query6 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural left join t1 order by t2.a
SELECT * FROM t2 natural left join t1 order by a
prepare stmt1 from @query5 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
the join statement is:
SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query4 ;
@ -654,28 +654,28 @@ a b a b
3 three 3 three
4 four 4 four
the join statement is:
SELECT * FROM t2 join t1 using(a) order by t2.a
SELECT * FROM t2 join t1 using(a) order by a
prepare stmt1 from @query3 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural join t1 order by t2.a
SELECT * FROM t2 natural join t1 order by a
prepare stmt1 from @query2 ;
execute stmt1 ;
a b

View file

@ -520,56 +520,56 @@ a ? a
drop table if exists t2 ;
create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 order by a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) order by a ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 order by a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) order by a ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 order by a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) order by a ' ;
the join statement is:
SELECT * FROM t2 right join t1 using(a) order by t2.a
SELECT * FROM t2 right join t1 using(a) order by a
prepare stmt1 from @query9 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural right join t1 order by t2.a
SELECT * FROM t2 natural right join t1 order by a
prepare stmt1 from @query8 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
the join statement is:
SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query7 ;
@ -592,47 +592,47 @@ a b a b
3 three 3 three
4 four 4 four
the join statement is:
SELECT * FROM t2 left join t1 using(a) order by t2.a
SELECT * FROM t2 left join t1 using(a) order by a
prepare stmt1 from @query6 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural left join t1 order by t2.a
SELECT * FROM t2 natural left join t1 order by a
prepare stmt1 from @query5 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
the join statement is:
SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query4 ;
@ -655,28 +655,28 @@ a b a b
3 three 3 three
4 four 4 four
the join statement is:
SELECT * FROM t2 join t1 using(a) order by t2.a
SELECT * FROM t2 join t1 using(a) order by a
prepare stmt1 from @query3 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural join t1 order by t2.a
SELECT * FROM t2 natural join t1 order by a
prepare stmt1 from @query2 ;
execute stmt1 ;
a b

View file

@ -562,56 +562,56 @@ a ? a
drop table if exists t2 ;
create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 order by a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) order by a ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 order by a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) order by a ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 order by a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) order by a ' ;
the join statement is:
SELECT * FROM t2 right join t1 using(a) order by t2.a
SELECT * FROM t2 right join t1 using(a) order by a
prepare stmt1 from @query9 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural right join t1 order by t2.a
SELECT * FROM t2 natural right join t1 order by a
prepare stmt1 from @query8 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
the join statement is:
SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query7 ;
@ -634,47 +634,47 @@ a b a b
3 three 3 three
4 four 4 four
the join statement is:
SELECT * FROM t2 left join t1 using(a) order by t2.a
SELECT * FROM t2 left join t1 using(a) order by a
prepare stmt1 from @query6 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural left join t1 order by t2.a
SELECT * FROM t2 natural left join t1 order by a
prepare stmt1 from @query5 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
the join statement is:
SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query4 ;
@ -697,28 +697,28 @@ a b a b
3 three 3 three
4 four 4 four
the join statement is:
SELECT * FROM t2 join t1 using(a) order by t2.a
SELECT * FROM t2 join t1 using(a) order by a
prepare stmt1 from @query3 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural join t1 order by t2.a
SELECT * FROM t2 natural join t1 order by a
prepare stmt1 from @query2 ;
execute stmt1 ;
a b
@ -3574,56 +3574,56 @@ a ? a
drop table if exists t2 ;
create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 order by a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) order by a ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 order by a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) order by a ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 order by a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) order by a ' ;
the join statement is:
SELECT * FROM t2 right join t1 using(a) order by t2.a
SELECT * FROM t2 right join t1 using(a) order by a
prepare stmt1 from @query9 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural right join t1 order by t2.a
SELECT * FROM t2 natural right join t1 order by a
prepare stmt1 from @query8 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
the join statement is:
SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query7 ;
@ -3646,47 +3646,47 @@ a b a b
3 three 3 three
4 four 4 four
the join statement is:
SELECT * FROM t2 left join t1 using(a) order by t2.a
SELECT * FROM t2 left join t1 using(a) order by a
prepare stmt1 from @query6 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural left join t1 order by t2.a
SELECT * FROM t2 natural left join t1 order by a
prepare stmt1 from @query5 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
the join statement is:
SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query4 ;
@ -3709,28 +3709,28 @@ a b a b
3 three 3 three
4 four 4 four
the join statement is:
SELECT * FROM t2 join t1 using(a) order by t2.a
SELECT * FROM t2 join t1 using(a) order by a
prepare stmt1 from @query3 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural join t1 order by t2.a
SELECT * FROM t2 natural join t1 order by a
prepare stmt1 from @query2 ;
execute stmt1 ;
a b

View file

@ -519,56 +519,56 @@ a ? a
drop table if exists t2 ;
create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 order by a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) order by a ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 order by a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) order by a ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 order by a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) order by a ' ;
the join statement is:
SELECT * FROM t2 right join t1 using(a) order by t2.a
SELECT * FROM t2 right join t1 using(a) order by a
prepare stmt1 from @query9 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural right join t1 order by t2.a
SELECT * FROM t2 natural right join t1 order by a
prepare stmt1 from @query8 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
the join statement is:
SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query7 ;
@ -591,47 +591,47 @@ a b a b
3 three 3 three
4 four 4 four
the join statement is:
SELECT * FROM t2 left join t1 using(a) order by t2.a
SELECT * FROM t2 left join t1 using(a) order by a
prepare stmt1 from @query6 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural left join t1 order by t2.a
SELECT * FROM t2 natural left join t1 order by a
prepare stmt1 from @query5 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
the join statement is:
SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query4 ;
@ -654,28 +654,28 @@ a b a b
3 three 3 three
4 four 4 four
the join statement is:
SELECT * FROM t2 join t1 using(a) order by t2.a
SELECT * FROM t2 join t1 using(a) order by a
prepare stmt1 from @query3 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural join t1 order by t2.a
SELECT * FROM t2 natural join t1 order by a
prepare stmt1 from @query2 ;
execute stmt1 ;
a b

View file

@ -519,56 +519,56 @@ a ? a
drop table if exists t2 ;
create table t2 as select * from t1 ;
set @query1= 'SELECT * FROM t2 join t1 on (t1.a=t2.a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 order by t2.a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) order by t2.a ' ;
set @query2= 'SELECT * FROM t2 natural join t1 order by a ' ;
set @query3= 'SELECT * FROM t2 join t1 using(a) order by a ' ;
set @query4= 'SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 order by t2.a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) order by t2.a ' ;
set @query5= 'SELECT * FROM t2 natural left join t1 order by a ' ;
set @query6= 'SELECT * FROM t2 left join t1 using(a) order by a ' ;
set @query7= 'SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 order by t2.a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) order by t2.a ' ;
set @query8= 'SELECT * FROM t2 natural right join t1 order by a ' ;
set @query9= 'SELECT * FROM t2 right join t1 using(a) order by a ' ;
the join statement is:
SELECT * FROM t2 right join t1 using(a) order by t2.a
SELECT * FROM t2 right join t1 using(a) order by a
prepare stmt1 from @query9 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural right join t1 order by t2.a
SELECT * FROM t2 natural right join t1 order by a
prepare stmt1 from @query8 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
the join statement is:
SELECT * FROM t2 right join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query7 ;
@ -591,47 +591,47 @@ a b a b
3 three 3 three
4 four 4 four
the join statement is:
SELECT * FROM t2 left join t1 using(a) order by t2.a
SELECT * FROM t2 left join t1 using(a) order by a
prepare stmt1 from @query6 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural left join t1 order by t2.a
SELECT * FROM t2 natural left join t1 order by a
prepare stmt1 from @query5 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b
1 one
2 two
3 three
4 four
the join statement is:
SELECT * FROM t2 left join t1 on(t1.a=t2.a) order by t2.a
prepare stmt1 from @query4 ;
@ -654,28 +654,28 @@ a b a b
3 three 3 three
4 four 4 four
the join statement is:
SELECT * FROM t2 join t1 using(a) order by t2.a
SELECT * FROM t2 join t1 using(a) order by a
prepare stmt1 from @query3 ;
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
execute stmt1 ;
a b a b
1 one 1 one
2 two 2 two
3 three 3 three
4 four 4 four
a b b
1 one one
2 two two
3 three three
4 four four
the join statement is:
SELECT * FROM t2 natural join t1 order by t2.a
SELECT * FROM t2 natural join t1 order by a
prepare stmt1 from @query2 ;
execute stmt1 ;
a b

View file

@ -0,0 +1,108 @@
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table t1 (a int auto_increment, primary key (a), b int, rand_value double not null);
create table t2 (a int auto_increment, primary key (a), b int);
create table t3 (a int auto_increment, primary key (a), name varchar(64) not null, old_a int, old_b int, rand_value double not null);
create trigger t1 before insert on t1 for each row
begin
insert into t3 values (NULL, "t1", new.a, new.b, rand());
end|
create trigger t2 after insert on t2 for each row
begin
insert into t3 values (NULL, "t2", new.a, new.b, rand());
end|
insert into t3 values(100,"log",0,0,0);
SET @@RAND_SEED1=658490765, @@RAND_SEED2=635893186;
insert into t1 values(1,1,rand()),(NULL,2,rand());
insert into t2 (b) values(last_insert_id());
insert into t2 values(3,0),(NULL,0);
insert into t2 values(NULL,0),(500,0);
select a,b, truncate(rand_value,4) from t1;
a b truncate(rand_value,4)
1 1 0.4320
2 2 0.3055
select * from t2;
a b
1 2
3 0
4 0
5 0
500 0
select a,name, old_a, old_b, truncate(rand_value,4) from t3;
a name old_a old_b truncate(rand_value,4)
100 log 0 0 0.0000
101 t1 1 1 0.3203
102 t1 0 2 0.5666
103 t2 1 2 0.9164
104 t2 3 0 0.8826
105 t2 4 0 0.6635
106 t2 5 0 0.6699
107 t2 500 0 0.3593
--- On slave --
select a,b, truncate(rand_value,4) from t1;
a b truncate(rand_value,4)
1 1 0.4320
2 2 0.3055
select * from t2;
a b
1 2
3 0
4 0
5 0
500 0
select a,name, old_a, old_b, truncate(rand_value,4) from t3;
a name old_a old_b truncate(rand_value,4)
100 log 0 0 0.0000
101 t1 1 1 0.3203
102 t1 0 2 0.5666
103 t2 1 2 0.9164
104 t2 3 0 0.8826
105 t2 4 0 0.6635
106 t2 5 0 0.6699
107 t2 500 0 0.3593
drop table t1,t2,t3;
select get_lock("bug12480",2);
get_lock("bug12480",2)
1
create table t1 (a datetime,b datetime, c datetime);
drop function if exists bug12480;
Warnings:
Note 1305 FUNCTION bug12480 does not exist
create function bug12480() returns datetime
begin
set @a=get_lock("bug12480",2);
return now();
end|
create trigger t1_first before insert on t1
for each row begin
set @a=get_lock("bug12480",2);
set new.b= now();
set new.c= bug12480();
end
|
insert into t1 set a = now();
select a=b && a=c from t1;
a=b && a=c
1
--- On slave --
select a=b && a=c from t1;
a=b && a=c
1
test
1
truncate table t1;
drop trigger t1_first;
insert into t1 values ("2003-03-03","2003-03-03","2003-03-03"),(bug12480(),bug12480(),bug12480()),(now(),now(),now());
select a=b && a=c from t1;
a=b && a=c
1
1
1
drop function bug12480;
drop table t1;

View file

@ -1350,45 +1350,42 @@ fld1 fld1
250504 250505
250505 250505
insert into t2 (fld1, companynr) values (999999,99);
select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
companynr companyname
99 NULL
select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null;
select count(*) from t2 left join t4 using (companynr) where companynr is not null;
count(*)
1199
explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
1200
explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where; Not exists
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where; Not exists
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
delete from t2 where fld1=999999;
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0;
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0;
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0;
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0;
1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 12
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
companynr companynr
37 36
@ -2115,159 +2112,142 @@ insert into t1 values ();
insert into t1 values ();
insert into t1 values ();
select * from (t1 as t2 left join t1 as t3 using (a)), t1;
a a a
1 1 1
2 2 1
3 3 1
1 1 2
2 2 2
3 3 2
1 1 3
2 2 3
3 3 3
a a
1 1
2 1
3 1
1 2
2 2
3 2
1 3
2 3
3 3
select * from t1, (t1 as t2 left join t1 as t3 using (a));
a a a
1 1 1
2 1 1
3 1 1
1 2 2
2 2 2
3 2 2
1 3 3
2 3 3
3 3 3
a a
1 1
2 1
3 1
1 2
2 2
3 2
1 3
2 3
3 3
select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1;
a a a
1 1 1
2 2 1
3 3 1
1 1 2
2 2 2
3 3 2
1 1 3
2 2 3
3 3 3
a a
1 1
2 1
3 1
1 2
2 2
3 2
1 3
2 3
3 3
select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a));
a a a
1 1 1
2 1 1
3 1 1
1 2 2
2 2 2
3 2 2
1 3 3
2 3 3
3 3 3
a a
1 1
2 1
3 1
1 2
2 2
3 2
1 3
2 3
3 3
select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1;
a a a
1 1 2
2 2 2
3 3 2
1 1 3
2 2 3
3 3 3
a a
1 2
2 2
3 2
1 3
2 3
3 3
select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
a a a
2 1 1
3 1 1
2 2 2
3 2 2
2 3 3
3 3 3
a a
2 1
3 1
2 2
3 2
2 3
3 3
select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a );
a a a
1 1 1
2 2 2
3 3 3
a
1
2
3
select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a );
a a a
1 1 1
2 2 2
3 3 3
a
1
2
3
select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1;
a a a
1 1 2
1 1 3
2 2 2
2 2 3
3 3 2
3 3 3
a a
1 2
1 3
2 2
2 3
3 2
3 3
select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
a a a
1 NULL NULL
2 1 1
2 2 2
2 3 3
3 1 1
3 2 2
3 3 3
a a
1 NULL
2 1
2 2
2 3
3 1
3 2
3 3
select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a );
a a a
1 1 1
2 2 2
3 3 3
a
1
2
3
select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a );
a a a
1 1 1
2 2 2
3 3 3
a
1
2
3
select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1;
a a a
1 1 1
2 2 2
3 3 3
a
1
2
3
select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a));
a a a
1 1 1
2 2 2
3 3 3
select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1;
a a a
NULL NULL 1
1 1 2
2 2 2
3 3 2
1 1 3
2 2 3
3 3 3
select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
a a a
2 1 1
3 1 1
2 2 2
3 2 2
2 3 3
3 3 3
a
1
2
3
select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a );
a a a
1 1 1
2 2 2
3 3 3
a
1
2
3
select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a );
a a a
1 1 1
2 2 2
3 3 3
a
1
2
3
select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1;
a a a
1 1 1
2 2 2
3 3 3
a
1
2
3
select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a));
a a a
1 1 1
2 2 2
3 3 3
a
1
2
3
select * from t1 natural join (t1 as t2 left join t1 as t3 using (a));
a a
1 1
2 2
3 3
a
1
2
3
select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1;
a a
1 1
2 2
3 3
a
1
2
3
drop table t1;
CREATE TABLE t1 ( aa char(2), id int(11) NOT NULL auto_increment, t2_id int(11) NOT NULL default '0', PRIMARY KEY (id), KEY replace_id (t2_id)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ("1",8264,2506),("2",8299,2517),("3",8301,2518),("4",8302,2519),("5",8303,2520),("6",8304,2521),("7",8305,2522);

View file

@ -84,7 +84,7 @@ set local max_join_size=8;
select * from (select * from t1) x;
ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay
set local max_join_size=1;
select * from (select * from t1 a, t1 b) x;
select * from (select a.a as aa, b.a as ba from t1 a, t1 b) x;
ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay
set local max_join_size=1;
select * from (select 1 union select 2 union select 3) x;

View file

@ -1200,7 +1200,7 @@ INSERT INTO t1 VALUES (1);
UPDATE t1 SET i=i+(SELECT MAX(i) FROM (SELECT 1) t) WHERE i=(SELECT MAX(i));
UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i));
UPDATE t1 SET t.i=i+(SELECT MAX(i) FROM (SELECT 1) t);
ERROR 42S02: Unknown table 't' in field list
ERROR 42S22: Unknown column 't.i' in 'field list'
select * from t1;
i
1
@ -1638,7 +1638,7 @@ ERROR 42S22: Unknown column 't1.s2' in 'where clause'
select * from t1 where (select count(*) from t2 group by t1.s2) = 1;
ERROR 42S22: Unknown column 't1.s2' in 'group statement'
select count(*) from t2 group by t1.s2;
ERROR 42S02: Unknown table 't1' in group statement
ERROR 42S22: Unknown column 't1.s2' in 'group statement'
drop table t1, t2;
CREATE TABLE t1(COLA FLOAT NOT NULL,COLB FLOAT NOT NULL,COLC VARCHAR(20) DEFAULT NULL,PRIMARY KEY (COLA, COLB));
CREATE TABLE t2(COLA FLOAT NOT NULL,COLB FLOAT NOT NULL,COLC CHAR(1) NOT NULL,PRIMARY KEY (COLA));
@ -1789,11 +1789,11 @@ CREATE TABLE t1 (id INT);
CREATE TABLE t2 (id INT);
INSERT INTO t1 VALUES (1), (2);
INSERT INTO t2 VALUES (1);
SELECT t1.id, ( SELECT COUNT(t.id) FROM t2 AS t WHERE t.id = t1.id ) AS c FROM t1 LEFT JOIN t2 USING (id);
SELECT id, ( SELECT COUNT(t.id) FROM t2 AS t WHERE t.id = t1.id ) AS c FROM t1 LEFT JOIN t2 USING (id);
id c
1 1
2 0
SELECT t1.id, ( SELECT COUNT(t.id) FROM t2 AS t WHERE t.id = t1.id ) AS c FROM t1 LEFT JOIN t2 USING (id) ORDER BY t1.id;
SELECT id, ( SELECT COUNT(t.id) FROM t2 AS t WHERE t.id = t1.id ) AS c FROM t1 LEFT JOIN t2 USING (id) ORDER BY id;
id c
1 1
2 0
@ -2754,13 +2754,26 @@ one two flag
5 6 N
7 8 N
insert into t2 values (null,null,'N');
insert into t2 values (null,3,'0');
insert into t2 values (null,5,'0');
insert into t2 values (10,null,'0');
insert into t1 values (10,3,'0');
insert into t1 values (10,5,'0');
insert into t1 values (10,10,'0');
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1;
one two test
1 2 0
2 3 0
3 4 0
1 2 NULL
2 3 NULL
3 4 NULL
5 6 1
7 8 1
10 3 NULL
10 5 NULL
10 10 NULL
SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
one two
5 6
7 8
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1;
one two test
1 2 NULL
@ -2768,6 +2781,47 @@ one two test
3 4 NULL
5 6 1
7 8 1
10 3 NULL
10 5 NULL
10 10 NULL
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1;
one two test
1 2 0
2 3 NULL
3 4 0
5 6 0
7 8 0
10 3 NULL
10 5 NULL
10 10 NULL
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
one two test
1 2 0
2 3 NULL
3 4 0
5 6 0
7 8 0
10 3 NULL
10 5 NULL
10 10 NULL
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 Using where
Warnings:
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where ((`test`.`t2`.`flag` = _latin1'0') and ((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`)) and ((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`))) having (<is_not_null_test>(`test`.`t2`.`one`) and <is_not_null_test>(`test`.`t2`.`two`)))) AS `test` from `test`.`t1`
explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 Using where
Warnings:
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where ((`test`.`t2`.`flag` = _latin1'N') and (<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) and (<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`))))
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 9 Using where; Using temporary; Using filesort
Warnings:
Note 1003 select `test`.`t1`.`one` AS `one`,`test`.`t1`.`two` AS `two`,<in_optimizer>((`test`.`t1`.`one`,`test`.`t1`.`two`),<exists>(select `test`.`t2`.`one` AS `one`,`test`.`t2`.`two` AS `two` from `test`.`t2` where (`test`.`t2`.`flag` = _latin1'0') group by `test`.`t2`.`one`,`test`.`t2`.`two` having (((<cache>(`test`.`t1`.`one`) = `test`.`t2`.`one`) or isnull(`test`.`t2`.`one`)) and ((<cache>(`test`.`t1`.`two`) = `test`.`t2`.`two`) or isnull(`test`.`t2`.`two`)) and <is_not_null_test>(`test`.`t2`.`one`) and <is_not_null_test>(`test`.`t2`.`two`)))) AS `test` from `test`.`t1`
DROP TABLE t1,t2;
CREATE TABLE t1 (a char(5), b char(5));
INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa');

View file

@ -664,3 +664,36 @@ end|
update t1 set data = 1;
update t1 set data = 2;
drop table t1;
create table t1 (c1 int, c2 datetime);
create trigger tr1 before insert on t1 for each row
begin
set new.c2= '2004-04-01';
select 'hello';
end|
ERROR 0A000: Not allowed to return a result set from a trigger
insert into t1 (c1) values (1),(2),(3);
select * from t1;
c1 c2
1 NULL
2 NULL
3 NULL
drop procedure if exists bug11587;
create procedure bug11587(x char(16))
begin
select "hello";
select "hello again";
end|
create trigger tr1 before insert on t1 for each row
begin
call bug11587();
set new.c2= '2004-04-02';
end|
insert into t1 (c1) values (4),(5),(6);
ERROR 0A000: PROCEDURE test.bug11587 can't return a result set in the given context
select * from t1;
c1 c2
1 NULL
2 NULL
3 NULL
drop procedure bug11587;
drop table t1;

View file

@ -307,18 +307,18 @@ create table t1 ( id integer unsigned not null primary key );
create table t2 ( id integer unsigned not null primary key );
insert into t1 values (1), (2);
insert into t2 values (1);
select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id );
select t1.id as id_A, t2.id as id_B from t1 left join t2 on (t1.id = t2.id);
id_A id_B
1 1
2 NULL
create table t3 (id_A integer unsigned not null, id_B integer unsigned null );
insert into t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id );
insert into t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 on (t1.id = t2.id);
select * from t3;
id_A id_B
1 1
2 NULL
drop table t3;
create table t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id );
create table t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 on (t1.id = t2.id);
select * from t3;
id_A id_B
1 1

View file

@ -430,7 +430,7 @@ drop temporary table t1;
create table t1 select a from t1 union select a from t2;
ERROR HY000: You can't specify target table 't1' for update in FROM clause
select a from t1 union select a from t2 order by t2.a;
ERROR 42S02: Unknown table 't2' in order clause
ERROR 42S22: Unknown column 't2.a' in 'order clause'
drop table t1,t2;
select length(version()) > 1 as `*` UNION select 2;
*

View file

@ -2065,3 +2065,35 @@ pid GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1)
2 c d
DROP VIEW v1;
DROP TABLE t1,t2;
CREATE TABLE t1 (id int PRIMARY KEY, f varchar(255));
CREATE VIEW v1 AS SELECT id, f FROM t1 WHERE id <= 2;
INSERT INTO t1 VALUES (2, 'foo2');
INSERT INTO t1 VALUES (1, 'foo1');
SELECT * FROM v1;
id f
1 foo1
2 foo2
SELECT * FROM v1;
id f
1 foo1
2 foo2
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (pk int PRIMARY KEY, b int);
CREATE TABLE t2 (pk int PRIMARY KEY, fk int, INDEX idx(fk));
CREATE TABLE t3 (pk int PRIMARY KEY, fk int, INDEX idx(fk));
CREATE TABLE t4 (pk int PRIMARY KEY, fk int, INDEX idx(fk));
CREATE TABLE t5 (pk int PRIMARY KEY, fk int, INDEX idx(fk));
CREATE VIEW v1 AS
SELECT t1.pk as a FROM t1,t2,t3,t4,t5
WHERE t1.b IS NULL AND
t1.pk=t2.fk AND t2.pk=t3.fk AND t3.pk=t4.fk AND t4.pk=t5.fk;
SELECT a FROM v1;
a
DROP VIEW v1;
DROP TABLE t1,t2,t3,t4,t5;
create view v1 as select timestampdiff(day,'1997-01-01 00:00:00','1997-01-02 00:00:00') as f1;
select * from v1;
f1
1
drop view v1;

View file

@ -22,6 +22,8 @@ a
xa start 'testa','testb';
insert t1 values (30);
xa end 'testa','testb';
xa start 'testa','testb';
ERROR XAE08: XAER_DUPID: The XID already exists
xa start 0x7465737462, 0x2030405060, 0xb;
insert t1 values (40);
xa end 'testb',' 0@P`',11;
@ -35,11 +37,11 @@ formatID gtrid_length bqual_length data
11 5 5 testb 0@P`
1 5 5 testatestb
xa commit 'testb',0x2030405060,11;
ERROR XAE04: XAER_NOTA: Unknown XID
xa rollback 'testa','testb';
xa start 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
select * from t1;
a
20
40
drop table t1;

View file

@ -400,7 +400,7 @@ drop table t1;
set @a:=now();
CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=bdb;
insert into t1 (a) values(1),(2),(3);
select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a;
select a from t1 natural join t1 as t2 where b >= @a order by a;
update t1 set a=5 where a=1;
select a from t1;
drop table t1;
@ -571,7 +571,7 @@ create temporary table tmp1
select branch_id, target_id, platform_id, product_id
from t1, t2, t3, t4 ;
create temporary table tmp2
select tmp1.branch_id, tmp1.target_id, tmp1.platform_id, tmp1.product_id
select branch_id, target_id, platform_id, product_id
from tmp1 left join t8
using (branch_id,target_id,platform_id,product_id)
where t8.archive_id is null ;

View file

@ -42,7 +42,7 @@ CREATE TABLE t2 (a int not null);
insert into t2 values(1);
select * from (select * from t1 where t1.a=(select a from t2 where t2.a=t1.a)) a;
select * from (select * from t1 where t1.a=(select t2.a from t2 where t2.a=t1.a) union select t1.a, t1.b from t1) a;
explain select * from (select * from t1,t2 where t1.a=t2.a) t1;
explain select * from (select t1.*, t2.a as t2a from t1,t2 where t1.a=t2.a) t1;
drop table t1, t2;
create table t1(a int not null, t char(8), index(a));
disable_query_log;
@ -249,4 +249,13 @@ select * from t1 union distinct select * from t2 union all select * from t3;
select * from (select * from t1 union distinct select * from t2 union all select * from t3) X;
drop table t1, t2, t3;
#
# Bug #11864 non unique names are allowed in subquery
#
create table t1 (a int);
create table t2 (a int);
--error 1060
select * from (select * from t1,t2) foo;
drop table t1,t2;
# End of 4.1 tests

View file

@ -14,9 +14,9 @@ update t1 set a=1;
create table t1 (a int);
--error 1054
select count(test.t1.b) from t1;
--error 1109
--error 1054
select count(not_existing_database.t1) from t1;
--error 1109
--error 1054
select count(not_existing_database.t1.a) from t1;
--error 1044,1146
select count(not_existing_database.t1.a) from not_existing_database.t1;

View file

@ -128,14 +128,14 @@ WHERE ticket2.id = ttxt.ticket AND t1.id = ticket2.ticket and
match(ttxt.inhalt) against ('foobar');
# In the following query MySQL didn't use the fulltext index
select t1.id FROM t2 as ttxt,t1 INNER JOIN t1 as ticket2 ON
ticket2.id = ttxt.ticket
WHERE t1.id = ticket2.ticket and match(ttxt.inhalt) against ('foobar');
select ticket2.id FROM t2 as ttxt,t2 INNER JOIN t1 as ticket2 ON
ticket2.id = t2.ticket
WHERE ticket2.id = ticket2.ticket and match(ttxt.inhalt) against ('foobar');
INSERT INTO t1 VALUES (3,3);
select t1.id FROM t2 as ttxt,t1
INNER JOIN t1 as ticket2 ON ticket2.id = ttxt.ticket
WHERE t1.id = ticket2.ticket and
select ticket2.id FROM t2 as ttxt,t2
INNER JOIN t1 as ticket2 ON ticket2.id = t2.ticket
WHERE ticket2.id = ticket2.ticket and
match(ttxt.inhalt) against ('foobar');
# Check that we get 'fulltext' index in SHOW CREATE

View file

@ -80,7 +80,7 @@ CREATE TABLE t3 (
FULLTEXT KEY betreff (betreff)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=996 ;
--error 1109
--error 1054
select a.text, b.id, b.betreff
from
t2 a inner join t3 b on a.id = b.forum inner join
@ -100,7 +100,7 @@ group by
order by
match(b.betreff) against ('+abc' in boolean mode) desc;
--error 1109
--error 1054
select a.text, b.id, b.betreff
from
t2 a inner join t3 b on a.id = b.forum inner join

View file

@ -41,4 +41,27 @@ select visitor_id,max(ts) as mts from t1 group by visitor_id
having DATE_ADD(mts,INTERVAL 3 MONTH) < NOW();
drop table t1;
#
# Bug #10627: Invalid date turned to NULL from date_sub/date_add in
# traditional mode
#
set sql_mode='traditional';
create table t1 (d date);
--error S22008
insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR);
--error S22008
insert into t1 (d) select date_add('2000-01-01',interval 8000 year);
# No warnings/errors from the next two
insert into t1 values (date_add(NULL, INTERVAL 1 DAY));
insert into t1 values (date_add('2000-01-04', INTERVAL NULL DAY));
set sql_mode='';
# These will all work now, and we'll end up with some NULL entries in the
# table and some warnings.
insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR);
insert into t1 (d) select date_add('2000-01-01',interval 8000 year);
insert into t1 values (date_add(NULL, INTERVAL 1 DAY));
insert into t1 values (date_add('2000-01-04', INTERVAL NULL DAY));
select * from t1;
drop table t1;
# End of 4.1 tests

View file

@ -46,3 +46,12 @@ drop table t1;
create table t1 as select uuid(), length(uuid());
show create table t1;
drop table t1;
# Bug #6760: Add SLEEP() function
create table t1 (a timestamp default '2005-05-05 01:01:01',
b timestamp default '2005-05-05 01:01:01');
insert into t1 set a = now();
select sleep(3);
update t1 set b = now();
select timediff(b, a) >= '00:00:03' from t1;
drop table t1;

View file

@ -31,6 +31,18 @@ drop table t1;
select TRUE,FALSE,NULL;
#
# Bug#12351: CONCAT with USER()/DATEBASE() and
# a constant and a column gets strange results
#
create table t1 (c1 char(5)) character set=latin1;
insert into t1 values('row 1');
insert into t1 values('row 2');
insert into t1 values('row 3');
select concat(user(), '--', c1) from t1;
select concat(database(), '--', c1) from t1;
drop table t1;
#
# Bug#8291 Illegal collation mix with USER() function
#

View file

@ -639,3 +639,13 @@ select trigger_schema, trigger_name from triggers where
trigger_name='tr1';
use test;
drop table t1;
#
# Bug#12518 COLUMN_DEFAULT has wrong value if NOT NULL is set
#
create table t1 (a int not null, b int);
use information_schema;
select column_name, column_default from columns
where table_schema='test' and table_name='t1';
use test;
drop table t1;

View file

@ -440,7 +440,7 @@ drop table t1;
set @a:=now();
CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=innodb;
insert into t1 (a) values(1),(2),(3);
select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a;
select a from t1 natural join t1 as t2 where b >= @a order by a;
update t1 set a=5 where a=1;
select a from t1;
drop table t1;
@ -981,7 +981,7 @@ insert into `t3`values ( 1 ) ;
delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
--error 1217
update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
--error 1109
--error 1054
update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id;
drop table t3,t2,t1;

View file

@ -196,9 +196,9 @@ insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= a +
#Some error cases
--error 1052
insert into t1 select t2.a from t2 on duplicate key update a= a + t2.b;
--error 1109
--error 1054
insert into t1 select t2.a from t2 on duplicate key update t2.a= a + t2.b;
--error 1109
--error 1054
insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= t1.a + t2.b;
drop table t1,t2,t3;

View file

@ -111,10 +111,12 @@ drop table t1, t2;
create table t1 (a int primary key);
insert into t1 values(1),(2);
select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a);
# TODO: WL#2486 - the query fails in PS mode with error:
# Cross dependency found in OUTER JOIN; examine your ON conditions
#select a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a);
--replace_result "31 tables" "XX tables" "61 tables" "XX tables"
--error 1116
select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a);
select a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a);
drop table t1;
#
@ -144,7 +146,7 @@ DROP TABLE t1, t2;
CREATE TABLE t1 (d DATE NOT NULL);
CREATE TABLE t2 (d DATE NOT NULL);
INSERT INTO t1 (d) VALUES ('2001-08-01'),('0000-00-00');
SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE t2.d IS NULL;
SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE d IS NULL;
SELECT * from t1 WHERE t1.d IS NULL;
SELECT * FROM t1 WHERE 1/0 IS NULL;
DROP TABLE t1,t2;
@ -266,8 +268,8 @@ CREATE TABLE t2 (
FULLTEXT KEY rate_code (rate_code)
) ENGINE=MyISAM;
INSERT INTO t2 VALUES ('rivercats','cust',20);
SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE emp.emp_id = 'psmith' AND lr.siteid = 'rivercats';
SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE lr.siteid = 'rivercats' AND emp.emp_id = 'psmith';
SELECT rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE emp.emp_id = 'psmith' AND siteid = 'rivercats';
SELECT rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE siteid = 'rivercats' AND emp.emp_id = 'psmith';
drop table t1,t2;
#
@ -315,14 +317,14 @@ select * from t3 right join t2 on (t3.i=t2.i);
select * from t3 natural right join t2 natural right join t1;
select * from t3 right join t2 on (t3.i=t2.i) right join t1 on (t2.i=t1.i);
select * from t1,t2 natural left join t3 order by t1.i,t2.i,t3.i;
select * from t1,t2 natural left join t3 order by 1,2;
select * from t1,t2 left join t3 on (t2.i=t3.i) order by t1.i,t2.i,t3.i;
select t1.i,t2.i,t3.i from t2 natural left join t3,t1 order by t1.i,t2.i,t3.i;
select * from t2 natural left join t3,t1 order by t1.i;
select t1.i,t2.i,t3.i from t2 left join t3 on (t2.i=t3.i),t1 order by t1.i,t2.i,t3.i;
select * from t1,t2 natural right join t3 order by t1.i,t2.i,t3.i;
select * from t1,t2 natural right join t3 order by 1,2;
select * from t1,t2 right join t3 on (t2.i=t3.i) order by t1.i,t2.i,t3.i;
select t1.i,t2.i,t3.i from t2 natural right join t3,t1 order by t1.i,t2.i,t3.i;
select * from t2 natural right join t3,t1 order by t1.i;
select t1.i,t2.i,t3.i from t2 right join t3 on (t2.i=t3.i),t1 order by t1.i,t2.i,t3.i;
drop table t1,t2,t3;

View file

@ -92,18 +92,11 @@ select distinct
t1.comments as comments,
sum( t3.amount_received ) + sum( t3.adjustment ) as total_budget
from
t1 ,
t2 as client_period ,
t2 as project_period
left join
t3
on
t3.project_ptr = t1.project_id
and t3.date_received <= '2001-03-22 14:15:09'
left join
t4
on
t4.client_id = t1.client_ptr
t2 as project_period,
t3 left join t1 on (t3.project_ptr = t1.project_id and
t3.date_received <= '2001-03-22 14:15:09')
left join t4 on t4.client_id = t1.client_ptr
where
1
and ( client_period.period_type = 'client_table'

View file

@ -130,15 +130,13 @@ SELECT t8.a,t8.b
EXPLAIN EXTENDED
SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
FROM t6,
t7
FROM (t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10;
SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
FROM t6,
t7
FROM (t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10;
@ -150,8 +148,7 @@ SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
FROM t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -162,8 +159,7 @@ SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
FROM t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -186,8 +182,7 @@ SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -203,8 +198,7 @@ SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -228,8 +222,7 @@ SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -252,8 +245,7 @@ SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -281,8 +273,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -308,8 +299,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -336,8 +326,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -375,8 +364,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -452,7 +440,7 @@ SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
WHERE t1.a <= 2;
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
FROM t1, t3, t4
FROM t1, (t3, t4)
RIGHT JOIN
t2
ON t3.a=1 AND t2.b=t4.b
@ -460,7 +448,7 @@ SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
EXPLAIN EXTENDED
SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
FROM t1, t3, t4
FROM t1, (t3, t4)
RIGHT JOIN
t2
ON t3.a=1 AND t2.b=t4.b
@ -470,13 +458,13 @@ CREATE INDEX idx_b ON t2(b);
EXPLAIN EXTENDED
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
FROM t3,t4
FROM (t3,t4)
LEFT JOIN
(t1,t2)
ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b;
SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b
FROM t3,t4
FROM (t3,t4)
LEFT JOIN
(t1,t2)
ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b;
@ -494,8 +482,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -534,8 +521,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -573,8 +559,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -613,8 +598,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -649,8 +633,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b,
t5
LEFT JOIN
(
t6,
t7
(t6, t7)
LEFT JOIN
t8
ON t7.b=t8.b AND t6.b < 10
@ -695,7 +678,7 @@ SELECT t2.a,t2.b,t3.a1,t3.b
FROM t2 LEFT JOIN t3 ON t2.b=t3.b
WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL);
SELECT t2.a,t2.b,t3.a1,t3.b
SELECT *
FROM t2 NATURAL LEFT JOIN t3
WHERE t2.a = 4 OR (t2.a > 4 AND t3.a1 IS NULL);

View file

@ -19,11 +19,11 @@ select t1.*,t2.* from t1 JOIN t2 where t1.a=t2.a;
select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) order by t1.grp,t1.a,t2.c;
select t1.*,t2.* from { oj t2 left outer join t1 on (t1.a=t2.a) };
select t1.*,t2.* from t1 as t0,{ oj t2 left outer join t1 on (t1.a=t2.a) } WHERE t0.a=2;
select t1.*,t2.* from t1 left join t2 using (a);
select t1.*,t2.* from t1 left join t2 using (a) where t1.a=t2.a;
select t1.*,t2.* from t1 left join t2 using (a,c);
select t1.*,t2.* from t1 left join t2 using (c);
select t1.*,t2.* from t1 natural left outer join t2;
select * from t1 left join t2 using (a);
select t1.*,t2.* from t1 left join t2 on t1.a=t2.a;
select * from t1 left join t2 using (a,c);
select * from t1 left join t2 using (c);
select * from t1 natural left outer join t2;
select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id=3;
select t1.*,t2.* from t1 left join t2 on (t1.a=t2.a) where t2.id is null;
@ -34,19 +34,19 @@ explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1;
select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
# The next query should rearange the left joins to get this to work
--error 1120
--error 1054
explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a);
--error 1120
--error 1054
select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a);
# The next query should give an error in MySQL
--error 1120
--error 1054
select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
# Test of inner join
select t1.*,t2.* from t1 inner join t2 using (a);
select * from t1 inner join t2 using (a);
select t1.*,t2.* from t1 inner join t2 on (t1.a=t2.a);
select t1.*,t2.* from t1 natural join t2;
select * from t1 natural join t2;
drop table t1,t2;
@ -292,7 +292,7 @@ insert into t3 values (1);
insert into t4 values (1,1);
insert into t5 values (1,1);
--error 1120
--error 1054
explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23;
drop table t1,t2,t3,t4,t5;
@ -325,7 +325,7 @@ INSERT INTO t2 VALUES (2,'y');
INSERT INTO t2 VALUES (3,'z');
SELECT t2.id2 FROM t2 LEFT OUTER JOIN t1 ON t1.id2 = t2.id2 WHERE id1 IS NULL;
SELECT t2.id2 FROM t2 NATURAL LEFT OUTER JOIN t1 WHERE id1 IS NULL;
SELECT id2 FROM t2 NATURAL LEFT OUTER JOIN t1 WHERE id1 IS NULL;
drop table t1,t2;
@ -430,8 +430,8 @@ insert into t1 values(1),(2);
insert into t2 values(2),(3);
insert into t3 values(2),(4);
select * from t1 natural left join t2 natural left join t3;
select * from t1 natural left join t2 where (t2.i is not null)=0;
select * from t1 natural left join t2 where (t2.i is not null) is not null;
select * from t1 natural left join t2 where (i is not null)=0;
select * from t1 natural left join t2 where (i is not null) is not null;
drop table t1,t2,t3;
#
@ -440,7 +440,6 @@ drop table t1,t2,t3;
create table t1 (f1 integer,f2 integer,f3 integer);
create table t2 (f2 integer,f4 integer);
create table t3 (f3 integer,f5 integer);
--error 1054
select * from t1
left outer join t2 using (f2)
left outer join t3 using (f3);
@ -657,8 +656,8 @@ create table t1 (a int, b varchar(20));
create table t2 (a int, c varchar(20));
insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb");
insert into t2 values (1,"cccccccccc"),(2,"dddddddddd");
select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a;
select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a;
select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by a;
select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by a;
drop table t1, t2;
set group_concat_max_len=default;

View file

@ -49,4 +49,16 @@ drop table t1;
--disable_metadata
#
# Bug #11688: Bad mysql_info() results in multi-results
#
--enable_info
delimiter //;
create table t1 (i int);
insert into t1 values (1),(2),(3);
select * from t1 where i = 2;
drop table t1;//
delimiter ;//
--disable_info
# End of 4.1 tests

View file

@ -152,12 +152,18 @@ INSERT INTO t1 (order_id, product_id, product_type) VALUES
INSERT INTO t2 (order_id, product_id, product_type) VALUES
('9d9aad7764b5b2c53004348ef8d34500',2315652, 3);
select t1.* from t1
left join t2 using(order_id, product_id, product_type)
where t2.order_id=NULL;
select t1.* from t1
left join t2 using(order_id, product_id, product_type)
select t1.* from t1 left join t2
on (t1.order_id = t2.order_id and
t1.product_id = t2.product_id and
t1.product_type = t2.product_type)
where t2.order_id = NULL;
select t1.* from t1 left join t2
on (t1.order_id = t2.order_id and
t1.product_id = t2.product_id and
t1.product_type = t2.product_type)
where t2.order_id is NULL;
drop table t1,t2;
#

View file

@ -153,12 +153,12 @@ INSERT INTO t3 VALUES (2,'453 Boardwalk');
SELECT a,b,if(b = 1,i,if(b = 2,v,''))
FROM t1
LEFT JOIN t2 USING(c)
LEFT JOIN t2 ON t1.c = t2.c
LEFT JOIN t3 ON t3.c = t1.c;
SELECT a,b,if(b = 1,i,if(b = 2,v,''))
FROM t1
LEFT JOIN t2 USING(c)
LEFT JOIN t2 ON t1.c = t2.c
LEFT JOIN t3 ON t3.c = t1.c
ORDER BY a;
@ -339,8 +339,8 @@ CREATE TABLE t2 (
INSERT INTO t1 (titre,auteur,dest) VALUES ('test','joce','bug');
INSERT INTO t2 (numeropost,pseudo) VALUES (1,'joce'),(1,'bug');
SELECT titre,t1.numeropost,auteur,icone,nbrep,0,date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30;
SELECT titre,t1.numeropost,auteur,icone,nbrep,'0',date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30;
SELECT titre,numeropost,auteur,icone,nbrep,0,date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30;
SELECT titre,numeropost,auteur,icone,nbrep,'0',date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30;
drop table t1,t2;
#

View file

@ -1,4 +1,4 @@
source include/have_openssl.inc;
source include/have_openssl_1.inc;
source include/master-slave.inc;
# We don't test all types of ssl auth params here since it's a bit hard

View file

@ -0,0 +1,118 @@
#
# Test of triggers with replication
#
source include/master-slave.inc;
#
# #12482: Triggers has side effects with auto_increment values
#
create table t1 (a int auto_increment, primary key (a), b int, rand_value double not null);
create table t2 (a int auto_increment, primary key (a), b int);
create table t3 (a int auto_increment, primary key (a), name varchar(64) not null, old_a int, old_b int, rand_value double not null);
delimiter |;
create trigger t1 before insert on t1 for each row
begin
insert into t3 values (NULL, "t1", new.a, new.b, rand());
end|
create trigger t2 after insert on t2 for each row
begin
insert into t3 values (NULL, "t2", new.a, new.b, rand());
end|
delimiter ;|
insert into t3 values(100,"log",0,0,0);
# Ensure we always have same random numbers
SET @@RAND_SEED1=658490765, @@RAND_SEED2=635893186;
# Emulate that we have rows 2-9 deleted on the slave
insert into t1 values(1,1,rand()),(NULL,2,rand());
insert into t2 (b) values(last_insert_id());
insert into t2 values(3,0),(NULL,0);
insert into t2 values(NULL,0),(500,0);
select a,b, truncate(rand_value,4) from t1;
select * from t2;
select a,name, old_a, old_b, truncate(rand_value,4) from t3;
save_master_pos;
connection slave;
sync_with_master;
--disable_query_log
select "--- On slave --" as "";
--enable_query_log
select a,b, truncate(rand_value,4) from t1;
select * from t2;
select a,name, old_a, old_b, truncate(rand_value,4) from t3;
connection master;
drop table t1,t2,t3;
#
# #12480: NOW() is not constant in a trigger
# #12481: Using NOW() in a stored function breaks statement based replication
#
# Start by getting a lock on 'bug12480' to be able to use get_lock() as sleep()
connect (con2,localhost,root,,);
connection con2;
select get_lock("bug12480",2);
connection default;
create table t1 (a datetime,b datetime, c datetime);
--ignore_warnings
drop function if exists bug12480;
--enable_warnings
delimiter |;
create function bug12480() returns datetime
begin
set @a=get_lock("bug12480",2);
return now();
end|
create trigger t1_first before insert on t1
for each row begin
set @a=get_lock("bug12480",2);
set new.b= now();
set new.c= bug12480();
end
|
delimiter ;|
insert into t1 set a = now();
select a=b && a=c from t1;
let $time=`select a from t1`;
save_master_pos;
connection slave;
sync_with_master;
--disable_query_log
select "--- On slave --" as "";
--enable_query_log
select a=b && a=c from t1;
--disable_query_log
eval select a='$time' as 'test' from t1;
--enable_query_log
connection master;
disconnect con2;
truncate table t1;
drop trigger t1_first;
insert into t1 values ("2003-03-03","2003-03-03","2003-03-03"),(bug12480(),bug12480(),bug12480()),(now(),now(),now());
select a=b && a=c from t1;
drop function bug12480;
drop table t1;
#
# End of test
#
save_master_pos;
connection slave;
sync_with_master;

View file

@ -1538,22 +1538,22 @@ select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 25
#
insert into t2 (fld1, companynr) values (999999,99);
select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null;
explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;
select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
select count(*) from t2 left join t4 using (companynr) where companynr is not null;
explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null;
delete from t2 where fld1=999999;
#
# Test left join optimization
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0;
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0;
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
# Following can't be optimized
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0;
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0;
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
#
# Joins with forms.
@ -1850,8 +1850,10 @@ select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a );
select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1;
select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a));
# right join on
select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1;
select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
# TODO: WL#2486 - there is a problem in the order of tables in RIGHT JOIN
# check how we set next_name_resolution_table
# select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1;
# select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
# right [outer] joing using
select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a );
select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a );

View file

@ -78,7 +78,7 @@ select * from (select * from t1) x;
set local max_join_size=1;
--error 1104
select * from (select * from t1 a, t1 b) x;
select * from (select a.a as aa, b.a as ba from t1 a, t1 b) x;
set local max_join_size=1;
--error 1104

View file

@ -811,19 +811,19 @@ end|
#
# Some things are caught when parsing
--error ER_SP_NO_RETSET_IN_FUNC
--error ER_SP_NO_RETSET
create function bug8408() returns int
begin
select * from t1;
return 0;
end|
--error ER_SP_NO_RETSET_IN_FUNC
--error ER_SP_NO_RETSET
create function bug8408() returns int
begin
show warnings;
return 0;
end|
--error ER_SP_NO_RETSET_IN_FUNC
--error ER_SP_NO_RETSET
create function bug8408(a int) returns int
begin
declare b int;

View file

@ -2468,25 +2468,26 @@ drop table t3|
#
# BUG#4318
#
#QQ Don't know if HANDLER commands can work with SPs, or at all...
#
#create table t3 (s1 int)|
#insert into t3 values (3), (4)|
#
#--disable_warnings
#drop procedure if exists bug4318|
#--enable_warnings
#create procedure bug4318()
# handler t3 read next|
#
#handler t3 open|
## Expect no results, as tables are closed, but there shouldn't be any errors
#call bug4318()|
#call bug4318()|
#handler t3 close|
#
#drop procedure bug4318|
#drop table t3|
--disable_parsing Don't know if HANDLER commands can work with SPs, or at all..
create table t3 (s1 int)|
insert into t3 values (3), (4)|
--disable_warnings
drop procedure if exists bug4318|
--enable_warnings
create procedure bug4318()
handler t3 read next|
handler t3 open|
# Expect no results, as tables are closed, but there shouldn't be any errors
call bug4318()|
call bug4318()|
handler t3 close|
drop procedure bug4318|
drop table t3|
--enable_parsing
#
# BUG#4902: Stored procedure with SHOW WARNINGS leads to packet error
@ -2834,26 +2835,27 @@ drop table t3|
#
# BUG#6022: Stored procedure shutdown problem with self-calling function.
#
# This part of test is disabled until we implement support for
# recursive stored functions.
#--disable_warnings
#drop function if exists bug6022|
#--enable_warnings
#
#--disable_warnings
#drop function if exists bug6022|
#--enable_warnings
#create function bug6022(x int) returns int
#begin
# if x < 0 then
# return 0;
# else
# return bug6022(x-1);
# end if;
#end|
#
#select bug6022(5)|
#drop function bug6022|
--disable_parsing until we implement support for recursive stored functions.
--disable_warnings
drop function if exists bug6022|
--enable_warnings
--disable_warnings
drop function if exists bug6022|
--enable_warnings
create function bug6022(x int) returns int
begin
if x < 0 then
return 0;
else
return bug6022(x-1);
end if;
end|
select bug6022(5)|
drop function bug6022|
--enable_parsing
#
# BUG#6029: Stored procedure specific handlers should have priority
@ -3760,27 +3762,28 @@ drop procedure if exists bug7088_1|
drop procedure if exists bug7088_2|
--enable_warnings
# psergey: temporarily disabled until Bar fixes BUG#11986
# create procedure bug6063()
# lâbel: begin end|
# call bug6063()|
# # QQ Known bug: this will not show the label correctly.
# show create procedure bug6063|
#
# set character set utf8|
# create procedure bug7088_1()
# label1: begin end label1|
# create procedure bug7088_2()
# läbel1: begin end|
# call bug7088_1()|
# call bug7088_2()|
# set character set default|
# show create procedure bug7088_1|
# show create procedure bug7088_2|
#
# drop procedure bug6063|
# drop procedure bug7088_1|
# drop procedure bug7088_2|
--disable_parsing temporarily disabled until Bar fixes BUG#11986
create procedure bug6063()
lâbel: begin end|
call bug6063()|
# QQ Known bug: this will not show the label correctly.
show create procedure bug6063|
set character set utf8|
create procedure bug7088_1()
label1: begin end label1|
create procedure bug7088_2()
läbel1: begin end|
call bug7088_1()|
call bug7088_2()|
set character set default|
show create procedure bug7088_1|
show create procedure bug7088_2|
drop procedure bug6063|
drop procedure bug7088_1|
drop procedure bug7088_2|
--enable_parsing
#
# BUG#9565: "Wrong locking in stored procedure if a sub-sequent procedure

View file

@ -696,7 +696,7 @@ CREATE TABLE `t1` (
INSERT INTO t1 VALUES (1);
UPDATE t1 SET i=i+(SELECT MAX(i) FROM (SELECT 1) t) WHERE i=(SELECT MAX(i));
UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i));
-- error 1109
-- error 1054
UPDATE t1 SET t.i=i+(SELECT MAX(i) FROM (SELECT 1) t);
select * from t1;
drop table t1;
@ -1005,7 +1005,7 @@ create table t2 (s1 int);
select * from t1 where (select count(*) from t2 where t1.s2) = 1;
-- error 1054
select * from t1 where (select count(*) from t2 group by t1.s2) = 1;
-- error 1109
-- error 1054
select count(*) from t2 group by t1.s2;
drop table t1, t2;
@ -1132,8 +1132,8 @@ CREATE TABLE t1 (id INT);
CREATE TABLE t2 (id INT);
INSERT INTO t1 VALUES (1), (2);
INSERT INTO t2 VALUES (1);
SELECT t1.id, ( SELECT COUNT(t.id) FROM t2 AS t WHERE t.id = t1.id ) AS c FROM t1 LEFT JOIN t2 USING (id);
SELECT t1.id, ( SELECT COUNT(t.id) FROM t2 AS t WHERE t.id = t1.id ) AS c FROM t1 LEFT JOIN t2 USING (id) ORDER BY t1.id;
SELECT id, ( SELECT COUNT(t.id) FROM t2 AS t WHERE t.id = t1.id ) AS c FROM t1 LEFT JOIN t2 USING (id);
SELECT id, ( SELECT COUNT(t.id) FROM t2 AS t WHERE t.id = t1.id ) AS c FROM t1 LEFT JOIN t2 USING (id) ORDER BY id;
DROP TABLE t1,t2;
#
@ -1774,9 +1774,20 @@ SELECT * FROM t1
WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N');
insert into t2 values (null,null,'N');
insert into t2 values (null,3,'0');
insert into t2 values (null,5,'0');
insert into t2 values (10,null,'0');
insert into t1 values (10,3,'0');
insert into t1 values (10,5,'0');
insert into t1 values (10,10,'0');
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1;
SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1;
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1;
SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1;
explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N');
explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1;
DROP TABLE t1,t2;
#

View file

@ -665,6 +665,7 @@ drop table t1;
# Test for bug #11973 "SELECT .. INTO var_name; in trigger cause
# crash on update"
create table t1 (id int, data int, username varchar(16));
insert into t1 (id, data) values (1, 0);
delimiter |;
@ -684,4 +685,47 @@ connection addconroot;
update t1 set data = 2;
connection default;
disconnect addconroot;
drop table t1;
#
# #11587 Trigger causes lost connection error
#
create table t1 (c1 int, c2 datetime);
delimiter |;
--error ER_SP_NO_RETSET
create trigger tr1 before insert on t1 for each row
begin
set new.c2= '2004-04-01';
select 'hello';
end|
delimiter ;|
insert into t1 (c1) values (1),(2),(3);
select * from t1;
--disable_warnings
drop procedure if exists bug11587;
--enable_warnings
delimiter |;
create procedure bug11587(x char(16))
begin
select "hello";
select "hello again";
end|
create trigger tr1 before insert on t1 for each row
begin
call bug11587();
set new.c2= '2004-04-02';
end|
delimiter ;|
--error 1312
insert into t1 (c1) values (4),(5),(6);
select * from t1;
drop procedure bug11587;
drop table t1;

View file

@ -157,12 +157,12 @@ create table t1 ( id integer unsigned not null primary key );
create table t2 ( id integer unsigned not null primary key );
insert into t1 values (1), (2);
insert into t2 values (1);
select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id );
select t1.id as id_A, t2.id as id_B from t1 left join t2 on (t1.id = t2.id);
create table t3 (id_A integer unsigned not null, id_B integer unsigned null );
insert into t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id );
insert into t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 on (t1.id = t2.id);
select * from t3;
drop table t3;
create table t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id );
create table t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 on (t1.id = t2.id);
select * from t3;
drop table t1,t2,t3;

View file

@ -276,7 +276,7 @@ create temporary table t1 select a from t1 union select a from t2;
drop temporary table t1;
--error 1093
create table t1 select a from t1 union select a from t2;
--error 1109
--error 1054
select a from t1 union select a from t2 order by t2.a;
drop table t1,t2;

View file

@ -1901,3 +1901,44 @@ SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM v1 GROUP BY pid;
DROP VIEW v1;
DROP TABLE t1,t2;
#
# Test for bug #12382: SELECT * FROM view after INSERT command
#
CREATE TABLE t1 (id int PRIMARY KEY, f varchar(255));
CREATE VIEW v1 AS SELECT id, f FROM t1 WHERE id <= 2;
INSERT INTO t1 VALUES (2, 'foo2');
INSERT INTO t1 VALUES (1, 'foo1');
SELECT * FROM v1;
SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1;
#
# Test for bug #12470: crash for a simple select from a view defined
# as a join over 5 tables
CREATE TABLE t1 (pk int PRIMARY KEY, b int);
CREATE TABLE t2 (pk int PRIMARY KEY, fk int, INDEX idx(fk));
CREATE TABLE t3 (pk int PRIMARY KEY, fk int, INDEX idx(fk));
CREATE TABLE t4 (pk int PRIMARY KEY, fk int, INDEX idx(fk));
CREATE TABLE t5 (pk int PRIMARY KEY, fk int, INDEX idx(fk));
CREATE VIEW v1 AS
SELECT t1.pk as a FROM t1,t2,t3,t4,t5
WHERE t1.b IS NULL AND
t1.pk=t2.fk AND t2.pk=t3.fk AND t3.pk=t4.fk AND t4.pk=t5.fk;
SELECT a FROM v1;
DROP VIEW v1;
DROP TABLE t1,t2,t3,t4,t5;
#
# Bug #12298 Typo in function name results in erroneous view being created.
#
create view v1 as select timestampdiff(day,'1997-01-01 00:00:00','1997-01-02 00:00:00') as f1;
select * from v1;
drop view v1;

View file

@ -31,6 +31,9 @@ xa end 'testa','testb';
connect (con1,localhost,,,);
connection con1;
--error 1440
xa start 'testa','testb';
# gtrid [ , bqual [ , formatID ] ]
xa start 0x7465737462, 0x2030405060, 0xb;
insert t1 values (40);
@ -47,6 +50,7 @@ xa prepare 'testa','testb';
xa recover;
--error 1397
xa commit 'testb',0x2030405060,11;
xa rollback 'testa','testb';

View file

@ -109,7 +109,7 @@ int list_walk(LIST *list, list_walk_action action, gptr argument)
{
if ((error = (*action)(list->data,argument)))
return error;
list=rest(list);
list=list_rest(list);
}
return 0;
}

View file

@ -1206,7 +1206,8 @@ void thr_print_locks(void)
pthread_mutex_lock(&THR_LOCK_lock);
puts("Current locks:");
for (list=thr_lock_thread_list ; list && count++ < MAX_THREADS ; list=rest(list))
for (list= thr_lock_thread_list; list && count++ < MAX_THREADS;
list= list_rest(list))
{
THR_LOCK *lock=(THR_LOCK*) list->data;
VOID(pthread_mutex_lock(&lock->mutex));

View file

@ -713,8 +713,9 @@ void free_old_query(MYSQL *mysql)
if (mysql->fields)
free_root(&mysql->field_alloc,MYF(0));
init_alloc_root(&mysql->field_alloc,8192,0); /* Assume rowlength < 8192 */
mysql->fields=0;
mysql->field_count=0; /* For API */
mysql->fields= 0;
mysql->field_count= 0; /* For API */
mysql->info= 0;
DBUG_VOID_RETURN;
}

View file

@ -958,8 +958,6 @@ int ha_berkeley::write_row(byte * record)
{
DB_TXN *sub_trans = transaction;
/* Don't use sub transactions in temporary tables */
ulong thd_options= (table->s->tmp_table == NO_TMP_TABLE ?
table->in_use->options : 0);
for (uint retry=0 ; retry < berkeley_trans_retry ; retry++)
{
key_map changed_keys(0);
@ -1070,7 +1068,7 @@ int ha_berkeley::key_cmp(uint keynr, const byte * old_row,
int ha_berkeley::update_primary_key(DB_TXN *trans, bool primary_key_changed,
const byte * old_row, DBT *old_key,
const byte * new_row, DBT *new_key,
ulong thd_options, bool local_using_ignore)
bool local_using_ignore)
{
DBT row;
int error;
@ -1119,8 +1117,7 @@ int ha_berkeley::update_primary_key(DB_TXN *trans, bool primary_key_changed,
int ha_berkeley::restore_keys(DB_TXN *trans, key_map *changed_keys,
uint primary_key,
const byte *old_row, DBT *old_key,
const byte *new_row, DBT *new_key,
ulong thd_options)
const byte *new_row, DBT *new_key)
{
int error;
DBT tmp_key;
@ -1130,7 +1127,7 @@ int ha_berkeley::restore_keys(DB_TXN *trans, key_map *changed_keys,
/* Restore the old primary key, and the old row, but don't ignore
duplicate key failure */
if ((error=update_primary_key(trans, TRUE, new_row, new_key,
old_row, old_key, thd_options, FALSE)))
old_row, old_key, FALSE)))
goto err; /* purecov: inspected */
/* Remove the new key, and put back the old key
@ -1167,8 +1164,6 @@ int ha_berkeley::update_row(const byte * old_row, byte * new_row)
DBT prim_key, key, old_prim_key;
int error;
DB_TXN *sub_trans;
ulong thd_options= (table->s->tmp_table == NO_TMP_TABLE ?
table->in_use->options : 0);
bool primary_key_changed;
DBUG_ENTER("update_row");
LINT_INIT(error);
@ -1204,7 +1199,7 @@ int ha_berkeley::update_row(const byte * old_row, byte * new_row)
if (!(error=update_primary_key(sub_trans, primary_key_changed,
old_row, &old_prim_key,
new_row, &prim_key,
thd_options, using_ignore)))
using_ignore)))
{
// Update all other keys
for (uint keynr=0 ; keynr < table->s->keys ; keynr++)
@ -1239,8 +1234,7 @@ int ha_berkeley::update_row(const byte * old_row, byte * new_row)
int new_error = 0;
if (!changed_keys.is_clear_all())
new_error=restore_keys(transaction, &changed_keys, primary_key,
old_row, &old_prim_key, new_row, &prim_key,
thd_options);
old_row, &old_prim_key, new_row, &prim_key);
if (new_error)
{
/* This shouldn't happen */
@ -1342,8 +1336,6 @@ int ha_berkeley::delete_row(const byte * record)
int error;
DBT row, prim_key;
key_map keys= table->s->keys_in_use;
ulong thd_options= (table->s->tmp_table == NO_TMP_TABLE ?
table->in_use->options : 0);
DBUG_ENTER("delete_row");
statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
@ -2150,7 +2142,7 @@ ha_rows ha_berkeley::records_in_range(uint keynr, key_range *start_key,
end_pos=end_range.less+end_range.equal;
rows=(end_pos-start_pos)*records;
DBUG_PRINT("exit",("rows: %g",rows));
DBUG_RETURN(rows <= 1.0 ? (ha_rows) 1 : (ha_rows) rows);
DBUG_RETURN((ha_rows)(rows <= 1.0 ? 1 : rows));
}

View file

@ -74,13 +74,12 @@ class ha_berkeley: public handler
DBT *prim_key, key_map *keys);
int restore_keys(DB_TXN *trans, key_map *changed_keys, uint primary_key,
const byte *old_row, DBT *old_key,
const byte *new_row, DBT *new_key,
ulong thd_options);
const byte *new_row, DBT *new_key);
int key_cmp(uint keynr, const byte * old_row, const byte * new_row);
int update_primary_key(DB_TXN *trans, bool primary_key_changed,
const byte * old_row, DBT *old_key,
const byte * new_row, DBT *prim_key,
ulong thd_options, bool local_using_ignore);
bool local_using_ignore);
int read_row(int error, char *buf, uint keynr, DBT *row, DBT *key, bool);
DBT *get_pos(DBT *to, byte *pos);

View file

@ -554,19 +554,20 @@ innobase_mysql_end_print_arbitrary_thd(void)
}
/*****************************************************************
Prints info of a THD object (== user session thread) to the
standard output. NOTE that /mysql/innobase/trx/trx0trx.c must contain
the prototype for this function! */
Prints info of a THD object (== user session thread) to the given file.
NOTE that /mysql/innobase/trx/trx0trx.c must contain the prototype for
this function! */
extern "C"
void
innobase_mysql_print_thd(
/*=====================*/
FILE* f, /* in: output stream */
void* input_thd)/* in: pointer to a MySQL THD object */
FILE* f, /* in: output stream */
void* input_thd, /* in: pointer to a MySQL THD object */
uint max_query_len) /* in: max query length to print, or 0 to
use the default max length */
{
const THD* thd;
const char* s;
char buf[301];
thd = (const THD*) input_thd;
@ -593,25 +594,47 @@ innobase_mysql_print_thd(
}
if ((s = thd->query)) {
/* determine the length of the query string */
uint32 i, len;
len = thd->query_length;
/* 3100 is chosen because currently 3000 is the maximum
max_query_len we ever give this. */
char buf[3100];
uint len;
if (len > 300) {
len = 300; /* ADDITIONAL SAFETY: print at most
300 chars to reduce the probability of
a seg fault if there is a race in
thd->query_length in MySQL; after
May 14, 2004 probably no race any more,
but better be safe */
/* If buf is too small, we dynamically allocate storage
in this. */
char* dyn_str = NULL;
/* Points to buf or dyn_str. */
char* str = buf;
if (max_query_len == 0)
{
/* ADDITIONAL SAFETY: the default is to print at
most 300 chars to reduce the probability of a
seg fault if there is a race in
thd->query_length in MySQL; after May 14, 2004
probably no race any more, but better be
safe */
max_query_len = 300;
}
len = min(thd->query_length, max_query_len);
if (len > (sizeof(buf) - 1))
{
dyn_str = my_malloc(len + 1, MYF(0));
str = dyn_str;
}
/* Use strmake to reduce the timeframe
for a race, compared to fwrite() */
i= (uint) (strmake(buf, s, len) - buf);
/* Use strmake to reduce the timeframe for a race,
compared to fwrite() */
len = (uint) (strmake(str, s, len) - str);
putc('\n', f);
fwrite(buf, 1, i, f);
fwrite(str, 1, len, f);
if (dyn_str)
{
my_free(dyn_str, MYF(0));
}
}
putc('\n', f);
@ -7009,7 +7032,7 @@ innobase_xa_prepare(
return(0);
}
trx->xid=thd->transaction.xid;
trx->xid=thd->transaction.xid_state.xid;
/* Release a possible FIFO ticket and search latch. Since we will
reserve the kernel mutex, we have to release the search system latch

View file

@ -6997,6 +6997,8 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond * &cond,
break;
Ndb_item *a= cond->next->ndb_item;
Ndb_item *b, *field, *value= NULL;
LINT_INIT(field);
switch (cond->ndb_item->argument_count()) {
case 1:
field=

View file

@ -547,8 +547,8 @@ void trans_register_ha(THD *thd, bool all, handlerton *ht_arg)
trans->ht[trans->nht++]=ht_arg;
DBUG_ASSERT(*ht == ht_arg);
trans->no_2pc|=(ht_arg->prepare==0);
if (thd->transaction.xid.is_null())
thd->transaction.xid.set(thd->query_id);
if (thd->transaction.xid_state.xid.is_null())
thd->transaction.xid_state.xid.set(thd->query_id);
DBUG_VOID_RETURN;
}
@ -595,7 +595,7 @@ int ha_commit_trans(THD *thd, bool all)
THD_TRANS *trans= all ? &thd->transaction.all : &thd->transaction.stmt;
bool is_real_trans= all || thd->transaction.all.nht == 0;
handlerton **ht= trans->ht;
my_xid xid= thd->transaction.xid.get_my_xid();
my_xid xid= thd->transaction.xid_state.xid.get_my_xid();
DBUG_ENTER("ha_commit_trans");
if (thd->in_sub_stmt)
@ -695,7 +695,7 @@ int ha_commit_one_phase(THD *thd, bool all)
trans->nht=0;
trans->no_2pc=0;
if (is_real_trans)
thd->transaction.xid.null();
thd->transaction.xid_state.xid.null();
if (all)
{
#ifdef HAVE_QUERY_CACHE
@ -751,7 +751,7 @@ int ha_rollback_trans(THD *thd, bool all)
trans->nht=0;
trans->no_2pc=0;
if (is_real_trans)
thd->transaction.xid.null();
thd->transaction.xid_state.xid.null();
if (all)
{
thd->variables.tx_isolation=thd->session_tx_isolation;
@ -945,6 +945,7 @@ int ha_recover(HASH *commit_list)
char buf[XIDDATASIZE*4+6]; // see xid_to_str
sql_print_information("ignore xid %s", xid_to_str(buf, list+i));
#endif
xid_cache_insert(list+i, XA_PREPARED);
found_foreign_xids++;
continue;
}
@ -1008,10 +1009,8 @@ bool mysql_xa_recover(THD *thd)
{
List<Item> field_list;
Protocol *protocol= thd->protocol;
handlerton **ht= handlertons, **end_ht=ht+total_ha;
bool error=TRUE;
int len, got;
XID *list=0;
int i=0;
XID_STATE *xs;
DBUG_ENTER("mysql_xa_recover");
field_list.push_back(new Item_int("formatID",0,11));
@ -1021,48 +1020,30 @@ bool mysql_xa_recover(THD *thd)
if (protocol->send_fields(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE);
for (len= MAX_XID_LIST_SIZE ; list==0 && len > MIN_XID_LIST_SIZE; len/=2)
{
list=(XID *)my_malloc(len*sizeof(XID), MYF(0));
}
if (!list)
{
my_error(ER_OUTOFMEMORY, MYF(0), len);
DBUG_RETURN(1);
}
for ( ; ht < end_ht ; ht++)
pthread_mutex_lock(&LOCK_xid_cache);
while (xs=(XID_STATE*)hash_element(&xid_cache, i++))
{
if (!(*ht)->recover)
continue;
while ((got=(*(*ht)->recover)(list, len)) > 0 )
if (xs->xa_state==XA_PREPARED)
{
XID *xid, *end;
for (xid=list, end=list+got; xid < end; xid++)
protocol->prepare_for_resend();
protocol->store_longlong((longlong)xs->xid.formatID, FALSE);
protocol->store_longlong((longlong)xs->xid.gtrid_length, FALSE);
protocol->store_longlong((longlong)xs->xid.bqual_length, FALSE);
protocol->store(xs->xid.data, xs->xid.gtrid_length+xs->xid.bqual_length,
&my_charset_bin);
if (protocol->write())
{
if (xid->get_my_xid())
continue; // skip "our" xids
protocol->prepare_for_resend();
protocol->store_longlong((longlong)xid->formatID, FALSE);
protocol->store_longlong((longlong)xid->gtrid_length, FALSE);
protocol->store_longlong((longlong)xid->bqual_length, FALSE);
protocol->store(xid->data, xid->gtrid_length+xid->bqual_length,
&my_charset_bin);
if (protocol->write())
goto err;
pthread_mutex_unlock(&LOCK_xid_cache);
DBUG_RETURN(1);
}
if (got < len)
break;
}
}
error=FALSE;
pthread_mutex_unlock(&LOCK_xid_cache);
send_eof(thd);
err:
my_free((gptr)list, MYF(0));
DBUG_RETURN(error);
DBUG_RETURN(0);
}
/*
@ -1660,7 +1641,7 @@ void handler::print_error(int error, myf errflag)
}
case HA_ERR_NULL_IN_SPATIAL:
textno= ER_UNKNOWN_ERROR;
DBUG_VOID_RETURN;
break;
case HA_ERR_FOUND_DUPP_UNIQUE:
textno=ER_DUP_UNIQUE;
break;
@ -1683,8 +1664,8 @@ void handler::print_error(int error, myf errflag)
textno=ER_CRASHED_ON_REPAIR;
break;
case HA_ERR_OUT_OF_MEM:
my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), errflag);
DBUG_VOID_RETURN;
textno=ER_OUT_OF_RESOURCES;
break;
case HA_ERR_WRONG_COMMAND:
textno=ER_ILLEGAL_HA;
break;
@ -1695,10 +1676,8 @@ void handler::print_error(int error, myf errflag)
textno=ER_UNSUPPORTED_EXTENSION;
break;
case HA_ERR_RECORD_FILE_FULL:
textno=ER_RECORD_FILE_FULL;
break;
case HA_ERR_INDEX_FILE_FULL:
textno= errno;
textno=ER_RECORD_FILE_FULL;
break;
case HA_ERR_LOCK_WAIT_TIMEOUT:
textno=ER_LOCK_WAIT_TIMEOUT;

View file

@ -227,11 +227,11 @@ struct xid_t {
char data[XIDDATASIZE]; // not \0-terminated !
bool eq(struct xid_t *xid)
{ return !memcmp(this, xid, sizeof(long)*3+gtrid_length+bqual_length); }
{ return !memcmp(this, xid, length()); }
bool eq(long g, long b, const char *d)
{ return g == gtrid_length && b == bqual_length && !memcmp(d, data, g+b); }
void set(struct xid_t *xid)
{ memcpy(this, xid, sizeof(long)*3+xid->gtrid_length+xid->bqual_length); }
{ memcpy(this, xid, xid->length()); }
void set(long f, const char *g, long gl, const char *b, long bl)
{
formatID= f;
@ -270,6 +270,11 @@ struct xid_t {
!memcmp(data, MYSQL_XID_PREFIX, MYSQL_XID_PREFIX_LEN) ?
quick_get_my_xid() : 0;
}
uint length()
{
return sizeof(formatID)+sizeof(gtrid_length)+sizeof(bqual_length)+
gtrid_length+bqual_length;
}
};
typedef struct xid_t XID;

View file

@ -39,12 +39,11 @@ void unireg_init(ulong options)
#endif
VOID(strmov(reg_ext,".frm"));
specialflag=SPECIAL_SAME_DB_NAME;
specialflag=SPECIAL_SAME_DB_NAME | options; /* Set options from argv */
/* Make a tab of powers of 10 */
for (i=0,nr=1.0; i < array_elements(log_10) ; i++)
{ /* It's used by filesort... */
log_10[i]= nr ; nr*= 10.0;
}
specialflag|=options; /* Set options from argv */
DBUG_VOID_RETURN;
}

View file

@ -3071,7 +3071,9 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
expression to 'reference', i.e. it substitute that expression instead
of this Item_field
*/
if ((from_field= find_field_in_tables(thd, this, context->table_list,
if ((from_field= find_field_in_tables(thd, this,
context->first_name_resolution_table,
context->last_name_resolution_table,
reference,
IGNORE_EXCEPT_NON_UNIQUE,
!any_privileges &&
@ -3080,13 +3082,13 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
not_found_field)
{
/*
If there is an outer contexts (outer selects, but current select is
If there are outer contexts (outer selects, but current select is
not derived table or view) try to resolve this reference in the
outer contexts.
We treat each subselect as a separate namespace, so that different
subselects may contain columns with the same names. The subselects are
searched starting from the innermost.
subselects may contain columns with the same names. The subselects
are searched starting from the innermost.
*/
Name_resolution_context *last_checked_context= context;
Item **ref= (Item **) not_found_item;
@ -3115,7 +3117,10 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
(!select->with_sum_func &&
select->group_list.elements == 0)) &&
(from_field= find_field_in_tables(thd, this,
outer_context->table_list,
outer_context->
first_name_resolution_table,
outer_context->
last_name_resolution_table,
reference,
IGNORE_EXCEPT_NON_UNIQUE,
outer_context->
@ -3190,7 +3195,9 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
else
{
/* Call find_field_in_tables only to report the error */
find_field_in_tables(thd, this, context->table_list,
find_field_in_tables(thd, this,
context->first_name_resolution_table,
context->last_name_resolution_table,
reference, REPORT_ALL_ERRORS,
!any_privileges &&
context->check_privileges, TRUE);
@ -4358,7 +4365,10 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
expression instead of this Item_ref
*/
from_field= find_field_in_tables(thd, this,
outer_context->table_list,
outer_context->
first_name_resolution_table,
outer_context->
last_name_resolution_table,
reference,
IGNORE_EXCEPT_NON_UNIQUE,
outer_context->check_privileges,
@ -4977,9 +4987,8 @@ void Item_trigger_field::setup_field(THD *thd, TABLE *table)
Try to find field by its name and if it will be found
set field_idx properly.
*/
(void)find_field_in_real_table(thd, table, field_name,
(uint) strlen(field_name),
0, 0, &field_idx);
(void)find_field_in_table(thd, table, field_name, (uint) strlen(field_name),
0, 0, &field_idx);
thd->set_query_id= save_set_query_id;
triggers= table->triggers;
}

View file

@ -254,6 +254,19 @@ struct Name_resolution_context
name resolution of different parts of the statement.
*/
TABLE_LIST *table_list;
/*
In most cases the two table references below replace 'table_list' above
for the purpose of name resolution. The first and last name resolution
table references allow us to search only in a sub-tree of the nested
join tree in a FROM clause. This is needed for NATURAL JOIN, JOIN ... USING
and JOIN ... ON.
*/
TABLE_LIST *first_name_resolution_table;
/*
Last table to search in the list of leaf table references that begins
with first_name_resolution_table.
*/
TABLE_LIST *last_name_resolution_table;
/*
SELECT_LEX item belong to, in case of merged VIEW it can differ from
@ -293,11 +306,13 @@ struct Name_resolution_context
{
resolve_in_select_list= FALSE;
error_processor= &dummy_error_processor;
first_name_resolution_table= NULL;
last_name_resolution_table= NULL;
}
void resolve_in_table_list_only(TABLE_LIST *tables)
{
table_list= tables;
table_list= first_name_resolution_table= tables;
resolve_in_select_list= FALSE;
}
@ -657,7 +672,8 @@ public:
current value and pointer passed via parameter otherwise.
*/
virtual Item **this_item_addr(THD *thd, Item **addr) { return addr; }
virtual Item *this_const_item() const { return const_cast<Item*>(this); } /* For SPs mostly. */
/* For SPs mostly. */
virtual Item *this_const_item() const { return const_cast<Item*>(this); }
// Row emulation
virtual uint cols() { return 1; }
@ -828,6 +844,10 @@ public:
void print(String *str);
virtual bool change_context_processor(byte *cntx)
{ context= (Name_resolution_context *)cntx; return FALSE; }
friend bool insert_fields(THD *thd, Name_resolution_context *context,
const char *db_name,
const char *table_name, List_iterator<Item> *it,
bool any_privileges);
};
class Item_equal;
@ -1129,7 +1149,8 @@ public:
void cleanup() {}
void print(String *str);
Item_num *neg() { value= -value; return this; }
uint decimal_precision() const { return (uint)(max_length - test(value < 0)); }
uint decimal_precision() const
{ return (uint)(max_length - test(value < 0)); }
bool eq(const Item *, bool binary_cmp) const;
};
@ -1566,6 +1587,15 @@ public:
bool val_bool();
bool get_date(TIME *ltime, uint fuzzydate);
void print(String *str);
/*
we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
*/
table_map used_tables() const
{
return (depended_from ?
OUTER_REF_TABLE_BIT :
(*ref)->used_tables() | RAND_TABLE_BIT);
}
};
class Item_null_helper :public Item_ref_null_helper
@ -1647,7 +1677,9 @@ public:
longlong val_int()
{
int err;
return null_value ? LL(0) : my_strntoll(str_value.charset(),str_value.ptr(),str_value.length(),10, (char**) 0,&err);
return null_value ? LL(0) : my_strntoll(str_value.charset(),str_value.ptr(),
str_value.length(),10, (char**) 0,
&err);
}
String *val_str(String*);
my_decimal *val_decimal(my_decimal *);

View file

@ -913,6 +913,11 @@ public:
longlong val_int();
const char *func_name() const { return "<is_not_null_test>"; }
void update_used_tables();
/*
we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
*/
table_map used_tables() const
{ return used_tables_cache | RAND_TABLE_BIT; }
};

View file

@ -354,6 +354,11 @@ Item *create_func_sha(Item* a)
return new Item_func_sha(a);
}
Item *create_func_sleep(Item* a)
{
return new Item_func_sleep(a);
}
Item *create_func_space(Item *a)
{
CHARSET_INFO *cs= current_thd->variables.collation_connection;

View file

@ -83,6 +83,7 @@ Item *create_func_sec_to_time(Item* a);
Item *create_func_sign(Item* a);
Item *create_func_sin(Item* a);
Item *create_func_sha(Item* a);
Item *create_func_sleep(Item* a);
Item *create_func_soundex(Item* a);
Item *create_func_space(Item *);
Item *create_func_sqrt(Item* a);

View file

@ -1873,6 +1873,9 @@ bool Item_func_rand::fix_fields(THD *thd,Item **ref)
Allocate rand structure once: we must use thd->current_arena
to create rand in proper mem_root if it's a prepared statement or
stored procedure.
No need to send a Rand log event if seed was given eg: RAND(seed),
as it will be replicated in the query as such.
*/
if (!rand && !(rand= (struct rand_struct*)
thd->current_arena->alloc(sizeof(*rand))))
@ -1895,16 +1898,16 @@ bool Item_func_rand::fix_fields(THD *thd,Item **ref)
else
{
/*
No need to send a Rand log event if seed was given eg: RAND(seed),
as it will be replicated in the query as such.
Save the seed only the first time RAND() is used in the query
Once events are forwarded rather than recreated,
the following can be skipped if inside the slave thread
*/
thd->rand_used=1;
thd->rand_saved_seed1=thd->rand.seed1;
thd->rand_saved_seed2=thd->rand.seed2;
if (!thd->rand_used)
{
thd->rand_used= 1;
thd->rand_saved_seed1= thd->rand.seed1;
thd->rand_saved_seed2= thd->rand.seed2;
}
rand= &thd->rand;
}
return FALSE;
@ -3259,6 +3262,17 @@ void Item_func_benchmark::print(String *str)
str->append(')');
}
/* This function is just used to create tests with time gaps */
longlong Item_func_sleep::val_int()
{
DBUG_ASSERT(fixed == 1);
double time= args[0]->val_real();
my_sleep((ulong)time*1000000L);
return 0;
}
#define extra_size sizeof(double)
static user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
@ -4654,10 +4668,9 @@ Item_func_sp::execute(Item **itp)
{
DBUG_ENTER("Item_func_sp::execute");
THD *thd= current_thd;
ulong old_client_capabilites;
int res= -1;
bool save_in_sub_stmt= thd->in_sub_stmt;
my_bool save_no_send_ok;
Sub_statement_state statement_state;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
st_sp_security_context save_ctx;
#endif
@ -4668,38 +4681,21 @@ Item_func_sp::execute(Item **itp)
goto error;
}
old_client_capabilites= thd->client_capabilities;
thd->client_capabilities &= ~CLIENT_MULTI_RESULTS;
#ifndef EMBEDDED_LIBRARY
save_no_send_ok= thd->net.no_send_ok;
thd->net.no_send_ok= TRUE;
#endif
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if (check_routine_access(thd, EXECUTE_ACL,
m_sp->m_db.str, m_sp->m_name.str, 0, 0))
goto error_check;
goto error;
sp_change_security_context(thd, m_sp, &save_ctx);
if (save_ctx.changed &&
check_routine_access(thd, EXECUTE_ACL,
m_sp->m_db.str, m_sp->m_name.str, 0, 0))
goto error_check_ctx;
#endif
/*
Like for SPs, we don't binlog the substatements. If the statement which
called this function is an update statement, it will be binlogged; but if
it's not (e.g. SELECT myfunc()) it won't be binlogged (documented known
problem).
*/
tmp_disable_binlog(thd); /* don't binlog the substatements */
thd->in_sub_stmt= TRUE;
thd->reset_sub_statement_state(&statement_state, SUB_STMT_FUNCTION);
res= m_sp->execute_function(thd, args, arg_count, itp);
thd->restore_sub_statement_state(&statement_state);
thd->in_sub_stmt= save_in_sub_stmt;
reenable_binlog(thd);
if (res && mysql_bin_log.is_open() &&
(m_sp->m_chistics->daccess == SP_CONTAINS_SQL ||
m_sp->m_chistics->daccess == SP_MODIFIES_SQL_DATA))
@ -4712,15 +4708,6 @@ error_check_ctx:
sp_restore_security_context(thd, m_sp, &save_ctx);
#endif
thd->client_capabilities|= old_client_capabilites & CLIENT_MULTI_RESULTS;
error_check:
#ifndef EMBEDDED_LIBRARY
thd->net.no_send_ok= save_no_send_ok;
#endif
thd->client_capabilities|= old_client_capabilites & CLIENT_MULTI_RESULTS;
error:
DBUG_RETURN(res);
}

View file

@ -874,6 +874,7 @@ public:
}
};
class Item_func_benchmark :public Item_int_func
{
ulong loop_count;
@ -888,6 +889,16 @@ public:
};
class Item_func_sleep :public Item_int_func
{
public:
Item_func_sleep(Item *a) :Item_int_func(a) {}
const char *func_name() const { return "sleep"; }
longlong val_int();
};
#ifdef HAVE_DLOPEN
class Item_udf_func :public Item_func

Some files were not shown because too many files have changed in this diff Show more