Skip to content

Commit

Permalink
Fix for Bug#36380711, Tests failing due to removal of deprecated feat…
Browse files Browse the repository at this point in the history
…ures.

Change-Id: I1e0df877b04b73a68631256d9637b9bc5da75627
  • Loading branch information
fjssilva committed Mar 8, 2024
1 parent 8b40d85 commit 6fbbd21
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 38 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.4.0

- Fix for Bug#36380711, Tests failing due to removal of deprecated features.

- Fix for Bug#113600 (Bug#36171575), Contribution: Fix join condition for retrieval of imported primary keys.
Thanks to Henning Pöttker for his contribution.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3986,10 +3986,6 @@ private byte[][] getTypeInfo(String mysqlTypeName) throws SQLException {
case BIGINT:
case BIGINT_UNSIGNED:
case BOOLEAN:
case DOUBLE:
case DOUBLE_UNSIGNED:
case FLOAT:
case FLOAT_UNSIGNED:
case INT:
case INT_UNSIGNED:
case MEDIUMINT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6751,10 +6751,10 @@ public void testBug20825727() throws Exception {
JdbcConnection testConn = (JdbcConnection) getConnectionWithProps(dbUrl, props);
Statement testStmt = testConn.createStatement();

this.rs = testStmt.executeQuery("SELECT @@GLOBAL.HAVE_SSL = 'YES' AS have_ssl");
final boolean sslEnabled = this.rs.next() && this.rs.getBoolean(1);
this.rs = testStmt.executeQuery("SHOW STATUS LIKE 'Ssl_version'");
final boolean sslEnabled = this.rs.next() && !this.rs.getString(1).isEmpty();

this.rs = testStmt.executeQuery("SHOW STATUS LIKE '%Rsa_public_key%'");
this.rs = testStmt.executeQuery("SHOW STATUS LIKE 'Rsa_public_key'");
final boolean rsaEnabled = this.rs.next() && this.rs.getString(1).length() > 0;

System.out.println();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1048,9 +1048,9 @@ public void testBug11575() throws Exception {
*/
@Test
public void testBug11781() throws Exception {
createTable("`app tab`", "( C1 int(11) NULL, C2 int(11) NULL, INDEX NEWINX (C1), INDEX NEWINX2 (C1, C2))", "InnoDB");
createTable("`app tab`", "(C1 INT(11) NOT NULL PRIMARY KEY, C2 INT(11) NULL, INDEX NEWINX1 (C1), INDEX NEWINX2 (C1, C2))", "InnoDB");

this.stmt.executeUpdate("ALTER TABLE `app tab` ADD CONSTRAINT APPFK FOREIGN KEY (C1) REFERENCES `app tab` (C1)");
this.stmt.executeUpdate("ALTER TABLE `app tab` ADD CONSTRAINT APPFK FOREIGN KEY (C2) REFERENCES `app tab` (C1)");

/*
* this.rs = this.conn.getMetaData().getCrossReference(
Expand All @@ -1074,7 +1074,7 @@ public void testBug11781() throws Exception {
this.rs = ((com.mysql.cj.jdbc.DatabaseMetaData) con.getMetaData()).extractForeignKeyFromCreateTable(db, "app tab");
assertTrue(this.rs.next(), "must return a row");

assertEquals(("comment; APPFK(`C1`) REFER `" + db + "`/ `app tab` (`C1`)").toUpperCase(), this.rs.getString(3).toUpperCase());
assertEquals(("comment; APPFK(`C2`) REFER `" + db + "`/ `app tab` (`C1`)").toUpperCase(), this.rs.getString(3).toUpperCase());

this.rs.close();

Expand Down Expand Up @@ -3266,7 +3266,8 @@ private void testBug65871_testTable(String unquotedDbName, String quotedDbName,
+ (((JdbcConnection) st1.getConnection()).getPropertySet().<DatabaseTerm>getEnumProperty(PropertyKey.databaseTerm)
.getValue() == DatabaseTerm.SCHEMA ? this.conn.getSchema() : this.conn.getCatalog())
+ ".testbug65871_foreign(cpd_foreign_1_id, cpd_foreign_2_id), CONSTRAINT `APPFK` FOREIGN KEY (`C\"1`) REFERENCES " + quotedDbName + "."
+ quotedTableName + " (`C\"1`)) ENGINE=InnoDB";
+ quotedTableName + " (\"`B`EST`\")) ENGINE=InnoDB";

st1.executeUpdate(sql);

// 1. Create table
Expand Down
59 changes: 32 additions & 27 deletions src/test/java/testsuite/x/devapi/TableInsertTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import org.junit.jupiter.api.Test;

import com.mysql.cj.ServerVersion;
import com.mysql.cj.xdevapi.DbDoc;
import com.mysql.cj.xdevapi.DbDocImpl;
import com.mysql.cj.xdevapi.InsertResult;
Expand Down Expand Up @@ -266,9 +267,7 @@ public void testGetAutoIncrementValue() {
InsertResult res = null;
try {
sqlUpdate("drop table if exists qatable1");
sqlUpdate("drop table if exists qatable2");
sqlUpdate("create table qatable1 (x bigint auto_increment primary key,y double)");
sqlUpdate("create table qatable2 (x double auto_increment primary key,y bigint)");

table = this.schema.getTable("qatable1", true);
res = table.insert("y").values(101.1).execute();
Expand Down Expand Up @@ -303,31 +302,37 @@ public void testGetAutoIncrementValue() {
assertEquals(9223372036854775803L, (long) res.getAutoIncrementValue());
assertEquals(1L, res.getAffectedItemsCount());

table = this.schema.getTable("qatable2");
res = table.insert("y").values(101.1).execute();
assertEquals(1L, (long) res.getAutoIncrementValue());
assertEquals(1L, res.getAffectedItemsCount());

res = table.insert("y").values(102.1).values(103.1).values(104.1).execute();
assertEquals(2L, (long) res.getAutoIncrementValue());
assertEquals(3L, res.getAffectedItemsCount());

row = new HashMap<>();
row.put("y", expr("concat('1','05.1')"));

res = table.insert(row).execute();
assertEquals(5L, (long) res.getAutoIncrementValue());
assertEquals(1L, res.getAffectedItemsCount());

this.session.sql("ALTER TABLE qatable2 AUTO_INCREMENT = 4294967299000000").execute();
res = table.insert("y").values(102.1).values(103.1).values(104.1).execute();
assertEquals(4294967299000000L, (long) res.getAutoIncrementValue());
assertEquals(3L, res.getAffectedItemsCount());

this.session.sql("ALTER TABLE qatable2 AUTO_INCREMENT = 4294967299000000").execute();
res = table.insert(row).execute();
assertEquals(4294967299000003L, (long) res.getAutoIncrementValue());
assertEquals(1L, res.getAffectedItemsCount());
if (!mysqlVersionMeetsMinimum(ServerVersion.parseVersion("8.4.0"))) {
// AUTO_INCREMENT for DOUBLE removed in MySQL 8.4.0.
sqlUpdate("drop table if exists qatable2");
sqlUpdate("create table qatable2 (x double auto_increment primary key,y bigint)");

table = this.schema.getTable("qatable2");
res = table.insert("y").values(101.1).execute();
assertEquals(1L, (long) res.getAutoIncrementValue());
assertEquals(1L, res.getAffectedItemsCount());

res = table.insert("y").values(102.1).values(103.1).values(104.1).execute();
assertEquals(2L, (long) res.getAutoIncrementValue());
assertEquals(3L, res.getAffectedItemsCount());

row = new HashMap<>();
row.put("y", expr("concat('1','05.1')"));

res = table.insert(row).execute();
assertEquals(5L, (long) res.getAutoIncrementValue());
assertEquals(1L, res.getAffectedItemsCount());

this.session.sql("ALTER TABLE qatable2 AUTO_INCREMENT = 4294967299000000").execute();
res = table.insert("y").values(102.1).values(103.1).values(104.1).execute();
assertEquals(4294967299000000L, (long) res.getAutoIncrementValue());
assertEquals(3L, res.getAffectedItemsCount());

this.session.sql("ALTER TABLE qatable2 AUTO_INCREMENT = 4294967299000000").execute();
res = table.insert(row).execute();
assertEquals(4294967299000003L, (long) res.getAutoIncrementValue());
assertEquals(1L, res.getAffectedItemsCount());
}
} finally {
sqlUpdate("drop table if exists qatable1");
sqlUpdate("drop table if exists qatable2");
Expand Down

0 comments on commit 6fbbd21

Please sign in to comment.