Skip to content
Snippets Groups Projects
Verified Commit 7d39e18d authored by Timm Fitschen's avatar Timm Fitschen
Browse files

BUG: Broken FIND {id}

parent 43bd98aa
Branches
Tags
2 merge requests!20BUG: Broken FIND {id},!11DRAFT: file system cleanup
Pipeline #42467 failed
......@@ -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.
......
#!/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
......@@ -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;
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment