Commit 570158b0 authored by unknown's avatar unknown

Fix for -fbranch-probabilites (bug 268)

Fix for LEFT/RIGHT/MID with multi-byte-character sets (bug 314)
Fix for new bison 1.875
max_insert_delayed_threads and delayed_insert_timeout now works as documented (bug 211)
Don't show port in SHOW PROCESSLIST for system threads
Fix problem with ORDER BY being discarded for some DISTINCT queries (bug 275)
Fixed bug with NATURAL LEFT JOIN, NATURAL RIGHT JOIN and RIGHT JOIN when
using many joined tables (Bug 212)


acinclude.m4:
  Fix for -fbranch-probabilites
configure.in:
  Fix for -fbranch-probabilites
myisam/mi_open.c:
  Give error instead of writing to stderr (Which user can't see)
mysql-test/r/join.result:
  Update results after change to NATURAL/LEFT/RIGHT JOIN
mysql-test/r/join_outer.result:
  Update results after change to NATURAL/LEFT/RIGHT JOIN
mysql-test/r/select.result:
  Update results after change to NATURAL/LEFT/RIGHT JOIN
mysql-test/t/join.test:
  Update results after change to NATURAL/LEFT/RIGHT JOIN
sql/item_strfunc.cc:
  Fix for LEFT/RIGHT/MID with multi-byte-character sets
sql/mysqld.cc:
  Fix for new bison 1.875 (Wrong error text message when one got syntax error)
sql/sql_class.cc:
  Don't show port in SHOW PROCESSLIST for system threads
sql/sql_insert.cc:
  max_insert_delayed_threads now works as documented.
  delayed_insert_timeout now works on Linux
sql/sql_parse.cc:
  Added comment
sql/sql_select.cc:
  Fix problem with ORDER BY being discarded and results returned un-sorted
sql/sql_yacc.yy:
  Fixed bug with NATURAL LEFT JOIN, NATURAL RIGHT JOIN and RIGHT JOIN when
  using many joined tables.
parent f994e61b
...@@ -38,7 +38,7 @@ AC_LANG_SAVE ...@@ -38,7 +38,7 @@ AC_LANG_SAVE
AC_LANG_CPLUSPLUS AC_LANG_CPLUSPLUS
if test "$ac_cv_prog_gxx" = "yes" if test "$ac_cv_prog_gxx" = "yes"
then then
CXXFLAGS="$CXXFLAGS -Werror" CXXFLAGS=`echo $CXXFLAGS -Werror | sed 's/-fbranch-probabilities//'`
fi fi
mysql_cv_btype_last_arg_accept=none mysql_cv_btype_last_arg_accept=none
[AC_TRY_COMPILE([#if defined(inline) [AC_TRY_COMPILE([#if defined(inline)
......
...@@ -1862,7 +1862,7 @@ AC_LANG_SAVE ...@@ -1862,7 +1862,7 @@ AC_LANG_SAVE
AC_LANG_CPLUSPLUS AC_LANG_CPLUSPLUS
if test "$ac_cv_prog_gxx" = "yes" -a "$with_other_libc" = "no" if test "$ac_cv_prog_gxx" = "yes" -a "$with_other_libc" = "no"
then then
CXXFLAGS="$CXXFLAGS -Werror" CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed 's/-fbranch-probabilities//'`
fi fi
AC_TRY_COMPILE( AC_TRY_COMPILE(
[#undef inline [#undef inline
...@@ -1894,7 +1894,7 @@ AC_LANG_SAVE ...@@ -1894,7 +1894,7 @@ AC_LANG_SAVE
AC_LANG_CPLUSPLUS AC_LANG_CPLUSPLUS
if test "$ac_cv_prog_gxx" = "yes" -a "$with_other_libc" = "no" if test "$ac_cv_prog_gxx" = "yes" -a "$with_other_libc" = "no"
then then
CXXFLAGS="$CXXFLAGS -Werror" CXXFLAGS=`echo "$CXXFLAGS -Werror" | sed 's/-fbranch-probabilities//'`
fi fi
AC_TRY_COMPILE( AC_TRY_COMPILE(
[#undef inline [#undef inline
...@@ -2341,7 +2341,7 @@ extern int mbcharlen_${c}(uint);" ...@@ -2341,7 +2341,7 @@ extern int mbcharlen_${c}(uint);"
mbcharlen_${c}" mbcharlen_${c}"
else else
CHARSET_COMP_CS_INIT="$CHARSET_COMP_CS_INIT CHARSET_COMP_CS_INIT="$CHARSET_COMP_CS_INIT
0, /* mbmaxlen */ 1, /* mbmaxlen */
NULL, /* ismbchar */ NULL, /* ismbchar */
NULL, /* ismbhead */ NULL, /* ismbhead */
NULL /* mbcharlen */" NULL /* mbcharlen */"
......
...@@ -183,8 +183,11 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) ...@@ -183,8 +183,11 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
share->state_diff_length=len-MI_STATE_INFO_SIZE; share->state_diff_length=len-MI_STATE_INFO_SIZE;
if (share->state.header.fulltext_keys) if (share->state.header.fulltext_keys)
fprintf(stderr, "Table file %s was created in MySQL 4.1+, use REPAIR TABLE ... USE_FRM to recreate it as a valid MySQL 4.0 table\n", name_buff); {
/* Not supported in this version */
my_errno= HA_ERR_UNSUPPORTED;
goto err;
}
mi_state_info_read(disk_cache, &share->state); mi_state_info_read(disk_cache, &share->state);
len= mi_uint2korr(share->state.header.base_info_length); len= mi_uint2korr(share->state.header.base_info_length);
if (len != MI_BASE_INFO_SIZE) if (len != MI_BASE_INFO_SIZE)
......
drop table if exists t1;
create table t1 (c text);
insert into t1 values (0xa4a2),(0xa4a3);
select hex(left(c,1)) from t1 group by c;
hex(left(c,1))
A4A2
A4A3
drop table t1;
...@@ -274,3 +274,90 @@ SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (site ...@@ -274,3 +274,90 @@ SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (site
rate_code base_rate rate_code base_rate
cust 20 cust 20
drop table t1,t2; drop table t1,t2;
create table t1 (i int);
create table t2 (i int);
create table t3 (i int);
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
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
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
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
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 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 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 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 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
1 2 2
2 NULL 4
2 2 2
drop table t1,t2,t3;
...@@ -351,12 +351,7 @@ select t1.name, t2.name, t2.id,t3.id from t1 right join t2 on (t1.id = t2.owner) ...@@ -351,12 +351,7 @@ select t1.name, t2.name, t2.id,t3.id from t1 right join t2 on (t1.id = t2.owner)
name name id id name name id id
Antonio Paz El Gato 1 1 Antonio Paz El Gato 1 1
Antonio Paz Perrito 2 1 Antonio Paz Perrito 2 1
NULL Happy 3 1 NULL NULL NULL 2
NULL El Gato 1 2
NULL Perrito 2 2
NULL Happy 3 2
NULL El Gato 1 3
NULL Perrito 2 3
Thimble Smith Happy 3 3 Thimble Smith Happy 3 3
select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner; select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner;
name name id owner id name name id owner id
......
...@@ -3402,13 +3402,7 @@ a a a ...@@ -3402,13 +3402,7 @@ a a a
select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a)); select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a));
a a a a a a
1 1 1 1 1 1
2 1 NULL
3 1 NULL
1 2 NULL
2 2 2 2 2 2
3 2 NULL
1 3 NULL
2 3 NULL
3 3 3 3 3 3
select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1; select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1;
a a a a a a
...@@ -3464,13 +3458,7 @@ a a a ...@@ -3464,13 +3458,7 @@ a a a
select * from t1 natural join (t1 as t2 left join t1 as t3 using (a)); select * from t1 natural join (t1 as t2 left join t1 as t3 using (a));
a a a a a a
1 1 1 1 1 1
2 1 NULL
3 1 NULL
1 2 NULL
2 2 2 2 2 2
3 2 NULL
1 3 NULL
2 3 NULL
3 3 3 3 3 3
select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1; select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1;
a a a a a a
......
--default-character-set=ujis
#
# Tests with the ujis character set
#
drop table if exists t1;
#
# Test problem with LEFT()
#
create table t1 (c text);
insert into t1 values (0xa4a2),(0xa4a3);
select hex(left(c,1)) from t1 group by c;
drop table t1;
...@@ -271,3 +271,35 @@ INSERT INTO t2 VALUES ('rivercats','cust',20); ...@@ -271,3 +271,35 @@ 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 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 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';
drop table t1,t2; drop table t1,t2;
#
# Test combination of join methods
#
create table t1 (i int);
create table t2 (i int);
create table t3 (i int);
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;
select * from t1 left join t2 on (t1.i=t2.i);
select * from t1 natural left join t2 natural left join t3;
select * from t1 left join t2 on (t1.i=t2.i) left join t3 on (t2.i=t3.i);
select * from t3 natural right join t2;
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 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 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 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 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;
...@@ -899,7 +899,7 @@ void Item_str_func::left_right_max_length() ...@@ -899,7 +899,7 @@ void Item_str_func::left_right_max_length()
max_length=args[0]->max_length; max_length=args[0]->max_length;
if (args[1]->const_item()) if (args[1]->const_item())
{ {
int length=(int) args[1]->val_int(); int length=(int) args[1]->val_int()*default_charset_info->mbmaxlen;
if (length <= 0) if (length <= 0)
max_length=0; max_length=0;
else else
...@@ -992,7 +992,7 @@ void Item_func_substr::fix_length_and_dec() ...@@ -992,7 +992,7 @@ void Item_func_substr::fix_length_and_dec()
} }
if (arg_count == 3 && args[2]->const_item()) if (arg_count == 3 && args[2]->const_item())
{ {
int32 length= (int32) args[2]->val_int(); int32 length= (int32) args[2]->val_int() * default_charset_info->mbmaxlen;
if (length <= 0) if (length <= 0)
max_length=0; /* purecov: inspected */ max_length=0; /* purecov: inspected */
else else
......
...@@ -1233,7 +1233,7 @@ void yyerror(const char *s) ...@@ -1233,7 +1233,7 @@ void yyerror(const char *s)
{ {
NET *net=my_pthread_getspecific_ptr(NET*,THR_NET); NET *net=my_pthread_getspecific_ptr(NET*,THR_NET);
char *yytext=(char*) current_lex->tok_start; char *yytext=(char*) current_lex->tok_start;
if (!strcmp(s,"parse error")) if (!strcmp(s,"parse error") || !strcmp(s,"syntax error"))
s=ER(ER_SYNTAX_ERROR); s=ER(ER_SYNTAX_ERROR);
net_printf(net,ER_PARSE_ERROR, s, yytext ? (char*) yytext : "", net_printf(net,ER_PARSE_ERROR, s, yytext ? (char*) yytext : "",
current_lex->yylineno); current_lex->yylineno);
...@@ -3787,7 +3787,7 @@ replicating a LOAD DATA INFILE command", ...@@ -3787,7 +3787,7 @@ replicating a LOAD DATA INFILE command",
(gptr*) &max_connect_errors, (gptr*) &max_connect_errors, 0, GET_ULONG, (gptr*) &max_connect_errors, (gptr*) &max_connect_errors, 0, GET_ULONG,
REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ~0L, 0, 1, 0}, REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ~0L, 0, 1, 0},
{"max_delayed_threads", OPT_MAX_DELAYED_THREADS, {"max_delayed_threads", OPT_MAX_DELAYED_THREADS,
"Don't start more than this number of threads to handle INSERT DELAYED statements. This option does not yet have effect (on TODO), unless it is set to zero, which means INSERT DELAYED is not used.", "Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero, which means INSERT DELAYED is not used.",
(gptr*) &max_insert_delayed_threads, (gptr*) &max_insert_delayed_threads, (gptr*) &max_insert_delayed_threads, (gptr*) &max_insert_delayed_threads,
0, GET_ULONG, REQUIRED_ARG, 20, 0, 16384, 0, 1, 0}, 0, GET_ULONG, REQUIRED_ARG, 20, 0, 16384, 0, 1, 0},
{"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE, {"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE,
......
...@@ -110,6 +110,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0), ...@@ -110,6 +110,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
net.last_error[0]=0; // If error on boot net.last_error[0]=0; // If error on boot
ull=0; ull=0;
system_thread=cleanup_done=0; system_thread=cleanup_done=0;
peer_port= 0; // For SHOW PROCESSLIST
transaction.changed_tables = 0; transaction.changed_tables = 0;
#ifdef __WIN__ #ifdef __WIN__
real_id = 0; real_id = 0;
......
...@@ -643,6 +643,9 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list) ...@@ -643,6 +643,9 @@ static TABLE *delayed_get_table(THD *thd,TABLE_LIST *table_list)
/* no match; create a new thread to handle the table */ /* no match; create a new thread to handle the table */
if (!(tmp=find_handler(thd,table_list))) if (!(tmp=find_handler(thd,table_list)))
{ {
/* Don't create more than max_insert_delayed_threads */
if (delayed_insert_threads >= max_insert_delayed_threads)
DBUG_RETURN(0);
thd->proc_info="Creating delayed handler"; thd->proc_info="Creating delayed handler";
pthread_mutex_lock(&LOCK_delayed_create); pthread_mutex_lock(&LOCK_delayed_create);
if (!(tmp=find_handler(thd,table_list))) // Was just created if (!(tmp=find_handler(thd,table_list))) // Was just created
...@@ -1021,7 +1024,7 @@ extern "C" pthread_handler_decl(handle_delayed_insert,arg) ...@@ -1021,7 +1024,7 @@ extern "C" pthread_handler_decl(handle_delayed_insert,arg)
while (!thd->killed) while (!thd->killed)
{ {
int error; int error;
#if (defined(HAVE_BROKEN_COND_TIMEDWAIT) || defined(HAVE_LINUXTHREADS)) #if defined(HAVE_BROKEN_COND_TIMEDWAIT)
error=pthread_cond_wait(&di->cond,&di->mutex); error=pthread_cond_wait(&di->cond,&di->mutex);
#else #else
error=pthread_cond_timedwait(&di->cond,&di->mutex,&abstime); error=pthread_cond_timedwait(&di->cond,&di->mutex,&abstime);
......
...@@ -210,9 +210,9 @@ static bool check_user(THD *thd,enum_server_command command, const char *user, ...@@ -210,9 +210,9 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
!(thd->client_capabilities & !(thd->client_capabilities &
CLIENT_LONG_PASSWORD),&ur); CLIENT_LONG_PASSWORD),&ur);
DBUG_PRINT("info", DBUG_PRINT("info",
("Capabilities: %d packet_length: %ld Host: '%s' User: '%s' Using password: %s Access: %u db: '%s'", ("Capabilities: %d packet_length: %ld Host: '%s' Login user: '%s' Priv_user: '%s' Using password: %s Access: %u db: '%s'",
thd->client_capabilities, thd->max_client_packet_length, thd->client_capabilities, thd->max_client_packet_length,
thd->host_or_ip, thd->priv_user, thd->host_or_ip, thd->user, thd->priv_user,
passwd[0] ? "yes": "no", passwd[0] ? "yes": "no",
thd->master_access, thd->db ? thd->db : "*none*")); thd->master_access, thd->db ? thd->db : "*none*"));
if (thd->master_access & NO_ACCESS) if (thd->master_access & NO_ACCESS)
...@@ -517,7 +517,6 @@ check_connections(THD *thd) ...@@ -517,7 +517,6 @@ check_connections(THD *thd)
DBUG_PRINT("info",("Host: %s",thd->host)); DBUG_PRINT("info",("Host: %s",thd->host));
thd->host_or_ip= thd->host; thd->host_or_ip= thd->host;
thd->ip= 0; thd->ip= 0;
thd->peer_port= 0;
bzero((char*) &thd->remote,sizeof(struct sockaddr)); bzero((char*) &thd->remote,sizeof(struct sockaddr));
} }
/* Ensure that wrong hostnames doesn't cause buffer overflows */ /* Ensure that wrong hostnames doesn't cause buffer overflows */
...@@ -3419,6 +3418,24 @@ void add_join_on(TABLE_LIST *b,Item *expr) ...@@ -3419,6 +3418,24 @@ void add_join_on(TABLE_LIST *b,Item *expr)
} }
/*
Mark that we have a NATURAL JOIN between two tables
SYNOPSIS
add_join_natural()
a Table to do normal join with
b Do normal join with this table
IMPLEMENTATION
This function just marks that table b should be joined with a.
The function setup_cond() will create in b->on_expr a list
of equal condition between all fields of the same name.
SELECT * FROM t1 NATURAL LEFT JOIN t2
<=>
SELECT * FROM t1 LEFT JOIN t2 ON (t1.i=t2.i and t1.j=t2.j ... )
*/
void add_join_natural(TABLE_LIST *a,TABLE_LIST *b) void add_join_natural(TABLE_LIST *a,TABLE_LIST *b)
{ {
b->natural_join=a; b->natural_join=a;
......
...@@ -556,7 +556,17 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, ...@@ -556,7 +556,17 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
select_distinct= 0; select_distinct= 0;
no_order= !order; no_order= !order;
if (all_order_fields_used) if (all_order_fields_used)
{
if (order && skip_sort_order)
{
/*
Force MySQL to read the table in sorted order to get result in
ORDER BY order.
*/
join.tmp_table_param.quick_group=0;
}
order=0; order=0;
}
join.group=1; // For end_write_group join.group=1; // For end_write_group
} }
else else
......
...@@ -492,12 +492,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -492,12 +492,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%right NOT %right NOT
%right BINARY %right BINARY
/* These don't actually affect the way the query is really evaluated, but
they silence a few warnings for shift/reduce conflicts. */
%left ','
%left STRAIGHT_JOIN JOIN_SYM
%nonassoc CROSS INNER_SYM NATURAL LEFT RIGHT
%type <lex_str> %type <lex_str>
IDENT TEXT_STRING REAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM LEX_HOSTNAME IDENT TEXT_STRING REAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM LEX_HOSTNAME
ULONGLONG_NUM field_ident select_alias ident ident_or_text ULONGLONG_NUM field_ident select_alias ident ident_or_text
...@@ -2116,7 +2110,7 @@ join_table_list: ...@@ -2116,7 +2110,7 @@ join_table_list:
| join_table_list ',' join_table_list { $$=$3; } | join_table_list ',' join_table_list { $$=$3; }
| join_table_list normal_join join_table_list { $$=$3; } | join_table_list normal_join join_table_list { $$=$3; }
| join_table_list STRAIGHT_JOIN join_table_list | join_table_list STRAIGHT_JOIN join_table_list
{ $$=$3 ; $$->straight=1; } { $$=$3 ; $1->next->straight=1; }
| join_table_list normal_join join_table_list ON expr | join_table_list normal_join join_table_list ON expr
{ add_join_on($3,$5); $$=$3; } { add_join_on($3,$5); $$=$3; }
| join_table_list normal_join join_table_list | join_table_list normal_join join_table_list
...@@ -2140,9 +2134,13 @@ join_table_list: ...@@ -2140,9 +2134,13 @@ join_table_list:
USING '(' using_list ')' USING '(' using_list ')'
{ add_join_on($5,$9); $5->outer_join|=JOIN_TYPE_LEFT; $$=$5; } { add_join_on($5,$9); $5->outer_join|=JOIN_TYPE_LEFT; $$=$5; }
| join_table_list NATURAL LEFT opt_outer JOIN_SYM join_table_list | join_table_list NATURAL LEFT opt_outer JOIN_SYM join_table_list
{ add_join_natural($1,$6); $6->outer_join|=JOIN_TYPE_LEFT; $$=$6; } {
add_join_natural($1,$1->next);
$1->next->outer_join|=JOIN_TYPE_LEFT;
$$=$6;
}
| join_table_list RIGHT opt_outer JOIN_SYM join_table_list ON expr | join_table_list RIGHT opt_outer JOIN_SYM join_table_list ON expr
{ add_join_on($1,$7); $1->outer_join|=JOIN_TYPE_RIGHT; $$=$1; } { add_join_on($1,$7); $1->outer_join|=JOIN_TYPE_RIGHT; $$=$5; }
| join_table_list RIGHT opt_outer JOIN_SYM join_table_list | join_table_list RIGHT opt_outer JOIN_SYM join_table_list
{ {
SELECT_LEX *sel=Select; SELECT_LEX *sel=Select;
...@@ -2150,11 +2148,15 @@ join_table_list: ...@@ -2150,11 +2148,15 @@ join_table_list:
sel->db2=$5->db; sel->table2=$5->alias; sel->db2=$5->db; sel->table2=$5->alias;
} }
USING '(' using_list ')' USING '(' using_list ')'
{ add_join_on($1,$9); $1->outer_join|=JOIN_TYPE_RIGHT; $$=$1; } { add_join_on($1,$9); $1->outer_join|=JOIN_TYPE_RIGHT; $$=$5; }
| join_table_list NATURAL RIGHT opt_outer JOIN_SYM join_table_list | join_table_list NATURAL RIGHT opt_outer JOIN_SYM join_table_list
{ add_join_natural($6,$1); $1->outer_join|=JOIN_TYPE_RIGHT; $$=$1; } {
add_join_natural($1->next,$1);
$1->outer_join|=JOIN_TYPE_RIGHT;
$$=$6;
}
| join_table_list NATURAL JOIN_SYM join_table_list | join_table_list NATURAL JOIN_SYM join_table_list
{ add_join_natural($1,$4); $$=$4; }; { add_join_natural($1,$1->next); $$=$4; };
normal_join: normal_join:
JOIN_SYM {} JOIN_SYM {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment