Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
3bfbe6e0
Commit
3bfbe6e0
authored
Mar 30, 2004
by
ram@gw.mysql.r18.ru
Browse files
Options
Browse Files
Download
Plain Diff
resolving conflicts
parents
4bc6b551
fffe1e84
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
39 deletions
+48
-39
mysql-test/r/join.result
mysql-test/r/join.result
+3
-3
mysql-test/r/join_outer.result
mysql-test/r/join_outer.result
+6
-6
mysql-test/r/select.result
mysql-test/r/select.result
+4
-4
sql/sql_base.cc
sql/sql_base.cc
+35
-26
No files found.
mysql-test/r/join.result
View file @
3bfbe6e0
...
@@ -277,11 +277,11 @@ CREATE TABLE t2 (ID INTEGER NOT NULL PRIMARY KEY, Value2 VARCHAR(255));
...
@@ -277,11 +277,11 @@ CREATE TABLE t2 (ID INTEGER NOT NULL PRIMARY KEY, Value2 VARCHAR(255));
INSERT INTO t1 VALUES (1, 'A');
INSERT INTO t1 VALUES (1, 'A');
INSERT INTO t2 VALUES (1, 'B');
INSERT INTO t2 VALUES (1, 'B');
SELECT * FROM t1 NATURAL JOIN t2 WHERE 1 AND (Value1 = 'A' AND Value2 <> 'B');
SELECT * FROM t1 NATURAL JOIN t2 WHERE 1 AND (Value1 = 'A' AND Value2 <> 'B');
ID Value1
ID
Value2
ID Value1 Value2
SELECT * FROM t1 NATURAL JOIN t2 WHERE 1 AND Value1 = 'A' AND Value2 <> 'B';
SELECT * FROM t1 NATURAL JOIN t2 WHERE 1 AND Value1 = 'A' AND Value2 <> 'B';
ID Value1
ID
Value2
ID Value1 Value2
SELECT * FROM t1 NATURAL JOIN t2 WHERE (Value1 = 'A' AND Value2 <> 'B') AND 1;
SELECT * FROM t1 NATURAL JOIN t2 WHERE (Value1 = 'A' AND Value2 <> 'B') AND 1;
ID Value1
ID
Value2
ID Value1 Value2
drop table t1,t2;
drop table t1,t2;
create table t1 (i int);
create table t1 (i int);
create table t2 (i int);
create table t2 (i int);
...
...
mysql-test/r/join_outer.result
View file @
3bfbe6e0
...
@@ -124,8 +124,8 @@ grp a c id a c d
...
@@ -124,8 +124,8 @@ grp a c id a c d
3 5 C 3 5 B 5
3 5 C 3 5 B 5
3 6 D 3 6 C 6
3 6 D 3 6 C 6
select t1.*,t2.* from t1 natural join t2;
select t1.*,t2.* from t1 natural join t2;
grp a c id
a c
d
grp a c id d
1 1 a 1 1
a 1
1 1 a 1 1
drop table t1,t2;
drop table t1,t2;
CREATE TABLE t1 (
CREATE TABLE t1 (
usr_id INT unsigned NOT NULL,
usr_id INT unsigned NOT NULL,
...
@@ -467,10 +467,10 @@ count color
...
@@ -467,10 +467,10 @@ count color
15 white
15 white
7 green
7 green
select * from t2 natural join t1;
select * from t2 natural join t1;
count color
color
name
count color name
10 green
green
lime
10 green lime
7 green
green
lime
7 green lime
5 black
black
grape
5 black grape
select t2.count, t1.name from t2 natural join t1;
select t2.count, t1.name from t2 natural join t1;
count name
count name
10 lime
10 lime
...
...
mysql-test/r/select.result
View file @
3bfbe6e0
...
@@ -2279,10 +2279,10 @@ a a a
...
@@ -2279,10 +2279,10 @@ a a a
2 2 2
2 2 2
3 3 3
3 3 3
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
1 1
1
1 1
2 2
2
2 2
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
1 1 1
1 1 1
...
...
sql/sql_base.cc
View file @
3bfbe6e0
...
@@ -2293,14 +2293,27 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name,
...
@@ -2293,14 +2293,27 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name,
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
#endif
#endif
Field
**
ptr
=
table
->
field
,
*
field
;
Field
**
ptr
=
table
->
field
,
*
field
;
TABLE
*
natural_join_table
;
thd
->
used_tables
|=
table
->
map
;
thd
->
used_tables
|=
table
->
map
;
if
(
table
->
outer_join
||
!
tables
->
natural_join
||
tables
->
natural_join
->
table
->
outer_join
)
natural_join_table
=
NULL
;
else
natural_join_table
=
tables
->
natural_join
->
table
;
while
((
field
=
*
ptr
++
))
while
((
field
=
*
ptr
++
))
{
/* Skip duplicate field names if NATURAL JOIN is used */
if
(
!
natural_join_table
||
!
find_field_in_table
(
thd
,
natural_join_table
,
field
->
field_name
,
strlen
(
field
->
field_name
),
0
,
0
))
{
{
Item_field
*
item
=
new
Item_field
(
field
);
Item_field
*
item
=
new
Item_field
(
field
);
if
(
!
found
++
)
if
(
!
found
++
)
(
void
)
it
->
replace
(
item
);
// Replace '*'
(
void
)
it
->
replace
(
item
);
// Replace '*'
else
else
it
->
after
(
item
);
it
->
after
(
item
);
}
/*
/*
Mark if field used before in this select.
Mark if field used before in this select.
Used by 'insert' to verify if a field name is used twice
Used by 'insert' to verify if a field name is used twice
...
@@ -2383,27 +2396,23 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
...
@@ -2383,27 +2396,23 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds)
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
cond_and
->
top_level_item
();
cond_and
->
top_level_item
();
uint
i
,
j
;
Field
**
t1_field
,
*
t2_field
;
for
(
i
=
0
;
i
<
t1
->
fields
;
i
++
)
for
(
t1_field
=
t1
->
field
;
(
*
t1_field
);
t1_field
++
)
{
// TODO: This could be optimized to use hashed names if t2 had a hash
for
(
j
=
0
;
j
<
t2
->
fields
;
j
++
)
{
{
if
(
!
my_strcasecmp
(
system_charset_info
,
const
char
*
t1_field_name
=
(
*
t1_field
)
->
field_name
;
t1
->
field
[
i
]
->
field_name
,
t2
->
field
[
j
]
->
field_name
))
if
((
t2_field
=
find_field_in_table
(
thd
,
t2
,
t1_field_name
,
strlen
(
t1_field_name
),
0
,
0
)))
{
{
Item_func_eq
*
tmp
=
new
Item_func_eq
(
new
Item_field
(
t1
->
field
[
i
]
),
Item_func_eq
*
tmp
=
new
Item_func_eq
(
new
Item_field
(
*
t1_field
),
new
Item_field
(
t2
->
field
[
j
]
));
new
Item_field
(
t2_field
));
if
(
!
tmp
)
if
(
!
tmp
)
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
/* Mark field used for table cache */
/* Mark field used for table cache */
t1
->
field
[
i
]
->
query_id
=
t2
->
field
[
j
]
->
query_id
=
thd
->
query_id
;
(
*
t1_field
)
->
query_id
=
t2_field
->
query_id
=
thd
->
query_id
;
cond_and
->
list
.
push_back
(
tmp
);
cond_and
->
list
.
push_back
(
tmp
);
t1
->
used_keys
.
intersect
(
t1
->
field
[
i
]
->
part_of_key
);
t1
->
used_keys
.
intersect
((
*
t1_field
)
->
part_of_key
);
t2
->
used_keys
.
intersect
(
t2
->
field
[
j
]
->
part_of_key
);
t2
->
used_keys
.
intersect
(
t2_field
->
part_of_key
);
break
;
}
}
}
}
}
thd
->
lex
->
current_select
->
cond_count
+=
cond_and
->
list
.
elements
;
thd
->
lex
->
current_select
->
cond_count
+=
cond_and
->
list
.
elements
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment