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
5e824aeb
Commit
5e824aeb
authored
Jul 03, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIELD() now takes in account arguments collations
parent
a584a021
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
15 deletions
+89
-15
mysql-test/r/func_str.result
mysql-test/r/func_str.result
+19
-0
mysql-test/t/func_str.test
mysql-test/t/func_str.test
+13
-0
sql/item_func.cc
sql/item_func.cc
+54
-8
sql/item_func.h
sql/item_func.h
+3
-7
No files found.
mysql-test/r/func_str.result
View file @
5e824aeb
...
...
@@ -278,6 +278,25 @@ row('A','b','c') = row('a' COLLATE latin1_bin,'b','c')
0
select row('A' COLLATE latin1_general_ci,'b','c') = row('a' COLLATE latin1_bin,'b','c');
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation '='
select FIELD('b','A','B');
FIELD('b','A','B')
2
select FIELD('B','A','B');
FIELD('B','A','B')
2
select FIELD('b' COLLATE latin1_bin,'A','B');
FIELD('b' COLLATE latin1_bin,'A','B')
0
select FIELD('b','A' COLLATE latin1_bin,'B');
FIELD('b','A' COLLATE latin1_bin,'B')
0
select FIELD(_latin2'b','A','B');
ERROR HY000: Illegal mix of collations for operation 'field'
select FIELD('b',_latin2'A','B');
ERROR HY000: Illegal mix of collations for operation 'field'
select FIELD('b',_latin2'A','B',1);
FIELD('b',_latin2'A','B',1)
1
select POSITION(_latin1'B' IN _latin1'abcd');
POSITION(_latin1'B' IN _latin1'abcd')
2
...
...
mysql-test/t/func_str.test
View file @
5e824aeb
...
...
@@ -152,6 +152,19 @@ select row('A','b','c') = row('a' COLLATE latin1_bin,'b','c');
--
error
1265
select
row
(
'A'
COLLATE
latin1_general_ci
,
'b'
,
'c'
)
=
row
(
'a'
COLLATE
latin1_bin
,
'b'
,
'c'
);
#
# Test FIELD() and collations
#
select
FIELD
(
'b'
,
'A'
,
'B'
);
select
FIELD
(
'B'
,
'A'
,
'B'
);
select
FIELD
(
'b'
COLLATE
latin1_bin
,
'A'
,
'B'
);
select
FIELD
(
'b'
,
'A'
COLLATE
latin1_bin
,
'B'
);
--
error
1269
select
FIELD
(
_latin2
'b'
,
'A'
,
'B'
);
--
error
1269
select
FIELD
(
'b'
,
_latin2
'A'
,
'B'
);
select
FIELD
(
'b'
,
_latin2
'A'
,
'B'
,
1
);
select
POSITION
(
_latin1
'B'
IN
_latin1
'abcd'
);
select
POSITION
(
_latin1
'B'
IN
_latin1
'abcd'
COLLATE
latin1_bin
);
...
...
sql/item_func.cc
View file @
5e824aeb
...
...
@@ -1118,6 +1118,8 @@ longlong Item_func_locate::val_int()
longlong
Item_func_field
::
val_int
()
{
if
(
cmp_type
==
STRING_RESULT
)
{
String
*
field
;
if
(
!
(
field
=
item
->
val_str
(
&
value
)))
return
0
;
// -1 if null ?
...
...
@@ -1125,12 +1127,56 @@ longlong Item_func_field::val_int()
{
String
*
tmp_value
=
args
[
i
]
->
val_str
(
&
tmp
);
if
(
tmp_value
&&
field
->
length
()
==
tmp_value
->
length
()
&&
!
memcmp
(
field
->
ptr
(),
tmp_value
->
ptr
(),
tmp_value
->
length
()))
!
sortcmp
(
field
,
tmp_value
,
cmp_collation
.
collation
))
return
(
longlong
)
(
i
+
1
);
}
}
else
if
(
cmp_type
==
INT_RESULT
)
{
longlong
val
=
item
->
val_int
();
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
{
if
(
val
==
args
[
i
]
->
val_int
())
return
(
longlong
)
(
i
+
1
);
}
}
else
{
double
val
=
item
->
val
();
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
{
if
(
val
==
args
[
i
]
->
val
())
return
(
longlong
)
(
i
+
1
);
}
}
return
0
;
}
void
Item_func_field
::
fix_length_and_dec
()
{
maybe_null
=
0
;
max_length
=
3
;
used_tables_cache
|=
item
->
used_tables
();
const_item_cache
&=
item
->
const_item
();
with_sum_func
=
with_sum_func
||
item
->
with_sum_func
;
cmp_type
=
item
->
result_type
();
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
cmp_type
=
item_cmp_type
(
cmp_type
,
args
[
i
]
->
result_type
());
if
(
cmp_type
==
STRING_RESULT
)
{
cmp_collation
.
set
(
item
->
collation
);
for
(
uint
i
=
0
;
i
<
arg_count
;
i
++
)
{
if
(
cmp_collation
.
aggregate
(
args
[
i
]
->
collation
))
{
my_error
(
ER_CANT_AGGREGATE_NCOLLATIONS
,
MYF
(
0
),
func_name
());
return
;
}
}
}
}
void
Item_func_field
::
split_sum_func
(
Item
**
ref_pointer_array
,
List
<
Item
>
&
fields
)
...
...
sql/item_func.h
View file @
5e824aeb
...
...
@@ -624,6 +624,8 @@ class Item_func_field :public Item_int_func
{
Item
*
item
;
String
value
,
tmp
;
Item_result
cmp_type
;
DTCollation
cmp_collation
;
public:
Item_func_field
(
Item
*
a
,
List
<
Item
>
&
list
)
:
Item_int_func
(
list
),
item
(
a
)
{}
~
Item_func_field
()
{
delete
item
;
}
...
...
@@ -641,13 +643,7 @@ class Item_func_field :public Item_int_func
const_item_cache
&=
item
->
const_item
();
}
const
char
*
func_name
()
const
{
return
"field"
;
}
void
fix_length_and_dec
()
{
maybe_null
=
0
;
max_length
=
3
;
used_tables_cache
|=
item
->
used_tables
();
const_item_cache
&=
item
->
const_item
();
with_sum_func
=
with_sum_func
||
item
->
with_sum_func
;
}
void
fix_length_and_dec
();
void
set_outer_resolving
()
{
item
->
set_outer_resolving
();
...
...
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