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
89bb56cd
Commit
89bb56cd
authored
Nov 17, 2007
by
istruewing@stella.local
Browse files
Options
Browse Files
Download
Plain Diff
Merge stella.local:/home2/mydev/mysql-5.1-ateam
into stella.local:/home2/mydev/mysql-5.1-axmrg
parents
fffe7f41
11115f1b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
1 deletion
+34
-1
mysql-test/r/user_var.result
mysql-test/r/user_var.result
+11
-0
mysql-test/t/user_var.test
mysql-test/t/user_var.test
+21
-0
sql/item_func.cc
sql/item_func.cc
+2
-1
No files found.
mysql-test/r/user_var.result
View file @
89bb56cd
...
@@ -353,3 +353,14 @@ select @a:=f4, count(f4) from t1 group by 1 desc;
...
@@ -353,3 +353,14 @@ select @a:=f4, count(f4) from t1 group by 1 desc;
2.6 1
2.6 1
1.6 4
1.6 4
drop table t1;
drop table t1;
create table t1(a int);
insert into t1 values(5),(4),(4),(3),(2),(2),(2),(1);
set @rownum := 0;
set @rank := 0;
set @prev_score := NULL;
select @rownum := @rownum + 1 as row,
@rank := IF(@prev_score!=a, @rownum, @rank) as rank,
@prev_score := a as score
from t1 order by score desc;
drop table t1;
End of 5.1 tests
mysql-test/t/user_var.test
View file @
89bb56cd
...
@@ -237,3 +237,24 @@ select @a:=f2, count(f2) from t1 group by 1 desc;
...
@@ -237,3 +237,24 @@ select @a:=f2, count(f2) from t1 group by 1 desc;
select
@
a
:=
f3
,
count
(
f3
)
from
t1
group
by
1
desc
;
select
@
a
:=
f3
,
count
(
f3
)
from
t1
group
by
1
desc
;
select
@
a
:=
f4
,
count
(
f4
)
from
t1
group
by
1
desc
;
select
@
a
:=
f4
,
count
(
f4
)
from
t1
group
by
1
desc
;
drop
table
t1
;
drop
table
t1
;
#
# Bug #32260: User variables in query cause server crash
#
create
table
t1
(
a
int
);
insert
into
t1
values
(
5
),(
4
),(
4
),(
3
),(
2
),(
2
),(
2
),(
1
);
set
@
rownum
:=
0
;
set
@
rank
:=
0
;
set
@
prev_score
:=
NULL
;
# Disable the result log as we assign a value to a user variable in one part
# of a statement and use the same variable in other part of the same statement,
# so we can get unexpected results.
--
disable_result_log
select
@
rownum
:=
@
rownum
+
1
as
row
,
@
rank
:=
IF
(
@
prev_score
!=
a
,
@
rownum
,
@
rank
)
as
rank
,
@
prev_score
:=
a
as
score
from
t1
order
by
score
desc
;
--
enable_result_log
drop
table
t1
;
--
echo
End
of
5.1
tests
sql/item_func.cc
View file @
89bb56cd
...
@@ -3843,7 +3843,8 @@ Item_func_set_user_var::fix_length_and_dec()
...
@@ -3843,7 +3843,8 @@ Item_func_set_user_var::fix_length_and_dec()
bool
Item_func_set_user_var
::
register_field_in_read_map
(
uchar
*
arg
)
bool
Item_func_set_user_var
::
register_field_in_read_map
(
uchar
*
arg
)
{
{
TABLE
*
table
=
(
TABLE
*
)
arg
;
TABLE
*
table
=
(
TABLE
*
)
arg
;
if
(
result_field
->
table
==
table
||
!
table
)
if
(
result_field
&&
(
!
table
||
result_field
->
table
==
table
))
bitmap_set_bit
(
result_field
->
table
->
read_set
,
result_field
->
field_index
);
bitmap_set_bit
(
result_field
->
table
->
read_set
,
result_field
->
field_index
);
return
0
;
return
0
;
}
}
...
...
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