Skip to content

Commit 13045c2

Browse files
committed
WL#10839, Adjust c/J tests to the new "ON" default for
explicit_defaults_for_timestamp.
1 parent 2e350a5 commit 13045c2

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

CHANGES

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
Version 8.0.16
55

6+
- WL#10839, Adjust c/J tests to the new "ON" default for explicit_defaults_for_timestamp.
7+
68
- Fix for Bug#29329326, PLEASE AVOID SHOW PROCESSLIST IF POSSIBLE.
79

810
- WL#12460, DevAPI: Support new session reset functionality.

src/test/java/testsuite/regression/MetaDataRegressionTest.java

+2-18
Original file line numberDiff line numberDiff line change
@@ -2882,14 +2882,6 @@ public void testBug63800() throws Exception {
28822882
}
28832883

28842884
private void testTimestamp(Connection con, Statement st, String dbname) throws SQLException {
2885-
boolean explicitDefaultsForTimestamp = false;
2886-
if (versionMeetsMinimum(8, 0, 2)) {
2887-
String v = getMysqlVariable("explicit_defaults_for_timestamp");
2888-
if ("ON".equals(v)) {
2889-
explicitDefaultsForTimestamp = true;
2890-
}
2891-
}
2892-
28932885
st.execute("DROP TABLE IF EXISTS testBug63800");
28942886
st.execute("CREATE TABLE testBug63800(f1 TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP)");
28952887
DatabaseMetaData dmd = con.getMetaData();
@@ -2913,7 +2905,7 @@ private void testTimestamp(Connection con, Statement st, String dbname) throws S
29132905
st.execute("CREATE TABLE testBug63800(f1 TIMESTAMP)");
29142906
dmd = con.getMetaData();
29152907
this.rs = dmd.getVersionColumns(dbname, dbname, "testBug63800");
2916-
if (explicitDefaultsForTimestamp) {
2908+
if ("ON".equals(getMysqlVariable("explicit_defaults_for_timestamp"))) {
29172909
assertFalse("0 column must be found", this.rs.next());
29182910
} else {
29192911
assertTrue("1 column must be found", this.rs.next());
@@ -3047,14 +3039,6 @@ private void testDatetime(Connection con, Statement st, String dbname) throws SQ
30473039
}
30483040
assertEquals("2 column must be found", 2, cnt);
30493041

3050-
boolean explicitDefaultsForTimestamp = false;
3051-
if (versionMeetsMinimum(8, 0, 2)) {
3052-
String v = getMysqlVariable("explicit_defaults_for_timestamp");
3053-
if ("ON".equals(v)) {
3054-
explicitDefaultsForTimestamp = true;
3055-
}
3056-
}
3057-
30583042
st.execute("DROP TABLE IF EXISTS testBug63800");
30593043
st.execute("CREATE TABLE testBug63800(f1 TIMESTAMP, f2 DATETIME ON UPDATE CURRENT_TIMESTAMP, f3 TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP)");
30603044
dmd = con.getMetaData();
@@ -3063,7 +3047,7 @@ private void testDatetime(Connection con, Statement st, String dbname) throws SQ
30633047
while (this.rs.next()) {
30643048
cnt++;
30653049
}
3066-
if (explicitDefaultsForTimestamp) {
3050+
if ("ON".equals(getMysqlVariable("explicit_defaults_for_timestamp"))) {
30673051
assertEquals("2 column must be found", 2, cnt);
30683052
} else {
30693053
assertEquals("3 column must be found", 3, cnt);

src/test/java/testsuite/x/devapi/CollectionTest.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program is free software; you can redistribute it and/or modify it under
55
* the terms of the GNU General Public License, version 2.0, as published by the
@@ -47,6 +47,7 @@
4747
import com.mysql.cj.xdevapi.JsonNumber;
4848
import com.mysql.cj.xdevapi.JsonString;
4949
import com.mysql.cj.xdevapi.Row;
50+
import com.mysql.cj.xdevapi.RowResult;
5051
import com.mysql.cj.xdevapi.SqlResult;
5152
import com.mysql.cj.xdevapi.XDevAPIError;
5253

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

204205
// FR1_8 Create an index using a timestamp field.
206+
RowResult res = this.session.sql("select @@explicit_defaults_for_timestamp").execute();
207+
Row r = res.next();
208+
boolean explicitDefaultsForTimestamp = r.getBoolean(0);
209+
205210
this.collection.createIndex("myIndex", "{\"fields\": [{\"field\": \"$.myField\", \"type\": \"TIMESTAMP\"}]}");
206-
validateIndex("myIndex", this.collectionName, "ds", false, false, false, 1, null);
211+
validateIndex("myIndex", this.collectionName, "ds", false, explicitDefaultsForTimestamp ? false : true, false, 1, null);
207212
this.collection.dropIndex("myIndex");
208213

209214
// FR1_9 Create an index using a time field.

0 commit comments

Comments
 (0)