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
6e71a819
Commit
6e71a819
authored
May 13, 2005
by
bell@book.sanja.is.com.ua
Browse files
Options
Browse Files
Download
Plain Diff
Merge book.sanja.is.com.ua:/Users/bell/mysql/bk/mysql-5.0
into book.sanja.is.com.ua:/Users/bell/mysql/bk/work-bug-5.0
parents
187ee471
e4fe89fa
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
130 additions
and
23 deletions
+130
-23
mysql-test/r/sp.result
mysql-test/r/sp.result
+25
-0
mysql-test/t/sp.test
mysql-test/t/sp.test
+29
-0
sql/item.cc
sql/item.cc
+7
-0
sql/item.h
sql/item.h
+12
-2
sql/sp_head.cc
sql/sp_head.cc
+42
-13
sql/sp_rcontext.cc
sql/sp_rcontext.cc
+3
-3
sql/sp_rcontext.h
sql/sp_rcontext.h
+9
-1
sql/sql_class.cc
sql/sql_class.cc
+3
-4
No files found.
mysql-test/r/sp.result
View file @
6e71a819
...
...
@@ -3073,4 +3073,29 @@ update v1 set data = 10|
call bug9841()|
drop view v1|
drop procedure bug9841|
drop procedure if exists bug5963|
create procedure bug5963_1 () begin declare v int; set v = (select s1 from t3); select v; end;|
create table t3 (s1 int)|
insert into t3 values (5)|
call bug5963_1()|
v
5
call bug5963_1()|
v
5
drop procedure bug5963_1|
drop table t3|
create procedure bug5963_2 (cfk_value int)
begin
if cfk_value in (select cpk from t3) then
set @x = 5;
end if;
end;
|
create table t3 (cpk int)|
insert into t3 values (1)|
call bug5963_2(1)|
call bug5963_2(1)|
drop procedure bug5963_2|
drop table t3|
drop table t1,t2;
mysql-test/t/sp.test
View file @
6e71a819
...
...
@@ -3772,6 +3772,35 @@ drop view v1|
drop
procedure
bug9841
|
#
# BUG#5963 subqueries in SET/IF
#
--
disable_warnings
drop
procedure
if
exists
bug5963
|
--
enable_warnings
create
procedure
bug5963_1
()
begin
declare
v
int
;
set
v
=
(
select
s1
from
t3
);
select
v
;
end
;
|
create
table
t3
(
s1
int
)
|
insert
into
t3
values
(
5
)
|
call
bug5963_1
()
|
call
bug5963_1
()
|
drop
procedure
bug5963_1
|
drop
table
t3
|
create
procedure
bug5963_2
(
cfk_value
int
)
begin
if
cfk_value
in
(
select
cpk
from
t3
)
then
set
@
x
=
5
;
end
if
;
end
;
|
create
table
t3
(
cpk
int
)
|
insert
into
t3
values
(
1
)
|
call
bug5963_2
(
1
)
|
call
bug5963_2
(
1
)
|
drop
procedure
bug5963_2
|
drop
table
t3
|
#
# BUG#NNNN: New bug synopsis
#
...
...
sql/item.cc
View file @
6e71a819
...
...
@@ -740,6 +740,13 @@ Item_splocal::this_item()
return
thd
->
spcont
->
get_item
(
m_offset
);
}
Item
**
Item_splocal
::
this_item_addr
(
THD
*
thd
,
Item
**
addr
)
{
return
thd
->
spcont
->
get_item_addr
(
m_offset
);
}
Item
*
Item_splocal
::
this_const_item
()
const
{
...
...
sql/item.h
View file @
6e71a819
...
...
@@ -525,8 +525,17 @@ class Item {
virtual
Item
*
equal_fields_propagator
(
byte
*
arg
)
{
return
this
;
}
virtual
Item
*
set_no_const_sub
(
byte
*
arg
)
{
return
this
;
}
virtual
Item
*
replace_equal_field
(
byte
*
arg
)
{
return
this
;
}
virtual
Item
*
this_item
()
{
return
this
;
}
/* For SPs mostly. */
/*
For SP local variable returns pointer to Item representing its
current value and pointer to current Item otherwise.
*/
virtual
Item
*
this_item
()
{
return
this
;
}
/*
For SP local variable returns address of pointer to Item representing its
current value and pointer passed via parameter otherwise.
*/
virtual
Item
**
this_item_addr
(
THD
*
thd
,
Item
**
addr
)
{
return
addr
;
}
virtual
Item
*
this_const_item
()
const
{
return
const_cast
<
Item
*>
(
this
);
}
/* For SPs mostly. */
// Row emulation
...
...
@@ -573,6 +582,7 @@ class Item_splocal : public Item
bool
is_splocal
()
{
return
1
;
}
/* Needed for error checking */
Item
*
this_item
();
Item
**
this_item_addr
(
THD
*
thd
,
Item
**
);
Item
*
this_const_item
()
const
;
bool
fix_fields
(
THD
*
,
struct
st_table_list
*
,
Item
**
);
...
...
sql/sp_head.cc
View file @
6e71a819
...
...
@@ -97,19 +97,48 @@ sp_multi_results_command(enum enum_sql_command cmd)
}
}
/*
Prepare Item for execution (call of fix_fields)
SYNOPSIS
sp_prepare_func_item()
thd thread handler
it_addr pointer on item refernce
RETURN
NULL error
prepared item
*/
static
Item
*
sp_prepare_func_item
(
THD
*
thd
,
Item
**
it_addr
)
{
Item
*
it
=
*
it_addr
;
DBUG_ENTER
(
"sp_prepare_func_item"
);
it_addr
=
it
->
this_item_addr
(
thd
,
it_addr
);
if
(
!
it
->
fixed
&&
(
*
it_addr
)
->
fix_fields
(
thd
,
0
,
it_addr
))
{
DBUG_PRINT
(
"info"
,
(
"fix_fields() failed"
));
DBUG_RETURN
(
NULL
);
}
DBUG_RETURN
(
*
it_addr
);
}
/* Evaluate a (presumed) func item. Always returns an item, the parameter
** if nothing else.
*/
Item
*
sp_eval_func_item
(
THD
*
thd
,
Item
*
it
,
enum
enum_field_types
type
)
sp_eval_func_item
(
THD
*
thd
,
Item
*
*
it_addr
,
enum
enum_field_types
type
)
{
DBUG_ENTER
(
"sp_eval_func_item"
);
it
=
it
->
this_item
(
);
Item
*
it
=
sp_prepare_func_item
(
thd
,
it_addr
);
DBUG_PRINT
(
"info"
,
(
"type: %d"
,
type
));
if
(
!
it
->
fixed
&&
it
->
fix_fields
(
thd
,
0
,
&
it
)
)
if
(
!
it
)
{
DBUG_PRINT
(
"info"
,
(
"fix_fields() failed"
));
DBUG_RETURN
(
NULL
);
}
...
...
@@ -679,7 +708,7 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp)
for
(
i
=
0
;
i
<
params
&&
i
<
argcount
;
i
++
)
{
sp_pvar_t
*
pvar
=
m_pcont
->
find_pvar
(
i
);
Item
*
it
=
sp_eval_func_item
(
thd
,
*
argp
++
,
pvar
->
type
);
Item
*
it
=
sp_eval_func_item
(
thd
,
argp
++
,
pvar
->
type
);
if
(
it
)
nctx
->
push_item
(
it
);
...
...
@@ -761,7 +790,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
{
Item_null
*
nit
=
NULL
;
// Re-use this, and only create if needed
uint
i
;
List_iterator
_fast
<
Item
>
li
(
*
args
);
List_iterator
<
Item
>
li
(
*
args
);
Item
*
it
;
nctx
=
new
sp_rcontext
(
csize
,
hmax
,
cmax
);
...
...
@@ -794,7 +823,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
}
else
{
Item
*
it2
=
sp_eval_func_item
(
thd
,
it
,
pvar
->
type
);
Item
*
it2
=
sp_eval_func_item
(
thd
,
li
.
ref
()
,
pvar
->
type
);
if
(
it2
)
nctx
->
push_item
(
it2
);
// IN or INOUT
...
...
@@ -1439,7 +1468,7 @@ sp_instr_set::exec_core(THD *thd, uint *nextp)
Item
*
it
;
int
res
;
it
=
sp_eval_func_item
(
thd
,
m_value
,
m_type
);
it
=
sp_eval_func_item
(
thd
,
&
m_value
,
m_type
);
if
(
!
it
)
res
=
-
1
;
else
...
...
@@ -1569,13 +1598,13 @@ sp_instr_jump_if::exec_core(THD *thd, uint *nextp)
Item
*
it
;
int
res
;
it
=
sp_
eval_func_item
(
thd
,
m_expr
,
MYSQL_TYPE_TINY
);
it
=
sp_
prepare_func_item
(
thd
,
&
m_expr
);
if
(
!
it
)
res
=
-
1
;
else
{
res
=
0
;
if
(
it
->
val_
int
())
if
(
it
->
val_
bool
())
*
nextp
=
m_dest
;
else
*
nextp
=
m_ip
+
1
;
...
...
@@ -1627,13 +1656,13 @@ sp_instr_jump_if_not::exec_core(THD *thd, uint *nextp)
Item
*
it
;
int
res
;
it
=
sp_
eval_func_item
(
thd
,
m_expr
,
MYSQL_TYPE_TINY
);
it
=
sp_
prepare_func_item
(
thd
,
&
m_expr
);
if
(
!
it
)
res
=
-
1
;
else
{
res
=
0
;
if
(
!
it
->
val_
int
())
if
(
!
it
->
val_
bool
())
*
nextp
=
m_dest
;
else
*
nextp
=
m_ip
+
1
;
...
...
@@ -1685,7 +1714,7 @@ sp_instr_freturn::exec_core(THD *thd, uint *nextp)
Item
*
it
;
int
res
;
it
=
sp_eval_func_item
(
thd
,
m_value
,
m_type
);
it
=
sp_eval_func_item
(
thd
,
&
m_value
,
m_type
);
if
(
!
it
)
res
=
-
1
;
else
...
...
sql/sp_rcontext.cc
View file @
6e71a819
...
...
@@ -41,10 +41,10 @@ sp_rcontext::sp_rcontext(uint fsize, uint hmax, uint cmax)
}
int
sp_rcontext
::
set_item_eval
(
uint
idx
,
Item
*
i
,
enum_field_types
type
)
sp_rcontext
::
set_item_eval
(
uint
idx
,
Item
*
*
item_addr
,
enum_field_types
type
)
{
extern
Item
*
sp_eval_func_item
(
THD
*
thd
,
Item
*
it
,
enum_field_types
type
);
Item
*
it
=
sp_eval_func_item
(
current_thd
,
i
,
type
);
extern
Item
*
sp_eval_func_item
(
THD
*
thd
,
Item
*
*
it
,
enum_field_types
type
);
Item
*
it
=
sp_eval_func_item
(
current_thd
,
i
tem_addr
,
type
);
if
(
!
it
)
return
-
1
;
...
...
sql/sp_rcontext.h
View file @
6e71a819
...
...
@@ -74,7 +74,7 @@ class sp_rcontext : public Sql_alloc
/* Returns 0 on success, -1 on (eval) failure */
int
set_item_eval
(
uint
idx
,
Item
*
i
,
enum_field_types
type
);
set_item_eval
(
uint
idx
,
Item
*
*
i
,
enum_field_types
type
);
inline
Item
*
get_item
(
uint
idx
)
...
...
@@ -82,6 +82,14 @@ class sp_rcontext : public Sql_alloc
return
m_frame
[
idx
];
}
inline
Item
**
get_item_addr
(
uint
idx
)
{
return
m_frame
+
idx
;
}
inline
void
set_result
(
Item
*
it
)
{
...
...
sql/sql_class.cc
View file @
6e71a819
...
...
@@ -1719,10 +1719,9 @@ bool select_dumpvar::send_data(List<Item> &items)
List_iterator_fast
<
Item_func_set_user_var
>
li
(
vars
);
List_iterator_fast
<
Item_splocal
>
var_li
(
local_vars
);
List_iterator_fast
<
my_var
>
my_li
(
var_list
);
List_iterator
_fast
<
Item
>
it
(
items
);
List_iterator
<
Item
>
it
(
items
);
Item_func_set_user_var
*
xx
;
Item_splocal
*
yy
;
Item
*
item
;
my_var
*
zz
;
DBUG_ENTER
(
"send_data"
);
if
(
unit
->
offset_limit_cnt
)
...
...
@@ -1741,13 +1740,13 @@ bool select_dumpvar::send_data(List<Item> &items)
my_message
(
ER_TOO_MANY_ROWS
,
ER
(
ER_TOO_MANY_ROWS
),
MYF
(
0
));
DBUG_RETURN
(
1
);
}
while
((
zz
=
my_li
++
)
&&
(
it
em
=
it
++
))
while
((
zz
=
my_li
++
)
&&
(
it
++
))
{
if
(
zz
->
local
)
{
if
((
yy
=
var_li
++
))
{
if
(
thd
->
spcont
->
set_item_eval
(
yy
->
get_offset
(),
it
em
,
zz
->
type
))
if
(
thd
->
spcont
->
set_item_eval
(
yy
->
get_offset
(),
it
.
ref
()
,
zz
->
type
))
DBUG_RETURN
(
1
);
}
}
...
...
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