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

WIP: EHN: version history

parent 5fb99009
No related branches found
No related tags found
No related merge requests found
...@@ -330,7 +330,8 @@ END; ...@@ -330,7 +330,8 @@ END;
DROP PROCEDURE IF EXISTS db_2_0.get_version_history // DROP PROCEDURE IF EXISTS db_2_0.get_version_history //
/** /**
* Select version timestamps of an entity. * Select the complete transaction history of an entity (Who created which
* version and when).
* *
* Parameters * Parameters
* ---------- * ----------
...@@ -339,8 +340,8 @@ DROP PROCEDURE IF EXISTS db_2_0.get_version_history // ...@@ -339,8 +340,8 @@ DROP PROCEDURE IF EXISTS db_2_0.get_version_history //
* *
* Selects * Selects
* ------- * -------
* Tuples (child, parent, child_seconds, child_nanos). `child` and `parent` are * Tuples (child, parent, child_seconds, child_nanos, child_username,
* version IDs. * child_realm). `child` and `parent` are version IDs.
*/ */
CREATE PROCEDURE db_2_0.get_version_history( CREATE PROCEDURE db_2_0.get_version_history(
in EntityID INT UNSIGNED) in EntityID INT UNSIGNED)
...@@ -349,7 +350,9 @@ BEGIN ...@@ -349,7 +350,9 @@ BEGIN
SELECT c.version AS child, SELECT c.version AS child,
NULL as parent, NULL as parent,
t.seconds AS child_seconds, t.seconds AS child_seconds,
t.nanos AS child_nanos t.nanos AS child_nanos,
t.username AS child_username,
t.realm AS child_realm
FROM entity_version AS c INNER JOIN transactions as t FROM entity_version AS c INNER JOIN transactions as t
ON ( c.srid = t.srid ) ON ( c.srid = t.srid )
WHERE c.entity_id = EntityID WHERE c.entity_id = EntityID
...@@ -363,7 +366,9 @@ BEGIN ...@@ -363,7 +366,9 @@ BEGIN
UNION SELECT c.version AS child, UNION SELECT c.version AS child,
p.version AS parent, p.version AS parent,
t.seconds AS child_seconds, t.seconds AS child_seconds,
t.nanos AS child_nanos t.nanos AS child_nanos,
t.username AS child_username,
t.realm AS child_realm
FROM entity_version AS p FROM entity_version AS p
INNER JOIN entity_version as c INNER JOIN entity_version as c
INNER JOIN transactions AS t INNER JOIN transactions AS t
......
...@@ -53,8 +53,6 @@ retrieveEntityBody: BEGIN ...@@ -53,8 +53,6 @@ retrieveEntityBody: BEGIN
DECLARE FileHash VARCHAR(255) DEFAULT NULL; DECLARE FileHash VARCHAR(255) DEFAULT NULL;
DECLARE DatatypeID INT UNSIGNED DEFAULT NULL; DECLARE DatatypeID INT UNSIGNED DEFAULT NULL;
DECLARE CollectionName VARCHAR(255) DEFAULT NULL; DECLARE CollectionName VARCHAR(255) DEFAULT NULL;
DECLARE VersionSeconds BIGINT UNSIGNED DEFAULT NULL;
DECLARE VersionNanos INT(10) UNSIGNED DEFAULT NULL;
DECLARE IsHead BOOLEAN DEFAULT TRUE; DECLARE IsHead BOOLEAN DEFAULT TRUE;
DECLARE IVersion INT UNSIGNED DEFAULT NULL; DECLARE IVersion INT UNSIGNED DEFAULT NULL;
...@@ -70,14 +68,6 @@ retrieveEntityBody: BEGIN ...@@ -70,14 +68,6 @@ retrieveEntityBody: BEGIN
SELECT get_head_version(EntityID) = Version INTO IsHead; SELECT get_head_version(EntityID) = Version INTO IsHead;
END IF; END IF;
SELECT t.seconds, t.nanos
INTO VersionSeconds, VersionNanos
FROM entity_version AS e
INNER JOIN transactions AS t
ON ( e.srid = t.srid )
WHERE e.entity_id = EntityID
AND e.version = Version;
IF IsHead IS FALSE THEN IF IsHead IS FALSE THEN
SET IVersion=get_iversion(EntityID, Version); SET IVersion=get_iversion(EntityID, Version);
...@@ -136,9 +126,7 @@ retrieveEntityBody: BEGIN ...@@ -136,9 +126,7 @@ retrieveEntityBody: BEGIN
FilePath AS FilePath, FilePath AS FilePath,
FileHash AS FileHash, FileHash AS FileHash,
(SELECT acl FROM entity_acl AS a WHERE a.id = e.acl) AS ACL, (SELECT acl FROM entity_acl AS a WHERE a.id = e.acl) AS ACL,
Version AS Version, Version AS Version
VersionSeconds AS VersionSeconds,
VersionNanos AS VersionNanos
FROM archive_entities AS e FROM archive_entities AS e
WHERE e.id = EntityID WHERE e.id = EntityID
AND e._iversion = IVersion AND e._iversion = IVersion
...@@ -187,9 +175,7 @@ retrieveEntityBody: BEGIN ...@@ -187,9 +175,7 @@ retrieveEntityBody: BEGIN
FilePath AS FilePath, FilePath AS FilePath,
FileHash AS FileHash, FileHash AS FileHash,
(SELECT acl FROM entity_acl AS a WHERE a.id = e.acl) AS ACL, (SELECT acl FROM entity_acl AS a WHERE a.id = e.acl) AS ACL,
Version AS Version, Version AS Version
VersionSeconds AS VersionSeconds,
VersionNanos AS VersionNanos
FROM entities e WHERE id = EntityID LIMIT 1; FROM entities e WHERE id = EntityID LIMIT 1;
END; END;
// //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment