Skip to content
Snippets Groups Projects
Commit d6089a81 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

Merge branch 'dev' into f-doc-inheritance

parents e9a5e30d 9619d462
No related branches found
No related tags found
1 merge request!22DOC: Update and extend importance and inheritance
Pipeline #9231 passed
...@@ -67,8 +67,8 @@ MYSQL_DATABASE_NAME=caosdb ...@@ -67,8 +67,8 @@ MYSQL_DATABASE_NAME=caosdb
MYSQL_USER_NAME=caosdb MYSQL_USER_NAME=caosdb
# Password for the user # Password for the user
MYSQL_USER_PASSWORD=caosdb MYSQL_USER_PASSWORD=caosdb
# Schema of mysql procedures and tables which is required by this CaosDB instance. The versioning follows SemVer 2.0 specs. # Schema of mysql procedures and tables which is required by this CaosDB instance
MYSQL_SCHEMA_VERSION=v4.0.0 MYSQL_SCHEMA_VERSION=v5.0
# -------------------------------------------------- # --------------------------------------------------
......
# Glossary # Glossary
## Valid ID
The ID of an existing entity. It is by definition unique among the IDs of all existing entities and is a positive integer."
## Valid Unique Existing Name ## Valid Unique Existing Name
A name of an exiting entity which is unique among the names of all existing entities. A name of an exiting entity which is unique among the names of all existing entities.
...@@ -8,10 +12,6 @@ A name of an exiting entity which is unique among the names of all existing enti ...@@ -8,10 +12,6 @@ A name of an exiting entity which is unique among the names of all existing enti
A name of a to-be-inserted/updated entity _e_ which is unique among the names of all other entities that are to be inserted or updated along with the entity _e_. A name of a to-be-inserted/updated entity _e_ which is unique among the names of all other entities that are to be inserted or updated along with the entity _e_.
## Valid ID
The ID of an existing entity. It is by definition unique among the IDs of all existing entities and is a positive integer."
## Valid Unique Temporary ID ## Valid Unique Temporary ID
The negative integer ID of a to-be-inserted entity _e_ which is unique among the ids of all other entities that are to be inserted along with the entity _e_. The negative integer ID of a to-be-inserted entity _e_ which is unique among the ids of all other entities that are to be inserted along with the entity _e_.
...@@ -7,7 +7,7 @@ Basic concepts of the CaosDB server ...@@ -7,7 +7,7 @@ Basic concepts of the CaosDB server
:glob: :glob:
Data Model <Data-Model> Data Model <Data-Model>
Permissions permissions
roles roles
The CaosDB server provides the HTTP API resources to users and client libraries. It uses a plain The CaosDB server provides the HTTP API resources to users and client libraries. It uses a plain
......
File moved
...@@ -175,25 +175,69 @@ class DatabaseConnectionPool { ...@@ -175,25 +175,69 @@ class DatabaseConnectionPool {
logger.debug("####################"); logger.debug("####################");
} }
/**
* Check the version of the SQL server's database.
*
* <p>Current behaviour: Major versions must match and the database's minor version must be at
* least the expected minor version as defined in {@link
* ServerProperties.KEY_MYSQL_SCHEMA_VERSION}.
*
* <p>@todo Patch versions are not handled yet.
*/
private static void checkVersion(final Connection con) private static void checkVersion(final Connection con)
throws SQLException, ConnectionException, CaosDBException { throws SQLException, ConnectionException, CaosDBException {
try { try {
final String[] expected_version =
CaosDBServer.getServerProperty(ServerProperties.KEY_MYSQL_SCHEMA_VERSION)
.toLowerCase()
.split("\\.");
final String expected_major = expected_version[0];
final String expected_minor = expected_version[1];
con.setReadOnly(false); con.setReadOnly(false);
final PreparedStatement prepareStatement = con.prepareStatement("SELECT CaosDBVersion()"); final PreparedStatement prepared = con.prepareStatement("SELECT CaosDBVersion()");
try { try {
final ResultSet executeQuery = prepareStatement.executeQuery(); final ResultSet executeQuery = prepared.executeQuery();
if (executeQuery.next()) { if (executeQuery.next()) {
final String v_e =
CaosDBServer.getServerProperty(ServerProperties.KEY_MYSQL_SCHEMA_VERSION) final String actual_version = executeQuery.getString(1).toLowerCase();
.toLowerCase(); final String[] actual_version_split = actual_version.split("\\.");
final String v_a = executeQuery.getString(1).toLowerCase(); final String actual_major = actual_version_split[0];
if (!Objects.equal(v_a, v_e)) { final String actual_minor = actual_version_split[1];
logger.error(
"Version of the MySQL schema is wrong.\n\tExpected: {}\n\tActual: {}n\nPlease upgrade the mysql backend.\n\n", if (!Objects.equal(actual_major, expected_major)) {
v_e, if (Integer.parseInt(actual_major.replace("v", ""))
v_a); < Integer.parseInt(expected_major.replace("v", ""))) {
logger.error(
"Version of the MySQL/MariaDB schema is incompatible.\n\tExpected: {}.{}\n\tActual: {}\nPlease upgrade the MySQL backend.\n\n",
expected_major,
expected_minor,
actual_version);
} else {
logger.error(
"Version of the MySQL/MariaDB schema is incompatible.\n\tExpected: {}.{}\n\tActual: {}\nPlease upgrade the CaosDB server.\n\n",
expected_major,
expected_minor,
actual_version);
}
System.exit(1); System.exit(1);
} }
if (!Objects.equal(actual_minor, expected_minor)) {
if (Integer.parseInt(actual_minor) < Integer.parseInt(expected_minor)) {
logger.error(
"Version of the MySQL/MariaDB schema is incompatible.\n\tExpected: {}.{}\n\tActual: {}\nPlease upgrade the MySQL backend.\n\n",
expected_major,
expected_minor,
actual_version);
System.exit(1);
}
}
} else {
logger.error(
"Version of the MySQL schema could not be determined. This probably means that the version is too old.\n\tExpected: {}.{}\n\tActual: unknown\nPlease upgrade the MySQL backend.\n\n",
expected_major,
expected_minor);
System.exit(1);
} }
} catch (final SQLException e) { } catch (final SQLException e) {
logger.error("Could not check the version of the MySQL schema.", e); logger.error("Could not check the version of the MySQL schema.", e);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment