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
60a4b4fb
Commit
60a4b4fb
authored
Nov 05, 2005
by
igor@rurik.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge rurik.mysql.com:/home/igor/mysql-5.0
into rurik.mysql.com:/home/igor/dev/mysql-5.0-0
parents
0960f5fe
33026e52
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
524 additions
and
29 deletions
+524
-29
mysql-test/r/bigint.result
mysql-test/r/bigint.result
+1
-1
mysql-test/r/join_nested.result
mysql-test/r/join_nested.result
+64
-0
mysql-test/r/view.result
mysql-test/r/view.result
+22
-1
mysql-test/t/bigint.test
mysql-test/t/bigint.test
+1
-1
mysql-test/t/join_nested.test
mysql-test/t/join_nested.test
+68
-0
mysql-test/t/view.test
mysql-test/t/view.test
+27
-1
sql/mysql_priv.h
sql/mysql_priv.h
+6
-0
sql/sql_lex.cc
sql/sql_lex.cc
+30
-10
sql/sql_prepare.cc
sql/sql_prepare.cc
+0
-2
sql/sql_select.cc
sql/sql_select.cc
+286
-11
sql/sql_select.h
sql/sql_select.h
+10
-1
sql/table.h
sql/table.h
+9
-1
No files found.
mysql-test/r/bigint.result
View file @
60a4b4fb
drop table if exists t1;
drop table if exists t1
, t2
;
select 0,256,00000000000000065536,2147483647,-2147483648,2147483648,+4294967296;
0 256 00000000000000065536 2147483647 -2147483648 2147483648 4294967296
0 256 65536 2147483647 -2147483648 2147483648 4294967296
...
...
mysql-test/r/join_nested.result
View file @
60a4b4fb
...
...
@@ -1403,3 +1403,67 @@ SELECT v2.x FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d);
ERROR 42S22: Unknown column 'v2.x' in 'field list'
DROP VIEW v1, v2;
DROP TABLE t1, t2, t3, t4, t5, t6;
create table t1 (id1 int(11) not null);
insert into t1 values (1),(2);
create table t2 (id2 int(11) not null);
insert into t2 values (1),(2),(3),(4);
create table t3 (id3 char(16) not null);
insert into t3 values ('100');
create table t4 (id2 int(11) not null, id3 char(16));
create table t5 (id1 int(11) not null, key (id1));
insert into t5 values (1),(2),(1);
create view v1 as
select t4.id3 from t4 join t2 on t4.id2 = t2.id2;
select t1.id1 from t1 inner join (t3 left join v1 on t3.id3 = v1.id3);
id1
1
2
drop view v1;
drop table t1, t2, t3, t4, t5;
create table t0 (a int);
insert into t0 values (0),(1),(2),(3);
create table t1(a int);
insert into t1 select A.a + 10*(B.a) from t0 A, t0 B;
create table t2 (a int, b int);
insert into t2 values (1,1), (2,2), (3,3);
create table t3(a int, b int, filler char(200), key(a));
insert into t3 select a,a,'filler' from t1;
insert into t3 select a,a,'filler' from t1;
create table t4 like t3;
insert into t4 select * from t3;
insert into t4 select * from t3;
create table t5 like t4;
insert into t5 select * from t4;
insert into t5 select * from t4;
create table t6 like t5;
insert into t6 select * from t5;
insert into t6 select * from t5;
create table t7 like t6;
insert into t7 select * from t6;
insert into t7 select * from t6;
explain select * from t4 join
t2 left join (t3 join t5 on t5.a=t3.b) on t3.a=t2.b where t4.a<=>t3.b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL X
1 SIMPLE t3 ref a a 5 test.t2.b X
1 SIMPLE t5 ref a a 5 test.t3.b X
1 SIMPLE t4 ref a a 5 test.t3.b X Using where
explain select * from (t4 join t6 on t6.a=t4.b) right join t3 on t4.a=t3.b
join t2 left join (t5 join t7 on t7.a=t5.b) on t5.a=t2.b where t3.a<=>t2.b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL X
1 SIMPLE t3 ref a a 5 test.t2.b X Using where
1 SIMPLE t4 ref a a 5 test.t3.b X
1 SIMPLE t6 ref a a 5 test.t4.b X
1 SIMPLE t5 ref a a 5 test.t2.b X
1 SIMPLE t7 ref a a 5 test.t5.b X
explain select * from t2 left join
(t3 left join (t4 join t6 on t6.a=t4.b) on t4.a=t3.b
join t5 on t5.a=t3.b) on t3.a=t2.b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL X
1 SIMPLE t3 ref a a 5 test.t2.b X
1 SIMPLE t4 ref a a 5 test.t3.b X
1 SIMPLE t6 ref a a 5 test.t4.b X
1 SIMPLE t5 ref a a 5 test.t3.b X
drop table t0, t1, t2, t4, t5, t6;
mysql-test/r/view.result
View file @
60a4b4fb
drop table if exists t1,t2,t9,`t1a``b`,v1,v2,v3,v4,v5,v6;
drop table if exists t1,t2,t
3,t4,t
9,`t1a``b`,v1,v2,v3,v4,v5,v6;
drop view if exists t1,t2,`t1a``b`,v1,v2,v3,v4,v5,v6;
drop database if exists mysqltest;
use test;
...
...
@@ -2335,6 +2335,27 @@ f1 group_concat(f2 order by f2 desc)
1 3,2,1
drop view v1,v2;
drop table t1;
create table t1 (x int, y int);
create table t2 (x int, y int, z int);
create table t3 (x int, y int, z int);
create table t4 (x int, y int, z int);
create view v1 as
select t1.x
from (
(t1 join t2 on ((t1.y = t2.y)))
join
(t3 left join t4 on (t3.y = t4.y) and (t3.z = t4.z))
);
prepare stmt1 from "select count(*) from v1 where x = ?";
set @parm1=1;
execute stmt1 using @parm1;
count(*)
0
execute stmt1 using @parm1;
count(*)
0
drop view v1;
drop table t1,t2,t3,t4;
CREATE TABLE t1(id INT);
CREATE VIEW v1 AS SELECT id FROM t1;
OPTIMIZE TABLE v1;
...
...
mysql-test/t/bigint.test
View file @
60a4b4fb
...
...
@@ -2,7 +2,7 @@
# Initialize
--
disable_warnings
drop
table
if
exists
t1
;
drop
table
if
exists
t1
,
t2
;
--
enable_warnings
#
...
...
mysql-test/t/join_nested.test
View file @
60a4b4fb
...
...
@@ -832,3 +832,71 @@ SELECT v2.x FROM v2 JOIN t2 ON e=b JOIN t3 ON e=c JOIN t4 USING(d);
DROP
VIEW
v1
,
v2
;
DROP
TABLE
t1
,
t2
,
t3
,
t4
,
t5
,
t6
;
#
# BUG#13126 -test case from bug report
#
create
table
t1
(
id1
int
(
11
)
not
null
);
insert
into
t1
values
(
1
),(
2
);
create
table
t2
(
id2
int
(
11
)
not
null
);
insert
into
t2
values
(
1
),(
2
),(
3
),(
4
);
create
table
t3
(
id3
char
(
16
)
not
null
);
insert
into
t3
values
(
'100'
);
create
table
t4
(
id2
int
(
11
)
not
null
,
id3
char
(
16
));
create
table
t5
(
id1
int
(
11
)
not
null
,
key
(
id1
));
insert
into
t5
values
(
1
),(
2
),(
1
);
create
view
v1
as
select
t4
.
id3
from
t4
join
t2
on
t4
.
id2
=
t2
.
id2
;
select
t1
.
id1
from
t1
inner
join
(
t3
left
join
v1
on
t3
.
id3
=
v1
.
id3
);
drop
view
v1
;
drop
table
t1
,
t2
,
t3
,
t4
,
t5
;
create
table
t0
(
a
int
);
insert
into
t0
values
(
0
),(
1
),(
2
),(
3
);
create
table
t1
(
a
int
);
insert
into
t1
select
A
.
a
+
10
*
(
B
.
a
)
from
t0
A
,
t0
B
;
create
table
t2
(
a
int
,
b
int
);
insert
into
t2
values
(
1
,
1
),
(
2
,
2
),
(
3
,
3
);
create
table
t3
(
a
int
,
b
int
,
filler
char
(
200
),
key
(
a
));
insert
into
t3
select
a
,
a
,
'filler'
from
t1
;
insert
into
t3
select
a
,
a
,
'filler'
from
t1
;
create
table
t4
like
t3
;
insert
into
t4
select
*
from
t3
;
insert
into
t4
select
*
from
t3
;
create
table
t5
like
t4
;
insert
into
t5
select
*
from
t4
;
insert
into
t5
select
*
from
t4
;
create
table
t6
like
t5
;
insert
into
t6
select
*
from
t5
;
insert
into
t6
select
*
from
t5
;
create
table
t7
like
t6
;
insert
into
t7
select
*
from
t6
;
insert
into
t7
select
*
from
t6
;
--
replace_column
9
X
explain
select
*
from
t4
join
t2
left
join
(
t3
join
t5
on
t5
.
a
=
t3
.
b
)
on
t3
.
a
=
t2
.
b
where
t4
.
a
<=>
t3
.
b
;
--
replace_column
9
X
explain
select
*
from
(
t4
join
t6
on
t6
.
a
=
t4
.
b
)
right
join
t3
on
t4
.
a
=
t3
.
b
join
t2
left
join
(
t5
join
t7
on
t7
.
a
=
t5
.
b
)
on
t5
.
a
=
t2
.
b
where
t3
.
a
<=>
t2
.
b
;
--
replace_column
9
X
explain
select
*
from
t2
left
join
(
t3
left
join
(
t4
join
t6
on
t6
.
a
=
t4
.
b
)
on
t4
.
a
=
t3
.
b
join
t5
on
t5
.
a
=
t3
.
b
)
on
t3
.
a
=
t2
.
b
;
drop
table
t0
,
t1
,
t2
,
t4
,
t5
,
t6
;
mysql-test/t/view.test
View file @
60a4b4fb
--
disable_warnings
drop
table
if
exists
t1
,
t2
,
t9
,
`t1a``b`
,
v1
,
v2
,
v3
,
v4
,
v5
,
v6
;
drop
table
if
exists
t1
,
t2
,
t
3
,
t4
,
t
9
,
`t1a``b`
,
v1
,
v2
,
v3
,
v4
,
v5
,
v6
;
drop
view
if
exists
t1
,
t2
,
`t1a``b`
,
v1
,
v2
,
v3
,
v4
,
v5
,
v6
;
drop
database
if
exists
mysqltest
;
--
enable_warnings
...
...
@@ -2200,6 +2200,32 @@ select * from v1;
select
*
from
v2
;
drop
view
v1
,
v2
;
drop
table
t1
;
#
# BUG#14026 Crash on second PS execution when using views
#
create
table
t1
(
x
int
,
y
int
);
create
table
t2
(
x
int
,
y
int
,
z
int
);
create
table
t3
(
x
int
,
y
int
,
z
int
);
create
table
t4
(
x
int
,
y
int
,
z
int
);
create
view
v1
as
select
t1
.
x
from
(
(
t1
join
t2
on
((
t1
.
y
=
t2
.
y
)))
join
(
t3
left
join
t4
on
(
t3
.
y
=
t4
.
y
)
and
(
t3
.
z
=
t4
.
z
))
);
prepare
stmt1
from
"select count(*) from v1 where x = ?"
;
set
@
parm1
=
1
;
execute
stmt1
using
@
parm1
;
execute
stmt1
using
@
parm1
;
drop
view
v1
;
drop
table
t1
,
t2
,
t3
,
t4
;
#
# Bug #14540: OPTIMIZE, ANALYZE, REPAIR applied to not a view
#
...
...
sql/mysql_priv.h
View file @
60a4b4fb
...
...
@@ -44,6 +44,12 @@
typedef
ulonglong
table_map
;
/* Used for table bits in join */
typedef
Bitmap
<
64
>
key_map
;
/* Used for finding keys */
typedef
ulong
key_part_map
;
/* Used for finding key parts */
/*
Used to identify NESTED_JOIN structures within a join (applicable only to
structures that have not been simplified away and embed more the one
element)
*/
typedef
ulonglong
nested_join_map
;
/* query_id */
typedef
ulonglong
query_id_t
;
...
...
sql/sql_lex.cc
View file @
60a4b4fb
...
...
@@ -2037,6 +2037,35 @@ void st_lex::cleanup_after_one_table_open()
}
/*
Do end-of-prepare fixup for list of tables and their merge-VIEWed tables
SYNOPSIS
fix_prepare_info_in_table_list()
thd Thread handle
tbl List of tables to process
DESCRIPTION
Perform end-end-of prepare fixup for list of tables, if any of the tables
is a merge-algorithm VIEW, recursively fix up its underlying tables as
well.
*/
static
void
fix_prepare_info_in_table_list
(
THD
*
thd
,
TABLE_LIST
*
tbl
)
{
for
(;
tbl
;
tbl
=
tbl
->
next_local
)
{
if
(
tbl
->
on_expr
)
{
tbl
->
prep_on_expr
=
tbl
->
on_expr
;
tbl
->
on_expr
=
tbl
->
on_expr
->
copy_andor_structure
(
thd
);
}
fix_prepare_info_in_table_list
(
thd
,
tbl
->
merge_underlying_list
);
}
}
/*
fix some structures at the end of preparation
...
...
@@ -2056,16 +2085,7 @@ void st_select_lex::fix_prepare_information(THD *thd, Item **conds)
prep_where
=
*
conds
;
*
conds
=
where
=
prep_where
->
copy_andor_structure
(
thd
);
}
for
(
TABLE_LIST
*
tbl
=
(
TABLE_LIST
*
)
table_list
.
first
;
tbl
;
tbl
=
tbl
->
next_local
)
{
if
(
tbl
->
on_expr
)
{
tbl
->
prep_on_expr
=
tbl
->
on_expr
;
tbl
->
on_expr
=
tbl
->
on_expr
->
copy_andor_structure
(
thd
);
}
}
fix_prepare_info_in_table_list
(
thd
,
(
TABLE_LIST
*
)
table_list
.
first
);
}
}
...
...
sql/sql_prepare.cc
View file @
60a4b4fb
...
...
@@ -2109,8 +2109,6 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
were closed in the end of previous prepare or execute call.
*/
tables
->
table
=
0
;
if
(
tables
->
nested_join
)
tables
->
nested_join
->
counter
=
0
;
if
(
tables
->
prep_on_expr
)
{
...
...
sql/sql_select.cc
View file @
60a4b4fb
This diff is collapsed.
Click to expand it.
sql/sql_select.h
View file @
60a4b4fb
...
...
@@ -136,7 +136,9 @@ typedef struct st_join_table {
TABLE_REF
ref
;
JOIN_CACHE
cache
;
JOIN
*
join
;
/* Bitmap of nested joins this table is part of */
nested_join_map
embedding_map
;
void
cleanup
();
}
JOIN_TAB
;
...
...
@@ -193,6 +195,13 @@ class JOIN :public Sql_alloc
*/
ha_rows
fetch_limit
;
POSITION
positions
[
MAX_TABLES
+
1
],
best_positions
[
MAX_TABLES
+
1
];
/*
Bitmap of nested joins embedding the position at the end of the current
partial join (valid only during join optimizer run).
*/
nested_join_map
cur_embedding_map
;
double
best_read
;
List
<
Item
>
*
fields
;
List
<
Cached_item
>
group_fields
,
group_fields_cache
;
...
...
sql/table.h
View file @
60a4b4fb
...
...
@@ -795,7 +795,15 @@ typedef struct st_nested_join
table_map
used_tables
;
/* bitmap of tables in the nested join */
table_map
not_null_tables
;
/* tables that rejects nulls */
struct
st_join_table
*
first_nested
;
/* the first nested table in the plan */
uint
counter
;
/* to count tables in the nested join */
/*
Used to count tables in the nested join in 2 isolated places:
1. In make_outerjoin_info().
2. check_interleaving_with_nj/restore_prev_nj_state (these are called
by the join optimizer.
Before each use the counters are zeroed by reset_nj_counters.
*/
uint
counter
;
nested_join_map
nj_map
;
/* Bit used to identify this nested join*/
}
NESTED_JOIN
;
...
...
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