Skip to content

Instantly share code, notes, and snippets.

@breunigs
Last active March 27, 2019 15:32
Show Gist options
  • Save breunigs/9d9b4db657ee53f2f323b0fd6f82c808 to your computer and use it in GitHub Desktop.
Save breunigs/9d9b4db657ee53f2f323b0fd6f82c808 to your computer and use it in GitHub Desktop.
select @@sql_mode
+--------------------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+--------------------------------------------------------------------------------------------------------------+
i.e. NO_ZERO_DATE and NO_ZERO_IN_DATE are disabled.
MySQL version 5.7.22
diff --git a/debezium-connector-mysql/src/test/java/io/debezium/connector/mysql/MysqlDefaultValueAllZeroTimeIT.java b/debezium-connector-mysql/src/test/java/io/debezium/connector/mysql/MysqlDefaultValueAllZeroTimeIT.java
index 40c13d92..2a2e6859 100644
--- a/debezium-connector-mysql/src/test/java/io/debezium/connector/mysql/MysqlDefaultValueAllZeroTimeIT.java
+++ b/debezium-connector-mysql/src/test/java/io/debezium/connector/mysql/MysqlDefaultValueAllZeroTimeIT.java
@@ -74,6 +74,7 @@ public void allZeroDateAndTimeTypeTest() throws InterruptedException {
Schema schemaD = record.valueSchema().fields().get(1).schema().fields().get(3).schema();
Schema schemaE = record.valueSchema().fields().get(1).schema().fields().get(4).schema();
Schema schemaF = record.valueSchema().fields().get(1).schema().fields().get(5).schema();
+ Schema schemaG = record.valueSchema().fields().get(1).schema().fields().get(6).schema();
//column A, 0000-00-00 00:00:00 => 1970-01-01 00:00:00
ZonedDateTime a = ZonedDateTime.ofInstant(Instant.EPOCH, ZoneOffset.UTC);
@@ -100,5 +101,9 @@ public void allZeroDateAndTimeTypeTest() throws InterruptedException {
assertThat(schemaF.isOptional()).isEqualTo(true);
assertThat(schemaF.defaultValue()).isEqualTo(null);
+ //column G allows null, default value should be ???
+ assertThat(schemaG.isOptional()).isEqualTo(true);
+ assertThat(schemaG.defaultValue()).isEqualTo("0000-12-00sdfdsf");
+
}
}
diff --git a/debezium-connector-mysql/src/test/resources/ddl/default_value_all_zero_time.sql b/debezium-connector-mysql/src/test/resources/ddl/default_value_all_zero_time.sql
index 66b904fb..d10327d8 100644
--- a/debezium-connector-mysql/src/test/resources/ddl/default_value_all_zero_time.sql
+++ b/debezium-connector-mysql/src/test/resources/ddl/default_value_all_zero_time.sql
@@ -4,7 +4,8 @@ CREATE TABLE ALL_ZERO_DATE_AND_TIME_TABLE (
C DATE NOT NULL DEFAULT '0000-00-00',
D DATE NULL DEFAULT '0000-00-00',
E DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
- F DATETIME NULL DEFAULT '0000-00-00 00:00:00'
+ F DATETIME NULL DEFAULT '0000-00-00 00:00:00',
+ G DATE NULL DEFAULT '0000-12-00'
);
INSERT INTO ALL_ZERO_DATE_AND_TIME_TABLE
-VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT );
+VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT );
org.apache.kafka.connect.errors.ConnectException: YEAR Error code: 0; SQLSTATE: S1009.
at io.debezium.connector.mysql.AbstractReader.wrap(AbstractReader.java:230)
at io.debezium.connector.mysql.AbstractReader.failed(AbstractReader.java:208)
at io.debezium.connector.mysql.SnapshotReader.execute(SnapshotReader.java:678)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
used by: java.sql.SQLException: YEAR
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:85)
at com.mysql.cj.jdbc.result.ResultSetImpl.getDate(ResultSetImpl.java:847)
at com.mysql.cj.jdbc.result.ResultSetImpl.getObject(ResultSetImpl.java:1352)
at io.debezium.connector.mysql.SnapshotReader.readField(SnapshotReader.java:142)
at io.debezium.connector.mysql.SnapshotReader.lambda$execute$15(SnapshotReader.java:518)
at io.debezium.jdbc.JdbcConnection.query(JdbcConnection.java:436)
at io.debezium.connector.mysql.SnapshotReader.execute(SnapshotReader.java:508)
... 3 more
used by: com.mysql.cj.exceptions.WrongArgumentException: YEAR
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
at com.mysql.cj.result.SqlDateValueFactory.createFromDate(SqlDateValueFactory.java:80)
at com.mysql.cj.result.SqlDateValueFactory.createFromDate(SqlDateValueFactory.java:46)
at com.mysql.cj.result.ZeroDateTimeToNullValueFactory.createFromDate(ZeroDateTimeToNullValueFactory.java:48)
at com.mysql.cj.result.BaseDecoratingValueFactory.createFromDate(BaseDecoratingValueFactory.java:53)
at com.mysql.cj.result.BaseDecoratingValueFactory.createFromDate(BaseDecoratingValueFactory.java:53)
at com.mysql.cj.protocol.a.MysqlTextValueDecoder.decodeDate(MysqlTextValueDecoder.java:72)
at com.mysql.cj.protocol.result.AbstractResultsetRow.decodeAndCreateReturnValue(AbstractResultsetRow.java:90)
at com.mysql.cj.protocol.result.AbstractResultsetRow.getValueFromBytes(AbstractResultsetRow.java:250)
at com.mysql.cj.protocol.a.result.TextBufferRow.getValue(TextBufferRow.java:132)
at com.mysql.cj.jdbc.result.ResultSetImpl.getNonStringValueFromRow(ResultSetImpl.java:656)
at com.mysql.cj.jdbc.result.ResultSetImpl.getDateOrTimestampValueFromRow(ResultSetImpl.java:679)
... 9 more
used by: java.lang.IllegalArgumentException: YEAR
at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2648)
at java.util.Calendar.updateTime(Calendar.java:3393)
at java.util.Calendar.getTimeInMillis(Calendar.java:1782)
at com.mysql.cj.result.SqlDateValueFactory.createFromDate(SqlDateValueFactory.java:77)
... 19 more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment