Skip to content

Commit

Permalink
[misc] version 1.3.0-beta-2
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Sep 29, 2015
1 parent 38cb5c1 commit 4bd080d
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 69 deletions.
2 changes: 1 addition & 1 deletion build_release.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ call %BINDIR%\mysqladmin -uroot shutdown

#deploy package
#generate javadoc : mvn javadoc:javadoc
#mvn clean deploy -Dmaven.test.skip=true -Dpackage-source
#mvn clean exec:exec deploy package -Dmaven.test.skip=true -Dpackage-source

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>mariadb-java-client</artifactId>
<packaging>jar</packaging>
<name>mariadb-java-client</name>
<version>1.3.0-beta-1</version>
<version>1.3.0-beta-2</version>
<description>JDBC driver for MariaDB and MySQL</description>
<url>https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/</url>
<properties>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/mariadb/jdbc/Version.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.mariadb.jdbc;

public final class Version {
public static final String version = "1.3.0-SNAPSHOT";
public static final String version = "1.3.0-beta-2";
public static final int majorVersion = 1;
public static final int minorVersion = 3;
public static final int patchVersion = 0;
public static final String qualifier = "SNAPSHOT";
public static final String qualifier = "beta-2";

}
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,36 @@ public Time getTime(Calendar cal) throws ParseException {
}

private Date binaryDate(Calendar cal) throws ParseException {
return new Date(getTimestamp(cal).getTime());
if (rawBytes.length == 0) return null;
int year = 1970;
int month = 1;
int day = 1;
int hour = 0;
int minutes = 0;
int seconds = 0;

year = ((rawBytes[0] & 0xff) | (rawBytes[1] & 0xff) << 8);
month = rawBytes[2];
day = rawBytes[3];

Calendar c = Calendar.getInstance();
/*if (!options.useLegacyDatetimeCode) {
c = cal;
}*/

Date dt;
synchronized (c) {
c.clear();
c.set(Calendar.YEAR, year);
c.set(Calendar.MONTH, month - 1);
c.set(Calendar.DAY_OF_MONTH, day);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
dt = new Date(c.getTimeInMillis());
}
return dt;
}

private Time binaryTime() {
Expand Down Expand Up @@ -721,14 +750,14 @@ private Timestamp binaryTimestamp(Calendar cal) throws ParseException {
}

Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR, year);
c.set(Calendar.MONTH, month - 1);
c.set(Calendar.DAY_OF_MONTH, day);
c.set(Calendar.HOUR_OF_DAY, hour);
c.set(Calendar.MINUTE, minutes);
c.set(Calendar.SECOND, seconds);
c.set(Calendar.MILLISECOND, microseconds / 1000);
Timestamp tt = new Timestamp(c.getTimeInMillis());
if (!options.useLegacyDatetimeCode) {
c = cal;
}
Timestamp tt;
synchronized (c) {
c.set(year, month - 1, day, hour, minutes, seconds);
tt = new Timestamp(c.getTimeInMillis());
}
tt.setNanos(microseconds * 1000);
return tt;
}
Expand Down
98 changes: 42 additions & 56 deletions src/test/java/org/mariadb/jdbc/TimezoneDaylightSavingTimeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,82 +340,68 @@ public void testTimeStampOffsetNowUseServer() throws SQLException {

@Test
public void testDayLightLegacy() throws SQLException {
testDayLight(true, false);
}

@Test
public void testDayLightLegacyForceServer() throws SQLException {
testDayLight(true, true);
testDayLight(true);
}

@Test
public void testDayLight() throws SQLException {
testDayLight(true, false);
}

@Test
public void testDayLightForceServer() throws SQLException {
testDayLight(true, true);
testDayLight(false);
}


private void testDayLight(boolean legacy, boolean forceServerZone) throws SQLException {
private void testDayLight(boolean legacy) throws SQLException {

Assume.assumeTrue(hasSuperPrivilege("testDayLight"));
TimeZone.setDefault(parisTimeZone);
Connection connection = null;
try {
connection = setConnection("&useLegacyDatetimeCode=" + legacy + ((forceServerZone) ? "&serverTimezone=Europe/Paris" : ""));
setSessionTimeZone(connection, "Europe/Paris");
Statement st = connection.createStatement();
String serverTimeZone = null;
ResultSet rs = st.executeQuery("SHOW GLOBAL VARIABLES LIKE 'time_zone';");
if (rs.next()) {
serverTimeZone = rs.getString(2);
}
try {
createTable("daylight", "id int, t1 TIMESTAMP(6), t2 TIME(6), t3 DATETIME(6) , t4 DATE");
Calendar quarterBeforeChangingHour = Calendar.getInstance(TimeZone.getTimeZone("utc"));
quarterBeforeChangingHour.clear();
quarterBeforeChangingHour.set(2015, 2, 29, 0, 45, 0);
int offsetBefore = parisTimeZone.getOffset(quarterBeforeChangingHour.getTimeInMillis());
Assert.assertEquals(offsetBefore, 3600000);
connection = setConnection("&useLegacyDatetimeCode=" + legacy + "&serverTimezone=Canada/Atlantic");
setSessionTimeZone(connection, "Canada/Atlantic");

Calendar quarterAfterChangingHour = Calendar.getInstance(TimeZone.getTimeZone("utc"));
quarterAfterChangingHour.clear();
quarterAfterChangingHour.set(2015, 2, 29, 1, 15, 0);
int offsetAfter = parisTimeZone.getOffset(quarterAfterChangingHour.getTimeInMillis());
Assert.assertEquals(offsetAfter, 7200000);
createTable("daylight", "id int, t1 TIMESTAMP(6), t2 TIME(6), t3 DATETIME(6) , t4 DATE");
Calendar quarterBeforeChangingHour = Calendar.getInstance(TimeZone.getTimeZone("utc"));
quarterBeforeChangingHour.clear();
quarterBeforeChangingHour.set(2015, 2, 29, 0, 45, 0);
int offsetBefore = parisTimeZone.getOffset(quarterBeforeChangingHour.getTimeInMillis());
Assert.assertEquals(offsetBefore, 3600000);


Timestamp vt1 = new Timestamp(quarterBeforeChangingHour.getTimeInMillis());
vt1.setNanos(12340000);
PreparedStatement pst = connection.prepareStatement("INSERT INTO daylight VALUES (?, ?, ?, ?, ?)");
pst.setInt(1, 1);
pst.setTimestamp(2, vt1);
pst.setTime(3, new Time(quarterBeforeChangingHour.getTimeInMillis()));
pst.setTimestamp(4, vt1);
pst.setDate(5, new java.sql.Date(quarterBeforeChangingHour.getTimeInMillis()));
pst.addBatch();
pst.setInt(1, 2);
pst.setTimestamp(2, new Timestamp(quarterAfterChangingHour.getTimeInMillis()));
pst.setTime(3, new Time(quarterAfterChangingHour.getTimeInMillis()));
pst.setTimestamp(4, new Timestamp(quarterAfterChangingHour.getTimeInMillis()));
pst.setDate(5, new java.sql.Date(quarterAfterChangingHour.getTimeInMillis()));
pst.addBatch();
pst.executeBatch();
SimpleDateFormat cDateFormatISO8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
cDateFormatISO8601.setTimeZone(canadaTimeZone);

checkResult(true, connection);
checkResult(false, connection);
Calendar test = Calendar.getInstance(TimeZone.getTimeZone("Canada/Atlantic"));
test.set(2015, 2, 28, 22, 45, 0);
System.out.println(cDateFormatISO8601.format(test.getTime()));

Calendar quarterAfterChangingHour = Calendar.getInstance(TimeZone.getTimeZone("utc"));
quarterAfterChangingHour.clear();
quarterAfterChangingHour.set(2015, 2, 29, 1, 15, 0);
int offsetAfter = parisTimeZone.getOffset(quarterAfterChangingHour.getTimeInMillis());
Assert.assertEquals(offsetAfter, 7200000);

} finally {
if (serverTimeZone != null)
st.executeQuery("SET GLOBAL time_zone = '" + serverTimeZone + "'");

}
Timestamp vt1 = new Timestamp(quarterBeforeChangingHour.getTimeInMillis());
vt1.setNanos(12340000);
PreparedStatement pst = connection.prepareStatement("INSERT INTO daylight VALUES (?, ?, ?, ?, ?)");
pst.setInt(1, 1);
pst.setTimestamp(2, vt1);
pst.setTime(3, new Time(quarterBeforeChangingHour.getTimeInMillis()));
pst.setTimestamp(4, Timestamp.valueOf("2015-03-29 01:45:00"));
pst.setDate(5, new java.sql.Date(quarterBeforeChangingHour.getTimeInMillis()));
pst.addBatch();
pst.setInt(1, 2);
pst.setTimestamp(2, Timestamp.valueOf("2015-03-29 03:15:00"));
pst.setTime(3, new Time(quarterAfterChangingHour.getTimeInMillis()));
pst.setTimestamp(4, Timestamp.valueOf("2015-03-29 03:15:00"));
pst.setDate(5, new java.sql.Date(quarterAfterChangingHour.getTimeInMillis()));
pst.addBatch();
pst.executeBatch();

checkResult(true, connection);
checkResult(false, connection);

} finally {
connection.close();
if (connection != null) connection.close();
}
}

Expand Down

0 comments on commit 4bd080d

Please sign in to comment.