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
9b2fe4bd
Commit
9b2fe4bd
authored
4 years ago
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-23435 Functions do not convert numbers to character_set_results
parent
2b6dd87b
Branches unavailable
Tags unavailable
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
155 additions
and
18 deletions
+155
-18
mysql-test/main/ctype_filename.result
mysql-test/main/ctype_filename.result
+65
-0
mysql-test/main/ctype_filename.test
mysql-test/main/ctype_filename.test
+62
-0
sql/protocol.cc
sql/protocol.cc
+27
-18
sql/protocol.h
sql/protocol.h
+1
-0
No files found.
mysql-test/main/ctype_filename.result
View file @
9b2fe4bd
...
...
@@ -32,5 +32,70 @@ EXECUTE IMMEDIATE _latin1 0x01;
ERROR 42000: You@0020have@0020an@0020error@0020in@0020your@0020SQL@0020syntax@003b@0020check@0020the@0020manual@0020that@0020corresponds@0020to@0020your@0020MariaDB@0020server@0020version@0020for@0020the@0020right@0020syntax@0020to@0020use@0020near@0020@0027@005c0001@0027@0020at@0020line@00201
SET NAMES utf8;
#
# MDEV-23435 Functions do not convert numbers to character_set_results
#
SET NAMES utf8, character_set_results=filename;
CREATE TABLE t1 (a DATETIME(6));
INSERT INTO t1 VALUES ('2001-01-01 00:00:00.000000');
SELECT a, COALESCE(a) AS c FROM t1;
a c
2001@002d01@002d01@002000@003a00@003a00@002e000000 2001@002d01@002d01@002000@003a00@003a00@002e000000
DROP TABLE t1;
CREATE TABLE t1 (a TIME(6));
INSERT INTO t1 VALUES ('00:00:00.000000');
SELECT a, COALESCE(a) AS c FROM t1;
a c
00@003a00@003a00@002e000000 00@003a00@003a00@002e000000
DROP TABLE t1;
CREATE TABLE t1 (a DATE);
INSERT INTO t1 VALUES ('2001-01-01');
SELECT a, COALESCE(a) AS c FROM t1;
a c
2001@002d01@002d01 2001@002d01@002d01
DROP TABLE t1;
CREATE TABLE t1 (a TINYINT);
INSERT INTO t1 VALUES (-1);
SELECT a, COALESCE(a) AS c FROM t1;
a c
@002d1 @002d1
DROP TABLE t1;
CREATE TABLE t1 (a SMALLINT);
INSERT INTO t1 VALUES (-1);
SELECT a, COALESCE(a) AS c FROM t1;
a c
@002d1 @002d1
DROP TABLE t1;
CREATE TABLE t1 (a MEDIUMINT);
INSERT INTO t1 VALUES (-1);
SELECT a, COALESCE(a) AS c FROM t1;
a c
@002d1 @002d1
DROP TABLE t1;
CREATE TABLE t1 (a BIGINT);
INSERT INTO t1 VALUES (-1);
SELECT a, COALESCE(a) AS c FROM t1;
a c
@002d1 @002d1
DROP TABLE t1;
CREATE TABLE t1 (a DECIMAL(10.2));
INSERT INTO t1 VALUES (-1);
SELECT a, COALESCE(a) AS c FROM t1;
a c
@002d1 @002d1
DROP TABLE t1;
CREATE TABLE t1 (a FLOAT);
INSERT INTO t1 VALUES (-1);
SELECT a, COALESCE(a) AS c FROM t1;
a c
@002d1 @002d1
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE);
INSERT INTO t1 VALUES (-1);
SELECT a, COALESCE(a) AS c FROM t1;
a c
@002d1 @002d1
DROP TABLE t1;
SET NAMES utf8;
#
# End of 10.5 tests
#
This diff is collapsed.
Click to expand it.
mysql-test/main/ctype_filename.test
View file @
9b2fe4bd
...
...
@@ -42,6 +42,68 @@ SET NAMES filename;
EXECUTE
IMMEDIATE
_latin1
0x01
;
SET
NAMES
utf8
;
--
echo
#
--
echo
# MDEV-23435 Functions do not convert numbers to character_set_results
--
echo
#
--
disable_ps_protocol
SET
NAMES
utf8
,
character_set_results
=
filename
;
CREATE
TABLE
t1
(
a
DATETIME
(
6
));
INSERT
INTO
t1
VALUES
(
'2001-01-01 00:00:00.000000'
);
SELECT
a
,
COALESCE
(
a
)
AS
c
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
TIME
(
6
));
INSERT
INTO
t1
VALUES
(
'00:00:00.000000'
);
SELECT
a
,
COALESCE
(
a
)
AS
c
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
DATE
);
INSERT
INTO
t1
VALUES
(
'2001-01-01'
);
SELECT
a
,
COALESCE
(
a
)
AS
c
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
TINYINT
);
INSERT
INTO
t1
VALUES
(
-
1
);
SELECT
a
,
COALESCE
(
a
)
AS
c
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
SMALLINT
);
INSERT
INTO
t1
VALUES
(
-
1
);
SELECT
a
,
COALESCE
(
a
)
AS
c
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
MEDIUMINT
);
INSERT
INTO
t1
VALUES
(
-
1
);
SELECT
a
,
COALESCE
(
a
)
AS
c
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
BIGINT
);
INSERT
INTO
t1
VALUES
(
-
1
);
SELECT
a
,
COALESCE
(
a
)
AS
c
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
DECIMAL
(
10.2
));
INSERT
INTO
t1
VALUES
(
-
1
);
SELECT
a
,
COALESCE
(
a
)
AS
c
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
FLOAT
);
INSERT
INTO
t1
VALUES
(
-
1
);
SELECT
a
,
COALESCE
(
a
)
AS
c
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
DOUBLE
);
INSERT
INTO
t1
VALUES
(
-
1
);
SELECT
a
,
COALESCE
(
a
)
AS
c
FROM
t1
;
DROP
TABLE
t1
;
SET
NAMES
utf8
;
--
enable_ps_protocol
--
echo
#
--
echo
# End of 10.5 tests
...
...
This diff is collapsed.
Click to expand it.
sql/protocol.cc
View file @
9b2fe4bd
...
...
@@ -1200,6 +1200,16 @@ bool Protocol::store_string_aux(const char *from, size_t length,
}
bool
Protocol_text
::
store_numeric_string_aux
(
const
char
*
from
,
size_t
length
)
{
CHARSET_INFO
*
tocs
=
thd
->
variables
.
character_set_results
;
// 'tocs' is NULL when the client issues SET character_set_results=NULL
if
(
tocs
&&
(
tocs
->
state
&
MY_CS_NONASCII
))
// Conversion needed
return
net_store_data_cs
((
uchar
*
)
from
,
length
,
&
my_charset_latin1
,
tocs
);
return
net_store_data
((
uchar
*
)
from
,
length
);
// No conversion
}
bool
Protocol
::
store_warning
(
const
char
*
from
,
size_t
length
)
{
BinaryStringBuffer
<
MYSQL_ERRMSG_SIZE
>
tmp
;
...
...
@@ -1235,8 +1245,8 @@ bool Protocol_text::store_tiny(longlong from)
field_pos
++
;
#endif
char
buff
[
22
];
return
net_store_data
((
uchar
*
)
buff
,
(
size_t
)
(
int10_to_str
((
int
)
from
,
buff
,
-
10
)
-
buff
)
);
size_t
length
=
(
size_t
)
(
int10_to_str
((
int
)
from
,
buff
,
-
10
)
-
buff
);
return
store_numeric_string_aux
(
buff
,
length
);
}
...
...
@@ -1247,9 +1257,8 @@ bool Protocol_text::store_short(longlong from)
field_pos
++
;
#endif
char
buff
[
22
];
return
net_store_data
((
uchar
*
)
buff
,
(
size_t
)
(
int10_to_str
((
int
)
from
,
buff
,
-
10
)
-
buff
));
size_t
length
=
(
size_t
)
(
int10_to_str
((
int
)
from
,
buff
,
-
10
)
-
buff
);
return
store_numeric_string_aux
(
buff
,
length
);
}
...
...
@@ -1260,9 +1269,9 @@ bool Protocol_text::store_long(longlong from)
field_pos
++
;
#endif
char
buff
[
22
];
return
net_store_data
((
uchar
*
)
buff
,
(
size_t
)
(
int10_to_str
((
long
int
)
from
,
buff
,
(
from
<
0
)
?-
10
:
10
)
-
buff
)
);
size_t
length
=
(
size_t
)
(
int10_to_str
((
long
int
)
from
,
buff
,
(
from
<
0
)
?
-
10
:
10
)
-
buff
);
return
store_numeric_string_aux
(
buff
,
length
);
}
...
...
@@ -1273,10 +1282,10 @@ bool Protocol_text::store_longlong(longlong from, bool unsigned_flag)
field_pos
++
;
#endif
char
buff
[
22
];
return
net_store_data
((
uchar
*
)
buff
,
(
size_t
)
(
longlong10_to_str
(
from
,
buff
,
unsigned_flag
?
10
:
-
10
)
-
buff
)
);
size_t
length
=
(
size_t
)
(
longlong10_to_str
(
from
,
buff
,
unsigned_flag
?
10
:
-
10
)
-
buff
);
return
store_numeric_string_aux
(
buff
,
length
);
}
...
...
@@ -1288,7 +1297,7 @@ bool Protocol_text::store_decimal(const my_decimal *d)
#endif
StringBuffer
<
DECIMAL_MAX_STR_LENGTH
>
str
;
(
void
)
d
->
to_string
(
&
str
);
return
net_store_data
((
uchar
*
)
str
.
ptr
(),
str
.
length
());
return
store_numeric_string_aux
(
str
.
ptr
(),
str
.
length
());
}
...
...
@@ -1299,7 +1308,7 @@ bool Protocol_text::store(float from, uint32 decimals, String *buffer)
field_pos
++
;
#endif
Float
(
from
).
to_string
(
buffer
,
decimals
);
return
net_store_data
((
uchar
*
)
buffer
->
ptr
(),
buffer
->
length
());
return
store_numeric_string_aux
(
buffer
->
ptr
(),
buffer
->
length
());
}
...
...
@@ -1310,7 +1319,7 @@ bool Protocol_text::store(double from, uint32 decimals, String *buffer)
field_pos
++
;
#endif
buffer
->
set_real
(
from
,
decimals
,
thd
->
charset
());
return
net_store_data
((
uchar
*
)
buffer
->
ptr
(),
buffer
->
length
());
return
store_numeric_string_aux
(
buffer
->
ptr
(),
buffer
->
length
());
}
...
...
@@ -1350,7 +1359,7 @@ bool Protocol_text::store(MYSQL_TIME *tm, int decimals)
#endif
char
buff
[
MAX_DATE_STRING_REP_LENGTH
];
uint
length
=
my_datetime_to_str
(
tm
,
buff
,
decimals
);
return
net_store_data
((
uchar
*
)
buff
,
length
);
return
store_numeric_string_aux
(
buff
,
length
);
}
...
...
@@ -1362,7 +1371,7 @@ bool Protocol_text::store_date(MYSQL_TIME *tm)
#endif
char
buff
[
MAX_DATE_STRING_REP_LENGTH
];
size_t
length
=
my_date_to_str
(
tm
,
buff
);
return
net_store_data
((
uchar
*
)
buff
,
length
);
return
store_numeric_string_aux
(
buff
,
length
);
}
...
...
@@ -1374,7 +1383,7 @@ bool Protocol_text::store_time(MYSQL_TIME *tm, int decimals)
#endif
char
buff
[
MAX_DATE_STRING_REP_LENGTH
];
uint
length
=
my_time_to_str
(
tm
,
buff
,
decimals
);
return
net_store_data
((
uchar
*
)
buff
,
length
);
return
store_numeric_string_aux
(
buff
,
length
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
sql/protocol.h
View file @
9b2fe4bd
...
...
@@ -206,6 +206,7 @@ class Protocol
class
Protocol_text
:
public
Protocol
{
bool
store_numeric_string_aux
(
const
char
*
from
,
size_t
length
);
public:
Protocol_text
(
THD
*
thd_arg
,
ulong
prealloc
=
0
)
:
Protocol
(
thd_arg
)
...
...
This diff is collapsed.
Click to expand it.
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