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

Use dump endpoint for turso db shell $DB .dump #658

Merged
merged 1 commit into from
Sep 27, 2023
Merged

Conversation

athoscouto
Copy link
Collaborator

This is a quick fix to enable folks to get dumps of arbitrary size.
We should patch the libsql-shell-go to use the endpoint instead of its own implementation.


Tested with:

> turso db shell flying-circuit      
Connected to flying-circuit at https://flying-circuit-athoscouto.turso.io

Welcome to Turso SQL shell!

Type ".quit" to exit the shell and ".help" to list all available commands.

→  select count(*) from fly;
COUNT (*) 
33554432      
→  .quit
> turso db shell flying-circuit .dump > fly.dump
> wc -l fly.dump 
 33554437 fly.dump
> head fly.dump 
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS libsql_wasm_func_table (name text PRIMARY KEY, body text) WITHOUT ROWID;
CREATE TABLE IF NOT EXISTS fly(a);
INSERT INTO fly VALUES(1);
INSERT INTO fly VALUES(1);
INSERT INTO fly VALUES(1);
INSERT INTO fly VALUES(1);
INSERT INTO fly VALUES(1);
INSERT INTO fly VALUES(1);
> tail fly.dump 
INSERT INTO fly VALUES(1);
INSERT INTO fly VALUES(1);
INSERT INTO fly VALUES(1);
INSERT INTO fly VALUES(1);
INSERT INTO fly VALUES(1);
INSERT INTO fly VALUES(1);
INSERT INTO fly VALUES(1);
INSERT INTO fly VALUES(1);
INSERT INTO fly VALUES(1);
COMMIT;

@athoscouto athoscouto temporarily deployed to internal September 27, 2023 03:09 — with GitHub Actions Inactive
This is a quick fix to enable folks to get dumps of arbitrary size.
We should patch the libsql-shell-go to use the endpoint instead of
its own implementation.
@athoscouto athoscouto temporarily deployed to internal September 27, 2023 16:41 — with GitHub Actions Inactive
@athoscouto athoscouto merged commit ab5b893 into main Sep 27, 2023
2 checks passed
@athoscouto athoscouto deleted the athos/dump branch September 27, 2023 17:21
@haaawk
Copy link
Collaborator

haaawk commented Sep 28, 2023

I'm not sure whether this works correct.

╰──> turso db shell dumptest ".dump"
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS libsql_wasm_func_table (name text PRIMARY KEY, body text) WITHOUT ROWID;
COMMIT;

We probably don't want the dump of libsql_wasm_func_table, do we?

@athoscouto
Copy link
Collaborator Author

@haaawk I don't know. Can users register functions? If so it makes sense to have it on the dump. It may be work to create a issue ok sqld repo about it.

@haaawk
Copy link
Collaborator

haaawk commented Sep 28, 2023

I think it's fine the way it is for now.

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

Successfully merging this pull request may close these issues.

2 participants