Skip to content

Commit

Permalink
WL#10839, Adjust c/J tests to the new "ON" default for
Browse files Browse the repository at this point in the history
explicit_defaults_for_timestamp.
  • Loading branch information
soklakov committed Feb 25, 2019
1 parent 2e350a5 commit 13045c2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

Version 8.0.16

- WL#10839, Adjust c/J tests to the new "ON" default for explicit_defaults_for_timestamp.

- Fix for Bug#29329326, PLEASE AVOID SHOW PROCESSLIST IF POSSIBLE.

- WL#12460, DevAPI: Support new session reset functionality.
Expand Down
20 changes: 2 additions & 18 deletions src/test/java/testsuite/regression/MetaDataRegressionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2882,14 +2882,6 @@ public void testBug63800() throws Exception {
}

private void testTimestamp(Connection con, Statement st, String dbname) throws SQLException {
boolean explicitDefaultsForTimestamp = false;
if (versionMeetsMinimum(8, 0, 2)) {
String v = getMysqlVariable("explicit_defaults_for_timestamp");
if ("ON".equals(v)) {
explicitDefaultsForTimestamp = true;
}
}

st.execute("DROP TABLE IF EXISTS testBug63800");
st.execute("CREATE TABLE testBug63800(f1 TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP)");
DatabaseMetaData dmd = con.getMetaData();
Expand All @@ -2913,7 +2905,7 @@ private void testTimestamp(Connection con, Statement st, String dbname) throws S
st.execute("CREATE TABLE testBug63800(f1 TIMESTAMP)");
dmd = con.getMetaData();
this.rs = dmd.getVersionColumns(dbname, dbname, "testBug63800");
if (explicitDefaultsForTimestamp) {
if ("ON".equals(getMysqlVariable("explicit_defaults_for_timestamp"))) {
assertFalse("0 column must be found", this.rs.next());
} else {
assertTrue("1 column must be found", this.rs.next());
Expand Down Expand Up @@ -3047,14 +3039,6 @@ private void testDatetime(Connection con, Statement st, String dbname) throws SQ
}
assertEquals("2 column must be found", 2, cnt);

boolean explicitDefaultsForTimestamp = false;
if (versionMeetsMinimum(8, 0, 2)) {
String v = getMysqlVariable("explicit_defaults_for_timestamp");
if ("ON".equals(v)) {
explicitDefaultsForTimestamp = true;
}
}

st.execute("DROP TABLE IF EXISTS testBug63800");
st.execute("CREATE TABLE testBug63800(f1 TIMESTAMP, f2 DATETIME ON UPDATE CURRENT_TIMESTAMP, f3 TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP)");
dmd = con.getMetaData();
Expand All @@ -3063,7 +3047,7 @@ private void testDatetime(Connection con, Statement st, String dbname) throws SQ
while (this.rs.next()) {
cnt++;
}
if (explicitDefaultsForTimestamp) {
if ("ON".equals(getMysqlVariable("explicit_defaults_for_timestamp"))) {
assertEquals("2 column must be found", 2, cnt);
} else {
assertEquals("3 column must be found", 3, cnt);
Expand Down
9 changes: 7 additions & 2 deletions src/test/java/testsuite/x/devapi/CollectionTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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
Expand Down Expand Up @@ -47,6 +47,7 @@
import com.mysql.cj.xdevapi.JsonNumber;
import com.mysql.cj.xdevapi.JsonString;
import com.mysql.cj.xdevapi.Row;
import com.mysql.cj.xdevapi.RowResult;
import com.mysql.cj.xdevapi.SqlResult;
import com.mysql.cj.xdevapi.XDevAPIError;

Expand Down Expand Up @@ -202,8 +203,12 @@ public void createIndex() throws Exception {
this.collection.dropIndex("myIndex");

// FR1_8 Create an index using a timestamp field.
RowResult res = this.session.sql("select @@explicit_defaults_for_timestamp").execute();
Row r = res.next();
boolean explicitDefaultsForTimestamp = r.getBoolean(0);

this.collection.createIndex("myIndex", "{\"fields\": [{\"field\": \"$.myField\", \"type\": \"TIMESTAMP\"}]}");
validateIndex("myIndex", this.collectionName, "ds", false, false, false, 1, null);
validateIndex("myIndex", this.collectionName, "ds", false, explicitDefaultsForTimestamp ? false : true, false, 1, null);
this.collection.dropIndex("myIndex");

// FR1_9 Create an index using a time field.
Expand Down

0 comments on commit 13045c2

Please sign in to comment.