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
69af692a
Commit
69af692a
authored
Jun 19, 2003
by
bar@bar.mysql.r18.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
These functions now return a result of proper collation:
BIN OCT CONV HEX CHAR FORMAT REPLACE
parent
a7f584da
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
8 deletions
+86
-8
mysql-test/r/func_str.result
mysql-test/r/func_str.result
+39
-2
mysql-test/t/func_str.test
mysql-test/t/func_str.test
+15
-2
sql/item.cc
sql/item.cc
+1
-1
sql/item_strfunc.cc
sql/item_strfunc.cc
+15
-0
sql/item_strfunc.h
sql/item_strfunc.h
+16
-3
No files found.
mysql-test/r/func_str.result
View file @
69af692a
...
...
@@ -249,6 +249,24 @@ INSERT INTO t1 VALUES (1, 'a545f661efdd1fb66fdee3aab79945bf');
SELECT 1 FROM t1 WHERE tmp=AES_DECRYPT(tmp,"password");
1
DROP TABLE t1;
select collation(bin(130)), coercibility(bin(130));
collation(bin(130)) coercibility(bin(130))
latin1_swedish_ci 3
select collation(oct(130)), coercibility(oct(130));
collation(oct(130)) coercibility(oct(130))
latin1_swedish_ci 3
select collation(conv(130,16,10)), coercibility(conv(130,16,10));
collation(conv(130,16,10)) coercibility(conv(130,16,10))
latin1_swedish_ci 3
select collation(hex(130)), coercibility(hex(130));
collation(hex(130)) coercibility(hex(130))
latin1_swedish_ci 3
select collation(char(130)), coercibility(hex(130));
collation(char(130)) coercibility(hex(130))
binary 3
select collation(format(130,10)), coercibility(format(130,10));
collation(format(130,10)) coercibility(format(130,10))
latin1_swedish_ci 3
select collation(lcase(_latin2'a')), coercibility(lcase(_latin2'a'));
collation(lcase(_latin2'a')) coercibility(lcase(_latin2'a'))
latin2_general_ci 3
...
...
@@ -306,8 +324,17 @@ latin2_general_ci 3
select collation(insert(_latin2'abcd',2,3,_latin2'ef')), coercibility(insert(_latin2'abcd',2,3,_latin2'ef'));
collation(insert(_latin2'abcd',2,3,_latin2'ef')) coercibility(insert(_latin2'abcd',2,3,_latin2'ef'))
latin2_general_ci 3
select collation(replace(_latin2'abcd',_latin2'b',_latin2'B')), coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B'));
collation(replace(_latin2'abcd',_latin2'b',_latin2'B')) coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B'))
latin2_general_ci 3
create table t1
select
bin(130),
oct(130),
conv(130,16,10),
hex(130),
char(130),
format(130,10),
left(_latin2'a',1),
right(_latin2'a',1),
lcase(_latin2'a'),
...
...
@@ -326,11 +353,20 @@ reverse(_latin2'ab'),
quote(_latin2'ab'),
soundex(_latin2'ab'),
substring(_latin2'ab',1),
insert(_latin2'abcd',2,3,_latin2'ef')
insert(_latin2'abcd',2,3,_latin2'ef'),
replace(_latin2'abcd',_latin2'b',_latin2'B')
;
Warnings:
Warning 1263 Data truncated for column 'format(130,10)' at row 1
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`bin(130)` char(64) NOT NULL default '',
`oct(130)` char(64) NOT NULL default '',
`conv(130,16,10)` char(64) NOT NULL default '',
`hex(130)` char(6) NOT NULL default '',
`char(130)` char(1) NOT NULL default '',
`format(130,10)` char(4) NOT NULL default '',
`left(_latin2'a',1)` char(1) character set latin2 NOT NULL default '',
`right(_latin2'a',1)` char(1) character set latin2 NOT NULL default '',
`lcase(_latin2'a')` char(1) character set latin2 NOT NULL default '',
...
...
@@ -349,6 +385,7 @@ t1 CREATE TABLE `t1` (
`quote(_latin2'ab')` char(6) character set latin2 NOT NULL default '',
`soundex(_latin2'ab')` char(4) character set latin2 NOT NULL default '',
`substring(_latin2'ab',1)` char(2) character set latin2 NOT NULL default '',
`insert(_latin2'abcd',2,3,_latin2'ef')` char(6) character set latin2 NOT NULL default ''
`insert(_latin2'abcd',2,3,_latin2'ef')` char(6) character set latin2 NOT NULL default '',
`replace(_latin2'abcd',_latin2'b',_latin2'B')` char(4) character set latin2 NOT NULL default ''
) TYPE=MyISAM CHARSET=latin1
drop table t1;
mysql-test/t/func_str.test
View file @
69af692a
...
...
@@ -136,6 +136,12 @@ DROP TABLE t1;
#
# Test collation and coercibility
#
select
collation
(
bin
(
130
)),
coercibility
(
bin
(
130
));
select
collation
(
oct
(
130
)),
coercibility
(
oct
(
130
));
select
collation
(
conv
(
130
,
16
,
10
)),
coercibility
(
conv
(
130
,
16
,
10
));
select
collation
(
hex
(
130
)),
coercibility
(
hex
(
130
));
select
collation
(
char
(
130
)),
coercibility
(
hex
(
130
));
select
collation
(
format
(
130
,
10
)),
coercibility
(
format
(
130
,
10
));
select
collation
(
lcase
(
_latin2
'a'
)),
coercibility
(
lcase
(
_latin2
'a'
));
select
collation
(
ucase
(
_latin2
'a'
)),
coercibility
(
ucase
(
_latin2
'a'
));
select
collation
(
left
(
_latin2
'a'
,
1
)),
coercibility
(
left
(
_latin2
'a'
,
1
));
...
...
@@ -155,9 +161,16 @@ select collation(quote(_latin2'ab')), coercibility(quote(_latin2'ab'));
select
collation
(
soundex
(
_latin2
'ab'
)),
coercibility
(
soundex
(
_latin2
'ab'
));
select
collation
(
substring
(
_latin2
'ab'
,
1
)),
coercibility
(
substring
(
_latin2
'ab'
,
1
));
select
collation
(
insert
(
_latin2
'abcd'
,
2
,
3
,
_latin2
'ef'
)),
coercibility
(
insert
(
_latin2
'abcd'
,
2
,
3
,
_latin2
'ef'
));
select
collation
(
replace
(
_latin2
'abcd'
,
_latin2
'b'
,
_latin2
'B'
)),
coercibility
(
replace
(
_latin2
'abcd'
,
_latin2
'b'
,
_latin2
'B'
));
create
table
t1
select
bin
(
130
),
oct
(
130
),
conv
(
130
,
16
,
10
),
hex
(
130
),
char
(
130
),
format
(
130
,
10
),
left
(
_latin2
'a'
,
1
),
right
(
_latin2
'a'
,
1
),
lcase
(
_latin2
'a'
),
...
...
@@ -176,8 +189,8 @@ select
quote
(
_latin2
'ab'
),
soundex
(
_latin2
'ab'
),
substring
(
_latin2
'ab'
,
1
),
insert
(
_latin2
'abcd'
,
2
,
3
,
_latin2
'ef'
)
insert
(
_latin2
'abcd'
,
2
,
3
,
_latin2
'ef'
),
replace
(
_latin2
'abcd'
,
_latin2
'b'
,
_latin2
'B'
)
;
show
create
table
t1
;
drop
table
t1
;
sql/item.cc
View file @
69af692a
...
...
@@ -39,7 +39,7 @@ Item::Item():
{
marker
=
0
;
maybe_null
=
null_value
=
with_sum_func
=
unsigned_flag
=
0
;
coercibility
=
COER_
IMPLICIT
;
coercibility
=
COER_
COERCIBLE
;
name
=
0
;
decimals
=
0
;
max_length
=
0
;
THD
*
thd
=
current_thd
;
...
...
sql/item_strfunc.cc
View file @
69af692a
...
...
@@ -813,6 +813,7 @@ String *Item_func_replace::val_str(String *str)
void
Item_func_replace
::
fix_length_and_dec
()
{
uint
i
;
max_length
=
args
[
0
]
->
max_length
;
int
diff
=
(
int
)
(
args
[
2
]
->
max_length
-
args
[
1
]
->
max_length
);
if
(
diff
>
0
&&
args
[
1
]
->
max_length
)
...
...
@@ -825,6 +826,20 @@ void Item_func_replace::fix_length_and_dec()
max_length
=
MAX_BLOB_WIDTH
;
maybe_null
=
1
;
}
set_charset
(
args
[
0
]
->
charset
(),
args
[
0
]
->
coercibility
);
for
(
i
=
1
;
i
<
3
;
i
++
)
{
if
(
set_charset
(
charset
(),
coercibility
,
args
[
i
]
->
charset
(),
args
[
i
]
->
coercibility
))
{
my_error
(
ER_CANT_AGGREGATE_COLLATIONS
,
MYF
(
0
),
charset
()
->
name
,
coercion_name
(
coercibility
),
args
[
i
]
->
charset
()
->
name
,
coercion_name
(
args
[
i
]
->
coercibility
),
func_name
());
break
;
}
}
}
...
...
sql/item_strfunc.h
View file @
69af692a
...
...
@@ -433,6 +433,7 @@ class Item_func_format :public Item_str_func
String
*
val_str
(
String
*
);
void
fix_length_and_dec
()
{
set_charset
(
default_charset
());
max_length
=
args
[
0
]
->
max_length
+
(
args
[
0
]
->
max_length
-
args
[
0
]
->
decimals
)
/
3
;
}
const
char
*
func_name
()
const
{
return
"format"
;
}
...
...
@@ -444,7 +445,11 @@ class Item_func_char :public Item_str_func
public:
Item_func_char
(
List
<
Item
>
&
list
)
:
Item_str_func
(
list
)
{}
String
*
val_str
(
String
*
);
void
fix_length_and_dec
()
{
maybe_null
=
0
;
max_length
=
arg_count
;
}
void
fix_length_and_dec
()
{
set_charset
(
default_charset
());
maybe_null
=
0
;
max_length
=
arg_count
;
}
const
char
*
func_name
()
const
{
return
"char"
;
}
};
...
...
@@ -490,7 +495,11 @@ class Item_func_conv :public Item_str_func
Item_func_conv
(
Item
*
a
,
Item
*
b
,
Item
*
c
)
:
Item_str_func
(
a
,
b
,
c
)
{}
const
char
*
func_name
()
const
{
return
"conv"
;
}
String
*
val_str
(
String
*
);
void
fix_length_and_dec
()
{
decimals
=
0
;
max_length
=
64
;
}
void
fix_length_and_dec
()
{
set_charset
(
default_charset
());
decimals
=
0
;
max_length
=
64
;
}
};
...
...
@@ -501,7 +510,11 @@ class Item_func_hex :public Item_str_func
Item_func_hex
(
Item
*
a
)
:
Item_str_func
(
a
)
{}
const
char
*
func_name
()
const
{
return
"hex"
;
}
String
*
val_str
(
String
*
);
void
fix_length_and_dec
()
{
decimals
=
0
;
max_length
=
args
[
0
]
->
max_length
*
2
;
}
void
fix_length_and_dec
()
{
set_charset
(
default_charset
());
decimals
=
0
;
max_length
=
args
[
0
]
->
max_length
*
2
;
}
};
...
...
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