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
979f27ee
Commit
979f27ee
authored
Nov 14, 2002
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bug in cyclic reference refinition
parent
b724f02c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
6 deletions
+36
-6
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+2
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+2
-0
sql/item.cc
sql/item.cc
+1
-5
sql/sql_class.cc
sql/sql_class.cc
+9
-0
sql/sql_class.h
sql/sql_class.h
+2
-0
sql/sql_parse.cc
sql/sql_parse.cc
+3
-1
sql/sql_select.cc
sql/sql_select.cc
+17
-0
No files found.
mysql-test/r/subselect.result
View file @
979f27ee
...
...
@@ -10,6 +10,8 @@ SELECT (SELECT (SELECT 0 UNION SELECT 0));
0
SELECT (SELECT 1 FROM (SELECT 1) HAVING a=1) as a;
Cyclic reference on subqueries
SELECT (SELECT 1 FROM (SELECT 1) HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) HAVING a=1) as b;
Cyclic reference on subqueries
drop table if exists t1,t2,t3,t4,t5,attend,clinic,inscrit;
create table t1 (a int);
create table t2 (a int, b int);
...
...
mysql-test/t/subselect.test
View file @
979f27ee
...
...
@@ -3,6 +3,8 @@ SELECT (SELECT 1) UNION SELECT (SELECT 2);
SELECT
(
SELECT
(
SELECT
0
UNION
SELECT
0
));
--
error
1243
SELECT
(
SELECT
1
FROM
(
SELECT
1
)
HAVING
a
=
1
)
as
a
;
--
error
1243
SELECT
(
SELECT
1
FROM
(
SELECT
1
)
HAVING
b
=
1
)
as
a
,(
SELECT
1
FROM
(
SELECT
1
)
HAVING
a
=
1
)
as
b
;
drop
table
if
exists
t1
,
t2
,
t3
,
t4
,
t5
,
attend
,
clinic
,
inscrit
;
create
table
t1
(
a
int
);
create
table
t2
(
a
int
,
b
int
);
...
...
sql/item.cc
View file @
979f27ee
...
...
@@ -876,11 +876,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference)
{
depended_from
=
last
;
thd
->
lex
.
current_select
->
mark_as_dependent
(
last
);
if
(
check_loop
(
thd
->
check_loops_counter
++
))
{
my_message
(
ER_CYCLIC_REFERENCE
,
ER
(
ER_CYCLIC_REFERENCE
),
MYF
(
0
));
return
1
;
}
thd
->
add_possible_loop
(
this
);
}
}
else
if
(
!
ref
)
...
...
sql/sql_class.cc
View file @
979f27ee
...
...
@@ -434,6 +434,15 @@ void THD::close_active_vio()
}
#endif
void
THD
::
add_possible_loop
(
Item
*
item
)
{
if
(
!
possible_loops
)
{
possible_loops
=
new
List
<
Item
>
;
}
possible_loops
->
push_back
(
item
);
}
/*****************************************************************************
** Functions to provide a interface to select results
*****************************************************************************/
...
...
sql/sql_class.h
View file @
979f27ee
...
...
@@ -482,6 +482,7 @@ public:
USER_CONN
*
user_connect
;
CHARSET_INFO
*
db_charset
;
CHARSET_INFO
*
thd_charset
;
List
<
Item
>
*
possible_loops
;
// Items that may cause loops in subselects
List
<
MYSQL_ERROR
>
warn_list
;
uint
warn_count
[(
uint
)
MYSQL_ERROR
::
WARN_LEVEL_END
];
uint
total_warn_count
,
old_total_warn_count
;
...
...
@@ -632,6 +633,7 @@ public:
net
.
last_errno
=
0
;
net
.
report_error
=
0
;
}
void
add_possible_loop
(
Item
*
);
};
/*
...
...
sql/sql_parse.cc
View file @
979f27ee
...
...
@@ -2862,7 +2862,8 @@ mysql_init_query(THD *thd)
lex
->
select_lex
.
init_query
();
lex
->
value_list
.
empty
();
lex
->
param_list
.
empty
();
lex
->
unit
.
global_parameters
=
lex
->
unit
.
slave
=
lex
->
current_select
=
&
lex
->
select_lex
;
lex
->
unit
.
global_parameters
=
lex
->
unit
.
slave
=
lex
->
current_select
=
&
lex
->
select_lex
;
lex
->
select_lex
.
master
=
&
lex
->
unit
;
lex
->
select_lex
.
prev
=
&
lex
->
unit
.
slave
;
lex
->
olap
=
lex
->
describe
=
0
;
...
...
@@ -2875,6 +2876,7 @@ mysql_init_query(THD *thd)
thd
->
sent_row_count
=
thd
->
examined_row_count
=
0
;
thd
->
fatal_error
=
thd
->
rand_used
=
0
;
thd
->
safe_to_cache_query
=
1
;
thd
->
possible_loops
=
0
;
DBUG_VOID_RETURN
;
}
...
...
sql/sql_select.cc
View file @
979f27ee
...
...
@@ -1087,6 +1087,23 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds,
{
DBUG_RETURN
(
-
1
);
}
if
(
thd
->
possible_loops
)
{
Item
*
item
;
while
(
thd
->
possible_loops
->
elements
)
{
item
=
thd
->
possible_loops
->
pop
();
if
(
item
->
check_loop
(
thd
->
check_loops_counter
++
))
{
delete
thd
->
possible_loops
;
thd
->
possible_loops
=
0
;
my_message
(
ER_CYCLIC_REFERENCE
,
ER
(
ER_CYCLIC_REFERENCE
),
MYF
(
0
));
return
1
;
}
}
delete
thd
->
possible_loops
;
thd
->
possible_loops
=
0
;
}
}
switch
(
join
->
optimize
())
...
...
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