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
102bfc9e
Commit
102bfc9e
authored
Jul 17, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CASE now aggregates all argument types instead of using the only one argument
parent
8283a01f
Changes
2
Hide 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 @
102bfc9e
...
@@ -892,13 +892,7 @@ Item *Item_func_case::find_item(String *str)
...
@@ -892,13 +892,7 @@ Item *Item_func_case::find_item(String *str)
}
}
if
((
tmp
=
args
[
i
]
->
val_str
(
str
)))
// If not null
if
((
tmp
=
args
[
i
]
->
val_str
(
str
)))
// If not null
{
{
/* QQ: COERCIBILITY */
if
(
sortcmp
(
tmp
,
first_expr_str
,
&
my_charset_bin
)
==
0
)
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
];
return
args
[
i
+
1
];
}
}
break
;
break
;
...
@@ -988,14 +982,62 @@ double Item_func_case::val()
...
@@ -988,14 +982,62 @@ double Item_func_case::val()
return
res
;
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
()
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
)
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
)
if
(
!
else_expr_num
!=
-
1
||
args
[
else_expr_num
]
->
maybe_null
)
maybe_null
=
1
;
maybe_null
=
1
;
max_length
=
0
;
max_length
=
0
;
decimals
=
0
;
decimals
=
0
;
cached_result_type
=
args
[
1
]
->
result_type
();
cached_result_type
=
args
[
1
]
->
result_type
();
...
...
sql/item_cmpfunc.h
View file @
102bfc9e
...
@@ -351,8 +351,9 @@ class Item_func_case :public Item_func
...
@@ -351,8 +351,9 @@ class Item_func_case :public Item_func
int
first_expr_num
,
else_expr_num
;
int
first_expr_num
,
else_expr_num
;
enum
Item_result
cached_result_type
;
enum
Item_result
cached_result_type
;
String
tmp_value
;
String
tmp_value
;
bool
first_expr_is_binary
;
uint
ncases
;
uint
ncases
;
Item_result
cmp_type
;
DTCollation
cmp_collation
;
public:
public:
Item_func_case
(
List
<
Item
>
&
list
,
Item
*
first_expr_arg
,
Item
*
else_expr_arg
)
Item_func_case
(
List
<
Item
>
&
list
,
Item
*
first_expr_arg
,
Item
*
else_expr_arg
)
:
Item_func
(),
first_expr_num
(
-
1
),
else_expr_num
(
-
1
),
:
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