diff --git a/CHANGELOG.md b/CHANGELOG.md index 989048b0bb0d95eed7bab913a4a6927e79ecb297..de747924e78a581ae372f40c6e2fa2e252668d9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,24 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [6.0.0 2023-10-17] ## +## [Unreleased, upcomming 6.1.0] ## + +### Added ### + +### Changed ### + +### Deprecated ### + +### Removed ### + +### Fixed ### + +* Fix broken `initEntity` procedure (and change the first parameters type from + INT UNSIGNED to VARCHAR(255) which is non-breaking). + +### Security ### + +## [6.0.0] - 2023-10-17 ## This is a major update. Switching from integer ids for internal and external use to string ids for the external use while keeping the old integer ids for internal use. diff --git a/patches/patch20231018-6.1.0/patch.sh b/patches/patch20231018-6.1.0/patch.sh new file mode 100755 index 0000000000000000000000000000000000000000..c5c126142f19f4db66ca804f9f2fa82a3b7ebedd --- /dev/null +++ b/patches/patch20231018-6.1.0/patch.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# This file is a part of the CaosDB Project. +# +# Copyright (C) 2023 IndiScale GmbH <info@indiscale.com> +# Copyright (C) 2023 Timm Fitschen <t.fitschen@indiscale.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# + +# Update mysql schema to version v6.1.0 +# No migration of the schema, updating procedures only + +NEW_VERSION="v6.1.0" +OLD_VERSION="v6.0.0-SNAPSHOT-EXTIDS" + +if [ -z "$UTILSPATH" ]; then + UTILSPATH="../utils" +fi + +. $UTILSPATH/patch_header.sh $* + +check_version $OLD_VERSION + +update_version $NEW_VERSION + +success + diff --git a/procedures/query/initEntity.sql b/procedures/query/initEntity.sql index 65d03b818f68991acabd82890c1730572ecc822c..d63c7773867cb9e5c29bdc4f95cbe866c3b426c4 100644 --- a/procedures/query/initEntity.sql +++ b/procedures/query/initEntity.sql @@ -30,7 +30,7 @@ DELIMITER // * If `versioned` is `TRUE`, also add archived entities (for example if the name was changed in the * past). */ -CREATE PROCEDURE db_5_0.initEntity(in eid INT UNSIGNED, in ename VARCHAR(255), +CREATE PROCEDURE db_5_0.initEntity(in eid VARCHAR(255), in ename VARCHAR(255), in enameLike VARCHAR(255), in enameRegexp VARCHAR(255), in resultset VARCHAR(255), in versioned BOOLEAN) initEntityLabel: BEGIN @@ -78,9 +78,9 @@ initEntityLabel: BEGIN 'INSERT IGNORE INTO `', resultset, IF(versioned, - '` (id, _iversion) SELECT id, _get_head_iversion(id) ', - '` (id) SELECT id '), - 'FROM entities WHERE id=',eid,';'); + '` (id, _iversion) SELECT eids.internal_id, _get_head_iversion(eids.internal_id) ', + '` (id) SELECT eids.internal_id '), + 'FROM entity_ids AS eids WHERE eids.id=',eid,';'); PREPARE initEntityStmt FROM @initEntityStmtStr; EXECUTE initEntityStmt; DEALLOCATE PREPARE initEntityStmt; diff --git a/utils/make_db b/utils/make_db index 071de0a3270fd0e3480cb54bbc692635983bd287..00a9e82724333f3b46a535e20b367c0604d758f0 100755 --- a/utils/make_db +++ b/utils/make_db @@ -132,8 +132,21 @@ name in your .config file " sed "s/db_5_0/$DATABASE_NAME/g" "$INSTALL_SQL_FILE" | $MYSQL_CMD $(get_mysql_args_nodb) } +function sanity_check_dump() { + SQL_FILE="$1" + DETECTED_VERSION="$(grep -A 5 -i 'CREATE.*FUNCTION.*CaosDBVersion' "$SQL_FILE" | grep -o -E -e "v[0-9][^'\"]*")" + echo "[INFO] Detected schema version of the dump: $DETECTED_VERSION" + AFFECTED_VERSION_REGEX='v([3-9]|2[0-9]|2\.1|2\.0\.[23][0-9]|2\.0\.1[6-9])' + passwords_table_should_be_gone=$(echo "$DETECTED_VERSION" | grep -E -e "$AFFECTED_VERSION_REGEX" -c || true) + if [ "$passwords_table_should_be_gone" -gt "0" ] && grep 'CREATE TABLE `passwords`' -c "$SQL_FILE" > /dev/null ; then + echo "[ERROR] Your dump is broken. The 'passwords' table should be gone: $SQL_FILE" + exit 1 + fi +} + # Inserts the dump (arg 1) into the database function restore_db() { + sanity_check_dump $1 SQL_FILE="$1" $MYSQL_CMD $(get_mysql_args) < "$SQL_FILE" cat <<EOF @@ -256,5 +269,6 @@ case $1 in "test-connection") test-connection ;; "install_db") install_db ;; "restore_db") restore_db $2 ;; + "sanity_check_dump") sanity_check_dump $2 ;; *) echo "Unknown action: $1"; exit 32 esac