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
16744e2e
Commit
16744e2e
authored
Oct 29, 2007
by
ramil/ram@ramil.myoffice.izhnet.ru
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/home/ram/work/mysql-5.0-maint
into mysql.com:/home/ram/work/b30782/b30782.5.0
parents
3494f691
98a4d999
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
9 deletions
+70
-9
mysql-test/r/case.result
mysql-test/r/case.result
+19
-1
mysql-test/t/case.test
mysql-test/t/case.test
+19
-2
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+30
-6
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+2
-0
No files found.
mysql-test/r/case.result
View file @
16744e2e
drop table if exists t1;
drop table if exists t1
, t2
;
select CASE "b" when "a" then 1 when "b" then 2 END;
CASE "b" when "a" then 1 when "b" then 2 END
2
...
...
@@ -200,3 +200,21 @@ CEMPNUM EMPMUM1 EMPNUM2
0.00 0 0.00
2.00 2 NULL
DROP TABLE t1,t2;
End of 4.1 tests
create table t1 (a int, b bigint unsigned);
create table t2 (c int);
insert into t1 (a, b) values (1,4572794622775114594), (2,18196094287899841997),
(3,11120436154190595086);
insert into t2 (c) values (1), (2), (3);
select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1
join t2 on t1.a=t2.c order by d;
a d
1 4572794622775114594
3 11120436154190595086
2 18196094287899841997
select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1
join t2 on t1.a=t2.c where b=11120436154190595086 order by d;
a d
3 11120436154190595086
drop table t1, t2;
End of 5.0 tests
mysql-test/t/case.test
View file @
16744e2e
...
...
@@ -3,7 +3,7 @@
#
--
disable_warnings
drop
table
if
exists
t1
;
drop
table
if
exists
t1
,
t2
;
--
enable_warnings
select
CASE
"b"
when
"a"
then
1
when
"b"
then
2
END
;
...
...
@@ -152,4 +152,21 @@ SELECT IFNULL(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
FROM
t1
LEFT
JOIN
t2
ON
t1
.
EMPNUM
=
t2
.
EMPNUM
;
DROP
TABLE
t1
,
t2
;
# End of 4.1 tests
--
echo
End
of
4.1
tests
#
# #30782: Truncated UNSIGNED BIGINT columns
#
create
table
t1
(
a
int
,
b
bigint
unsigned
);
create
table
t2
(
c
int
);
insert
into
t1
(
a
,
b
)
values
(
1
,
4572794622775114594
),
(
2
,
18196094287899841997
),
(
3
,
11120436154190595086
);
insert
into
t2
(
c
)
values
(
1
),
(
2
),
(
3
);
select
t1
.
a
,
(
case
t1
.
a
when
0
then
0
else
t1
.
b
end
)
d
from
t1
join
t2
on
t1
.
a
=
t2
.
c
order
by
d
;
select
t1
.
a
,
(
case
t1
.
a
when
0
then
0
else
t1
.
b
end
)
d
from
t1
join
t2
on
t1
.
a
=
t2
.
c
where
b
=
11120436154190595086
order
by
d
;
drop
table
t1
,
t2
;
--
echo
End
of
5.0
tests
sql/item_cmpfunc.cc
View file @
16744e2e
...
...
@@ -2530,6 +2530,23 @@ bool Item_func_case::fix_fields(THD *thd, Item **ref)
}
void
Item_func_case
::
agg_str_lengths
(
Item
*
arg
)
{
set_if_bigger
(
max_length
,
arg
->
max_length
);
set_if_bigger
(
decimals
,
arg
->
decimals
);
unsigned_flag
=
unsigned_flag
&&
arg
->
unsigned_flag
;
}
void
Item_func_case
::
agg_num_lengths
(
Item
*
arg
)
{
uint
len
=
my_decimal_length_to_precision
(
arg
->
max_length
,
arg
->
decimals
,
arg
->
unsigned_flag
)
-
arg
->
decimals
;
set_if_bigger
(
max_length
,
len
);
set_if_bigger
(
decimals
,
arg
->
decimals
);
unsigned_flag
=
unsigned_flag
&&
arg
->
unsigned_flag
;
}
void
Item_func_case
::
fix_length_and_dec
()
{
...
...
@@ -2579,15 +2596,22 @@ void Item_func_case::fix_length_and_dec()
max_length
=
0
;
decimals
=
0
;
for
(
uint
i
=
0
;
i
<
ncases
;
i
+=
2
)
unsigned_flag
=
TRUE
;
if
(
cached_result_type
==
STRING_RESULT
)
{
set_if_bigger
(
max_length
,
args
[
i
+
1
]
->
max_length
);
set_if_bigger
(
decimals
,
args
[
i
+
1
]
->
decimals
);
for
(
uint
i
=
0
;
i
<
ncases
;
i
+=
2
)
agg_str_lengths
(
args
[
i
+
1
]);
if
(
else_expr_num
!=
-
1
)
agg_str_lengths
(
args
[
else_expr_num
]);
}
if
(
else_expr_num
!=
-
1
)
else
{
set_if_bigger
(
max_length
,
args
[
else_expr_num
]
->
max_length
);
set_if_bigger
(
decimals
,
args
[
else_expr_num
]
->
decimals
);
for
(
uint
i
=
0
;
i
<
ncases
;
i
+=
2
)
agg_num_lengths
(
args
[
i
+
1
]);
if
(
else_expr_num
!=
-
1
)
agg_num_lengths
(
args
[
else_expr_num
]);
max_length
=
my_decimal_precision_to_length
(
max_length
+
decimals
,
decimals
,
unsigned_flag
);
}
}
...
...
sql/item_cmpfunc.h
View file @
16744e2e
...
...
@@ -753,6 +753,8 @@ public:
void
print
(
String
*
str
);
Item
*
find_item
(
String
*
str
);
CHARSET_INFO
*
compare_collation
()
{
return
cmp_collation
.
collation
;
}
void
agg_str_lengths
(
Item
*
arg
);
void
agg_num_lengths
(
Item
*
arg
);
};
...
...
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