`call dolt_clone()` does not work if you have not used a database
Repro
In Shell 1:
dolt $ dolt sql-server
Starting server with Config HP="localhost:3306"|T="28800000"|R="false"|L="info"
2022-07-26T15:59:25-07:00 INFO [conn 1] NewConnection {DisableClientMultiStatements=false}
2022-07-26T15:59:53-07:00 WARN [conn 1] error running query {connectTime=2022-07-26T15:59:25-07:00, connectionDb=, error=stored procedure "dolt_clone" does not exist, query=call dolt_clone('dolthub/SHAQ'); }
In shell 2:
git $ dolt sql-client
# Welcome to the Dolt MySQL client.
# Statements must be terminated with ';'.
# "exit" or "quit" (or Ctrl-D) to exit.
mysql> call dolt_clone('dolthub/SHAQ');
Error 1105: stored procedure "dolt_clone" does not exist
Note, I have a bunch of databases here:
mysql> show databases;
+-----------------------------------------+
| Database |
+-----------------------------------------+
| Org_record_backup_3 |
| Source3 |
| backup_example |
| backup_restore |
| bats_working |
| ckeran |
| datasets |
| demo |
| dirty_branch |
| disqo_demo |
| docs |
| dolt_test |
| doltdb |
| drop_test |
| earnings |
...
But if I use a database that exists:
mysql> use docs;
mysql> call dolt_clone('dolthub/SHAQ');
+--------+
| status |
+--------+
| 0 |
+--------+
mysql> show databases;
+-----------------------------------------+
| Database |
+-----------------------------------------+
| Org_record_backup_3 |
| SHAQ |
| Source3 |
| backup_example |
| backup_restore |
| bats_working |
...
It works.
Note, it clones into the correct directory. It does not clone into docs.
dolt $ ls SHAQ/
dolt $ ls docs/
privs.json
I also can't clone dolthub/corona-virus potentially because of the -. Using backticks doesn't work
mysql> use coronavirus;
Database changed
mysql> call dolt_clone(`dolthub/corona-virus`);
ERROR 1105 (HY000): column "dolthub/corona-virus" could not be found in any table in scope
To make the dolt_clone stored procedure work with no database selected, it seems like we'll need to introduce some concept like "global stored procedures" – a stored procedure that is not associated with a specific database and can be call'ed with no database selected. I'll dig into this and find the simplest way we could introduce something like that.
@tbantle22 – I was able to clone the dolthub/corona-virus db, like this:
mysql> use db1;
mysql> call dolt_clone("dolthub/corona-virus");
+--------+
| status |
+--------+
| 0 |
+--------+
1 row in set (15.75 sec)
mysql> use corona-virus;
mysql> show tables;
+------------------------------------+
| Tables_in_corona-virus |
+------------------------------------+
| case_details |
| cases |
...
MySQL interprets anything quoted with backticks as an identifier, so that explains the error message you got. Give it a shot with double-quotes instead of backticks and let me know if it still doesn't work for you and I'll keep digging in.
That worked for a local sql server, but getting this error trying to call dolt_clone from a hosted instance
mysql> use coronavirus;
Database changed
mysql> call dolt_clone("dolthub/corona-virus");
ERROR 1105 (HY000): unable to clone remote database; no remote dialer configured
That should probaly be a new bug and in the hosted-issues repository. It's possible the port to clone is not open on the hosted instance.
Done https://github.com/dolthub/hosted-issues/issues/31
Would this one work better as a sql function? select dolt_clone()