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
5d6d28f2
Commit
5d6d28f2
authored
Oct 11, 2019
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-20798 Conversion from INET6 to other types performed without errors or warnings
parent
d8e599bb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
610 additions
and
15 deletions
+610
-15
plugin/type_inet/mysql-test/type_inet/type_inet6.result
plugin/type_inet/mysql-test/type_inet/type_inet6.result
+300
-0
plugin/type_inet/mysql-test/type_inet/type_inet6.test
plugin/type_inet/mysql-test/type_inet/type_inet6.test
+284
-0
plugin/type_inet/sql_type_inet.cc
plugin/type_inet/sql_type_inet.cc
+7
-15
plugin/type_inet/sql_type_inet.h
plugin/type_inet/sql_type_inet.h
+1
-0
sql/field.h
sql/field.h
+8
-0
sql/sql_type.h
sql/sql_type.h
+10
-0
No files found.
plugin/type_inet/mysql-test/type_inet/type_inet6.result
View file @
5d6d28f2
...
...
@@ -1580,6 +1580,280 @@ a
2001:db8::ff00:42:8329
DROP TABLE t1;
#
# SET from INET6 to INET6
#
CREATE TABLE t1 (a INET6, b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
#
# SET from INET6 to numeric
#
CREATE TABLE t1 (a INET6, b INT);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect integer value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b DOUBLE);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect double value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b DECIMAL(32,0));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect decimal value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b YEAR);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect integer value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
#
# SET from numeric to INET6
#
CREATE TABLE t1 (a INT, b INET6);
INSERT INTO t1 VALUES (1, NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect inet6 value: '1' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE, b INET6);
INSERT INTO t1 VALUES (1, NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect inet6 value: '1' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a DECIMAL(32,0), b INET6);
INSERT INTO t1 VALUES (1, NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect inet6 value: '1' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a YEAR, b INET6);
INSERT INTO t1 VALUES (1, NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect inet6 value: '2001' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
#
# SET from INET6 to temporal
#
CREATE TABLE t1 (a INET6, b TIME);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect time value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b DATE);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect date value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b DATETIME);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect datetime value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b TIMESTAMP NULL DEFAULT NULL);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect datetime value: 'ffff::ffff' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
#
# SET from temporal to INET6
#
CREATE TABLE t1 (a TIME, b INET6);
INSERT INTO t1 VALUES ('00:00:00', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect inet6 value: '00:00:00' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a DATE, b INET6);
INSERT INTO t1 VALUES ('2001-01:01', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect inet6 value: '2001-01-01' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a DATETIME, b INET6);
INSERT INTO t1 VALUES ('2001-01-01 10:20:30', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect inet6 value: '2001-01-01 10:20:30' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
CREATE TABLE t1 (a TIMESTAMP, b INET6);
INSERT INTO t1 VALUES ('2001-01-01 10:20:30', NULL);
UPDATE t1 SET b=a;
ERROR 22007: Incorrect inet6 value: '2001-01-01 10:20:30' for column `test`.`t1`.`b` at row 1
SELECT b FROM t1;
b
NULL
DROP TABLE t1;
#
# SET from INET6 to character string
#
CREATE TABLE t1 (a INET6, b CHAR(39));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b VARCHAR(39));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b TEXT);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b ENUM('ffff::ffff'));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b SET('ffff::ffff'));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
#
# SET from character string to INET6
#
CREATE TABLE t1 (a CHAR(39), b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(39), b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a TEXT, b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a ENUM('ffff::ffff'), b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a SET('ffff::ffff'), b INET6);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
#
# SET from INET6 to binary
#
CREATE TABLE t1 (a INET6, b BINARY(16));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT HEX(b) FROM t1;
HEX(b)
FFFF000000000000000000000000FFFF
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b VARBINARY(39));
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT HEX(b) FROM t1;
HEX(b)
FFFF000000000000000000000000FFFF
DROP TABLE t1;
CREATE TABLE t1 (a INET6, b BLOB);
INSERT INTO t1 VALUES ('ffff::ffff', NULL);
UPDATE t1 SET b=a;
SELECT HEX(b) FROM t1;
HEX(b)
FFFF000000000000000000000000FFFF
DROP TABLE t1;
#
# SET from binary to INET6
#
CREATE TABLE t1 (a BINARY(16), b INET6);
INSERT INTO t1 VALUES (CONCAT(0xFFFF,REPEAT(0x0000,6),0xFFFF), NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a VARBINARY(16), b INET6);
INSERT INTO t1 VALUES (CONCAT(0xFFFF,REPEAT(0x0000,6),0xFFFF), NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
CREATE TABLE t1 (a BLOB, b INET6);
INSERT INTO t1 VALUES (CONCAT(0xFFFF,REPEAT(0x0000,6),0xFFFF), NULL);
UPDATE t1 SET b=a;
SELECT b FROM t1;
b
ffff::ffff
DROP TABLE t1;
#
# Limit clause parameter
# TODO: this should fail.
# The test for a valid data type should be moved
...
...
@@ -1631,3 +1905,29 @@ INSERT INTO t1 VALUES ('::');
SELECT CAST(a AS FLOAT) FROM t1;
ERROR HY000: Illegal parameter data type inet6 for operation 'float_typecast'
DROP TABLE t1;
#
# MDEV-20798 Conversion from INET6 to other types performed without errors or warnings
#
CREATE TABLE t1 (a INET6, b INT);
INSERT INTO t1 (a) VALUES ('::');
UPDATE t1 SET b=a;
ERROR 22007: Incorrect integer value: '::' for column `test`.`t1`.`b` at row 1
SELECT * FROM t1;
a b
:: NULL
DROP TABLE t1;
SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30');
CREATE TABLE t1 (a INET6, b TIMESTAMP);
INSERT INTO t1 (a) VALUES ('::');
UPDATE t1 SET b=a;
ERROR 22007: Incorrect datetime value: '::' for column `test`.`t1`.`b` at row 1
SELECT * FROM t1;
a b
:: 2001-01-01 10:20:30
DROP TABLE t1;
SET timestamp=DEFAULT;
CREATE OR REPLACE TABLE t1 (a INET6);
INSERT INTO t1 (a) VALUES ('::');
ALTER TABLE t1 MODIFY a DATE;
ERROR 22007: Incorrect date value: '::' for column `test`.`t1`.`a` at row 1
DROP TABLE t1;
plugin/type_inet/mysql-test/type_inet/type_inet6.test
View file @
5d6d28f2
...
...
@@ -1065,6 +1065,264 @@ SELECT a FROM t1;
DROP
TABLE
t1
;
--
echo
#
--
echo
# SET from INET6 to INET6
--
echo
#
CREATE
TABLE
t1
(
a
INET6
,
b
INET6
);
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# SET from INET6 to numeric
--
echo
#
CREATE
TABLE
t1
(
a
INET6
,
b
INT
);
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
--
error
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
INET6
,
b
DOUBLE
);
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
--
error
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
INET6
,
b
DECIMAL
(
32
,
0
));
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
--
error
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
INET6
,
b
YEAR
);
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
--
error
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# SET from numeric to INET6
--
echo
#
CREATE
TABLE
t1
(
a
INT
,
b
INET6
);
INSERT
INTO
t1
VALUES
(
1
,
NULL
);
--
error
ER_TRUNCATED_WRONG_VALUE
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
DOUBLE
,
b
INET6
);
INSERT
INTO
t1
VALUES
(
1
,
NULL
);
--
error
ER_TRUNCATED_WRONG_VALUE
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
DECIMAL
(
32
,
0
),
b
INET6
);
INSERT
INTO
t1
VALUES
(
1
,
NULL
);
--
error
ER_TRUNCATED_WRONG_VALUE
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
YEAR
,
b
INET6
);
INSERT
INTO
t1
VALUES
(
1
,
NULL
);
--
error
ER_TRUNCATED_WRONG_VALUE
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# SET from INET6 to temporal
--
echo
#
CREATE
TABLE
t1
(
a
INET6
,
b
TIME
);
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
--
error
ER_TRUNCATED_WRONG_VALUE
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
INET6
,
b
DATE
);
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
--
error
ER_TRUNCATED_WRONG_VALUE
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
INET6
,
b
DATETIME
);
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
--
error
ER_TRUNCATED_WRONG_VALUE
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
INET6
,
b
TIMESTAMP
NULL
DEFAULT
NULL
);
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
--
error
ER_TRUNCATED_WRONG_VALUE
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# SET from temporal to INET6
--
echo
#
CREATE
TABLE
t1
(
a
TIME
,
b
INET6
);
INSERT
INTO
t1
VALUES
(
'00:00:00'
,
NULL
);
--
error
ER_TRUNCATED_WRONG_VALUE
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
DATE
,
b
INET6
);
INSERT
INTO
t1
VALUES
(
'2001-01:01'
,
NULL
);
--
error
ER_TRUNCATED_WRONG_VALUE
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
DATETIME
,
b
INET6
);
INSERT
INTO
t1
VALUES
(
'2001-01-01 10:20:30'
,
NULL
);
--
error
ER_TRUNCATED_WRONG_VALUE
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
TIMESTAMP
,
b
INET6
);
INSERT
INTO
t1
VALUES
(
'2001-01-01 10:20:30'
,
NULL
);
--
error
ER_TRUNCATED_WRONG_VALUE
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# SET from INET6 to character string
--
echo
#
CREATE
TABLE
t1
(
a
INET6
,
b
CHAR
(
39
));
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
INET6
,
b
VARCHAR
(
39
));
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
INET6
,
b
TEXT
);
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
INET6
,
b
ENUM
(
'ffff::ffff'
));
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
INET6
,
b
SET
(
'ffff::ffff'
));
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# SET from character string to INET6
--
echo
#
CREATE
TABLE
t1
(
a
CHAR
(
39
),
b
INET6
);
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
VARCHAR
(
39
),
b
INET6
);
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
TEXT
,
b
INET6
);
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
ENUM
(
'ffff::ffff'
),
b
INET6
);
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
SET
(
'ffff::ffff'
),
b
INET6
);
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# SET from INET6 to binary
--
echo
#
CREATE
TABLE
t1
(
a
INET6
,
b
BINARY
(
16
));
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
HEX
(
b
)
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
INET6
,
b
VARBINARY
(
39
));
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
HEX
(
b
)
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
INET6
,
b
BLOB
);
INSERT
INTO
t1
VALUES
(
'ffff::ffff'
,
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
HEX
(
b
)
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# SET from binary to INET6
--
echo
#
CREATE
TABLE
t1
(
a
BINARY
(
16
),
b
INET6
);
INSERT
INTO
t1
VALUES
(
CONCAT
(
0xFFFF
,
REPEAT
(
0x0000
,
6
),
0xFFFF
),
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
VARBINARY
(
16
),
b
INET6
);
INSERT
INTO
t1
VALUES
(
CONCAT
(
0xFFFF
,
REPEAT
(
0x0000
,
6
),
0xFFFF
),
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
a
BLOB
,
b
INET6
);
INSERT
INTO
t1
VALUES
(
CONCAT
(
0xFFFF
,
REPEAT
(
0x0000
,
6
),
0xFFFF
),
NULL
);
UPDATE
t1
SET
b
=
a
;
SELECT
b
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# Limit clause parameter
--
echo
# TODO: this should fail.
...
...
@@ -1127,3 +1385,29 @@ INSERT INTO t1 VALUES ('::');
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
CAST
(
a
AS
FLOAT
)
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# MDEV-20798 Conversion from INET6 to other types performed without errors or warnings
--
echo
#
CREATE
TABLE
t1
(
a
INET6
,
b
INT
);
INSERT
INTO
t1
(
a
)
VALUES
(
'::'
);
--
error
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
UPDATE
t1
SET
b
=
a
;
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
SET
timestamp
=
UNIX_TIMESTAMP
(
'2001-01-01 10:20:30'
);
CREATE
TABLE
t1
(
a
INET6
,
b
TIMESTAMP
);
INSERT
INTO
t1
(
a
)
VALUES
(
'::'
);
--
error
ER_TRUNCATED_WRONG_VALUE
UPDATE
t1
SET
b
=
a
;
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
SET
timestamp
=
DEFAULT
;
CREATE
OR
REPLACE
TABLE
t1
(
a
INET6
);
INSERT
INTO
t1
(
a
)
VALUES
(
'::'
);
--
error
ER_TRUNCATED_WRONG_VALUE
ALTER
TABLE
t1
MODIFY
a
DATE
;
DROP
TABLE
t1
;
plugin/type_inet/sql_type_inet.cc
View file @
5d6d28f2
...
...
@@ -802,23 +802,15 @@ class Field_inet6: public Field
int
save_in_field
(
Field
*
to
)
override
{
// INSERT INTO t2 (different_field_type) SELECT inet6_field FROM t1;
switch
(
to
->
cmp_type
())
{
case
INT_RESULT
:
case
REAL_RESULT
:
case
DECIMAL_RESULT
:
case
TIME_RESULT
:
if
(
to
->
charset
()
==
&
my_charset_bin
&&
dynamic_cast
<
const
Type_handler_general_purpose_string
*>
(
to
->
type_handler
()))
{
my_decimal
buff
;
return
to
->
store_decimal
(
val_decimal
(
&
buff
));
NativeBufferInet6
res
;
val_native
(
&
res
);
return
to
->
store
(
res
.
ptr
(),
res
.
length
(),
&
my_charset_bin
);
}
case
STRING_RESULT
:
return
save_in_field_str
(
to
);
case
ROW_RESULT
:
break
;
}
DBUG_ASSERT
(
0
);
to
->
reset
();
return
0
;
return
save_in_field_str
(
to
);
}
Copy_func
*
get_copy_func
(
const
Field
*
from
)
const
override
{
...
...
plugin/type_inet/sql_type_inet.h
View file @
5d6d28f2
...
...
@@ -393,6 +393,7 @@ class Type_handler_inet6: public Type_handler
bool
can_return_text
()
const
override
{
return
true
;
}
bool
can_return_date
()
const
override
{
return
false
;
}
bool
can_return_time
()
const
override
{
return
false
;
}
bool
convert_to_binary_using_val_native
()
const
override
{
return
true
;
}
uint
Item_time_precision
(
THD
*
thd
,
Item
*
item
)
const
override
{
...
...
sql/field.h
View file @
5d6d28f2
...
...
@@ -4168,6 +4168,14 @@ class Field_blob :public Field_longstr {
}
int
store_field
(
Field
*
from
)
override
{
// Be sure the value is stored
if
(
field_charset
()
==
&
my_charset_bin
&&
from
->
type_handler
()
->
convert_to_binary_using_val_native
())
{
NativeBuffer
<
64
>
tmp
;
from
->
val_native
(
&
tmp
);
value
.
copy
(
tmp
.
ptr
(),
tmp
.
length
(),
&
my_charset_bin
);
return
store
(
value
.
ptr
(),
value
.
length
(),
&
my_charset_bin
);
}
from
->
val_str
(
&
value
);
if
(
table
->
copy_blobs
||
(
!
value
.
is_alloced
()
&&
from
->
is_varchar_and_in_write_set
()))
...
...
sql/sql_type.h
View file @
5d6d28f2
...
...
@@ -3411,6 +3411,16 @@ class Type_handler
{
return
false
;
}
/*
If operations such as:
UPDATE t1 SET binary_string_field=this_type_field;
should store this_type_field->val_native() rather than
this_type_field->val_str().
*/
virtual
bool
convert_to_binary_using_val_native
()
const
{
return
false
;
}
virtual
bool
is_timestamp_type
()
const
{
return
false
;
...
...
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