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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
2ec485f0
Commit
2ec485f0
authored
Sep 18, 2006
by
gkodinov@dl145s.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal:/home/bk/mysql-5.0-opt
into dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt
parents
fae596aa
d3d3cef8
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
158 additions
and
11 deletions
+158
-11
mysql-test/r/sp.result
mysql-test/r/sp.result
+63
-0
mysql-test/t/sp.test
mysql-test/t/sp.test
+67
-0
sql/sql_delete.cc
sql/sql_delete.cc
+2
-1
sql/sql_insert.cc
sql/sql_insert.cc
+1
-1
sql/sql_lex.cc
sql/sql_lex.cc
+19
-4
sql/sql_lex.h
sql/sql_lex.h
+1
-1
sql/sql_select.cc
sql/sql_select.cc
+3
-3
sql/sql_update.cc
sql/sql_update.cc
+2
-1
No files found.
mysql-test/r/sp.result
View file @
2ec485f0
...
@@ -5394,4 +5394,67 @@ Procedure sql_mode Create Procedure
...
@@ -5394,4 +5394,67 @@ Procedure sql_mode Create Procedure
bug21416 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug21416`()
bug21416 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug21416`()
show create procedure bug21416
show create procedure bug21416
drop procedure bug21416|
drop procedure bug21416|
CREATE TABLE t3 (
Member_ID varchar(15) NOT NULL,
PRIMARY KEY (Member_ID)
)|
CREATE TABLE t4 (
ID int(10) unsigned NOT NULL auto_increment,
Member_ID varchar(15) NOT NULL default '',
Action varchar(12) NOT NULL,
Action_Date datetime NOT NULL,
Track varchar(15) default NULL,
User varchar(12) default NULL,
Date_Updated timestamp NOT NULL default CURRENT_TIMESTAMP on update
CURRENT_TIMESTAMP,
PRIMARY KEY (ID),
KEY Action (Action),
KEY Action_Date (Action_Date)
)|
INSERT INTO t3(Member_ID) VALUES
('111111'), ('222222'), ('333333'), ('444444'), ('555555'), ('666666')|
INSERT INTO t4(Member_ID, Action, Action_Date, Track) VALUES
('111111', 'Disenrolled', '2006-03-01', 'CAD' ),
('111111', 'Enrolled', '2006-03-01', 'CAD' ),
('111111', 'Disenrolled', '2006-07-03', 'CAD' ),
('222222', 'Enrolled', '2006-03-07', 'CAD' ),
('222222', 'Enrolled', '2006-03-07', 'CHF' ),
('222222', 'Disenrolled', '2006-08-02', 'CHF' ),
('333333', 'Enrolled', '2006-03-01', 'CAD' ),
('333333', 'Disenrolled', '2006-03-01', 'CAD' ),
('444444', 'Enrolled', '2006-03-01', 'CAD' ),
('555555', 'Disenrolled', '2006-03-01', 'CAD' ),
('555555', 'Enrolled', '2006-07-21', 'CAD' ),
('555555', 'Disenrolled', '2006-03-01', 'CHF' ),
('666666', 'Enrolled', '2006-02-09', 'CAD' ),
('666666', 'Enrolled', '2006-05-12', 'CHF' ),
('666666', 'Disenrolled', '2006-06-01', 'CAD' )|
DROP FUNCTION IF EXISTS bug21493|
Warnings:
Note 1305 FUNCTION bug21493 does not exist
CREATE FUNCTION bug21493(paramMember VARCHAR(15)) RETURNS varchar(45)
BEGIN
DECLARE tracks VARCHAR(45);
SELECT GROUP_CONCAT(Track SEPARATOR ', ') INTO tracks FROM t4
WHERE Member_ID=paramMember AND Action='Enrolled' AND
(Track,Action_Date) IN (SELECT Track, MAX(Action_Date) FROM t4
WHERE Member_ID=paramMember GROUP BY Track);
RETURN tracks;
END|
SELECT bug21493('111111')|
bug21493('111111')
NULL
SELECT bug21493('222222')|
bug21493('222222')
CAD
SELECT bug21493(Member_ID) FROM t3|
bug21493(Member_ID)
NULL
CAD
CAD
CAD
CAD
CHF
DROP FUNCTION bug21493|
DROP TABLE t3,t4|
drop table t1,t2;
drop table t1,t2;
mysql-test/t/sp.test
View file @
2ec485f0
...
@@ -6322,6 +6322,73 @@ create procedure bug21416() show create procedure bug21416|
...
@@ -6322,6 +6322,73 @@ create procedure bug21416() show create procedure bug21416|
call
bug21416
()
|
call
bug21416
()
|
drop
procedure
bug21416
|
drop
procedure
bug21416
|
#
# BUG#21493: Crash on the second call of a procedure containing
# a select statement that uses an IN aggregating subquery
#
CREATE
TABLE
t3
(
Member_ID
varchar
(
15
)
NOT
NULL
,
PRIMARY
KEY
(
Member_ID
)
)
|
CREATE
TABLE
t4
(
ID
int
(
10
)
unsigned
NOT
NULL
auto_increment
,
Member_ID
varchar
(
15
)
NOT
NULL
default
''
,
Action
varchar
(
12
)
NOT
NULL
,
Action_Date
datetime
NOT
NULL
,
Track
varchar
(
15
)
default
NULL
,
User
varchar
(
12
)
default
NULL
,
Date_Updated
timestamp
NOT
NULL
default
CURRENT_TIMESTAMP
on
update
CURRENT_TIMESTAMP
,
PRIMARY
KEY
(
ID
),
KEY
Action
(
Action
),
KEY
Action_Date
(
Action_Date
)
)
|
INSERT
INTO
t3
(
Member_ID
)
VALUES
(
'111111'
),
(
'222222'
),
(
'333333'
),
(
'444444'
),
(
'555555'
),
(
'666666'
)
|
INSERT
INTO
t4
(
Member_ID
,
Action
,
Action_Date
,
Track
)
VALUES
(
'111111'
,
'Disenrolled'
,
'2006-03-01'
,
'CAD'
),
(
'111111'
,
'Enrolled'
,
'2006-03-01'
,
'CAD'
),
(
'111111'
,
'Disenrolled'
,
'2006-07-03'
,
'CAD'
),
(
'222222'
,
'Enrolled'
,
'2006-03-07'
,
'CAD'
),
(
'222222'
,
'Enrolled'
,
'2006-03-07'
,
'CHF'
),
(
'222222'
,
'Disenrolled'
,
'2006-08-02'
,
'CHF'
),
(
'333333'
,
'Enrolled'
,
'2006-03-01'
,
'CAD'
),
(
'333333'
,
'Disenrolled'
,
'2006-03-01'
,
'CAD'
),
(
'444444'
,
'Enrolled'
,
'2006-03-01'
,
'CAD'
),
(
'555555'
,
'Disenrolled'
,
'2006-03-01'
,
'CAD'
),
(
'555555'
,
'Enrolled'
,
'2006-07-21'
,
'CAD'
),
(
'555555'
,
'Disenrolled'
,
'2006-03-01'
,
'CHF'
),
(
'666666'
,
'Enrolled'
,
'2006-02-09'
,
'CAD'
),
(
'666666'
,
'Enrolled'
,
'2006-05-12'
,
'CHF'
),
(
'666666'
,
'Disenrolled'
,
'2006-06-01'
,
'CAD'
)
|
#--disable_warnings
DROP
FUNCTION
IF
EXISTS
bug21493
|
#--enable_warnings
CREATE
FUNCTION
bug21493
(
paramMember
VARCHAR
(
15
))
RETURNS
varchar
(
45
)
BEGIN
DECLARE
tracks
VARCHAR
(
45
);
SELECT
GROUP_CONCAT
(
Track
SEPARATOR
', '
)
INTO
tracks
FROM
t4
WHERE
Member_ID
=
paramMember
AND
Action
=
'Enrolled'
AND
(
Track
,
Action_Date
)
IN
(
SELECT
Track
,
MAX
(
Action_Date
)
FROM
t4
WHERE
Member_ID
=
paramMember
GROUP
BY
Track
);
RETURN
tracks
;
END
|
SELECT
bug21493
(
'111111'
)
|
SELECT
bug21493
(
'222222'
)
|
SELECT
bug21493
(
Member_ID
)
FROM
t3
|
DROP
FUNCTION
bug21493
|
DROP
TABLE
t3
,
t4
|
#
#
# BUG#NNNN: New bug synopsis
# BUG#NNNN: New bug synopsis
#
#
...
...
sql/sql_delete.cc
View file @
2ec485f0
...
@@ -342,6 +342,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
...
@@ -342,6 +342,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
*/
*/
bool
mysql_prepare_delete
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
Item
**
conds
)
bool
mysql_prepare_delete
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
Item
**
conds
)
{
{
Item
*
fake_conds
=
0
;
SELECT_LEX
*
select_lex
=
&
thd
->
lex
->
select_lex
;
SELECT_LEX
*
select_lex
=
&
thd
->
lex
->
select_lex
;
DBUG_ENTER
(
"mysql_prepare_delete"
);
DBUG_ENTER
(
"mysql_prepare_delete"
);
...
@@ -367,7 +368,7 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
...
@@ -367,7 +368,7 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
DBUG_RETURN
(
TRUE
);
DBUG_RETURN
(
TRUE
);
}
}
}
}
select_lex
->
fix_prepare_information
(
thd
,
conds
);
select_lex
->
fix_prepare_information
(
thd
,
conds
,
&
fake_conds
);
DBUG_RETURN
(
FALSE
);
DBUG_RETURN
(
FALSE
);
}
}
...
...
sql/sql_insert.cc
View file @
2ec485f0
...
@@ -1002,7 +1002,7 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
...
@@ -1002,7 +1002,7 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
update_non_unique_table_error
(
table_list
,
"INSERT"
,
duplicate
);
update_non_unique_table_error
(
table_list
,
"INSERT"
,
duplicate
);
DBUG_RETURN
(
TRUE
);
DBUG_RETURN
(
TRUE
);
}
}
select_lex
->
fix_prepare_information
(
thd
,
&
fake_conds
);
select_lex
->
fix_prepare_information
(
thd
,
&
fake_conds
,
&
fake_conds
);
select_lex
->
first_execution
=
0
;
select_lex
->
first_execution
=
0
;
}
}
if
(
duplic
==
DUP_UPDATE
||
duplic
==
DUP_REPLACE
)
if
(
duplic
==
DUP_UPDATE
||
duplic
==
DUP_REPLACE
)
...
...
sql/sql_lex.cc
View file @
2ec485f0
...
@@ -2158,15 +2158,25 @@ static void fix_prepare_info_in_table_list(THD *thd, TABLE_LIST *tbl)
...
@@ -2158,15 +2158,25 @@ static void fix_prepare_info_in_table_list(THD *thd, TABLE_LIST *tbl)
/*
/*
fix some structures at the end of preparation
Save WHERE/HAVING/ON clauses and replace them with disposable copies
SYNOPSIS
SYNOPSIS
st_select_lex::fix_prepare_information
st_select_lex::fix_prepare_information
thd thread handler
thd thread handler
conds pointer on conditions which will be used for execution statement
conds in/out pointer to WHERE condition to be met at execution
having_conds in/out pointer to HAVING condition to be met at execution
DESCRIPTION
The passed WHERE and HAVING are to be saved for the future executions.
This function saves it, and returns a copy which can be thrashed during
this execution of the statement. By saving/thrashing here we mean only
AND/OR trees.
The function also calls fix_prepare_info_in_table_list that saves all
ON expressions.
*/
*/
void
st_select_lex
::
fix_prepare_information
(
THD
*
thd
,
Item
**
conds
)
void
st_select_lex
::
fix_prepare_information
(
THD
*
thd
,
Item
**
conds
,
Item
**
having_conds
)
{
{
if
(
!
thd
->
stmt_arena
->
is_conventional
()
&&
first_execution
)
if
(
!
thd
->
stmt_arena
->
is_conventional
()
&&
first_execution
)
{
{
...
@@ -2176,6 +2186,11 @@ void st_select_lex::fix_prepare_information(THD *thd, Item **conds)
...
@@ -2176,6 +2186,11 @@ void st_select_lex::fix_prepare_information(THD *thd, Item **conds)
prep_where
=
*
conds
;
prep_where
=
*
conds
;
*
conds
=
where
=
prep_where
->
copy_andor_structure
(
thd
);
*
conds
=
where
=
prep_where
->
copy_andor_structure
(
thd
);
}
}
if
(
*
having_conds
)
{
prep_having
=
*
having_conds
;
*
having_conds
=
having
=
prep_having
->
copy_andor_structure
(
thd
);
}
fix_prepare_info_in_table_list
(
thd
,
(
TABLE_LIST
*
)
table_list
.
first
);
fix_prepare_info_in_table_list
(
thd
,
(
TABLE_LIST
*
)
table_list
.
first
);
}
}
}
}
...
...
sql/sql_lex.h
View file @
2ec485f0
...
@@ -656,7 +656,7 @@ class st_select_lex: public st_select_lex_node
...
@@ -656,7 +656,7 @@ class st_select_lex: public st_select_lex_node
void
print
(
THD
*
thd
,
String
*
str
);
void
print
(
THD
*
thd
,
String
*
str
);
static
void
print_order
(
String
*
str
,
ORDER
*
order
);
static
void
print_order
(
String
*
str
,
ORDER
*
order
);
void
print_limit
(
THD
*
thd
,
String
*
str
);
void
print_limit
(
THD
*
thd
,
String
*
str
);
void
fix_prepare_information
(
THD
*
thd
,
Item
**
conds
);
void
fix_prepare_information
(
THD
*
thd
,
Item
**
conds
,
Item
**
having_conds
);
/*
/*
Destroy the used execution plan (JOIN) of this subtree (this
Destroy the used execution plan (JOIN) of this subtree (this
SELECT_LEX and all nested SELECT_LEXes and SELECT_LEX_UNITs).
SELECT_LEX and all nested SELECT_LEXes and SELECT_LEX_UNITs).
...
...
sql/sql_select.cc
View file @
2ec485f0
...
@@ -382,12 +382,14 @@ JOIN::prepare(Item ***rref_pointer_array,
...
@@ -382,12 +382,14 @@ JOIN::prepare(Item ***rref_pointer_array,
if
((
res
=
subselect
->
select_transformer
(
this
))
!=
if
((
res
=
subselect
->
select_transformer
(
this
))
!=
Item_subselect
::
RES_OK
)
Item_subselect
::
RES_OK
)
{
{
select_lex
->
fix_prepare_information
(
thd
,
&
conds
);
select_lex
->
fix_prepare_information
(
thd
,
&
conds
,
&
having
);
DBUG_RETURN
((
res
==
Item_subselect
::
RES_ERROR
));
DBUG_RETURN
((
res
==
Item_subselect
::
RES_ERROR
));
}
}
}
}
}
}
select_lex
->
fix_prepare_information
(
thd
,
&
conds
,
&
having
);
if
(
having
&&
having
->
with_sum_func
)
if
(
having
&&
having
->
with_sum_func
)
having
->
split_sum_func2
(
thd
,
ref_pointer_array
,
all_fields
,
having
->
split_sum_func2
(
thd
,
ref_pointer_array
,
all_fields
,
&
having
,
TRUE
);
&
having
,
TRUE
);
...
@@ -499,7 +501,6 @@ JOIN::prepare(Item ***rref_pointer_array,
...
@@ -499,7 +501,6 @@ JOIN::prepare(Item ***rref_pointer_array,
if
(
alloc_func_list
())
if
(
alloc_func_list
())
goto
err
;
goto
err
;
select_lex
->
fix_prepare_information
(
thd
,
&
conds
);
DBUG_RETURN
(
0
);
// All OK
DBUG_RETURN
(
0
);
// All OK
err:
err:
...
@@ -618,7 +619,6 @@ JOIN::optimize()
...
@@ -618,7 +619,6 @@ JOIN::optimize()
build_bitmap_for_nested_joins
(
join_list
,
0
);
build_bitmap_for_nested_joins
(
join_list
,
0
);
sel
->
prep_where
=
conds
?
conds
->
copy_andor_structure
(
thd
)
:
0
;
sel
->
prep_where
=
conds
?
conds
->
copy_andor_structure
(
thd
)
:
0
;
sel
->
prep_having
=
having
?
having
->
copy_andor_structure
(
thd
)
:
0
;
if
(
arena
)
if
(
arena
)
thd
->
restore_active_arena
(
arena
,
&
backup
);
thd
->
restore_active_arena
(
arena
,
&
backup
);
...
...
sql/sql_update.cc
View file @
2ec485f0
...
@@ -606,6 +606,7 @@ int mysql_update(THD *thd,
...
@@ -606,6 +606,7 @@ int mysql_update(THD *thd,
bool
mysql_prepare_update
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
bool
mysql_prepare_update
(
THD
*
thd
,
TABLE_LIST
*
table_list
,
Item
**
conds
,
uint
order_num
,
ORDER
*
order
)
Item
**
conds
,
uint
order_num
,
ORDER
*
order
)
{
{
Item
*
fake_conds
=
0
;
TABLE
*
table
=
table_list
->
table
;
TABLE
*
table
=
table_list
->
table
;
TABLE_LIST
tables
;
TABLE_LIST
tables
;
List
<
Item
>
all_fields
;
List
<
Item
>
all_fields
;
...
@@ -645,7 +646,7 @@ bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
...
@@ -645,7 +646,7 @@ bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
DBUG_RETURN
(
TRUE
);
DBUG_RETURN
(
TRUE
);
}
}
}
}
select_lex
->
fix_prepare_information
(
thd
,
conds
);
select_lex
->
fix_prepare_information
(
thd
,
conds
,
&
fake_conds
);
DBUG_RETURN
(
FALSE
);
DBUG_RETURN
(
FALSE
);
}
}
...
...
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