Skip to content

Commit 58aeec8

Browse files
authored
Merge pull request #1768 from dolthub/fulghum/undrop
Adding docs for `dolt_undrop()` and `dolt_purge_dropped_databases()`
2 parents 5a59eed + adab60a commit 58aeec8

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

content/reference/sql/version-control/dolt-sql-procedures.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ title: Dolt SQL Procedures
1818
- [dolt_gc()](#dolt_gc)
1919
- [dolt_merge()](#dolt_merge)
2020
- [dolt_pull()](#dolt_pull)
21+
- [dolt_purge_dropped_databases()](#dolt_purge_dropped_databases)
2122
- [dolt_push()](#dolt_push)
2223
- [dolt_remote()](#dolt_remote)
2324
- [dolt_reset()](#dolt_reset)
2425
- [dolt_revert()](#dolt_revert)
2526
- [dolt_tag()](#dolt_tag)
27+
- [dolt_undrop()](#dolt_undrop)
2628
- [dolt_verify_constraints()](#dolt_verify_constraints)
2729

2830
# Dolt SQL Procedures
@@ -908,6 +910,32 @@ CALL DOLT_PULL('origin', 'some-branch');
908910
SELECT * FROM dolt_log LIMIT 5;
909911
```
910912

913+
914+
## `DOLT_PURGE_DROPPED_DATABASES()`
915+
916+
Permanently deletes any dropped databases that are being held in a temporary holding area. When a Dolt database is
917+
dropped, it is moved to a temporary holding area where the [`dolt_undrop()` stored procedure](#dolt_undrop) can restore
918+
it. The `dolt_purge_dropped_databases()` stored procedure clears this holding area and permanently deletes any data
919+
from those databases. This action is not reversible, so callers should be cautious about using it. The main benefit
920+
of using this function is to reclaim disk space used by the temporary holding area. Because this is a destructive
921+
operation, callers must have `SUPER` privileges in order to execute it.
922+
923+
### Example
924+
925+
```sql
926+
-- Create a database and populate a table in the working set
927+
CREATE DATABASE database1;
928+
use database1;
929+
create table t(pk int primary key);
930+
931+
-- Dropping the database will move it to a temporary holding area
932+
DROP DATABASE database1;
933+
934+
-- At this point, the database can be restored by calling dolt_undrop('database1'), but
935+
-- instead, we permanently delete it by calling dolt_purge_dropped_databases().
936+
CALL dolt_purge_dropped_databases();
937+
```
938+
911939
## `DOLT_PUSH()`
912940

913941
Updates remote refs using local refs, while sending objects necessary to
@@ -1193,6 +1221,39 @@ CALL DOLT_COMMIT('-am', 'committing all changes');
11931221
CALL DOLT_TAG('v1','head','-m','creating v1 tag');
11941222
```
11951223

1224+
## `DOLT_UNDROP()`
1225+
1226+
Restores a dropped database. See the [`dolt_purge_dropped_databases()` stored procedure](#dolt_purge_dropped_databases) for info on how to permanently remove dropped databases.
1227+
1228+
```sql
1229+
CALL DOLT_UNDROP(<database_name>);
1230+
```
1231+
1232+
### Options
1233+
1234+
`dolt_undrop()` takes a single argument – the name of the dropped database to restore. When called without any arguments,
1235+
`dolt_undrop()` returns an error message that contains a list of all dropped databases that are available to be restored.
1236+
1237+
### Example
1238+
1239+
```sql
1240+
-- Create a database and populate a table in the working set
1241+
CREATE DATABASE database1;
1242+
use database1;
1243+
create table t(pk int primary key);
1244+
1245+
-- Dropping the database will move it to a temporary holding area
1246+
DROP DATABASE database1;
1247+
1248+
-- calling dolt_undrop() with no arguments will return an error message that
1249+
-- lists the dropped database that are available to be restored
1250+
CALL dolt_undrop();
1251+
1252+
-- Use dolt_undrop() to restore it
1253+
CALL dolt_undrop('database1');
1254+
SELECT * FROM database1.t;
1255+
```
1256+
11961257
## `DOLT_VERIFY_CONSTRAINTS()`
11971258

11981259
Verifies that working set changes (inserts, updates, and/or deletes) satisfy the

0 commit comments

Comments
 (0)