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
c8ecb452
Commit
c8ecb452
authored
Jul 18, 2003
by
bar@bar.mysql.r18.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CASE optimization
parent
ccece982
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
28 deletions
+30
-28
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+30
-28
No files found.
sql/item_cmpfunc.cc
View file @
c8ecb452
...
...
@@ -863,58 +863,60 @@ Item *Item_func_case::find_item(String *str)
String
*
first_expr_str
,
*
tmp
;
longlong
first_expr_int
;
double
first_expr_real
;
bool
int_used
,
real_used
,
str_used
;
int_used
=
real_used
=
str_used
=
0
;
/* These will be initialized later */
LINT_INIT
(
first_expr_str
);
LINT_INIT
(
first_expr_int
);
LINT_INIT
(
first_expr_real
);
if
(
first_expr_num
!=
-
1
)
{
switch
(
cmp_type
)
{
case
STRING_RESULT
:
// We can't use 'str' here as this may be overwritten
if
(
!
(
first_expr_str
=
args
[
first_expr_num
]
->
val_str
(
&
str_value
)))
return
else_expr_num
!=
-
1
?
args
[
else_expr_num
]
:
0
;
// Impossible
break
;
case
INT_RESULT
:
first_expr_int
=
args
[
first_expr_num
]
->
val_int
();
if
(
args
[
first_expr_num
]
->
null_value
)
return
else_expr_num
!=
-
1
?
args
[
else_expr_num
]
:
0
;
break
;
case
REAL_RESULT
:
first_expr_real
=
args
[
first_expr_num
]
->
val
();
if
(
args
[
first_expr_num
]
->
null_value
)
return
else_expr_num
!=
-
1
?
args
[
else_expr_num
]
:
0
;
break
;
case
ROW_RESULT
:
default:
// This case should never be choosen
DBUG_ASSERT
(
0
);
break
;
}
}
// Compare every WHEN argument with it and return the first match
for
(
uint
i
=
0
;
i
<
ncases
;
i
+=
2
)
{
if
(
first_expr_num
==
-
1
)
{
// No expression between CASE and first WHEN
// No expression between CASE and
the
first WHEN
if
(
args
[
i
]
->
val_int
())
return
args
[
i
+
1
];
continue
;
}
switch
(
args
[
i
]
->
result_type
()
)
{
switch
(
cmp_type
)
{
case
STRING_RESULT
:
if
(
!
str_used
)
{
str_used
=
1
;
// We can't use 'str' here as this may be overwritten
if
(
!
(
first_expr_str
=
args
[
first_expr_num
]
->
val_str
(
&
str_value
)))
return
else_expr_num
!=
-
1
?
args
[
else_expr_num
]
:
0
;
// Impossible
}
if
((
tmp
=
args
[
i
]
->
val_str
(
str
)))
// If not null
{
if
(
sortcmp
(
tmp
,
first_expr_str
,
cmp_collation
.
collation
)
==
0
)
return
args
[
i
+
1
];
}
break
;
case
INT_RESULT
:
if
(
!
int_used
)
{
int_used
=
1
;
first_expr_int
=
args
[
first_expr_num
]
->
val_int
();
if
(
args
[
first_expr_num
]
->
null_value
)
return
else_expr_num
!=
-
1
?
args
[
else_expr_num
]
:
0
;
}
if
(
args
[
i
]
->
val_int
()
==
first_expr_int
&&
!
args
[
i
]
->
null_value
)
return
args
[
i
+
1
];
break
;
case
REAL_RESULT
:
if
(
!
real_used
)
{
real_used
=
1
;
first_expr_real
=
args
[
first_expr_num
]
->
val
();
if
(
args
[
first_expr_num
]
->
null_value
)
return
else_expr_num
!=
-
1
?
args
[
else_expr_num
]
:
0
;
}
if
(
args
[
i
]
->
val
()
==
first_expr_real
&&
!
args
[
i
]
->
null_value
)
return
args
[
i
+
1
];
break
;
...
...
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