Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call dolt_clone() does not work if you have not used a database #3934

Closed
timsehn opened this issue Jul 26, 2022 · 8 comments · Fixed by #4021
Closed

call dolt_clone() does not work if you have not used a database #3934

timsehn opened this issue Jul 26, 2022 · 8 comments · Fixed by #4021
Assignees

Comments

@timsehn
Copy link
Contributor

timsehn commented Jul 26, 2022

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.

@timsehn
Copy link
Contributor Author

timsehn commented Jul 26, 2022

Note, it clones into the correct directory. It does not clone into docs.

dolt $ ls SHAQ/
dolt $ ls docs/
privs.json

@tbantle22
Copy link
Contributor

tbantle22 commented Jul 26, 2022

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

@fulghum fulghum self-assigned this Jul 27, 2022
@fulghum
Copy link
Contributor

fulghum commented Jul 28, 2022

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.

@fulghum
Copy link
Contributor

fulghum commented Jul 28, 2022

@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.

@tbantle22
Copy link
Contributor

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

@timsehn
Copy link
Contributor Author

timsehn commented Jul 28, 2022

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.

@tbantle22
Copy link
Contributor

Done dolthub/hosted-issues#31

@timsehn
Copy link
Contributor Author

timsehn commented Jul 28, 2022

Would this one work better as a sql function? select dolt_clone()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants