Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...




sudo bash -c 'curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | sudo bash'$ git clone [email protected]:dolthub/dolt.git
Cloning into 'dolt'...
remote: Enumerating objects: 25, done.
remote: Counting objects: 100% (25/25), done.
remote: Compressing objects: 100% (25/25), done.
remote: Total 87117 (delta 4), reused 6 (delta 0), pack-reused 87092
Receiving objects: 100% (87117/87117), 93.77 MiB | 13.94 MiB/s, done.
Resolving deltas: 100% (57066/57066), done.v
$ cd dolt/go && go install ./cmd/dolt.zipmysql> create table complex (pk1 int, pk2 varchar(47), c1 tinyint not null, c2 datetime, c3 json, primary key(pk1, pk2));
mysql> show create table complex;
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| complex | CREATE TABLE `complex` (
`pk1` int NOT NULL,
`pk2` varchar(47) NOT NULL,
`c1` tinyint NOT NULL,
`c2` datetime,
`c3` json,
PRIMARY KEY (`pk1`,`pk2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin |
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+winget install doltchoco install doltscoop install doltdolt sql-server
Starting server with Config HP="localhost:3306"|T="28800000"|R="false"|L="info"% mysql --host 127.0.0.1 --port 3306 -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.9-Vitess
Copyright (c) 2000, 2022, 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>




$ brew install dolt
==> Downloading https://homebrew.bintray.com/bottles/dolt-0.18.3.catalina.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/c03cc532d5045fa090cb4e0f141883685de3765bf1d221e400c750b3ae89e328?response-content-disposition=attachment%3Bfilename%3D%22dolt-0.18.3.catalina.bottle.tar.gz%22&Policy=eyJTdGF0
######################################################################## 100.0%
==> Pouring dolt-0.18.3.catalina.bottle.tar.gz
🍺 /usr/local/Cellar/dolt/0.18.3: 7 files, 56.9MBmysql> create table salaries (name varchar(255), salary int, primary key(name));
mysql> insert into salaries values ('Jim', 120000), ('Bob', 240000), ('Sally', 360000);
mysql> create view monthly_salaries as select name, salary/12 as monthly_pay from salaries;
mysql> select * from monthly_salaries order by monthly_pay asc;
+-------+-------------+
| name | monthly_pay |
+-------+-------------+
| Jim | 10000 |
| Bob | 20000 |
| Sally | 30000 |
+-------+-------------+mysql> call dolt_add('-A');
mysql> call dolt_commit('-am', 'Created table and view');
+----------------------------------+
| hash |
+----------------------------------+
| trj7dm02r8c94nqpbphjgolhhsk37rkj |
+----------------------------------+
mysql> insert into salaries values ('Tim', 480000);
mysql> select * from monthly_salaries order by monthly_pay asc;
+-------+-------------+
| name | monthly_pay |
+-------+-------------+
| Jim | 10000 |
| Bob | 20000 |
| Sally | 30000 |
| Tim | 40000 |
+-------+-------------+
mysql> select * from monthly_salaries as of 'HEAD' order by monthly_pay asc;
+-------+-------------+
| name | monthly_pay |
+-------+-------------+
| Jim | 10000 |
| Bob | 20000 |
| Sally | 30000 |
+-------+-------------+mysql> show databases;
+--------------------+
| Database |
+--------------------+
| docs |
| information_schema |
+--------------------+
mysql> use docs;
mysql> show tables;
+----------------+
| Tables_in_docs |
+----------------+
| docs |
+----------------+docs $ dolt branch new-branch
docs $ dolt branch
* main
new-branch
docs $ dolt checkout -b check-out-new-branch
Switched to branch 'check-out-new-branch'
docs $ dolt branch
* check-out-new-branch
main
new-branch
docs $ dolt sql -q "select * from dolt_branches"
+----------------------+----------------------------------+------------------+------------------------+-----------------------------------+------------------------------+
| name | hash | latest_committer | latest_committer_email | latest_commit_date | latest_commit_message |
+----------------------+----------------------------------+------------------+------------------------+-----------------------------------+------------------------------+
| check-out-new-branch | f0ga78jrh4llc0uus8h2refopp6n870m | Tim Sehn | [email protected] | 2021-12-06 13:39:57.705 -0800 PST | Removed row from no_pk table |
| main | f0ga78jrh4llc0uus8h2refopp6n870m | Tim Sehn | [email protected] | 2021-12-06 13:39:57.705 -0800 PST | Removed row from no_pk table |
| new-branch | f0ga78jrh4llc0uus8h2refopp6n870m | Tim Sehn | [email protected] | 2021-12-06 13:39:57.705 -0800 PST | Removed row from no_pk table |
+----------------------+----------------------------------+------------------+------------------------+-----------------------------------+------------------------------+behavior:
auto_gc_behavior:
enable: false$ dolt sql --disable-auto-gcmysql> show tables;
+----------------+
| Tables_in_docs |
+----------------+
| complex |
| docs |
+----------------+
mysql> alter table complex add column c4 blob;
mysql> show create table complex;
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| complex | CREATE TABLE `complex` (
`pk1` int NOT NULL,
`pk2` varchar(47) NOT NULL,
`c1` tinyint NOT NULL,
`c2` datetime,
`c3` json,
`c4` blob,
PRIMARY KEY (`pk1`,`pk2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin |
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+mysql> create table a (x int primary key);
mysql> create table b (y int primary key);
mysql> create trigger adds_one before insert on a for each row set new.x = new.x + 1;
mysql> insert into a values (1), (3);
mysql> select * from a;
+---+
| x |
+---+
| 2 |
| 4 |
+---+
mysql> create trigger inserts_into_b after insert on a for each row insert into b values (new.x * 2);
mysql> insert into a values (5);
mysql> select * from a;
+---+
| x |
+---+
| 2 |
| 4 |
| 6 |
+---+
mysql> select * from b;
+----+
| y |
+----+
| 12 |
+----+mysql> select * from dolt_status;
+--------------+--------+-----------+
| table_name | staged | status |
+--------------+--------+-----------+
| dolt_schemas | 0 | new table |
| a | 0 | new table |
| b | 0 | new table |
+--------------+--------+-----------+
mysql> select * from dolt_schemas;
+---------+----------------+-----------------------------------------------------------------------------------------------+----+--------------------------------+
| type | name | fragment | id | extra |
+---------+----------------+-----------------------------------------------------------------------------------------------+----+--------------------------------+
| trigger | adds_one | create trigger adds_one before insert on a for each row set new.x = new.x + 1 | 1 | {"CreatedAt": 1.656093714e+09} |
| trigger | inserts_into_b | create trigger inserts_into_b after insert on a for each row insert into b values (new.x * 2) | 2 | {"CreatedAt": 1.656093749e+09} |
+---------+----------------+-----------------------------------------------------------------------------------------------+----+--------------------------------+% dolt log
commit cffu3k56rtv6cf28370buivf33bb2mvr
Author: Tim Sehn <[email protected]>
Date: Fri Dec 03 09:49:29 -0800 2021
This is a commit
commit t5d5inj4bpc1fltrdm9uoscjdsgebaih
Author: Tim Sehn <[email protected]>
Date: Fri Dec 03 09:49:10 -0800 2021
Initialize data repository
docs $ dolt sql -q "select * from dolt_log"
+----------------------------------+-----------+------------------+-----------------------------------+----------------------------+
| commit_hash | committer | email | date | message |
+----------------------------------+-----------+------------------+-----------------------------------+----------------------------+
| u73s2mb1ho4mj1ldkof939vampo93bld | Tim Sehn | [email protected] | 2021-12-06 10:45:11.148 -0800 PST | This is a commit |
| bo318l76dq3bdvu1ie84d4nmv4hpi4km | Tim Sehn | [email protected] | 2021-12-02 16:55:00.101 -0800 PST | This is a commit |
| jcj6q9c9nsveh72eadsms9i9k9ii1e55 | Tim Sehn | [email protected] | 2021-12-02 16:54:35.87 -0800 PST | Initialize data repository |
+----------------------------------+-----------+------------------+-----------------------------------+----------------------------+$ dolt sql -q "select * from dolt_history_employees where id=0 order by commit_date";
+------+-----------+------------+------------+----------------------------------+-----------+-------------------------+
| id | last_name | first_name | start_date | commit_hash | committer | commit_date |
+------+-----------+------------+------------+----------------------------------+-----------+-------------------------+
| 0 | Sehn | Tim | NULL | 13qfqa5rojq18j84d1n2htjkm6fletg4 | Tim Sehn | 2022-06-07 16:39:32.066 |
| 0 | Sehn | Timothy | NULL | uhkv57j4bp2v16vcnmev9lshgkqq8ppb | Tim Sehn | 2022-06-07 16:41:49.847 |
| 0 | Sehn | Tim | 2018-09-08 | pg3nfi0j1dpc5pf1rfgckpmlteaufdrt | Tim Sehn | 2022-06-07 16:44:37.513 |
| 0 | Sehn | Timothy | 2018-09-08 | vn9b0qcematsj2f6ka0hfoflhr5s6p0b | Tim Sehn | 2022-06-07 17:10:02.07 |
+------+-----------+------------+------------+----------------------------------+-----------+-------------------------+% dolt sql-server
Starting server with Config HP="localhost:3306"|U="root"|P=""|T="28800000"|R="false"|L="info"$ ps -a | grep dolt
66187 ttys000 0:00.00 grep dolt
46800 ttys003 3351:00.34 dolt sql-server
65544 ttys010 0:07.82 dolt push
$ kill -QUIT 46800% dolt sql
# Welcome to the DoltSQL shell.
# Statements must be terminated with ';'.
# "exit" or "quit" (or Ctrl-D) to exit.
menus> show tables;
+------------+
| Table |
+------------+
| menu_items |
+------------+
menus> exit
Bye% dolt sql -q "show tables"
+------------+
| Table |
+------------+
| menu_items |
+------------+% dolt sql < mysqldump.sql$ ls -ltr $(which dolt)
lrwxr-xr-x 1 oscarbatori admin 30 Aug 26 16:49 /usr/local/bin/dolt -> ../Cellar/dolt/0.18.3/bin/doltsudo port install doltsudo bash -c 'curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | sudo bash'sudo useradd -r -m -d /var/lib/doltdb dolt$ cd /var/lib/doltdb
$ sudo -u dolt dolt config --global --add user.email [email protected]
$ sudo -u dolt dolt config --global --add user.name "Dolt Server Account"cd /var/lib/doltdb
sudo -u dolt mkdir -p databases/my_db
cd databases/my_db
sudo -u dolt dolt initSuccessfully initialized dolt data repository.cd ~
cat > doltdb.service <<EOF
[Unit]
Description=dolt SQL server
After=network.target
[Install]
WantedBy=multi-user.target
[Service]
User=dolt
Group=dolt
ExecStart=/usr/local/bin/dolt sql-server
WorkingDirectory=/var/lib/doltdb/databases/my_db
KillSignal=SIGTERM
SendSIGKILL=no
EOF
sudo chown root:root doltdb.service
sudo chmod 644 doltdb.service
sudo mv doltdb.service /etc/systemd/systemsudo systemctl daemon-reload
sudo systemctl enable doltdb.service
sudo systemctl start doltdbmysql -h 127.0.0.1 -u root -p''mysql> CREATE PROCEDURE example(x INT) SELECT x + 1;
mysql> call example(1);
+---------+
| (x + 1) |
+---------+
| 2 |
+---------+mysql> select * from dolt_status;
+-----------------+--------+----------+
| table_name | staged | status |
+-----------------+--------+----------+
| dolt_procedures | 0 | modified |
+-----------------+--------+----------+
mysql> select * from dolt_procedures;
+---------+----------------------------------------------+----------------------------+----------------------------+
| name | create_stmt | created_at | modified_at |
+---------+----------------------------------------------+----------------------------+----------------------------+
| example | CREATE PROCEDURE example(x INT) SELECT x + 1 | 2022-06-24 18:21:44.125045 | 2022-06-24 18:21:44.125045 |
+---------+----------------------------------------------+----------------------------+----------------------------+SET AUTOCOMMIT = 0;
mysql> select * from docs;
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
| 3 | 0 |
| 4 | 4 |
+----+----+
mysql> BEGIN
-> ;
mysql> delete from docs where pk=4;
mysql> select * from docs;
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
| 3 | 0 |
+----+----+
mysql> rollback;
mysql> select * from docs;
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
| 3 | 0 |
| 4 | 4 |
+----+----+%% dolt backup add backup1 file://../backups/backup1
/ Tree Level: 1, Percent Buffered: 0.00% Files Written: 0, Files Uploaded: 1$ dolt backup sync backup1$ dolt backup restore file://./backups/backup1 repo2
$ dolt branch -a
* main
$ dolt statusus-businesses $ dolt sql --save "Example saved query" -q "show tables"
+----------------+
| Table |
+----------------+
| business_types |
| businesses |
| naics |
| sic |
+----------------+
us-businesses $ dolt sql -x "Example saved query"
Executing saved query 'Example saved query':
show tables
+----------------+
| Table |
+----------------+
| business_types |
| businesses |
| naics |
| sic |
+----------------+us-businesses $ dolt sql -q "select * from dolt_query_catalog"
+---------------------+---------------+---------------------+-------------+-------------+
| id | display_order | name | query | description |
+---------------------+---------------+---------------------+-------------+-------------+
| Example saved query | 1 | Example saved query | show tables | |
+---------------------+---------------+---------------------+-------------+-------------+
us-businesses $ dolt sql -q "delete from dolt_query_catalog where id ='Example saved query'"
Query OK, 1 row affected
us-businesses $ dolt sql -q "select * from dolt_query_catalog"
+----+---------------+------+-------+-------------+
| id | display_order | name | query | description |
+----+---------------+------+-------+-------------+
+----+---------------+------+-------+-------------+
us-businesses $ dolt sql --save "Example saved query" -q "show tables" -m "You can even add a long description"
+----------------+
| Table |
+----------------+
| business_types |
| businesses |
| naics |
| sic |
+----------------+
us-businesses $ dolt sql -q "select * from dolt_query_catalog"
+---------------------+---------------+---------------------+-------------+-------------------------------------+
| id | display_order | name | query | description |
+---------------------+---------------+---------------------+-------------+-------------------------------------+
| Example saved query | 1 | Example saved query | show tables | You can even add a long description |
+---------------------+---------------+---------------------+-------------+-------------------------------------+

1.82.2. Tests that did not run could not complete due to a timeout earlier in the run.UNIQUEdolt $ dolt clone timsehn/docs
cloning https://doltremoteapi.dolthub.com/timsehn/docs
29 of 29 chunks complete. 0 chunks being downloaded currently.
dolt $ cd docs/
docs $ dolt ls
Tables in working set:
docs
docs $ dolt sql -q "select * from docs"
+----+----+
| pk | c1 |
+----+----+
+----+----+
docs $ dolt sql -q "insert into docs values (0,0),(1,1),(2,2)"
Query OK, 3 rows affected
docs $ dolt sql -q "select * from docs"
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
+----+----+
docs $ dolt add docs
docs $ dolt commit -m "Committing inserts so I can push it to my remote"
commit uhumidn2e7ucan59jk9vuabm7r5osggs
Author: Tim Sehn <[email protected]>
Date: Mon Dec 06 17:14:46 -0800 2021
Committing inserts so I can push it to my remote
docs $ dolt remote
origin
docs $ dolt remote -v
origin https://doltremoteapi.dolthub.com/timsehn/docs
docs $ dolt push origin main
\ Tree Level: 1, Percent Buffered: 0.00% Files Written: 0, Files Uploaded: 1docs $ dolt sql -q "create table docs (pk int, primary key(pk))"
docs $ dolt add .
docs $ dolt status
On branch main
Changes to be committed:
(use "dolt reset <table>..." to unstage)
new table: docs
docs $ dolt commit -m "Added example table docs"
commit 7vureh3qotrr02sog3tjgjk73sqmc2de
Author: Tim Sehn <[email protected]>
Date: Mon Dec 06 13:25:55 -0800 2021
Added example table docs
docs $ dolt sql -q "create table docs_sql (pk int, primary key(pk))"
docs $ dolt sql -q "call dolt_commit('-a', '-m', 'Added docs_sql example table. Use -a to stage all changes for commit ie. skip dolt add')"
+-------------------------------------------------------------------------------------------------------------------+
| dolt_commit('-a', '-m', 'Added docs_sql example table. Use -a to stage all changes for commit ie. skip dolt add') |
+-------------------------------------------------------------------------------------------------------------------+
| v42og53ru3k3hak3decm23crp5p6kd2f |
+-------------------------------------------------------------------------------------------------------------------+docs $ dolt commit --allow-empty -m "This is a commit"
commit bo318l76dq3bdvu1ie84d4nmv4hpi4km
Author: Tim Sehn <[email protected]>
Date: Thu Dec 02 16:55:00 -0800 2021
This is a commit
docs $ dolt sql -q "call dolt_commit('-a', '--allow-empty', '-m', 'This is a commit')"
+--------------------------------------------------------------+
| dolt_commit('-a', '--allow-empty', '-m', 'This is a commit') |
+--------------------------------------------------------------+
| u73s2mb1ho4mj1ldkof939vampo93bld |
+--------------------------------------------------------------+mysql> create table complex (pk1 int, pk2 varchar(47), c1 tinyint not null, c2 datetime, c3 json, primary key(pk1, pk2));
mysql> show create table complex;
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| complex | CREATE TABLE `complex` (
`pk1` int NOT NULL,
`pk2` varchar(47) NOT NULL,
`c1` tinyint NOT NULL,
`c2` datetime,
`c3` json,
PRIMARY KEY (`pk1`,`pk2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin |
+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+$ dolt sql
# Welcome to the DoltSQL shell.
# Statements must be terminated with ';'.
# "exit" or "quit" (or Ctrl-D) to exit.
dolt> CREATE USER testuser@localhost IDENTIFIED BY 'password123';
dolt> GRANT SELECT ON db_name.example TO testuser@localhost;
dolt> CREATE ROLE testrole;
dolt> GRANT SELECT, INSERT, UPDATE, DELETE on *.* TO testrole;
dolt> exit;$ dolt --user="testuser" --password="password123" sql
# Welcome to the DoltSQL shell.
# Statements must be terminated with ';'.
# "exit" or "quit" (or Ctrl-D) to exit.
dolt> USE db_name;
db_name> SELECT * FROM example;
+----+
| pk |
+----+
| 1 |
| 2 |
| 3 |
+----+
db_name> SELECT * FROM example2;
Error 1105: Access denied for user 'testuser'@'localhost' to table 'example2'
db_name> SELECT * FROM table_does_not_exist;
Error 1105: Access denied for user 'testuser'@'localhost' to table 'table_does_not_exist'
db_name> INSERT INTO example VALUES (4);
Error 1105: command denied to user 'testuser'@'localhost'mysql> create index index1 on complex(c1);
mysql> show create table complex;
+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| complex | CREATE TABLE `complex` (
`pk1` int NOT NULL,
`pk2` varchar(47) NOT NULL,
`c1` tinyint NOT NULL,
`c2` datetime,
`c3` json,
`c4` blob,
PRIMARY KEY (`pk1`,`pk2`),
KEY `index1` (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin |
+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+SELECT pk FROM tab1 WHERE ((((col3 > 0 AND ((col0 >= 7 AND col0 <= 2)
AND (col0 <= 4 OR col4 < 5.82 OR col3 > 7) AND col0 >= 4) AND col0 <
0) AND ((col1 > 7.76))))) OR ((col1 > 7.23 OR (col0 <= 3) OR (col4 >=
2.72 OR col1 >= 8.63) OR (col3 >= 3 AND col3 <= 4)) AND ((col0 < 2 AND
col3 < 0 AND (col1 < 6.30 AND col4 >= 7.2)) AND (((col3 < 5 AND col4
IN (SELECT col1 FROM tab1 WHERE ((col3 >= 7 AND col3 <= 6) OR col0 < 0
OR col1 >= 0.64 OR col3 <= 7 AND (col3 >= 8) AND ((col3 <= 6) AND
((col0 = 1 AND col3 IS NULL)) OR col0 > 7 OR col3 IN (8,1,7,4) OR col3
> 7 AND col3 >= 5 AND (col3 < 0) OR col0 > 3 AND col4 > 1.21 AND col0
< 4 OR ((col4 > 9.30)) AND ((col3 >= 5 AND col3 <= 7))) AND col0 <= 5
OR ((col0 >= 1 AND col4 IS NULL AND col0 > 5 AND (col0 < 3) OR col4 <=
8.86 AND (col3 > 0) AND col3 = 8)) OR col3 >= 1 OR (col3 < 4 OR (col3
= 7 OR (col1 >= 4.84 AND col1 <= 5.61)) OR col3 >= 5 AND ((col3 < 4)
AND ((col3 > 9)) OR (col0 < 3) AND (((col0 IS NULL))) AND (col0 < 4))
AND ((col4 IN (0.79)))) OR (col4 = 6.26 AND col1 >= 5.64) OR col1 IS
NULL AND col0 < 1)))) AND ((((col3 < 9) OR ((col0 IS NULL) OR (((col1
>= 8.40 AND col1 <= 0.30) AND col3 IS NULL OR (col0 <= 7 OR ((col3 >
4))) AND col0 = 6)) OR col3 < 6 AND (((((((col1 > 4.8)) OR col0 < 9 OR
(col3 = 1))) AND col4 >= 4.12))) OR (((col1 > 1.58 AND col0 < 7))) AND
(col1 < 8.60) AND ((col0 > 1 OR col0 > 1 AND ((col3 >= 2 AND col3 <=
0) AND col0 <= 0) OR ((col0 >= 8)) AND (((col3 >= 8 AND col3 <= 8) OR
col0 > 4 OR col3 = 8)) AND col1 > 5.10) AND ((col0 < 7 OR (col0 < 6 OR
(col3 < 0 OR col4 >= 9.51 AND (col3 IS NULL AND col1 < 9.41 AND col1 =
1.9 AND col0 > 1 AND col3 < 9 OR (col4 IS NULL) OR col1 = 0.5 AND
(col0 >= 3) OR col4 = 9.25 OR ((col1 > 0.26)) AND col4 < 8.25 AND
(col0 >= 2) AND col3 IS NULL AND (col1 > 3.52) OR (((col4 < 7.24)) AND
col1 IS NULL) OR col0 > 3) AND col3 >= 4 AND col4 >= 2.5 AND col0 >= 0
OR (col3 > 3 AND col3 >= 3) AND col0 = 1 OR col1 <= 8.9 AND col1 >
9.66 OR (col3 > 9) AND col0 > 0 AND col3 >= 0 AND ((col4 > 8.39))))
AND (col1 IS NULL)))))) AND col1 <= 2.0 OR col4 < 1.8 AND (col4 = 6.59
AND col3 IN (3,9,0))))) OR col4 <= 4.25 OR ((col3 = 5))) OR (((col0 >
0)) AND col0 > 6 AND (col4 >= 6.56)))mysql> create table keyed (c1 int, c2 int, c3 int, c4 int, primary key(c1, c2));
mysql> show create table keyed;
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| keyed | CREATE TABLE `keyed` (
`c1` int NOT NULL,
`c2` int NOT NULL,
`c3` int,
`c4` int,
PRIMARY KEY (`c1`,`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin |
+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+mysql> alter table keyed drop primary key;
mysql> alter table keyed add primary key(c1);
mysql> show create table keyed;
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| keyed | CREATE TABLE `keyed` (
`c1` int NOT NULL,
`c2` int NOT NULL,
`c3` int,
`c4` int,
PRIMARY KEY (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin |
+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+mysql> create table keyless (c1 int, c2 int, c3 int, c4 int);
mysql> show create table keyless;
+---------+-------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+---------+-------------------------------------------------------------------------------------------------------------------------------------+
| keyless | CREATE TABLE `keyless` (
`c1` int,
`c2` int,
`c3` int,
`c4` int
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin |
+---------+-------------------------------------------------------------------------------------------------------------------------------------+mysql> insert into keyed values (0,0,0,0), (1,1,1,1), (2,2,2,2);
mysql> insert into keyless values (0,0,0,0), (1,1,1,1), (2,2,2,2);
mysql> call dolt_commit('-am', "Inserted values");
+----------------------------------+
| hash |
+----------------------------------+
| 089j3jom08iauhbmbl0mhur8pgsai6nh |
+----------------------------------+
mysql> update keyed set c4=10 where c1=2;
mysql> select * from dolt_diff_keyed where to_commit='WORKING';
+-------+-------+-------+-------+-----------+----------------+---------+---------+---------+---------+----------------------------------+-------------------------+-----------+
| to_c2 | to_c4 | to_c1 | to_c3 | to_commit | to_commit_date | from_c2 | from_c4 | from_c1 | from_c3 | from_commit | from_commit_date | diff_type |
+-------+-------+-------+-------+-----------+----------------+---------+---------+---------+---------+----------------------------------+-------------------------+-----------+
| 2 | 10 | 2 | 2 | WORKING | NULL | 2 | 2 | 2 | 2 | 089j3jom08iauhbmbl0mhur8pgsai6nh | 2022-06-21 22:00:52.081 | modified |
+-------+-------+-------+-------+-----------+----------------+---------+---------+---------+---------+----------------------------------+-------------------------+-----------+
mysql> update keyless set c4=10 where c1=2;
mysql> select * from dolt_diff_keyless where to_commit='WORKING';
+-------+-------+-------+-------+-----------+----------------+---------+---------+---------+---------+----------------------------------+-------------------------+-----------+
| to_c2 | to_c4 | to_c3 | to_c1 | to_commit | to_commit_date | from_c2 | from_c4 | from_c3 | from_c1 | from_commit | from_commit_date | diff_type |
+-------+-------+-------+-------+-----------+----------------+---------+---------+---------+---------+----------------------------------+-------------------------+-----------+
| NULL | NULL | NULL | NULL | WORKING | NULL | 2 | 2 | 2 | 2 | 089j3jom08iauhbmbl0mhur8pgsai6nh | 2022-06-21 22:00:52.081 | removed |
| 2 | 10 | 2 | 2 | WORKING | NULL | NULL | NULL | NULL | NULL | 089j3jom08iauhbmbl0mhur8pgsai6nh | 2022-06-21 22:00:52.081 | added |
+-------+-------+-------+-------+-----------+----------------+---------+---------+---------+---------+----------------------------------+-------------------------+-----------+mysql> create table employees (
id int,
last_name varchar(100),
first_name varchar(100),
age int,
primary key(id),
constraint over_18 check (age >= 18));
mysql> show create table employees;
+-----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| employees | CREATE TABLE `employees` (
`id` int NOT NULL,
`last_name` varchar(100),
`first_name` varchar(100),
`age` int,
PRIMARY KEY (`id`),
CONSTRAINT `over_18` CHECK ((`age` >= 18))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin |
+-----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
mysql> create table pay (id int,
salary int,
primary key(id),
foreign key (id) references employees(id));
mysql> show create table pay;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| pay | CREATE TABLE `pay` (
`id` int NOT NULL,
`salary` int,
PRIMARY KEY (`id`),
CONSTRAINT `kfkov1vc` FOREIGN KEY (`id`) REFERENCES `employees` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+mysql> insert into employees values (0, 'Smith', 'Ella', 34), (1, 'Baker', 'Jack', 27);
mysql> insert into pay values (0, 50000);
mysql> call dolt_commit('-am', "Data for foreign key doc");
+----------------------------------+
| hash |
+----------------------------------+
| kgjb1tdbqt3vsn2e3nv06n5a6jdaqtk8 |
+----------------------------------+
mysql> call dolt_checkout('-b', 'delete-parent');
+--------+
| status |
+--------+
| 0 |
+--------+
mysql> delete from employees where id=1;
mysql> call dolt_commit('-am', "Deleted Jack Baker, id=1");
+----------------------------------+
| hash |
+----------------------------------+
| pd8r1j7or0aonincnc8iutsdjqnkmtsb |
+----------------------------------+
mysql> call dolt_checkout('main');
+--------+
| status |
+--------+
| 0 |
+--------+
mysql> insert into pay values (1, 48000);
mysql> call dolt_commit('-am', "Added salary for Jack Baker id=1");
+----------------------------------+
| hash |
+----------------------------------+
| 44h9p2k59o59rc1lcenkg4dghe052um0 |
+----------------------------------+
mysql> call dolt_merge('delete-parent');
Error 1105: Constraint violation from merge detected, cannot commit transaction. Constraint violations from a merge must be resolved using the dolt_constraint_violations table before committing a transaction. To commit transactions with constraint violations set @@dolt_force_transaction_commit=1$ dolt remote add origin timsehn/replication_example
$ dolt config --add --local sqlserver.global.dolt_replicate_to_remote origin
$ dolt sql -q "create table test (pk int, c1 int, primary key(pk))"
$ dolt sql -q "insert into test values (0,0)"
Query OK, 1 row affected
$ dolt add test
$ dolt sql -q "call dolt_commit('-m', 'trigger replication')"
+----------------------------------+
| hash |
+----------------------------------+
| 7on23n1h8k22062mbebbt0ejm3i7dakd |
+----------------------------------+$ dolt clone timsehn/replication_example read_replica
cloning https://doltremoteapi.dolthub.com/timsehn/replication_example
28 of 28 chunks complete. 0 chunks being downloaded currently.
dolt $ cd read_replica/$ dolt config --add --local sqlserver.global.dolt_read_replica_remote origin
Config successfully updated.
$ dolt config --add --local sqlserver.global.dolt_replicate_heads main
Config successfully updated.
$ dolt sql -q "select * from test"
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
+----+----+$ dolt sql -q "insert into test values (2,2); call dolt_commit('-am', 'Inserted (2,2)');"
Query OK, 1 row affected
+----------------------------------+
| hash |
+----------------------------------+
| i97i9f1a3vrvd09pphiq0bbdeuf8riid |
+----------------------------------+$ dolt sql -q "select * from test"
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
+----+----+
$ dolt log -n 1
commit i97i9f1a3vrvd09pphiq0bbdeuf8riid (HEAD -> main, origin/main)
Author: Tim Sehn <[email protected]>
Date: Mon Jul 11 16:48:37 -0700 2022
Inserted (2,2)
% dolt clone taylor/us-schools
cloning https://doltremoteapi.dolthub.com/taylor/us-schools
141,350 of 141,350 chunks complete. 0 chunks being downloaded currently
% cd us-schools% dolt checkout -b taylor/add-missing-websites
Switched to branch 'taylor/add-missing-websites'
% dolt sql
# Welcome to the DoltSQL shell.
# Statements must be terminated with ';'.
# "exit" or "quit" (or Ctrl-D) to exit.
us_schools> update schools set website='https://www.cde.ca.gov/schooldirectory/details?cdscode=19111976102321' where name='HILLCREST' and city='REDONDO BEACH' and state='CA';
Query OK, 1 row affected
Rows matched: 1 Changed: 1 Warnings: 0
us_schools> update schools set website='https://www.cde.ca.gov/schooldirectory/details?cdscode=39322763932951' where name='HOLTON (KARL) HIGH' and city='STOCKTON' and state='CA';
Query OK, 1 row affected
Rows matched: 1 Changed: 1 Warnings: 0]
us_schools> exit;
Bye% dolt diff
diff --dolt a/schools b/schools
--- a/schools @ ml65mjlsqpd45htsq1oc741nj4ns64fe
+++ b/schools @ jlrm3n5scc9cdj7sh368i4scik81km32
+-----+--------------------+---------------+-------+---------------------+-------+-----------------------------------------------------------------------+----------+----------------+--------------------------------------+-------------------+---------------------+
| | name | city | state | address | zip | website | category | public_private | district | lat | lon |
+-----+--------------------+---------------+-------+---------------------+-------+-----------------------------------------------------------------------+----------+----------------+--------------------------------------+-------------------+---------------------+
| < | HILLCREST | REDONDO BEACH | CA | 200 N LUCIA AVE | 90277 | NULL | NULL | PUBLIC | LOS ANGELES COUNTY SPECIAL EDUCATION | 33.84496307373047 | -118.3777847290039 |
| > | HILLCREST | REDONDO BEACH | CA | 200 N LUCIA AVE | 90277 | https://www.cde.ca.gov/schooldirectory/details?cdscode=19111976102321 | NULL | PUBLIC | LOS ANGELES COUNTY SPECIAL EDUCATION | 33.84496307373047 | -118.3777847290039 |
| < | HOLTON (KARL) HIGH | STOCKTON | CA | 7650 S NEWCASTLE RD | 95213 | NULL | HIGH | PUBLIC | CEA SAN JOAQUIN COUNTY | 37.89115524291992 | -121.19744110107422 |
| > | HOLTON (KARL) HIGH | STOCKTON | CA | 7650 S NEWCASTLE RD | 95213 | https://www.cde.ca.gov/schooldirectory/details?cdscode=39322763932951 | HIGH | PUBLIC | CEA SAN JOAQUIN COUNTY | 37.89115524291992 | -121.19744110107422 |
+-----+--------------------+---------------+-------+---------------------+-------+-----------------------------------------------------------------------+----------+----------------+--------------------------------------+-------------------+---------------------+
% dolt add schools && dolt commit -m "Update two schools with websites"
commit qvbg0laf84umi1hkdkiooiciil2gtene
Author: Taylor Bantle <[email protected]>
Date: Fri Dec 03 14:15:38 -0800 2021
Update two schools with websites
% dolt push origin taylor/add-missing-websites
/ Tree Level: 1, Percent Buffered: 0.00%, Files Written: 0, Files Uploaded: 1, Current Upload Speed: 59 kB/s









AS OFdolt clone dolthub/ip-to-country && cd ip-to-country> dolt sql -q 'show tables'
+---------------+
| Table |
+---------------+
| IPv4ToCountry |
| IPv6ToCountry |
+---------------+> dolt sql-server
Starting server with Config HP="0.0.0.0:3306"|U="root"|P=""|T="28800000"|R="false"|L="info"$ dolt sql -q "insert into docs values (3,0)";
Query OK, 1 row affected
$ dolt status
On branch main
Changes not staged for commit:
(use "dolt add <table>" to update what will be committed)
(use "dolt checkout <table>" to discard changes in working directory)
modified: docs$ dolt diff
diff --dolt a/docs b/docs
--- a/docs @ c341qjl0eholuiu1k4pvujre7mc75qtc
+++ b/docs @ f7isl5tqm92ovogh6v8seq26lsjmiknk
+-----+----+----+
| | pk | c1 |
+-----+----+----+
| + | 3 | 0 |
+-----+----+----+
docs $ dolt sql -q "select * from dolt_diff_docs where to_commit='WORKING'"
+-------+-------+-----------+----------------+---------+---------+----------------------------------+-------------------------+-----------+
| to_c1 | to_pk | to_commit | to_commit_date | from_c1 | from_pk | from_commit | from_commit_date | diff_type |
+-------+-------+-----------+----------------+---------+---------+----------------------------------+-------------------------+-----------+
| 0 | 3 | WORKING | NULL | NULL | NULL | uhumidn2e7ucan59jk9vuabm7r5osggs | 2021-12-07 01:14:46.684 | added |
+-------+-------+-----------+----------------+---------+---------+----------------------------------+-------------------------+-----------+docs $ dolt status
On branch main
Changes not staged for commit:
(use "dolt add <table>" to update what will be committed)
(use "dolt checkout <table>" to discard changes in working directory)
modified: docs
docs $ dolt checkout docs
docs $ dolt status
On branch main
nothing to commit, working tree clean
docs $ dolt sql -q "select * from docs"
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
+----+----+docs $ dolt sql -q "select * from docs"
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
+----+----+
docs $ dolt branch
feature-branch
* main
docs $ dolt sql -q "insert into docs values (3,0)";
Query OK, 1 row affected
docs $ dolt checkout -b follow-me
Switched to branch 'follow-me'
docs $ dolt sql -q "select * from docs"
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
| 3 | 0 |
+----+----+
docs $ dolt status
On branch follow-me
Changes not staged for commit:
(use "dolt add <table>" to update what will be committed)
(use "dolt checkout <table>" to discard changes in working directory)
modified: docs
docs $ dolt diff
diff --dolt a/docs b/docs
--- a/docs @ c341qjl0eholuiu1k4pvujre7mc75qtc
+++ b/docs @ f7isl5tqm92ovogh6v8seq26lsjmiknk
+-----+----+----+
| | pk | c1 |
+-----+----+----+
| + | 3 | 0 |
+-----+----+----+mysql> insert into docs values (4,4);
mysql> select * from docs ;
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
| 3 | 0 |
| 4 | 4 |
+----+----+
mysql> call dolt_checkout('follow-me');
+--------+
| status |
+--------+
| 0 |
+--------+
mysql> select * from docs ;
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
| 3 | 0 |
+----+----+SELECT * FROM myTable AS OF 'kfvpgcf8pkd6blnkvv8e0kle8j6lug7a';
SELECT * FROM myTable AS OF 'myBranch';
SELECT * FROM myTable AS OF 'HEAD^2';
SELECT * FROM myTable AS OF TIMESTAMP('2020-01-01');
SELECT * FROM myTable AS OF 'myBranch' JOIN myTable AS OF 'yourBranch' AS foo;SHOW TABLES AS OF 'kfvpgcf8pkd6blnkvv8e0kle8j6lug7a';
SHOW CREATE TABLE myTable AS OF 'myBranch';
DESCRIBE myTable AS OF 'HEAD~';USE mydb/ia1ibijq8hq1llr7u85uivsi5lh3310pshow create table `mydb/ia1ibijq8hq1llr7u85uivsi5lh3310p`.myTable;SELECT * FROM dolt_history_mytable
WHERE state = "Virginia"
ORDER BY "commit_date"
+----------+------------+----------+-------------+-----------+---------------------------------+
| state | population | capital | commit_hash | committer | commit_date |
+----------+------------+----------+-------------+-----------+---------------------------------+
| Virginia | 691937 | NULL | ... | billybob | 1790-01-09 00:00:00.0 +0000 UTC |
| Virginia | 807557 | Richmond | ... | billybob | 1800-01-01 00:00:00.0 +0000 UTC |
| Virginia | 877683 | NULL | ... | billybob | 1810-01-01 00:00:00.0 +0000 UTC |
+----------+------------+----------+-------------+-----------+---------------------------------+SELECT * FROM dolt_commit_diff_mytable
WHERE to_commit = HASHOF('HEAD')
AND from_commit = HASHOF('HEAD~')
ORDER BY state, to_commit_date;call dolt_checkout('-b', 'old-view-def', '81223g1cpmib215gmov8686b6310p37d');-- Past data
view_test> select * from t1 as of '81223g1cpmib215gmov8686b6310p37d';
+---+---+
| a | b |
+---+---+
| 1 | 1 |
| 2 | 2 |
+---+---+
-- Past view definition
view_test> show create table `view_test/81223g1cpmib215gmov8686b6310p37d`.v1;
+------+--------------------------------------+
| View | Create View |
+------+--------------------------------------+
| v1 | CREATE VIEW `v1` AS select * from t1 |
+------+--------------------------------------+
-- Current data
view_test> select * from t1;
+---+---+
| a | b |
+---+---+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
+---+---+
-- Current view definition
view_test> show create table v1;
+------+-----------------------------------------------+
| View | Create View |
+------+-----------------------------------------------+
| v1 | CREATE VIEW `v1` AS select a+10, b+10 from t1 |
+------+-----------------------------------------------+
-- Select past data using current view definition
view_test> select * from v1 as of '81223g1cpmib215gmov8686b6310p37d';
+------+------+
| a+10 | b+10 |
+------+------+
| 11 | 11 |
| 12 | 12 |
+------+------+
-- Select past data using past view definition
view_test> select * from `view_test/81223g1cpmib215gmov8686b6310p37d`.v1;
+---+---+
| a | b |
+---+---+
| 1 | 1 |
| 2 | 2 |
+---+---+
-- Select past data using past view definition by checking out a new branch
view_test> call dolt_checkout('-b', 'old-view-def', '81223g1cpmib215gmov8686b6310p37d');
view_test> select * from v1;
+---+---+
| a | b |
+---+---+
| 1 | 1 |
| 2 | 2 |
+---+---+
















dolt diff --schema-- global variables default to persisted configuration or system defaults
mysql> select @@GLOBAL.max_connections;
+--------------------------+
| @@GLOBAL.max_connections |
+--------------------------+
| 150 |
+--------------------------+
-- session variables are initialized from global values
mysql> select @@SESSION.max_connections;
+---------------------------+
| @@SESSION.max_connections |
+---------------------------+
| 151 |
+---------------------------+
-- variable defaults to session value
mysql> select @@max_connections;
+---------------------------+
| @@SESSION.max_connections |
+---------------------------+
| 151 |
+---------------------------+-- some variables are read only
mysql> SET @@GLOBAL.basedir = '/';
Error 1105: Variable 'basedir' is a read only variable
-- some variables are "dynamic" at session time
mysql> SET @@autocommit = 1;
-- some variables are only globally "dynamic"
mysql> SET @@max_connections = 100;
Variable 'max_connections' is a GLOBAL variable and should be set with SET GLOBAL
-- global variable changes only affect new sessions
mysql> SET @@GLOBAL.max_connections = 100;
mysql> select @@GLOBAL.max_connections;
+--------------------------+
| @@GLOBAL.max_connections |
+--------------------------+
| 100 |
+--------------------------+
-- editing a global variable only affects new sessions
mysql> select @@max_connections;
+---------------------------+
| @@SESSION.max_connections |
+---------------------------+
| 151 |
+---------------------------+-- persisting a variable with PERSIST affects existing GLOBAL value and outlives server restarts
mysql> SET @@PERSIST.max_connections = 99;
mysql> select @@GLOBAL.max_connections;
+---------------------------+
| @@SESSION.max_connections |
+---------------------------+
| 99 |
+---------------------------+
-- persisting a variable with PERSIST_ONLY will only impact restarted servers
mysql> SET @@PERSIST_ONLY.max_connections = 10;
mysql> select @@GLOBAL.max_connections;
+---------------------------+
| @@SESSION.max_connections |
+---------------------------+
| 99 |
+---------------------------+mysql> show variables like 'dolt_%';
+-------------------------------+-------+
| Variable_name | Value |
+-------------------------------+-------+
| dolt_allow_commit_conflicts | 0 |
| dolt_async_replication | 0 |
| dolt_force_transaction_commit | 0 |
| dolt_read_replica_remote | |
| dolt_replicate_all_heads | 0 |
| dolt_replicate_heads | |
| dolt_replicate_to_remote | |
| dolt_skip_replication_errors | 0 |
| dolt_transaction_commit | 0 |
| dolt_transactions_disabled | 0 |
+-------------------------------+-------+mydb> show variables like 'mydb_%' ;
+---------------------+----------------------------------+
| Variable_name | Value |
+---------------------+----------------------------------+
| mydb_default_branch | |
| mydb_head | lv1hhlqsfn2ikhgogkts7c8399k7evik |
| mydb_head_ref | refs/heads/main |
| mydb_staged | egnkhhepjlhsfhj4v0uhuna4sbcmstif |
| mydb_working | egnkhhepjlhsfhj4v0uhuna4sbcmstif |
+---------------------+----------------------------------+% dolt clone taylor/us-schools
cloning https://doltremoteapi.dolthub.com/taylor/us-schools
141,350 of 141,350 chunks complete. 0 chunks being downloaded currently.mysql --host 127.0.0.1 --port 3306 -u root mydb/feature-branchUSE `mydb/feature-branch`USE `mydb/ia1ibijq8hq1llr7u85uivsi5lh3310p`
USE `mydb/v1.0`insert into `mydatabase/feature-branch`.accounts (id) values (1);SELECT * from `mydatabase/ia1ibijq8hq1llr7u85uivsi5lh3310p`.accounts;SELECT * from `mydatabase/v1.0`.accounts;CALL DOLT_CHECKOUT('-b', 'new-branch');CALL DOLT_CHECKOUT('-b', 'new-branch-at-commit', 'ia1ibijq8hq1llr7u85uivsi5lh3310p')start transaction;
insert into `mydb/branch1`.t1 values (100);
insert into `mydb/branch2`.t1 values (200);
commit; -- ERROR: can only commit changes to one branch at a timestart transaction;
call dolt_checkout('branch1');
insert into t1 values (100);
call dolt_checkout('branch2');
insert into t1 values (200);
commit; -- ERROR: can only commit changes to one branch at a timeset autocommit = on;
use mydb/branch1;
insert into t1 values (1); -- modifying the `branch1` branch
use mydb/branch2;
insert into t1 values (2); -- modifying the `branch2` branch
use mydb;
insert into t1 values (3); -- modifying the `main` branchset autocommit = on;
call dolt_checkout('branch1');
insert into t1 values (1); -- modifying the `branch1` branch
call dolt_checkout('branch2');;
insert into t1 values (2); -- modifying the `branch2` branch
use mydb;
insert into t1 values (3); -- modifying the `branch2` branch# Show only new tables and inserted rows as SQL
dolt diff HEAD~1 --filter=added -r sqldocs $ dolt sql -q "alter table docs add column c1 int"
docs $ dolt diff
diff --dolt a/docs b/docs
--- a/docs @ 90tss7r2gfraa2cjugganbbtg5j6kjfc
+++ b/docs @ nt808mhhienne2dss4mjdcj8jrdig6ml
CREATE TABLE `docs` (
`pk` int NOT NULL,
+ `c1` int,
PRIMARY KEY (`pk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+-----+----+----+
| < | pk | |
| > | pk | c1 |
+-----+----+----+
+-----+----+----+docs $ dolt sql -q "insert into docs values (1,0),(2,1)"
Query OK, 2 rows affected
docs $ dolt diff
diff --dolt a/docs b/docs
--- a/docs @ cj9ln2kg7u6aiprr7i24rf48es4tk1eg
+++ b/docs @ qfiv5iankh0gltpov71h0mcvaqvftvlh
+-----+----+----+
| | pk | c1 |
+-----+----+----+
| + | 1 | 0 |
| + | 2 | 1 |
+-----+----+----+
docs $ dolt sql -q "delete from docs where pk=0"
Query OK, 1 row affected
docs $ dolt diff
diff --dolt a/docs b/docs
--- a/docs @ cj9ln2kg7u6aiprr7i24rf48es4tk1eg
+++ b/docs @ 8aca41vfss9kcqkrdhos25be87nlu3b9
+-----+----+----+
| | pk | c1 |
+-----+----+----+
| - | 0 | 0 |
| + | 1 | 0 |
| + | 2 | 1 |
+-----+----+----+docs $ dolt sql -q "update docs set c1=1 where pk=1"
Query OK, 1 row affected
Rows matched: 1 Changed: 1 Warnings: 0
docs $ dolt diff
diff --dolt a/docs b/docs
--- a/docs @ 8aca41vfss9kcqkrdhos25be87nlu3b9
+++ b/docs @ 2lcu9e49ia08icjonmt3l0s7ph2cdb5s
+-----+----+----+
| | pk | c1 |
+-----+----+----+
| < | 1 | 0 |
| > | 1 | 1 |
+-----+----+----+docs $ dolt sql -q "insert into no_pk values (0,0,0),(1,1,1),(2,2,2)"
Query OK, 3 rows affected
docs $ dolt diff
diff --dolt a/no_pk b/no_pk
--- a/no_pk @ df9bd3mf77t2gicphep87nvuobqjood7
+++ b/no_pk @ 7s8jhc9nlnouhai8kdtsssrm1hpegpf0
+-----+----+----+----+
| | c1 | c2 | c3 |
+-----+----+----+----+
| + | 1 | 1 | 1 |
| + | 2 | 2 | 2 |
| + | 0 | 0 | 0 |
+-----+----+----+----+
docs $ dolt commit -am "Added data to no_pk table"
commit mjbtf27jidi86jrm32lvop7mmlpgplbg
Author: Tim Sehn <[email protected]>
Date: Mon Dec 06 13:38:19 -0800 2021
Added data to no_pk table
docs $ dolt sql -q "delete from no_pk where c1=0"
Query OK, 1 row affected
docs $ dolt diff
diff --dolt a/no_pk b/no_pk
--- a/no_pk @ 7s8jhc9nlnouhai8kdtsssrm1hpegpf0
+++ b/no_pk @ s23c851fomfcjaiufm25mi9mlnhurh2c
+-----+----+----+----+
| | c1 | c2 | c3 |
+-----+----+----+----+
| - | 0 | 0 | 0 |
+-----+----+----+----+docs $ dolt sql -q "update no_pk set c1=0 where c1=1"
Query OK, 1 row affected
Rows matched: 1 Changed: 1 Warnings: 0
docs $ dolt diff
diff --dolt a/no_pk b/no_pk
--- a/no_pk @ s23c851fomfcjaiufm25mi9mlnhurh2c
+++ b/no_pk @ 18k2q3pav9a2v8mkk26nhhhss4eda86k
+-----+----+----+----+
| | c1 | c2 | c3 |
+-----+----+----+----+
| - | 1 | 1 | 1 |
| + | 0 | 1 | 1 |
+-----+----+----+----+docs $ dolt sql -q "select * from dolt_diff_docs"
+-------+-------+----------------------------------+-----------------------------------+---------+---------+----------------------------------+-----------------------------------+-----------+
| to_c1 | to_pk | to_commit | to_commit_date | from_c1 | from_pk | from_commit | from_commit_date | diff_type |
+-------+-------+----------------------------------+-----------------------------------+---------+---------+----------------------------------+-----------------------------------+-----------+
| 0 | 0 | dmmkbaiq6g6mm0vruc07utpns47sjkv7 | 2021-12-06 21:31:54.041 +0000 UTC | NULL | NULL | v42og53ru3k3hak3decm23crp5p6kd2f | 2021-12-06 21:27:53.886 +0000 UTC | added |
| 1 | 1 | 5emu36fgedeurr6qk5uq6mj96k5j53j9 | 2021-12-06 21:36:02.076 +0000 UTC | 0 | 1 | ne14m8g2trlunju5a2mu735kjioocmll | 2021-12-06 21:34:12.585 +0000 UTC | modified |
| NULL | NULL | ne14m8g2trlunju5a2mu735kjioocmll | 2021-12-06 21:34:12.585 +0000 UTC | 0 | 0 | dmmkbaiq6g6mm0vruc07utpns47sjkv7 | 2021-12-06 21:31:54.041 +0000 UTC | removed |
| 0 | 1 | ne14m8g2trlunju5a2mu735kjioocmll | 2021-12-06 21:34:12.585 +0000 UTC | NULL | NULL | dmmkbaiq6g6mm0vruc07utpns47sjkv7 | 2021-12-06 21:31:54.041 +0000 UTC | added |
| 1 | 2 | ne14m8g2trlunju5a2mu735kjioocmll | 2021-12-06 21:34:12.585 +0000 UTC | NULL | NULL | dmmkbaiq6g6mm0vruc07utpns47sjkv7 | 2021-12-06 21:31:54.041 +0000 UTC | added |
+-------+-------+----------------------------------+-----------------------------------+---------+---------+----------------------------------+-----------------------------------+-----------+
docs $ dolt sql -q "select * from dolt_diff_docs where from_pk=0"
+-------+-------+----------------------------------+-----------------------------------+---------+---------+----------------------------------+-----------------------------------+-----------+
| to_c1 | to_pk | to_commit | to_commit_date | from_c1 | from_pk | from_commit | from_commit_date | diff_type |
+-------+-------+----------------------------------+-----------------------------------+---------+---------+----------------------------------+-----------------------------------+-----------+
| NULL | NULL | ne14m8g2trlunju5a2mu735kjioocmll | 2021-12-06 21:34:12.585 +0000 UTC | 0 | 0 | dmmkbaiq6g6mm0vruc07utpns47sjkv7 | 2021-12-06 21:31:54.041 +0000 UTC | removed |
+-------+-------+----------------------------------+-----------------------------------+---------+---------+----------------------------------+-----------------------------------+-----------+> docker pull dolthub/dolt:latest
> docker run dolthub/dolt:latest version
dolt version 1.5.0
>
> docker pull dolthub/dolt:1.4.2
> docker run dolthub/dolt:1.4.2 version
dolt version 1.4.2> docker run dolthub/dolt-sql-server:latest --help> docker run -e DOLT_ROOT_PASSWORD=secret2 -e DOLT_ROOT_HOST=% -p 3307:3306 dolthub/dolt-sql-server:latest> mysql --host 0.0.0.0 -P 3307 -u root -p secret2> docker run -p 3307:3306 dolthub/dolt-sql-server:latest -l debug --no-auto-commit> docker run -p 3307:3306 -v /Users/jennifer/docker/server:/etc/dolt/servercfg.d dolthub/dolt-sql-server:latest> docker run -p 3307:3306 -v /Users/jennifer/docker/databases:/var/lib/dolt dolthub/dolt-sql-server:latestshared > ls
databases dolt server
shared > docker run -e DOLT_ROOT_HOST='%' -p 3307:3306 -v $PWD/server:/etc/dolt/servercfg.d -v $PWD/dolt:/etc/dolt/doltcfg.d -v $PWD/databases:/var/lib/dolt dolthub/dolt-sql-server:latest
2022-10-27 18:07:51+00:00 [Note] [Entrypoint]: Entrypoint script for Dolt Server 1.5.0 starting.
2022-10-27 18:07:51+00:00 [Note] [Entrypoint]: Checking for config provided in /etc/dolt/doltcfg.d
2022-10-27 18:07:51+00:00 [Note] [Entrypoint]: /etc/dolt/doltcfg.d/config.json file is found
2022-10-27 18:07:51+00:00 [Note] [Entrypoint]: Checking for config provided in /etc/dolt/servercfg.d
2022-10-27 18:07:51+00:00 [Note] [Entrypoint]: /etc/dolt/servercfg.d/config.yaml file is found
2022-10-27 18:07:51+00:00 [Warn] [Entrypoint]: /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
2022-10-27 18:07:51+00:00 [Note] [Entrypoint]: Dolt Server 1.5.0 is started.
Starting server with Config HP="0.0.0.0:3306"|T="28800000"|R="false"|L="debug"
> mysql --host 0.0.0.0 -P 3307 -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.7.9-Vitess
Copyright (c) 2000, 2022, 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> create database doltdb;
Query OK, 1 row affected (0.08 sec)
mysql> use doltdb;
Database changed
mysql> create table mytable(pk int primary key, col1 varchar(20));
Query OK, 0 rows affected (0.02 sec)
mysql> insert into mytable values (1, 'first row'),(2, 'second row');
Query OK, 2 row affected (0.02 sec)
mysql> exitshared > cd databases && ls
doltdb
databases > cd doltdb && dolt sql -q "SELECT * FROM mytable"
+----+------------+
| pk | col1 |
+----+------------+
| 1 | first row |
| 2 | second row |
+----+------------+
shared > cd databases && ls
doltdb
databases > docker run -v $PWD/doltdb:/doltdb dolthub/dolt:latest sql -q "USE doltdb; SELECT * FROM mytable;"
Database changed
+----+------------+
| pk | col1 |
+----+------------+
| 1 | first row |
| 2 | second row |
+----+------------+
livenessProbe:
exec:
command: ["dolt", "--host", "127.0.0.1", "--port", "3306", "--no-tls", "sql", "-q", "select current_timestamp();"]
initialDelaySeconds: 60
periodSeconds: 10
readinessProbe:
exec:
command: ["dolt", "--host", "127.0.0.1", "--port", "3306", "--no-tls", "sql", "-q", "select current_timestamp();"]
initialDelaySeconds: 40
periodSeconds: 10log_level: info
listener:
host: localhost
port: 11227
max_connections: 100
read_timeout_millis: 28800000
write_timeout_millis: 28800000
metrics:
labels: {}
host: localhost
port: 11228












global:
scrape_interval: 15s
scrape_configs:
- job_name: "dolt-sql-server"
static_configs:
- targets: ["localhost:11228"].doltcfg/privileges.dbSELECT /*+ JOIN_ORDER(arg1,arg2) */ 1
SELECT /*+ JOIN_ORDER(arg1,arg2) NO_ICP */ 1SELECT /*+ JOIN_ORDER(xy,uv,ab) LOOKUP_JOIN(xy,uv) HASH_JOIN(uv,ab) */ 1
FROM xy
JOIN uv on x = u
JOIN ab on a = u;CREATE TABLE xy (x int primary key, y int);
INSERT INTO xy values (1,1), (2,2);
ANALYZE TABLE xy;
SELECT * from information_schema.tables;
+-------------+------------+-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| SCHEMA_NAME | TABLE_NAME | COLUMN_NAME | HISTOGRAM |
+-------------+------------+-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tmp4 | xy | x | {"statistic": {"avg_size": 0, "buckets": [{"bound_count": 1, "distinct_count": 2, "mcv_counts": [1,1], "mcvs": [[1],[2]], "null_count": 0, "row_count": 2, "upper_bound": [2]}], "columns": ["x"], "created_at": "2023-11-14T11:33:32.250178-08:00", "distinct_count": 2, "null_count": 2, "qualifier": "tmp4.xy.PRIMARY", "row_count": 2, "types:": ["int"]}} |
+-------------+------------+-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+create table horses (id int primary key, name varchar(10), key(name));
insert into horses select x, 'Steve' from (with recursive inputs(x) as (select 1 union select x+1 from inputs where x < 1000) select * from inputs) dt;
analyze table horses;
select `index`, `position`, row_count, distinct_count, columns, upper_bound, upper_bound_cnt, mcv1 from dolt_statistics;
+---------+----------+-----------+----------------+----------+-------------+-----------------+-----------+
| index | position | row_count | distinct_count | columns | upper_bound | upper_bound_cnt | mcv1 |
+---------+----------+-----------+----------------+----------+-------------+-----------------+-----------+
| primary | 0 | 344 | 344 | ["id"] | [344] | 1 | [344] |
| primary | 1 | 125 | 125 | ["id"] | [469] | 1 | [469] |
| primary | 2 | 249 | 249 | ["id"] | [718] | 1 | [718] |
| primary | 3 | 112 | 112 | ["id"] | [830] | 1 | [830] |
| primary | 4 | 170 | 170 | ["id"] | [1000] | 1 | [1000] |
| name | 5 | 260 | 1 | ["name"] | ["Steve"] | 260 | ["Steve"] |
| name | 6 | 237 | 1 | ["name"] | ["Steve"] | 237 | ["Steve"] |
| name | 7 | 137 | 1 | ["name"] | ["Steve"] | 137 | ["Steve"] |
| name | 8 | 188 | 1 | ["name"] | ["Steve"] | 188 | ["Steve"] |
| name | 9 | 178 | 1 | ["name"] | ["Steve"] | 178 | ["Steve"] |
+---------+----------+-----------+----------------+----------+-------------+-----------------+-----------+call dolt_stats_stop();
call dolt_stats_purge();call dolt_stats_restart();
call dolt_stats_once();— on version 1.51.0 or higher
SET @@PERSIST.dolt_stats_enabled = 0;
— up to 1.50.x
SET @@PERSIST.dolt_stats_auto_refresh_enabled = 0;% dolt remote add backup https://doltremoteapi.dolthub.com/timsehn/backup-example
$ dolt remote -v
backup https://doltremoteapi.dolthub.com/timsehn/backup-examplemysql> use backup_example;
mysql> create table test (pk int, c1 int, primary key(pk));
mysql> insert into test values (0,0);
mysql> call dolt_add('test');
mysql> call dolt_commit('-m', "Created table and inserted values to be backed up");
+----------------------------------+
| hash |
+----------------------------------+
| slm5cql6ri8l4vd7uemvqhj6p2e2g98k |
+----------------------------------+
mysql> call dolt_push('backup', 'main');
+---------+
| success |
+---------+
| 1 |
+---------+$ mkdir -p /Users/timsehn/liquidata/dolt/backups/backup-example
$ dolt backup add local-backup file:///Users/timsehn/liquidata/dolt/backups/backup-example
$ dolt backup sync local-backup
Uploaded 3.1 kB of 3.1 kB @ 0 B/s.
$$ dolt backup add dolthub-backup https://doltremoteapi.dolthub.com/username/my-database-backup
$ dolt backup sync dolthub-backupmysql> use backup_example;
mysql> insert into test values (1,1);
mysql> call dolt_backup('sync', 'local-backup');
+---------+
| success |
+---------+
| 1 |
+---------+$ dolt backup restore file:///Users/timsehn/liquidata/dolt/backups/backup-example backup-restore
Downloaded 14 chunks, 3.5 kB @ 0 B/s.
$ cd backup-restore/
backup-restore $ dolt sql -q "select * from test"
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
+----+----+CREATE USER user1@'%' IDENTIFIED BY 'pass1';
GRANT ALL ON *.* to user1@'%';CALL DOLT_MERGE('feature-branch');START TRANSACTION;SET ROLE
+--------------+-----------+
| fast_forward | conflicts |
+--------------+-----------+
| 0 | 1 |
+--------------+-----------+> SELECT * from DOLT_MERGE_STATUS;
+------------+--------+---------------+--------+-----------------+
| is_merging | source | source_commit | target | unmerged_tables |
+------------+--------+---------------+--------+-----------------+
| false | NULL | NULL | NULL | NULL |
+------------+--------+---------------+--------+-----------------+> SELECT table_name, description, base_schema, our_schema, their_schema FROM dolt_schema_conflicts;
+------------+--------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------+
| table_name | description | base_schema | our_schema | their_schema |
+------------+--------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------+
| people | different column definitions for our | CREATE TABLE `people` ( | CREATE TABLE `people` ( | CREATE TABLE `people` ( |
| | column age and their column age | `id` int NOT NULL, | `id` int NOT NULL, | `id` int NOT NULL, |
| | | `last_name` varchar(120), | `last_name` varchar(120), | `last_name` varchar(120), |
| | | `first_name` varchar(120), | `first_name` varchar(120), | `first_name` varchar(120), |
| | | `birthday` datetime(6), | `birthday` datetime(6), | `birthday` datetime(6), |
| | | `age` int DEFAULT '0', | `age` float, | `age` bigint, |
| | | PRIMARY KEY (`id`) | PRIMARY KEY (`id`) | PRIMARY KEY (`id`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; |
+------------+--------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------+SELECT * FROM dolt_conflicts;
+--------+---------------+
| table | num_conflicts |
+--------+---------------+
| people | 3 |
+--------+---------------+DESCRIBE dolt_conflicts_people;
+------------------+-------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+-------------+------+------+---------+-------+``
| base_occupation | varchar(32) | YES | | | |
| base_last_name | varchar(64) | YES | | | |
| base_id | int | YES | | | |
| base_first_name | varchar(32) | YES | | | |
| base_age | int | YES | | | |
| our_occupation | varchar(32) | YES | | | |
| our_last_name | varchar(64) | YES | | | |
| our_id | int | YES | | | |
| our_first_name | varchar(32) | YES | | | |
| our_age | int | YES | | | |
| their_occupation | varchar(32) | YES | | | |
| their_last_name | varchar(64) | YES | | | |
| their_id | int | YES | | | |
| their_first_name | varchar(32) | YES | | | |
| their_age | int | YES | | | |
+------------------+-------------+------+------+---------+-------+
SELECT * FROM dolt_conflicts_people;
+-----------------+----------------+---------+-----------------+----------+----------------+---------------+--------+----------------+---------+------------------+-----------------+----------+------------------+-----------+
| base_occupation | base_last_name | base_id | base_first_name | base_age | our_occupation | our_last_name | our_id | our_first_name | our_age | their_occupation | their_last_name | their_id | their_first_name | their_age |
+-----------------+----------------+---------+-----------------+----------+----------------+---------------+--------+----------------+---------+------------------+-----------------+----------+------------------+-----------+
| Homemaker | Simpson | 1 | Marge | 37 | Homemaker | Simpson | 1 | Marge | 36 | NULL | NULL | NULL | NULL | NULL |
| Bartender | Szyslak | 2 | Moe | NULL | Bartender | Szyslak | 2 | Moe | 62 | Bartender | Szyslak | 2 | Moe | 60 |
| NULL | NULL | NULL | NULL | NULL | Student | Simpson | 3 | Bart | 10 | Student | Simpson | 3 | Lisa | 8 |
+-----------------+----------------+---------+-----------------+----------+----------------+---------------+--------+----------------+---------+------------------+-----------------+----------+------------------+-----------+DELETE FROM dolt_conflicts_people;-- Replace existing rows with rows taken with their_* values as long
-- as their_id is not null (rows deleted in theirs)
REPLACE INTO people (id,first_name,last_name,age) (
SELECT their_id, their_first_name, their_last_name, their_age
FROM dolt_conflicts_people
WHERE their_id IS NOT NULL
);
-- Delete any rows that are deleted in theirs
DELETE FROM PEOPLE WHERE id IN (
SELECT base_id
FROM dolt_conflicts
WHERE base_id IS NOT NULL AND their_id IS NULL
);
-- mark conflicts resolved
DELETE FROM dolt_conflicts_people;UPDATE dolt_conflicts_people
SET our_first_name = their_first_name,
our_last_name = their_last_name,
our_age = their_age
WHERE their_id IS NOT NULL;set @@dolt_allow_commit_conflicts = 1;CREATE TABLE parent (pk INT PRIMARY KEY);
CREATE TABLE child (
pk INT PRIMARY KEY,
parent_fk INT,
FOREIGN KEY (parent_fk) REFERENCES parent (pk)
);INSERT INTO parent values (1);
CALL DOLT_COMMIT('-Am', 'setup');
CALL DOLT_CHECKOUT('-b', 'branch_to_merge');
INSERT INTO child values (1, 1);
CALL DOLT_COMMIT('-Am', 'add a child of parent 1');
CALL DOLT_CHECKOUT('main');
DELETE from parent where pk = 1;
CALL DOLT_COMMIT('-Am', 'delete parent 1');> START TRANSACTION;
> CALL DOLT_MERGE('branch_to_merge');
+--------------+-----------+
| fast_forward | conflicts |
+--------------+-----------+
| 0 | 1 |
+--------------+-----------+> SELECT * from dolt_constraint_violations;
+-------+----------------+
| table | num_violations |
+-------+----------------+
| child | 1 |
+-------+----------------+
> select violation_type, pk, parent_fk from dolt_constraint_violations_child;
+----------------+----+-----------+
| violation_type | pk | parent_fk |
+----------------+----+-----------+
| foreign key | 1 | 1 |
+----------------+----+-----------+DELETE from child where pk = 1;
DELETE from dolt_constraint_violations_child;
CALL DOLT_COMMIT('-Am', 'merge branch_to_merge into main');docs $ dolt sql -q "insert into docs values (10,10)"
Query OK, 1 row affected
docs $ dolt diff
diff --dolt a/docs b/docs
--- a/docs @ 2lcu9e49ia08icjonmt3l0s7ph2cdb5s
+++ b/docs @ vpl1rk08eccdfap89kkrff1pk3r8519j
+-----+----+----+
| | pk | c1 |
+-----+----+----+
| + | 10 | 10 |
+-----+----+----+
docs $ dolt commit -am "Added a row on a branch"
commit ijrrpul05o5j0kgsk1euds9pt5n5ddh0
Author: Tim Sehn <[email protected]>
Date: Mon Dec 06 15:06:39 -0800 2021
Added a row on a branch
docs $ dolt checkout main
Switched to branch 'main'
docs $ dolt sql -q "select * from docs"
+----+----+
| pk | c1 |
+----+----+
| 1 | 1 |
| 2 | 1 |
+----+----+
docs $ dolt merge check-out-new-branch
Updating f0ga78jrh4llc0uus8h2refopp6n870m..ijrrpul05o5j0kgsk1euds9pt5n5ddh0
Fast-forward
docs $ dolt sql -q "select * from docs"
+----+----+
| pk | c1 |
+----+----+
| 1 | 1 |
| 2 | 1 |
| 10 | 10 |
+----+----+docs $ dolt sql -q "select * from docs"
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
+----+----+
docs $ dolt branch make-conflicts
docs $ dolt sql -q "update docs set c1=10 where pk=1"
Query OK, 1 row affected
Rows matched: 1 Changed: 1 Warnings: 0
docs $ dolt sql -q "select * from docs"
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 10 |
| 2 | 2 |
+----+----+
docs $ dolt add docs
docs $ dolt commit -m "Made pk=1, c1=10"
commit jjkqslpnbbvjh7efdhcsqdh68ekl0leb
Author: Tim Sehn <[email protected]>
Date: Mon Dec 06 16:40:12 -0800 2021
Made pk=1, c1=10
docs $ dolt checkout make-conflicts
Switched to branch 'make-conflicts'
docs $ dolt sql -q "select * from docs"
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
+----+----+
docs $ dolt sql -q "update docs set c1=0 where pk=1"
Query OK, 1 row affected
Rows matched: 1 Changed: 1 Warnings: 0
docs $ dolt sql -q "select * from docs"
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 0 |
| 2 | 2 |
+----+----+
docs $ dolt add docs
docs $ dolt commit -m "Made pk=1, c1=0"
commit 5gmleh5ksmtsdeeaqeagpsitpug4ntoj
Author: Tim Sehn <[email protected]>
Date: Mon Dec 06 16:40:54 -0800 2021
Made pk=1, c1=0
docs $ dolt checkout main
Switched to branch 'main'
docs $ dolt merge make-conflicts
Updating jjkqslpnbbvjh7efdhcsqdh68ekl0leb..5gmleh5ksmtsdeeaqeagpsitpug4ntoj
Auto-merging docs
CONFLICT (content): Merge conflict in docs
Automatic merge failed; fix conflicts and then commit the result.
docs $ dolt conflicts cat docs
+-----+--------+----+----+
| | | pk | c1 |
+-----+--------+----+----+
| | base | 1 | 1 |
| * | ours | 1 | 10 |
| * | theirs | 1 | 0 |
+-----+--------+----+----+docs $ dolt conflicts cat docs
+-----+--------+----+----+
| | | pk | c1 |
+-----+--------+----+----+
| | base | 1 | 1 |
| * | ours | 1 | 10 |
| * | theirs | 1 | 0 |
+-----+--------+----+----+
docs $ dolt conflicts resolve --ours docs
docs $ dolt conflicts cat docs
docs $ dolt sql -q "select * from docs"
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 10 |
| 2 | 2 |
+----+----+
docs $ dolt add docs
docs $ dolt commit -m "Resolved conflict"
commit c8mff2tp5b3tg4j4u07dnmp912btltim
Merge: jjkqslpnbbvjh7efdhcsqdh68ekl0leb 5gmleh5ksmtsdeeaqeagpsitpug4ntoj
Author: Tim Sehn <[email protected]>
Date: Mon Dec 06 16:44:22 -0800 2021
Resolved conflict
$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.9-Vitess
Copyright (c) 2000, 2022, 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>conn_string_base = "mysql+mysqlconnector://"
engine = create_engine(conn_string_base +
"{user}@127.0.0.1:{port}/{db}".format(user=user,
port=port,
db=db)dolt_branch_controldolt_branch_namespace_controlwrite Permissionadmin Permissiondolt login
Credentials created successfully.
pub key: l5bfb43fmqu8u8b59m8fp5cb8o1jcpt8281u94t80us35u6fgavg
/Users/dustin/.dolt/creds/6h68h8brsfu9580rqupi3h9icfhtd5s28ikoguejqqesq.jwk
Opening a browser to:
https://dolthub.com/settings/credentials#l5bfb43fmqu8u8b59m8fp5cb8o1jcpt8281u94t80us35u6fgavg
Please associate your key with your account.
Checking remote server looking for key association.
Retrying in 2Key successfully associated with user: coffeegoddd email [email protected]mysql> call dolt_checkout('main');
+--------+---------------------------+
| status | message |
+--------+---------------------------+
| 0 | Switched to branch 'main' |
+--------+---------------------------+
1 row in set (0.02 sec)mysql> call dolt_remote('add', 'origin', 'coffeegoddd/getting_started');
+--------+
| status |
+--------+
| 0 |
+--------+
1 row in set (0.03 sec)mysql> call dolt_push('origin', 'main');
+--------+
| status |
+--------+
| 0 |
+--------+
1 row in set (0.77 sec)dolt remote add origin file:///Users/brian/datasets/menusdolt clone file:///Users/brian/datasets/menusdolt remote add origin file:///c:/Users/brian/datasets/menusdolt clone file:///c:/Users/brian/datasets/menus# Add a git remote (local path, ssh, or https all work as long as it ends in .git)
dolt remote add origin ../remote.git
# Or select a non-default ref in the git repository
dolt remote add --ref refs/dolt/custom origin [email protected]:org/repo.git
# Push like normal
dolt push --set-upstream origin main# SSH
dolt remote add origin [email protected]:ORG/REPO.git
dolt push --set-upstream origin main
# HTTPS
dolt remote add origin https://github.com/ORG/REPO.git
dolt push --set-upstream origin maindolt clone ../remote.git
# Or with a non-default ref
dolt clone --ref refs/dolt/custom [email protected]:org/repo.git repo2CALL dolt_remote('add', 'origin', '../remote.git');
CALL dolt_push('origin', 'main');
CALL dolt_remote('add', '--ref', 'refs/dolt/custom', 'origin', '../remote.git');
CALL dolt_clone('--ref', 'refs/dolt/custom', '../remote.git', 'repo2');dolt remote add origin aws://[dolt_dynamo_table:dolt_remotes_s3_storage]/menusdolt clone aws://[dolt_remotes:dolt_remotes_storage]/menusdolt remote add --aws-creds-profile prod-profile --aws-region us-west-2 origin aws://[dolt_dynamo_table:dolt_remotes_s3_storage]/menusdolt clone --aws-creds-profile prod-profile --aws-region us-west-2 origin aws://[dolt_dynamo_table:dolt_remotes_s3_storage]/menusdolt remote add origin gs://BUCKET/path/for/remotedolt remote add origin oci://BUCKET/path/for/remote$dolt remote add origin Dolthub/menus
$dolt remote -v
origin https://doltremoteapi.dolthub.com/Dolthub/menusremotesrv --http-port 1234 --dir ./remote_storage$ cat config.yaml
remotesapi:
port: 8080
$ dolt sql -q "create database exampledb"
$ dolt sql -q "create user 'exampleuser'@'%' identified by 'examplepassword'"
$ dolt sql -q "grant clone_admin on *.* to 'exampleuser'@'%'"
$ dolt sql-server --config config.yaml &$ DOLT_REMOTE_PASSWORD=examplepassword dolt clone --user exampleuser https://localhost:8080/exampledb exampledb
$ cd exampledb
$ dolt log --oneline
q17m6q60c9qnu85kf37r1bb78bdq7pac (HEAD -> main, remotes/origin/main) Initialize data repository$ dolt sql -q "GRANT ALL PRIVILEGES ON exampledb.* TO 'exampleuser'@'%' WITH GRANT OPTION"$ DOLT_REMOTE_PASSWORD=examplepassword dolt push origin --user exampleuser HEAD:mainfresh> show databases;
+--------------------+
| Database |
+--------------------+
| fresh |
| information_schema |
| mysql |
+--------------------+
3 rows in set (0.00 sec)
fresh> set @@dolt_show_branch_databases = 1;
fresh> show databases;
+--------------------+
| Database |
+--------------------+
| fresh |
| fresh/b1 |
| fresh/main |
| information_schema |
| mysql |
+--------------------+
5 rows in set (0.00 sec)-- check out an older branch that has a different schema
CALL dolt_checkout('olderBranch');
-- running a query that references the Birthdate column will fail
SELECT Name, Birthdate FROM People;
column "Birthdate" could not be found in any table in scope
-- turning on schema overriding allows us to automatically map our data to the schema at the specified commit
SET @@dolt_override_schema = 'main';
SELECT Name, Birthdate FROM People;
+-----------+-----------+
| Name | Birthdate |
+-----------+-----------+
| Billy | NULL |
| Jimbo | NULL |
+-----------+-----------+-- Enable commit verification for all tests
SET @@PERSIST.dolt_commit_verification_groups = '*';
-- Enable for specific test groups only
SET @@PERSIST.dolt_commit_verification_groups = 'unit,integration';
-- Disable commit verification
SET @@PERSIST.dolt_commit_verification_groups = NULL;
-- Example: commit will fail if tests fail
INSERT INTO dolt_tests VALUES ('test_count', 'unit', 'SELECT COUNT(*) FROM users', 'expected_single_value', '==', '5');
CALL dolt_commit('-m', 'Add user data'); -- Will run tests first
-- Example: bypass verification for this operation
CALL dolt_commit('--skip-verification', '-m', 'Emergency fix');mysql> select name from dolt_remotes;
+---------+
| name |
+---------+
| remote1 |
| origin |
+---------+
mysql> SET @@GLOBAL.dolt_replicate_to_remote = remote1;
mysql> CALL dolt_commit('-am', 'push on write');mysql> SET @@GLOBAL.dolt_replicate_to_remote = remote1;
mysql> SET @@GLOBAL.dolt_async_replication = 1;mysql> SET @@GLOBAL.dolt_read_replica_remote = origin;
mysql> SET @@GLOBAL.dolt_replicate_heads = main;
mysql> START TRANSACTION;mysql> SET @@GLOBAL.dolt_replicate_all_heads = 1;mysql> SET @@GLOBAL.dolt_replicate_heads = main;
mysql> SET @@GLOBAL.dolt_replicate_heads = "main,feature1,feature2";
mysql> SET @@GLOBAL.dolt_replicate_heads = "main,release*";set @@persist.dolt_replication_remote_url_template = 'file:///share/doltRemotes/{database}'; -- file based remote
set @@persist.dolt_replication_remote_url_template = 'aws://dynamo-table:s3-bucket/{database}'; -- AWS remote
set @@persist.dolt_replication_remote_url_template = 'gs://mybucket/remotes/{database}'; -- GCP remotemysql> SET @@GLOBAL.dolt_skip_replication_errors = 1;mydb> select @@mydb_head_ref;
+-------------------------+
| @@SESSION.mydb_head_ref |
+-------------------------+
| refs/heads/master |
+-------------------------+SET @@mydb_head_ref = 'feature-branch'call dolt_checkout('feature-branch')SET PERSIST max_connections = 1000;
SET @@PERSIST.max_connections = 1000;SET PERSIST_ONLY back_log = 1000;
SET @@PERSIST_ONLY.back_log = 1000;$ dolt sql -q "set @@persist.max_connections = 1000"$ dolt
Valid commands for dolt are
init - Create an empty Dolt data repository.
status - Show the working tree status.
add - Add table changes to the list of staged table changes.
diff - Diff a table.
reset - Remove table changes from the list of staged table changes.
clean - Remove untracked tables from working set.
commit - Record changes to the repository.
sql - Run a SQL query against tables in repository.
sql-server - Start a MySQL-compatible server.
log - Show commit logs.
branch - Create, list, edit, delete branches.
checkout - Checkout a branch or overwrite a table from HEAD.
merge - Merge a branch.
conflicts - Commands for viewing and resolving merge conflicts.
cherry-pick - Apply the changes introduced by an existing commit.
revert - Undo the changes introduced in a commit.
clone - Clone from a remote data repository.
fetch - Update the database from a remote data repository.
pull - Fetch from a dolt remote data repository and merge.
push - Push to a dolt remote.
config - Dolt configuration.
remote - Manage set of tracked repositories.
backup - Manage a set of server backups.
login - Login to a dolt remote host.
creds - Commands for managing credentials.
ls - List tables in the working set.
schema - Commands for showing and importing table schemas.
table - Commands for copying, renaming, deleting, and exporting tables.
tag - Create, list, delete tags.
blame - Show what revision and author last modified each row of a table.
constraints - Commands for handling constraints.
migrate - Executes a database migration to use the latest Dolt data format.
read-tables - Fetch table(s) at a specific commit into a new dolt repo
gc - Cleans up unreferenced data from the repository.
filter-branch - Edits the commit history using the provided query.
merge-base - Find the common ancestor of two commits.
version - Displays the current Dolt cli version.
dump - Export all tables in the working set into a file.
docs - Commands for working with Dolt documents.






roottestuser an admin permission over the main% branch. The main, as well as other branches that begin with main. The users added are all fake, and are just used to demonstrate the capability. We end by showing that this only applies to the exact match expression, as the very similar _main branch name is still off-limits.mainmain% entry. Consequently, testuser cannot use mainroot as a prefix, as main% entry.$ dolt config --global --add user.name "Tim Sehn"
$ dolt config --global --add user.email "[email protected]"$ ls ~/.dolt/config_global.json
/Users/timsehn/.dolt/config_global.json$ cd ~
$ mkdir dolt
$ cd dolt$ mkdir git_for_data
$ cd git_for_data
$ dolt init
Successfully initialized dolt data repository.$ dolt log
commit f06jtfp6fqaak6dkm0olmv175atkbhl3 (HEAD -> main)
Author: timsehn <[email protected]>
Date: Wed Jan 18 17:02:38 -0800 2023
Initialize data repository
$ cat employees.csv
id,first_name,last_name
0,Tim,Sehn
1,Brian,Hendriks
2,Aaron,Son$ dolt table import --create-table --pk id employees employees.csv
Rows Processed: 3, Additions: 3, Modifications: 0, Had No Effect: 0
Import completed successfully.$ dolt status
On branch main
Untracked files:
(use "dolt add <table>" to include in what will be committed)
new table: employees$ dolt sql -q "show tables"
+------------------------+
| Tables_in_git_for_data |
+------------------------+
| employees |
+------------------------+
$ dolt sql -q "describe employees"
+------------+----------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+----------------+------+-----+---------+-------+
| id | int | NO | PRI | NULL | |
| first_name | varchar(16383) | YES | | NULL | |
| last_name | varchar(16383) | YES | | NULL | |
+------------+----------------+------+-----+---------+-------+
$ dolt sql -q "select * from employees"
+----+------------+-----------+
| id | first_name | last_name |
+----+------------+-----------+
| 0 | Tim | Sehn |
| 1 | Brian | Hendriks |
| 2 | Aaron | Son |
+----+------------+-----------+$ dolt add employees
$ dolt status
On branch main
Changes to be committed:
(use "dolt reset <table>..." to unstage)
new table: employees
$ dolt commit -m "Added new employees table containing the founders of DoltHub"
commit aq86v87h1g05i5cdht6v6tptp70eibms (HEAD -> main)
Author: timsehn <[email protected]>
Date: Thu Jan 19 14:56:13 -0800 2023
Added new employees table containing the founders of DoltHub
$ dolt status
On branch main
nothing to commit, working tree clean
$ dolt log
commit aq86v87h1g05i5cdht6v6tptp70eibms (HEAD -> main)
Author: timsehn <[email protected]>
Date: Thu Jan 19 14:56:13 -0800 2023
Added new employees table containing the founders of DoltHub
commit f06jtfp6fqaak6dkm0olmv175atkbhl3
Author: timsehn <[email protected]>
Date: Wed Jan 18 17:02:38 -0800 2023
Initialize data repository
$ dolt sql -q "insert into employees values (3, 'Daylon', 'Wilkins')"
Query OK, 1 row affected (0.00 sec)
$ dolt sql -q "update employees set first_name='Timothy' where last_name like 'S%'"
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0
$ dolt diff
diff --dolt a/employees b/employees
--- a/employees @ m3qr6lhb8ad6fc5puvsaiv5ladajfi9r
+++ b/employees @ uvrbmnv52n2m25gpmom92qf4723bn9og
+---+----+------------+-----------+
| | id | first_name | last_name |
+---+----+------------+-----------+
| < | 0 | Tim | Sehn |
| > | 0 | Timothy | Sehn |
| < | 2 | Aaron | Son |
| > | 2 | Timothy | Son |
| + | 3 | Daylon | Wilkins |
+---+----+------------+-----------+$ dolt checkout employees
$ dolt diff
$ dolt sql -q "select * from employees"
+----+------------+-----------+
| id | first_name | last_name |
+----+------------+-----------+
| 0 | Tim | Sehn |
| 1 | Brian | Hendriks |
| 2 | Aaron | Son |
+----+------------+-----------+$ dolt sql -q "insert into employees values (3, 'Daylon', 'Wilkins')"
Query OK, 1 row affected (0.00 sec)
$ dolt sql -q "update employees set first_name='Timothy' where first_name='Tim'"
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
$ dolt diff
diff --dolt a/employees b/employees
--- a/employees @ m3qr6lhb8ad6fc5puvsaiv5ladajfi9r
+++ b/employees @ 72aq85jbhr83v4gmh73v550gupk4mr3k
+---+----+------------+-----------+
| | id | first_name | last_name |
+---+----+------------+-----------+
| < | 0 | Tim | Sehn |
| > | 0 | Timothy | Sehn |
| + | 3 | Daylon | Wilkins |
+---+----+------------+-----------+$ dolt commit -am "Added Daylon. Make Tim Timothy."
commit envoh3j93s47idjmrn16r2tka3ap8s0d (HEAD -> main)
Author: timsehn <[email protected]>
Date: Thu Jan 19 16:55:14 -0800 2023
Added Daylon. Make Tim Timothy.
$ dolt sql-server
Starting server with Config HP="localhost:3306"|T="28800000"|R="false"|L="info"|S="/tmp/mysql.sock"call dolt_checkout('-b','modifications');
insert INTO employees values (5,'Taylor', 'Bantle');
call dolt_commit('-am', 'Modifications on a branch');$ dolt branch
* main
modifications$ dolt checkout modifications
Switched to branch 'modifications'
$ dolt sql -q "select * from employees"
+----+------------+-----------+
| id | first_name | last_name |
+----+------------+-----------+
| 0 | Timothy | Sehn |
| 1 | Brian | Hendriks |
| 2 | Aaron | Son |
| 3 | Daylon | Wilkins |
| 5 | Taylor | Bantle |
+----+------------+-----------+
$ dolt diff main
diff --dolt a/employees b/employees
--- a/employees @ 72aq85jbhr83v4gmh73v550gupk4mr3k
+++ b/employees @ pacpigp52ubvo5gcrl29h61310kt9p3s
+---+----+------------+-----------+
| | id | first_name | last_name |
+---+----+------------+-----------+
| + | 5 | Taylor | Bantle |
+---+----+------------+-----------+$ dolt checkout main
Switched to branch 'main'
$ dolt merge modifications
Updating envoh3j93s47idjmrn16r2tka3ap8s0d..74m09obaaae0am5n7iucupt2od1lhi4v
Fast-forward
$ dolt sql -q "select * from employees"
+----+------------+-----------+
| id | first_name | last_name |
+----+------------+-----------+
| 0 | Timothy | Sehn |
| 1 | Brian | Hendriks |
| 2 | Aaron | Son |
| 3 | Daylon | Wilkins |
| 5 | Taylor | Bantle |
+----+------------+-----------+
$ dolt branch -d modifications
$ dolt branch
* main INSERT INTO dolt_branch_namespace_control VALUES ('%', '%', '', '');$ mkdir example
$ cd example
$ dolt init
Successfully initialized dolt data repository.
$ dolt sql -q "DELETE FROM dolt_branch_control;"
Query OK, 0 rows affected (0.00 sec)
$ dolt sql -q "CREATE USER testuser@localhost; GRANT ALL ON *.* TO testuser@localhost;"
Query OK, 0 rows affected (0.00 sec)
$ dolt sql -q "CREATE USER root@localhost; GRANT ALL ON *.* TO root@localhost WITH GRANT OPTION;"
Query OK, 0 rows affected (0.00 sec)
$ dolt sql-server
Starting server with Config HP="localhost:3306"|T="28800000"|R="false"|L="info"$ mysql --user=root
mysql> USE example;
mysql> INSERT INTO dolt_branch_control VALUES ('%', 'main', 'testuser', '%', 'write');
mysql> CREATE TABLE test (pk BIGINT PRIMARY KEY);
Error 1105: `root`@`%` does not have the correct permissions on branch `main`
mysql> exit;
$ mysql --user=testuser
mysql> USE example;
mysql> CREATE TABLE test (pk BIGINT PRIMARY KEY);
mysql> exit;$ mysql --user=testuser
mysql> USE example;
mysql> CREATE TABLE test (pk BIGINT PRIMARY KEY);
Error 1105: `testuser`@`localhost` does not have the correct permissions on branch `main`
mysql> INSERT INTO dolt_branch_control VALUES ('example', 'main', 'newuser', '%', 'write');
Error 1105: `testuser`@`localhost` cannot add the row ["example", "main", "newuser", "%", "write"]
mysql> INSERT INTO dolt_branch_namespace_control VALUES ('example', 'main', 'newuser', '%');
Error 1105: `testuser`@`localhost` cannot add the row ["example", "main", "newuser", "%"]
mysql> exit;
$ mysql --user=root
mysql> USE example;
mysql> INSERT INTO dolt_branch_control VALUES ('example', 'main%', 'testuser', '%', 'admin');
mysql> exit;
$ mysql --user=testuser
mysql> USE example;
mysql> CREATE TABLE test (pk BIGINT PRIMARY KEY);
mysql> INSERT INTO dolt_branch_control VALUES ('example', 'main', 'newuser', '%', 'write');
mysql> INSERT INTO dolt_branch_control VALUES ('example', 'main_new', 'otheruser', '%', 'write');
mysql> INSERT INTO dolt_branch_control VALUES ('example', '_main', 'someuser', '%', 'write');
Error 1105: `testuser`@`localhost` cannot add the row ["example", "_main", "someuser", "%", "write"]
mysql> INSERT INTO dolt_branch_namespace_control VALUES ('example', 'main1', 'theuser', '%');
mysql> INSERT INTO dolt_branch_namespace_control VALUES ('example', '_main', 'anotheruser', '%');
Error 1105: `testuser`@`localhost` cannot add the row ["example", "_main", "anotheruser", "%"]
mysql> exit;$ mysql --user=root
mysql> USE example;
mysql> INSERT INTO dolt_branch_namespace_control VALUES ('%', 'main%', 'testuser', '%');
mysql> INSERT INTO dolt_branch_namespace_control VALUES ('%', 'mainroot%', 'root', '%');
mysql> CALL DOLT_BRANCH('does_not_start_with_main');
+--------+
| status |
+--------+
| 0 |
+--------+
1 row in set (0.00 sec)
mysql> CALL DOLT_BRANCH('main1');
Error 1105: `root`@`%` cannot create a branch named `main1`
mysql> CALL DOLT_BRANCH('mainroot');
+--------+
| status |
+--------+
| 0 |
+--------+
1 row in set (0.00 sec)
mysql> exit;
$ mysql --user=testuser
mysql> USE example;
mysql> CALL DOLT_BRANCH('main1');
+--------+
| status |
+--------+
| 0 |
+--------+
1 row in set (0.00 sec)
mysql> CALL DOLT_BRANCH('mainroot1');
Error 1105: `testuser`@`localhost` cannot create a branch named `mainroot1`
mysql> exit;mysql --user=root
mysql> USE example;
mysql> CREATE TABLE test (pk BIGINT PRIMARY KEY);
Error 1105: `root`@`%` does not have the correct permissions on branch `main`
mysql> INSERT INTO dolt_branch_control VALUES ('example', '%', 'root', '%', 'write');
mysql> CREATE TABLE test (pk BIGINT PRIMARY KEY);
mysql> DROP TABLE test;
mysql> CREATE DATABASE newdb;
mysql> USE newdb;
mysql> CREATE TABLE test2 (pk BIGINT PRIMARY KEY);
Error 1105: `root`@`%` does not have the correct permissions on branch `main`
mysql> exit;@@dolt_replicate_all_heads*cluster.bootstrap_roledolt-1.dbdolt-2.dbprimary which is at a higher configuration epoch than the server itself, the server will immediately transition to be a standby at the same configuration epoch as the server which is making the incoming replication request.



$ dolt remote add origin timsehn/replication_example
$ dolt sql -q "set @@persist.dolt_replicate_to_remote = 'origin'"$ dolt sql -q "create table test (pk int, c1 int, primary key(pk))"
$ dolt sql -q "insert into test values (0,0)"
Query OK, 1 row affected
$ dolt add -A
$ dolt commit -m 'trigger replication'dolt sql -q "set @@persist.dolt_replicate_to_remote = ''"$ dolt sql -q "set @@persist.dolt_transaction_commit = 1"
$ dolt sql -q "insert into test values (1,1)"
Query OK, 1 row affected
$ dolt log -n 1
commit u4shvua2st16btub8mimdd2lj7iv4sdu (HEAD -> main)
Author: Tim Sehn <[email protected]>
Date: Mon Jul 11 15:54:22 -0700 2022
Transaction commit$ dolt sql -q "set @@persist.dolt_async_replication = 1"$ dolt clone timsehn/replication_example read_replica
cloning https://doltremoteapi.dolthub.com/timsehn/replication_example
28 of 28 chunks complete. 0 chunks being downloaded currently.
dolt $ cd read_replica/$ dolt sql -q "set @@persist.dolt_replicate_heads = 'main'"
$ dolt sql -q "set @@persist.dolt_read_replica_remote = 'origin'"
$ dolt sql -q "select * from test"
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
+----+----+$ dolt sql -q "insert into test values (2,2); call dolt_commit('-am', 'Inserted (2,2)');"
Query OK, 1 row affected
+----------------------------------+
| hash |
+----------------------------------+
| i97i9f1a3vrvd09pphiq0bbdeuf8riid |
+----------------------------------+$ dolt sql -q "select * from test"
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
+----+----+
$ dolt log -n 1
commit i97i9f1a3vrvd09pphiq0bbdeuf8riid (HEAD -> main, origin/main)
Author: Tim Sehn <[email protected]>
Date: Mon Jul 11 16:48:37 -0700 2022
Inserted (2,2)read_replica $ dolt sql -q "set @@persist.dolt_replicate_heads = ''"
read_replica $ dolt sql -q "set @@persist.dolt_replicate_all_heads = 1"replication_example $ dolt sql -q "call dolt_checkout('-b', 'branch1'); insert into test values (3,3); call dolt_commit('-am', 'Inserted (3,3)');"
+--------+
| status |
+--------+
| 0 |
+--------+
Query OK, 1 row affected
+----------------------------------+
| hash |
+----------------------------------+
| 0alihi9nll9986ossq9mc2n54j4kafhc |
+----------------------------------+$ dolt sql -q "call dolt_checkout('branch1'); select * from test;"
+--------+
| status |
+--------+
| 0 |
+--------+
+----+----+
| pk | c1 |
+----+----+
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
+----+----+set @@persist.dolt_replication_remote_url_template = 'file:///share/doltRemotes/{database}'; -- file based remote
set @@persist.dolt_replication_remote_url_template = 'aws://dynamo-table:s3-bucket/{database}'; -- AWS remote
set @@persist.dolt_replication_remote_url_template = 'gs://mybucket/remotes/{database}'; -- GCP remotecluster:
standby_remotes:
- name: standby
remote_url_template: http://dolt-2.db:50051/{database}
bootstrap_role: primary
bootstrap_epoch: 1
remotesapi:
port: 50051cluster:
standby_remotes:
- name: standby
remote_url_template: http://dolt-1.db:50051/{database}
bootstrap_role: standby
bootstrap_epoch: 1
remotesapi:
port: 50051$ dolt sql-server --config server.yaml --data-dir .$ mkdir appdb
$ cd appdb
$ dolt init
$ dolt remote add standby http://dolt-2.db:50051/appdb$ dolt sql-server --config server.yamlCALL dolt_assume_cluster_role('standby', 2)CALL dolt_assume_cluster_role('primary', 2)mysql> select @@GLOBAL.dolt_cluster_role, @@GLOBAL.dolt_cluster_role_epoch;
+----------------------------+----------------------------------+
| @@GLOBAL.dolt_cluster_role | @@GLOBAL.dolt_cluster_role_epoch |
+----------------------------+----------------------------------+
| primary | 15 |
+----------------------------+----------------------------------+mysql> select * from dolt_cluster.dolt_cluster_status;
+----------+----------------+---------+-------+------------------------+----------------------------+---------------+
| database | standby_remote | role | epoch | replication_lag_millis | last_update | current_error |
+----------+----------------+---------+-------+------------------------+----------------------------+---------------+
| appdb | standby | primary | 15 | 0 | 2022-10-17 19:07:38.366702 | NULL |
+----------+----------------+---------+-------+------------------------+----------------------------+---------------+cluster:
standby_remotes:
- name: standby_replica_one
remote_url_template: https://standby_replica_one.svc.cluster.local:50051/{database}
- name: standby_replica_two
remote_url_template: https://standby_replica_two.svc.cluster.local:50051/{database}
boostrap_role: ...
boostrap_epoch: ...
remotesapi:
# The listening address. By default all listenable interfaces.
address: "127.0.0.1" | "::1" | "..."
# The TCP port to listen on.
port: 50051
# A file path to a file containing the PEM-encoded private key to be used by
# this server's TLS listener.
tls_key: "remotesapi_key.pem"
# A file path to a file containing the PEM-encoded certificate chain to be
# presented by this server's TLS listener.
tls_cert: "remotesapi_chain.pem"
# A file path to a file containing a list of PEM-encoded CA certificates
# to be trusted by this sql-server when establishing outbound TLS
# connections. If this is not set, default certificate verification and
# trusted certificate roots are used.
tls_ca: "standby_cas.pem"
# A list of server name URLs, one of which must appear in the SANs of the
# presented leaf certificate for the certificate to pass verification. If
# this list is empty, no assertions are made against SAN URLs. This should
# only be set when `tls_ca` is set.
server_name_urls:
- "https://standby_replica_one.svc.cluster.local"
- "https://standby_replica_two.svc.cluster.local"
# A list of server DNS names, one of which must appear in the SANs of the
# presented leaf certificate for the certificate to pass verification. If
# this list is empty, no assertions are made against SAN DNS entries. This
# should only be set when `tls_ca` is set.
server_name_dns:
- "standby_replica_one.svc.cluster.local"
- "standby_replica_two.svc.cluster.local"$ brew install mysql
$ brew services start mysql$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.32 Homebrew
Copyright (c) 2000, 2023, 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>mysql> SET @@GLOBAL.ENFORCE_GTID_CONSISTENCY = ON;
Query OK, 0 rows affected (0.00 sec)mysql> SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;
Query OK, 0 rows affected (0.01 sec)
mysql> SET @@GLOBAL.GTID_MODE = ON_PERMISSIVE;
Query OK, 0 rows affected (0.01 sec)
mysql> SET @@GLOBAL.GTID_MODE = ON;
Query OK, 0 rows affected (0.00 sec)mysql> SHOW VARIABLES WHERE Variable_Name LIKE '%gtid_mode' OR Variable_Name LIKE '%enforce_gtid_consistency' OR Variable_Name LIKE '%binlog_format' OR Variable_Name LIKE 'server_id';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| binlog_format | ROW |
| enforce_gtid_consistency | ON |
| gtid_mode | ON |
| server_id | 1 |
+--------------------------+-------+$ du -h /Users/timsehn//go/bin/dolt
68M /Users/timsehn/go/bin/doltsudo bash -c 'curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | sudo bash'$ cd ~
$ mkdir dolt_replica
$ cd dolt_replica$ dolt sql-server -P 1234 --loglevel=debug
Starting server with Config HP="localhost:1234"|T="28800000"|R="false"|L="debug"|S="/tmp/mysql.sock"
2023-03-08T13:05:06-08:00 WARN [no conn] unix socket set up failed: file already in use: /tmp/mysql.sock {}$ mysql -h 127.0.0.1 -P 1234 -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.7.9-Vitess
Copyright (c) 2000, 2023, 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>mysql> SET @@GLOBAL.SERVER_ID=2;
Query OK, 1 row affected (0.00 sec)mysql> CHANGE REPLICATION SOURCE TO SOURCE_HOST='localhost', SOURCE_USER='root', SOURCE_PORT=3306;
Query OK, 0 rows affected (0.00 sec)mysql> START REPLICA;
Query OK, 0 rows affected (0.00 sec)2023-03-13T11:32:16-07:00 DEBUG [conn 1] Starting query {connectTime=2023-03-13T11:31:37-07:00, connectionDb=, query=START REPLICA}
2023-03-13T11:32:16-07:00 INFO [conn 1] starting binlog replication... {connectTime=2023-03-13T11:31:37-07:00, connectionDb=, query=START REPLICA}
2023-03-13T11:32:16-07:00 DEBUG [no conn] no binlog connection to source, attempting to establish one {}
2023-03-13T11:32:16-07:00 DEBUG [conn 1] Query finished in 1 ms {connectTime=2023-03-13T11:31:37-07:00, connectionDb=, query=START REPLICA}
2023-03-13T11:32:16-07:00 DEBUG [no conn] Received binlog event: Rotate {}
2023-03-13T11:32:16-07:00 DEBUG [no conn] Received binlog event: FormatDescription {checksum=1, format=&{4 8.0.32 19 1 [0 13 0 8 0 0 0 0 4 0 4 0 0 0 98 0 4 26 8 0 0 0 8 8 8 2 0 0 0 10 10 10 42 42 0 18 52 0 10 40 0]}, formatVersion=4, serverVersion=8.0.32}
2023-03-13T11:32:16-07:00 DEBUG [no conn] Received binlog event: PreviousGTIDs {previousGtids=}mysql> create database foo;
Query OK, 1 row affected (0.00 sec)
mysql> use foo;
Database changed
mysql> create table t (c1 int primary key, c2 int);
Query OK, 0 rows affected (0.01 sec)
mysql> show tables;
+---------------+
| Tables_in_foo |
+---------------+
| t |
+---------------+
1 row in set (0.01 sec)
mysql> insert into t values (0,0);
Query OK, 1 row affected (0.01 sec)2023-03-13T11:33:51-07:00 DEBUG [no conn] Received binlog event: GTID {gtid=cb01d44a-c1cc-11ed-889a-b5857bdad497:1, isBegin=false}
2023-03-13T11:33:51-07:00 DEBUG [no conn] Received binlog event: Query {charset=client:255 conn:255 server:255, database=foo, options=0x0, query=create database foo, sql_mode=0x45a00020}
2023-03-13T11:34:13-07:00 DEBUG [no conn] Received binlog event: GTID {connectionDb=foo, gtid=cb01d44a-c1cc-11ed-889a-b5857bdad497:2, isBegin=false}
2023-03-13T11:34:13-07:00 DEBUG [no conn] Received binlog event: Query {charset=client:255 conn:255 server:255, connectionDb=foo, database=foo, options=0x0, query=create table t (c1 int primary key, c2 int), sql_mode=0x45a00020}
2023-03-13T11:34:30-07:00 DEBUG [no conn] Received binlog event: GTID {connectionDb=foo, gtid=cb01d44a-c1cc-11ed-889a-b5857bdad497:3, isBegin=false}
2023-03-13T11:34:30-07:00 DEBUG [no conn] Received binlog event: Query {charset=client:255 conn:255 server:255, connectionDb=foo, database=foo, options=0x0, query=BEGIN, sql_mode=0x45a00020}
2023-03-13T11:34:30-07:00 DEBUG [no conn] Received binlog event: TableMap {connectionDb=foo, database=foo, flags=1, id=113, metadata=[0 0], tableName=t, types=[3 3]}
2023-03-13T11:34:30-07:00 DEBUG [no conn] Received binlog event: WriteRows {connectionDb=foo}
2023-03-13T11:34:30-07:00 DEBUG [no conn] Processing rows from WriteRows event {connectionDb=foo, flags=1}
2023-03-13T11:34:30-07:00 DEBUG [no conn] - Inserted Rows (table: t) {connectionDb=foo}
2023-03-13T11:34:30-07:00 DEBUG [no conn] - Data: [0,0] {connectionDb=foo}
2023-03-13T11:34:30-07:00 DEBUG [no conn] Received binlog event: XID {connectionDb=foo}mysql> use foo;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+---------------+
| Tables_in_foo |
+---------------+
| t |
+---------------+
1 row in set (0.01 sec)
mysql> select * from t;
+------+------+
| c1 | c2 |
+------+------+
| 0 | 0 |
+------+------+
1 row in set (0.01 sec)mysql> select * from dolt_log;
+----------------------------------+-----------+-----------------+-------------------------+-------------------------------------------------------------------------+
| commit_hash | committer | email | date | message |
+----------------------------------+-----------+-----------------+-------------------------+-------------------------------------------------------------------------+
| h9hsr5ij8u9gml4nkqenm8alep1la1r9 | timsehn | [email protected] | 2023-03-13 18:31:22.706 | Dolt binlog replica commit: GTID cb01d44a-c1cc-11ed-889a-b5857bdad497:3 |
| t3bp704udfjcuo83hb7qjat8ltv1osea | timsehn | [email protected] | 2023-03-13 18:31:22.706 | Dolt binlog replica commit: GTID cb01d44a-c1cc-11ed-889a-b5857bdad497:2 |
| gia1ra16aakuc69hmha7p9pjnjd9ghid | timsehn | [email protected] | 2023-03-13 18:33:51.736 | Initialize data repository |
+----------------------------------+-----------+-----------------+-------------------------+-------------------------------------------------------------------------+
3 rows in set (0.01 sec)mysql> select * from dolt_diff('t3bp704udfjcuo83hb7qjat8ltv1osea', 'h9hsr5ij8u9gml4nkqenm8alep1la1r9', 't');
+-------+-------+----------------------------------+-------------------------+---------+---------+----------------------------------+-------------------------+-----------+
| to_c1 | to_c2 | to_commit | to_commit_date | from_c1 | from_c2 | from_commit | from_commit_date | diff_type |
+-------+-------+----------------------------------+-------------------------+---------+---------+----------------------------------+-------------------------+-----------+
| 0 | 0 | h9hsr5ij8u9gml4nkqenm8alep1la1r9 | 2023-03-13 18:31:22.706 | NULL | NULL | t3bp704udfjcuo83hb7qjat8ltv1osea | 2023-03-13 18:31:22.706 | added |
+-------+-------+----------------------------------+-------------------------+---------+---------+----------------------------------+-------------------------+-----------+$ git clone [email protected]:datacharmer/test_db.git
Cloning into 'test_db'...
remote: Enumerating objects: 120, done.
remote: Total 120 (delta 0), reused 0 (delta 0), pack-reused 120
Receiving objects: 100% (120/120), 74.27 MiB | 22.43 MiB/s, done.
Resolving deltas: 100% (62/62), done.
$ cd test_db
$ mysql -u root < employees.sql
INFO
CREATING DATABASE STRUCTURE
INFO
storage engine: InnoDB
INFO
LOADING departments
INFO
LOADING employees
INFO
LOADING dept_emp
INFO
LOADING dept_manager
INFO
LOADING titles
INFO
LOADING salaries
data_load_time_diff
00:00:25mysql> show databases;
+--------------------+
| Database |
+--------------------+
| employees |
| foo |
| information_schema |
| mysql |
+--------------------+
4 rows in set (0.00 sec)
mysql> use employees;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+----------------------+
| Tables_in_employees |
+----------------------+
| current_dept_emp |
| departments |
| dept_emp |
| dept_emp_latest_date |
| dept_manager |
| employees |
| salaries |
| titles |
+----------------------+
8 rows in set (0.00 sec)mysql> use employees;
Database changed
mysql> show tables;
+----------------------+
| Tables_in_employees |
+----------------------+
| current_dept_emp |
| departments |
| dept_emp |
| dept_emp_latest_date |
| dept_manager |
| employees |
| salaries |
| titles |
+----------------------+
8 rows in set (0.00 sec)
mysql> select count(*) from salaries;
+----------+
| count(*) |
+----------+
| 2844047 |
+----------+
1 row in set (0.08 sec)
mysql> select count(*) from employees;
+----------+
| count(*) |
+----------+
| 300024 |
+----------+
1 row in set (0.03 sec)
mysql> select * from employees limit 5;
+--------+------------+------------+-----------+--------+------------+
| emp_no | birth_date | first_name | last_name | gender | hire_date |
+--------+------------+------------+-----------+--------+------------+
| 10001 | 1953-09-02 | Georgi | Facello | M | 1986-06-26 |
| 10002 | 1964-06-02 | Bezalel | Simmel | F | 1985-11-21 |
| 10003 | 1959-12-03 | Parto | Bamford | M | 1986-08-28 |
| 10004 | 1954-05-01 | Chirstian | Koblick | M | 1986-12-01 |
| 10005 | 1955-01-21 | Kyoichi | Maliniak | M | 1989-09-12 |
+--------+------------+------------+-----------+--------+------------+
5 rows in set (0.00 sec)mysql> describe employees;
+------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------+------+-----+---------+-------+
| emp_no | int | NO | PRI | NULL | |
| birth_date | date | NO | | NULL | |
| first_name | varchar(14) | NO | | NULL | |
| last_name | varchar(16) | NO | | NULL | |
| gender | enum('M','F') | NO | | NULL | |
| hire_date | date | NO | | NULL | |
+------------+---------------+------+-----+---------+-------+
6 rows in set (0.01 sec)
mysql> select max(emp_no) from employees;
+-------------+
| max(emp_no) |
+-------------+
| 499999 |
+-------------+
1 row in set (0.00 sec)
mysql> insert into employees values (500000, '1980-02-03', 'Timothy', 'Sehn', 'M', '2023-02-03');
Query OK, 1 row affected (0.00 sec)
mysql> describe salaries;
+-----------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------+------+-----+---------+-------+
| emp_no | int | NO | PRI | NULL | |
| salary | int | NO | | NULL | |
| from_date | date | NO | PRI | NULL | |
| to_date | date | NO | | NULL | |
+-----------+------+------+-----+---------+-------+
4 rows in set (0.00 sec)
mysql> insert into salaries values (500000, 1000000,'2023-02-03','2023-02-03');
Query OK, 1 row affected (0.00 sec)mysql> update salaries set salary=salary-1 order by rand() limit 5;
Query OK, 5 rows affected (0.87 sec)
Rows matched: 5 Changed: 5 Warnings: 0mysql> insert into employees values (500001, '1984-02-06', 'Aaron', 'Son', 'M', '2023-02-06'), (500002, '1984-02-06', 'Brian', 'Nendriks', 'M', '2023-02-06');
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> insert into salaries values (500001, 1,'2023-02-06','2023-02-06'),(500002, 1,'2023-02-06','2023-02-06');
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0mysql> select * from dolt_diff where table_name='salaries' limit 10;
+----------------------------------+------------+-----------+-----------------+-------------------------+---------------------------------------------------------------------------+-------------+---------------+
| commit_hash | table_name | committer | email | date | message | data_change | schema_change |
+----------------------------------+------------+-----------+-----------------+-------------------------+---------------------------------------------------------------------------+-------------+---------------+
| 649fgvojpthn1e21bqrdlv3r3bht4rqb | salaries | timsehn | [email protected] | 2023-03-14 16:58:40.516 | Dolt binlog replica commit: GTID 5dd3b782-c288-11ed-8525-f178832944db:184 | 1 | 0 |
| 123d9jc85evssjcrv6u5mlt5dg4lk6ss | salaries | timsehn | [email protected] | 2023-03-14 16:58:12.711 | Dolt binlog replica commit: GTID 5dd3b782-c288-11ed-8525-f178832944db:182 | 1 | 0 |
| 4te2i1qheceek434m3uoqsuejfv6f0nu | salaries | timsehn | [email protected] | 2023-03-14 16:57:59.715 | Dolt binlog replica commit: GTID 5dd3b782-c288-11ed-8525-f178832944db:181 | 1 | 0 |
| vrurdbqr7im0f2ha37e9agf9qr933r0j | salaries | timsehn | [email protected] | 2023-03-14 16:55:24.921 | Dolt binlog replica commit: GTID 5dd3b782-c288-11ed-8525-f178832944db:179 | 1 | 0 |
| u2rpdr1v49pumtdkpir04ohv2cinfrd6 | salaries | timsehn | [email protected] | 2023-03-14 16:55:24.72 | Dolt binlog replica commit: GTID 5dd3b782-c288-11ed-8525-f178832944db:178 | 1 | 0 |
| masl3j4d2f7ic3d0lgkhgskc8gridrk0 | salaries | timsehn | [email protected] | 2023-03-14 16:55:24.096 | Dolt binlog replica commit: GTID 5dd3b782-c288-11ed-8525-f178832944db:177 | 1 | 0 |
| bouhk6kkn9oqpn1ki61b8tc2uk81lted | salaries | timsehn | [email protected] | 2023-03-14 16:55:23.487 | Dolt binlog replica commit: GTID 5dd3b782-c288-11ed-8525-f178832944db:176 | 1 | 0 |
| ag00rebd7h25n6h786c4o0j2en76pek9 | salaries | timsehn | [email protected] | 2023-03-14 16:55:22.877 | Dolt binlog replica commit: GTID 5dd3b782-c288-11ed-8525-f178832944db:175 | 1 | 0 |
| pa4t6uj1igtma6r7elf3dl0s9b7q8sa8 | salaries | timsehn | [email protected] | 2023-03-14 16:55:22.281 | Dolt binlog replica commit: GTID 5dd3b782-c288-11ed-8525-f178832944db:174 | 1 | 0 |
| gqtrl19isbj7p97llibn0rejqr2r01mt | salaries | timsehn | [email protected] | 2023-03-14 16:55:21.739 | Dolt binlog replica commit: GTID 5dd3b782-c288-11ed-8525-f178832944db:173 | 1 | 0 |
+----------------------------------+------------+-----------+-----------------+-------------------------+---------------------------------------------------------------------------+-------------+---------------+
10 rows in set (0.00 sec)mysql> select * from dolt_diff('4te2i1qheceek434m3uoqsuejfv6f0nu', '649fgvojpthn1e21bqrdlv3r3bht4rqb', 'salaries');
+-----------+-----------+--------------+------------+----------------------------------+-------------------------+-------------+-------------+----------------+--------------+----------------------------------+-------------------------+-----------+
| to_emp_no | to_salary | to_from_date | to_to_date | to_commit | to_commit_date | from_emp_no | from_salary | from_from_date | from_to_date | from_commit | from_commit_date | diff_type |
+-----------+-----------+--------------+------------+----------------------------------+-------------------------+-------------+-------------+----------------+--------------+----------------------------------+-------------------------+-----------+
| 203464 | 76540 | 1997-02-20 | 1998-02-20 | 649fgvojpthn1e21bqrdlv3r3bht4rqb | 2023-03-14 16:58:40.516 | 203464 | 76541 | 1997-02-20 | 1998-02-20 | 4te2i1qheceek434m3uoqsuejfv6f0nu | 2023-03-14 16:57:59.715 | modified |
| 255639 | 48854 | 1994-12-12 | 1995-12-12 | 649fgvojpthn1e21bqrdlv3r3bht4rqb | 2023-03-14 16:58:40.516 | 255639 | 48855 | 1994-12-12 | 1995-12-12 | 4te2i1qheceek434m3uoqsuejfv6f0nu | 2023-03-14 16:57:59.715 | modified |
| 291810 | 56424 | 1997-09-15 | 1998-09-15 | 649fgvojpthn1e21bqrdlv3r3bht4rqb | 2023-03-14 16:58:40.516 | 291810 | 56425 | 1997-09-15 | 1998-09-15 | 4te2i1qheceek434m3uoqsuejfv6f0nu | 2023-03-14 16:57:59.715 | modified |
| 416268 | 47129 | 1996-02-03 | 1997-02-02 | 649fgvojpthn1e21bqrdlv3r3bht4rqb | 2023-03-14 16:58:40.516 | 416268 | 47130 | 1996-02-03 | 1997-02-02 | 4te2i1qheceek434m3uoqsuejfv6f0nu | 2023-03-14 16:57:59.715 | modified |
| 441152 | 67238 | 1992-09-09 | 1993-08-27 | 649fgvojpthn1e21bqrdlv3r3bht4rqb | 2023-03-14 16:58:40.516 | 441152 | 67239 | 1992-09-09 | 1993-08-27 | 4te2i1qheceek434m3uoqsuejfv6f0nu | 2023-03-14 16:57:59.715 | modified |
| 500001 | 1 | 2023-02-06 | 2023-02-06 | 649fgvojpthn1e21bqrdlv3r3bht4rqb | 2023-03-14 16:58:40.516 | NULL | NULL | NULL | NULL | 4te2i1qheceek434m3uoqsuejfv6f0nu | 2023-03-14 16:57:59.715 | added |
| 500002 | 1 | 2023-02-06 | 2023-02-06 | 649fgvojpthn1e21bqrdlv3r3bht4rqb | 2023-03-14 16:58:40.516 | NULL | NULL | NULL | NULL | 4te2i1qheceek434m3uoqsuejfv6f0nu | 2023-03-14 16:57:59.715 | added |
+-----------+-----------+--------------+------------+----------------------------------+-------------------------+-------------+-------------+----------------+--------------+----------------------------------+-------------------------+-----------+
7 rows in set (0.01 sec)mysql> select * from dolt_diff('123d9jc85evssjcrv6u5mlt5dg4lk6ss', '649fgvojpthn1e21bqrdlv3r3bht4rqb', 'salaries');
+-----------+-----------+--------------+------------+----------------------------------+-------------------------+-------------+-------------+----------------+--------------+----------------------------------+-------------------------+-----------+
| to_emp_no | to_salary | to_from_date | to_to_date | to_commit | to_commit_date | from_emp_no | from_salary | from_from_date | from_to_date | from_commit | from_commit_date | diff_type |
+-----------+-----------+--------------+------------+----------------------------------+-------------------------+-------------+-------------+----------------+--------------+----------------------------------+-------------------------+-----------+
| 500001 | 1 | 2023-02-06 | 2023-02-06 | 649fgvojpthn1e21bqrdlv3r3bht4rqb | 2023-03-14 16:58:40.516 | NULL | NULL | NULL | NULL | 123d9jc85evssjcrv6u5mlt5dg4lk6ss | 2023-03-14 16:58:12.711 | added |
| 500002 | 1 | 2023-02-06 | 2023-02-06 | 649fgvojpthn1e21bqrdlv3r3bht4rqb | 2023-03-14 16:58:40.516 | NULL | NULL | NULL | NULL | 123d9jc85evssjcrv6u5mlt5dg4lk6ss | 2023-03-14 16:58:12.711 | added |
+-----------+-----------+--------------+------------+----------------------------------+-------------------------+-------------+-------------+----------------+--------------+----------------------------------+-------------------------+-----------+mysql> select * from dolt_diff('4te2i1qheceek434m3uoqsuejfv6f0nu', '123d9jc85evssjcrv6u5mlt5dg4lk6ss', 'salaries');
+-----------+-----------+--------------+------------+----------------------------------+-------------------------+-------------+-------------+----------------+--------------+----------------------------------+-------------------------+-----------+
| to_emp_no | to_salary | to_from_date | to_to_date | to_commit | to_commit_date | from_emp_no | from_salary | from_from_date | from_to_date | from_commit | from_commit_date | diff_type |
+-----------+-----------+--------------+------------+----------------------------------+-------------------------+-------------+-------------+----------------+--------------+----------------------------------+-------------------------+-----------+
| 203464 | 76540 | 1997-02-20 | 1998-02-20 | 123d9jc85evssjcrv6u5mlt5dg4lk6ss | 2023-03-14 16:58:12.711 | 203464 | 76541 | 1997-02-20 | 1998-02-20 | 4te2i1qheceek434m3uoqsuejfv6f0nu | 2023-03-14 16:57:59.715 | modified |
| 255639 | 48854 | 1994-12-12 | 1995-12-12 | 123d9jc85evssjcrv6u5mlt5dg4lk6ss | 2023-03-14 16:58:12.711 | 255639 | 48855 | 1994-12-12 | 1995-12-12 | 4te2i1qheceek434m3uoqsuejfv6f0nu | 2023-03-14 16:57:59.715 | modified |
| 291810 | 56424 | 1997-09-15 | 1998-09-15 | 123d9jc85evssjcrv6u5mlt5dg4lk6ss | 2023-03-14 16:58:12.711 | 291810 | 56425 | 1997-09-15 | 1998-09-15 | 4te2i1qheceek434m3uoqsuejfv6f0nu | 2023-03-14 16:57:59.715 | modified |
| 416268 | 47129 | 1996-02-03 | 1997-02-02 | 123d9jc85evssjcrv6u5mlt5dg4lk6ss | 2023-03-14 16:58:12.711 | 416268 | 47130 | 1996-02-03 | 1997-02-02 | 4te2i1qheceek434m3uoqsuejfv6f0nu | 2023-03-14 16:57:59.715 | modified |
| 441152 | 67238 | 1992-09-09 | 1993-08-27 | 123d9jc85evssjcrv6u5mlt5dg4lk6ss | 2023-03-14 16:58:12.711 | 441152 | 67239 | 1992-09-09 | 1993-08-27 | 4te2i1qheceek434m3uoqsuejfv6f0nu | 2023-03-14 16:57:59.715 | modified |
+-----------+-----------+--------------+------------+----------------------------------+-------------------------+-------------+-------------+----------------+--------------+----------------------------------+-------------------------+-----------+
5 rows in set (0.00 sec)mysql> call dolt_checkout('-b', 'revert_bad_change');
+--------+
| status |
+--------+
| 0 |
+--------+
1 row in set (0.02 sec)mysql> call dolt_revert('123d9jc85evssjcrv6u5mlt5dg4lk6ss');
+--------+
| status |
+--------+
| 0 |
+--------+
1 row in set (0.02 sec)
mysql> select * from dolt_diff('HEAD^', 'HEAD', 'salaries');
+-----------+-----------+--------------+------------+-----------+-------------------------+-------------+-------------+----------------+--------------+-------------+-------------------------+-----------+
| to_emp_no | to_salary | to_from_date | to_to_date | to_commit | to_commit_date | from_emp_no | from_salary | from_from_date | from_to_date | from_commit | from_commit_date | diff_type |
+-----------+-----------+--------------+------------+-----------+-------------------------+-------------+-------------+----------------+--------------+-------------+-------------------------+-----------+
| 203464 | 76541 | 1997-02-20 | 1998-02-20 | HEAD | 2023-03-14 17:54:24.246 | 203464 | 76540 | 1997-02-20 | 1998-02-20 | HEAD^ | 2023-03-14 16:58:40.516 | modified |
| 255639 | 48855 | 1994-12-12 | 1995-12-12 | HEAD | 2023-03-14 17:54:24.246 | 255639 | 48854 | 1994-12-12 | 1995-12-12 | HEAD^ | 2023-03-14 16:58:40.516 | modified |
| 291810 | 56425 | 1997-09-15 | 1998-09-15 | HEAD | 2023-03-14 17:54:24.246 | 291810 | 56424 | 1997-09-15 | 1998-09-15 | HEAD^ | 2023-03-14 16:58:40.516 | modified |
| 416268 | 47130 | 1996-02-03 | 1997-02-02 | HEAD | 2023-03-14 17:54:24.246 | 416268 | 47129 | 1996-02-03 | 1997-02-02 | HEAD^ | 2023-03-14 16:58:40.516 | modified |
| 441152 | 67239 | 1992-09-09 | 1993-08-27 | HEAD | 2023-03-14 17:54:24.246 | 441152 | 67238 | 1992-09-09 | 1993-08-27 | HEAD^ | 2023-03-14 16:58:40.516 | modified |
+-----------+-----------+--------------+------------+-----------+-------------------------+-------------+-------------+----------------+--------------+-------------+-------------------------+-----------+
5 rows in set (0.00 sec)mysql> select * from dolt_patch('HEAD^', 'HEAD');
+-----------------+----------------------------------+----------------------------------+------------+-----------+------------------------------------------------------------------------------------------+
| statement_order | from_commit_hash | to_commit_hash | table_name | diff_type | statement |
+-----------------+----------------------------------+----------------------------------+------------+-----------+------------------------------------------------------------------------------------------+
| 1 | 649fgvojpthn1e21bqrdlv3r3bht4rqb | 2kakjoil0jvtl2bldd5rj83t9eeilvvm | salaries | data | UPDATE `salaries` SET `salary`=76541 WHERE `emp_no`=203464 AND `from_date`='1997-02-20'; |
| 2 | 649fgvojpthn1e21bqrdlv3r3bht4rqb | 2kakjoil0jvtl2bldd5rj83t9eeilvvm | salaries | data | UPDATE `salaries` SET `salary`=48855 WHERE `emp_no`=255639 AND `from_date`='1994-12-12'; |
| 3 | 649fgvojpthn1e21bqrdlv3r3bht4rqb | 2kakjoil0jvtl2bldd5rj83t9eeilvvm | salaries | data | UPDATE `salaries` SET `salary`=56425 WHERE `emp_no`=291810 AND `from_date`='1997-09-15'; |
| 4 | 649fgvojpthn1e21bqrdlv3r3bht4rqb | 2kakjoil0jvtl2bldd5rj83t9eeilvvm | salaries | data | UPDATE `salaries` SET `salary`=47130 WHERE `emp_no`=416268 AND `from_date`='1996-02-03'; |
| 5 | 649fgvojpthn1e21bqrdlv3r3bht4rqb | 2kakjoil0jvtl2bldd5rj83t9eeilvvm | salaries | data | UPDATE `salaries` SET `salary`=67239 WHERE `emp_no`=441152 AND `from_date`='1992-09-09'; |
+-----------------+----------------------------------+----------------------------------+------------+-----------+------------------------------------------------------------------------------------------+
5 rows in set (0.00 sec)mysql> select replace(group_concat(statement), ',', '') from dolt_patch('HEAD^', 'HEAD');
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| replace(group_concat(statement), ',', '') |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| UPDATE `salaries` SET `salary`=76541 WHERE `emp_no`=203464 AND `from_date`='1997-02-20';UPDATE `salaries` SET `salary`=48855 WHERE `emp_no`=255639 AND `from_date`='1994-12-12';UPDATE `salaries` SET `salary`=56425 WHERE `emp_no`=291810 AND `from_date`='1997-09-15';UPDATE `salaries` SET `salary`=47130 WHERE `emp_no`=416268 AND `from_date`='1996-02-03';UPDATE `salaries` SET `salary`=67239 WHERE `emp_no`=441152 AND `from_date`='1992-09-09'; |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)mysql> UPDATE `salaries` SET `salary`=76541 WHERE `emp_no`=203464 AND `from_date`='1997-02-20';UPDATE `salaries` SET `salary`=48855 WHERE `emp_no`=255639 AND `from_date`='1994-12-12';UPDATE `salaries` SET `salary`=56425 WHERE `emp_no`=291810 AND `from_date`='1997-09-15';UPDATE `salaries` SET `salary`=47130 WHERE `emp_no`=416268 AND `from_date`='1996-02-03';UPDATE `salaries` SET `salary`=67239 WHERE `emp_no`=441152 AND `from_date`='1992-09-09';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0mysql> select * from dolt_diff('main', 'revert_bad_change', 'salaries');
Empty set (0.00 sec)~/dolt% cd ~
% mkdir dolt
% cd doltdolt sql-server
Starting server with Config HP="localhost:3306"|T="28800000"|R="false"|L="info"% mysql --version
mysql Ver 8.0.29 for macos12.2 on x86_64 (Homebrew)% mysql --host 127.0.0.1 --port 3306 -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.9-Vitess
Copyright (c) 2000, 2022, 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>2022-06-06T13:26:55-07:00 INFO [conn 2] NewConnection {DisableClientMultiStatements=false}mysql> create database getting_started;
Query OK, 1 row affected (0.04 sec)
mysql> use getting_started;
Database changed
mysql> create table employees (
id int,
last_name varchar(255),
first_name varchar(255),
primary key(id));
Query OK, 0 rows affected (0.01 sec)
mysql> create table teams (
id int,
team_name varchar(255),
primary key(id));
Query OK, 0 rows affected (0.00 sec)
mysql> create table employees_teams(
team_id int,
employee_id int,
primary key(team_id, employee_id),
foreign key (team_id) references teams(id),
foreign key (employee_id) references employees(id));
Query OK, 0 rows affected (0.01 sec)
mysql> show tables;
+---------------------------+
| Tables_in_getting_started |
+---------------------------+
| employees |
| employees_teams |
| teams |
+---------------------------+
3 rows in set (0.00 sec)mysql> call dolt_add('teams', 'employees', 'employees_teams');
+--------+
| status |
+--------+
| 0 |
+--------+
1 row in set (0.03 sec)
mysql> call dolt_commit('-m', 'Created initial schema');
+----------------------------------+
| hash |
+----------------------------------+
| ne182jemgrlm8jnjmoubfqsstlfi1s98 |
+----------------------------------+
1 row in set (0.02 sec)
mysql> select * from dolt_log;
+----------------------------------+-----------+-----------------+-------------------------+----------------------------+
| commit_hash | committer | email | date | message |
+----------------------------------+-----------+-----------------+-------------------------+----------------------------+
| ne182jemgrlm8jnjmoubfqsstlfi1s98 | Tim Sehn | [email protected] | 2022-06-07 16:35:49.277 | Created initial schema |
| vluuhvd0bn59598utedt77ed9q5okbcb | Tim Sehn | [email protected] | 2022-06-07 16:33:59.531 | Initialize data repository |
+----------------------------------+-----------+-----------------+-------------------------+----------------------------+
2 rows in set (0.01 sec)mysql> insert into employees values
(0, 'Sehn', 'Tim'),
(1, 'Hendriks', 'Brian'),
(2, 'Son','Aaron'),
(3, 'Fitzgerald', 'Brian');
Query OK, 4 rows affected (0.01 sec)
mysql> select * from employees where first_name='Brian';
+------+------------+------------+
| id | last_name | first_name |
+------+------------+------------+
| 1 | Hendriks | Brian |
| 3 | Fitzgerald | Brian |
+------+------------+------------+
2 rows in set (0.00 sec)
mysql> insert into teams values
(0, 'Engineering'),
(1, 'Sales');
Query OK, 2 rows affected (0.00 sec)
mysql> insert into employees_teams values
(0,0),
(1,0),
(2,0),
(0,1),
(3,1);
ERROR 1452 (HY000): cannot add or update a child row - Foreign key violation on fk: `rv9ek7ft`, table: `employees_teams`, referenced table: `teams`, key: `[2]`mysql> insert into employees_teams(employee_id, team_id) values
(0,0),
(1,0),
(2,0),
(0,1),
(3,1);
Query OK, 5 rows affected (0.01 sec)
mysql> select first_name, last_name, team_name from employees
join employees_teams on (employees.id=employees_teams.employee_id)
join teams on (teams.id=employees_teams.team_id)
where team_name='Engineering';
+------------+-----------+-------------+
| first_name | last_name | team_name |
+------------+-----------+-------------+
| Tim | Sehn | Engineering |
| Brian | Hendriks | Engineering |
| Aaron | Son | Engineering |
+------------+-----------+-------------+
3 rows in set (0.00 sec)mysql> select * from dolt_status;
+-----------------+--------+----------+
| table_name | staged | status |
+-----------------+--------+----------+
| teams | 0 | modified |
| employees | 0 | modified |
| employees_teams | 0 | modified |
+-----------------+--------+----------+
3 rows in set (0.01 sec)
mysql> select * from dolt_diff_employees;
+--------------+---------------+-------+-----------+----------------+----------------+-----------------+---------+----------------------------------+-------------------------+-----------+
| to_last_name | to_first_name | to_id | to_commit | to_commit_date | from_last_name | from_first_name | from_id | from_commit | from_commit_date | diff_type |
+--------------+---------------+-------+-----------+----------------+----------------+-----------------+---------+----------------------------------+-------------------------+-----------+
| Sehn | Tim | 0 | WORKING | NULL | NULL | NULL | NULL | ne182jemgrlm8jnjmoubfqsstlfi1s98 | 2022-06-07 16:35:49.277 | added |
| Hendriks | Brian | 1 | WORKING | NULL | NULL | NULL | NULL | ne182jemgrlm8jnjmoubfqsstlfi1s98 | 2022-06-07 16:35:49.277 | added |
| Son | Aaron | 2 | WORKING | NULL | NULL | NULL | NULL | ne182jemgrlm8jnjmoubfqsstlfi1s98 | 2022-06-07 16:35:49.277 | added |
| Fitzgerald | Brian | 3 | WORKING | NULL | NULL | NULL | NULL | ne182jemgrlm8jnjmoubfqsstlfi1s98 | 2022-06-07 16:35:49.277 | added |
+--------------+---------------+-------+-----------+----------------+----------------+-----------------+---------+----------------------------------+-------------------------+-----------+
4 rows in set (0.00 sec)mysql> call dolt_commit('-am', 'Populated tables with data');
+----------------------------------+
| hash |
+----------------------------------+
| 13qfqa5rojq18j84d1n2htjkm6fletg4 |
+----------------------------------+
1 row in set (0.02 sec)mysql> select * from dolt_log;
+----------------------------------+-----------+-----------------+-------------------------+----------------------------+
| commit_hash | committer | email | date | message |
+----------------------------------+-----------+-----------------+-------------------------+----------------------------+
| 13qfqa5rojq18j84d1n2htjkm6fletg4 | Tim Sehn | [email protected] | 2022-06-07 16:39:32.066 | Populated tables with data |
| ne182jemgrlm8jnjmoubfqsstlfi1s98 | Tim Sehn | [email protected] | 2022-06-07 16:35:49.277 | Created initial schema |
| vluuhvd0bn59598utedt77ed9q5okbcb | Tim Sehn | [email protected] | 2022-06-07 16:33:59.531 | Initialize data repository |
+----------------------------------+-----------+-----------------+-------------------------+----------------------------+
3 rows in set (0.00 sec)
mysql> select * from dolt_diff;
+----------------------------------+-----------------+-----------+-----------------+-------------------------+----------------------------+-------------+---------------+
| commit_hash | table_name | committer | email | date | message | data_change | schema_change |
+----------------------------------+-----------------+-----------+-----------------+-------------------------+----------------------------+-------------+---------------+
| 13qfqa5rojq18j84d1n2htjkm6fletg4 | teams | Tim Sehn | [email protected] | 2022-06-07 16:39:32.066 | Populated tables with data | 1 | 0 |
| 13qfqa5rojq18j84d1n2htjkm6fletg4 | employees | Tim Sehn | [email protected] | 2022-06-07 16:39:32.066 | Populated tables with data | 1 | 0 |
| 13qfqa5rojq18j84d1n2htjkm6fletg4 | employees_teams | Tim Sehn | [email protected] | 2022-06-07 16:39:32.066 | Populated tables with data | 1 | 0 |
| ne182jemgrlm8jnjmoubfqsstlfi1s98 | employees | Tim Sehn | [email protected] | 2022-06-07 16:35:49.277 | Created initial schema | 0 | 1 |
| ne182jemgrlm8jnjmoubfqsstlfi1s98 | employees_teams | Tim Sehn | [email protected] | 2022-06-07 16:35:49.277 | Created initial schema | 0 | 1 |
| ne182jemgrlm8jnjmoubfqsstlfi1s98 | teams | Tim Sehn | [email protected] | 2022-06-07 16:35:49.277 | Created initial schema | 0 | 1 |
+----------------------------------+-----------------+-----------+-----------------+-------------------------+----------------------------+-------------+---------------+
6 rows in set (0.00 sec)mysql> drop table employees_teams;
Query OK, 0 rows affected (0.01 sec)
mysql> show tables;
+---------------------------+
| Tables_in_getting_started |
+---------------------------+
| employees |
| teams |
+---------------------------+
2 rows in set (0.00 sec)mysql> call dolt_reset('--hard');
+--------+
| status |
+--------+
| 0 |
+--------+
1 row in set (0.01 sec)
mysql> show tables;
+---------------------------+
| Tables_in_getting_started |
+---------------------------+
| employees |
| employees_teams |
| teams |
+---------------------------+
3 rows in set (0.01 sec)call dolt_checkout('-b','modifications');
update employees SET first_name='Timothy' where first_name='Tim';
insert INTO employees (id, first_name, last_name) values (4,'Daylon', 'Wilkins');
insert into employees_teams(team_id, employee_id) values (0,4);
delete from employees_teams where employee_id=0 and team_id=1;
call dolt_commit('-am', 'Modifications on a branch')mysql> select * from dolt_branches;
+---------------+----------------------------------+------------------+------------------------+-------------------------+----------------------------+
| name | hash | latest_committer | latest_committer_email | latest_commit_date | latest_commit_message |
+---------------+----------------------------------+------------------+------------------------+-------------------------+----------------------------+
| main | 13qfqa5rojq18j84d1n2htjkm6fletg4 | Tim Sehn | [email protected] | 2022-06-07 16:39:32.066 | Populated tables with data |
| modifications | uhkv57j4bp2v16vcnmev9lshgkqq8ppb | Tim Sehn | [email protected] | 2022-06-07 16:41:49.847 | Modifications on a branch |
+---------------+----------------------------------+------------------+------------------------+-------------------------+----------------------------+
2 rows in set (0.00 sec)
mysql> select active_branch();
+-----------------+
| active_branch() |
+-----------------+
| main |
+-----------------+
1 row in set (0.00 sec)
mysql> select * from employees;
+------+------------+------------+
| id | last_name | first_name |
+------+------------+------------+
| 0 | Sehn | Tim |
| 1 | Hendriks | Brian |
| 2 | Son | Aaron |
| 3 | Fitzgerald | Brian |
+------+------------+------------+
4 rows in set (0.00 sec)mysql> select * from employees as of 'modifications';
+------+------------+------------+
| id | last_name | first_name |
+------+------------+------------+
| 0 | Sehn | Timothy |
| 1 | Hendriks | Brian |
| 2 | Son | Aaron |
| 3 | Fitzgerald | Brian |
| 4 | Wilkins | Daylon |
+------+------------+------------+
5 rows in set (0.01 sec)mysql> select * from dolt_diff('main', 'modifications', 'employees');
+--------------+---------------+-------+---------------+-------------------------+----------------+-----------------+---------+-------------+-------------------------+-----------+
| to_last_name | to_first_name | to_id | to_commit | to_commit_date | from_last_name | from_first_name | from_id | from_commit | from_commit_date | diff_type |
+--------------+---------------+-------+---------------+-------------------------+----------------+-----------------+---------+-------------+-------------------------+-----------+
| Sehn | Timothy | 0 | modifications | 2022-06-07 16:41:49.847 | Sehn | Tim | 0 | main | 2022-06-07 16:39:32.066 | modified |
| Wilkins | Daylon | 4 | modifications | 2022-06-07 16:41:49.847 | NULL | NULL | NULL | main | 2022-06-07 16:39:32.066 | added |
+--------------+---------------+-------+---------------+-------------------------+----------------+-----------------+---------+-------------+-------------------------+-----------+
2 rows in set (0.00 sec)mysql> call dolt_checkout('-b', 'schema_changes');
+--------+
| status |
+--------+
| 0 |
+--------+
1 row in set (0.01 sec)
mysql> alter table employees add column start_date date;
Query OK, 0 rows affected (0.02 sec)
mysql> update employees set start_date='2018-09-08';
Query OK, 4 rows affected (0.01 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> update employees set start_date='2021-04-19' where last_name='Fitzgerald';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from employees;
+------+------------+------------+------------+
| id | last_name | first_name | start_date |
+------+------------+------------+------------+
| 0 | Sehn | Tim | 2018-09-08 |
| 1 | Hendriks | Brian | 2018-09-08 |
| 2 | Son | Aaron | 2018-09-08 |
| 3 | Fitzgerald | Brian | 2021-04-19 |
+------+------------+------------+------------+
4 rows in set (0.00 sec)
mysql> call dolt_commit('-am', 'Added start_date column to employees');
+----------------------------------+
| hash |
+----------------------------------+
| pg3nfi0j1dpc5pf1rfgckpmlteaufdrt |
+----------------------------------+
1 row in set (0.01 sec)mysql> call dolt_checkout('main');
+--------+
| status |
+--------+
| 0 |
+--------+
1 row in set (0.01 sec)
mysql> select * from dolt_status;
Empty set (0.00 sec)
mysql> call dolt_merge('schema_changes');
+--------------+
| no_conflicts |
+--------------+
| 1 |
+--------------+
1 row in set (0.01 sec)
mysql> select * from employees;
+------+------------+------------+------------+
| id | last_name | first_name | start_date |
+------+------------+------------+------------+
| 0 | Sehn | Tim | 2018-09-08 |
| 1 | Hendriks | Brian | 2018-09-08 |
| 2 | Son | Aaron | 2018-09-08 |
| 3 | Fitzgerald | Brian | 2021-04-19 |
+------+------------+------------+------------+
4 rows in set (0.00 sec)mysql> call dolt_merge('modifications');
+--------------+
| no_conflicts |
+--------------+
| 1 |
+--------------+
1 row in set (0.02 sec)
mysql> select * from employees;
+------+------------+------------+------------+
| id | last_name | first_name | start_date |
+------+------------+------------+------------+
| 0 | Sehn | Timothy | 2018-09-08 |
| 1 | Hendriks | Brian | 2018-09-08 |
| 2 | Son | Aaron | 2018-09-08 |
| 3 | Fitzgerald | Brian | 2021-04-19 |
| 4 | Wilkins | Daylon | NULL |
+------+------------+------------+------------+
5 rows in set (0.00 sec)mysql> select first_name, last_name, team_name from employees
join employees_teams on (employees.id=employees_teams.employee_id)
join teams on (teams.id=employees_teams.team_id)
where team_name='Sales';
+------------+------------+-----------+
| first_name | last_name | team_name |
+------------+------------+-----------+
| Brian | Fitzgerald | Sales |
+------------+------------+-----------+
1 row in set (0.01 sec)mysql> select * from dolt_log;
+----------------------------------+-----------+-----------------+-------------------------+----------------------------------------+
| commit_hash | committer | email | date | message |
+----------------------------------+-----------+-----------------+-------------------------+----------------------------------------+
| vn9b0qcematsj2f6ka0hfoflhr5s6p0b | Tim Sehn | [email protected] | 2022-06-07 17:10:02.07 | Merge branch 'modifications' into main |
| pg3nfi0j1dpc5pf1rfgckpmlteaufdrt | Tim Sehn | [email protected] | 2022-06-07 16:44:37.513 | Added start_date column to employees |
| uhkv57j4bp2v16vcnmev9lshgkqq8ppb | Tim Sehn | [email protected] | 2022-06-07 16:41:49.847 | Modifications on a branch |
| 13qfqa5rojq18j84d1n2htjkm6fletg4 | Tim Sehn | [email protected] | 2022-06-07 16:39:32.066 | Populated tables with data |
| ne182jemgrlm8jnjmoubfqsstlfi1s98 | Tim Sehn | [email protected] | 2022-06-07 16:35:49.277 | Created initial schema |
| vluuhvd0bn59598utedt77ed9q5okbcb | Tim Sehn | [email protected] | 2022-06-07 16:33:59.531 | Initialize data repository |
+----------------------------------+-----------+-----------------+-------------------------+----------------------------------------+
6 rows in set (0.00 sec)mysql> select * from dolt_history_employees where id=0 order by commit_date;
+------+-----------+------------+------------+----------------------------------+-----------+-------------------------+
| id | last_name | first_name | start_date | commit_hash | committer | commit_date |
+------+-----------+------------+------------+----------------------------------+-----------+-------------------------+
| 0 | Sehn | Tim | NULL | 13qfqa5rojq18j84d1n2htjkm6fletg4 | Tim Sehn | 2022-06-07 16:39:32.066 |
| 0 | Sehn | Timothy | NULL | uhkv57j4bp2v16vcnmev9lshgkqq8ppb | Tim Sehn | 2022-06-07 16:41:49.847 |
| 0 | Sehn | Tim | 2018-09-08 | pg3nfi0j1dpc5pf1rfgckpmlteaufdrt | Tim Sehn | 2022-06-07 16:44:37.513 |
| 0 | Sehn | Timothy | 2018-09-08 | vn9b0qcematsj2f6ka0hfoflhr5s6p0b | Tim Sehn | 2022-06-07 17:10:02.07 |
+------+-----------+------------+------------+----------------------------------+-----------+-------------------------+
4 rows in set (0.00 sec)mysql> select to_commit,from_first_name,to_first_name from dolt_diff_employees
where (from_id=0 or to_id=0) and (from_first_name <> to_first_name or from_first_name is NULL)
order by to_commit_date;
+----------------------------------+-----------------+---------------+
| to_commit | from_first_name | to_first_name |
+----------------------------------+-----------------+---------------+
| 13qfqa5rojq18j84d1n2htjkm6fletg4 | NULL | Tim |
| uhkv57j4bp2v16vcnmev9lshgkqq8ppb | Tim | Timothy |
| vn9b0qcematsj2f6ka0hfoflhr5s6p0b | Tim | Timothy |
+----------------------------------+-----------------+---------------+
3 rows in set (0.01 sec)


log_levellog_formatbehaviorread_onlyautocommitdisable_client_multi_statementsdolt_transaction_commitevent_schedulerauto_gc_behaviorbranch_activity_trackinglistenerhostportmax_connectionsback_logmax_connections_timeout_millisread_timeout_milliswrite_timeout_millisca_certtls_keytls_certrequire_secure_transportrequire_client_certallow_cleartext_passwordsdata_dirconfig_dirprivilege_filebranch_control_filelog_level: info
log_format: text
behavior:
read_only: false
autocommit: true
disable_client_multi_statements: false
dolt_transaction_commit: false
event_scheduler: "ON"
auto_gc_behavior:
enable: false
archive_level: 0
listener:
host: localhost
port: 3306
max_connections: 1000
back_log: 50
max_connections_timeout_millis: 60000
read_timeout_millis: 28800000
write_timeout_millis: 28800000
ca_cert: null
tls_key: null
tls_cert: null
require_client_cert: null
require_secure_transport: null
allow_cleartext_passwords: null
max_logged_query_len: 0
data_dir: .
cfg_dir: .doltcfg
privilege_file: .doltcfg/privileges.db
branch_control_file: .doltcfg/branch_control.db
# Advanced Configuration
metrics:
labels: {}
host: null
port: -1
remotesapi:
port: null
read_only: null
mcp_server:
port: 7007
user: root
password: ""
database: ""
system_variables: {}
user_session_vars: []
jwks: []
# Cluster configuration has required defaults.
# cluster: {}create table t (
id int primary key,
words varchar(100)
)$ grep log_level config.yaml
log_level: info
$ dolt sql-server --config=config.yaml
Starting server with Config HP="localhost:3310"|T="28800000"|R="false"|L="info"|S="/tmp/mysql.sock"
WARN[0000] unix socket set up failed: file already in use: /tmp/mysql.sock
INFO[0000] Server ready. Accepting connections.
WARN[0000] secure_file_priv is set to "", which is insecure.
WARN[0000] Any user with GRANT FILE privileges will be able to read any file which the sql-server process can read.
WARN[0000] Please consider restarting the server with secure_file_priv set to a safe (or non-existent) directory.
INFO[0009] NewConnection DisableClientMultiStatements=false connectionID=1
WARN[0009] error running query connectTime="2024-12-04 13:22:52.439832 -0800 PST m=+9.896056876" connectionDb=config_blog connectionID=1 error="column \"bad_col\" could not be found in any table in scope"$ emacs config.yaml
$ grep log_level config.yaml
log_level: debug
$ dolt sql-server --config=config.yaml
Starting server with Config HP="localhost:3310"|T="28800000"|R="false"|L="debug"|S="/tmp/mysql.sock"
DEBU[0000] Loading events
WARN[0000] unix socket set up failed: file already in use: /tmp/mysql.sock
INFO[0000] Server ready. Accepting connections.
WARN[0000] secure_file_priv is set to "", which is insecure.
WARN[0000] Any user with GRANT FILE privileges will be able to read any file which the sql-server process can read.
WARN[0000] Please consider restarting the server with secure_file_priv set to a safe (or non-existent) directory.
INFO[0006] NewConnection DisableClientMultiStatements=false connectionID=1
DEBU[0006] Starting query connectTime="2024-12-04 13:25:18.756126 -0800 PST m=+6.422378084" connectionID=1 query="select @@version_comment limit 1"
DEBU[0006] Query finished in 0 ms connectTime="2024-12-04 13:25:18.756126 -0800 PST m=+6.422378084" connectionID=1 query="select @@version_comment limit 1"
DEBU[0011] Starting query connectTime="2024-12-04 13:25:18.756126 -0800 PST m=+6.422378084" connectionID=1 query="SELECT DATABASE()"
DEBU[0011] Query finished in 0 ms connectTime="2024-12-04 13:25:18.756126 -0800 PST m=+6.422378084" connectionID=1 query="SELECT DATABASE()"
DEBU[0011] Starting query connectTime="2024-12-04 13:25:18.756126 -0800 PST m=+6.422378084" connectionDb=config_blog connectionID=1 query="show databases"
DEBU[0011] Query finished in 0 ms connectTime="2024-12-04 13:25:18.756126 -0800 PST m=+6.422378084" connectionDb=config_blog connectionID=1 query="show databases"
DEBU[0011] Starting query connectTime="2024-12-04 13:25:18.756126 -0800 PST m=+6.422378084" connectionDb=config_blog connectionID=1 query="show tables"
DEBU[0011] Query finished in 0 ms connectTime="2024-12-04 13:25:18.756126 -0800 PST m=+6.422378084" connectionDb=config_blog connectionID=1 query="show tables"
DEBU[0011] Starting query connectTime="2024-12-04 13:25:18.756126 -0800 PST m=+6.422378084" connectionDb=config_blog connectionID=1 query="SELECT * FROM `t` LIMIT 0;"
DEBU[0011] Query finished in 0 ms connectTime="2024-12-04 13:25:18.756126 -0800 PST m=+6.422378084" connectionDb=config_blog connectionID=1 query="SELECT * FROM `t` LIMIT 0;"
DEBU[0019] Starting query connectTime="2024-12-04 13:25:18.756126 -0800 PST m=+6.422378084" connectionDb=config_blog connectionID=1 query="select * from t where bad_col=3"
WARN[0019] error running query connectTime="2024-12-04 13:25:18.756126 -0800 PST m=+6.422378084" connectionDb=config_blog connectionID=1 error="column \"bad_col\" could not be found in any table in scope" query="select * from t where bad_col=3"$ grep log_format config.yaml
log_format: json
$ dolt sql-server --config=config.yaml
'Starting server with Config HP="localhost:3306"|T="28800000"|R="false"|L="debug"|S="/tmp/mysql.sock"
{"level":"debug","msg":"Loading events","time":"2025-03-05T09:38:03-08:00"}
{"level":"debug","msg":"privileges.db already exists, not creating root superuser","time":"2025-03-05T09:38:03-08:00"}
{"level":"warning","msg":"unix socket set up failed: file already in use: /tmp/mysql.sock","time":"2025-03-05T09:38:03-08:00"}
{"level":"info","msg":"Server ready. Accepting connections.","time":"2025-03-05T09:38:03-08:00"}
{"level":"warning","msg":"secure_file_priv is set to \"\", which is insecure.","time":"2025-03-05T09:38:03-08:00"}
{"level":"warning","msg":"Any user with GRANT FILE privileges will be able to read any file which the sql-server process can read.","time":"2025-03-05T09:38:03-08:00"}
{"level":"warning","msg":"Please consider restarting the server with secure_file_priv set to a safe (or non-existent) directory.","time":"2025-03-05T09:38:03-08:00"}$ grep read_only config.yaml
read_only: false
read_only: null
$ emacs config.yaml
$ dolt sql-server --config=config.yaml
Starting server with Config HP="localhost:3310"|T="28800000"|R="false"|L="info"|S="/tmp/mysql.sock"
WARN[0000] unix socket set up failed: file already in use: /tmp/mysql.sock
INFO[0000] Server ready. Accepting connections.
WARN[0000] secure_file_priv is set to "", which is insecure.
WARN[0000] Any user with GRANT FILE privileges will be able to read any file which the sql-server process can read.
WARN[0000] Please consider restarting the server with secure_file_priv set to a safe (or non-existent) directory. MySQL [config_blog]> insert into t values (0, 'first');
Query OK, 1 row affected (0.006 sec)$ emacs config.yaml
$ grep read_only config.yaml
read_only: true
read_only: null
$ dolt sql-server --config=config.yaml
Starting server with Config HP="localhost:3310"|T="28800000"|R="true"|L="info"|S="/tmp/mysql.sock"
WARN[0000] unix socket set up failed: file already in use: /tmp/mysql.sock
INFO[0000] Server ready. Accepting connections.
WARN[0000] secure_file_priv is set to "", which is insecure.
WARN[0000] Any user with GRANT FILE privileges will be able to read any file which the sql-server process can read.
WARN[0000] Please consider restarting the server with secure_file_priv set to a safe (or non-existent) directory.
INFO[0016] NewConnection DisableClientMultiStatements=false connectionID=1
WARN[0016] error running query connectTime="2024-12-04 14:38:05.684674 -0800 PST m=+16.751230334" connectionDb=config_blog connectionID=1 error="database server is set to read only mode"MySQL [config_blog]> insert into t values (1, 'second');
ERROR 1105 (HY000): database server is set to read only mode$ grep autocommit config.yaml
autocommit: true
$ dolt sql-server --config=config.yaml
Starting server with Config HP="localhost:3310"|T="28800000"|R="false"|L="info"|S="/tmp/mysql.sock"MySQL [config_blog]> select * from t;
+----+-------+
| id | words |
+----+-------+
| 0 | first |
+----+-------+
1 row in set (0.001 sec)MySQL [config_blog]> select * from t;
+----+-------+
| id | words |
+----+-------+
| 0 | first |
+----+-------+
1 row in set (0.001 sec)MySQL [config_blog]> insert into t values (1, 'second');
Query OK, 1 row affected (0.007 sec)MySQL [config_blog]> select * from t;
+----+--------+
| id | words |
+----+--------+
| 0 | first |
| 1 | second |
+----+--------+
2 rows in set (0.004 sec)$ emacs config.yaml
$ grep autocommit config.yaml
autocommit: false
$ dolt sql-server --config=config.yaml
Starting server with Config HP="localhost:3310"|T="28800000"|R="false"|L="info"|S="/tmp/mysql.sock"MySQL [config_blog]> select * from t;
+----+--------+
| id | words |
+----+--------+
| 0 | first |
| 1 | second |
+----+--------+
2 rows in set (0.004 sec)MySQL [config_blog]> insert into t values (2, 'third');
Query OK, 1 row affected (0.005 sec)MySQL [config_blog]> select * from t;
+----+--------+
| id | words |
+----+--------+
| 0 | first |
| 1 | second |
+----+--------+
2 rows in set (0.001 sec)MySQL [config_blog]> commit;
Query OK, 0 rows affected (0.007 sec)MySQL [config_blog]> begin;
Query OK, 0 rows affected (0.000 sec)
MySQL [config_blog]> select * from t;
+----+--------+
| id | words |
+----+--------+
| 0 | first |
| 1 | second |
| 2 | third |
+----+--------+
3 rows in set (0.001 sec)MySQL [config_blog]> delimiter '?';MySQL [config_blog]> insert into t values (3, 'fourth'); update t set words='first modified' where id=0?
Query OK, 1 row affected (0.012 sec)
Query OK, 1 row affected (0.012 sec)
Rows matched: 1 Changed: 1 Warnings: 0$ emacs config.yaml
$ grep multi_statement config.yaml
disable_client_multi_statements: true
$ dolt sql-server --config=config.yaml
Starting server with Config HP="localhost:3310"|T="28800000"|R="false"|L="debug"|S="/tmp/mysql.sock"MySQL [config_blog]> delete from t where id=3; update t set words='first' where id=0?
ERROR 1105 (HY000): syntax error at position 33 near 'update'MySQL [config_blog]> call dolt_commit('-Am', 'Manual commit');
+----------------------------------+
| hash |
+----------------------------------+
| rgifn94i58hqov4mdv0efsjju0qpg964 |
+----------------------------------+
1 row in set (0.006 sec)
MySQL [config_blog]> select * from dolt_log;
+----------------------------------+-----------+-----------------+---------------------+---------------------------------+
| commit_hash | committer | email | date | message |
+----------------------------------+-----------+-----------------+---------------------+---------------------------------+
| rgifn94i58hqov4mdv0efsjju0qpg964 | root | root@% | 2024-12-05 00:48:50 | Manual commit |
| do1tvb8g442jvggv4e3nfqp3fmqt0u5a | timsehn | [email protected] | 2024-12-03 19:16:49 | Inіtialіze datа rеposіtory |
+----------------------------------+-----------+-----------------+---------------------+---------------------------------+
2 rows in set (0.001 sec)$ emacs config.yaml
$ grep dolt_transaction_commit config.yaml
dolt_transaction_commit: true
$ dolt sql-server --config=config.yaml
Starting server with Config HP="localhost:3310"|T="28800000"|R="false"|L="debug"|S="/tmp/mysql.sock"MySQL [config_blog]> insert into t values (4, 'dolt commit');
Query OK, 1 row affected (0.009 sec)
MySQL [config_blog]> select * from dolt_log;
+----------------------------------+------------+-----------------+---------------------+---------------------------------+
| commit_hash | committer | email | date | message |
+----------------------------------+------------+-----------------+---------------------+---------------------------------+
| vmikac4f7s4395v0v43dtfcbhrmtmo41 | configblog | [email protected] | 2024-12-05 00:51:32 | Transaction commit |
| rgifn94i58hqov4mdv0efsjju0qpg964 | root | root@% | 2024-12-05 00:48:50 | Manual commit |
| do1tvb8g442jvggv4e3nfqp3fmqt0u5a | timsehn | [email protected] | 2024-12-03 19:16:49 | Inіtialіze datа rеposіtory |
+----------------------------------+------------+-----------------+---------------------+---------------------------------+[config_blog]> CREATE EVENT make_dolt_commits ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 MINUTE DO CALL dolt_commit('-A', '--allow-empty', '-m', 'Commit created using an event');
Query OK, 0 rows affected (0.011 sec)DEBU[0090] Executing event config_blog.make_dolt_commits, seconds until execution: -28.759227
DEBU[0090] executing event config_blog.make_dolt_commits query="CALL dolt_commit('-A', '--allow-empty', '-m', 'Commit created using an event')"MySQL [config_blog]> select * from dolt_log;
+----------------------------------+------------+-----------------+---------------------+---------------------------------+
| commit_hash | committer | email | date | message |
+----------------------------------+------------+-----------------+---------------------+---------------------------------+
| im7qq2ja3nfqnc75khtuli8krla3s3fm | root | root@% | 2024-12-05 20:19:04 | Commit created using an event |
| vmikac4f7s4395v0v43dtfcbhrmtmo41 | configblog | [email protected] | 2024-12-05 00:51:32 | Transaction commit |
| rgifn94i58hqov4mdv0efsjju0qpg964 | root | root@% | 2024-12-05 00:48:50 | Manual commit |
| do1tvb8g442jvggv4e3nfqp3fmqt0u5a | timsehn | [email protected] | 2024-12-03 19:16:49 | Inіtialіze datа rеposіtory |
+----------------------------------+------------+-----------------+---------------------+---------------------------------+$ emacs config.yaml
$ grep event_scheduler config.yaml
event_scheduler: "OFF"
$ dolt sql-server --config=config.yaml
Starting server with Config HP="localhost:3310"|T="28800000"|R="false"|L="debug"|S="/tmp/mysql.sock"MySQL [auto_gc_test]> call dolt_gc();
+--------+
| status |
+--------+
| 0 |
+--------+
1 row in set (0,04 sec)
MySQL [auto_gc_test]> select 1;
ERROR 1105 (HY000): this connection was established when this server performed an online garbage collection. this connection can no longer be used. please reconnect.% cat config.yaml
behavior: { auto_gc_behavior: { enable: true } }
% dolt sql-server --config=config.yaml >/dev/null &> call dolt_gc();
+--------+
| status |
+--------+
| 0 |
+--------+
1 row in set (0,04 sec)
> select 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0,01 sec)mysql> CREATE TABLE vals (
-> i1 int, i2 int, i3 int, i4 int, i5 int, i6 int,
-> KEY(i1, i2, i3, i4, i5, i6),
-> KEY(i1, i3, i4, i5, i6, i2),
-> KEY(i1, i4, i5, i6, i2, i3),
-> KEY(i1, i5, i6, i2, i3, i4),
-> KEY(i1, i6, i2, i3, i4, i5)
-> );
Query OK, 0 rows affected, 4 warnings (0,01 sec)
mysql> DELIMITER //
mysql> CREATE PROCEDURE insertn(n INT)
-> BEGIN
-> SET @i = 0;
-> REPEAT
-> SET @i = @i + 1;
-> INSERT INTO vals VALUES (rand()*65536, rand()*65536, rand()*65536, rand()*65536, rand()*65536, rand()*65536);
-> UNTIL @i > n END REPEAT;
-> END //
Query OK, 0 rows affected (0,01 sec)
mysql> DELIMITER ;
mysql> CALL insertn(8192);
Query OK, 1 row affected (3,52 sec)
INFO[0257] sqle/auto_gc: Successfully completed auto GC of database auto_gc_test in 3.508769959smysql> call dolt_gc();
ERROR 1105 (HY000): no changes since last gc% cat config.yaml
behavior: { auto_gc_behavior: { enable: true, archive_level: 1 } }
% dolt sql-server --config config.yaml% cat config.yaml
behavior: { branch_activity_tracking: true } }
% dolt sql-server --config config.yaml$ emacs config.yaml
$ grep host: config.yaml
host: 127.0.0.1
host: null
$ dolt sql-server --config=config.yaml
Starting server with Config HP="127.0.0.1:3310"|T="28800000"|R="false"|L="debug"$ grep port config.yaml
port: 3310
require_secure_transport: null
port: -1
port: null
$ dolt sql-server --config=config.yaml
Starting server with Config HP="localhost:3310"|T="28800000"|R="false"|L="debug"|S="/tmp/mysql.sock"$ grep max_connections config.yaml
max_connections: 1
$ dolt sql-server --config=config.yaml
Starting server with Config HP="127.0.0.1:3310"|T="28800000"|R="false"|L="debug"$ mysql -h 127.0.0.1 -P 3310 -u root
WARNING: option --ssl-verify-server-cert is disabled, because of an insecure passwordless login.
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 8.0.33 Dolt
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>$ mysql -h 127.0.0.1 -P 3310 -u root
WARNING: option --ssl-verify-server-cert is disabled, because of an insecure passwordless login.MySQL [(none)]> exit
Bye$ mysql -h 127.0.0.1 -P 3310 -u root
WARNING: option --ssl-verify-server-cert is disabled, because of an insecure passwordless login.
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 8.0.33 Dolt
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>$ cat config.yaml
listener:
max_connections: 42
back_log: 5
max_connections_timeout_millis: 7000
$ dolt sql-server --config=config.yaml
Starting server with Config HP="127.0.0.1:3310"|T="28800000"|R="false"|L="debug"$ emacs config.yaml
$ grep read_timeout config.yaml
read_timeout_millis: 1
$ dolt sql-server --config=config.yaml
Starting server with Config HP="127.0.0.1:3310"|T="1"|R="false"|L="debug"$ mysql -h 127.0.0.1 -P 3310 -u root
WARNING: option --ssl-verify-server-cert is disabled, because of an insecure passwordless login.
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 8.0.33
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> select sleep(5);
ERROR 2006 (HY000): Server has gone away
No connection. Trying to reconnect...
Connection id: 1
Current database: *** NONE ***
ERROR 1105 (HY000): row read wait bigger than connection timeout tls_key: "/Users/timsehn/dolthub/git/dolt/go/libraries/doltcore/servercfg/tes\
tdata/chain_key.pem"
tls_cert: "/Users/timsehn/dolthub/git/dolt/go/libraries/doltcore/servercfg/te\
stdata/chain_cert.pem"
require_secure_transport: true$ mysql -h 127.0.0.1 -P 3310 -u root
WARNING: option --ssl-verify-server-cert is disabled, because of an insecure passwordless login.
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 8.0.33 Dolt
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> source
ERROR: Usage: \. <filename> | source <filename>
MySQL [(none)]> status
--------------
mysql from 11.6.2-MariaDB, client 15.2 for osx10.20 (arm64) using EditLine wrapper
Connection id: 1
Current database:
Current user: root@%
SSL: Cipher in use is TLS_AES_128_GCM_SHA256, cert is UNKNOWN
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MySQL
Server version: 8.0.33 Dolt
Protocol version: 10
Connection: 127.0.0.1 via TCP/IP
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb4
Conn. characterset: utf8mb4
TCP port: 3310
--------------listener:
require_client_cert: true
tls_key: /path/to/my/certs/server_key.pem
tls_cert: /path/to/my/certs/server_cert.pem$ grep log_level config.yaml
log_level: debug
$ grep max_log config.yaml
max_logged_query_len: 10
$ dolt sql-server --config=config.yaml
Starting server with Config HP="127.0.0.1:3310"|T="28800000"|R="false"|L="debug"DEBU[0020] Starting query connectTime="2024-12-06 14:21:58.139943 -0800 PST m=+3.826578251" connectionDb=config_blog connectionID=1 query="select * f..."$ grep data_dir config.yaml
data_dir: /tmp
$ dolt sql-server --config=config.yaml
Starting server with Config HP="127.0.0.1:3310"|T="28800000"|R="false"|L="debug"$ mysql -h 127.0.0.1 -P 3310 -u root
WARNING: option --ssl-verify-server-cert is disabled, because of an insecure passwordless login.
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 8.0.33 Dolt
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
+--------------------+
2 rows in set (0.000 sec)MySQL [(none)]> create database tmp;
Query OK, 1 row affected (0.135 sec)$ ls -al /tmp/tmp
total 0
drwxr-xr-x 3 timsehn wheel 96 Dec 6 14:26 .
drwxrwxrwt 7 root wheel 224 Dec 6 14:26 ..
drwxr-xr-x 7 timsehn wheel 224 Dec 6 14:26 .dolt$ grep -3 metrics config.yaml
cfg_dir: .doltcfg
metrics:
labels: {}
host: localhost
port: 11111
$ dolt sql-server --config config.yaml
Starting server with Config HP="127.0.0.1:3310"|T="28800000"|R="false"|L="debug"
INFO[0000] Server ready. Accepting connections. $ curl http://localhost:11111/metrics | HEAD -n 10
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6041 0 6041 0 0 4776k 0 --:--:-- --:--:-- --:--:-- 5899k
# HELP dss_concurrent_connections Number of clients concurrently connected to this instance of dolt sql server
# TYPE dss_concurrent_connections gauge
dss_concurrent_connections 0
# HELP dss_concurrent_queries Number of queries concurrently being run on this instance of dolt sql server
# TYPE dss_concurrent_queries gauge
dss_concurrent_queries 0
# HELP dss_connects Count of server connects
# TYPE dss_connects counter
dss_connects 0
# HELP dss_disconnects Count of server disconnects$ grep -3 metrics config.yaml
cfg_dir: .doltcfg
metrics:
host: localhost
port: 11111
labels: {"process": "dolt-sql-server"}
$ dolt sql-server --config config.yaml
Starting server with Config HP="127.0.0.1:3310"|T="28800000"|R="false"|L="debug"
INFO[0000] Server ready. Accepting connections. $ curl http://localhost:11111/metrics | HEAD -n 10
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6425 0 6425 0 0 3115k 0 --:--:-- --:--:-- --:--:-- 3137k
# HELP dss_concurrent_connections Number of clients concurrently connected to this instance of dolt sql server
# TYPE dss_concurrent_connections gauge
dss_concurrent_connections{process="dolt-sql-server"} 0
# HELP dss_concurrent_queries Number of queries concurrently being run on this instance of dolt sql server
# TYPE dss_concurrent_queries gauge
dss_concurrent_queries{process="dolt-sql-server"} 0
# HELP dss_connects Count of server connects
# TYPE dss_connects counter
dss_connects{process="dolt-sql-server"} 0
# HELP dss_disconnects Count of server disconnects$ grep -3 remotesapi config.yaml
port: 11111
labels: {"process": "dolt-sql-server"}
remotesapi:
port: 22222
read_only: null
$ dolt sql-server --config config.yaml
Starting server with Config HP="127.0.0.1:3310"|T="28800000"|R="false"|L="debug"
INFO[0000] Server ready. Accepting connections.
INFO[0000] Starting http server on :22222 $ DOLT_REMOTE_PASSWORD= dolt clone --user root http://localhost:22222/config_blog
cloning http://localhost:22222/config_blog
$ cd config_blog
$ dolt log
commit im7qq2ja3nfqnc75khtuli8krla3s3fm (HEAD -> main, remotes/origin/main)
Author: root <root@%>
Date: Thu Dec 05 12:19:04 -0800 2024
Commit created using an event
commit vmikac4f7s4395v0v43dtfcbhrmtmo41
Author: configblog <[email protected]>
Date: Wed Dec 04 16:51:32 -0800 2024
Transaction commit
commit rgifn94i58hqov4mdv0efsjju0qpg964
Author: root <root@%>
Date: Wed Dec 04 16:48:50 -0800 2024
Manual commit
commit do1tvb8g442jvggv4e3nfqp3fmqt0u5a
Author: timsehn <[email protected]>
Date: Tue Dec 03 11:16:49 -0800 2024
Inіtialіze datа rеposіtory
$ grep -3 remotesapi config.yaml
port: 11111
labels: {"process": "dolt-sql-server"}
remotesapi:
port: 22222
read_only: true
$ dolt sql-server --config config.yaml
Starting server with Config HP="127.0.0.1:3310"|T="28800000"|R="false"|L="debug"
INFO[0000] Starting http server on :22222 $ dolt sql -q "insert into t values (6, 'Can I push this');
dquote> "
Query OK, 1 row affected (0.00 sec)
$ dolt sql -q "select * from t;"
+----+-----------------+
| id | words |
+----+-----------------+
| 0 | first modified |
| 1 | second |
| 2 | third |
| 3 | fourth |
| 4 | dolt commit |
| 6 | Can I push this |
+----+-----------------+
$ dolt commit -am "Added row to push"
commit 0vkmfbrt3d1uljrh0ie0mdikoc9tcsss (HEAD -> main)
Author: timsehn <[email protected]>
Date: Wed Dec 11 14:07:35 -0800 2024
Added row to push
$ DOLT_REMOTE_PASSWORD= dolt push --user root origin main
- Uploading...unknown push error; rpc error: code = PermissionDenied desc = this server only provides read-only access$ grep -5 mcp_server config.yaml
# remotesapi:
# port: 8000
# read_only: false
mcp_server:
port: 7007
user: root
password: ""
database: ""
$ dolt sql-server --config config.yaml
Starting server with Config HP="0.0.0.0:3306"|T="28800000"|R="false"|L="debug"
DEBU[0000] Loading events
DEBU[0000] privileges.db already exists, not creating root superuser
INFO[0000] Server ready. Accepting connections.
WARN[0000] secure_file_priv is set to "", which is insecure.
WARN[0000] Any user with GRANT FILE privileges will be able to read any file which the sql-server process can read.
WARN[0000] Please consider restarting the server with secure_file_priv set to a safe (or non-existent) directory.$ claude mcp add -t http dolt-mcp http://localhost:7007/mcp
Added HTTP MCP server dolt-mcp with URL: http://localhost:7007/mcp to local config$ claude
╭───────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code! │
│ │
│ /help for help, /status for your current setup │
│ │
╰───────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────────╮
│ Manage MCP servers │
│ │
│ ❯ 1. dolt-mcp ✔ connected · Enter to view details │
│ │
╰──────────────────────────────────────────────────────────────╯
Esc to exit$ grep system_variables config.yaml
system_variables: {"dolt_show_system_tables": 1}MySQL [config_blog]> select @@dolt_show_system_tables;
+---------------------------+
| @@dolt_show_system_tables |
+---------------------------+
| 1 |
+---------------------------+
1 row in set (0.000 sec)
MySQL [config_blog]> show tables;
+------------------------------+
| Tables_in_config_blog |
+------------------------------+
| dolt_branches |
| dolt_commit_ancestors |
| dolt_commit_diff_t |
| dolt_commits |
| dolt_conflicts |
| dolt_conflicts_t |
| dolt_constraint_violations |
| dolt_constraint_violations_t |
| dolt_diff_t |
| dolt_history_t |
| dolt_log |
| dolt_remote_branches |
| dolt_remotes |
| dolt_status |
| dolt_workspace_t |
| t |
+------------------------------+
16 rows in set (0.000 sec)$ grep -3 user_session config.yaml
system_variables: {}
user_session_vars:
- name: "root"
vars:
"dolt_show_system_tables": 1MySQL [config_blog]> select user();
+--------+
| user() |
+--------+
| root@% |
+--------+
1 row in set (0.000 sec)
MySQL [config_blog]> select @@dolt_show_system_tables;
+---------------------------+
| @@dolt_show_system_tables |
+---------------------------+
| 1 |
+---------------------------+
1 row in set (0.000 sec)
MySQL [config_blog]> show tables;
+------------------------------+
| Tables_in_config_blog |
+------------------------------+
| dolt_branches |
| dolt_commit_ancestors |
| dolt_commit_diff_t |
| dolt_commits |
| dolt_conflicts |
| dolt_conflicts_t |
| dolt_constraint_violations |
| dolt_constraint_violations_t |
| dolt_diff_t |
| dolt_history_t |
| dolt_log |
| dolt_remote_branches |
| dolt_remotes |
| dolt_status |
| dolt_workspace_t |
| t |
+------------------------------+
16 rows in set (0.000 sec)set @@dolt_transaction_commit = 1;ACTIVE_BRANCH()DOLT_MERGE_BASE()DOLT_HASHOF()DOLT_HASHOF_TABLE()DOLT_HASHOF_DB()DOLT_VERSION()HAS_ANCESTOR()LAST_INSERT_UUID()DOLT_DIFF()DOLT_DIFF_STAT()DOLT_DIFF_SUMMARY()DOLT_JSON_DIFF()DOLT_LOG()DOLT_PATCH()DOLT_PREVIEW_MERGE_CONFLICTS_SUMMARY()DOLT_PREVIEW_MERGE_CONFLICTS()DOLT_REFLOG()DOLT_SCHEMA_DIFF()DOLT_QUERY_DIFF()DOLT_BRANCH_STATUS()DOLT_TEST_RUN()from_revision..to_revision — gets the two dot diff, or revision of table data between the from_revision and to_revision. This is equivalent to dolt_diff(<from_revision>, <to_revision>, <tablename>).to_commitfrom_commitdolt_commit_diff_$tablenamefrom_revision..to_revision — gets the two dot diff stat, or revision of table data between the from_revision and to_revision. This is equivalent to dolt_diff_stat(<from_revision>, <to_revision>, <tablename>).from_revision..to_revision — gets the two dot diff summary, or revision of table data between the from_revision and to_revision. This is equivalent to dolt_diff_summary(<from_revision>, <to_revision>, <tablename>).DOLT_LOG('revision1..revision2')^DOLT_LOG('revision2', '^revision1')^from_revision..to_revision — gets the two dot patch, or revision of table data between the from_revision and to_revision. This is equivalent to dolt_patch(<from_revision>, <to_revision>, <tablename>).dolt_conflict_id is a unique identifier for each conflictfrom_revision..to_revision — gets the two dot diff, or revision of table schema between the from_revision and to_revision. This is equivalent to dolt_schema_diff(<from_revision>, <to_revision>, [<tablename>]).from_table_name and to_table_name, but from_create_statement is different from to_create_statement. This means the table's schema changed between main and feature_branch.to_create_statement A---B---C feature
/
D---E---F---G mainmysql> SELECT dolt_hashof_table('color');
+----------------------------------+
| dolt_hashof_table('color') |
+----------------------------------+
| q8t28sb3h5g2lnhiojacpi7s09p4csjv |
+----------------------------------+
1 row in set (0.01 sec)mysql> SELECT dolt_hashof_db();
+----------------------------------+
| dolt_hashof_db() |
+----------------------------------+
| 1q8t28sb3h5g2lnhiojacpi7s09p4csj |
+----------------------------------+mysql> select dolt_version();
+----------------+
| dolt_version() |
+----------------+
| 0.40.4 |
+----------------+ A---B---C feature
/
D---E---F---G mainselect has_ancestor('feature', 'A'); -- true
select has_ancestor('feature', 'E'); -- true
select has_ancestor('feature', 'F'); -- false
select has_ancestor('main', 'E'); -- true
select has_ancestor('G', 'main'); -- true> create table t (pk binary(16) primary key default (UUID_to_bin(UUID())), c1 varchar(100));
> insert into t (c1) values ("one"), ("two");
Query OK, 2 rows affected (0.00 sec)
> select last_insert_uuid();
+--------------------------------------+
| last_insert_uuid() |
+--------------------------------------+
| 6cd58555-bb3f-45d8-9302-d32d94d8e28a |
+--------------------------------------+
> select c1 from t where pk = uuid_to_bin(last_insert_uuid());
+-----+
| c1 |
+-----+
| one |
+-----+DOLT_DIFF(<from_revision>, <to_revision>, <tablename>)
DOLT_DIFF(<from_revision..to_revision>, <tablename>)
DOLT_DIFF(<from_revision...to_revision>, <tablename>)+------------------+----------+
| field | type |
+------------------+----------+
| from_commit | TEXT |
| from_commit_date | DATETIME |
| to_commit | TEXT |
| to_commit_date | DATETIME |
| diff_type | TEXT |
| other cols | |
+------------------+----------++----------+------+
| field | type |
+----------+------+
| pk | int |
| name | text |
| quantity | int |
+----------+------++----------+------+
| field | type |
+----------+------+
| pk | int |
| name | text |
| color | text |
| size | int |
+----------+------++------------------+----------+
| field | type |
+------------------+----------+
| from_pk | int |
| from_name | text |
| from_quantity | int |
| from_commit | TEXT |
| from_commit_date | DATETIME |
| to_pk | int |
| to_name | text |
| to_color | text |
| to_size | int |
| to_commit | TEXT |
| to_commit_date | DATETIME |
| diff_type | text |
+------------------+----------+SELECT * FROM DOLT_DIFF("main", "feature_branch", "inventory")+---------+-------+---------+----------+----------------+-----------------------------------+-----------+---------+---------------+-------------+-----------------------------------+-----------+
| to_name | to_pk | to_size | to_color | to_commit | to_commit_date | from_name | from_pk | from_quantity | from_commit | from_commit_date | diff_type |
+---------+-------+---------+----------+----------------+-----------------------------------+-----------+---------+---------------+-------------+-----------------------------------+-----------+
| shirt | 1 | 15 | false | feature_branch | 2022-03-23 18:57:38.476 +0000 UTC | shirt | 1 | 70 | main | 2022-03-23 18:51:48.333 +0000 UTC | modified |
| shoes | 2 | 9 | brown | feature_branch | 2022-03-23 18:57:38.476 +0000 UTC | shoes | 2 | 200 | main | 2022-03-23 18:51:48.333 +0000 UTC | modified |
| pants | 3 | 30 | blue | feature_branch | 2022-03-23 18:57:38.476 +0000 UTC | pants | 3 | 150 | main | 2022-03-23 18:51:48.333 +0000 UTC | modified |
| hat | 4 | 6 | grey | feature_branch | 2022-03-23 18:57:38.476 +0000 UTC | NULL | NULL | NULL | main | 2022-03-23 18:51:48.333 +0000 UTC | added |
+---------+-------+---------+----------+----------------+-----------------------------------+-----------+---------+---------------+-------------+-----------------------------------+-----------+A - B - C - D (main)
\
E - F (feature_branch)DOLT_DIFF_STAT(<from_revision>, <to_revision>, <optional_tablename>)
DOLT_DIFF_STAT(<from_revision..to_revision>, <optional_tablename>)
DOLT_DIFF_STAT(<from_revision...to_revision>, <optional_tablename>)+-----------------+--------+
| field | type |
+-----------------+--------+
| table_name | TEXT |
| rows_unmodified | BIGINT |
| rows_added | BIGINT |
| rows_deleted | BIGINT |
| rows_modified | BIGINT |
| cells_added | BIGINT |
| cells_deleted | BIGINT |
| cells_modified | BIGINT |
| old_row_count | BIGINT |
| new_row_count | BIGINT |
| old_cell_count | BIGINT |
| new_cell_count | BIGINT |
+-----------------+--------++----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| pk | int | NO | PRI | NULL | |
| name | varchar(50) | YES | | NULL | |
| quantity | int | YES | | NULL | |
+----------+-------------+------+-----+---------+-------++----+-------+----------+
| pk | name | quantity |
+----+-------+----------+
| 1 | shirt | 15 |
| 2 | shoes | 10 |
+----+-------+----------+ALTER TABLE inventory ADD COLUMN color VARCHAR(10);
INSERT INTO inventory VALUES (3, 'hat', 6, 'red');
UPDATE inventory SET quantity=0 WHERE pk=1;
CREATE TABLE items (name varchar(50));
INSERT INTO items VALUES ('shirt'),('pants');+----+-------+----------+-------+
| pk | name | quantity | color |
+----+-------+----------+-------+
| 1 | shirt | 0 | NULL |
| 2 | shoes | 10 | NULL |
| 3 | hat | 6 | red |
+----+-------+----------+-------+SELECT * FROM DOLT_DIFF_STAT('main', 'WORKING');+------------+-----------------+------------+--------------+---------------+-------------+---------------+----------------+---------------+---------------+----------------+----------------+
| table_name | rows_unmodified | rows_added | rows_deleted | rows_modified | cells_added | cells_deleted | cells_modified | old_row_count | new_row_count | old_cell_count | new_cell_count |
+------------+-----------------+------------+--------------+---------------+-------------+---------------+----------------+---------------+---------------+----------------+----------------+
| inventory | 1 | 1 | 0 | 1 | 6 | 0 | 1 | 2 | 3 | 6 | 12 |
| items | NULL | 2 | 0 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
+------------+-----------------+------------+--------------+---------------+-------------+---------------+----------------+---------------+---------------+----------------+----------------+SELECT * FROM DOLT_DIFF_STAT('WORKING', 'main', 'inventory');+------------+-----------------+------------+--------------+---------------+-------------+---------------+----------------+---------------+---------------+----------------+----------------+
| table_name | rows_unmodified | rows_added | rows_deleted | rows_modified | cells_added | cells_deleted | cells_modified | old_row_count | new_row_count | old_cell_count | new_cell_count |
+------------+-----------------+------------+--------------+---------------+-------------+---------------+----------------+---------------+---------------+----------------+----------------+
| inventory | 1 | 0 | 1 | 1 | 0 | 6 | 1 | 3 | 2 | 12 | 6 |
+------------+-----------------+------------+--------------+---------------+-------------+---------------+----------------+---------------+---------------+----------------+----------------+DOLT_DIFF_SUMMARY(<from_revision>, <to_revision>, <optional_tablename>)
DOLT_DIFF_SUMMARY(<from_revision..to_revision>, <optional_tablename>)
DOLT_DIFF_SUMMARY(<from_revision...to_revision>, <optional_tablename>)+-----------------+---------+
| field | type |
+-----------------+---------+
| from_table_name | TEXT |
| to_table_name | TEXT |
| diff_type | TEXT |
| data_change | BOOLEAN |
| schema_change | BOOLEAN |
+-----------------+---------++----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| pk | int | NO | PRI | NULL | |
| name | varchar(50) | YES | | NULL | |
| quantity | int | YES | | NULL | |
+----------+-------------+------+-----+---------+-------++----+-------+----------+
| pk | name | quantity |
+----+-------+----------+
| 1 | shirt | 15 |
| 2 | shoes | 10 |
+----+-------+----------+ALTER TABLE inventory ADD COLUMN color VARCHAR(10);
INSERT INTO inventory VALUES (3, 'hat', 6, 'red');
UPDATE inventory SET quantity=0 WHERE pk=1;
CREATE TABLE items (name varchar(50));+----+-------+----------+-------+
| pk | name | quantity | color |
+----+-------+----------+-------+
| 1 | shirt | 0 | NULL |
| 2 | shoes | 10 | NULL |
| 3 | hat | 6 | red |
+----+-------+----------+-------+SELECT * FROM DOLT_DIFF_SUMMARY('main', 'WORKING');+-----------------+---------------+-----------+-------------+---------------+
| from_table_name | to_table_name | diff_type | data_change | schema_change |
+-----------------+---------------+-----------+-------------+---------------+
| inventory | inventory | modified | true | true |
| items | items | added | false | true |
+-----------------+---------------+-----------+-------------+---------------+SELECT * FROM DOLT_DIFF_SUMMARY('WORKING', 'main', 'inventory');+-----------------+---------------+-----------+-------------+---------------+
| from_table_name | to_table_name | diff_type | data_change | schema_change |
+-----------------+---------------+-----------+-------------+---------------+
| inventory | inventory | modified | true | true |
+-----------------+---------------+-----------+-------------+---------------+DOLT_DIFF_SUMMARY(<from_document>, <to_document>)+-----------------+---------+
| field | type |
+-----------------+---------+
| diff_type | TEXT |
| path | TEXT |
| from_value | JSON |
| to_value | JSON |
+-----------------+---------++----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| pk | int | NO | PRI | NULL | |
| name | varchar(50) | YES | | NULL | |
| metadata | json | YES | | NULL | |
+----------+-------------+------+-----+---------+-------++----+-------+----------------------------------------------------------------+
| pk | name | metadata. |
+----+-------+----------------------------------------------------------------+
| 1 | shirt | {"colors": ["red"] } |
| 2 | shoes | {"colors": ["black"], "size": "small" } |
| 3 | pants | {"colors": ["blue", "beige"], "materials": ["denim", "silk"] } |
| 4 | tie | {"colours": ["red"], "clip-on": true } |
+----+-------+----------------------------------------------------------------++----+-------+-------------------------------------------------------------+
| pk | name | metadata |
+----+-------+-------------------------------------------------------------+
| 1 | shirt | {"colors": ["red", "blue"], "types": ["tee", "hawaiian"] } |
| 2 | shoes | {"colors": ["white"], "size": "medium" } |
| 3 | pants | {"colors": ["blue"] } |
| 4 | tie | { "colors": ["red"], "clip-on": false } |
+----+-------+-------------------------------------------------------------+SELECT
to_pk as pk,
to_name as name,
json_diff.diff_type as json_diff_type,
row_diff.from_metadata,
row_diff.to_metadata,
path,
json_diff.from_value,
json_diff.to_value
FROM
DOLT_WORKSPACE_inventory AS row_diff
JOIN
lateral (SELECT * FROM DOLT_JSON_DIFF(from_metadata, to_metadata)) json_diff
WHERE row_diff.diff_type = 'modified' and row_diff.staged = false;+----+-------+----------------+----------------------------------------------------------+------------------------------------------------------+-------------+------------------+--------------------+
| pk | name | json_diff_type | from_metadata | to_metadata | path | from_value | to_value |
+----+-------+----------------+----------------------------------------------------------+------------------------------------------------------+-------------+------------------+--------------------+
| 0 | shirt | added | {"colors":["red"]} | {"colors":["red","blue"],"types":["tee","hawaiian"]} | $.colors[1] | NULL | "blue" |
| 0 | shirt | added | {"colors":["red"]} | {"colors":["red","blue"],"types":["tee","hawaiian"]} | $.types | NULL | ["tee","hawaiian"] |
| 1 | shoes | modified | {"colors":["black"],"size":"small"} | {"colors":["white"],"size":"medium"} | $.colors[0] | "black" | "white" |
| 1 | shoes | modified | {"colors":["black"],"size":"small"} | {"colors":["white"],"size":"medium"} | $.size | "small" | "medium" |
| 2 | pants | removed | {"colors":["blue","beige"],"materials":["denim","silk"]} | {"colors":["blue"]} | $.colors[1] | "beige" | NULL |
| 2 | pants | removed | {"colors":["blue","beige"],"materials":["denim","silk"]} | {"colors":["blue"]} | $.materials | ["denim","silk"] | NULL |
| 3 | tie | modified | {"clip-on":true,"colours":["red"]} | {"clip-on":false,"colors":["red"]} | $.clip-on | true | false |
| 3 | tie | added | {"clip-on":true,"colours":["red"]} | {"clip-on":false,"colors":["red"]} | $.colors | NULL | ["red"] |
| 3 | tie | removed | {"clip-on":true,"colours":["red"]} | {"clip-on":false,"colors":["red"]} | $.colours | ["red"] | NULL |
+----+-------+----------------+----------------------------------------------------------+------------------------------------------------------+-------------+------------------+--------------------+DOLT_LOG([<optional_revisions>...], [--tables <tables>...])+--------------+----------+
| field | type |
+--------------+--------- +
| commit_hash | text |
| committer | text |
| email | text |
| date | datetime |
| message | text |
| commit_order | int |
| parents | text | -- column hidden unless `--parents` flag provided
| refs | text | -- column hidden unless `--decorate` is "short" or "full"
+--------------+--------- +A - B - C - D (main)
\
E - F (feature)SELECT * FROM DOLT_LOG('main');+----------------------------------+-----------+--------------------+-----------------------------------+---------------+
| commit_hash | committer | email | date | message |
+----------------------------------+-----------+--------------------+-----------------------------------+---------------+
| qi331vjgoavqpi5am334cji1gmhlkdv5 | bheni | [email protected] | 2019-06-07 00:22:24.856 +0000 UTC | update rating |
| 137qgvrsve1u458briekqar5f7iiqq2j | bheni | [email protected] | 2019-04-04 22:43:00.197 +0000 UTC | change rating |
| rqpd7ga1nic3jmc54h44qa05i8124vsp | bheni | [email protected] | 2019-04-04 21:07:36.536 +0000 UTC | fixes |
| qfk3bpan8mtrl05n8nihh2e3t68t3hrk | bheni | [email protected] | 2019-04-04 21:01:16.649 +0000 UTC | test |
+----------------------------------+-----------+--------------------+-----------------------------------+---------------+SELECT * FROM DOLT_LOG('feature');SELECT * FROM DOLT_LOG('main..feature');
SELECT * FROM DOLT_LOG('feature', '^main');
SELECT * FROM DOLT_LOG('feature', '--not', 'main');SELECT * FROM DOLT_LOG('main...feature');DOLT_PATCH(<from_revision>, <to_revision>, <optional_tablename>)
DOLT_PATCH(<from_revision..to_revision>, <optional_tablename>)
DOLT_PATCH(<from_revision...to_revision>, <optional_tablename>)+------------------+--------+
| field | type |
+------------------+--------+
| statement_order | BIGINT |
| from_commit_hash | TEXT |
| to_commit_hash | TEXT |
| table_name | TEXT |
| diff_type | TEXT |
| statement | TEXT |
+------------------+--------++----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| pk | int | NO | PRI | NULL | |
| name | varchar(50) | YES | | NULL | |
| quantity | int | YES | | NULL | |
+----------+-------------+------+-----+---------+-------++----+-------+----------+
| pk | name | quantity |
+----+-------+----------+
| 1 | shirt | 15 |
| 2 | shoes | 10 |
+----+-------+----------+INSERT INTO inventory VALUES (3, 'hat', 6);
UPDATE inventory SET quantity=0 WHERE pk=1;
CREATE TABLE items (name varchar(50));
INSERT INTO items VALUES ('shirt'),('pants');+----+-------+----------+
| pk | name | quantity |
+----+-------+----------+
| 1 | shirt | 0 |
| 2 | shoes | 10 |
| 3 | hat | 6 |
+----+-------+----------+SELECT * FROM DOLT_PATCH('main', 'WORKING');+-----------------+----------------------------------+----------------+------------+-----------+----------------------------------------------------------------------+
| statement_order | from_commit_hash | to_commit_hash | table_name | diff_type | statement |
+-----------------+----------------------------------+----------------+------------+-----------+----------------------------------------------------------------------+
| 1 | gg4kasjl6tgrtoag8tnn1der09sit4co | WORKING | inventory | data | UPDATE `inventory` SET `quantity`=0 WHERE `pk`=1; |
| 2 | gg4kasjl6tgrtoag8tnn1der09sit4co | WORKING | inventory | data | INSERT INTO `inventory` (`pk`,`name`,`quantity`) VALUES (3,'hat',6); |
| 3 | gg4kasjl6tgrtoag8tnn1der09sit4co | WORKING | items | schema | CREATE TABLE `items` ( |
| | | | | | `name` varchar(50) |
| | | | | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; |
| 4 | gg4kasjl6tgrtoag8tnn1der09sit4co | WORKING | items | data | INSERT INTO `items` (`name`) VALUES ('shirt'); |
| 5 | gg4kasjl6tgrtoag8tnn1der09sit4co | WORKING | items | data | INSERT INTO `items` (`name`) VALUES ('pants'); |
+-----------------+----------------------------------+----------------+------------+-----------+----------------------------------------------------------------------+SELECT * FROM DOLT_PATCH('WORKING', 'main', 'items') WHERE diff_type = 'schema';+-----------------+------------------+----------------------------------+------------+-----------+---------------------+
| statement_order | from_commit_hash | to_commit_hash | table_name | diff_type | statement |
+-----------------+------------------+----------------------------------+------------+-----------+---------------------+
| 1 | WORKING | gg4kasjl6tgrtoag8tnn1der09sit4co | items | schema | DROP TABLE `items`; |
+-----------------+------------------+----------------------------------+------------+-----------+---------------------+DOLT_PREVIEW_MERGE_CONFLICTS_SUMMARY(<base_branch>, <merge_branch>)+---------------------+--------+
| field | type |
+---------------------+--------+
| table | TEXT |
| num_data_conflicts | BIGINT |
| num_schema_conflicts| BIGINT |
+---------------------+--------+SELECT * FROM DOLT_PREVIEW_MERGE_CONFLICTS_SUMMARY('main', 'feature_branch');+----------+--------------------+---------------------+
| table | num_data_conflicts | num_schema_conflicts|
+----------+--------------------+---------------------+
| users | 3 | 0 |
| orders | 1 | 0 |
| products | NULL | 2 |
+----------+--------------------+---------------------+DOLT_PREVIEW_MERGE_CONFLICTS(<base_branch>, <merge_branch>, <table_name>)+------------------+--------+
| field | type |
+------------------+--------+
| from_root_ish | TEXT |
| our_diff_type | TEXT |
| their_diff_type | TEXT |
| dolt_conflict_id | TEXT |
+------------------+--------+SELECT * FROM DOLT_PREVIEW_MERGE_CONFLICTS('main', 'feature_branch', 'users');+----------------------------------+---------+-----------+----------------+---------+-----------+------------------+---------------+-----------+-----------+-------------------+-----------------+------------------------+
| from_root_ish | base_id | base_name | base_email | our_id | our_name | our_email | our_diff_type | their_id | their_name| their_email | their_diff_type | dolt_conflict_id |
+----------------------------------+---------+-----------+----------------+---------+-----------+------------------+---------------+-----------+-----------+-------------------+-----------------+------------------------+
| abc123def456789012345678901234567 | 1 | John | [email protected] | 1 | John Doe | [email protected] | modified | 1 | John | [email protected] | modified | abc123def456 |
| abc123def456789012345678901234567 | NULL | NULL | NULL | 2 | Jane | [email protected] | added | 2 | Jane Doe | [email protected] | added | def789ghi012 |
+----------------------------------+---------+-----------+----------------+---------+-----------+------------------+---------------+-----------+-----------+-------------------+-----------------+------------------------+SELECT dolt_conflict_id, base_name, our_name, our_diff_type, their_name, their_diff_type
FROM DOLT_PREVIEW_MERGE_CONFLICTS('main', 'feature_branch', 'users');+-------------------+--------+
| field | type |
+-------------------+--------+
| base_cardinality | BIGINT |
| our_cardinality | BIGINT |
| their_cardinality | BIGINT |
+-------------------+--------+SELECT * FROM DOLT_PREVIEW_MERGE_CONFLICTS('main', 'feature_branch', 'logs');+----------------------------------+---------------------+-------------+------------------+---------------------+-------------+------------------+---------------+---------------------+-------------+------------------+-----------------+------------------------+------------------+-------------------+---------------------+
| from_root_ish | base_timestamp | base_level | base_message | our_timestamp | our_level | our_message | our_diff_type | their_timestamp | their_level | their_message | their_diff_type | dolt_conflict_id | base_cardinality | our_cardinality | their_cardinality |
+----------------------------------+---------------------+-------------+------------------+---------------------+-------------+------------------+---------------+---------------------+-------------+------------------+-----------------+------------------------+------------------+-------------------+---------------------+
| abc123def456789012345678901234567 | 2023-01-01 10:00:00 | ERROR | Database timeout | 2023-01-01 10:00:00 | ERROR | Database timeout | modified | 2023-01-01 10:00:00 | ERROR | Database timeout | modified | xyz789abc123 | 1 | 3 | 2 |
+----------------------------------+---------------------+-------------+------------------+---------------------+-------------+------------------+---------------+---------------------+-------------+------------------+-----------------+------------------------+------------------+-------------------+---------------------+DOLT_REFLOG()
DOLT_REFLOG(['--all'], <ref_name>)+-----------------------+-----------+
| field | type |
+-----------------------+-----------+
| ref | TEXT |
| ref_timestamp | TIMESTAMP |
| commit_hash | TEXT |
| commit_message | TEXT |
+-----------------------+-----------+-- Someone accidentally deletes the wrong branch!
call dolt_branch('-D', 'prodBranch');
-- After we realize the wrong branch has been deleted, we query the Dolt reflog on the same Dolt database instance
-- where the branch was deleted to see what commits the prodBranch branch has referenced. Using the same Dolt
-- instance is important, since reflog information is always local and not included when pushing/pulling databases.
select * from dolt_reflog('prodBranch');
+-----------------------+---------------------+----------------------------------+-------------------------------+
| ref | ref_timestamp | commit_hash | commit_message |
+-----------------------+---------------------+----------------------------------+-------------------------------+
| refs/heads/prodBranch | 2023-10-25 20:54:37 | v531ptpmv2tquig8v591tsjghtj84ksg | inserting row 42 |
| refs/heads/prodBranch | 2023-10-25 20:53:12 | rvt34lqrbtdr3dhnjchruu73lik4e398 | inserting row 100000 |
| refs/heads/prodBranch | 2023-10-25 20:53:06 | v531ptpmv2tquig8v591tsjghtj84ksg | inserting row 42 |
| refs/heads/prodBranch | 2023-10-25 20:52:43 | ihuj1l7fmqq37sjhtlrgpup5n76gfhju | inserting row 1 into table xy |
+-----------------------+---------------------+----------------------------------+-------------------------------+
-- The last commit prodBranch pointed to was v531ptpmv2tquig8v591tsjghtj84ksg, so to restore our branch, we
-- just need to create a branch with the same name, pointing to that last commit.
call dolt_branch('prodBranch', 'v531ptpmv2tquig8v591tsjghtj84ksg');DOLT_SCHEMA_DIFF(<from_commit>, <to_commit>, <optional_tablename>)
DOLT_SCHEMA_DIFF(<from_revision..to_revision>, <optional_tablename>)
DOLT_SCHEMA_DIFF(<from_revision...to_revision>, <optional_tablename>)+-----------------------+------+
| field | type |
+-----------------------+------+
| from_table_name | TEXT |
| to_table_name | TEXT |
| from_create_statement | TEXT |
| to_create_statement | TEXT |
+-----------------------+------+SELECT * FROM DOLT_SCHEMA_DIFF("main", "feature_branch")+-----------------+---------------+-------------------------------------------------------------------+-------------------------------------------------------------------+
| from_table_name | to_table_name | from_create_statement | to_create_statement |
+-----------------+---------------+-------------------------------------------------------------------+-------------------------------------------------------------------+
| employees | | CREATE TABLE `employees` ( | |
| | | `pk` int NOT NULL, | |
| | | `name` varchar(50), | |
| | | PRIMARY KEY (`pk`) | |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; | |
| inventory | inventory | CREATE TABLE `inventory` ( | CREATE TABLE `inventory` ( |
| | | `pk` int NOT NULL, | `pk` int NOT NULL, |
| | | `name` varchar(50), | `name` varchar(50), |
| | | `quantity` int, | `color` varchar(10), |
| | | PRIMARY KEY (`pk`) | PRIMARY KEY (`pk`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; |
| | photos | | CREATE TABLE `photos` ( |
| | | | `pk` int NOT NULL, |
| | | | `name` varchar(50), |
| | | | `dt` datetime(6), |
| | | | PRIMARY KEY (`pk`) |
| | | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; |
| vacations | trips | CREATE TABLE `vacations` ( | CREATE TABLE `trips` ( |
| | | `pk` int NOT NULL, | `pk` int NOT NULL, |
| | | `name` varchar(50), | `name` varchar(50), |
| | | PRIMARY KEY (`pk`) | PRIMARY KEY (`pk`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; |
+-----------------+---------------+-------------------------------------------------------------------+-------------------------------------------------------------------+select * from dolt_schema_diff('v1', 'v1.1');
select * from dolt_schema_diff('tjj1kp2mnoad8crv6b94mh4a4jiq7ab2', 'v391rm7r0t4989sgomv0rpn9ue4ugo6g');SELECT * FROM DOLT_SCHEMA_DIFF("main", "feature_branch", "inventory")+-----------------+---------------+-------------------------------------------------------------------+-------------------------------------------------------------------+
| from_table_name | to_table_name | from_create_statement | to_create_statement |
+-----------------+---------------+-------------------------------------------------------------------+-------------------------------------------------------------------+
| inventory | inventory | CREATE TABLE `inventory` ( | CREATE TABLE `inventory` ( |
| | | `pk` int NOT NULL, | `pk` int NOT NULL, |
| | | `name` varchar(50), | `name` varchar(50), |
| | | `quantity` int, | `color` varchar(10), |
| | | PRIMARY KEY (`pk`) | PRIMARY KEY (`pk`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; |
+-----------------+---------------+-------------------------------------------------------------------+-------------------------------------------------------------------+SELECT * FROM DOLT_SCHEMA_DIFF("main", "feature_branch", "trips");
SELECT * FROM DOLT_SCHEMA_DIFF("main", "feature_branch", "vacations");+-----------------+---------------+-------------------------------------------------------------------+-------------------------------------------------------------------+
| from_table_name | to_table_name | from_create_statement | to_create_statement |
+-----------------+---------------+-------------------------------------------------------------------+-------------------------------------------------------------------+
| vacations | trips | CREATE TABLE `vacations` ( | CREATE TABLE `trips` ( |
| | | `pk` int NOT NULL, | `pk` int NOT NULL, |
| | | `name` varchar(50), | `name` varchar(50), |
| | | PRIMARY KEY (`pk`) | PRIMARY KEY (`pk`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; |
+-----------------+---------------+-------------------------------------------------------------------+-------------------------------------------------------------------+select * from dolt_schema_diff('feature_branch', 'main');+-----------------+---------------+-------------------------------------------------------------------+-------------------------------------------------------------------+
| from_table_name | to_table_name | from_create_statement | to_create_statement |
+-----------------+---------------+-------------------------------------------------------------------+-------------------------------------------------------------------+
| photos | | CREATE TABLE `photos` ( | |
| | | `pk` int NOT NULL, | |
| | | `name` varchar(50), | |
| | | `dt` datetime(6), | |
| | | PRIMARY KEY (`pk`) | |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; | |
| | employees | | CREATE TABLE `employees` ( |
| | | | `pk` int NOT NULL, |
| | | | `name` varchar(50), |
| | | | PRIMARY KEY (`pk`) |
| | | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; |
| inventory | inventory | CREATE TABLE `inventory` ( | CREATE TABLE `inventory` ( |
| | | `pk` int NOT NULL, | `pk` int NOT NULL, |
| | | `name` varchar(50), | `name` varchar(50), |
| | | `color` varchar(10), | `quantity` int, |
| | | PRIMARY KEY (`pk`) | PRIMARY KEY (`pk`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; |
| trips | vacations | CREATE TABLE `trips` ( | CREATE TABLE `vacations` ( |
| | | `pk` int NOT NULL, | `pk` int NOT NULL, |
| | | `name` varchar(50), | `name` varchar(50), |
| | | PRIMARY KEY (`pk`) | PRIMARY KEY (`pk`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; |
+-----------------+---------------+-------------------------------------------------------------------+-------------------------------------------------------------------++---+----+
| i | j |
+---+----+
| 0 | 0 |
| 1 | 10 |
| 3 | 3 |
| 4 | 4 |
+---+----++---+---+
| i | j |
+---+---+
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
| 4 | 4 |
+---+---+dolt> select * from dolt_query_diff('select * from t as of main', 'select * from t as of other');
+--------+--------+------+------+-----------+
| from_i | from_j | to_i | to_j | diff_type |
+--------+--------+------+------+-----------+
| 1 | 10 | 1 | 1 | modified |
| NULL | NULL | 2 | 2 | added |
| 3 | 3 | NULL | NULL | deleted |
+--------+--------+------+------+-----------+
3 rows in set (0.00 sec)DOLT_BRANCH_STATUS(<base_refspec>, [<target_refspec1, target_refspec2, ...])+----------------+------+
| field | type |
+----------------+------+
| branch | TEXT |
| commits_ahead | INT |
| commits_behind | INT |
+----------------+------+tmp/main> select * from dolt_log();
+----------------------------------+-----------+-------------------+---------------------+----------------------------+--------------+
| commit_hash | committer | email | date | message | commit_order |
+----------------------------------+-----------+-------------------+---------------------+----------------------------+--------------+
| 0qkkos3enbd4bh8e1ppbcupsa1paubr0 | root | root@localhost | 2025-06-02 21:06:20 | main commit | 2 |
| 8elol3v7a8u94rti5fjpakkm1vq25slv | jcor | [email protected] | 2025-06-02 21:05:52 | Initialize data repository | 1 |
+----------------------------------+-----------+-------------------+---------------------+----------------------------+--------------+
2 rows in set (0.00 sec)tmp/other> select * from dolt_log();
+----------------------------------+-----------+-------------------+---------------------+----------------------------+--------------+
| commit_hash | committer | email | date | message | commit_order |
+----------------------------------+-----------+-------------------+---------------------+----------------------------+--------------+
| ip47q9ee2un84se8nvq5c5kuil7uuqvo | root | root@localhost | 2025-06-02 21:06:12 | other commit 2 | 3 |
| hoitroluotdc94cdmma82mvh9s0ct94b | root | root@localhost | 2025-06-02 21:06:11 | other commit 1 | 2 |
| 8elol3v7a8u94rti5fjpakkm1vq25slv | jcor | [email protected] | 2025-06-02 21:05:52 | Initialize data repository | 1 |
+----------------------------------+-----------+-------------------+---------------------+----------------------------+--------------+
3 rows in set (0.00 sec)
tmp/main> SELECT * FROM DOLT_BRANCH_STATUS('main', 'other');
+--------+---------------+----------------+
| branch | commits_ahead | commits_behind |
+--------+---------------+----------------+
| other | 2 | 1 |
+--------+---------------+----------------+
1 row in set (0.00 sec)DOLT_TEST_RUN()
DOLT_TEST_RUN('*')
DOLT_TEST_RUN(<test_name>)
DOLT_TEST_RUN(<group_name>)
DOLT_TEST_RUN(<test_name>, <test_name>, <group_name>) +-----------------+------+
| field | type |
+-----------------+------+
| test_name | TEXT |
| test_group_name | TEXT |
| query | TEXT |
| status | TEXT |
| message | TEXT |
+-----------------+------+INSERT INTO dolt_tests VALUES
('user_count_test', 'users', 'SELECT COUNT(*) FROM users', 'expected_single_value', '>=', '10'),
('active_users_test', 'users', 'SELECT COUNT(*) FROM users WHERE active = 1', 'expected_single_value', '>', '5'),
('table_columns_test', 'schema', 'SELECT * FROM products', 'expected_columns', '==', '4');SELECT * FROM DOLT_TEST_RUN();+-------------------+-----------------+-----------------------------------------------+--------+-----------------------------------------------------------------+
| test_name | test_group_name | query | status | message |
+-------------------+-----------------+-----------------------------------------------+--------+-----------------------------------------------------------------+
| user_count_test | users | SELECT COUNT(*) FROM users | PASS | |
| active_users_test | users | SELECT COUNT(*) FROM users WHERE active = 1 | FAIL | Assertion failed: expected_single_value greater than 5, got 3 |
| table_columns_test| schema | SELECT * FROM products | PASS | |
+-------------------+-----------------+-----------------------------------------------+--------+-----------------------------------------------------------------+--- This will run all tests
SELECT * FROM DOLT_TEST_RUN('*');
--- This will run both groups
SELECT * FROM DOLT_TEST_RUN('users', 'schema')
--- This will run these two specific tests
SELECT * FROM DOLT_TEST_RUN('user_count_test', 'table_columns_test')+------------------------+----------+
| Field | Type |
+------------------------+----------+
| name | TEXT |
| hash | TEXT |
| latest_committer | TEXT |
| latest_committer_email | TEXT |
| latest_commit_date | DATETIME |
| latest_commit_message | TEXT |
| remote | TEXT |
| branch | TEXT |
| dirty | BOOLEAN |
+------------------------+----------++------------------------+----------+
| Field | Type |
+------------------------+----------+
| name | TEXT |
| hash | TEXT |
| latest_committer | TEXT |
| latest_committer_email | TEXT |
| latest_commit_date | DATETIME |
| latest_commit_message | TEXT |
+------------------------+----------+SELECT *
FROM dolt_branches
UNION
SELECT * FROM dolt_remote_branches;+-----------------+----------------------------------+------------------+------------------------+-------------------------+----------------------------+
| name | hash | latest_committer | latest_committer_email | latest_commit_date | latest_commit_message |
+-----------------+----------------------------------+------------------+------------------------+-------------------------+----------------------------+
| main | r3flrdqk73lkcrugtbohcdbb3hmr2bev | Zach Musgrave | [email protected] | 2023-02-01 18:59:55.156 | Initialize data repository |
| remotes/rem1/b1 | r3flrdqk73lkcrugtbohcdbb3hmr2bev | Zach Musgrave | [email protected] | 2023-02-01 18:59:55.156 | Initialize data repository |
+-----------------+----------------------------------+------------------+------------------------+-------------------------+----------------------------++----------+------+
| field | type |
+----------+------+
| doc_name | text |
| doc_text | text |
+----------+------++-------------+----------+
| field | type |
+-------------+----------+
| name | longtext |
| create_stmt | longtext |
| created_at | datetime |
| modified_at | datetime |
| sql_mode | longtext |
+-------------+----------+CREATE PROCEDURE simple_proc1(x DOUBLE, y DOUBLE) SELECT x*y;
CREATE PROCEDURE simple_proc2() SELECT name FROM category;+---------------+-----------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-----------------+------+-----+---------+-------+
| id | varchar(16383) | NO | PRI | | |
| display_order | bigint unsigned | NO | | | |
| name | varchar(16383) | YES | | | |
| query | varchar(16383) | YES | | | |
| description | varchar(16383) | YES | | | |
+---------------+-----------------+------+-----+---------+-------+> dolt sql -q "select * from tablename" -s "select all" -m "Query to select all records from tablename"> dolt sql -x "Large Irises"
Executing saved query 'Large Irises':
select distinct(class) from classified_measurements where petal_length_cm > 5
+------------+
| class) |
+------------+
| versicolor |
| virginica |
+------------+dolt add dolt_query_catalog
dolt commit -m "Adding new named query"+-------------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+------+------+-----+---------+-------+
| name | text | NO | PRI | | |
| url | text | NO | | | |
| fetch_specs | json | YES | | | |
| params | json | YES | | | |
+-------------+------+------+-----+---------+-------+SELECT *
FROM dolt_remotes
WHERE name = 'origin';+--------+-----------------------------------------+--------------------------------------+--------+
| name | url | fetch_specs | params |
+--------+-----------------------------------------+--------------------------------------+--------+
| origin | file:///go/github.com/dolthub/dolt/rem1 | [refs/heads/*:refs/remotes/origin/*] | map[] |
+--------+-----------------------------------------+--------------------------------------+--------++-------------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+------+------+-----+---------+-------+
| name | text | NO | PRI | | |
| url | text | NO | | | |
+-------------+------+------+-----+---------+-------++-------------+----------------------------------------+
| name | url |
+-------------+----------------------------------------+
| backup-west | aws://[ddb-westtable:s3bucket-west]/db |
| backup-east | aws://[ddb-easttable:s3bucket-east]/db |
| backup-local| file:///path/to/local/backup |
+-------------+----------------------------------------++----------+----------------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+----------------------------------------+------+-----+---------+-------+
| type | varchar(64) COLLATE utf8mb4_0900_ai_ci | NO | PRI | NULL | |
| name | varchar(64) COLLATE utf8mb4_0900_ai_ci | NO | PRI | NULL | |
| fragment | longtext | YES | | NULL | |
| extra | json | YES | | NULL | |
+----------+----------------------------------------+------+-----+---------+-------+CREATE VIEW four AS SELECT 2+2 FROM dual;
CREATE TABLE mytable (x INT PRIMARY KEY);
CREATE TRIGGER inc_insert BEFORE INSERT ON mytable FOR EACH ROW SET NEW.x = NEW.x + 1;
CREATE EVENT monthly_gc ON SCHEDULE EVERY 1 MONTH DO CALL DOLT_GC();+----------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+----------+------+-----+---------+-------+
| tag_name | text | NO | PRI | NULL | |
| tag_hash | text | NO | PRI | NULL | |
| tagger | text | NO | | NULL | |
| email | text | NO | | NULL | |
| date | datetime | NO | | NULL | |
| message | text | NO | | NULL | |
+----------+----------+------+-----+---------+-------+CALL DOLT_TAG('_migrationtest','head','-m','savepoint for migration testing');+--------+
| status |
+--------+
| 0 |
+--------++-------------------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+----------+------+-----+---------+-------+
| branch | text | NO | PRI | NULL | |
| last_read | datetime | YES | | NULL | |
| last_write | datetime | YES | | NULL | |
| active_sessions | int | NO | | NULL | |
| system_start_time | datetime | NO | | NULL | |
+-------------------+----------+------+-----+---------+-------+SELECT *
FROM dolt_branch_activity
WHERE active_sessions = 0
AND system_start_time < NOW() - INTERVAL 7 DAY
AND (last_read IS NULL OR last_read < NOW() - INTERVAL 7 DAY)
AND (last_write IS NULL OR last_write < NOW() - INTERVAL 7 DAY);+-----------------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+----------+------+-----+---------+-------+
| database_name | text | NO | PRI | NULL | |
| table_name | text | NO | PRI | NULL | |
| index_name | text | NO | PRI | NULL | |
| row_count | bigint | NO | | NULL | |
| distinct_count | bigint | NO | | NULL | |
| null_count | bigint | NO | | NULL | |
| columns | text | NO | | NULL | |
| types | text | NO | | NULL | |
| upper_bound | text | NO | | NULL | |
| upper_bound_cnt | bigint | NO | | NULL | |
| created_at | datetime | NO | | NULL | |
| mcv1 | text | NO | | NULL | |
| mcv2 | text | NO | | NULL | |
| mcv3 | text | NO | | NULL | |
| mcv4 | text | NO | | NULL | |
| mcvCounts | text | NO | | NULL | |
+-----------------+----------+------+-----+---------+-------++-------------------+----------+
| field | type |
+-------------------+----------+
| commit | text |
| commit_date | datetime |
| committer | text |
| email | text |
| message | text |
| primary key cols | |
+-------------------+----------++--------------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+------+------+-----+---------+-------+
| commit_hash | text | NO | PRI | | |
| parent_hash | text | NO | PRI | | |
| parent_index | int | NO | PRI | | |
+--------------+------+------+-----+---------+-------+> describe dolt_commits;
+-------------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+----------+------+-----+---------+-------+
| commit_hash | text | NO | PRI | | |
| committer | text | NO | | | |
| email | text | NO | | | |
| date | datetime | NO | | | |
| message | text | NO | | | |
+-------------+----------+------+-----+---------+-------++-------------+----------+
| field | type |
+-------------+----------+
| commit_hash | TEXT |
| committer | TEXT |
| commit_date | DATETIME |
| other cols | |
+-------------+----------++------------+--------+
| field | type |
+------------+--------+
| x | INT |
+------------+--------++-------------+----------+
| field | type |
+-------------+----------+
| x | INT |
| commit_hash | TEXT |
| committer | TEXT |
| commit_date | DATETIME |
+-------------+----------+ B---E feature
/
A---C---D main+--------------+----------+
| field | type |
+--------------+--------- +
| commit_hash | text |
| committer | text |
| email | text |
| date | datetime |
| message | text |
| commit_order | int |
+--------------+--------- ++------------------+----------+
| field | type |
+------------------+----------+
| from_commit | TEXT |
| from_commit_date | DATETIME |
| to_commit | TEXT |
| to_commit_date | DATETIME |
| diff_type | TEXT |
| other cols | |
+------------------+----------++--------------+
| field | type |
+--------------+
| x | int |
+--------------++------------------+----------+
| field | type |
+------------------+----------+
| to_x | int |
| to_commit | longtext |
| to_commit_date | datetime |
| from_x | int |
| from_commit | longtext |
| from_commit_date | datetime |
| diff_type | varchar |
+------------------+----------+ A---B---C feature
/
D---E---F---G main+---------------+----------+
| field | Type |
+---------------+----------+
| commit_hash | text |
| table_name | text |
| committer | text |
| email | text |
| date | datetime |
| message | text |
| data_change | boolean |
| schema_change | boolean |
+---------------+----------++-------------+----------+
| field | Type |
+-------------+----------+
| commit_hash | text |
| table_name | text |
| column_name | text |
| committer | text |
| email | text |
| date | datetime |
| message | text |
| diff_type | text |
+-------------+----------++------------------+----------+
| field | type |
+------------------+----------+
| from_commit | TEXT |
| from_commit_date | DATETIME |
| to_commit | TEXT |
| to_commit_date | DATETIME |
| diff_type | TEXT |
| other cols | |
+------------------+----------++------------+--------+
| field | type |
+------------+--------+
| state | TEXT |
| population | BIGINT |
| area | BIGINT |
+-------------+-------++------------------+----------+
| field | type |
+-----------------+-----------+
| from_state | TEXT |
| from_population | BIGINT |
| from_area | TEXT |
| from_commit | TEXT |
| from_commit_date | DATETIME |
| to_state | TEXT |
| to_population | BIGINT |
| to_area | TEXT |
| to_commit | TEXT |
| to_commit_date | DATETIME |
| diff_type | TEXT |
+------------------+----------++---------------+-----------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-----------------+------+-----+---------+-------+
| table | text | NO | PRI | | |
| num_conflicts | bigint unsigned | NO | | | |
+---------------+-----------------+------+-----+---------+-------++-------+------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-----+---------+-------+
| a | int | NO | PRI | | |
| b | int | YES | | | |
+-------+------+------+-----+---------+-------+mydb> select * from dolt_conflicts_mytable;
+----------------------------------+--------+--------+-------+-------+---------------+---------+---------+-----------------+------------------------+
| from_root_ish | base_a | base_b | our_a | our_b | our_diff_type | their_a | their_b | their_diff_type | dolt_conflict_id |
+----------------------------------+--------+--------+-------+-------+---------------+---------+---------+-----------------+------------------------+
| gip4h957r8k07c9414lkp3sqe7rh9an6 | NULL | NULL | 3 | 3 | added | 3 | 1 | added | hWDLmYufTrm+eVjFSVzPWw |
| gip4h957r8k07c9414lkp3sqe7rh9an6 | NULL | NULL | 4 | 4 | added | 4 | 2 | added | gi2p1YbSwu8oUV/WRSpr3Q |
+----------------------------------+--------+--------+-------+-------+---------------+---------+---------+-----------------+------------------------+mydb> select dolt_conflict_id, base_a, base_b, our_a, our_b, their_a, their_b from dolt_conflicts_mytable;
+------------------------+--------+--------+-------+-------+---------+---------+
| dolt_conflict_id | base_a | base_b | our_a | our_b | their_a | their_b |
+------------------------+--------+--------+-------+-------+---------+---------+
| hWDLmYufTrm+eVjFSVzPWw | NULL | NULL | 3 | 3 | 3 | 1 |
| gi2p1YbSwu8oUV/WRSpr3Q | NULL | NULL | 4 | 4 | 4 | 2 |
+------------------------+--------+--------+-------+-------+---------+---------+mydb> delete from dolt_conflicts_mytable;mydb> replace into mytable (select their_a, their_b from dolt_conflicts_mytable);mydb> update dolt_conflicts_mytable set our_a = their_a, our_b = their_b;> SELECT table_name, description, base_schema, our_schema, their_schema FROM dolt_schema_conflicts;
+------------+--------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------+
| table_name | description | base_schema | our_schema | their_schema |
+------------+--------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------+
| people | different column definitions for our | CREATE TABLE `people` ( | CREATE TABLE `people` ( | CREATE TABLE `people` ( |
| | column age and their column age | `id` int NOT NULL, | `id` int NOT NULL, | `id` int NOT NULL, |
| | | `last_name` varchar(120), | `last_name` varchar(120), | `last_name` varchar(120), |
| | | `first_name` varchar(120), | `first_name` varchar(120), | `first_name` varchar(120), |
| | | `birthday` datetime(6), | `birthday` datetime(6), | `birthday` datetime(6), |
| | | `age` int DEFAULT '0', | `age` float, | `age` bigint, |
| | | PRIMARY KEY (`id`) | PRIMARY KEY (`id`) | PRIMARY KEY (`id`) |
| | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin; |
+------------+--------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------+-------------------------------------------------------------------+CREATE TABLE `dolt_merge_status` (
-- Whether a merge is currently active or not
`is_merging` tinyint NOT NULL,
-- The commit spec that was used to initiate the merge
`source` text,
-- The commit that the commit spec resolved to at the time of merge
`source_commit` text,
-- The target destination working set
`target` text,
-- A list of tables that have conflicts or constraint violations
`unmerged_tables` text
)dolt sql -q "CREATE TABLE t (a INT PRIMARY KEY, b INT);"
dolt add .
dolt commit -am "base"
dolt checkout -b right
dolt sql <<SQL
ALTER TABLE t ADD c INT;
INSERT INTO t VALUES (1, 2, 1);
SQL
dolt commit -am "right"
dolt checkout main
dolt sql -q "INSERT INTO t values (1, 3);"
dolt commit -am "left"
dolt merge right+------------+--------+----------------------------------+-----------------+-----------------+
| is_merging | source | source_commit | target | unmerged_tables |
+------------+--------+----------------------------------+-----------------+-----------------+
| true | right | fbghslue1k9cfgbi00ti4r8417frgbca | refs/heads/main | t |
+------------+--------+----------------------------------+-----------------+-----------------++----------------+------+------+-----+
| Field | Type | Null | Key |
+----------------+------+------+-----+
| name | text | NO | |
| stash_id | text | NO | |
| branch | text | NO | |
| hash | text | NO | |
| commit_message | text | NO | |
+----------------+------+------+-----+SELECT *
FROM dolt_stashes
WHERE name = 'myStash';+---------+------------+--------+----------------------------------+------------------+
| name | stash_id | branch | hash | commit_message |
+---------+------------+--------+----------------------------------+------------------+
| myStash | stash@{0} | main | pnpq4p07977jjbpkg6ojj2mpjp2kru9r | Created a table |
+---------+------------+--------+----------------------------------+------------------++------------+---------+------+-----+
| Field | Type | Null | Key |
+------------+---------+------+-----+
| table_name | text | NO | PRI |
| staged | tinyint | NO | PRI |
| status | text | NO | PRI |
+------------+---------+------+-----+SELECT *
FROM dolt_status
WHERE staged=false;+------------+--------+-----------+
| table_name | staged | status |
+------------+--------+-----------+
| one_pk | false | new table |
+------------+--------+-----------++------------+---------+------+-----+
| Field | Type | Null | Key |
+------------+---------+------+-----+
| table_name | text | NO | PRI |
| staged | tinyint | NO | PRI |
| status | text | NO | PRI |
| ignored | bool | NO | |
+------------+---------+------+-----+INSERT INTO dolt_ignore VALUES ("ignored_*", true);
SELECT *
FROM dolt_status_ignored
WHERE staged=false;+---------------+--------+-----------+---------+
| table_name | staged | status | ignored |
+---------------+--------+-----------+---------+
| ignored_table | false | new table | true |
+---------------+--------+-----------+---------++------------------+----------+
| field | type |
+------------------+----------+
| id | int |
| staged | bool |
| diff_type | varchar |
| to_x | ... |
| to_y | ... |
| from_x | ... |
| from_y | ... |
+------------------+----------+SELECT *
FROM dolt_workspace_mytable
WHERE staged=false+----+--------+-----------+-------+----------+---------+------------+
| id | staged | diff_type | to_id | to_value | from_id | from_value |
+----+--------+-----------+-------+----------+---------+------------+
| 0 | false | modified | 3 | 44 | 3 | 31 |
| 1 | false | modified | 4 | 68 | 4 | 1 |
| 2 | false | modified | 9 | 47 | 9 | 59 |
+----+--------+-----------+-------+----------+---------+------------+
3 rows in set (0.00 sec)UPDATE dolt_workspace_mytable SET staged = TRUE WHERE to_id = 3;
CALL dolt_commit("-m", "Added row id 3 in my table");+----------------+-----------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-----------------+------+-----+---------+-------+
| table | text | NO | PRI | | |
| num_violations | bigint unsigned | NO | | | |
+----------------+-----------------+------+-----+---------+-------++-------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| x | bigint | NO | PRI | | |
| y | varchar(1) | YES | | | |
+-------+------------+------+-----+---------+-------++----------------+------------------------------------------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+------------------------------------------------------------------+------+-----+---------+-------+
| from_root_ish | varchar(1023) | YES | | | |
| violation_type | enum('foreign key','unique index','check constraint','not null') | NO | PRI | | |
| x | bigint | NO | PRI | | |
| y | varchar(1) | YES | | | |
| violation_info | json | YES | | | |
+----------------+------------------------------------------------------------------+------+-----+---------+-------+{
"ForeignKey": "key_name",
"Table": "myTable",
"Columns": ["col1", "col2"],
"Index": "myIdx",
"OnDelete": "RESTRICT",
"OnUpdate": "RESTRICT",
"ReferencedColumns": ["col3", "col4"],
"ReferencedIndex": "myIdx2",
"ReferencedTable": "refTable"
}{
"Name": "constraint_name",
"Columns": ["col1", "col2"]
}{
"Columns": ["col1", "col2"]
}{
"Name": "constraint_name",
"Expression": "(col1 > 0)"
}+------------+---------+------+-----+
| Field | Type | Null | Key |
+------------+---------+------+-----+
| pattern | text | NO | PRI |
| ignored | tinyint | NO | |
+------------+---------+------+-----+INSERT INTO dolt_ignore VALUES ("generated_*", true), ("generated_exception", false);
CREATE TABLE foo (pk int);
CREATE TABLE generated_foo (pk int);
CREATE TABLE generated_exception (pk int);
CALL dolt_add("-A");
SELECT *
FROM dolt_status
WHERE staged=true;+---------------------+--------+-----------+
| table_name | staged | status |
+---------------------+--------+-----------+
| foo | true | new table |
| generated_exception | true | new table |
+---------------------+--------+-----------++----------------------+------+------+-----+
| Field | Type | Null | Key |
+----------------------+------+------+-----+
| table_name | text | NO | PRI |
| target_ref | text | YES | |
| ref_table | text | YES | |
| options | text | YES | |
+----------------------+------+------+-----+INSERT INTO dolt_nonlocal_tables (table_name, target_ref, options) VALUES ('global_*', 'global_branch', 'immediate');
INSERT INTO global_users VALUES ('timsehn'); -- Equivalent to INSERT INTO global_branch.global_users VALUES ('timsehn')
INSERT INTO dolt_nonlocal_tables (table_name, target_ref, ref_table, options) VALUES ('origin_products', 'origin/main', 'products', 'immediate');
SELECT * FROM origin_products; -- Equivalent to SELECT * FROM `origin/main`.global_branch.products+----------------------+------+------+-----+
| Field | Type | Null | Key |
+----------------------+------+------+-----+
| test_name | text | NO | PRI |
| test_group | text | YES | |
| test_query | text | NO | |
| assertion_type | text | NO | |
| assertion_comparator | text | NO | |
| assertion_value | text | NO | |
+----------------------+------+------+-----+INSERT INTO dolt_tests VALUES
('check_user_count', 'users', 'SELECT * FROM users', 'expected_rows', '==', '10');INSERT INTO dolt_tests VALUES
('total_revenue', 'finance', 'SELECT SUM(amount) FROM sales', 'expected_single_value', '>=', '100000');+----------------+---------------------------------------------------+
| Field | Type |
+----------------+---------------------------------------------------+
| rebase_order | DECIMAL(6,2) |
| action | ENUM('pick', 'drop', 'reword', 'squash', 'fixup') |
| commit_hash | TEXT |
| commit_message | TEXT |
+----------------+---------------------------------------------------+update dolt_rebase set action = 'squash' where rebase_order > 1;update dolt_rebase set action = 'reword', commit_message = 'here is my new message' where commit_hash = '123aef456f';update dolt_rebase set action = 'drop' where rebase_order = 2;delete from dolt_rebase where rebase_order = 2;DOLT_ADD()DOLT_BACKUP()DOLT_BRANCH()DOLT_CHECKOUT()DOLT_CHERRY_PICK()DOLT_CLEAN()DOLT_CLONE()DOLT_COMMIT()DOLT_CONFLICTS_RESOLVE()DOLT_FETCH()DOLT_GC()DOLT_MERGE()DOLT_PULL()DOLT_PURGE_DROPPED_DATABASES()DOLT_PUSH()DOLT_REBASE()DOLT_REMOTE()DOLT_RESET()DOLT_REVERT()DOLT_RM()DOLT_STASH()DOLT_TAG()DOLT_UNDROP()DOLT_UPDATE_COLUMN_TAG()DOLT_VERIFY_CONSTRAINTS()dolt_stats_restart()dolt_stats_stop()dolt_stats_purge()dolt_stats_once():dolt_stats_wait():dolt_stats_gc():dolt_stats_flush():dolt_stats_info():dolt_reset()CALL DOLT_CHECKOUT('-b', 'feature-branch');CALL DOLT_ADD('-A');
CALL DOLT_ADD('.');
CALL DOLT_ADD('table1', 'table2');+--------+------+---------------------------+
| Field | Type | Description |
+--------+------+---------------------------+
| status | int | 0 if successful, 1 if not |
+--------+------+---------------------------+-- Set the current database for the session
USE mydb;
-- Make modifications
UPDATE table
SET column = "new value"
WHERE pk = "key";
-- Stage all changes.
CALL DOLT_ADD('-A');
-- Commit the changes.
CALL DOLT_COMMIT('-m', 'committing all changes');+--------+------+---------------------------+
| Field | Type | Description |
+--------+------+---------------------------+
| status | int | 0 if successful, 1 if not |
+--------+------+---------------------------+CALL DOLT_BACKUP('sync', 'name');CALL DOLT_BACKUP('sync-url', 'https://dolthub.com/some_organization/some_dolthub_repository');CALL DOLT_BACKUP('add', 'dolthub', 'https://dolthub.com/some_organization/some_dolthub_repository');
CALL DOLT_BACKUP('remove', 'dolthub');CALL DOLT_BACKUP('restore', 'https://dolthub.com/some_organization/some_dolthub_repository', 'database_name');-- Set the current database for the session
USE mydb;
-- Configure a backup to sync to.
CALL dolt_backup('add', 'my-backup', 'https://dolthub.com/some_organization/some_dolthub_repository');
-- Upload the current database contents to that named backup
CALL dolt_backup('sync', 'my-backup')
-- Restore the uploaded database to a new database name
CALL dolt_backup('restore', 'https://dolthub.com/some_organization/some_dolthub_repository', 'mydb_restored');-- Create a new branch from the current HEAD
CALL DOLT_BRANCH('myNewBranch');
-- Create a new branch from start point of tip of feature1 branch.
CALL DOLT_BRANCH('myNewBranch', 'feature1');
-- Create a new branch by copying an existing branch
-- Will fail if feature1 branch already exists
CALL DOLT_BRANCH('-c', 'main', 'feature1');
-- Create or replace a branch by copying an existing branch
-- '-f' forces the copy, even if feature1 branch already exists
CALL DOLT_BRANCH('-c', '-f', 'main', 'feature1');
-- Delete a branch
CALL DOLT_BRANCH('-d', 'branchToDelete');
-- Rename a branch
CALL DOLT_BRANCH('-m', 'currentBranchName', 'newBranchName')+--------+------+---------------------------+
| Field | Type | Description |
+--------+------+---------------------------+
| status | int | 0 if successful, 1 if not |
+--------+------+---------------------------+-- List the available branches
SELECT * FROM DOLT_BRANCHES;
+--------+----------------------------------+
| name | hash |
+--------+----------------------------------+
| backup | nsqtc86d54kafkuf0a24s4hqircvg68g |
| main | dvtsgnlg7n9squriob3nq6kve6gnhkf2 |
+--------+----------------------------------+
-- Create a new branch for development work from the tip of head and switch to it
CALL DOLT_BRANCH('myNewFeature');
CALL DOLT_CHECKOUT('myNewFeature');
-- View your current branch
select active_branch();
+----------------+
| active_branch |
+----------------+
| myNewFeature |
+----------------+
-- Create a new branch from an existing branch
CALL DOLT_BRANCH('-c', 'backup', 'bugfix-3482');
-- Rename a branch
CALL DOLT_BRANCH('-m', 'bugfix-3482', 'critical-bugfix-3482');
-- Delete a branch
CALL DOLT_BRANCH('-d', 'old-unused-branch');CALL DOLT_CHECKOUT('-b', 'my-new-branch');
CALL DOLT_CHECKOUT('my-existing-branch');
CALL DOLT_CHECKOUT('my-table');set autocommit = on;
use mydb/branch1; -- current db is now `mydb/branch1`
insert into t1 values (1); -- modifying the `branch1` branch
call dolt_checkout('branch2'); -- current db is now `mydb`
insert into t1 values (2); -- modifying the `branch2` branch
use mydb/branch3; -- current db is now `mydb/branch3`
insert into mydb.t1 values (3); -- modifying the `branch2` branch+---------+------+-----------------------------+
| Field | Type | Description |
+---------+------+-----------------------------+
| status | int | 0 if successful, 1 if not |
| message | text | success/failure information |
+---------+------+-----------------------------+-- Set the current database for the session
USE mydb;
-- Create and checkout to a new branch.
CALL DOLT_CHECKOUT('-b', 'feature-branch');
-- Make modifications
UPDATE table
SET column = "new value"
WHERE pk = "key";
-- Stage and commit all changes.
CALL DOLT_COMMIT('-a', '-m', 'committing all changes');
-- Go back to main
CALL DOLT_CHECKOUT('main');CALL DOLT_CHERRY_PICK('my-existing-branch~2');
CALL DOLT_CHERRY_PICK('qj6ouhjvtrnp1rgbvajaohmthoru2772');+-----------------------+------+---------------------------------+
| Field | Type | Description |
+-----------------------+------+---------------------------------+
| hash | text | hash of the applied commit |
| data_conflicts | int | number of data conflicts |
| schema_conflicts | int | number of schema conflicts |
| constraint_violations | int | number of constraint violations |
+-----------------------+------+---------------------------------+-- Checkout main branch
CALL DOLT_CHECKOUT('main');
-- View a log of commits
SELECT commit_hash, message FROM dolt_log;
+----------------------------------+----------------------------+
| commit_hash | message |
+----------------------------------+----------------------------+
| 7e2q0hibo2m2af874i4e7isgnum74j4m | create a new table |
| omuqq67att6vfnka94drdallu4983gnr | Initialize data repository |
+----------------------------------+----------------------------+
2 rows in set (0.00 sec)
-- View the table
SELECT * FROM mytable;
Empty set (0.00 sec)
-- Checkout new branch
CALL DOLT_CHECKOUT('mybranch');
-- View a log of commits
SELECT commit_hash, message FROM dolt_log;
+----------------------------------+----------------------------+
| commit_hash | message |
+----------------------------------+----------------------------+
| 577isdjbq1951k2q4dqhli06jlauo51p | add 3, 4, 5 to the table |
| k318tpmqn4l97ofpaerato9c3m70lc14 | add 1, 2 to the table |
| 7e2q0hibo2m2af874i4e7isgnum74j4m | create a new table |
| omuqq67att6vfnka94drdallu4983gnr | Initialize data repository |
+----------------------------------+----------------------------+
4 rows in set (0.00 sec)
-- View the table
SELECT * FROM mytable;
+---+
| a |
+---+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
+---+
5 rows in set (0.00 sec)-- Checkout main branch
CALL DOLT_CHECKOUT('main');
-- Cherry-pick the commit
CALL DOLT_CHERRY_PICK('k318tpmqn4l97ofpaerato9c3m70lc14');
+----------------------------------+
| hash |
+----------------------------------+
| mh518gdgbsut8m705b7b5rie9neq9uaj |
+----------------------------------+
1 row in set (0.02 sec)
mydb> SELECT * FROM mytable;
+---+
| a |
+---+
| 1 |
| 2 |
+---+
2 rows in set (0.00 sec)
mydb> SELECT commit_hash, message FROM dolt_log;
+----------------------------------+----------------------------+
| commit_hash | message |
+----------------------------------+----------------------------+
| mh518gdgbsut8m705b7b5rie9neq9uaj | add 1, 2 to the table |
| 7e2q0hibo2m2af874i4e7isgnum74j4m | create a new table |
| omuqq67att6vfnka94drdallu4983gnr | Initialize data repository |
+----------------------------------+----------------------------+
3 rows in set (0.00 sec)CALL DOLT_CLEAN();
CALL DOLT_CLEAN('untracked-table');
CALL DOLT_CLEAN('--dry-run');+--------+------+---------------------------+
| Field | Type | Description |
+--------+------+---------------------------+
| status | int | 0 if successful, 1 if not |
+--------+------+---------------------------+-- Create three new tables
create table tracked (x int primary key);
create table committed (x int primary key);
create table untracked (x int primary key);
-- Commit the first table
call dolt_add('committed');
call dolt_commit('-m', 'commit a table');
+----------------------------------+
| hash |
+----------------------------------+
| n7gle7jv6aqf72stbdicees6iduhuoo9 |
+----------------------------------+
-- Track the second table
call dolt_add('tracked');
-- Observe database status
select * from dolt_status;
+------------+--------+-----------+
| table_name | staged | status |
+------------+--------+-----------+
| tracked | true | new table |
| untracked | false | new table |
+------------+--------+-----------+
-- Clear untracked tables
call dolt_clean('untracked');
-- Observe final status
select * from dolt_status;
+------------+--------+-----------+
| table_name | staged | status |
+------------+--------+-----------+
| tracked | true | new table |
+------------+--------+-----------+
-- Committed and tracked tables are preserved
show tables;
+----------------+
| Tables_in_tmp3 |
+----------------+
| committed |
| tracked |
+----------------+CALL DOLT_CLONE('file:///myDatabasesDir/database/.dolt/noms');
CALL DOLT_CLONE('dolthub/us-jails', 'myCustomDbName');+--------+------+---------------------------+
| Field | Type | Description |
+--------+------+---------------------------+
| status | int | 0 if successful, 1 if not |
+--------+------+---------------------------+-- Clone the dolthub/us-jails database from DoltHub using the <org>/<database> notation.
CALL DOLT_CLONE('dolthub/us-jails');
-- Use the new, cloned database
-- NOTE: backticks are required for database names with hyphens
USE `us-jails`;
SHOW TABLES;
+-----------------------------+
| Tables_in_us-jails |
+-----------------------------+
| incidents |
| inmate_population_snapshots |
| jails |
+-----------------------------+
-- Clone the dolthub/museum-collections database, this time using a doltremoteapi URL, cloning
-- only a single branch, customizing the remote name, and providing a custom database name.
CALL DOLT_CLONE('-branch', 'prod', '-remote', 'dolthub',
'https://doltremoteapi.dolthub.com/dolthub/ge-taxi-demo', 'taxis');
-- Verify that only the prod branch was cloned
USE taxis;
SELECT * FROM DOLT_BRANCHES;
+------+----------------------------------+------------------+------------------------+-------------------------+------------------------------+
| name | hash | latest_committer | latest_committer_email | latest_commit_date | latest_commit_message |
+------+----------------------------------+------------------+------------------------+-------------------------+------------------------------+
| prod | 1s61u4rbbd26u0tlpdhb46cuejd1dogj | oscarbatori | [email protected] | 2021-06-14 17:52:58.702 | Added first cut of trip data |
+------+----------------------------------+------------------+------------------------+-------------------------+------------------------------+
-- Verify that the default remote for this new, cloned database is named "dolthub" (not "origin")
SELECT * FROM DOLT_REMOTES;
+---------+--------------------------------------------------------+-----------------------------------------+--------+
| name | url | fetch_specs | params |
+---------+--------------------------------------------------------+-----------------------------------------+--------+
| dolthub | https://doltremoteapi.dolthub.com/dolthub/ge-taxi-demo | ["refs/heads/*:refs/remotes/dolthub/*"] | {} |
+---------+--------------------------------------------------------+-----------------------------------------+--------+
CALL DOLT_COMMIT('-a', '-m', 'This is a commit');
CALL DOLT_COMMIT('-m', 'This is a commit');
CALL DOLT_COMMIT('-m', 'This is a commit', '--author', 'John Doe <[email protected]>');+-------+------+----------------------------+
| Field | Type | Description |
+-------+------+----------------------------+
| hash | text | hash of the commit created |
+-------+------+----------------------------+-- Set the current database for the session
USE mydb;
-- Make modifications
UPDATE table
SET column = "new value"
WHERE pk = "key";
-- Stage all changes and commit.
CALL DOLT_COMMIT('-a', '-m', 'This is a commit', '--author', 'John Doe <[email protected]>');CALL DOLT_CONFLICTS_RESOLVE('--ours', <table>);
CALL DOLT_CONFLICTS_RESOLVE('--theirs', <table>);+--------+------+---------------------------+
| Field | Type | Description |
+--------+------+---------------------------+
| status | int | 0 if successful, 1 if not |
+--------+------+---------------------------+-- Set the current database for the session
USE mydb;
-- Attempt merge
CALL DOLT_MERGE('feature-branch');
-- Check for conflicts
SELECT * FROM dolt_conflicts;
-- Resolve conflicts for tables t1 and t2 with rows from our branch.
CALL DOLT_CONFLICTS_RESOLVE('--ours', 't1', 't2');CALL DOLT_FETCH('origin', 'main');
CALL DOLT_FETCH('origin', 'feature-branch');
CALL DOLT_FETCH('origin', 'refs/heads/main:refs/remotes/origin/main');
CALL DOLT_FETCH('origin', NULL);
CALL DOLT_FETCH('origin');+--------+------+---------------------------+
| Field | Type | Description |
+--------+------+---------------------------+
| status | int | 0 if successful, 1 if not |
+--------+------+---------------------------+-- Get remote main
CALL DOLT_FETCH('origin', 'main');
-- Inspect the hash of the fetched remote branch
SELECT HASHOF('origin/main');
-- Merge remote main with current branch
CALL DOLT_MERGE('origin/main');CALL DOLT_GC();
CALL DOLT_GC('--shallow');+--------+------+---------------------------+
| Field | Type | Description |
+--------+------+---------------------------+
| status | int | 0 if successful, 1 if not |
+--------+------+---------------------------+ERROR 1105 (HY000): this connection was established when this server performed an online
garbage collection. this connection can no longer be used. please reconnect.CALL DOLT_MERGE('feature-branch'); -- Optional --squash parameter
CALL DOLT_MERGE('feature-branch', '--no-ff', '-m', 'This is a msg for a non fast forward merge');
CALL DOLT_MERGE('--abort');+--------------+------+--------------------------------------+
| Field | Type | Description |
+--------------+------+--------------------------------------+
| hash | text | hash of the merge commit |
| fast_forward | int | whether the merge was a fast forward |
| conflicts | int | number of conflicts created |
| message | text | optional informational message |
+--------------+------+--------------------------------------+-- Set the current database for the session
USE mydb;
-- Create and checkout to a new branch.
CALL DOLT_CHECKOUT('-b', 'feature-branch');
-- Make modifications
UPDATE table
SET column = "new value"
WHERE pk = "key";
-- Stage and commit all changes.
CALL DOLT_COMMIT('-a', '-m', 'committing all changes');
-- Go back to main
CALL DOLT_MERGE('feature-branch', '--author', 'John Doe <[email protected]>');CALL DOLT_PULL('origin');
CALL DOLT_PULL('origin', 'some-branch');
CALL DOLT_PULL('feature-branch', '--force');+--------------+------+-------------------------------------+
| Field | Type | Description |
+--------------+------+-------------------------------------+
| fast_forward | int | whether the pull was a fast forward |
| conflicts | int | number of conflicts created |
| message | text | optional informational message |
+--------------+------+-------------------------------------+-- Update local working set with remote changes
-- Note: this requires upstream tracking information to be set in order for
-- Dolt to know what remote branch to merge
CALL DOLT_PULL('origin');
-- Update local working set with remote changes from an explicit branch
CALL DOLT_PULL('origin', 'some-branch');
-- View a log of new commits
SELECT * FROM dolt_log LIMIT 5;-- Create a database and populate a table in the working set
CREATE DATABASE database1;
use database1;
create table t(pk int primary key);
-- Dropping the database will move it to a temporary holding area
DROP DATABASE database1;
-- At this point, the database can be restored by calling dolt_undrop('database1'), but
-- instead, we permanently delete it by calling dolt_purge_dropped_databases().
CALL dolt_purge_dropped_databases(); CALL DOLT_PUSH('origin', 'main');
CALL DOLT_PUSH('--force', 'origin', 'main');+---------+------+--------------------------------+
| Field | Type | Description |
+---------+------+--------------------------------+
| status | int | 0 if successful, 1 if not |
| message | text | optional informational message |
+---------+------+--------------------------------+-- Checkout new branch
CALL DOLT_CHECKOUT('-b', 'feature-branch');
-- Add a table
CREATE TABLE test (a int primary key);
-- Create commit
CALL DOLT_COMMIT('-a', '-m', 'create table test');
-- Push to remote
CALL DOLT_PUSH('origin', 'feature-branch');A → B → C → D → E → F main
↘
G → H → I featureA → B → C → D → E → F main
↘
G' → H' → I' featureCALL DOLT_REBASE('--interactive', 'main');
CALL DOLT_REBASE('-i', 'main');
CALL DOLT_REBASE('-i', '--empty=keep', 'main');
CALL DOLT_REBASE('--continue');
CALL DOLT_REBASE('--abort');+---------+------+-----------------------------+
| Field | Type | Description |
+---------+------+-----------------------------+
| status | int | 0 if successful, 1 if not |
| message | text | success/failure information |
+---------+------+-----------------------------+-- create a simple table
create table t (pk int primary key);
call dolt_commit('-Am', 'creating table t');
-- create a new branch that we'll add more commits to later
call dolt_branch('branch1');
-- create another commit on the main branch, right after where branch1 branched off
insert into t values (0);
call dolt_commit('-am', 'inserting row 0');
-- switch to branch1 and create three more commits that each insert one row
call dolt_checkout('branch1');
insert into t values (1);
call dolt_commit('-am', 'inserting row 1');
insert into t values (2);
call dolt_commit('-am', 'inserting row 2');
insert into t values (3);
call dolt_commit('-am', 'inserting row 3');
-- check out what our commit history on branch1 looks like before we rebase
select commit_hash, message from dolt_log;
+----------------------------------+----------------------------+
| commit_hash | message |
+----------------------------------+----------------------------+
| tsq01op7b48ij6dfa2tst60vbfm9rcus | inserting row 3 |
| uou7dibe86e9939pu8fdtjdce5pt7v1c | inserting row 2 |
| 3umkjmqeeep5ho7nn0iggfinajoo1l6q | inserting row 1 |
| 35gfll6o322aq9uffdqin1dqmq7q3vek | creating table t |
| do1tp9u39vsja3c8umshv9p6fernr0lt | Inіtіalizе dаta repоsitоry |
+----------------------------------+----------------------------+
-- start an interactive rebase and check out the default rebase plan; this will rebase
-- all the new commits on this branch and move them to the tip of the main branch
call dolt_rebase('-i', 'main');
select * from dolt_rebase order by rebase_order;
+--------------+--------+----------------------------------+-----------------+
| rebase_order | action | commit_hash | commit_message |
+--------------+--------+----------------------------------+-----------------+
| 1.00 | pick | 3umkjmqeeep5ho7nn0iggfinajoo1l6q | inserting row 1 |
| 2.00 | pick | uou7dibe86e9939pu8fdtjdce5pt7v1c | inserting row 2 |
| 3.00 | pick | tsq01op7b48ij6dfa2tst60vbfm9rcus | inserting row 3 |
+--------------+--------+----------------------------------+-----------------+
-- adjust the rebase plan to reword the first commit, drop the commit that inserted row 2,
-- and combine the third commit into the previous commit
update dolt_rebase set action='reword', commit_message='insert rows' where rebase_order=1;
update dolt_rebase set action='drop' where rebase_order=2;
update dolt_rebase set action='fixup' where rebase_order=3;
-- continue rebasing now that we've adjusted the rebase plan
call dolt_rebase('--continue');
-- check out the history
select commit_hash, message from dolt_log;
+----------------------------------+----------------------------+
| commit_hash | message |
+----------------------------------+----------------------------+
| 8jc1dpj25fv6f2kn3bd47uokc8hs1vp0 | insert rows |
| hb9fnqnrsd5ghq3fgag0kiq6nvpsasvo | inserting row 0 |
| 35gfll6o322aq9uffdqin1dqmq7q3vek | creating table t |
| do1tp9u39vsja3c8umshv9p6fernr0lt | Inіtіalizе dаta repоsitоry |
+----------------------------------+----------------------------+CALL DOLT_REMOTE('add','remote_name','remote_url');
CALL DOLT_REMOTE('remove','existing_remote_name');+--------+------+---------------------------+
| Field | Type | Description |
+--------+------+---------------------------+
| status | int | 0 if successful, 1 if not |
+--------+------+---------------------------+-- Add a HTTP remote
CALL DOLT_REMOTE('add','origin','https://doltremoteapi.dolthub.com/Dolthub/museum-collections');
-- Add a HTTP remote with shorthand notation for the URL
CALL DOLT_REMOTE('add','origin1','Dolthub/museum-collections');
-- Add a filesystem based remote
CALL DOLT_REMOTE('add','origin2','file:///Users/jennifer/datasets/museum-collections');
-- List remotes to check.
SELECT * FROM dolt_remotes;
+---------+--------------------------------------------------------------+-----------------------------------------+--------+
| name | url | fetch_specs | params |
+---------+--------------------------------------------------------------+-----------------------------------------+--------+
| origin | https://doltremoteapi.dolthub.com/Dolthub/museum-collections | ["refs/heads/*:refs/remotes/origin/*"] | {} |
| origin1 | https://doltremoteapi.dolthub.com/Dolthub/museum-collections | ["refs/heads/*:refs/remotes/origin1/*"] | {} |
| origin2 | file:///Users/jennifer/datasets/museum-collections | ["refs/heads/*:refs/remotes/origin2/*"] | {} |
+---------+--------------------------------------------------------------+-----------------------------------------+--------+
-- Remove a remote
CALL DOLT_REMOTE('remove','origin1');
-- List remotes to check.
SELECT * FROM dolt_remotes;
+---------+--------------------------------------------------------------+-----------------------------------------+--------+
| name | url | fetch_specs | params |
+---------+--------------------------------------------------------------+-----------------------------------------+--------+
| origin | https://doltremoteapi.dolthub.com/Dolthub/museum-collections | ["refs/heads/*:refs/remotes/origin/*"] | {} |
| origin2 | file:///Users/jennifer/datasets/museum-collections | ["refs/heads/*:refs/remotes/origin2/*"] | {} |
+---------+--------------------------------------------------------------+-----------------------------------------+--------+CALL DOLT_RESET('--hard', 'featureBranch');
CALL DOLT_RESET('--hard', 'commitHash123abc');
CALL DOLT_RESET('myTable'); -- soft reset+--------+------+---------------------------+
| Field | Type | Description |
+--------+------+---------------------------+
| status | int | 0 if successful, 1 if not |
+--------+------+---------------------------+-- Set the current database for the session
USE mydb;
-- Make modifications
UPDATE table
SET column = "new value"
WHERE pk = "key";
-- Reset the changes permanently.
CALL DOLT_RESET('--hard');
-- Makes some more changes.
UPDATE table
SET column = "new value"
WHERE pk = "key";
-- Stage the table.
CALL DOLT_ADD('table')
-- Unstage the table.
CALL DOLT_RESET('table')CALL DOLT_REVERT('gtfv1qhr5le61njimcbses9oom0de41e');
CALL DOLT_REVERT('HEAD~2');
CALL DOLT_REVERT('HEAD', '[email protected]');+--------+------+---------------------------+
| Field | Type | Description |
+--------+------+---------------------------+
| status | int | 0 if successful, 1 if not |
+--------+------+---------------------------+-- Create a table and add data in multiple commits
CREATE TABLE t1(pk INT PRIMARY KEY, c VARCHAR(255));
CALL dolt_add("t1")
CALL dolt_commit("-m", "Creating table t1");
INSERT INTO t1 VALUES(1, "a"), (2, "b"), (3, "c");
CALL dolt_commit("-am", "Adding some data");
insert into t1 VALUES(10, "aa"), (20, "bb"), (30, "cc");
CALL dolt_commit("-am", "Adding some more data");
-- Examine the changes made in the commit immediately before the current HEAD commit
SELECT to_pk, to_c, to_commit, diff_type FROM dolt_diff_t1 WHERE to_commit=hashof("HEAD~1");
+-------+------+----------------------------------+-----------+
| to_pk | to_c | to_commit | diff_type |
+-------+------+----------------------------------+-----------+
| 1 | a | fc4fks6jutcnee9ka6458nmuot7rl1r2 | added |
| 2 | b | fc4fks6jutcnee9ka6458nmuot7rl1r2 | added |
| 3 | c | fc4fks6jutcnee9ka6458nmuot7rl1r2 | added |
+-------+------+----------------------------------+-----------+
-- Revert the commit immediately before the current HEAD commit
CALL dolt_revert("HEAD~1");
-- Check out the new commit created by dolt_revert
SELECT commit_hash, message FROM dolt_log limit 1;
+----------------------------------+---------------------------+
| commit_hash | message |
+----------------------------------+---------------------------+
| vbevrdghj3in3napcgdsch0mq7f8en4v | Revert "Adding some data" |
+----------------------------------+---------------------------+
-- View the exact changes made by the revert commit
SELECT from_pk, from_c, to_commit, diff_type FROM dolt_diff_t1 WHERE to_commit=hashof("HEAD");
+---------+--------+----------------------------------+-----------+
| from_pk | from_c | to_commit | diff_type |
+---------+--------+----------------------------------+-----------+
| 1 | a | vbevrdghj3in3napcgdsch0mq7f8en4v | removed |
| 2 | b | vbevrdghj3in3napcgdsch0mq7f8en4v | removed |
| 3 | c | vbevrdghj3in3napcgdsch0mq7f8en4v | removed |
+---------+--------+----------------------------------+-----------+CALL DOLT_RM('table1');
CALL DOLT_RM('table1', 'table2', 'table3');
CALL DOLT_RM('--cached', 'table1');+--------+------+---------------------------+
| Field | Type | Description |
+--------+------+---------------------------+
| status | int | 0 if successful, 1 if not |
+--------+------+---------------------------+-- Create and modify a table, then stage it
CREATE TABLE t1 (id INT PRIMARY KEY, name VARCHAR(50));
INSERT INTO t1 VALUES (1, 'test');
CALL DOLT_ADD('t1');
-- Remove the table from staging area only, but keep the working copy
CALL DOLT_RM('--cached', 't1');
--Examine the state of the working directory
SELECT * FROM DOLT_STATUS;
+------------+--------+-----------+
| table_name | staged | status |
+------------+--------+-----------+
| t1 | false | new table |
+------------+--------+-----------+
-- Stage the table again
CALL DOLT_ADD('t1');
-- Remove the table completely (from both staging and working directory)
CALL DOLT_RM('t1');
--Examine the state of the working directory
SELECT * FROM DOLT_STATUS;
Empty set (0.00 sec)CALL DOLT_STASH('push', 'stash_name');
CALL DOLT_STASH('push', 'stash_name', '--include-untracked');
CALL DOLT_STASH('push', 'stash_name', '--all');CALL DOLT_STASH('pop', 'stash_name');
CALL DOLT_STASH('pop', 'stash_name', 'stash@{0}');CALL DOLT_STASH('drop', 'stash_name');
CALL DOLT_STASH('drop', 'stash_name', 'stash@{0}');CALL DOLT_STASH('clear', 'stash_name');-- Create a table and make some changes
CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(100));
INSERT INTO employees VALUES (1, 'Alice'), (2, 'Bob');
CALL DOLT_ADD('.');
-- Stash the changes
CALL DOLT_STASH('push', 'stash1');
-- Working directory is now clean
SELECT * FROM employees;
Empty set (0.00 sec)
-- View stashes
SELECT * FROM dolt_stashes;
+--------+----------+--------+----------------------------------+-------------------------------------+
| name | stash_id | branch | hash | commit_message |
+--------+----------+--------+----------------------------------+-------------------------------------+
| stash1 | stash@{0}| main | abc123def456789... | Initialized Data Repository |
+--------+----------+--------+----------------------------------+-------------------------------------+
-- Restore the changes
CALL DOLT_STASH('pop', 'stash1');
-- Changes are restored
SELECT * FROM employees;
+----+-------+
| id | name |
+----+-------+
| 1 | Alice |
| 2 | Bob |
+----+-------+CALL DOLT_TAG('tag_name', 'commit_ref');
CALL DOLT_TAG('-m', 'message', 'tag_name', 'commit_ref');
CALL DOLT_TAG('-m', 'message', '--author', 'John Doe <[email protected]>', 'tag_name', 'commit_ref');
CALL DOLT_TAG('-d', 'tag_name');+--------+------+---------------------------+
| Field | Type | Description |
+--------+------+---------------------------+
| status | int | 0 if successful, 1 if not |
+--------+------+---------------------------+-- Set the current database for the session
USE mydb;
-- Make modifications
UPDATE table
SET column = "new value"
WHERE pk = "key";
-- Stage and commit all changes.
CALL DOLT_COMMIT('-am', 'committing all changes');
-- Create a tag for the HEAD commit.
CALL DOLT_TAG('v1','head','-m','creating v1 tag');CALL DOLT_UNDROP(<database_name>);-- Create a database and populate a table in the working set
CREATE DATABASE database1;
use database1;
create table t(pk int primary key);
-- Dropping the database will move it to a temporary holding area
DROP DATABASE database1;
-- calling dolt_undrop() with no arguments will return an error message that
-- lists the dropped database that are available to be restored
CALL dolt_undrop();
-- Use dolt_undrop() to restore it
CALL dolt_undrop('database1');
SELECT * FROM database1.t;+--------+------+---------------------------+
| Field | Type | Description |
+--------+------+---------------------------+
| status | int | 0 if successful, 1 if not |
+--------+------+---------------------------+CALL dolt_update_column_tag('myTable', 'col1', 42);
CALL dolt_commit('-am', 'updating myTable.col1 tag');+------------+------+-----------------------------------------+
| Field | Type | Description |
+------------+------+-----------------------------------------+
| violations | int | 1 if violations were found, otherwise 0 |
+------------+------+-----------------------------------------+CREATE TABLE parent (
pk int PRIMARY KEY
);
CREATE TABLE child (
pk int PRIMARY KEY,
parent_fk int,
FOREIGN KEY (parent_fk) REFERENCES parent(pk)
);-- enable dolt_force_transaction_commit so that we can inspect the
-- violation in our working set
SET dolt_force_transaction_commit = ON;
SET FOREIGN_KEY_CHECKS = OFF;
INSERT INTO PARENT VALUES (1);
-- Violates child's foreign key constraint
INSERT INTO CHILD VALUES (1, -1);
CALL DOLT_VERIFY_CONSTRAINTS();
/*
+------------+
| violations |
+------------+
| 1 |
+------------+
*/
SELECT * from dolt_constraint_violations;
/*
+-------+----------------+
| table | num_violations |
+-------+----------------+
| child | 1 |
+-------+----------------+
*/
SELECT violation_type, pk, parent_fk from dolt_constraint_violations_child;
/*
+----------------+----+-----------+
| violation_type | pk | parent_fk |
+----------------+----+-----------+
| foreign key | 1 | -1 |
+----------------+----+-----------+
*/SET DOLT_FORCE_TRANSACTION_COMMIT = ON;
SET FOREIGN_KEY_CHECKS = OFF;
INSERT INTO PARENT VALUES (1);
INSERT INTO CHILD VALUES (1, -1);
CALL DOLT_COMMIT('-am', 'violating rows');
CALL DOLT_VERIFY_CONSTRAINTS();
/*
No violations are returned since there are no changes in the working set.
+------------+
| violations |
+------------+
| 0 |
+------------+
*/
SELECT * from dolt_constraints_violations_child;
/*
+----------------+----+-----------+----------------+
| violation_type | pk | parent_fk | violation_info |
+----------------+----+-----------+----------------+
+----------------+----+-----------+----------------+
*/
CALL DOLT_VERIFY_CONSTRAINTS('--all');
/*
When all rows are considered, constraint violations are found.
+------------+
| violations |
+------------+
| 1 |
+------------+
*/
SELECT * from dolt_constraint_violations_child;
/*
+----------------+----+-----------+
| violation_type | pk | parent_fk |
+----------------+----+-----------+
| foreign key | 1 | -1 |
+----------------+----+-----------+
*/SET DOLT_FORCE_TRANSACTION_COMMIT = ON;
SET FOREIGN_KEY_CHECKS = OFF;
INSERT INTO PARENT VALUES (1);
INSERT INTO CHILD VALUES (1, -1);
CALL DOLT_VERIFY_CONSTRAINTS('parent');
/*
+------------+
| violations |
+------------+
| 0 |
+------------+
*/
CALL DOLT_VERIFY_CONSTRAINTS('child');
/*
+------------+
| violations |
+------------+
| 1 |
+------------+
*/
SELECT * from dolt_constraint_violations_child;
/*
+----------------+----+-----------+
| violation_type | pk | parent_fk |
+----------------+----+-----------+
| foreign key | 1 | -1 |
+----------------+----+-----------+
*/> call dolt_stats_info('--short');
{""dbCnt":1,"active":false,"storageBucketCnt":2,"cachedBucketCnt":2,"cachedBoundCnt":2,"cachedTemplateCnt":4,"statCnt":2,"backing":""repo2""}mydb> GRANT EXECUTE ON mydb.* TO pat@localhostmydb> GRANT EXECUTE ON PROCEDURE mydb.dolt_commit TO pat@localhostmydb> REVOKE EXECUTE ON PROCEDURE mydb.dolt_commit FROM pat@localhost
mydb> REVOKE EXECUTE ON mydb.* FROM pat@localhostdatabase> GRANT EXECUTE ON PROCEDURE mydb.dolt_gc TO service_account@localhostdolt adddolt backupdolt blamedolt branchdolt checkoutdolt cherry-pickdolt ci destroydolt ci exportdolt ci importdolt ci initdolt ci lsdolt ci removedolt ci rundolt ci viewdolt cleandolt clonedolt commitdolt configdolt conflicts catdolt conflicts resolvedolt constraints verifydolt creds checkdolt creds importdolt creds lsdolt creds newdolt creds rmdolt creds usedolt debugdolt diffdolt docs diffdolt docs printdolt docs uploaddolt dumpdolt fetchdolt filter-branchdolt fsckdolt gcdolt initdolt logdolt logindolt lsdolt mergedolt merge-basedolt profiledolt pulldolt pushdolt query-diffdolt read-tablesdolt rebasedolt reflogdolt remotedolt resetdolt revertdolt rmdolt schema exportdolt schema importdolt schema showdolt schema tagsdolt schema update-tagdolt showdolt sqldolt sql-serverdolt stashdolt statusdolt table cpdolt table exportdolt table importdolt table mvdolt table rmdolt tagdolt version$ dolt
Valid commands for dolt are
init - Create an empty Dolt data repository.
status - Show the working tree status.
add - Add table changes to the list of staged table changes.
diff - Diff a table.
reset - Remove table changes from the list of staged table changes.
clean - Remove untracked tables from working set.
commit - Record changes to the repository.
sql - Run a SQL query against tables in repository.
sql-server - Start a MySQL-compatible server.
log - Show commit logs.
show - Show information about a specific commit.
branch - Create, list, edit, delete branches.
checkout - Checkout a branch or overwrite a table from HEAD.
merge - Merge a branch.
conflicts - Commands for viewing and resolving merge conflicts.
cherry-pick - Apply the changes introduced by an existing commit.
revert - Undo the changes introduced in a commit.
clone - Clone from a remote data repository.
fetch - Update the database from a remote data repository.
pull - Fetch from a dolt remote data repository and merge.
push - Push to a dolt remote.
config - Dolt configuration.
remote - Manage set of tracked repositories.
backup - Manage a set of server backups.
login - Login to a dolt remote host.
creds - Commands for managing credentials.
ls - List tables in the working set.
schema - Commands for showing and importing table schemas.
table - Commands for copying, renaming, deleting, and exporting tables.
tag - Create, list, delete tags.
blame - Show what revision and author last modified each row of a table.
constraints - Commands for handling constraints.
migrate - Executes a database migration to use the latest Dolt data format.
read-tables - Fetch table(s) at a specific commit into a new dolt repo
gc - Cleans up unreferenced data from the repository.
fsck - Verifies the contents of the database are not corrupted. Provides repair when possible.
filter-branch - Edits the commit history using the provided query.
merge-base - Find the common ancestor of two commits.
version - Displays the version for the Dolt binary.
dump - Export all tables in the working set into a file.
docs - Commands for working with Dolt documents.
stash - Stash the changes in a dirty workspace away.
profile - Manage dolt profiles for CLI global options.
query-diff - Shows table diff between two queries.
reflog - Show history of named refs.
rebase - Reapplies commits on top of another base tip
ci - Commands for working with Dolt continuous integration configuration.
debug - Run a query in profile and trace mode
rm - Drops a table and removes it from trackingdolt [global flags] subcommand [subcommand arguments]dolt diff --filter=droppeddolt add [<table>...]dolt backup [-v | --verbose]
dolt backup add [--aws-region <region>] [--aws-creds-type <creds-type>] [--aws-creds-file <file>] [--aws-creds-profile <profile>] <name> <url>
dolt backup remove <name>
dolt backup restore [--aws-region <region>] [--aws-creds-type <creds-type>] [--aws-creds-file <file>] [--aws-creds-profile <profile>] [--force] <url> <name>
dolt backup sync <name>
dolt backup sync-url [--aws-region <region>] [--aws-creds-type <creds-type>] [--aws-creds-file <file>] [--aws-creds-profile <profile>] <url>role: Use the credentials installed for the current user.
env: Looks for environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
file: Uses the credentials file specified by the parameter aws-creds-file.dolt blame [<rev>] <tablename>dolt branch [--list] [-v] [-a] [-r]
dolt branch [-f] <branchname> [<start-point>]
dolt branch -m [-f] [<oldbranch>] <newbranch>
dolt branch -c [-f] [<oldbranch>] <newbranch>
dolt branch -d [-f] [-r] <branchname>...dolt checkout <branch>
dolt checkout <commit> [--] <table>...
dolt checkout <table>...
dolt checkout -b <new-branch> [<start-point>]
dolt checkout --track <remote>/<branch>dolt cherry-pick [--allow-empty] <commit>dolt ci destroy dolt ci export <workflow name>dolt ci import <file> # Dolt test step
- name: <step-name>
dolt_test_groups: [<group-name>, ...] # optional
dolt_test_tests: [<test-name>, ...] # optionaldolt ci init dolt ci ls dolt ci remove <workflow name>dolt ci run <workflow name>dolt ci view <workflow name>
dolt ci view <workflow name> --job <job name>dolt clean [--dry-run]
dolt clean [--dry-run] <tables>...dolt clone [-remote <remote>] [-branch <branch>] [--aws-region <region>] [--aws-creds-type <creds-type>] [--aws-creds-file <file>] [--aws-creds-profile <profile>] <remote-url> <new-dir>dolt commit [options]dolt config [--global|--local] --list
dolt config [--global|--local] --add <name> <value>
dolt config [--global|--local] --set <name> <value>
dolt config [--global|--local] --get <name>
dolt config [--global|--local] --unset <name>...- core.editor - lets you edit 'commit' or 'tag' messages by launching the set editor.
- creds.add_url - sets the endpoint used to authenticate a client for 'dolt login'.
- doltlab.insecure - boolean flag used to authenticate a client against DoltLab.
- init.defaultbranch - allows overriding the default branch name e.g. when initializing a new repository.
- metrics.disabled - boolean flag disables sending metrics when true.
- user.creds - sets user keypairs for authenticating with doltremoteapi.
- user.email - sets name used in the author and committer field of commit objects.
- user.name - sets email used in the author and committer field of commit objects.
- remotes.default_host - sets default host for authenticating with doltremoteapi.
- remotes.default_port - sets default port for authenticating with doltremoteapi.
- push.autoSetupRemote - if set to "true" assume --set-upstream on default push when no upstream tracking exists for the current branch.dolt conflicts cat <table>...dolt conflicts resolve --ours|--theirs <table>...dolt constraints verify [--all] [--output-only] [<table>...]dolt creds check [--endpoint doltremoteapi.dolthub.com:443] [--creds <eak95022q3vskvumn2fcrpibdnheq1dtr8t...>]dolt creds import [--no-profile] [<jwk_filename>]dolt creds ls [-v | --verbose]dolt creds rm <public_key_as_appears_in_ls>dolt creds use <public_key_as_appears_in_ls | public_key_id_as_appears_in_ls>dolt debug
dolt debug < script.sql
dolt debug -q <query> [-r <result format>] [-s <name> -m <message>] [-b]
dolt debug -x <name>
dolt debug --list-saveddolt diff [options] [<commit>] [<tables>...]
dolt diff [options] <commit> <commit> [<tables>...]dolt docs diff <doc>dolt docs print <doc>dolt docs upload <doc> <file>dolt dump [-f] [-r <result-format>] [-fn <file_name>] [-d <directory>] [--batch] [--no-batch] [--no-autocommit] [--no-create-db] dolt fetch [<remote>] [<refspec> ...]dolt filter-branch [--all] -q <queries> [<commit>]dolt fsck [--quiet]
dolt fsck --revive-journal-with-data-lossdolt gc [--shallow|--full]dolt init dolt log [-n <num_commits>] [<revision-range>] [[--] <table>]dolt login [--auth-endpoint <endpoint>] [--login-url <url>] [-i | --insecure] [<creds>]dolt ls [--options] [<commit>]dolt merge [--squash] <branch>
dolt merge --no-ff [-m message] <branch>
dolt merge --abortdolt merge-base <commit spec> <commit spec>dolt profile [-v | --verbose]
dolt profile add [-u <user>] [-p <password>] [--host <host>] [--port <port>] [--no-tls] [--data-dir <directory>] [--doltcfg-dir <directory>] [--privilege-file <privilege file>] [--branch-control-file <branch control file>] [--use-db <database>] <name>
dolt profile remove <name>dolt pull [<remote>, [<remoteBranch>]]dolt push [-u | --set-upstream] [<remote>] [<refspec>]dolt query-diff [options] [<query1>] [<query2>]dolt read-tables [--dir <directory>] <remote-url> <commit> [<table>...]dolt rebase (-i | --interactive) [--empty=drop|keep] <upstream>
dolt rebase (--continue | --abort)dolt reflog [--all] <ref>dolt remote [-v | --verbose]
dolt remote add [--aws-region <region>] [--aws-creds-type <creds-type>] [--aws-creds-file <file>] [--aws-creds-profile <profile>] <name> <url>
dolt remote remove <name>role: Use the credentials installed for the current user
env: Looks for environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
file: Uses the credentials file specified by the parameter aws-creds-filedolt reset <tables>...
dolt reset [--hard | --soft] <revision>dolt revert <revision>...dolt rm [<table>...]dolt schema export [<table>] [<file>]dolt schema import [--create|--replace] [--force] [--dry-run] [--lower|--upper] [--keep-types] [--file-type <type>] [--float-threshold] [--map <mapping-file>] [--delim <delimiter>]--pks <field>,... <table> <file>{
"source_field_name":"dest_field_name"
...
}dolt schema show [<commit>] [<table>...]dolt schema tags [-r <result format>] [<table>...]dolt schema update-tag <table> <column> <tag>dolt show [<revision>]dolt sql
dolt sql < script.sql
dolt sql -q <query> [-r <result format>] [-s <name> -m <message>] [-b]
dolt sql -x <name>
dolt sql --list-saveddolt sql-server --config <file>
dolt sql-server [-H <host>] [-P <port>] [-t <timeout>] [-l <loglevel>] [--data-dir <directory>] [-r]log_level: info
log_format: text
behavior:
read_only: false
autocommit: true
disable_client_multi_statements: false
dolt_transaction_commit: false
event_scheduler: "ON"
auto_gc_behavior:
enable: true
archive_level: 1
branch_activity_tracking: false
listener:
host: localhost
port: 3306
max_connections: 1000
back_log: 50
max_connections_timeout_millis: 60000
read_timeout_millis: 28800000
write_timeout_millis: 28800000
data_dir: .
cfg_dir: .doltcfg
privilege_file: .doltcfg\privileges.db
branch_control_file: .doltcfg\branch_control.db
user_session_vars: []
jwks: []
metrics:
labels: {}
port: -1
tls_cert: ""
tls_key: ""
tls_ca: ""
jwt_required_for_localhost: falsedolt stash
dolt stash list
dolt stash pop <stash>
dolt stash clear
dolt stash drop <stash>dolt status dolt table cp [-f] <oldtable> <newtable>dolt table export [-f] [-pk <field>] [-schema <file>] [-map <file>] [-continue] [-file-type <type>] <table> <file>dolt table import -c [-f] [--pk <field>] [--all-text] [--schema <file>] [--map <file>] [--continue] [--quiet] [--disable-fk-checks] [--file-type <type>] [--no-header] [--columns <col1,col2,...>] <table> <file>
dolt table import -u [--map <file>] [--continue] [--quiet] [--file-type <type>] [--no-header] [--columns <col1,col2,...>] <table> <file>
dolt table import -a [--map <file>] [--continue] [--quiet] [--file-type <type>] [--no-header] [--columns <col1,col2,...>] <table> <file>
dolt table import -r [--map <file>] [--file-type <type>] [--no-header] [--columns <col1,col2,...>] <table> <file>{
"source_field_name":"dest_field_name"
...
}{ "rows":
[
{
"column_name":"value"
...
}, ...
]
}dolt table mv [-f] <oldtable> <newtable>dolt table rm <table>...dolt tag [-v]
dolt tag [-m <message>] <tagname> [<ref>]
dolt tag -d <tagname>dolt version [--verbose] [--feature]