Fixed MysqlDataTruncation error when logging large bundles (fixes #799)

This commit is contained in:
Intelli committed 2026-05-20 18:40:37 -06:00
1 parent ec96019bc2
commit 7f7de03f54
3 files changed
+52 -2

No files matched your search

@@ -365,11 +365,11 @@ public class Database extends Queue {
// Container
index = ", INDEX(wid,x,z,time), INDEX(user,time), INDEX(type,time)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "container(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, user int, wid int, x int, y int, z int, type int, data int, amount int, metadata blob, action tinyint, rolled_back tinyint" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "container(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, user int, wid int, x int, y int, z int, type int, data int, amount int, metadata mediumblob, action tinyint, rolled_back tinyint" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
// Item
index = ", INDEX(wid,x,z,time), INDEX(user,time), INDEX(type,time)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "item(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, user int, wid int, x int, y int, z int, type int, data blob, amount int, action tinyint, rolled_back tinyint" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "item(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, user int, wid int, x int, y int, z int, type int, data mediumblob, amount int, action tinyint, rolled_back tinyint" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
// Database lock
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "database_lock(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),status tinyint,time int) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
@@ -21,6 +21,10 @@ public class __2_24_0 {
e.printStackTrace();
return false;
}
if (!updateItemMetadataColumns(statement)) {
return false;
}
}
}
catch (Exception e) {
@@ -31,4 +35,26 @@ public class __2_24_0 {
return true;
}
protected static boolean updateItemMetadataColumns(Statement statement) {
if (Config.getGlobal().MYSQL) {
return modifyColumn(statement, ConfigHandler.prefix + "container", "ALTER TABLE " + ConfigHandler.prefix + "container MODIFY metadata MEDIUMBLOB") &&
modifyColumn(statement, ConfigHandler.prefix + "item", "ALTER TABLE " + ConfigHandler.prefix + "item MODIFY data MEDIUMBLOB");
}
return true;
}
private static boolean modifyColumn(Statement statement, String table, String query) {
try {
statement.executeUpdate(query);
return true;
}
catch (Exception e) {
Chat.console(Phrase.build(Phrase.PATCH_SKIP_UPDATE, table, Selector.FIRST, Selector.FIRST));
e.printStackTrace();
}
return false;
}
}
@@ -0,0 +1,24 @@
package net.coreprotect.patch.script;
import java.sql.Statement;
import net.coreprotect.patch.Patch;
public class __2_24_1 {
protected static boolean patch(Statement statement) {
try {
Integer[] last_version = Patch.getDatabaseVersion(statement.getConnection(), true);
if (last_version[0] == 2 && last_version[1] == 24 && last_version[2] == 0) {
return __2_24_0.updateItemMetadataColumns(statement);
}
}
catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
}