Skip to content
Snippets Groups Projects
Commit 3ceebfec authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

Merge branch 'f-mariadb-48' into 'dev'

F mariadb 48

See merge request !21
parents 65f34f84 1dd62a9a
Branches
Tags
2 merge requests!21F mariadb 48,!11DRAFT: file system cleanup
Pipeline #42769 failed
......@@ -5,12 +5,25 @@ 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).
## [Unreleased, upcomming 6.1.0] ##
## [Unreleased, upcomming 7.0.0] ##
### Added ###
### Changed ###
* Change signature of procedure `insertEntityDataType`: expect the data type ID
instead of the name.
* Change result set of procedure `retrieveEntity`: Rename column `Datatype` to
`DatatypeName` and add column `DatatypeID`.
* Change result set of procedure `retrieveOverrides`: Rename column
`type_override` to `type_name_override` and add `type_id_override`.
* Change signature of procedure `updateEntity`: expect the data type ID instead
to the name.
* Internal ids, when returned by `retrieveEntityProperties`,
`registerReplacementIds`, or `retrieveOverrides`, are prefixed by a special
character which serves as a ephemeral marker. Currently this is `$` but this
may change in the future if there is a more suitable candidate.
### Deprecated ###
* MySQL Support. Last version which is known to work well with LinkAhead is MySQL 5.7.36
......@@ -19,6 +32,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ###
* Unknown Server Error when inserting an Entity.
[linkahead-mariadbbackend#48](https://gitlab.indiscale.com/caosdb/src/caosdb-mysqlbackend/-/issues/48).
* Fix broken `initEntity` procedure (and change the first parameters type from
INT UNSIGNED to VARCHAR(255) which is non-breaking).
......@@ -30,7 +45,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Old passwords table is removed from dumps where it still exists.
## [6.0.0 2023-10-17] ##
>>>>>>> dev
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.
......
......@@ -28,16 +28,16 @@ DELIMITER //
* ----------
* PropertyID : VARCHAR(255)
* The property id.
* DataType : VARCHAR(255)
* The data type, e.g. "DOUBLE", "Person"
* DataTypeID : VARCHAR(255)
* The data type id (not the name!)
*/
CREATE PROCEDURE db_5_0.insertEntityDataType(in PropertyID VARCHAR(255), in DataType VARCHAR(255))
CREATE PROCEDURE db_5_0.insertEntityDataType(in PropertyID VARCHAR(255), in DataTypeID VARCHAR(255))
BEGIN
DECLARE InternalPropertyID INT UNSIGNED DEFAULT NULL;
SELECT internal_id INTO InternalPropertyID FROM entity_ids WHERE id=PropertyID;
INSERT INTO data_type (domain_id, entity_id, property_id, datatype) SELECT 0, 0, InternalPropertyID, ( SELECT entity_id FROM name_data WHERE domain_id = 0 AND property_id = 20 AND value = DataType LIMIT 1);
INSERT INTO data_type (domain_id, entity_id, property_id, datatype) SELECT 0, 0, InternalPropertyID, ( SELECT internal_id FROM entity_ids WHERE id = DataTypeID);
END;
......
......@@ -76,9 +76,20 @@ BEGIN
DECLARE InternalEntityID INT UNSIGNED DEFAULT NULL;
DECLARE InternalDomainID INT UNSIGNED DEFAULT 0;
SELECT temp.internal_id INTO InternalDomainID FROM (SELECT internal_id AS internal_id FROM entity_ids WHERE id = DomainID UNION SELECT DomainID AS internal_id) AS temp LIMIT 1;
SELECT temp.internal_id INTO InternalEntityID FROM (SELECT internal_id AS internal_id FROM entity_ids WHERE id = EntityID UNION SELECT EntityID AS internal_id) AS temp LIMIT 1;
SELECT temp.internal_id INTO InternalPropertyID FROM (SELECT internal_id AS internal_id FROM entity_ids WHERE id = PropertyID UNION SELECT PropertyID AS internal_id) AS temp LIMIT 1;
SELECT internal_id INTO InternalDomainID FROM entity_ids WHERE id = DomainID;
-- When DomainID != 0 the EntityID could possibly be a 'replacement id'
-- which are internal ids by definition (and do not have external
-- equivalents).
IF LOCATE("$", EntityID) = 1 THEN
SET InternalEntityID=SUBSTRING(EntityID, 2);
ELSE
SELECT internal_id INTO InternalEntityID FROM entity_ids WHERE id = EntityID;
END IF;
IF LOCATE("$", PropertyID) = 1 THEN
SET InternalPropertyID=SUBSTRING(PropertyID, 2);
ELSE
SELECT internal_id INTO InternalPropertyID FROM entity_ids WHERE id = PropertyID;
END IF;
CASE Datatable
WHEN 'double_data' THEN
......@@ -109,8 +120,10 @@ BEGIN
SELECT 0 from `ReferenceValueIVersion_WAS_NULL`;
END IF;
ELSEIF LOCATE("$", PropertyValue) = 1 THEN
SET ReferenceValue = SUBSTRING(PropertyValue, 2);
ELSE
SELECT temp.internal_id INTO ReferenceValue FROM (SELECT internal_id AS internal_id FROM entity_ids WHERE id = PropertyValue UNION SELECT PropertyValue AS internal_id) AS temp LIMIT 1;
SELECT internal_id INTO ReferenceValue FROM entity_ids WHERE id = PropertyValue;
END IF;
......
......@@ -36,7 +36,7 @@ BEGIN
SET ED = ED + 1;
END WHILE;
SELECT e.id as ReplacementID FROM entities AS e WHERE e.Role='_REPLACEMENT' and e.id!=0;
SELECT CONCAT("$", e.id) as ReplacementID FROM entities AS e WHERE e.Role='_REPLACEMENT' and e.id!=0;
END;
//
......
......@@ -42,8 +42,9 @@ drop procedure if exists db_5_0.retrieveEntity //
*
* ResultSet
* ---------
* Tuple of (Datatype, Collection, EntityID, EntityName, EntityDesc,
* EntityRole, FileSize, FilePath, FileHash, ACL, Version)
* Tuple of (DatatypeID, DatatypeName, Collection, EntityID, EntityName,
* EntityDesc, EntityRole, FileSize, FilePath, FileHash, ACL,
* Version)
*/
create procedure db_5_0.retrieveEntity(
in EntityID VARCHAR(255),
......@@ -52,7 +53,8 @@ retrieveEntityBody: BEGIN
DECLARE FilePath VARCHAR(255) DEFAULT NULL;
DECLARE FileSize VARCHAR(255) DEFAULT NULL;
DECLARE FileHash VARCHAR(255) DEFAULT NULL;
DECLARE DatatypeID INT UNSIGNED DEFAULT NULL;
DECLARE DatatypeID VARCHAR(255) DEFAULT NULL;
DECLARE InternalDatatypeID INT UNSIGNED DEFAULT NULL;
DECLARE CollectionName VARCHAR(255) DEFAULT NULL;
DECLARE IsHead BOOLEAN DEFAULT TRUE;
DECLARE IVersion INT UNSIGNED DEFAULT NULL;
......@@ -94,7 +96,7 @@ retrieveEntityBody: BEGIN
LIMIT 1;
SELECT datatype
INTO DatatypeID
INTO InternalDatatypeID
FROM archive_data_type
WHERE domain_id = 0
AND entity_id = 0
......@@ -116,10 +118,10 @@ retrieveEntityBody: BEGIN
( SELECT value FROM
( SELECT value FROM name_data
WHERE domain_id = 0
AND entity_ID = DatatypeID
AND entity_id = InternalDatatypeID
AND property_id = 20
UNION SELECT DatatypeID AS value
) AS tmp LIMIT 1 ) AS Datatype,
) AS tmp LIMIT 1 ) AS DatatypeName,
( SELECT id FROM entity_ids WHERE internal_id=InternalDatatypeID ) AS DatatypeID,
CollectionName AS Collection,
EntityID AS EntityID,
( SELECT value FROM archive_name_data
......@@ -152,7 +154,7 @@ retrieveEntityBody: BEGIN
WHERE file_id = InternalEntityID
LIMIT 1;
SELECT dt.datatype INTO DatatypeID
SELECT dt.datatype INTO InternalDatatypeID
FROM data_type as dt
WHERE dt.domain_id=0
AND dt.entity_id=0
......@@ -169,8 +171,9 @@ retrieveEntityBody: BEGIN
SELECT
( SELECT value FROM name_data
WHERE domain_id = 0
AND entity_id = DatatypeID
AND property_id = 20 LIMIT 1 ) AS Datatype,
AND entity_id = InternalDatatypeID
AND property_id = 20 LIMIT 1 ) AS DatatypeName,
( SELECT id FROM entity_ids WHERE internal_id=InternalDatatypeID ) AS DatatypeID,
CollectionName AS Collection,
EntityID AS EntityID,
( SELECT value FROM name_data
......
......@@ -41,7 +41,8 @@ delimiter //
* collection_override, # e.g. LIST
* name_override, # the name
* desc_override, # the description
* type_override, # the datatype, e.g. DOUBLE
* type_name_override, # the datatype, e.g. DOUBLE
* type_id_override, # data type id.
* entity_id, # same as input EntityID
* InternalPropertyID, # internal property id, to be used when property_id
* # is NULL because a replacement is used.
......@@ -60,11 +61,12 @@ retrieveOverridesBody: BEGIN
-- When DomainID != 0 the EntityID could possibly be a 'replacement id'
-- which are internal ids by definition (and do not have external
-- equivalents). That's why we do the UNION here, falling back to the
-- EntityID.
SELECT temp.internal_id INTO InternalEntityID
FROM (SELECT internal_id AS internal_id FROM
entity_ids WHERE id = EntityID UNION SELECT EntityID AS internal_id) AS temp LIMIT 1;
-- equivalents).
IF LOCATE("$", EntityID) = 1 THEN
SET InternalEntityID=SUBSTRING(EntityID, 2);
ELSE
SELECT internal_id INTO InternalEntityID FROM entity_ids WHERE id = EntityID;
END IF;
-- DomainID != 0 are always normal (i.e. external) Entity ids.
SELECT internal_id INTO InternalDomainID from entity_ids WHERE id = DomainID;
......@@ -94,9 +96,10 @@ retrieveOverridesBody: BEGIN
NULL AS collection_override,
name AS name_override,
NULL AS desc_override,
NULL AS type_override,
NULL AS type_name_override,
NULL AS type_id_override,
EntityID AS entity_id,
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id
FROM archive_name_overrides
WHERE domain_id = InternalDomainID
......@@ -110,9 +113,10 @@ retrieveOverridesBody: BEGIN
NULL AS collection_override,
NULL AS name_override,
description AS desc_override,
NULL AS type_override,
NULL AS type_name_override,
NULL AS type_id_override,
EntityID AS entity_id,
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id
FROM archive_desc_overrides
WHERE domain_id = InternalDomainID
......@@ -126,13 +130,14 @@ retrieveOverridesBody: BEGIN
NULL AS collection_override,
NULL AS name_override,
NULL AS desc_override,
IFNULL((SELECT value FROM name_data
(SELECT value FROM name_data
WHERE domain_id = 0
AND entity_id = datatype
AND property_id = 20
LIMIT 1), datatype) AS type_override,
LIMIT 1) AS type_name_override,
(SELECT id FROM entity_ids WHERE internal_id = datatype) AS type_id_override,
EntityID AS entity_id,
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id
FROM archive_data_type
WHERE domain_id = InternalDomainID
......@@ -146,9 +151,10 @@ retrieveOverridesBody: BEGIN
collection AS collection_override,
NULL AS name_override,
NULL AS desc_override,
NULL AS type_override,
NULL AS type_name_override,
NULL AS type_id_override,
EntityID AS entity_id,
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id
FROM archive_collection_type
WHERE domain_id = InternalDomainID
......@@ -163,9 +169,10 @@ retrieveOverridesBody: BEGIN
NULL AS collection_override,
name AS name_override,
NULL AS desc_override,
NULL AS type_override,
NULL AS type_name_override,
NULL AS type_id_override,
EntityID AS entity_id,
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id
FROM name_overrides
WHERE domain_id = InternalDomainID
......@@ -177,9 +184,10 @@ retrieveOverridesBody: BEGIN
NULL AS collection_override,
NULL AS name_override,
description AS desc_override,
NULL AS type_override,
NULL AS type_name_override,
NULL AS type_id_override,
EntityID AS entity_id,
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id
FROM desc_overrides
WHERE domain_id = InternalDomainID
......@@ -191,12 +199,13 @@ retrieveOverridesBody: BEGIN
NULL AS collection_override,
NULL AS name_override,
NULL AS desc_override,
IFNULL((SELECT value FROM name_data
(SELECT value FROM name_data
WHERE domain_id = 0
AND entity_ID = datatype
AND property_id = 20 LIMIT 1), datatype) AS type_override,
AND property_id = 20 LIMIT 1) AS type_name_override,
(SELECT id FROM entity_ids WHERE internal_id = datatype) AS type_id_override,
EntityID AS entity_id,
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id
FROM data_type
WHERE domain_id = InternalDomainID
......@@ -208,9 +217,10 @@ retrieveOverridesBody: BEGIN
collection AS collection_override,
NULL AS name_override,
NULL AS desc_override,
NULL AS type_override,
NULL AS type_name_override,
NULL AS type_id_override,
EntityID AS entity_id,
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id
FROM collection_type
WHERE domain_id = InternalDomainID
......
......@@ -66,9 +66,12 @@ retrieveEntityPropertiesBody: BEGIN
-- When DomainID != 0 the EntityID could possibly be a 'replacement id'
-- which are internal ids by definition (and do not have external
-- equivalents). That's why we do the UNION here, falling back to the
-- EntityID.
SELECT temp.internal_id INTO InternalEntityID FROM (SELECT internal_id AS internal_id FROM entity_ids WHERE id = EntityID UNION SELECT EntityID AS internal_id) AS temp LIMIT 1;
-- equivalents).
IF LOCATE("$", EntityID) = 1 THEN
SET InternalEntityID=SUBSTRING(EntityID, 2);
ELSE
SELECT internal_id INTO InternalEntityID FROM entity_ids WHERE id = EntityID;
END IF;
-- DomainID != 0 are always normal (i.e. external) Entity ids.
SELECT internal_id INTO InternalDomainID from entity_ids WHERE id = DomainID;
......@@ -95,7 +98,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- double properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue,
status AS PropertyStatus,
......@@ -109,7 +112,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- integer properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue,
status AS PropertyStatus,
......@@ -123,7 +126,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- date properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
CONCAT(value, '.NULL.NULL') AS PropertyValue,
status AS PropertyStatus,
......@@ -137,7 +140,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- datetime properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
CONCAT(value, 'UTC', IF(value_ns IS NULL, '', value_ns))
AS PropertyValue,
......@@ -152,7 +155,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- text properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue,
status AS PropertyStatus,
......@@ -166,7 +169,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- enum properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue,
status AS PropertyStatus,
......@@ -180,11 +183,11 @@ retrieveEntityPropertiesBody: BEGIN
#-- reference properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
IF(value_iversion IS NULL,
IF(status = "REPLACEMENT",
value,
CONCAT("$", value),
( SELECT id FROM entity_ids WHERE internal_id = value )),
-- make it "value@version" if necessary
CONCAT(
......@@ -202,7 +205,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- null properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
NULL AS PropertyValue,
status AS PropertyStatus,
......@@ -216,7 +219,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- name properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue,
status AS PropertyStatus,
......@@ -233,7 +236,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- double properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue,
status AS PropertyStatus,
......@@ -246,7 +249,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- integer properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue,
status AS PropertyStatus,
......@@ -259,7 +262,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- date properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
CONCAT(value, '.NULL.NULL') AS PropertyValue,
status AS PropertyStatus,
......@@ -272,7 +275,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- datetime properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
CONCAT(value, 'UTC', IF(value_ns IS NULL, '', value_ns))
AS PropertyValue,
......@@ -286,7 +289,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- text properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue,
status AS PropertyStatus,
......@@ -299,7 +302,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- enum properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue,
status AS PropertyStatus,
......@@ -312,11 +315,11 @@ retrieveEntityPropertiesBody: BEGIN
#-- reference properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
IF(value_iversion IS NULL,
IF(status = "REPLACEMENT",
value,
CONCAT("$", value),
( SELECT id FROM entity_ids WHERE internal_id = value )),
-- make it "value@version" if necessary
CONCAT(
......@@ -333,7 +336,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- null properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
NULL AS PropertyValue,
status AS PropertyStatus,
......@@ -346,7 +349,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- name properties
SELECT
property_id AS InternalPropertyID,
CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue,
status AS PropertyStatus,
......
......@@ -35,7 +35,7 @@ CREATE PROCEDURE db_5_0.updateEntity(
in EntityName VARCHAR(255),
in EntityDescription TEXT,
in EntityRole VARCHAR(255),
in Datatype VARCHAR(255),
in DatatypeID VARCHAR(255),
in Collection VARCHAR(255),
in ACL VARBINARY(65525))
BEGIN
......@@ -114,11 +114,10 @@ BEGIN
DELETE FROM collection_type
WHERE domain_id=0 AND entity_id=0 AND property_id=InternalEntityID;
IF Datatype IS NOT NULL THEN
IF DatatypeID IS NOT NULL THEN
INSERT INTO data_type (domain_id, entity_id, property_id, datatype)
SELECT 0, 0, InternalEntityID,
( SELECT entity_id FROM name_data WHERE domain_id = 0
AND property_id = 20 AND value = Datatype LIMIT 1 );
( SELECT internal_id FROM entity_ids WHERE id = DatatypeID );
IF Collection IS NOT NULL THEN
INSERT INTO collection_type (domain_id, entity_id, property_id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment