From c1e9c7d1f3ff5b31ca6a2744707ae4dd7840cf3c Mon Sep 17 00:00:00 2001 From: Alexander Soklakov Date: Mon, 10 Feb 2020 11:46:05 +0400 Subject: [PATCH] Fix for Bug#91112 (28125069), AGAIN WRONG JAVA.SQL.DATE. --- CHANGES | 2 + .../mysql/cj/conf/PropertyDefinitions.java | 3 + .../java/com/mysql/cj/conf/PropertyKey.java | 1 + .../com/mysql/cj/protocol/ServerSession.java | 6 +- .../mysql/cj/ClientPreparedQueryBindings.java | 6 +- .../cj/ServerPreparedQueryBindValue.java | 51 +++++- .../mysql/cj/ServerPreparedQueryBindings.java | 7 +- .../mysql/cj/protocol/a/NativeProtocol.java | 3 +- .../cj/protocol/a/NativeServerSession.java | 16 +- .../mysql/cj/protocol/x/XServerSession.java | 7 +- .../cj/LocalizedErrorMessages.properties | 1 + .../com/mysql/cj/jdbc/ConnectionImpl.java | 4 +- .../com/mysql/cj/jdbc/EscapeProcessor.java | 12 +- .../java/com/mysql/cj/jdbc/StatementImpl.java | 6 +- .../mysql/cj/jdbc/result/ResultSetImpl.java | 19 +-- src/test/java/testsuite/BaseTestCase.java | 1 - .../regression/StatementRegressionTest.java | 148 ++++++++++++++++-- 17 files changed, 230 insertions(+), 63 deletions(-) diff --git a/CHANGES b/CHANGES index e23efedb6..1580274a7 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,8 @@ Version 8.0.20 + - Fix for Bug#91112 (28125069), AGAIN WRONG JAVA.SQL.DATE. + - Fix for Bug#30474158, CONNECTOR/J 8 DOES NOT HONOR THE REQUESTED RESULTSETTYPE SCROLL_INSENSITIVE ETC. - Fix for Bug#98445 (30832513), Connection option clientInfoProvider=ClientInfoProviderSP causes NPE. diff --git a/src/main/core-api/java/com/mysql/cj/conf/PropertyDefinitions.java b/src/main/core-api/java/com/mysql/cj/conf/PropertyDefinitions.java index 6e38e4593..ed7eb963b 100644 --- a/src/main/core-api/java/com/mysql/cj/conf/PropertyDefinitions.java +++ b/src/main/core-api/java/com/mysql/cj/conf/PropertyDefinitions.java @@ -369,6 +369,9 @@ public enum DatabaseTerm { new StringPropertyDefinition(PropertyKey.queryInterceptors, DEFAULT_VALUE_NULL_STRING, RUNTIME_MODIFIABLE, Messages.getString("ConnectionProperties.queryInterceptors"), "8.0.7", CATEGORY_STATEMENTS, Integer.MIN_VALUE), + new BooleanPropertyDefinition(PropertyKey.cacheDefaultTimezone, DEFAULT_VALUE_TRUE, RUNTIME_MODIFIABLE, + Messages.getString("ConnectionProperties.cacheDefaultTimezone"), "8.0.20", CATEGORY_STATEMENTS, Integer.MIN_VALUE), + // // CATEGORY_PREPARED_STATEMENTS // diff --git a/src/main/core-api/java/com/mysql/cj/conf/PropertyKey.java b/src/main/core-api/java/com/mysql/cj/conf/PropertyKey.java index 8758217b5..be5d4c4d0 100644 --- a/src/main/core-api/java/com/mysql/cj/conf/PropertyKey.java +++ b/src/main/core-api/java/com/mysql/cj/conf/PropertyKey.java @@ -78,6 +78,7 @@ public enum PropertyKey { blobsAreStrings("blobsAreStrings", true), // blobSendChunkSize("blobSendChunkSize", true), // cacheCallableStmts("cacheCallableStmts", true), // + cacheDefaultTimezone("cacheDefaultTimezone", true), // cachePrepStmts("cachePrepStmts", true), // cacheResultSetMetadata("cacheResultSetMetadata", true), // cacheServerConfiguration("cacheServerConfiguration", true), // diff --git a/src/main/core-api/java/com/mysql/cj/protocol/ServerSession.java b/src/main/core-api/java/com/mysql/cj/protocol/ServerSession.java index 99970b8c8..438f2f6db 100644 --- a/src/main/core-api/java/com/mysql/cj/protocol/ServerSession.java +++ b/src/main/core-api/java/com/mysql/cj/protocol/ServerSession.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License, version 2.0, as published by the @@ -251,9 +251,7 @@ public interface ServerSession { * The default time zone used to marshall date/time values to/from the server. This is used when getDate(), etc methods are called without a calendar * argument. * - * @return The server time zone (which may be user overridden in a connection property) + * @return The default JVM time zone */ TimeZone getDefaultTimeZone(); - - void setDefaultTimeZone(TimeZone defaultTimeZone); } diff --git a/src/main/core-impl/java/com/mysql/cj/ClientPreparedQueryBindings.java b/src/main/core-impl/java/com/mysql/cj/ClientPreparedQueryBindings.java index 2c937dcb9..57f088ab6 100644 --- a/src/main/core-impl/java/com/mysql/cj/ClientPreparedQueryBindings.java +++ b/src/main/core-impl/java/com/mysql/cj/ClientPreparedQueryBindings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License, version 2.0, as published by the @@ -728,7 +728,7 @@ public void setTime(int parameterIndex, Time x, Calendar cal) { if (x == null) { setNull(parameterIndex); } else { - this.tdf = TimeUtil.getSimpleDateFormat(this.tdf, "''HH:mm:ss''", cal, cal != null ? null : this.session.getServerSession().getDefaultTimeZone()); + this.tdf = TimeUtil.getSimpleDateFormat(this.tdf, "''HH:mm:ss''", cal, cal != null ? null : this.session.getServerSession().getServerTimeZone()); setValue(parameterIndex, this.tdf.format(x), MysqlType.TIME); } } @@ -783,7 +783,7 @@ public void setTimestamp(int parameterIndex, Timestamp x, Calendar targetCalenda x = TimeUtil.adjustTimestampNanosPrecision(x, fractionalLength, !this.session.getServerSession().isServerTruncatesFracSecs()); this.tsdf = TimeUtil.getSimpleDateFormat(this.tsdf, "''yyyy-MM-dd HH:mm:ss", targetCalendar, - targetCalendar != null ? null : this.session.getServerSession().getDefaultTimeZone()); + targetCalendar != null ? null : this.session.getServerSession().getServerTimeZone()); StringBuffer buf = new StringBuffer(); buf.append(this.tsdf.format(x)); diff --git a/src/main/core-impl/java/com/mysql/cj/ServerPreparedQueryBindValue.java b/src/main/core-impl/java/com/mysql/cj/ServerPreparedQueryBindValue.java index 09cf833a8..4f6cf04e1 100644 --- a/src/main/core-impl/java/com/mysql/cj/ServerPreparedQueryBindValue.java +++ b/src/main/core-impl/java/com/mysql/cj/ServerPreparedQueryBindValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License, version 2.0, as published by the @@ -33,6 +33,9 @@ import java.util.Locale; import java.util.TimeZone; +import com.mysql.cj.conf.PropertyKey; +import com.mysql.cj.conf.PropertySet; +import com.mysql.cj.conf.RuntimeProperty; import com.mysql.cj.exceptions.CJException; import com.mysql.cj.exceptions.ExceptionFactory; import com.mysql.cj.exceptions.ExceptionInterceptor; @@ -53,11 +56,15 @@ public class ServerPreparedQueryBindValue extends ClientPreparedQueryBindValue i public Calendar calendar; private TimeZone defaultTimeZone; + private TimeZone serverTimeZone; + private RuntimeProperty cacheDefaultTimezone = null; protected String charEncoding = null; - public ServerPreparedQueryBindValue(TimeZone defaultTZ) { + public ServerPreparedQueryBindValue(TimeZone defaultTZ, TimeZone serverTZ, PropertySet pset) { this.defaultTimeZone = defaultTZ; + this.serverTimeZone = serverTZ; + this.cacheDefaultTimezone = pset.getBooleanProperty(PropertyKey.cacheDefaultTimezone); } @Override @@ -68,7 +75,7 @@ public ServerPreparedQueryBindValue clone() { private ServerPreparedQueryBindValue(ServerPreparedQueryBindValue copyMe) { super(copyMe); - this.defaultTimeZone = copyMe.defaultTimeZone; + this.serverTimeZone = copyMe.serverTimeZone; this.bufferType = copyMe.bufferType; this.calendar = copyMe.calendar; this.charEncoding = copyMe.charEncoding; @@ -229,6 +236,8 @@ public void storeBinding(NativePacketPayload intoPacket, boolean isLoadDataQuery storeTime(intoPacket); return; case MysqlType.FIELD_TYPE_DATE: + storeDate(intoPacket); + return; case MysqlType.FIELD_TYPE_DATETIME: case MysqlType.FIELD_TYPE_TIMESTAMP: storeDateTime(intoPacket); @@ -263,7 +272,7 @@ private void storeTime(NativePacketPayload intoPacket) { intoPacket.writeInteger(IntegerDataType.INT4, 0); // tm->day, not used if (this.calendar == null) { - this.calendar = Calendar.getInstance(this.defaultTimeZone, Locale.US); + this.calendar = Calendar.getInstance(this.serverTimeZone, Locale.US); } this.calendar.setTime((java.util.Date) this.value); @@ -272,6 +281,38 @@ private void storeTime(NativePacketPayload intoPacket) { intoPacket.writeInteger(IntegerDataType.INT1, this.calendar.get(Calendar.SECOND)); } + private void storeDate(NativePacketPayload intoPacket) { + synchronized (this) { + if (this.calendar == null) { + this.calendar = Calendar.getInstance(this.cacheDefaultTimezone.getValue() ? this.defaultTimeZone : TimeZone.getDefault(), Locale.US); + } + + this.calendar.setTime((java.util.Date) this.value); + + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 0); + + byte length = (byte) 7; + + intoPacket.ensureCapacity(length); + + intoPacket.writeInteger(IntegerDataType.INT1, length); // length + + int year = this.calendar.get(Calendar.YEAR); + int month = this.calendar.get(Calendar.MONTH) + 1; + int date = this.calendar.get(Calendar.DAY_OF_MONTH); + + intoPacket.writeInteger(IntegerDataType.INT2, year); + intoPacket.writeInteger(IntegerDataType.INT1, month); + intoPacket.writeInteger(IntegerDataType.INT1, date); + + intoPacket.writeInteger(IntegerDataType.INT1, 0); + intoPacket.writeInteger(IntegerDataType.INT1, 0); + intoPacket.writeInteger(IntegerDataType.INT1, 0); + } + } + /** * @param intoPacket * packet to write into @@ -279,7 +320,7 @@ private void storeTime(NativePacketPayload intoPacket) { private void storeDateTime(NativePacketPayload intoPacket) { synchronized (this) { if (this.calendar == null) { - this.calendar = Calendar.getInstance(this.defaultTimeZone, Locale.US); + this.calendar = Calendar.getInstance(this.serverTimeZone, Locale.US); } this.calendar.setTime((java.util.Date) this.value); diff --git a/src/main/core-impl/java/com/mysql/cj/ServerPreparedQueryBindings.java b/src/main/core-impl/java/com/mysql/cj/ServerPreparedQueryBindings.java index b027237b9..a342e2944 100644 --- a/src/main/core-impl/java/com/mysql/cj/ServerPreparedQueryBindings.java +++ b/src/main/core-impl/java/com/mysql/cj/ServerPreparedQueryBindings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License, version 2.0, as published by the @@ -69,7 +69,8 @@ public ServerPreparedQueryBindings(int parameterCount, Session sess) { protected void initBindValues(int parameterCount) { this.bindValues = new ServerPreparedQueryBindValue[parameterCount]; for (int i = 0; i < parameterCount; i++) { - this.bindValues[i] = new ServerPreparedQueryBindValue(this.session.getServerSession().getDefaultTimeZone()); + this.bindValues[i] = new ServerPreparedQueryBindValue(this.session.getServerSession().getDefaultTimeZone(), + this.session.getServerSession().getServerTimeZone(), this.session.getPropertySet()); } } @@ -469,7 +470,7 @@ public void setTime(int parameterIndex, Time x, Calendar cal) { } public void setTime(int parameterIndex, Time x) { - setTime(parameterIndex, x, null); // this.session.getServerSession().getDefaultTimeZone() + setTime(parameterIndex, x, null); } @Override diff --git a/src/main/protocol-impl/java/com/mysql/cj/protocol/a/NativeProtocol.java b/src/main/protocol-impl/java/com/mysql/cj/protocol/a/NativeProtocol.java index 719e4c5cf..2c110fe75 100644 --- a/src/main/protocol-impl/java/com/mysql/cj/protocol/a/NativeProtocol.java +++ b/src/main/protocol-impl/java/com/mysql/cj/protocol/a/NativeProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License, version 2.0, as published by the @@ -2134,7 +2134,6 @@ public void configureTimezone() { } } - this.serverSession.setDefaultTimeZone(this.serverSession.getServerTimeZone()); } @Override diff --git a/src/main/protocol-impl/java/com/mysql/cj/protocol/a/NativeServerSession.java b/src/main/protocol-impl/java/com/mysql/cj/protocol/a/NativeServerSession.java index db8023cc1..cac5990d6 100644 --- a/src/main/protocol-impl/java/com/mysql/cj/protocol/a/NativeServerSession.java +++ b/src/main/protocol-impl/java/com/mysql/cj/protocol/a/NativeServerSession.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License, version 2.0, as published by the @@ -38,6 +38,7 @@ import com.mysql.cj.ServerVersion; import com.mysql.cj.conf.PropertyKey; import com.mysql.cj.conf.PropertySet; +import com.mysql.cj.conf.RuntimeProperty; import com.mysql.cj.exceptions.ExceptionFactory; import com.mysql.cj.exceptions.WrongArgumentException; import com.mysql.cj.protocol.ServerCapabilities; @@ -116,11 +117,13 @@ public class NativeServerSession implements ServerSession { /** The timezone of the server */ private TimeZone serverTimeZone = null; - /** c.f. getDefaultTimeZone(). this value may be overridden during connection initialization */ private TimeZone defaultTimeZone = TimeZone.getDefault(); + private RuntimeProperty cacheDefaultTimezone = null; + public NativeServerSession(PropertySet propertySet) { this.propertySet = propertySet; + this.cacheDefaultTimezone = this.propertySet.getBooleanProperty(PropertyKey.cacheDefaultTimezone); // preconfigure some server variables which are consulted before their initialization from server this.serverVariables.put("character_set_server", "utf8"); @@ -546,10 +549,9 @@ public void setServerTimeZone(TimeZone serverTimeZone) { } public TimeZone getDefaultTimeZone() { - return this.defaultTimeZone; - } - - public void setDefaultTimeZone(TimeZone defaultTimeZone) { - this.defaultTimeZone = defaultTimeZone; + if (this.cacheDefaultTimezone.getValue()) { + return this.defaultTimeZone; + } + return TimeZone.getDefault(); } } diff --git a/src/main/protocol-impl/java/com/mysql/cj/protocol/x/XServerSession.java b/src/main/protocol-impl/java/com/mysql/cj/protocol/x/XServerSession.java index 7410216c5..1ea26b96e 100644 --- a/src/main/protocol-impl/java/com/mysql/cj/protocol/x/XServerSession.java +++ b/src/main/protocol-impl/java/com/mysql/cj/protocol/x/XServerSession.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License, version 2.0, as published by the @@ -47,7 +47,6 @@ public class XServerSession implements ServerSession { /** The timezone of the server */ //private TimeZone serverTimeZone = null; - /** c.f. getDefaultTimeZone(). this value may be overridden during connection initialization */ private TimeZone defaultTimeZone = TimeZone.getDefault(); @Override @@ -334,8 +333,4 @@ public void setServerTimeZone(TimeZone serverTimeZone) { public TimeZone getDefaultTimeZone() { return this.defaultTimeZone; } - - public void setDefaultTimeZone(TimeZone defaultTimeZone) { - this.defaultTimeZone = defaultTimeZone; - } } diff --git a/src/main/resources/com/mysql/cj/LocalizedErrorMessages.properties b/src/main/resources/com/mysql/cj/LocalizedErrorMessages.properties index da1abf8e9..4be581ded 100644 --- a/src/main/resources/com/mysql/cj/LocalizedErrorMessages.properties +++ b/src/main/resources/com/mysql/cj/LocalizedErrorMessages.properties @@ -813,6 +813,7 @@ ConnectionProperties.metadataCacheSize=The number of queries to cache ResultSetM ConnectionProperties.netTimeoutForStreamingResults=What value should the driver automatically set the server setting ''net_write_timeout'' to when the streaming result sets feature is in use? (value has unit of seconds, the value ''0'' means the driver will not try and adjust this value) ConnectionProperties.noAccessToProcedureBodies=When determining procedure parameter types for CallableStatements, and the connected user can''t access procedure bodies through "SHOW CREATE PROCEDURE" or select on mysql.proc should the driver instead create basic metadata (all parameters reported as INOUT VARCHARs) instead of throwing an exception? ConnectionProperties.noDatetimeStringSync=Don''t ensure that ResultSet.getDatetimeType().toString().equals(ResultSet.getString()) +ConnectionProperties.cacheDefaultTimezone=Caches client's default time zone. This results in better performance when dealing with time zone conversions in Date and Time data types, however it won't be aware of time zone changes if they happen at runtime. ConnectionProperties.nullCatalogMeansCurrent=When DatabaseMetadata methods ask for a ''catalog'' or ''schema'' parameter, does the value null mean use the current database? See also property ''databaseTerm''. ConnectionProperties.databaseTerm=MySQL uses the term "schema" as a synonym of the term "database," while Connector/J historically takes the JDBC term "catalog" as synonymous to "database". This property sets for Connector/J which of the JDBC terms "catalog" and "schema" is used in an application to refer to a database. The property takes one of the two values CATALOG or SCHEMA and uses it to determine (1) which Connection methods can be used to set/get the current database (e.g. setCatalog() or setSchema()?), (2) which arguments can be used within the various DatabaseMetaData methods to filter results (e.g. the catalog or schemaPattern argument of getColumns()?), and (3) which fields in the ResultSet returned by DatabaseMetaData methods contain the database identification information (i.e., the TABLE_CAT or TABLE_SCHEM field in the ResultSet returned by getTables()?).[CR]If databaseTerm=CATALOG, schemaPattern for searches are ignored and calls of schema methods (like setSchema() or get Schema()) become no-ops, and vice versa. ConnectionProperties.packetDebugBufferSize=The maximum number of packets to retain when ''enablePacketDebug'' is true diff --git a/src/main/user-impl/java/com/mysql/cj/jdbc/ConnectionImpl.java b/src/main/user-impl/java/com/mysql/cj/jdbc/ConnectionImpl.java index ad165ccea..bf0b856d6 100644 --- a/src/main/user-impl/java/com/mysql/cj/jdbc/ConnectionImpl.java +++ b/src/main/user-impl/java/com/mysql/cj/jdbc/ConnectionImpl.java @@ -1478,7 +1478,7 @@ public String nativeSQL(String sql) throws SQLException { return null; } - Object escapedSqlResult = EscapeProcessor.escapeSQL(sql, getMultiHostSafeProxy().getSession().getServerSession().getDefaultTimeZone(), + Object escapedSqlResult = EscapeProcessor.escapeSQL(sql, getMultiHostSafeProxy().getSession().getServerSession().getServerTimeZone(), getMultiHostSafeProxy().getSession().getServerSession().getCapabilities().serverSupportsFracSecs(), getMultiHostSafeProxy().getSession().getServerSession().isServerTruncatesFracSecs(), getExceptionInterceptor()); @@ -1490,7 +1490,7 @@ public String nativeSQL(String sql) throws SQLException { } private CallableStatement parseCallableStatement(String sql) throws SQLException { - Object escapedSqlResult = EscapeProcessor.escapeSQL(sql, getMultiHostSafeProxy().getSession().getServerSession().getDefaultTimeZone(), + Object escapedSqlResult = EscapeProcessor.escapeSQL(sql, getMultiHostSafeProxy().getSession().getServerSession().getServerTimeZone(), getMultiHostSafeProxy().getSession().getServerSession().getCapabilities().serverSupportsFracSecs(), getMultiHostSafeProxy().getSession().getServerSession().isServerTruncatesFracSecs(), getExceptionInterceptor()); diff --git a/src/main/user-impl/java/com/mysql/cj/jdbc/EscapeProcessor.java b/src/main/user-impl/java/com/mysql/cj/jdbc/EscapeProcessor.java index 8711609f7..f45911631 100644 --- a/src/main/user-impl/java/com/mysql/cj/jdbc/EscapeProcessor.java +++ b/src/main/user-impl/java/com/mysql/cj/jdbc/EscapeProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License, version 2.0, as published by the @@ -84,8 +84,8 @@ class EscapeProcessor { * * @param sql * the SQL to escape process. - * @param defaultTimeZone - * time zone + * @param serverTimeZone + * server time zone * @param serverSupportsFractionalSecond * flag indicating if server supports fractional seconds * @param serverTruncatesFractionalSecond @@ -98,7 +98,7 @@ class EscapeProcessor { * @throws SQLException * if error occurs */ - public static final Object escapeSQL(String sql, TimeZone defaultTimeZone, boolean serverSupportsFractionalSecond, boolean serverTruncatesFractionalSecond, + public static final Object escapeSQL(String sql, TimeZone serverTimeZone, boolean serverSupportsFractionalSecond, boolean serverTruncatesFractionalSecond, ExceptionInterceptor exceptionInterceptor) throws java.sql.SQLException { boolean replaceEscapeSequence = false; String escapeSequence = null; @@ -140,7 +140,7 @@ public static final Object escapeSQL(String sql, TimeZone defaultTimeZone, boole if (nestedBrace != -1) { StringBuilder buf = new StringBuilder(token.substring(0, 1)); - Object remainingResults = escapeSQL(token.substring(1, token.length() - 1), defaultTimeZone, serverSupportsFractionalSecond, + Object remainingResults = escapeSQL(token.substring(1, token.length() - 1), serverTimeZone, serverSupportsFractionalSecond, serverTruncatesFractionalSecond, exceptionInterceptor); String remaining = null; @@ -223,7 +223,7 @@ public static final Object escapeSQL(String sql, TimeZone defaultTimeZone, boole } } } else if (StringUtils.startsWithIgnoreCase(collapsedToken, "{ts")) { - processTimestampToken(defaultTimeZone, newSql, token, serverSupportsFractionalSecond, serverTruncatesFractionalSecond, + processTimestampToken(serverTimeZone, newSql, token, serverSupportsFractionalSecond, serverTruncatesFractionalSecond, exceptionInterceptor); } else if (StringUtils.startsWithIgnoreCase(collapsedToken, "{t")) { processTimeToken(newSql, token, serverSupportsFractionalSecond, exceptionInterceptor); diff --git a/src/main/user-impl/java/com/mysql/cj/jdbc/StatementImpl.java b/src/main/user-impl/java/com/mysql/cj/jdbc/StatementImpl.java index e336e1ac1..21ab28695 100644 --- a/src/main/user-impl/java/com/mysql/cj/jdbc/StatementImpl.java +++ b/src/main/user-impl/java/com/mysql/cj/jdbc/StatementImpl.java @@ -684,7 +684,7 @@ private boolean executeInternal(String sql, boolean returnGeneratedKeys) throws setupStreamingTimeout(locallyScopedConn); if (this.doEscapeProcessing) { - Object escapedSqlResult = EscapeProcessor.escapeSQL(sql, this.session.getServerSession().getDefaultTimeZone(), + Object escapedSqlResult = EscapeProcessor.escapeSQL(sql, this.session.getServerSession().getServerTimeZone(), this.session.getServerSession().getCapabilities().serverSupportsFracSecs(), this.session.getServerSession().isServerTruncatesFracSecs(), getExceptionInterceptor()); sql = escapedSqlResult instanceof String ? (String) escapedSqlResult : ((EscapeProcessorResult) escapedSqlResult).escapedSql; @@ -1124,7 +1124,7 @@ public java.sql.ResultSet executeQuery(String sql) throws SQLException { setupStreamingTimeout(locallyScopedConn); if (this.doEscapeProcessing) { - Object escapedSqlResult = EscapeProcessor.escapeSQL(sql, this.session.getServerSession().getDefaultTimeZone(), + Object escapedSqlResult = EscapeProcessor.escapeSQL(sql, this.session.getServerSession().getServerTimeZone(), this.session.getServerSession().getCapabilities().serverSupportsFracSecs(), this.session.getServerSession().isServerTruncatesFracSecs(), getExceptionInterceptor()); sql = escapedSqlResult instanceof String ? (String) escapedSqlResult : ((EscapeProcessorResult) escapedSqlResult).escapedSql; @@ -1262,7 +1262,7 @@ protected long executeUpdateInternal(String sql, boolean isBatch, boolean return ResultSetInternalMethods rs = null; if (this.doEscapeProcessing) { - Object escapedSqlResult = EscapeProcessor.escapeSQL(sql, this.session.getServerSession().getDefaultTimeZone(), + Object escapedSqlResult = EscapeProcessor.escapeSQL(sql, this.session.getServerSession().getServerTimeZone(), this.session.getServerSession().getCapabilities().serverSupportsFracSecs(), this.session.getServerSession().isServerTruncatesFracSecs(), getExceptionInterceptor()); sql = escapedSqlResult instanceof String ? (String) escapedSqlResult : ((EscapeProcessorResult) escapedSqlResult).escapedSql; diff --git a/src/main/user-impl/java/com/mysql/cj/jdbc/result/ResultSetImpl.java b/src/main/user-impl/java/com/mysql/cj/jdbc/result/ResultSetImpl.java index a27669c67..1c55449f0 100644 --- a/src/main/user-impl/java/com/mysql/cj/jdbc/result/ResultSetImpl.java +++ b/src/main/user-impl/java/com/mysql/cj/jdbc/result/ResultSetImpl.java @@ -194,8 +194,6 @@ public class ResultSetImpl extends NativeResultset implements ResultSetInternalM private ValueFactory doubleValueFactory; private ValueFactory bigDecimalValueFactory; private ValueFactory binaryStreamValueFactory; - // temporal values include the default conn TZ, can be overridden with cal param, e.g. getDate(1, calWithOtherTZ) - private ValueFactory defaultDateValueFactory; private ValueFactory