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
6cbbbd69
Commit
6cbbbd69
authored
Mar 04, 2003
by
bar@bar.mysql.r18.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for SHOW, it didn't display CHARACTER SET and COLLATE clause
for binary collations
parent
c4dc670d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
18 deletions
+56
-18
mysql-test/r/ctype_collate.result
mysql-test/r/ctype_collate.result
+27
-0
mysql-test/t/ctype_collate.test
mysql-test/t/ctype_collate.test
+15
-0
sql/field.cc
sql/field.cc
+12
-7
sql/field.h
sql/field.h
+1
-10
sql/sql_show.cc
sql/sql_show.cc
+1
-1
No files found.
mysql-test/r/ctype_collate.result
View file @
6cbbbd69
...
...
@@ -483,4 +483,31 @@ Z
z
SELECT DISTINCT latin1_f COLLATE koi8r FROM t1;
COLLATION 'koi8r' is not valid for CHARACTER SET 'latin1'
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`latin1_f` char(32) NOT NULL default ''
) TYPE=MyISAM CHARSET=latin1
SHOW FIELDS FROM t1;
Field Type Collation Null Key Default Extra
latin1_f char(32) latin1
ALTER TABLE t1 CHANGE latin1_f
latin1_f CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`latin1_f` char(32) character set latin1 collate latin1_bin default NULL
) TYPE=MyISAM CHARSET=latin1
SHOW FIELDS FROM t1;
Field Type Collation Null Key Default Extra
latin1_f char(32) character set latin1 latin1_bin YES NULL
ALTER TABLE t1 CHARACTER SET latin1 COLLATE latin1_bin;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`latin1_f` char(32) collate latin1_bin default NULL
) TYPE=MyISAM CHARSET=latin1 COLLATE=latin1_bin
SHOW FIELDS FROM t1;
Field Type Collation Null Key Default Extra
latin1_f char(32) latin1_bin YES NULL
DROP TABLE t1;
mysql-test/t/ctype_collate.test
View file @
6cbbbd69
...
...
@@ -112,4 +112,19 @@ SELECT DISTINCT latin1_f COLLATE koi8r FROM t1;
--
FROM
t1
--
HAVING
(
_latin1
'Mu"ller'
COLLATE
latin1_de
)
=
k
#
# Check that SHOW displays COLLATE clause
#
SHOW
CREATE
TABLE
t1
;
SHOW
FIELDS
FROM
t1
;
ALTER
TABLE
t1
CHANGE
latin1_f
latin1_f
CHAR
(
32
)
CHARACTER
SET
latin1
COLLATE
latin1_bin
;
SHOW
CREATE
TABLE
t1
;
SHOW
FIELDS
FROM
t1
;
ALTER
TABLE
t1
CHARACTER
SET
latin1
COLLATE
latin1_bin
;
SHOW
CREATE
TABLE
t1
;
SHOW
FIELDS
FROM
t1
;
DROP
TABLE
t1
;
sql/field.cc
View file @
6cbbbd69
...
...
@@ -248,7 +248,7 @@ void Field_str::make_field(Send_field *field)
void
Field_str
::
add_binary_or_charset
(
String
&
res
)
const
{
if
(
binary
()
)
if
(
charset
()
==
&
my_charset_bin
)
res
.
append
(
" binary"
);
else
if
(
field_charset
!=
table
->
table_charset
&&
!
(
current_thd
->
variables
.
sql_mode
&
MODE_NO_FIELD_OPTIONS
)
&&
...
...
@@ -3875,13 +3875,18 @@ void Field_datetime::sql_type(String &res) const
/* Copy a string and fill with space */
static
bool
use_conversion
(
CHARSET_INFO
*
cs1
,
CHARSET_INFO
*
cs2
)
{
return
(
cs1
!=
&
my_charset_bin
)
&&
(
cs2
!=
&
my_charset_bin
)
&&
(
cs1
!=
cs2
);
}
int
Field_string
::
store
(
const
char
*
from
,
uint
length
,
CHARSET_INFO
*
cs
)
{
int
error
=
0
;
char
buff
[
80
];
String
tmpstr
(
buff
,
sizeof
(
buff
),
&
my_charset_bin
);
/* Convert character set if nesessary */
if
(
(
cs
!=
field_charset
)
&&
(
cs
!=&
my_charset_bin
)
&&
(
!
binary
()
))
if
(
use_conversion
(
cs
,
field_charset
))
{
tmpstr
.
copy
(
from
,
length
,
cs
,
field_charset
);
from
=
tmpstr
.
ptr
();
...
...
@@ -4063,7 +4068,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
char
buff
[
80
];
String
tmpstr
(
buff
,
sizeof
(
buff
),
&
my_charset_bin
);
/* Convert character set if nesessary */
if
(
(
cs
!=
field_charset
)
&&
(
cs
!=&
my_charset_bin
)
&&
(
!
binary
()
))
if
(
use_conversion
(
cs
,
field_charset
))
{
tmpstr
.
copy
(
from
,
length
,
cs
,
field_charset
);
from
=
tmpstr
.
ptr
();
...
...
@@ -4380,7 +4385,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
char
buff
[
80
];
String
tmpstr
(
buff
,
sizeof
(
buff
),
&
my_charset_bin
);
/* Convert character set if nesessary */
if
(
(
cs
!=
field_charset
)
&&
(
cs
!=&
my_charset_bin
)
&&
(
!
binary
()
))
if
(
use_conversion
(
cs
,
field_charset
))
{
tmpstr
.
copy
(
from
,
length
,
cs
,
field_charset
);
from
=
tmpstr
.
ptr
();
...
...
@@ -4627,7 +4632,7 @@ void Field_blob::sql_type(String &res) const
case
4
:
str
=
"long"
;
length
=
4
;
break
;
}
res
.
set_latin1
(
str
,
length
);
if
(
binary
()
)
if
(
charset
()
==
&
my_charset_bin
)
res
.
append
(
"blob"
);
else
{
...
...
@@ -4857,7 +4862,7 @@ int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs)
char
buff
[
80
];
String
tmpstr
(
buff
,
sizeof
(
buff
),
&
my_charset_bin
);
/* Convert character set if nesessary */
if
(
(
cs
!=
field_charset
)
&&
(
cs
!=&
my_charset_bin
)
&&
(
!
binary
()
))
if
(
use_conversion
(
cs
,
field_charset
))
{
tmpstr
.
copy
(
from
,
length
,
cs
,
field_charset
);
from
=
tmpstr
.
ptr
();
...
...
@@ -5072,7 +5077,7 @@ int Field_set::store(const char *from,uint length,CHARSET_INFO *cs)
char
buff
[
80
];
String
tmpstr
(
buff
,
sizeof
(
buff
),
&
my_charset_bin
);
/* Convert character set if nesessary */
if
(
(
cs
!=
field_charset
)
&&
(
cs
!=&
my_charset_bin
)
&&
(
!
binary
()
))
if
(
use_conversion
(
cs
,
field_charset
))
{
tmpstr
.
copy
(
from
,
length
,
cs
,
field_charset
);
from
=
tmpstr
.
ptr
();
...
...
sql/field.h
View file @
6cbbbd69
...
...
@@ -160,8 +160,6 @@ public:
{
get_image
(
buff
,
length
,
cs
);
}
virtual
void
set_key_image
(
char
*
buff
,
uint
length
,
CHARSET_INFO
*
cs
)
{
set_image
(
buff
,
length
,
cs
);
}
inline
int
cmp_image
(
char
*
buff
,
uint
length
)
{
return
memcmp
(
ptr
,
buff
,
length
);
}
inline
longlong
val_int_offset
(
uint
row_offset
)
{
ptr
+=
row_offset
;
...
...
@@ -265,7 +263,7 @@ public:
unireg_check_arg
,
field_name_arg
,
table_arg
)
{
field_charset
=
charset
;
if
(
binary
()
)
if
(
charset
->
state
&
MY_CS_BINSORT
)
flags
|=
BINARY_FLAG
;
}
Item_result
result_type
()
const
{
return
STRING_RESULT
;
}
...
...
@@ -277,13 +275,6 @@ public:
void
set_charset
(
CHARSET_INFO
*
charset
)
{
field_charset
=
charset
;
}
bool
binary
()
const
{
return
field_charset
->
state
&
MY_CS_BINSORT
?
1
:
0
;
}
inline
int
cmp_image
(
char
*
buff
,
uint
length
)
{
if
(
binary
())
return
memcmp
(
ptr
,
buff
,
length
);
else
return
my_strncasecmp
(
field_charset
,
ptr
,
buff
,
length
);
}
friend
class
create_field
;
};
...
...
sql/sql_show.cc
View file @
6cbbbd69
...
...
@@ -1074,7 +1074,7 @@ store_create_info(THD *thd, TABLE *table, String *packet)
For string types dump collation name only if
collation is not primary for the given charset
*/
if
(
!
field
->
binary
()
&&
!
(
field
->
charset
()
->
state
&
MY_CS_PRIMARY
)
&&
if
(
!
(
field
->
charset
()
->
state
&
MY_CS_PRIMARY
)
&&
!
limited_mysql_mode
&&
!
foreign_db_mode
)
{
packet
->
append
(
" collate "
,
9
);
...
...
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