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
a2f7ef9c
Commit
a2f7ef9c
authored
Jul 17, 2003
by
bar@bar.mysql.r18.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CASE now aggregates all argument types instead of using the only one argument
parent
8cffa7b2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
10 deletions
+53
-10
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+51
-9
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+2
-1
No files found.
sql/item_cmpfunc.cc
View file @
a2f7ef9c
...
...
@@ -891,16 +891,10 @@ Item *Item_func_case::find_item(String *str)
return
else_expr_num
!=
-
1
?
args
[
else_expr_num
]
:
0
;
// Impossible
}
if
((
tmp
=
args
[
i
]
->
val_str
(
str
)))
// If not null
{
/* QQ: COERCIBILITY */
if
(
first_expr_is_binary
||
(
args
[
i
]
->
charset
()
->
state
&
MY_CS_BINSORT
))
{
if
(
sortcmp
(
tmp
,
first_expr_str
,
&
my_charset_bin
)
==
0
)
return
args
[
i
+
1
];
}
else
if
(
sortcmp
(
tmp
,
first_expr_str
,
tmp
->
charset
())
==
0
)
return
args
[
i
+
1
];
}
break
;
case
INT_RESULT
:
if
(
!
int_used
)
...
...
@@ -988,11 +982,59 @@ double Item_func_case::val()
return
res
;
}
static
void
agg_result_type
(
Item_result
*
type
,
Item
**
items
,
uint
nitems
)
{
uint
i
;
type
[
0
]
=
items
[
0
]
->
result_type
();
for
(
i
=
1
;
i
<
nitems
;
i
++
)
type
[
0
]
=
item_store_type
(
type
[
0
],
items
[
i
]
->
result_type
());
}
static
void
agg_cmp_type
(
Item_result
*
type
,
Item
**
items
,
uint
nitems
)
{
uint
i
;
type
[
0
]
=
items
[
0
]
->
result_type
();
for
(
i
=
1
;
i
<
nitems
;
i
++
)
type
[
0
]
=
item_cmp_type
(
type
[
0
],
items
[
i
]
->
result_type
());
}
void
Item_func_case
::
fix_length_and_dec
()
{
Item
**
agg
;
uint
nagg
;
if
(
!
(
agg
=
(
Item
**
)
sql_alloc
(
sizeof
(
Item
*
)
*
(
ncases
+
1
))))
return
;
// Aggregate all THEN and ELSE expression types
// and collations when string result
for
(
nagg
=
0
;
nagg
<
ncases
/
2
;
nagg
++
)
agg
[
nagg
]
=
args
[
nagg
*
2
+
1
];
if
(
else_expr_num
!=
-
1
)
agg
[
nagg
++
]
=
args
[
else_expr_num
];
agg_result_type
(
&
cached_result_type
,
agg
,
nagg
);
if
((
cached_result_type
==
STRING_RESULT
)
&&
agg_arg_collations
(
collation
,
agg
,
nagg
))
return
;
// Aggregate first expression and all THEN expression types
// and collations when string comparison
if
(
first_expr_num
!=
-
1
)
first_expr_is_binary
=
args
[
first_expr_num
]
->
charset
()
->
state
&
MY_CS_BINSORT
;
{
agg
[
0
]
=
args
[
first_expr_num
];
for
(
nagg
=
0
;
nagg
<
ncases
/
2
;
nagg
++
)
agg
[
nagg
+
1
]
=
args
[
nagg
];
nagg
++
;
agg_cmp_type
(
&
cmp_type
,
agg
,
nagg
);
if
((
cmp_type
==
STRING_RESULT
)
&&
agg_arg_collations_for_comparison
(
cmp_collation
,
agg
,
nagg
))
return
;
}
if
(
!
else_expr_num
!=
-
1
||
args
[
else_expr_num
]
->
maybe_null
)
maybe_null
=
1
;
...
...
sql/item_cmpfunc.h
View file @
a2f7ef9c
...
...
@@ -351,8 +351,9 @@ class Item_func_case :public Item_func
int
first_expr_num
,
else_expr_num
;
enum
Item_result
cached_result_type
;
String
tmp_value
;
bool
first_expr_is_binary
;
uint
ncases
;
Item_result
cmp_type
;
DTCollation
cmp_collation
;
public:
Item_func_case
(
List
<
Item
>
&
list
,
Item
*
first_expr_arg
,
Item
*
else_expr_arg
)
:
Item_func
(),
first_expr_num
(
-
1
),
else_expr_num
(
-
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