If you create a new directory and run dolt sql-server within it, and then connect to it and run:
CREATE DATABASE `db`;
CREATE DATABASE `db/subdb`;
you will end up with the directories:
./db
./db/.dolt
./db/subdb
./db/subdb/.dolt
This breaks backups and causes other problems. We should either not allow / in database names, or create our directories using some filesystem safe encoding (Such as ./db%2Fsubdb)... But I imagine it's probably easiest to prevent slashes in db names.
Repro Steps:
Create a new directory to test from and run dolt sql-server
~>mysql -h127.0.0.1 -udolt
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 8.0.33 Dolt
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
+--------------------+
2 rows in set (0.00 sec)
mysql> CREATE DATABASE db;
Query OK, 1 row affected (0.08 sec)
mysql> CREATE DATABASE `db/subdb`;
Query OK, 1 row affected (0.10 sec)
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| db |
| db/subdb |
| information_schema |
| mysql |
+--------------------+
4 rows in set (0.01 sec)
mysql> exit
Check the folders created:
~/datasets/dolt/hierarchical>ls -la
total 0
drwxr-xr-x 4 brian staff 128 Jul 16 14:24 .
drwxr-xr-x 36 brian staff 1152 Jul 16 14:13 ..
drwxr-xr-x 2 brian staff 64 Jul 16 14:24 .dolt
drwxr-xr-x 4 brian staff 128 Jul 16 14:24 db
~/datasets/dolt/hierarchical>cd db
~/datasets/dolt/hierarchical/db>ls -la
total 0
drwxr-xr-x 4 brian staff 128 Jul 16 14:24 .
drwxr-xr-x 4 brian staff 128 Jul 16 14:24 ..
drwxr-xr-x 6 brian staff 192 Jul 16 14:24 .dolt
drwxr-xr-x 3 brian staff 96 Jul 16 14:24 subdb
~/datasets/dolt/hierarchical/db>cd subdb
~/datasets/dolt/hierarchical/db/subdb>ls -la
total 0
drwxr-xr-x 3 brian staff 96 Jul 16 14:24 .
drwxr-xr-x 4 brian staff 128 Jul 16 14:24 ..
drwxr-xr-x 6 brian staff 192 Jul 16 14:24 .dolt
If you create a new directory and run
dolt sql-server
within it, and then connect to it and run:you will end up with the directories:
This breaks backups and causes other problems. We should either not allow
/
in database names, or create our directories using some filesystem safe encoding (Such as ./db%2Fsubdb)... But I imagine it's probably easiest to prevent slashes in db names.Repro Steps: Create a new directory to test from and run
dolt sql-server
Connect to the running server and run the queries
Check the folders created: