Commit 358635bb authored by Andrew Hutchings's avatar Andrew Hutchings Committed by Andrew Hutchings

MDEV-29782 CONNECT YEAR type conversion fix

When using the MySQL table type the CONNECT engine converted the YEAR
datatype to DATETIME for INSERT queries. This is incorrect, causing an
error on the INSERT. It should be SHORT instead.
parent 476b24d0
......@@ -364,5 +364,16 @@ hex(col)
DROP TABLE t2;
DROP TABLE t1;
#
# MDEV-29782 CONNECT engine converted YEAR to DATETIME, causing INSERT to fail
#
CREATE TABLE t1 (id year);
CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL DBNAME='test' TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=PORT';
INSERT INTO t2 VALUES (1999);
SELECT * FROM t2;
id
1999
DROP TABLE t2;
DROP TABLE t1;
#
# End of 10.3 tests
#
......@@ -533,6 +533,21 @@ DROP TABLE t2;
DROP TABLE t1;
--echo #
--echo # MDEV-29782 CONNECT engine converted YEAR to DATETIME, causing INSERT to fail
--echo #
CREATE TABLE t1 (id year);
--replace_result $PORT PORT
--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL DBNAME='test' TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
INSERT INTO t2 VALUES (1999);
SELECT * FROM t2;
DROP TABLE t2;
DROP TABLE t1;
--echo #
--echo # End of 10.3 tests
--echo #
......@@ -183,6 +183,7 @@ int MYSQLtoPLG(int mytype, char *var)
switch (mytype) {
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_YEAR:
type = TYPE_SHORT;
break;
case MYSQL_TYPE_LONG:
......@@ -209,7 +210,6 @@ int MYSQLtoPLG(int mytype, char *var)
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_YEAR:
case MYSQL_TYPE_TIME:
type = TYPE_DATE;
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment