Skip to content

Commit c511280

Browse files
authored
Merge pull request #2250 from dolthub/gitbook-dev
publish doltgres
2 parents 1d27328 + f4ded62 commit c511280

18 files changed

+153
-198
lines changed

packages/doltgres/content/concepts/git/working-set.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ the staging set. The staging set is committed by issuing a `dolt_commit()` comma
1212
appropriate metadata.
1313

1414
If you start a Doltgres SQL server and start making changes, you are making changes to the working
15-
set. If you never make a commit, your working set is a standard MySQL database. So, a way to think
16-
about your working set is Doltgres without version control features, just a standard MySQL
15+
set. If you never make a commit, your working set is a standard Postgres database. So, a way to think
16+
about your working set is Doltgres without version control features, just a standard Postgres
1717
relational database.
1818

1919
## How to use Working Sets
@@ -24,7 +24,7 @@ to a working set, you can `dolt_reset()` or `dolt_checkout()` to the previous co
2424

2525
## Difference between Git Working Sets and Doltgres Working Sets
2626

27-
Git working sets change files. Doltgres working sets change tables.
27+
Git working sets change files. Doltgres working sets change tables.
2828

2929
On the command line, working set changes do follow to the newly checked out branch, just like
3030
Git. However, in SQL server mode, working set changes are not transferred to the newly checked out
@@ -91,7 +91,7 @@ call dolt_checkout('branch2');
9191
+--------+
9292
| 0 |
9393
+--------+
94-
mysql> select * from docs ;
94+
select * from docs ;
9595
+----+----+
9696
| pk | c1 |
9797
+----+----+

packages/doltgres/content/concepts/sql/constraints.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ title: Constraints
66

77
## What is a Constraint?
88

9-
Constraints restrict the values allowed in a column. There are multiple forms of constraints:
9+
Constraints restrict the values allowed in a column. There are multiple forms of constraints:
1010

1111
1. `NOT NULL` or `UNIQUE` in the column definition
1212
2. Check constraints
1313
3. Foreign Key constraints
1414

1515
Simple constraints like `NOT NULL` and `UNIQUE` can be added when defining a column. These constrain the column to not be NULL and only contain unique values, respectively.
1616

17-
Check constraints allow the database user to define more complex constraints, like ranges on numerical values.
17+
Check constraints allow the database user to define more complex constraints, like ranges on numerical values.
1818

19-
Foreign key constraints allow you to reference and define relations between other tables in your database.
19+
Foreign key constraints allow you to reference and define relations between other tables in your database.
2020

2121
## How to use Constraints
2222

@@ -26,9 +26,9 @@ database.
2626

2727
You can add constraints when running `CREATE TABLE` statements or add them to existing tables using `ALTER` statements.
2828

29-
## Difference between MySQL Constraints and Doltgres Constraints
29+
## Difference between Postgres Constraints and Doltgres Constraints
3030

31-
MySQL and Doltgres constraints are functionally equivalent.
31+
Postgres and Doltgres constraints are functionally equivalent.
3232

3333
## Interaction with Doltgres Version Control
3434

@@ -49,15 +49,15 @@ making a Doltgres commit.
4949

5050
```sql
5151
create table employees (
52-
id int,
53-
last_name varchar(100),
54-
first_name varchar(100),
55-
age int,
56-
primary key(id),
52+
id int,
53+
last_name varchar(100),
54+
first_name varchar(100),
55+
age int,
56+
primary key(id),
5757
constraint over_18 check (age >= 18));
58-
create table pay (id int,
59-
salary int,
60-
primary key(id),
58+
create table pay (id int,
59+
salary int,
60+
primary key(id),
6161
foreign key (id) references employees(id));
6262
```
6363

packages/doltgres/content/concepts/sql/databases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ When you connect a client to a running server, you can see the databases being s
2424
command in the `psql` shell. To use a specific database, you issue a `\c <database>` statement. You
2525
can also specify the database in the connection string to connect to a particular database.
2626

27-
## Difference between MySQL Databases and Doltgres Databases
27+
## Difference between Postgres Databases and Doltgres Databases
2828

2929
In Doltgres, databases act like they do in Postgres.
3030

packages/doltgres/content/concepts/sql/indexes.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ performance. Additionally, you should have the disk space available to store the
2323

2424
You create indexes using the `CREATE INDEX` SQL statement.
2525

26-
## Difference between MySQL Secondary Indexes and Doltgres Secondary Indexes
26+
## Difference between Postgres Secondary Indexes and Doltgres Secondary Indexes
2727

28-
Functionally, Doltgres and MySQL indexes are equivalent.
28+
Functionally, Doltgres and Postgres indexes are equivalent.
2929

3030
## Interaction with Doltgres Version Control
3131

@@ -37,6 +37,7 @@ Doltgres will merge indexes as part of a Doltgres merge. This can be used to off
3737
to a branch or offline clone.
3838

3939
## Example
40+
4041
```
4142
create index index1 on complex(c1);
4243
```

packages/doltgres/content/concepts/sql/primary-key.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ key is a unique identification or id number.
1111

1212
In most databases, a map of primary keys to the values of the other columns in the table is how the
1313
data is laid out on disk or memory. This makes row lookups by primary key indexed lookups. Indexed
14-
lookups can be accomplished in constant time (ie. O(1)). Thus, use of primary keys in table
14+
lookups can be accomplished in constant time (ie. O(1)). Thus, use of primary keys in table
1515
definition and queries is a common database performance optimization. [Secondary
1616
Indexes](./indexes.md) are called "secondary" to distinguish them from primary keys.
1717

@@ -30,7 +30,7 @@ database applications assign a primary key, usually called `id`, on row creation
3030

3131
<!-- TODO: talk about sequences in primary keys -->
3232

33-
## Difference between MySQL Primary Keys and Doltgres Primary Keys
33+
## Difference between Postgres Primary Keys and Doltgres Primary Keys
3434

3535
Postgres and Doltgres primary keys are functionally the same. You use the same syntax to define and
3636
alter them.

packages/doltgres/content/concepts/sql/schema.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Schema
66

77
## What is a Schema?
88

9-
Schema defines the shape of the data in your database.
9+
Schema defines the shape of the data in your database.
1010

1111
<!-- TODO: talk about database schemas -->
1212

@@ -40,7 +40,7 @@ Changing schema can be a costly operation. For instance, adding an index to a co
4040
database requires scanning the entire table and writing a new index artifact, usually while also
4141
restricting writes to that table.
4242

43-
## Difference between MySQL Schema and Doltgres Schema
43+
## Difference between Postgres Schema and Doltgres Schema
4444

4545
Doltgres supports [most Postgres schema elements at least
4646
partially](../../reference/sql-support/supported-types.md), with more support being built out

packages/doltgres/content/concepts/sql/system-variables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ support should have the same lifecycle behavior as Postgres.
2626
We also have Doltgres-specific system variables, which can be found
2727
[here](../../reference/sql/version-control/dolt-sysvars.md). Most dolt specific variables are
2828
prefixed with either `dolt_...` or the database's name (ex: `mydb_...`). These can be listed in the
29-
MySQL shell with show queries: `show all`.
29+
Postgres shell with show queries: `show all`.
3030

3131
## Interaction with Doltgres Version Control
3232

packages/doltgres/content/concepts/sql/table.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ A Postgres and Dolt table function the same on the surface. `CREATE` and `ALTER`
2525
same on both.
2626

2727
Dolt and Postgres are [row major](https://en.wikipedia.org/wiki/Row-_and_column-major_order),
28-
meaning row values are stored next to each other. However, MySQL stores data in a binary tree
28+
meaning row values are stored next to each other. However, Postgres stores data in a binary tree
2929
structure while Dolt stores table data on disk using a content-addressed binary tree called a
3030
[prolly tree](https://docs.dolthub.com/architecture/storage-engine/prolly-tree). This setup makes Dolt [fairly
3131
comparable in query performance to Postgres](../../reference/benchmarks/latency.md) while also

packages/doltgres/content/concepts/sql/transaction.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Transactions
66

77
## What is a Transaction?
88

9-
A transaction is the unit of change isolation is a database.
9+
A transaction is the unit of change isolation is a database.
1010

1111
## How to use Transactions
1212

@@ -21,17 +21,17 @@ back to the way it was when the transaction began.
2121
Postgres and Doltgres both automatically commit every statement that wasn't explicitly placed in a
2222
transaction with a `BEGIN` statement.
2323

24-
## Difference between MySQL Transaction and Doltgres Transaction
24+
## Difference between Postgres Transaction and Doltgres Transaction
2525

2626
Doltgres uses the Read Committed transaction model whereas Postgres supports [all transaction
2727
isolation levels](https://www.postgresql.org/docs/current/transaction-iso.html).
2828

2929
## Interaction with Doltgres Version Control
3030

31-
Traditional SQL transactions exist in isolation from Doltgres version control features.
31+
Traditional SQL transactions exist in isolation from Doltgres version control features.
3232

3333
Doltgres can be thought of having two layers of transactions. The first layer accessed with `BEGIN`
34-
and `COMMIT` SQL statements is the same as MySQL. Doltgres adds an additional second layer with
34+
and `COMMIT` SQL statements is the same as Postgres. Doltgres adds an additional second layer with
3535
branches and Doltgres commits. Branches can be thought of as long running transactions that may or
3636
may not be merged.
3737

@@ -41,7 +41,7 @@ variable](./system-variables.md),
4141

4242
## Example
4343

44-
```
44+
```sql
4545
BEGIN;
4646
select * from docs;
4747
+----+----+
@@ -63,8 +63,8 @@ select * from docs;
6363
| 2 | 2 |
6464
| 3 | 0 |
6565
+----+----+
66-
mysql> rollback;
67-
mysql> select * from docs;
66+
database=# rollback;
67+
database=# select * from docs;
6868
+----+----+
6969
| pk | c1 |
7070
+----+----+

packages/doltgres/content/concepts/sql/types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type of a column with `ALTER` statements.
2626
When querying tables, the type of the column defines which functions can be used on the data
2727
retrieved. To manipulate the type of a column when querying you use the `CONVERT()` function.
2828

29-
## Difference between MySQL Types and Doltgres Types
29+
## Difference between Postgres Types and Doltgres Types
3030

3131
Doltgres supports [most Postgres types](../../reference/sql-support/supported-types.md), with more
3232
being implemented.

packages/doltgres/content/reference/sql/server/branch-permissions.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ title: Branch Permissions
77
## What are Branch Permissions?
88

99
Branch permissions are a way of managing how users may interact with branches when running Doltgres
10-
as a server (via `doltgres sql-server`). The branch permissions model is composed of two system
11-
tables: `dolt_branch_control` and `dolt_branch_namespace_control`. The former table handles branch
12-
modification, while the latter table handles branch creation. All operations that are not
10+
as a server (via `doltgres sql-server`). The branch permissions model is composed of two system
11+
tables: `dolt_branch_control` and `dolt_branch_namespace_control`. The former table handles branch
12+
modification, while the latter table handles branch creation. All operations that are not
1313
explicitly done as a client connected to a server (such as locally using the CLI) will bypass branch
1414
permissions.
1515

@@ -21,7 +21,7 @@ Each column is composed of a string that represents a pattern-matching expressio
2121
### `dolt_branch_control`
2222

2323
| Column | Type | Collation |
24-
|:------------|:------------------------------|:-------------------|
24+
| :---------- | :---------------------------- | :----------------- |
2525
| database | VARCHAR(16383) | utf8mb4_0900_ai_ci |
2626
| branch | VARCHAR(16383) | utf8mb4_0900_ai_ci |
2727
| user | VARCHAR(16383) | utf8mb4_0900_bin |
@@ -31,7 +31,7 @@ Each column is composed of a string that represents a pattern-matching expressio
3131
### `dolt_branch_namespace_control`
3232

3333
| Column | Type | Collation |
34-
|:---------|:---------------|:-------------------|
34+
| :------- | :------------- | :----------------- |
3535
| database | VARCHAR(16383) | utf8mb4_0900_ai_ci |
3636
| branch | VARCHAR(16383) | utf8mb4_0900_ai_ci |
3737
| user | VARCHAR(16383) | utf8mb4_0900_bin |
@@ -40,7 +40,7 @@ Each column is composed of a string that represents a pattern-matching expressio
4040
### Available Permissions
4141

4242
| Permission | Effect |
43-
|:-----------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
43+
| :--------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
4444
| admin | Grants all permissions available. In addition, grants write access to entries on both system tables, as long as the database and branch are equivalent, or they're subset of the database + branch that this permission belongs to. |
4545
| write | Grants the ability to write on the branch, as well as modify the branch in all possible ways (rename, delete, etc.). |
4646
| read | Does not explicitly grant any permissions, as having the ability to read a branch is an irrevocable right for all users. This is just for the visual convenience, versus having an empty field. |
@@ -54,8 +54,8 @@ The form of pattern matching that each column implements is very similar to how
5454
Most characters are interpreted as-is, with the exception of three characters.
5555

5656
| Character | Function |
57-
|:----------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
58-
| _ | Matches a single character, regardless of what that character is. |
57+
| :-------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
58+
| \_ | Matches a single character, regardless of what that character is. |
5959
| % | Matches zero or more characters, regardless of what those characters are. |
6060
| \ | Escapes the next character, allowing it to be compared literally. This is only useful when attempting to match one of these special characters, as it is otherwise ignored (has no effect). |
6161

@@ -93,7 +93,7 @@ The modification of both system tables are controlled by two entities: the privi
9393
Any user that satisfies the privilege requirements may edit the appropriate entries in both system tables.
9494

9595
| Scope | Privileges | Remarks |
96-
|:-------------|:-------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------|
96+
| :----------- | :----------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------ |
9797
| `*.*` | SUPER, GRANT OPTION | Considered a global admin. May edit any entry in either table, including entries containing special characters. |
9898
| `*.*` | CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, EXECUTE, GRANT OPTION | Same as above. |
9999
| `database.*` | CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, EXECUTE, GRANT OPTION | Considered a database admin. May edit entries only for their specific database. This also excludes all databases that contain _any_ special characters. |
@@ -152,9 +152,11 @@ It is worth noting that operations such as renaming a branch also require the co
152152
This is because a rename may be viewed as a copy and delete, therefore it is modifying the original branch.
153153

154154
To turn `dolt_branch_namespace_control` into a blacklist (just like `dolt_branch_control`), then run the following statement:
155+
155156
```sql
156157
INSERT INTO dolt_branch_namespace_control VALUES ('%', '%', '', '');
157158
```
159+
158160
This will add an entry that will match every possible branch, but will never match a user as a user will never have an empty user and host.
159161
Due to the longest match rule, this entry will be ignored when a valid match is found.
160162

@@ -175,8 +177,8 @@ The following examples are a small snippet that shows branch permissions in acti
175177
It is assumed that this document has been read in full, as concepts that are explained in previous sections are not explained in-depth.
176178
The [setup section](#setup) is run before each example, therefore remember to have a dedicated terminal window for [setup](#setup) if you want to try any of these examples yourself.
177179
All examples other than [setup](#setup) will exclusively use the second terminal window.
178-
All examples will use MySQL's default client, `mysql`.
179-
Feel free to use your desired MySQL client.
180+
All examples will use Postgres' default client, `psql`.
181+
Feel free to use your desired Postgres client.
180182

181183
### Setup
182184

@@ -254,14 +256,15 @@ INSERT INTO dolt_branch_namespace_control VALUES ('example', '_main', 'anotherus
254256
```
255257

256258
### Restricting Branch Names
257-
Please refer to the [setup section](#setup) before continuing this example. This example shows how
258-
to [restrict which users are able to use branch names](#branch-creation) with the `main` prefix. To
259+
260+
Please refer to the [setup section](#setup) before continuing this example. This example shows how
261+
to [restrict which users are able to use branch names](#branch-creation) with the `main` prefix. To
259262
do this, we insert a `main%` entry into the `dolt_branch_namespace_control` table, assigning the
260-
`testuser` user. We create another entry with `mainroot%` as the branch name, and assign that to
261-
`root`. This means that `root` is able to create any branches with names that **do not** start with
262-
`main`, but is unable to create branches that **do** start with `main`. The exception being
263+
`testuser` user. We create another entry with `mainroot%` as the branch name, and assign that to
264+
`root`. This means that `root` is able to create any branches with names that **do not** start with
265+
`main`, but is unable to create branches that **do** start with `main`. The exception being
263266
`mainroot`, which while having `main` as a prefix, it is considered [the longest
264-
match](#longest-match), and therefore takes precedence over the `main%` entry. Consequently,
267+
match](#longest-match), and therefore takes precedence over the `main%` entry. Consequently,
265268
`testuser` cannot use `mainroot` as a prefix, as [the longest match](#longest-match) overrides their
266269
`main%` entry.
267270

@@ -286,7 +289,7 @@ CALL DOLT_BRANCH('mainroot');
286289
+--------+
287290
1 row in set (0.00 sec)
288291

289-
mysql> exit;
292+
example=# exit;
290293

291294
$ psql --user=testuser
292295
CALL DOLT_BRANCH('main1');

packages/doltgres/content/reference/sql/server/replication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Replication
55
# Replication
66

77
Doltgres can [replicate data](../../../concepts/rdbms/replication.md) between two or more
8-
Doltgres servers, or can be a read-replica for a MySQL server. This page describes the two supported
8+
Doltgres servers, or can be a read-replica for a Postgres server. This page describes the two supported
99
replication modes between a Doltgres primary server and Doltgres replica servers. See the [Postgres
1010
to Doltgres Replication guide](../../../guides/replication-from-postgres.md) for more information on
1111
setting up a Doltgres server as a read-replica for a Postgres server.

0 commit comments

Comments
 (0)