Skip to content

Commit eba40a9

Browse files
committed
Merge remote-tracking branch 'origin/main' into taylor/pref-dtables
2 parents df46da9 + b3853f6 commit eba40a9

33 files changed

+2958
-66
lines changed

go/cmd/dolt/commands/ci/ci.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2024 Dolthub, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package ci
16+
17+
import (
18+
"github.com/dolthub/dolt/go/cmd/dolt/cli"
19+
)
20+
21+
var Commands = cli.NewHiddenSubCommandHandler("ci", "Commands for working with Dolt continuous integration configuration.", []cli.Command{
22+
InitCmd{},
23+
DestroyCmd{},
24+
})

go/cmd/dolt/commands/ci/destroy.go

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Copyright 2024 Dolthub, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package ci
16+
17+
import (
18+
"context"
19+
20+
"github.com/dolthub/dolt/go/libraries/doltcore/env/actions/dolt_ci"
21+
22+
"github.com/dolthub/dolt/go/cmd/dolt/cli"
23+
"github.com/dolthub/dolt/go/cmd/dolt/commands"
24+
"github.com/dolthub/dolt/go/cmd/dolt/errhand"
25+
"github.com/dolthub/dolt/go/libraries/doltcore/env"
26+
"github.com/dolthub/dolt/go/libraries/utils/argparser"
27+
)
28+
29+
var destroyDocs = cli.CommandDocumentationContent{
30+
ShortDesc: "Drops database tables used to store continuous integration configuration",
31+
LongDesc: "Drops database tables used to store continuous integration configuration",
32+
Synopsis: []string{
33+
"{{.LessThan}}destroy{{.GreaterThan}}",
34+
},
35+
}
36+
37+
type DestroyCmd struct{}
38+
39+
// Name implements cli.Command.
40+
func (cmd DestroyCmd) Name() string {
41+
return "destroy"
42+
}
43+
44+
// Description implements cli.Command.
45+
func (cmd DestroyCmd) Description() string {
46+
return destroyDocs.ShortDesc
47+
}
48+
49+
// RequiresRepo implements cli.Command.
50+
func (cmd DestroyCmd) RequiresRepo() bool {
51+
return true
52+
}
53+
54+
// Docs implements cli.Command.
55+
func (cmd DestroyCmd) Docs() *cli.CommandDocumentation {
56+
ap := cmd.ArgParser()
57+
return cli.NewCommandDocumentation(destroyDocs, ap)
58+
}
59+
60+
// Hidden should return true if this command should be hidden from the help text
61+
func (cmd DestroyCmd) Hidden() bool {
62+
return true
63+
}
64+
65+
// ArgParser implements cli.Command.
66+
func (cmd DestroyCmd) ArgParser() *argparser.ArgParser {
67+
ap := argparser.NewArgParserWithMaxArgs(cmd.Name(), 0)
68+
return ap
69+
}
70+
71+
// Exec implements cli.Command.
72+
func (cmd DestroyCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
73+
ap := cmd.ArgParser()
74+
_, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, initDocs, ap))
75+
76+
if !cli.CheckEnvIsValid(dEnv) {
77+
return 1
78+
}
79+
80+
queryist, sqlCtx, closeFunc, err := cliCtx.QueryEngine(ctx)
81+
if err != nil {
82+
return commands.HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage)
83+
}
84+
if closeFunc != nil {
85+
defer closeFunc()
86+
}
87+
88+
db, err := newDatabase(sqlCtx, sqlCtx.GetCurrentDatabase(), dEnv, false)
89+
if err != nil {
90+
return commands.HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage)
91+
}
92+
93+
name, email, err := env.GetNameAndEmail(dEnv.Config)
94+
if err != nil {
95+
return commands.HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage)
96+
}
97+
98+
var verr errhand.VerboseError
99+
err = dolt_ci.DestroyDoltCITables(sqlCtx, db, queryist.Query, name, email)
100+
if err != nil {
101+
verr = errhand.VerboseErrorFromError(err)
102+
}
103+
104+
return commands.HandleVErrAndExitCode(verr, usage)
105+
}

go/cmd/dolt/commands/ci/init.go

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// Copyright 2024 Dolthub, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package ci
16+
17+
import (
18+
"context"
19+
"fmt"
20+
21+
"github.com/dolthub/dolt/go/libraries/doltcore/env/actions/dolt_ci"
22+
23+
"github.com/dolthub/dolt/go/cmd/dolt/cli"
24+
"github.com/dolthub/dolt/go/cmd/dolt/commands"
25+
"github.com/dolthub/dolt/go/cmd/dolt/errhand"
26+
"github.com/dolthub/dolt/go/libraries/doltcore/env"
27+
"github.com/dolthub/dolt/go/libraries/doltcore/sqle"
28+
"github.com/dolthub/dolt/go/libraries/doltcore/table/editor"
29+
"github.com/dolthub/dolt/go/libraries/utils/argparser"
30+
)
31+
32+
var initDocs = cli.CommandDocumentationContent{
33+
ShortDesc: "Creates database tables used to store continuous integration configuration",
34+
LongDesc: "Creates database tables used to store continuous integration configuration",
35+
Synopsis: []string{
36+
"{{.LessThan}}init{{.GreaterThan}}",
37+
},
38+
}
39+
40+
type InitCmd struct{}
41+
42+
// Name implements cli.Command.
43+
func (cmd InitCmd) Name() string {
44+
return "init"
45+
}
46+
47+
// Description implements cli.Command.
48+
func (cmd InitCmd) Description() string {
49+
return initDocs.ShortDesc
50+
}
51+
52+
// RequiresRepo implements cli.Command.
53+
func (cmd InitCmd) RequiresRepo() bool {
54+
return true
55+
}
56+
57+
// Docs implements cli.Command.
58+
func (cmd InitCmd) Docs() *cli.CommandDocumentation {
59+
ap := cmd.ArgParser()
60+
return cli.NewCommandDocumentation(initDocs, ap)
61+
}
62+
63+
// Hidden should return true if this command should be hidden from the help text
64+
func (cmd InitCmd) Hidden() bool {
65+
return true
66+
}
67+
68+
// ArgParser implements cli.Command.
69+
func (cmd InitCmd) ArgParser() *argparser.ArgParser {
70+
ap := argparser.NewArgParserWithMaxArgs(cmd.Name(), 0)
71+
return ap
72+
}
73+
74+
// Exec implements cli.Command.
75+
func (cmd InitCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
76+
ap := cmd.ArgParser()
77+
_, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, initDocs, ap))
78+
79+
if !cli.CheckEnvIsValid(dEnv) {
80+
return 1
81+
}
82+
83+
_, sqlCtx, closeFunc, err := cliCtx.QueryEngine(ctx)
84+
if err != nil {
85+
return commands.HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage)
86+
}
87+
if closeFunc != nil {
88+
defer closeFunc()
89+
}
90+
91+
db, err := newDatabase(sqlCtx, sqlCtx.GetCurrentDatabase(), dEnv, false)
92+
if err != nil {
93+
return commands.HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage)
94+
}
95+
96+
name, email, err := env.GetNameAndEmail(dEnv.Config)
97+
if err != nil {
98+
return commands.HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage)
99+
}
100+
101+
hasTables, err := dolt_ci.HasDoltCITables(sqlCtx)
102+
if err != nil {
103+
return commands.HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage)
104+
}
105+
106+
if hasTables {
107+
return commands.HandleVErrAndExitCode(errhand.VerboseErrorFromError(fmt.Errorf("dolt ci has already been initialized")), usage)
108+
}
109+
110+
var verr errhand.VerboseError
111+
err = dolt_ci.CreateDoltCITables(sqlCtx, db, name, email)
112+
if err != nil {
113+
verr = errhand.VerboseErrorFromError(err)
114+
}
115+
116+
return commands.HandleVErrAndExitCode(verr, usage)
117+
}
118+
119+
func newDatabase(ctx context.Context, name string, dEnv *env.DoltEnv, useBulkEditor bool) (sqle.Database, error) {
120+
deaf := dEnv.DbEaFactory()
121+
if useBulkEditor {
122+
deaf = dEnv.BulkDbEaFactory()
123+
}
124+
tmpDir, err := dEnv.TempTableFilesDir()
125+
if err != nil {
126+
return sqle.Database{}, err
127+
}
128+
opts := editor.Options{
129+
Deaf: deaf,
130+
Tempdir: tmpDir,
131+
}
132+
return sqle.NewDatabase(ctx, name, dEnv.DbData(), opts)
133+
}

go/cmd/dolt/commands/diff.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,12 @@ func diffRows(
14011401
toSch = pkSch.Schema
14021402
}
14031403

1404-
unionSch := unionSchemas(fromSch, toSch)
1404+
var unionSch sql.Schema
1405+
if fromSch.Equals(toSch) {
1406+
unionSch = fromSch
1407+
} else {
1408+
unionSch = unionSchemas(fromSch, toSch)
1409+
}
14051410

14061411
// We always instantiate a RowWriter in case the diffWriter needs it to close off any work from schema output
14071412
rowWriter, err := dw.RowWriter(fromTableInfo, toTableInfo, tableSummary, unionSch)
@@ -1561,13 +1566,13 @@ func unionSchemas(s1 sql.Schema, s2 sql.Schema) sql.Schema {
15611566
//
15621567
// Note this is only for printing the diff. This is not robust for other purposes.
15631568
func chooseMostFlexibleType(origA, origB sql.Type) sql.Type {
1564-
if origA == origB {
1565-
return origA
1566-
}
1567-
15681569
at := origA.Type()
15691570
bt := origB.Type()
15701571

1572+
if at == bt {
1573+
return origA
1574+
}
1575+
15711576
// If both are numbers, we'll take the float.
15721577
if sqltypes.IsIntegral(at) && sqltypes.IsFloat(bt) {
15731578
return origB

go/cmd/dolt/dolt.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"github.com/dolthub/dolt/go/cmd/dolt/cli"
4444
"github.com/dolthub/dolt/go/cmd/dolt/commands"
4545
"github.com/dolthub/dolt/go/cmd/dolt/commands/admin"
46+
"github.com/dolthub/dolt/go/cmd/dolt/commands/ci"
4647
"github.com/dolthub/dolt/go/cmd/dolt/commands/cnfcmds"
4748
"github.com/dolthub/dolt/go/cmd/dolt/commands/credcmds"
4849
"github.com/dolthub/dolt/go/cmd/dolt/commands/cvcmds"
@@ -126,6 +127,7 @@ var doltSubCommands = []cli.Command{
126127
commands.ReflogCmd{},
127128
commands.RebaseCmd{},
128129
commands.ArchiveCmd{},
130+
ci.Commands,
129131
}
130132

131133
var commandsWithoutCliCtx = []cli.Command{
@@ -166,6 +168,7 @@ var commandsWithoutGlobalArgSupport = []cli.Command{
166168
sqlserver.SqlServerCmd{VersionStr: doltversion.Version},
167169
commands.VersionCmd{VersionStr: doltversion.Version},
168170
commands.ConfigCmd{},
171+
ci.Commands,
169172
}
170173

171174
// commands that do not need write access for the current directory

go/cmd/dolt/doltversion/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
package doltversion
1717

1818
const (
19-
Version = "1.43.11"
19+
Version = "1.43.13"
2020
)

go/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ require (
5757
github.com/cespare/xxhash/v2 v2.2.0
5858
github.com/creasty/defaults v1.6.0
5959
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
60-
github.com/dolthub/go-mysql-server v0.18.2-0.20241104142123-e00c563047c0
60+
github.com/dolthub/go-mysql-server v0.18.2-0.20241106010546-3281d09c1f15
6161
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63
6262
github.com/dolthub/swiss v0.1.0
6363
github.com/goccy/go-json v0.10.2

go/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
183183
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
184184
github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662 h1:aC17hZD6iwzBwwfO5M+3oBT5E5gGRiQPdn+vzpDXqIA=
185185
github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662/go.mod h1:KPUcpx070QOfJK1gNe0zx4pA5sicIK1GMikIGLKC168=
186-
github.com/dolthub/go-mysql-server v0.18.2-0.20241104142123-e00c563047c0 h1:89pFCcn78El3hYvNK11Vx9ez2bQAGSrMu6CLFO0BdXQ=
187-
github.com/dolthub/go-mysql-server v0.18.2-0.20241104142123-e00c563047c0/go.mod h1:0xWs/FBE4xlhlOsAWoGh24SDRHemT7/U1nApu7SNRXg=
186+
github.com/dolthub/go-mysql-server v0.18.2-0.20241106010546-3281d09c1f15 h1:VGjaqZKfys8GeaI5uIaKr9y4XZbqMWlA5DJcgfiMHl8=
187+
github.com/dolthub/go-mysql-server v0.18.2-0.20241106010546-3281d09c1f15/go.mod h1:0xWs/FBE4xlhlOsAWoGh24SDRHemT7/U1nApu7SNRXg=
188188
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
189189
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
190190
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE=

go/libraries/doltcore/doltdb/doltdb.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ func LoadDoltDBWithParams(ctx context.Context, nbf *types.NomsBinFormat, urlStr
141141
if err != nil {
142142
return nil, err
143143
}
144+
144145
return &DoltDB{db: hooksDatabase{Database: db}, vrw: vrw, ns: ns, databaseName: name}, nil
145146
}
146147

0 commit comments

Comments
 (0)