Skip to content

Commit b7129fe

Browse files
authored
Merge pull request #881 from dolthub/taylor/dolt-schema
Update first batch of dolt system tables to use `dolt` schema
2 parents f1757f8 + 379c316 commit b7129fe

31 files changed

+439
-189
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ getting_started=> \d
119119
7. Make a Dolt Commit.
120120

121121
```sql
122-
getting_started=> select * from dolt_status;
122+
getting_started=> select * from dolt.status;
123123
table_name | staged | status
124124
------------------------+--------+-----------
125125
public.employees | 0 | new table
@@ -132,7 +132,7 @@ getting_started=> call dolt_add('teams', 'employees', 'employees_teams');
132132
--------
133133
0
134134
(1 row)
135-
getting_started=> select * from dolt_status;
135+
getting_started=> select * from dolt.status;
136136
table_name | staged | status
137137
-----------------------+--------+-----------
138138
public.employees | 1 | new table
@@ -150,7 +150,7 @@ getting_started=> call dolt_commit('-m', 'Created initial schema');
150150
8. View the Dolt log.
151151

152152
```
153-
getting_started=> select * from dolt_log;
153+
getting_started=> select * from dolt.log;
154154
commit_hash | committer | email | date | message
155155
----------------------------------+-----------+--------------------+---------------------+----------------------------
156156
peqq98e2dl5gscvfvic71e7j6ne34533 | doltgres | [email protected] | 2023-11-01 22:08:04 | Created initial schema

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ require (
88
github.com/PuerkitoBio/goquery v1.8.1
99
github.com/cockroachdb/apd/v2 v2.0.3-0.20200518165714-d020e156310a
1010
github.com/cockroachdb/errors v1.7.5
11-
github.com/dolthub/dolt/go v0.40.5-0.20241025002354-1bf5606b7e23
11+
github.com/dolthub/dolt/go v0.40.5-0.20241028195925-746ebc613846
1212
github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20240827111219-e4bb9ca3442d
1313
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
1414
github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662
15-
github.com/dolthub/go-mysql-server v0.18.2-0.20241024233927-96a484368bea
15+
github.com/dolthub/go-mysql-server v0.18.2-0.20241028173746-a6973b5e90d6
1616
github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216
1717
github.com/dolthub/vitess v0.0.0-20241016191424-d14e107a654e
1818
github.com/fatih/color v1.13.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm
214214
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
215215
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
216216
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
217-
github.com/dolthub/dolt/go v0.40.5-0.20241025002354-1bf5606b7e23 h1:R/isZppGvXrUIujDnYblRvdfGJxgsNSbnNwG6Bu2BSY=
218-
github.com/dolthub/dolt/go v0.40.5-0.20241025002354-1bf5606b7e23/go.mod h1:Dlf8rNaNwRfW+RRcsGxDxxpkwB616hrh5Gqr2YJGQOg=
217+
github.com/dolthub/dolt/go v0.40.5-0.20241028195925-746ebc613846 h1:IYbgv29ClfGVj/vM4qxQpZJQnw9XdrW8UZxNaVYJjKc=
218+
github.com/dolthub/dolt/go v0.40.5-0.20241028195925-746ebc613846/go.mod h1:sZ612KergPWZQkkCL5uVi6BV15YH08HlBXOyRzEccg8=
219219
github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20240827111219-e4bb9ca3442d h1:RZkQeYOrDrOWzCxaP2ttkvg4E2TM9n8lnEsIBLKjqkM=
220220
github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi v0.0.0-20240827111219-e4bb9ca3442d/go.mod h1:L5RDYZbC9BBWmoU2+TjTekeqqhFXX5EqH9ln00O0stY=
221221
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 h1:u3PMzfF8RkKd3lB9pZ2bfn0qEG+1Gms9599cr0REMww=
@@ -224,8 +224,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
224224
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
225225
github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662 h1:aC17hZD6iwzBwwfO5M+3oBT5E5gGRiQPdn+vzpDXqIA=
226226
github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662/go.mod h1:KPUcpx070QOfJK1gNe0zx4pA5sicIK1GMikIGLKC168=
227-
github.com/dolthub/go-mysql-server v0.18.2-0.20241024233927-96a484368bea h1:bqHfelpj4LTC4RQnnFeC8KiXda90E0YfG0Elg5AqV0w=
228-
github.com/dolthub/go-mysql-server v0.18.2-0.20241024233927-96a484368bea/go.mod h1:z/GGuH2asedC+lkJA4sx+C3oyRH1HRx8ET6N9AGBVms=
227+
github.com/dolthub/go-mysql-server v0.18.2-0.20241028173746-a6973b5e90d6 h1:+RYghO025hK+Q2y9rPXv3mLOSnWOKllVjfg3vEJ4lfM=
228+
github.com/dolthub/go-mysql-server v0.18.2-0.20241028173746-a6973b5e90d6/go.mod h1:z/GGuH2asedC+lkJA4sx+C3oyRH1HRx8ET6N9AGBVms=
229229
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
230230
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
231231
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE=

server/tables/dtables/dolt_docs.go renamed to server/tables/dtables/docs.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@ import (
2222
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
2323
)
2424

25+
// getDocsSchema returns the schema for the docs table.
2526
func getDocsSchema() sql.Schema {
2627
return []*sql.Column{
27-
{Name: doltdb.DocPkColumnName, Type: pgtypes.Text, Source: doltdb.DocTableName, PrimaryKey: true, Nullable: false},
28-
{Name: doltdb.DocTextColumnName, Type: pgtypes.Text, Source: doltdb.DocTableName, PrimaryKey: false},
28+
{Name: doltdb.DocPkColumnName, Type: pgtypes.Text, Source: getDocTableName(), PrimaryKey: true, Nullable: false},
29+
{Name: doltdb.DocTextColumnName, Type: pgtypes.Text, Source: getDocTableName(), PrimaryKey: false},
2930
}
3031
}
32+
33+
// getDocTableName returns the name of the docs table.
34+
func getDocTableName() string {
35+
return "docs"
36+
}

server/tables/dtables/init.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,37 @@
1414

1515
package dtables
1616

17-
import "github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables"
17+
import (
18+
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
19+
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/dtables"
20+
)
1821

1922
// Init handles initialization of all Postgres-specific and Doltgres-specific Dolt system tables.
2023
func Init() {
2124
dtables.GetDocsSchema = getDocsSchema
25+
doltdb.GetDocTableName = getDocTableName
26+
doltdb.GetBranchesTableName = getBranchesTableName
27+
doltdb.GetLogTableName = getLogTableName
28+
doltdb.GetStatusTableName = getStatusTableName
29+
doltdb.GetTagsTableName = getTagsTableName
30+
}
31+
32+
// getBranchesTableName returns the name of the branches table.
33+
func getBranchesTableName() string {
34+
return "branches"
35+
}
36+
37+
// getLogTableName returns the name of the branches table.
38+
func getLogTableName() string {
39+
return "log"
40+
}
41+
42+
// getStatusTableName returns the name of the status table.
43+
func getStatusTableName() string {
44+
return "status"
45+
}
46+
47+
// getTagsTableName returns the name of the tags table.
48+
func getTagsTableName() string {
49+
return "tags"
2250
}

testing/go/dolt_functions_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ func TestDoltFunctions(t *testing.T) {
3939
SkipResultsCheck: true,
4040
},
4141
{
42-
Query: "select count(*) from dolt_log",
42+
Query: "select count(*) from dolt.log",
4343
Expected: []sql.Row{
4444
{3}, // initial commit, CREATE DATABASE commit, CREATE TABLE commit
4545
},
4646
},
4747
{
48-
Query: "select message from dolt_log order by date desc limit 1",
48+
Query: "select message from dolt.log order by date desc limit 1",
4949
Expected: []sql.Row{
5050
{"new table"},
5151
},
@@ -73,7 +73,7 @@ func TestDoltFunctions(t *testing.T) {
7373
},
7474
},
7575
{
76-
Query: "select count(*) from dolt_log",
76+
Query: "select count(*) from dolt.log",
7777
Expected: []sql.Row{
7878
{3}, // initial commit, CREATE DATABASE commit, CREATE TABLE commit
7979
},
@@ -83,7 +83,7 @@ func TestDoltFunctions(t *testing.T) {
8383
SkipResultsCheck: true,
8484
},
8585
{
86-
Query: "select count(*) from dolt_log",
86+
Query: "select count(*) from dolt.log",
8787
Expected: []sql.Row{
8888
{5}, // initial commit, CREATE DATABASE commit, CREATE TABLE t1 commit, new CREATE TABLE t2 commit, merge commit
8989
},
@@ -112,7 +112,7 @@ func TestDoltFunctions(t *testing.T) {
112112
},
113113
},
114114
{
115-
Query: "SELECT * FROM dolt_status",
115+
Query: "SELECT * FROM dolt.status",
116116
Expected: []sql.Row{
117117
{"public.t1", 0, "modified"},
118118
},
@@ -122,7 +122,7 @@ func TestDoltFunctions(t *testing.T) {
122122
ExpectedErr: "error: local changes would be stomped by merge",
123123
},
124124
{
125-
Query: "SELECT * FROM dolt_status",
125+
Query: "SELECT * FROM dolt.status",
126126
Expected: []sql.Row{
127127
{"public.t1", 0, "modified"},
128128
},
@@ -151,7 +151,7 @@ func TestDoltFunctions(t *testing.T) {
151151
},
152152
},
153153
{
154-
Query: "SELECT * FROM dolt_status",
154+
Query: "SELECT * FROM dolt.status",
155155
Expected: []sql.Row{
156156
{"public.t1", 0, "modified"},
157157
},
@@ -161,7 +161,7 @@ func TestDoltFunctions(t *testing.T) {
161161
SkipResultsCheck: true,
162162
},
163163
{
164-
Query: "SELECT * FROM dolt_status",
164+
Query: "SELECT * FROM dolt.status",
165165
Expected: []sql.Row{
166166
{"public.t1", 0, "modified"},
167167
},
@@ -176,7 +176,7 @@ func TestDoltFunctions(t *testing.T) {
176176
},
177177
Assertions: []ScriptTestAssertion{
178178
{
179-
Query: "SELECT * FROM dolt_status;",
179+
Query: "SELECT * FROM dolt.status;",
180180
Expected: []sql.Row{
181181
{"public.t1", 0, "new table"},
182182
},
@@ -186,7 +186,7 @@ func TestDoltFunctions(t *testing.T) {
186186
Expected: []sql.Row{{"{0}"}},
187187
},
188188
{
189-
Query: "SELECT * FROM dolt_status;",
189+
Query: "SELECT * FROM dolt.status;",
190190
Expected: []sql.Row{
191191
{"public.t1", 1, "new table"},
192192
},
@@ -196,7 +196,7 @@ func TestDoltFunctions(t *testing.T) {
196196
Expected: []sql.Row{{"{0}"}},
197197
},
198198
{
199-
Query: "SELECT * FROM dolt_status;",
199+
Query: "SELECT * FROM dolt.status;",
200200
Expected: []sql.Row{
201201
{"public.t1", 0, "new table"},
202202
},
@@ -211,7 +211,7 @@ func TestDoltFunctions(t *testing.T) {
211211
},
212212
Assertions: []ScriptTestAssertion{
213213
{
214-
Query: "SELECT * FROM dolt_status;",
214+
Query: "SELECT * FROM dolt.status;",
215215
Expected: []sql.Row{
216216
{"public.t1", 0, "new table"},
217217
},
@@ -221,15 +221,15 @@ func TestDoltFunctions(t *testing.T) {
221221
Expected: []sql.Row{{"{0}"}},
222222
},
223223
{
224-
Query: "SELECT * FROM dolt_status;",
224+
Query: "SELECT * FROM dolt.status;",
225225
Expected: []sql.Row{},
226226
},
227227
{
228228
Query: "CREATE TABLE t1 (pk int primary key);",
229229
Expected: []sql.Row{},
230230
},
231231
{
232-
Query: "SELECT * FROM dolt_status;",
232+
Query: "SELECT * FROM dolt.status;",
233233
Expected: []sql.Row{
234234
{"public.t1", 0, "new table"},
235235
},
@@ -241,7 +241,7 @@ func TestDoltFunctions(t *testing.T) {
241241
},
242242
{
243243
Skip: true,
244-
Query: "SELECT * FROM dolt_status;",
244+
Query: "SELECT * FROM dolt.status;",
245245
Expected: []sql.Row{},
246246
},
247247
},
@@ -254,7 +254,7 @@ func TestDoltFunctions(t *testing.T) {
254254
},
255255
Assertions: []ScriptTestAssertion{
256256
{
257-
Query: "SELECT * FROM dolt_status;",
257+
Query: "SELECT * FROM dolt.status;",
258258
Expected: []sql.Row{
259259
{"public.t1", 0, "new table"},
260260
},
@@ -264,7 +264,7 @@ func TestDoltFunctions(t *testing.T) {
264264
Expected: []sql.Row{{"{0}"}},
265265
},
266266
{
267-
Query: "SELECT * FROM dolt_status;",
267+
Query: "SELECT * FROM dolt.status;",
268268
Expected: []sql.Row{},
269269
},
270270
},
@@ -371,7 +371,7 @@ func TestDoltFunctions(t *testing.T) {
371371
},
372372
Assertions: []ScriptTestAssertion{
373373
{
374-
Query: "SELECT * FROM dolt_status;",
374+
Query: "SELECT * FROM dolt.status;",
375375
Expected: []sql.Row{
376376
{"public.t1", 0, "new table"},
377377
{"testschema.t2", 0, "new table"},

0 commit comments

Comments
 (0)