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
b37386d8
Commit
b37386d8
authored
Oct 09, 2019
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-20785 Converting INET6 to CHAR(39) produces garbage without a warning
parent
c78ae293
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
227 additions
and
1 deletion
+227
-1
plugin/type_inet/mysql-test/type_inet/type_inet6.result
plugin/type_inet/mysql-test/type_inet/type_inet6.result
+124
-0
plugin/type_inet/mysql-test/type_inet/type_inet6.test
plugin/type_inet/mysql-test/type_inet/type_inet6.test
+102
-0
sql/field_conv.cc
sql/field_conv.cc
+1
-1
No files found.
plugin/type_inet/mysql-test/type_inet/type_inet6.result
View file @
b37386d8
...
@@ -1266,6 +1266,117 @@ Warning 1292 Incorrect inet6 value: '::192.168.0.1'
...
@@ -1266,6 +1266,117 @@ Warning 1292 Incorrect inet6 value: '::192.168.0.1'
Warning 1292 Incorrect inet6 value: '::ffff:192.168.0.1'
Warning 1292 Incorrect inet6 value: '::ffff:192.168.0.1'
DROP TABLE t1;
DROP TABLE t1;
#
#
# ALTER to character string data types
#
CREATE OR REPLACE TABLE t1 (a INET6);
INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
SELECT CAST(a AS CHAR(39)) FROM t1;
CAST(a AS CHAR(39))
2001:db8::ff00:42:8329
ALTER TABLE t1 MODIFY a CHAR(39);
SELECT * FROM t1;
a
2001:db8::ff00:42:8329
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (a INET6);
INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
ALTER TABLE t1 MODIFY a VARCHAR(39);
SELECT * FROM t1;
a
2001:db8::ff00:42:8329
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (a INET6);
INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
ALTER TABLE t1 MODIFY a TINYTEXT;
SELECT * FROM t1;
a
2001:db8::ff00:42:8329
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (a INET6);
INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
ALTER TABLE t1 MODIFY a TEXT;
SELECT * FROM t1;
a
2001:db8::ff00:42:8329
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (a INET6);
INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
ALTER TABLE t1 MODIFY a MEDIUMTEXT;
SELECT * FROM t1;
a
2001:db8::ff00:42:8329
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (a INET6);
INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
ALTER TABLE t1 MODIFY a LONGTEXT;
SELECT * FROM t1;
a
2001:db8::ff00:42:8329
DROP TABLE t1;
#
# ALTER from character string data types
#
CREATE OR REPLACE TABLE t1 (a CHAR(64));
INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
SELECT CAST(a AS INET6) FROM t1;
CAST(a AS INET6)
2001:db8::ff00:42:8329
ALTER TABLE t1 MODIFY a INET6;
SELECT * FROM t1;
a
2001:db8::ff00:42:8329
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (a VARCHAR(64));
INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
SELECT CAST(a AS INET6) FROM t1;
CAST(a AS INET6)
2001:db8::ff00:42:8329
ALTER TABLE t1 MODIFY a INET6;
SELECT * FROM t1;
a
2001:db8::ff00:42:8329
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (a TINYTEXT);
INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
SELECT CAST(a AS INET6) FROM t1;
CAST(a AS INET6)
2001:db8::ff00:42:8329
ALTER TABLE t1 MODIFY a INET6;
SELECT * FROM t1;
a
2001:db8::ff00:42:8329
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (a TEXT);
INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
SELECT CAST(a AS INET6) FROM t1;
CAST(a AS INET6)
2001:db8::ff00:42:8329
ALTER TABLE t1 MODIFY a INET6;
SELECT * FROM t1;
a
2001:db8::ff00:42:8329
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (a MEDIUMTEXT);
INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
SELECT CAST(a AS INET6) FROM t1;
CAST(a AS INET6)
2001:db8::ff00:42:8329
ALTER TABLE t1 MODIFY a INET6;
SELECT * FROM t1;
a
2001:db8::ff00:42:8329
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (a LONGTEXT);
INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
SELECT CAST(a AS INET6) FROM t1;
CAST(a AS INET6)
2001:db8::ff00:42:8329
ALTER TABLE t1 MODIFY a INET6;
SELECT * FROM t1;
a
2001:db8::ff00:42:8329
DROP TABLE t1;
#
# Limit clause parameter
# Limit clause parameter
# TODO: this should fail.
# TODO: this should fail.
# The test for a valid data type should be moved
# The test for a valid data type should be moved
...
@@ -1274,3 +1385,16 @@ DROP TABLE t1;
...
@@ -1274,3 +1385,16 @@ DROP TABLE t1;
#
#
EXECUTE IMMEDIATE 'SELECT 1 FROM DUAL LIMIT ?' USING CAST('::' AS INET6);
EXECUTE IMMEDIATE 'SELECT 1 FROM DUAL LIMIT ?' USING CAST('::' AS INET6);
1
1
#
# MDEV-20785 Converting INET6 to CHAR(39) produces garbage without a warning
#
CREATE OR REPLACE TABLE t1 (a INET6);
INSERT INTO t1 VALUES ('2001:db8::ff00:42:8329');
SELECT CAST(a AS CHAR(39)) FROM t1;
CAST(a AS CHAR(39))
2001:db8::ff00:42:8329
ALTER TABLE t1 MODIFY a CHAR(39);
SELECT * FROM t1;
a
2001:db8::ff00:42:8329
DROP TABLE t1;
plugin/type_inet/mysql-test/type_inet/type_inet6.test
View file @
b37386d8
...
@@ -813,6 +813,96 @@ SELECT id, length(a), a, IS_IPV4_MAPPED(BINARY a) FROM t1 ORDER BY id;
...
@@ -813,6 +813,96 @@ SELECT id, length(a), a, IS_IPV4_MAPPED(BINARY a) FROM t1 ORDER BY id;
SELECT
id
,
length
(
a
),
a
,
IS_IPV4_COMPAT
(
BINARY
a
)
FROM
t1
ORDER
BY
id
;
SELECT
id
,
length
(
a
),
a
,
IS_IPV4_COMPAT
(
BINARY
a
)
FROM
t1
ORDER
BY
id
;
DROP
TABLE
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# ALTER to character string data types
--
echo
#
CREATE
OR
REPLACE
TABLE
t1
(
a
INET6
);
INSERT
INTO
t1
VALUES
(
'2001:db8::ff00:42:8329'
);
SELECT
CAST
(
a
AS
CHAR
(
39
))
FROM
t1
;
ALTER
TABLE
t1
MODIFY
a
CHAR
(
39
);
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
CREATE
OR
REPLACE
TABLE
t1
(
a
INET6
);
INSERT
INTO
t1
VALUES
(
'2001:db8::ff00:42:8329'
);
ALTER
TABLE
t1
MODIFY
a
VARCHAR
(
39
);
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
CREATE
OR
REPLACE
TABLE
t1
(
a
INET6
);
INSERT
INTO
t1
VALUES
(
'2001:db8::ff00:42:8329'
);
ALTER
TABLE
t1
MODIFY
a
TINYTEXT
;
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
CREATE
OR
REPLACE
TABLE
t1
(
a
INET6
);
INSERT
INTO
t1
VALUES
(
'2001:db8::ff00:42:8329'
);
ALTER
TABLE
t1
MODIFY
a
TEXT
;
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
CREATE
OR
REPLACE
TABLE
t1
(
a
INET6
);
INSERT
INTO
t1
VALUES
(
'2001:db8::ff00:42:8329'
);
ALTER
TABLE
t1
MODIFY
a
MEDIUMTEXT
;
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
CREATE
OR
REPLACE
TABLE
t1
(
a
INET6
);
INSERT
INTO
t1
VALUES
(
'2001:db8::ff00:42:8329'
);
ALTER
TABLE
t1
MODIFY
a
LONGTEXT
;
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# ALTER from character string data types
--
echo
#
CREATE
OR
REPLACE
TABLE
t1
(
a
CHAR
(
64
));
INSERT
INTO
t1
VALUES
(
'2001:db8::ff00:42:8329'
);
SELECT
CAST
(
a
AS
INET6
)
FROM
t1
;
ALTER
TABLE
t1
MODIFY
a
INET6
;
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
CREATE
OR
REPLACE
TABLE
t1
(
a
VARCHAR
(
64
));
INSERT
INTO
t1
VALUES
(
'2001:db8::ff00:42:8329'
);
SELECT
CAST
(
a
AS
INET6
)
FROM
t1
;
ALTER
TABLE
t1
MODIFY
a
INET6
;
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
CREATE
OR
REPLACE
TABLE
t1
(
a
TINYTEXT
);
INSERT
INTO
t1
VALUES
(
'2001:db8::ff00:42:8329'
);
SELECT
CAST
(
a
AS
INET6
)
FROM
t1
;
ALTER
TABLE
t1
MODIFY
a
INET6
;
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
CREATE
OR
REPLACE
TABLE
t1
(
a
TEXT
);
INSERT
INTO
t1
VALUES
(
'2001:db8::ff00:42:8329'
);
SELECT
CAST
(
a
AS
INET6
)
FROM
t1
;
ALTER
TABLE
t1
MODIFY
a
INET6
;
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
CREATE
OR
REPLACE
TABLE
t1
(
a
MEDIUMTEXT
);
INSERT
INTO
t1
VALUES
(
'2001:db8::ff00:42:8329'
);
SELECT
CAST
(
a
AS
INET6
)
FROM
t1
;
ALTER
TABLE
t1
MODIFY
a
INET6
;
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
CREATE
OR
REPLACE
TABLE
t1
(
a
LONGTEXT
);
INSERT
INTO
t1
VALUES
(
'2001:db8::ff00:42:8329'
);
SELECT
CAST
(
a
AS
INET6
)
FROM
t1
;
ALTER
TABLE
t1
MODIFY
a
INET6
;
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
#
--
echo
# Limit clause parameter
--
echo
# Limit clause parameter
--
echo
# TODO: this should fail.
--
echo
# TODO: this should fail.
...
@@ -833,3 +923,15 @@ EXECUTE IMMEDIATE 'SELECT 1 FROM DUAL LIMIT ?' USING CAST('::' AS INET6);
...
@@ -833,3 +923,15 @@ EXECUTE IMMEDIATE 'SELECT 1 FROM DUAL LIMIT ?' USING CAST('::' AS INET6);
## - This should fail with the "illegal data type" error:
## - This should fail with the "illegal data type" error:
## EXTRACT(MINUTE...)
## EXTRACT(MINUTE...)
##
##
--
echo
#
--
echo
# MDEV-20785 Converting INET6 to CHAR(39) produces garbage without a warning
--
echo
#
CREATE
OR
REPLACE
TABLE
t1
(
a
INET6
);
INSERT
INTO
t1
VALUES
(
'2001:db8::ff00:42:8329'
);
SELECT
CAST
(
a
AS
CHAR
(
39
))
FROM
t1
;
ALTER
TABLE
t1
MODIFY
a
CHAR
(
39
);
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
sql/field_conv.cc
View file @
b37386d8
...
@@ -786,7 +786,7 @@ Field::Copy_func *Field_string::get_copy_func(const Field *from) const
...
@@ -786,7 +786,7 @@ Field::Copy_func *Field_string::get_copy_func(const Field *from) const
{
{
if
(
from
->
type
()
==
MYSQL_TYPE_BIT
)
if
(
from
->
type
()
==
MYSQL_TYPE_BIT
)
return
do_field_int
;
return
do_field_int
;
if
(
Field_string
::
real_type
()
!=
from
->
real_type
()
||
if
(
Field_string
::
type_handler
()
!=
from
->
type_handler
()
||
Field_string
::
charset
()
!=
from
->
charset
())
Field_string
::
charset
()
!=
from
->
charset
())
return
do_field_string
;
return
do_field_string
;
if
(
Field_string
::
pack_length
()
<
from
->
pack_length
())
if
(
Field_string
::
pack_length
()
<
from
->
pack_length
())
...
...
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