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
f8ed7ebb
Commit
f8ed7ebb
authored
Dec 13, 2003
by
serg@serg.mylan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
insert table select * from table2 now converts charsets correctly
parent
28709e8f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
8 deletions
+40
-8
mysql-test/r/ctype_recoding.result
mysql-test/r/ctype_recoding.result
+22
-2
mysql-test/t/ctype_recoding.test
mysql-test/t/ctype_recoding.test
+14
-2
sql/field_conv.cc
sql/field_conv.cc
+4
-4
No files found.
mysql-test/r/ctype_recoding.result
View file @
f8ed7ebb
SET CHARACTER SET koi8r;
DROP TABLE IF EXISTS , t1;
DROP TABLE IF EXISTS , t1
, t2
;
SET CHARACTER SET koi8r;
CREATE TABLE t1 (a CHAR(10) CHARACTER SET cp1251) SELECT _koi8r'' AS a;
CREATE TABLE t2 (a CHAR(10) CHARACTER SET utf8);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
...
...
@@ -13,7 +14,26 @@ a
SELECT HEX(a) FROM t1;
HEX(a)
EFF0EEE1E0
DROP TABLE t1;
INSERT t2 SELECT * FROM t1;
SELECT HEX(a) FROM t2;
HEX(a)
D0BFD180D0BED0B1D0B0
DROP TABLE t1, t2;
CREATE TABLE t1 (a TEXT CHARACTER SET cp1251) SELECT _koi8r'' AS a;
CREATE TABLE t2 (a TEXT CHARACTER SET utf8);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text character set cp1251
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT HEX(a) FROM t1;
HEX(a)
EFF0EEE1E0
INSERT t2 SELECT * FROM t1;
SELECT HEX(a) FROM t2;
HEX(a)
D0BFD180D0BED0B1D0B0
DROP TABLE t1, t2;
CREATE TABLE ``
(
CHAR(32) CHARACTER SET koi8r NOT NULL COMMENT " "
...
...
mysql-test/t/ctype_recoding.test
View file @
f8ed7ebb
SET
CHARACTER
SET
koi8r
;
--
disable_warnings
DROP
TABLE
IF
EXISTS
,
t1
;
DROP
TABLE
IF
EXISTS
,
t1
,
t2
;
--
enable_warnings
SET
CHARACTER
SET
koi8r
;
CREATE
TABLE
t1
(
a
CHAR
(
10
)
CHARACTER
SET
cp1251
)
SELECT
_koi8r
''
AS
a
;
CREATE
TABLE
t2
(
a
CHAR
(
10
)
CHARACTER
SET
utf8
);
SHOW
CREATE
TABLE
t1
;
SELECT
a
FROM
t1
;
SELECT
HEX
(
a
)
FROM
t1
;
DROP
TABLE
t1
;
INSERT
t2
SELECT
*
FROM
t1
;
SELECT
HEX
(
a
)
FROM
t2
;
DROP
TABLE
t1
,
t2
;
# same with TEXT
CREATE
TABLE
t1
(
a
TEXT
CHARACTER
SET
cp1251
)
SELECT
_koi8r
''
AS
a
;
CREATE
TABLE
t2
(
a
TEXT
CHARACTER
SET
utf8
);
SHOW
CREATE
TABLE
t1
;
SELECT
HEX
(
a
)
FROM
t1
;
INSERT
t2
SELECT
*
FROM
t1
;
SELECT
HEX
(
a
)
FROM
t2
;
DROP
TABLE
t1
,
t2
;
CREATE
TABLE
``
(
...
...
sql/field_conv.cc
View file @
f8ed7ebb
...
...
@@ -17,7 +17,7 @@
/*
Functions to copy data to or from fields
This could be done with a single short function but openco
o
ding this
This could be done with a single short function but opencoding this
gives much more speed.
*/
...
...
@@ -549,6 +549,7 @@ void field_conv(Field *to,Field *from)
if
(
to
->
pack_length
()
==
from
->
pack_length
()
&&
to
->
real_type
()
!=
FIELD_TYPE_ENUM
&&
to
->
real_type
()
!=
FIELD_TYPE_SET
&&
from
->
charset
()
==
to
->
charset
()
&&
to
->
table
->
db_low_byte_first
==
from
->
table
->
db_low_byte_first
)
{
// Identical fields
memcpy
(
to
->
ptr
,
from
->
ptr
,
to
->
pack_length
());
...
...
@@ -562,7 +563,7 @@ void field_conv(Field *to,Field *from)
if
(
!
blob
->
value
.
is_alloced
()
&&
from
->
real_type
()
!=
FIELD_TYPE_STRING
)
blob
->
value
.
copy
();
blob
->
store
(
blob
->
value
.
ptr
(),
blob
->
value
.
length
(),
to
->
charset
());
blob
->
store
(
blob
->
value
.
ptr
(),
blob
->
value
.
length
(),
from
->
charset
());
return
;
}
if
((
from
->
result_type
()
==
STRING_RESULT
&&
...
...
@@ -574,8 +575,7 @@ void field_conv(Field *to,Field *from)
char
buff
[
MAX_FIELD_WIDTH
];
String
result
(
buff
,
sizeof
(
buff
),
from
->
charset
());
from
->
val_str
(
&
result
,
&
result
);
to
->
store
(
result
.
c_ptr_quick
(),
result
.
length
(),
to
->
charset
());
// QQ: what to do if "from" and "to" are of dirrent charsets?
to
->
store
(
result
.
c_ptr_quick
(),
result
.
length
(),
from
->
charset
());
}
else
if
(
from
->
result_type
()
==
REAL_RESULT
)
to
->
store
(
from
->
val_real
());
...
...
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