Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-mysqlbackend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-mysqlbackend
Commits
2d455272
Verified
Commit
2d455272
authored
4 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
add parent_directory column to files table
parent
8c20200a
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!12
DRAFT: ENH: file system: core
Pipeline
#7920
failed
4 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
patches/patch20210219-5.0.0-rc1/patch.sql
+10
-4
10 additions, 4 deletions
patches/patch20210219-5.0.0-rc1/patch.sql
procedures/retrieveEntity.sql
+11
-8
11 additions, 8 deletions
procedures/retrieveEntity.sql
with
21 additions
and
12 deletions
patches/patch20210219-5.0.0-rc1/patch.sql
+
10
−
4
View file @
2d455272
...
...
@@ -9,6 +9,7 @@ ALTER TABLE files ADD UNIQUE (`path`);
ALTER
TABLE
files
ADD
COLUMN
IF
NOT
EXISTS
(
parent_directory
INT
UNSIGNED
DEFAULT
NULL
,
mimetype
VARBINARY
(
255
)
DEFAULT
NULL
,
file_storage_id
VARBINARY
(
255
)
NOT
NULL
DEFAULT
"DEFAULT"
,
file_key
VARBINARY
(
255
)
DEFAULT
NULL
,
...
...
@@ -16,6 +17,7 @@ ALTER TABLE files ADD COLUMN IF NOT EXISTS (
);
ALTER
TABLE
archive_files
ADD
COLUMN
IF
NOT
EXISTS
(
parent_directory
INT
UNSIGNED
DEFAULT
NULL
,
mimetype
VARBINARY
(
255
)
DEFAULT
NULL
,
file_storage_id
VARBINARY
(
255
)
NOT
NULL
DEFAULT
"DEFAULT"
,
file_key
VARBINARY
(
255
)
DEFAULT
NULL
,
...
...
@@ -44,6 +46,7 @@ BEGIN
DECLARE
_path
VARCHAR
(
255
)
DEFAULT
NULL
;
DECLARE
dir_id
INT
UNSIGNED
DEFAULT
NULL
;
DECLARE
dir_path
VARCHAR
(
255
)
DEFAULT
""
;
DECLARE
dir_path_no_trailing_slash
VARCHAR
(
255
)
DEFAULT
""
;
DECLARE
dir_exists
BOOLEAN
DEFAULT
FALSE
;
DECLARE
cur
CURSOR
FOR
SELECT
file_id
,
path
FROM
files
;
DECLARE
CONTINUE
HANDLER
FOR
NOT
FOUND
SET
done
=
TRUE
;
...
...
@@ -63,7 +66,8 @@ BEGIN
SET
done
=
FALSE
;
LEAVE
loop2
;
END
IF
;
SELECT
TRUE
INTO
dir_exists
FROM
files
WHERE
path
=
LEFT
(
dir_path
,
CHAR_LENGTH
(
dir_path
)
-
1
);
SET
dir_path_no_trailing_slash
=
LEFT
(
dir_path
,
CHAR_LENGTH
(
dir_path
)
-
1
);
SELECT
TRUE
INTO
dir_exists
FROM
files
WHERE
path
=
dir_path_no_trailing_slash
;
IF
dir_exists
IS
TRUE
THEN
SET
dir_exists
=
FALSE
;
ITERATE
loop2
;
...
...
@@ -72,9 +76,11 @@ BEGIN
SET
dir_id
=
LAST_INSERT_ID
();
INSERT
INTO
files
(
file_id
,
path
,
size
,
hash
,
checked_timestamp
,
mimetype
,
file_storage_id
,
file_key
)
VALUES
(
dir_id
,
LEFT
(
dir_path
,
CHAR_LENGTH
(
dir_path
)
-
1
),
0
,
NULL
,
0
,
"inode/directory"
,
"DEFAULT"
,
LEFT
(
dir_path
,
CHAR_LENGTH
(
dir_path
)
-
1
));
VALUES
(
dir_id
,
dir_path_no_trailing_slash
,
0
,
NULL
,
0
,
"inode/directory"
,
"DEFAULT"
,
dir_path_no_trailing_slash
);
UPDATE
files
SET
parent_directory
=
dir_id
WHERE
path
LIKE
CONCAT
(
dir_path
,
"%"
);
UPDATE
files
SET
parent_directory
=
0
WHERE
path
LIKE
CONCAT
(
dir_path
,
"%"
);
END
LOOP
;
END
LOOP
;
...
...
This diff is collapsed.
Click to expand it.
procedures/retrieveEntity.sql
+
11
−
8
View file @
2d455272
...
...
@@ -45,19 +45,21 @@ drop procedure if exists db_2_0.retrieveEntity //
*
* ResultSet
* ---------
* Tuple of (Datatype, Collection, EntityID, EntityName, EntityDesc,
* EntityRole, FileSize, FilePath, FileHash, ACL, Version)
* Tuple of (DatatypeID, Collection, EntityID, EntityName, EntityDesc,
* EntityRole, FileSize, FilePath, FileHash, FileHashChecked,
* FileMimetype, FileStorageID, FileKey, FileParentID, ACL, Version)
*/
create
procedure
db_2_0
.
retrieveEntity
(
in
EntityID
INT
UNSIGNED
,
in
Version
VARBINARY
(
255
))
retrieveEntityBody
:
BEGIN
DECLARE
FilePath
VARCHAR
(
255
)
DEFAULT
NULL
;
DECLARE
FileParentID
INT
UNSIGNED
DEFAULT
NULL
;
DECLARE
FileSize
VARCHAR
(
255
)
DEFAULT
NULL
;
DECLARE
FileHash
VARCHAR
(
255
)
DEFAULT
NULL
;
DECLARE
FileHashChecked
BIGINT
DEFAULT
NULL
;
DECLARE
FileMimetype
VARBINARY
(
255
)
DEFAULT
NULL
;
DECLARE
FileStorageI
d
VARBINARY
(
255
)
DEFAULT
NULL
;
DECLARE
FileStorageI
D
VARBINARY
(
255
)
DEFAULT
NULL
;
DECLARE
FileKey
VARBINARY
(
65525
)
DEFAULT
NULL
;
DECLARE
DatatypeID
INT
UNSIGNED
DEFAULT
NULL
;
DECLARE
CollectionName
VARCHAR
(
255
)
DEFAULT
NULL
;
...
...
@@ -86,7 +88,7 @@ retrieveEntityBody: BEGIN
END
IF
;
SELECT
path
,
size
,
hex
(
hash
),
checked_timestamp
,
mimetype
,
file_storage_id
,
file_key
INTO
FilePath
,
FileSize
,
FileHash
,
FileHashChecked
,
FileMimetype
,
FileStorageI
d
,
FileKey
INTO
FilePath
,
FileSize
,
FileHash
,
FileHashChecked
,
FileMimetype
,
FileStorageI
D
,
FileKey
FROM
archive_files
WHERE
file_id
=
EntityID
AND
_iversion
=
IVersion
...
...
@@ -135,7 +137,7 @@ retrieveEntityBody: BEGIN
FileHash
AS
FileHash
,
FileHashChecked
AS
FileHashChecked
,
FileMimetype
as
FileMimetype
,
FileStorageI
d
as
FileStorageI
d
,
FileStorageI
D
as
FileStorageI
D
,
FileKey
as
FileKey
,
(
SELECT
acl
FROM
entity_acl
AS
a
WHERE
a
.
id
=
e
.
acl
)
AS
ACL
,
Version
AS
Version
...
...
@@ -150,8 +152,8 @@ retrieveEntityBody: BEGIN
END
IF
;
END
IF
;
SELECT
path
,
size
,
hex
(
hash
),
checked_timestamp
,
mimetype
,
file_storage_id
,
file_key
INTO
FilePath
,
FileSize
,
FileHash
,
FileHashChecked
,
FileMimetype
,
FileStorageI
d
,
FileKey
SELECT
path
,
parent_directory
,
size
,
hex
(
hash
),
checked_timestamp
,
mimetype
,
file_storage_id
,
file_key
INTO
FilePath
,
FileParentID
,
FileSize
,
FileHash
,
FileHashChecked
,
FileMimetype
,
FileStorageI
D
,
FileKey
FROM
files
WHERE
file_id
=
EntityID
LIMIT
1
;
...
...
@@ -188,8 +190,9 @@ retrieveEntityBody: BEGIN
FileHash
AS
FileHash
,
FileHashChecked
AS
FileHashChecked
,
FileMimetype
as
FileMimetype
,
FileStorageI
d
as
FileStorageI
d
,
FileStorageI
D
as
FileStorageI
D
,
FileKey
as
FileKey
,
FileParentID
as
FileParentID
,
(
SELECT
acl
FROM
entity_acl
AS
a
WHERE
a
.
id
=
e
.
acl
)
AS
ACL
,
Version
AS
Version
FROM
entities
e
WHERE
id
=
EntityID
LIMIT
1
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment