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

up

parent 746d41ea
Branches
No related tags found
No related merge requests found
version: '3.6'
services:
sqldb:
image: mariadb:10.5
volumes:
- type: volume
source: "caosdb-sqldata"
target: /var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: caosdb1234
networks:
# available on port 3306, host name 'sqldb'
- caosnet
ports:
- 3306:3306
# A well-defined network for caosdb
volumes:
caosdb-sqldata:
networks:
caosnet:
driver: bridge
......@@ -87,18 +87,6 @@ with the then current version of the stored entities.
* Alternatively, to run the tests in a containerized MariaDB instance, run `make test-docker`,
followed by `make test-docker-stop`.
### Running in a Docker Container
You can use `.docker/docker-compose.yml` to start a docker container
(`docker-compose -f .docker/docker-compose.yml up -d`) that runs
mariadb and you can connect to it with
`mariadb -h localhost -P3306 -u caosdb -prandom1234 caosdb`. You need appropriate
settings in `.config`.
Due to [a Bug](https://gitlab.com/linkahead/linkahead-mariadbbackend/-/issues/33)
`MYSQL_CMD="mariadb -h localhost -P3306"` and
`DATABASE_USER_HOST_LIST=%,`
### Troubleshooting
#### MySQL has failing tests
......
......@@ -34,16 +34,13 @@ DELIMITER //
* ----------
*
* versioned : boolean
* If True, sourceSet and targetSet have an _iversion column, otherwise that column will be ignored
* (or only HEAD will be inserted into targetSet).
TODO description of sourceSet and targetSet is insufficient!
* If True, sourceSet and targetSet have an _iversion column, otherwise that column will be
* ignored (or only HEAD will be inserted into targetSet).
*/
CREATE PROCEDURE db_5_0.applyPOV(in sourceSet VARCHAR(255), /* (?) Name of the table that the POV will be applied to. This can be a temporary table. */
in targetSet VARCHAR(255), /* (?) Name of the result table of this POV. */
in propertiesTable VARCHAR(255),
in refIdsTable VARCHAR(255), /* (?) Name of a tmp table that contains all ids of children of the value interpreted as entity */
in refIdsTable VARCHAR(255),
in o CHAR(4), /* The operator for this operation. can be one of:
0 check for "equals NULL"
!0 check for "not NULL"
......@@ -84,19 +81,6 @@ POV_LABEL: BEGIN
DECLARE keepTabl VARCHAR(255) DEFAULT NULL;
DECLARE existence_op VARCHAR(255) DEFAULT "EXISTS";
select NOW(6) into @time;
SET @tmpquery = CONCAT('SELECT * FROM `', refIdsTable, '` into outfile "/tmp/stuff', now(0),'"');
PREPARE stmt FROM @tmpquery;
EXECUTE stmt;
SET @tmpquery2 = CONCAT('insert into povtimes (SELECT now(0), count(*), 0 FROM `', propertiesTable , '`)');
PREPARE stmt2 FROM @tmpquery2;
EXECUTE stmt2;
insert into povtimes (select now(0), "Beginning", timediff(NOW(6),@time) as time_passed);
#-- ######### HINT ##############
#-- first the appropriate statement is created which in the end prepared and executed
#-- #############################
IF o = '->' THEN
#-- special case: pure reference property
call applyRefPOV(sourceSet,targetSet, propertiesTable, refIdsTable, versioned);
......@@ -245,8 +229,6 @@ POV_LABEL: BEGIN
IF o = "!=" AND refIdsTable IS NOT NULL THEN
SET existence_op = "NOT EXISTS";
END IF;
/* select all entities that reference the entity or a child of the
* value interpreted as ID*/
SET sRefData = IF(vText IS NULL,
' UNION ALL SELECT DISTINCT domain_id, entity_id, property_id FROM `reference_data`',
IF(refIdsTable IS NULL,
......@@ -261,9 +243,6 @@ POV_LABEL: BEGIN
END IF;
insert into povtimes (select now(0), "data string assembled", timediff(NOW(6),@time) as time_passed);
#-- create array of statement parts (and replace null with empty string) (?)
SET data = CONCAT('(',sTextData,
IF(sNameData IS NULL, '', sNameData),
IF(sEnumData IS NULL, '', sEnumData),
......@@ -278,10 +257,8 @@ POV_LABEL: BEGIN
call createTmpTable(keepTabl, versioned);
insert into povtimes (select now(0), "created tmptable ", timediff(NOW(6),@time) as time_passed);
IF versioned THEN
#-- generate statement from statement parts
#-- (versioned section)
SET @stmtPOVkeepTblStr = CONCAT(
'INSERT IGNORE INTO `', keepTabl, '` (id, _iversion) SELECT entity_id AS id, _iversion FROM ', data,
' as data', IF(propertiesTable IS NULL, '', CONCAT(
......@@ -322,15 +299,7 @@ POV_LABEL: BEGIN
DEALLOCATE PREPARE stmtPOVkeepTbl;
ELSE
#-- generate statement from statement parts
#-- (unversioned section)
SET @stmtPOVkeepTblStr = CONCAT('INSERT IGNORE INTO `', keepTabl, '` (id)
SELECT DISTINCT entity_id AS id FROM ', data, ' as data',
IF(propertiesTable IS NULL,
'',
/* restrict to properties with one of the appropriate ids
* and where the domain (???) equals the entity*/
CONCAT(' WHERE EXISTS (Select 1 from `', propertiesTable, '` AS prop
WHERE prop.id = data.property_id AND (prop.id2=data.entity_id OR prop.id2=0))')));
SET @stmtPOVkeepTblStr = CONCAT('INSERT IGNORE INTO `', keepTabl, '` (id) SELECT DISTINCT entity_id AS id FROM ', data, ' as data', IF(propertiesTable IS NULL, '', CONCAT(' WHERE EXISTS (Select 1 from `', propertiesTable, '` AS prop WHERE prop.id = data.property_id AND (prop.id2=data.entity_id OR prop.id2=0))')));
SET @stmtPOVStr = CONCAT(
IF(targetSet IS NULL,
......@@ -351,23 +320,19 @@ POV_LABEL: BEGIN
#-- prepare and execute
PREPARE stmt3 FROM @stmtPOVStr;
PREPARE stmtPOVkeepTbl FROM @stmtPOVkeepTblStr;
insert into povtimes (select now(0), "statements prepared ", timediff(NOW(6),@time) as time_passed);
IF vText IS NULL THEN
EXECUTE stmtPOVkeepTbl;
ELSE
SET @vText = vText;
EXECUTE stmtPOVkeepTbl USING @vText, @vText, @vText;
END IF;
insert into povtimes (select now(0), "first execute ", timediff(NOW(6),@time) as time_passed);
EXECUTE stmt3;
insert into povtimes (select now(0), "second execute ", timediff(NOW(6),@time) as time_passed);
DEALLOCATE PREPARE stmt3;
DEALLOCATE PREPARE stmtPOVkeepTbl;
END IF;
SELECT @stmtPOVkeepTblStr as applyPOVStmt1, @stmtPOVStr as applyPOVStmt2, keepTabl as applyPOVIntermediateResultSet;
insert into povtimes (select now(0), "end ", timediff(NOW(6),@time) as time_passed);
END;
//
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment