Merge main

This commit is contained in:
milogreg
2024-12-09 15:13:38 -08:00
parent 5f4f2d140d
commit 698cc6356c
43 changed files with 283 additions and 279 deletions

View File

@@ -84,9 +84,9 @@ jobs:
run: |
latest=$(git rev-parse HEAD)
echo "commitish=$latest" >> $GITHUB_OUTPUT
GO_BUILD_VERSION=1.22 go/utils/publishrelease/buildpgobinaries.sh
GO_BUILD_VERSION=1.23.3 go/utils/publishrelease/buildpgobinaries.sh
env:
GO_BUILD_VERSION: "1.22"
GO_BUILD_VERSION: "1.23.3"
PROFILE: ${{ format('{0}/dolt-cpu-profile.pprof', github.workspace) }}
- name: Create Release
id: create_release

View File

@@ -41,13 +41,11 @@ type commandLineServerConfig struct {
autoCommit bool
doltTransactionCommit bool
maxConnections uint64
queryParallelism int
tlsKey string
tlsCert string
requireSecureTransport bool
maxLoggedQueryLen int
shouldEncodeLoggedQuery bool
persistenceBehavior string
privilegeFilePath string
branchControlFilePath string
allowCleartextPasswords bool
@@ -72,8 +70,6 @@ func DefaultCommandLineServerConfig() *commandLineServerConfig {
logLevel: servercfg.DefaultLogLevel,
autoCommit: servercfg.DefaultAutoCommit,
maxConnections: servercfg.DefaultMaxConnections,
queryParallelism: servercfg.DefaultQueryParallelism,
persistenceBehavior: servercfg.DefaultPersistenceBahavior,
dataDir: servercfg.DefaultDataDir,
cfgDir: filepath.Join(servercfg.DefaultDataDir, servercfg.DefaultCfgDir),
privilegeFilePath: filepath.Join(servercfg.DefaultDataDir, servercfg.DefaultCfgDir, servercfg.DefaultPrivilegeFilePath),
@@ -124,10 +120,6 @@ func NewCommandLineConfig(creds *cli.UserPassword, apr *argparser.ArgParseResult
config.WithRemotesapiReadOnly(&val)
}
if persistenceBehavior, ok := apr.GetValue(persistenceBehaviorFlag); ok {
config.withPersistenceBehavior(persistenceBehavior)
}
if timeoutStr, ok := apr.GetValue(timeoutFlag); ok {
timeout, err := strconv.ParseUint(timeoutStr, 10, 64)
@@ -156,10 +148,6 @@ func NewCommandLineConfig(creds *cli.UserPassword, apr *argparser.ArgParseResult
config.withDataDir(dataDir)
}
if queryParallelism, ok := apr.GetInt(queryParallelismFlag); ok {
config.withQueryParallelism(queryParallelism)
}
if maxConnections, ok := apr.GetInt(maxConnectionsFlag); ok {
config.withMaxConnections(uint64(maxConnections))
}
@@ -236,16 +224,6 @@ func (cfg *commandLineServerConfig) MaxConnections() uint64 {
return cfg.maxConnections
}
// QueryParallelism returns the parallelism that should be used by the go-mysql-server analyzer
func (cfg *commandLineServerConfig) QueryParallelism() int {
return cfg.queryParallelism
}
// PersistenceBehavior returns whether to autoload persisted server configuration
func (cfg *commandLineServerConfig) PersistenceBehavior() string {
return cfg.persistenceBehavior
}
// TLSKey returns a path to the servers PEM-encoded private TLS key. "" if there is none.
func (cfg *commandLineServerConfig) TLSKey() string {
return cfg.tlsKey
@@ -402,12 +380,6 @@ func (cfg *commandLineServerConfig) withMaxConnections(maxConnections uint64) *c
return cfg
}
// withQueryParallelism updates the query parallelism and returns the called `*commandLineServerConfig`, which is useful for chaining calls.
func (cfg *commandLineServerConfig) withQueryParallelism(queryParallelism int) *commandLineServerConfig {
cfg.queryParallelism = queryParallelism
return cfg
}
// withDataDir updates the path to a directory to use as the data dir.
func (cfg *commandLineServerConfig) withDataDir(dataDir string) *commandLineServerConfig {
cfg.dataDir = dataDir
@@ -420,12 +392,6 @@ func (cfg *commandLineServerConfig) withCfgDir(cfgDir string) *commandLineServer
return cfg
}
// withPersistenceBehavior updates persistence behavior of system globals on server init
func (cfg *commandLineServerConfig) withPersistenceBehavior(persistenceBehavior string) *commandLineServerConfig {
cfg.persistenceBehavior = persistenceBehavior
return cfg
}
// withPrivilegeFilePath updates the path to the file which contains all needed privilege information in the form of a JSON string
func (cfg *commandLineServerConfig) withPrivilegeFilePath(privFilePath string) *commandLineServerConfig {
cfg.privilegeFilePath = privFilePath

View File

@@ -956,18 +956,9 @@ func getConfigFromServerConfig(serverConfig servercfg.ServerConfig) (server.Conf
return server.Config{}, err
}
// if persist is 'load' we use currently set persisted global variable,
// else if 'ignore' we set persisted global variable to current value from serverConfig
if serverConfig.PersistenceBehavior() == servercfg.LoadPerisistentGlobals {
serverConf, err = serverConf.NewConfig()
if err != nil {
return server.Config{}, err
}
} else {
err = sql.SystemVariables.SetGlobal("max_connections", serverConfig.MaxConnections())
if err != nil {
return server.Config{}, err
}
serverConf, err = serverConf.NewConfig()
if err != nil {
return server.Config{}, err
}
// Do not set the value of Version. Let it default to what go-mysql-server uses. This should be equivalent

View File

@@ -45,7 +45,6 @@ const (
configFileFlag = "config"
queryParallelismFlag = "query-parallelism"
maxConnectionsFlag = "max-connections"
persistenceBehaviorFlag = "persistence-behavior"
allowCleartextPasswordsFlag = "allow-cleartext-passwords"
socketFlag = "socket"
remotesapiPortFlag = "remotesapi-port"
@@ -173,7 +172,6 @@ func (cmd SqlServerCmd) ArgParserWithName(name string) *argparser.ArgParser {
ap.SupportsFlag(noAutoCommitFlag, "", "Set @@autocommit = off for the server.")
ap.SupportsInt(queryParallelismFlag, "", "num-go-routines", "Deprecated, no effect in current versions of Dolt")
ap.SupportsInt(maxConnectionsFlag, "", "max-connections", fmt.Sprintf("Set the number of connections handled by the server. Defaults to `%d`.", serverConfig.MaxConnections()))
ap.SupportsString(persistenceBehaviorFlag, "", "persistence-behavior", fmt.Sprintf("Indicate whether to `load` or `ignore` persisted global variables. Defaults to `%s`.", serverConfig.PersistenceBehavior()))
ap.SupportsString(commands.PrivsFilePathFlag, "", "privilege file", "Path to a file to load and store users and grants. Defaults to `$doltcfg-dir/privileges.db`. Will be created as needed.")
ap.SupportsString(commands.BranchCtrlPathFlag, "", "branch control file", "Path to a file to load and store branch control permissions. Defaults to `$doltcfg-dir/branch_control.db`. Will be created as needed.")
ap.SupportsString(allowCleartextPasswordsFlag, "", "allow-cleartext-passwords", "Allows use of cleartext passwords. Defaults to false.")

View File

@@ -16,5 +16,5 @@
package doltversion
const (
Version = "1.43.20"
Version = "1.44.1"
)

View File

@@ -15,7 +15,7 @@ require (
github.com/dolthub/fslock v0.0.3
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81
github.com/dolthub/vitess v0.0.0-20241126223332-cd8f828f26ac
github.com/dolthub/vitess v0.0.0-20241209181212-588631aba4be
github.com/dustin/go-humanize v1.0.1
github.com/fatih/color v1.13.0
github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568
@@ -57,7 +57,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0
github.com/creasty/defaults v1.6.0
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-mysql-server v0.18.2-0.20241203001635-29d50967b518
github.com/dolthub/go-mysql-server v0.18.2-0.20241209182739-d644619dc9ed
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63
github.com/dolthub/swiss v0.1.0
github.com/goccy/go-json v0.10.2
@@ -170,4 +170,4 @@ require (
replace github.com/dolthub/dolt/go/gen/proto/dolt/services/eventsapi => ./gen/proto/dolt/services/eventsapi
go 1.22.2
go 1.23.3

View File

@@ -183,8 +183,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662 h1:aC17hZD6iwzBwwfO5M+3oBT5E5gGRiQPdn+vzpDXqIA=
github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662/go.mod h1:KPUcpx070QOfJK1gNe0zx4pA5sicIK1GMikIGLKC168=
github.com/dolthub/go-mysql-server v0.18.2-0.20241203001635-29d50967b518 h1:aqDEdL6NI1A2RBEoVr+d41yGLiH6ww1YhIsoO1ydV70=
github.com/dolthub/go-mysql-server v0.18.2-0.20241203001635-29d50967b518/go.mod h1:QdaXQKE8XFwM4P1yN14m2eydx4V2xyuqpQp4tmNoXzQ=
github.com/dolthub/go-mysql-server v0.18.2-0.20241209182739-d644619dc9ed h1:YlXOo9xfRRglBrg+OvAFpBNohzWtK3YQ7SnTZNTbYZ0=
github.com/dolthub/go-mysql-server v0.18.2-0.20241209182739-d644619dc9ed/go.mod h1:Ra4lA9OjCy9J5tWPn05IBBlODnwaXZc8j+cChvfN/9Q=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE=
@@ -197,8 +197,8 @@ github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81 h1:7/v8q9X
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81/go.mod h1:siLfyv2c92W1eN/R4QqG/+RjjX5W2+gCTRjZxBjI3TY=
github.com/dolthub/swiss v0.1.0 h1:EaGQct3AqeP/MjASHLiH6i4TAmgbG/c4rA6a1bzCOPc=
github.com/dolthub/swiss v0.1.0/go.mod h1:BeucyB08Vb1G9tumVN3Vp/pyY4AMUnr9p7Rz7wJ7kAQ=
github.com/dolthub/vitess v0.0.0-20241126223332-cd8f828f26ac h1:A0U/OdIqdCkAV0by7MVBbnSyZBsa94ZjIZxx7PhjBW4=
github.com/dolthub/vitess v0.0.0-20241126223332-cd8f828f26ac/go.mod h1:alcJgfdyIhFaAiYyEmuDCFSLCzedz3KCaIclLoCUtJg=
github.com/dolthub/vitess v0.0.0-20241209181212-588631aba4be h1:YF+vUXEAMqai036iZPJS2JRKd3pXcCQ1TYcLWBR4boo=
github.com/dolthub/vitess v0.0.0-20241209181212-588631aba4be/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=

View File

@@ -1,6 +1,6 @@
go 1.22.5
go 1.23.3
toolchain go1.22.7
toolchain go1.23.3
use (
.

View File

@@ -19,6 +19,7 @@ import (
goerrors "errors"
"fmt"
"os"
"strings"
"sync/atomic"
flatbuffers "github.com/dolthub/flatbuffers/v23/go"
@@ -243,7 +244,7 @@ func CheckAccess(ctx context.Context, flags Permissions) error {
user := branchAwareSession.GetUser()
host := branchAwareSession.GetHost()
database := branchAwareSession.GetCurrentDatabase()
database := getDatabaseNameOnly(branchAwareSession.GetCurrentDatabase())
branch, err := branchAwareSession.GetBranch()
if err != nil {
return err
@@ -277,7 +278,7 @@ func CanCreateBranch(ctx context.Context, branchName string) error {
user := branchAwareSession.GetUser()
host := branchAwareSession.GetHost()
database := branchAwareSession.GetCurrentDatabase()
database := getDatabaseNameOnly(branchAwareSession.GetCurrentDatabase())
if controller.Namespace.CanCreate(database, branchName, user, host) {
return nil
}
@@ -304,7 +305,7 @@ func CanDeleteBranch(ctx context.Context, branchName string) error {
user := branchAwareSession.GetUser()
host := branchAwareSession.GetHost()
database := branchAwareSession.GetCurrentDatabase()
database := getDatabaseNameOnly(branchAwareSession.GetCurrentDatabase())
// Get the permissions for the branch, user, and host combination
_, perms := controller.Access.Match(database, branchName, user, host)
// If the user has the write or admin flags, then we allow access
@@ -329,7 +330,7 @@ func AddAdminForContext(ctx context.Context, branchName string) error {
user := branchAwareSession.GetUser()
host := branchAwareSession.GetHost()
database := branchAwareSession.GetCurrentDatabase()
database := getDatabaseNameOnly(branchAwareSession.GetCurrentDatabase())
// Check if we already have admin permissions for the given branch, as there's no need to do another insertion if so
controller.Access.RWMutex.RLock()
_, modPerms := controller.Access.Match(database, branchName, user, host)
@@ -381,3 +382,10 @@ func HasDatabasePrivileges(ctx Context, database string) bool {
sql.PrivilegeType_Insert, sql.PrivilegeType_Update, sql.PrivilegeType_Delete, sql.PrivilegeType_Execute, sql.PrivilegeType_GrantOption)
return hasSuper || isGlobalAdmin || isDatabaseAdmin
}
// getDatabaseNameOnly gets the database name only, which is useful for when the database name includes a revision.
// This is a direct reimplementation of the logic in dsess.SplitRevisionDbName, however we cannot use that function due
// to import cycles.
func getDatabaseNameOnly(dbName string) string {
return strings.SplitN(dbName, "/", 2)[0]
}

View File

@@ -520,9 +520,6 @@ func (td TableDelta) HasPrimaryKeySetChanged() bool {
}
func (td TableDelta) HasChanges() (bool, error) {
fromString := td.FromTable.DebugString(context.Background(), td.FromTable.NodeStore())
toString := td.ToTable.DebugString(context.Background(), td.ToTable.NodeStore())
_, _ = fromString, toString
hashChanged, err := td.HasHashChanged()
if err != nil {
return false, err

View File

@@ -20,13 +20,9 @@ import (
"fmt"
"unicode"
"github.com/dolthub/go-mysql-server/sql"
gmstypes "github.com/dolthub/go-mysql-server/sql/types"
"github.com/dolthub/dolt/go/libraries/doltcore/conflict"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb/durable"
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
"github.com/dolthub/dolt/go/libraries/doltcore/schema/typeinfo"
"github.com/dolthub/dolt/go/store/hash"
"github.com/dolthub/dolt/go/store/prolly/tree"
"github.com/dolthub/dolt/go/store/types"
@@ -35,8 +31,6 @@ import (
var ErrNoConflictsResolved = errors.New("no conflicts resolved")
const dolt_row_hash_tag = 0
// IsValidTableName checks if name is a valid identifier, and doesn't end with space characters
func IsValidTableName(name string) bool {
if len(name) == 0 || unicode.IsSpace(rune(name[len(name)-1])) {
@@ -351,46 +345,6 @@ func (t *Table) getNomsConflictSchemas(ctx context.Context) (base, sch, mergeSch
return cs.Base, cs.Schema, cs.MergeSchema, nil
}
// GetConstraintViolationsSchema returns this table's dolt_constraint_violations system table schema.
func (t *Table) GetConstraintViolationsSchema(ctx context.Context) (schema.Schema, error) {
sch, err := t.GetSchema(ctx)
if err != nil {
return nil, err
}
typeType, err := typeinfo.FromSqlType(
gmstypes.MustCreateEnumType([]string{"foreign key", "unique index", "check constraint", "not null"}, sql.Collation_Default))
if err != nil {
return nil, err
}
typeCol, err := schema.NewColumnWithTypeInfo("violation_type", schema.DoltConstraintViolationsTypeTag, typeType, true, "", false, "")
if err != nil {
return nil, err
}
infoCol, err := schema.NewColumnWithTypeInfo("violation_info", schema.DoltConstraintViolationsInfoTag, typeinfo.JSONType, false, "", false, "")
if err != nil {
return nil, err
}
colColl := schema.NewColCollection()
// the commit hash or working set hash of the right side during merge
colColl = colColl.Append(schema.NewColumn("from_root_ish", 0, types.StringKind, false))
colColl = colColl.Append(typeCol)
if schema.IsKeyless(sch) {
// If this is a keyless table, we need to add a new column for the keyless table's generated row hash.
// We need to add this internal row hash value, in order to guarantee a unique primary key in the
// constraint violations table.
colColl = colColl.Append(schema.NewColumn("dolt_row_hash", dolt_row_hash_tag, types.BlobKind, true))
} else {
colColl = colColl.Append(sch.GetPKCols().GetColumns()...)
}
colColl = colColl.Append(sch.GetNonPKCols().GetColumns()...)
colColl = colColl.Append(infoCol)
return schema.SchemaFromCols(colColl)
}
// GetConstraintViolations returns a map of all constraint violations for this table, along with a bool indicating
// whether the table has any violations.
func (t *Table) GetConstraintViolations(ctx context.Context) (types.Map, error) {

View File

@@ -25,7 +25,7 @@ import (
"github.com/dolthub/dolt/go/store/val"
)
func NextConstraintViolation(ctx context.Context, itr prolly.ArtifactIter, kd, vd val.TupleDesc, ns tree.NodeStore) (violationType uint64, key sql.Row, value sql.Row, err error) {
func NextConstraintViolation(ctx context.Context, itr prolly.ArtifactIter, kd, vd val.TupleDesc, ns tree.NodeStore) (violationType any, key sql.Row, value sql.Row, err error) {
art, err := itr.Next(ctx)
if err != nil {
return
@@ -56,7 +56,13 @@ func NextConstraintViolation(ctx context.Context, itr prolly.ArtifactIter, kd, v
return MapCVType(art.ArtType), key, value, nil
}
func MapCVType(artifactType prolly.ArtifactType) (outType uint64) {
// MapCVType maps an ArtifactType to value for a sql.Row in the dolt_constraint_violations_* table.
// This is used by Doltgres to convert the ArtifactType to the correct type.
var MapCVType = func(artifactType prolly.ArtifactType) any {
return mapCVType(artifactType)
}
func mapCVType(artifactType prolly.ArtifactType) (outType uint64) {
switch artifactType {
case prolly.ArtifactTypeForeignKeyViol:
outType = uint64(CvType_ForeignKey)
@@ -72,7 +78,16 @@ func MapCVType(artifactType prolly.ArtifactType) (outType uint64) {
return
}
func UnmapCVType(in CvType) (out prolly.ArtifactType) {
// UnmapCVType unmaps a sql.Row value from the dolt_constraint_violations_* table to an ArtifactType.
// This is used by Doltgres to convert a value of a different type to an ArtifactType.
var UnmapCVType = func(in any) (out prolly.ArtifactType) {
if cv, ok := in.(uint64); ok {
return unmapCVType(CvType(cv))
}
panic("invalid type")
}
func unmapCVType(in CvType) (out prolly.ArtifactType) {
switch in {
case CvType_ForeignKey:
out = prolly.ArtifactTypeForeignKeyViol

View File

@@ -50,8 +50,6 @@ const (
DefaultAutoCommit = true
DefaultDoltTransactionCommit = false
DefaultMaxConnections = 100
DefaultQueryParallelism = 0
DefaultPersistenceBahavior = LoadPerisistentGlobals
DefaultDataDir = "."
DefaultCfgDir = ".doltcfg"
DefaultPrivilegeFilePath = "privileges.db"
@@ -64,11 +62,6 @@ const (
DefaultEncodeLoggedQuery = false
)
const (
IgnorePeristentGlobals = "ignore"
LoadPerisistentGlobals = "load"
)
func ptr[T any](t T) *T {
return &t
}
@@ -153,8 +146,6 @@ type ServerConfig interface {
CfgDir() string
// MaxConnections returns the maximum number of simultaneous connections the server will allow. The default is 1
MaxConnections() uint64
// QueryParallelism returns the parallelism that should be used by the go-mysql-server analyzer
QueryParallelism() int
// TLSKey returns a path to the servers PEM-encoded private TLS key. "" if there is none.
TLSKey() string
// TLSCert returns a path to the servers PEM-encoded TLS certificate chain. "" if there is none.
@@ -169,8 +160,6 @@ type ServerConfig interface {
// If true, queries will be logged as base64 encoded strings.
// If false (default behavior), queries will be logged as strings, but newlines and tabs will be replaced with spaces.
ShouldEncodeLoggedQuery() bool
// PersistenceBehavior is "load" if we include persisted system globals on server init
PersistenceBehavior() string
// DisableClientMultiStatements is true if we want the server to not
// process incoming ComQuery packets as if they had multiple queries in
// them, even if the client advertises support for MULTI_STATEMENTS.
@@ -222,7 +211,6 @@ func defaultServerConfigYAML() *YAMLConfig {
BehaviorConfig: BehaviorYAMLConfig{
ReadOnly: ptr(DefaultReadOnly),
AutoCommit: ptr(DefaultAutoCommit),
PersistenceBehavior: ptr(DefaultPersistenceBahavior),
DoltTransactionCommit: ptr(DefaultDoltTransactionCommit),
},
UserConfig: UserYAMLConfig{
@@ -237,7 +225,6 @@ func defaultServerConfigYAML() *YAMLConfig {
WriteTimeoutMillis: ptr(uint64(DefaultTimeout)),
AllowCleartextPasswords: ptr(DefaultAllowCleartextPasswords),
},
PerformanceConfig: PerformanceYAMLConfig{QueryParallelism: ptr(DefaultQueryParallelism)},
DataDirStr: ptr(DefaultDataDir),
CfgDirStr: ptr(filepath.Join(DefaultDataDir, DefaultCfgDir)),
PrivilegeFile: ptr(filepath.Join(DefaultDataDir, DefaultCfgDir, DefaultPrivilegeFilePath)),

View File

@@ -7,7 +7,7 @@ EncodeLoggedQuery *bool 0.0.0 encode_logged_query,omitempty
BehaviorConfig servercfg.BehaviorYAMLConfig 0.0.0 behavior
-ReadOnly *bool 0.0.0 read_only
-AutoCommit *bool 0.0.0 autocommit
-PersistenceBehavior *string 0.0.0 persistence_behavior
-PersistenceBehavior *string 0.0.0 persistence_behavior,omitempty
-DisableClientMultiStatements *bool 0.0.0 disable_client_multi_statements
-DoltTransactionCommit *bool 0.0.0 dolt_transaction_commit
-EventSchedulerStatus *string 1.17.0 event_scheduler,omitempty
@@ -25,8 +25,8 @@ ListenerConfig servercfg.ListenerYAMLConfig 0.0.0 listener
-RequireSecureTransport *bool 0.0.0 require_secure_transport
-AllowCleartextPasswords *bool 0.0.0 allow_cleartext_passwords
-Socket *string 0.0.0 socket,omitempty
PerformanceConfig servercfg.PerformanceYAMLConfig 0.0.0 performance
-QueryParallelism *int 0.0.0 query_parallelism
PerformanceConfig *servercfg.PerformanceYAMLConfig 0.0.0 performance,omitempty
-QueryParallelism *int 0.0.0 query_parallelism,omitempty
DataDirStr *string 0.0.0 data_dir,omitempty
CfgDirStr *string 0.0.0 cfg_dir,omitempty
MetricsConfig servercfg.MetricsYAMLConfig 0.0.0 metrics

View File

@@ -52,8 +52,8 @@ func nillableIntPtr(n int) *int {
type BehaviorYAMLConfig struct {
ReadOnly *bool `yaml:"read_only"`
AutoCommit *bool `yaml:"autocommit"`
// PersistenceBehavior regulates loading persisted system variable configuration.
PersistenceBehavior *string `yaml:"persistence_behavior"`
// PersistenceBehavior is unused, but still present to prevent breaking any YAML configs that still use it.
PersistenceBehavior *string `yaml:"persistence_behavior,omitempty"`
// Disable processing CLIENT_MULTI_STATEMENTS support on the
// sql server. Dolt's handling of CLIENT_MULTI_STATEMENTS is currently
// broken. If a client advertises to support it (mysql cli client
@@ -95,7 +95,8 @@ type ListenerYAMLConfig struct {
// PerformanceYAMLConfig contains configuration parameters for performance tweaking
type PerformanceYAMLConfig struct {
QueryParallelism *int `yaml:"query_parallelism"`
// QueryParallelism is deprecated but still present to prevent breaking YAML config that still uses it
QueryParallelism *int `yaml:"query_parallelism,omitempty"`
}
type MetricsYAMLConfig struct {
@@ -124,20 +125,20 @@ type UserSessionVars struct {
// YAMLConfig is a ServerConfig implementation which is read from a yaml file
type YAMLConfig struct {
LogLevelStr *string `yaml:"log_level,omitempty"`
MaxQueryLenInLogs *int `yaml:"max_logged_query_len,omitempty"`
EncodeLoggedQuery *bool `yaml:"encode_logged_query,omitempty"`
BehaviorConfig BehaviorYAMLConfig `yaml:"behavior"`
UserConfig UserYAMLConfig `yaml:"user"`
ListenerConfig ListenerYAMLConfig `yaml:"listener"`
PerformanceConfig PerformanceYAMLConfig `yaml:"performance"`
DataDirStr *string `yaml:"data_dir,omitempty"`
CfgDirStr *string `yaml:"cfg_dir,omitempty"`
MetricsConfig MetricsYAMLConfig `yaml:"metrics"`
RemotesapiConfig RemotesapiYAMLConfig `yaml:"remotesapi"`
ClusterCfg *ClusterYAMLConfig `yaml:"cluster,omitempty"`
PrivilegeFile *string `yaml:"privilege_file,omitempty"`
BranchControlFile *string `yaml:"branch_control_file,omitempty"`
LogLevelStr *string `yaml:"log_level,omitempty"`
MaxQueryLenInLogs *int `yaml:"max_logged_query_len,omitempty"`
EncodeLoggedQuery *bool `yaml:"encode_logged_query,omitempty"`
BehaviorConfig BehaviorYAMLConfig `yaml:"behavior"`
UserConfig UserYAMLConfig `yaml:"user"`
ListenerConfig ListenerYAMLConfig `yaml:"listener"`
PerformanceConfig *PerformanceYAMLConfig `yaml:"performance,omitempty"`
DataDirStr *string `yaml:"data_dir,omitempty"`
CfgDirStr *string `yaml:"cfg_dir,omitempty"`
MetricsConfig MetricsYAMLConfig `yaml:"metrics"`
RemotesapiConfig RemotesapiYAMLConfig `yaml:"remotesapi"`
ClusterCfg *ClusterYAMLConfig `yaml:"cluster,omitempty"`
PrivilegeFile *string `yaml:"privilege_file,omitempty"`
BranchControlFile *string `yaml:"branch_control_file,omitempty"`
// TODO: Rename to UserVars_
Vars []UserSessionVars `yaml:"user_session_vars"`
SystemVars_ map[string]interface{} `yaml:"system_variables,omitempty" minver:"1.11.1"`
@@ -175,37 +176,33 @@ func YamlConfigFromFile(fs filesys.Filesys, path string) (ServerConfig, error) {
}
func ServerConfigAsYAMLConfig(cfg ServerConfig) *YAMLConfig {
systemVars := map[string]interface{}(cfg.SystemVars())
systemVars := cfg.SystemVars()
return &YAMLConfig{
LogLevelStr: ptr(string(cfg.LogLevel())),
MaxQueryLenInLogs: nillableIntPtr(cfg.MaxLoggedQueryLen()),
EncodeLoggedQuery: nillableBoolPtr(cfg.ShouldEncodeLoggedQuery()),
BehaviorConfig: BehaviorYAMLConfig{
ptr(cfg.ReadOnly()),
ptr(cfg.AutoCommit()),
ptr(cfg.PersistenceBehavior()),
ptr(cfg.DisableClientMultiStatements()),
ptr(cfg.DoltTransactionCommit()),
ptr(cfg.EventSchedulerStatus()),
ReadOnly: ptr(cfg.ReadOnly()),
AutoCommit: ptr(cfg.AutoCommit()),
DisableClientMultiStatements: ptr(cfg.DisableClientMultiStatements()),
DoltTransactionCommit: ptr(cfg.DoltTransactionCommit()),
EventSchedulerStatus: ptr(cfg.EventSchedulerStatus()),
},
UserConfig: UserYAMLConfig{
Name: ptr(cfg.User()),
Password: ptr(cfg.Password()),
},
ListenerConfig: ListenerYAMLConfig{
ptr(cfg.Host()),
ptr(cfg.Port()),
ptr(cfg.MaxConnections()),
ptr(cfg.ReadTimeout()),
ptr(cfg.WriteTimeout()),
nillableStrPtr(cfg.TLSKey()),
nillableStrPtr(cfg.TLSCert()),
nillableBoolPtr(cfg.RequireSecureTransport()),
nillableBoolPtr(cfg.AllowCleartextPasswords()),
nillableStrPtr(cfg.Socket()),
},
PerformanceConfig: PerformanceYAMLConfig{
QueryParallelism: nillableIntPtr(cfg.QueryParallelism()),
HostStr: ptr(cfg.Host()),
PortNumber: ptr(cfg.Port()),
MaxConnections: ptr(cfg.MaxConnections()),
ReadTimeoutMillis: ptr(cfg.ReadTimeout()),
WriteTimeoutMillis: ptr(cfg.WriteTimeout()),
TLSKey: nillableStrPtr(cfg.TLSKey()),
TLSCert: nillableStrPtr(cfg.TLSCert()),
RequireSecureTransport: nillableBoolPtr(cfg.RequireSecureTransport()),
AllowCleartextPasswords: nillableBoolPtr(cfg.AllowCleartextPasswords()),
Socket: nillableStrPtr(cfg.Socket()),
},
DataDirStr: ptr(cfg.DataDir()),
CfgDirStr: ptr(cfg.CfgDir()),
@@ -596,15 +593,6 @@ func (cfg YAMLConfig) AllowCleartextPasswords() bool {
return *cfg.ListenerConfig.AllowCleartextPasswords
}
// QueryParallelism returns the parallelism that should be used by the go-mysql-server analyzer
func (cfg YAMLConfig) QueryParallelism() int {
if cfg.PerformanceConfig.QueryParallelism == nil {
return DefaultQueryParallelism
}
return *cfg.PerformanceConfig.QueryParallelism
}
// TLSKey returns a path to the servers PEM-encoded private TLS key. "" if there is none.
func (cfg YAMLConfig) TLSKey() string {
if cfg.ListenerConfig.TLSKey == nil {
@@ -648,14 +636,6 @@ func (cfg YAMLConfig) ShouldEncodeLoggedQuery() bool {
return *cfg.EncodeLoggedQuery
}
// PersistenceBehavior is "load" if we include persisted system globals on server init
func (cfg YAMLConfig) PersistenceBehavior() string {
if cfg.BehaviorConfig.PersistenceBehavior == nil {
return LoadPerisistentGlobals
}
return *cfg.BehaviorConfig.PersistenceBehavior
}
// DataDir is the path to a directory to use as the data dir, both to create new databases and locate existing ones.
func (cfg YAMLConfig) DataDir() string {
if cfg.DataDirStr != nil {

View File

@@ -33,7 +33,6 @@ behavior:
read_only: false
autocommit: true
dolt_transaction_commit: true
persistence_behavior: load
disable_client_multi_statements: false
event_scheduler: ON

View File

@@ -28,15 +28,14 @@ import (
)
// renameTable renames a table with in a RootValue and returns the updated root.
func renameTable(ctx context.Context, root doltdb.RootValue, oldName, newName string) (doltdb.RootValue, error) {
func renameTable(ctx context.Context, root doltdb.RootValue, oldName, newName doltdb.TableName) (doltdb.RootValue, error) {
if newName == oldName {
return root, nil
} else if root == nil {
panic("invalid parameters")
}
// TODO: schema name
return root.RenameTable(ctx, doltdb.TableName{Name: oldName}, doltdb.TableName{Name: newName})
return root.RenameTable(ctx, oldName, newName)
}
// Nullable represents whether a column can have a null value.

View File

@@ -96,7 +96,7 @@ func TestRenameTable(t *testing.T) {
require.NoError(t, err)
beforeSch := schemas[doltdb.TableName{Name: tt.oldName}]
updatedRoot, err := renameTable(ctx, root, tt.oldName, tt.newName)
updatedRoot, err := renameTable(ctx, root, doltdb.TableName{Name: tt.oldName}, doltdb.TableName{Name: tt.newName})
if len(tt.expectedErr) > 0 {
assert.Error(t, err)
assert.Contains(t, err.Error(), tt.expectedErr)

View File

@@ -1726,12 +1726,23 @@ func (db Database) RenameTable(ctx *sql.Context, oldName, newName string) error
return ErrInvalidTableName.New(newName)
}
if _, ok, _ := db.GetTableInsensitive(ctx, newName); ok {
oldNameWithSchema, _, exists, err := resolve.Table(ctx, root, oldName)
if err != nil {
return err
}
if !exists {
return sql.ErrTableNotFound.New(oldName)
}
// TODO: we have no way to rename a table to a different schema, need to change the GMS interface for that
newNameWithSchema := doltdb.TableName{Schema: oldNameWithSchema.Schema, Name: newName}
_, exists, err = root.ResolveTableName(ctx, newNameWithSchema)
if exists {
return sql.ErrTableAlreadyExists.New(newName)
}
newRoot, err := renameTable(ctx, root, oldName, newName)
newRoot, err := renameTable(ctx, root, oldNameWithSchema, newNameWithSchema)
if err != nil {
return err
}

View File

@@ -42,7 +42,7 @@ func newNomsCVTable(ctx *sql.Context, tblName doltdb.TableName, root doltdb.Root
if err != nil {
return nil, err
}
cvSch, err := tbl.GetConstraintViolationsSchema(ctx)
cvSch, err := getConstraintViolationsSchema(ctx, tbl, tblName, root)
if err != nil {
return nil, err
}

View File

@@ -15,23 +15,81 @@
package dtables
import (
"context"
"encoding/json"
"github.com/dolthub/go-mysql-server/sql"
gmstypes "github.com/dolthub/go-mysql-server/sql/types"
"github.com/dolthub/vitess/go/sqltypes"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb/durable"
"github.com/dolthub/dolt/go/libraries/doltcore/merge"
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
"github.com/dolthub/dolt/go/libraries/doltcore/schema/typeinfo"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/index"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/sqlutil"
"github.com/dolthub/dolt/go/store/hash"
"github.com/dolthub/dolt/go/store/pool"
"github.com/dolthub/dolt/go/store/prolly"
"github.com/dolthub/dolt/go/store/prolly/tree"
"github.com/dolthub/dolt/go/store/types"
"github.com/dolthub/dolt/go/store/val"
)
func getDoltConstraintViolationsBaseSqlSchema() sql.Schema {
return []*sql.Column{
{Name: "from_root_ish", Type: gmstypes.MustCreateStringWithDefaults(sqltypes.VarChar, 1023), PrimaryKey: false, Nullable: true},
{Name: "violation_type", Type: gmstypes.MustCreateEnumType([]string{"foreign key", "unique index", "check constraint", "not null"}, sql.Collation_Default), PrimaryKey: true},
}
}
// GetDoltConstraintViolationsBaseSqlSchema returns the base schema for the dolt_constraint_violations_* system table.
// This is used by Doltgres to update the dolt_constraint_violations_* schema using Doltgres types.
var GetDoltConstraintViolationsBaseSqlSchema = getDoltConstraintViolationsBaseSqlSchema
// getConstraintViolationsSchema returns a table's dolt_constraint_violations system table schema.
func getConstraintViolationsSchema(ctx context.Context, t *doltdb.Table, tn doltdb.TableName, root doltdb.RootValue) (schema.Schema, error) {
sch, err := t.GetSchema(ctx)
if err != nil {
return nil, err
}
baseSch := sql.NewPrimaryKeySchema(GetDoltConstraintViolationsBaseSqlSchema())
baseDoltSch, err := sqlutil.ToDoltSchema(ctx, root, tn, baseSch, root, sql.Collation_Default)
if err != nil {
return nil, err
}
baseColColl := baseDoltSch.GetAllCols()
baseCols := baseColColl.GetColumns()
schSize := sch.GetAllCols().Size()
if schema.IsKeyless(sch) {
// Keyless tables have an additional dolt_row_hash column
schSize += 1
}
cols := make([]schema.Column, 0, baseColColl.Size()+schSize)
cols = append(cols, baseCols[0:2]...)
infoCol, err := schema.NewColumnWithTypeInfo("violation_info", schema.DoltConstraintViolationsInfoTag, typeinfo.JSONType, false, "", false, "")
if err != nil {
return nil, err
}
if schema.IsKeyless(sch) {
// If this is a keyless table, we need to add a new column for the keyless table's generated row hash.
// We need to add this internal row hash value, in order to guarantee a unique primary key in the
// constraint violations table.
cols = append(cols, schema.NewColumn("dolt_row_hash", 0, types.BlobKind, true))
} else {
cols = append(cols, sch.GetPKCols().GetColumns()...)
}
cols = append(cols, sch.GetNonPKCols().GetColumns()...)
cols = append(cols, infoCol)
return schema.NewSchema(schema.NewColCollection(cols...), nil, schema.Collation_Default, nil, nil)
}
func newProllyCVTable(ctx *sql.Context, tblName doltdb.TableName, root doltdb.RootValue, rs RootSetter) (sql.Table, error) {
var tbl *doltdb.Table
var err error
@@ -39,7 +97,7 @@ func newProllyCVTable(ctx *sql.Context, tblName doltdb.TableName, root doltdb.Ro
if err != nil {
return nil, err
}
cvSch, err := tbl.GetConstraintViolationsSchema(ctx)
cvSch, err := getConstraintViolationsSchema(ctx, tbl, tblName, root)
if err != nil {
return nil, err
}
@@ -278,7 +336,7 @@ func (d *prollyCVDeleter) Delete(ctx *sql.Context, r sql.Row) error {
d.kb.PutCommitAddr(d.kd.Count()-2, h)
// Finally the artifact type
artType := merge.UnmapCVType(merge.CvType(r[1].(uint64)))
artType := merge.UnmapCVType(r[1])
d.kb.PutUint8(d.kd.Count()-1, uint8(artType))
key := d.kb.Build(d.pool)

View File

@@ -41,16 +41,24 @@ func (mst MergeStatusTable) String() string {
return mst.tableName
}
func (mst MergeStatusTable) Schema() sql.Schema {
func getDoltMergeStatusSchema(dbName, tableName string) sql.Schema {
return []*sql.Column{
{Name: "is_merging", Type: types.Boolean, Source: mst.tableName, PrimaryKey: false, Nullable: false, DatabaseSource: mst.dbName},
{Name: "source", Type: types.Text, Source: mst.tableName, PrimaryKey: false, Nullable: true, DatabaseSource: mst.dbName},
{Name: "source_commit", Type: types.Text, Source: mst.tableName, PrimaryKey: false, Nullable: true, DatabaseSource: mst.dbName},
{Name: "target", Type: types.Text, Source: mst.tableName, PrimaryKey: false, Nullable: true, DatabaseSource: mst.dbName},
{Name: "unmerged_tables", Type: types.Text, Source: mst.tableName, PrimaryKey: false, Nullable: true, DatabaseSource: mst.dbName},
{Name: "is_merging", Type: types.Boolean, Source: tableName, PrimaryKey: false, Nullable: false, DatabaseSource: dbName},
{Name: "source", Type: types.Text, Source: tableName, PrimaryKey: false, Nullable: true, DatabaseSource: dbName},
{Name: "source_commit", Type: types.Text, Source: tableName, PrimaryKey: false, Nullable: true, DatabaseSource: dbName},
{Name: "target", Type: types.Text, Source: tableName, PrimaryKey: false, Nullable: true, DatabaseSource: dbName},
{Name: "unmerged_tables", Type: types.Text, Source: tableName, PrimaryKey: false, Nullable: true, DatabaseSource: dbName},
}
}
// GetDoltMergeStatusSchema returns the schema of the dolt_merge_status system table. This is used
// by Doltgres to update the dolt_merge_status schema using Doltgres types.
var GetDoltMergeStatusSchema = getDoltMergeStatusSchema
func (mst MergeStatusTable) Schema() sql.Schema {
return GetDoltMergeStatusSchema(mst.dbName, mst.tableName)
}
func (mst MergeStatusTable) Collation() sql.CollationID {
return sql.Collation_Default
}

View File

@@ -61,14 +61,22 @@ func (st StatusTable) String() string {
return st.tableName
}
func (st StatusTable) Schema() sql.Schema {
func getDoltStatusSchema(tableName string) sql.Schema {
return []*sql.Column{
{Name: "table_name", Type: types.Text, Source: st.tableName, PrimaryKey: true, Nullable: false},
{Name: "staged", Type: types.Boolean, Source: st.tableName, PrimaryKey: true, Nullable: false},
{Name: "status", Type: types.Text, Source: st.tableName, PrimaryKey: true, Nullable: false},
{Name: "table_name", Type: types.Text, Source: tableName, PrimaryKey: true, Nullable: false},
{Name: "staged", Type: types.Boolean, Source: tableName, PrimaryKey: true, Nullable: false},
{Name: "status", Type: types.Text, Source: tableName, PrimaryKey: true, Nullable: false},
}
}
// GetDoltStatusSchema returns the schema of the dolt_status system table. This is used
// by Doltgres to update the dolt_status schema using Doltgres types.
var GetDoltStatusSchema = getDoltStatusSchema
func (st StatusTable) Schema() sql.Schema {
return GetDoltStatusSchema(st.tableName)
}
func (st StatusTable) Collation() sql.CollationID {
return sql.Collation_Default
}

View File

@@ -409,6 +409,9 @@ func NewWorkspaceTable(ctx *sql.Context, workspaceTableName string, tableName do
sch := sql.NewPrimaryKeySchema(GetDoltWorkspaceBaseSqlSchema())
baseDoltSch, err := sqlutil.ToDoltSchema(ctx, head, tableName, sch, head, sql.Collation_Default)
if err != nil {
return nil, err
}
totalSch, err := workspaceSchema(fromSch, toSch, baseDoltSch)
if err != nil {

View File

@@ -683,6 +683,7 @@ func RunDoltRevisionDbScriptsTest(t *testing.T, h DoltEnginetestHarness) {
require.NoError(t, err)
defer e.Close()
ctx := h.NewContext()
ctx.SetCurrentDatabase("mydb")
setupScripts := []setup.SetupScript{
{"create table t01 (pk int primary key, c1 int)"},

View File

@@ -270,6 +270,10 @@ func (d *DoltHarness) NewEngine(t *testing.T) (enginetest.QueryEngine, error) {
if err != nil {
return nil, err
}
// Get a fresh session after running setup scripts, since some setup scripts can change the session state
d.session, err = dsess.NewDoltSession(enginetest.NewBaseSession(), d.provider, d.multiRepoEnv.Config(), d.branchControl, d.statsPro, writer.NewWriteSession)
require.NoError(t, err)
}
if d.configureStats {
@@ -304,16 +308,14 @@ func (d *DoltHarness) NewEngine(t *testing.T) (enginetest.QueryEngine, error) {
d.engine.Analyzer.Catalog.MySQLDb.AddRootAccount()
d.engine.Analyzer.Catalog.StatsProvider = statspro.NewProvider(d.provider.(*sqle.DoltDatabaseProvider), statsnoms.NewNomsStatsFactory(d.multiRepoEnv.RemoteDialProvider()))
// Get a fresh session if we are reusing the engine
if !initializeEngine {
var err error
d.session, err = dsess.NewDoltSession(enginetest.NewBaseSession(), d.provider, d.multiRepoEnv.Config(), d.branchControl, d.statsPro, writer.NewWriteSession)
require.NoError(t, err)
}
var err error
ctx := enginetest.NewContext(d)
e, err := enginetest.RunSetupScripts(ctx, d.engine, d.resetScripts(), d.SupportsNativeIndexCreation())
// Get a fresh session after running setup scripts, since some setup scripts can change the session state
d.session, err = dsess.NewDoltSession(enginetest.NewBaseSession(), d.provider, d.multiRepoEnv.Config(), d.branchControl, d.statsPro, writer.NewWriteSession)
require.NoError(t, err)
return e, err
}

View File

@@ -2076,7 +2076,7 @@ var HistorySystemTableScriptTests = []queries.ScriptTest{
},
},
{
Query: "explain select pk, c from dolt_history_t1 where pk = 3",
Query: "explain plan select pk, c from dolt_history_t1 where pk = 3",
Expected: []sql.Row{
{"Filter"},
{" ├─ (dolt_history_t1.pk = 3)"},
@@ -2087,7 +2087,7 @@ var HistorySystemTableScriptTests = []queries.ScriptTest{
},
},
{
Query: "explain select pk, c from dolt_history_t1 where pk = 3 and committer = 'someguy'",
Query: "explain plan select pk, c from dolt_history_t1 where pk = 3 and committer = 'someguy'",
Expected: []sql.Row{
{"Project"},
{" ├─ columns: [dolt_history_t1.pk, dolt_history_t1.c]"},
@@ -2151,7 +2151,7 @@ var HistorySystemTableScriptTests = []queries.ScriptTest{
},
},
{
Query: "explain select pk, c from dolt_history_t1 where c = 4",
Query: "explain plan select pk, c from dolt_history_t1 where c = 4",
Expected: []sql.Row{
{"Filter"},
{" ├─ (dolt_history_t1.c = 4)"},
@@ -2162,7 +2162,7 @@ var HistorySystemTableScriptTests = []queries.ScriptTest{
},
},
{
Query: "explain select pk, c from dolt_history_t1 where c = 10 and committer = 'someguy'",
Query: "explain plan select pk, c from dolt_history_t1 where c = 10 and committer = 'someguy'",
Expected: []sql.Row{
{"Project"},
{" ├─ columns: [dolt_history_t1.pk, dolt_history_t1.c]"},

View File

@@ -1661,7 +1661,7 @@ var MergeScripts = []queries.ScriptTest{
Expected: []sql.Row{{doltCommit, 1, 0, "merge successful"}},
},
{
Query: "INSERT INTO t VALUES (NULL,5),(6,6),(NULL,7);",
Query: "INSERT INTO t(c0) VALUES (5),(6),(7);",
Expected: []sql.Row{{types.OkResult{RowsAffected: 3, InsertID: 5}}},
},
{
@@ -1698,7 +1698,7 @@ var MergeScripts = []queries.ScriptTest{
Expected: []sql.Row{{doltCommit, 0, 0, "merge successful"}},
},
{
Query: "INSERT INTO t VALUES (NULL,6),(7,7),(NULL,8);",
Query: "INSERT INTO t(c0) VALUES (6),(7),(8);",
Expected: []sql.Row{{types.OkResult{RowsAffected: 3, InsertID: 6}}},
},
{

View File

@@ -275,7 +275,7 @@ type pullBehavior bool
const pullBehaviorFastForward pullBehavior = false
const pullBehaviorForcePull pullBehavior = true
// pullBranches pulls the remote branches named and returns the map of their hashes keyed by branch path.
// pullBranches pulls the named remote branches and tags and returns the map of their hashes keyed by ref ID.
func pullBranches(
ctx *sql.Context,
rrd ReadReplicaDatabase,
@@ -283,17 +283,17 @@ func pullBranches(
localRefs []doltdb.RefWithHash,
behavior pullBehavior,
) (map[string]doltdb.RefWithHash, error) {
localRefsByPath := make(map[string]doltdb.RefWithHash)
remoteRefsByPath := make(map[string]doltdb.RefWithHash)
localRefsById := make(map[string]doltdb.RefWithHash)
remoteRefsById := make(map[string]doltdb.RefWithHash)
remoteHashes := make([]hash.Hash, len(remoteRefs))
for i, b := range remoteRefs {
remoteRefsByPath[b.Ref.GetPath()] = b
remoteRefsById[b.Ref.String()] = b
remoteHashes[i] = b.Hash
}
for _, b := range localRefs {
localRefsByPath[b.Ref.GetPath()] = b
localRefsById[b.Ref.String()] = b
}
// XXX: Our view of which remote branches to pull and what to set the
@@ -311,7 +311,7 @@ func pullBranches(
REFS: // every successful pass through the loop below must end with `continue REFS` to get out of the retry loop
for _, remoteRef := range remoteRefs {
trackingRef := ref.NewRemoteRef(rrd.remote.Name, remoteRef.Ref.GetPath())
localRef, localRefExists := localRefsByPath[remoteRef.Ref.GetPath()]
localRef, localRefExists := localRefsById[remoteRef.Ref.String()]
// loop on optimistic lock failures
OPTIMISTIC_RETRY:
@@ -378,7 +378,7 @@ func pullBranches(
return nil, err
}
return remoteRefsByPath, nil
return remoteRefsById, nil
}
// expandWildcardBranchPattern evaluates |pattern| and returns a list of branch names from the source database that

View File

@@ -68,6 +68,8 @@ func NewParquetReader(vrw types.ValueReadWriter, fr source.ParquetFile, sche sch
return nil, err
}
rootName := pr.SchemaHandler.GetRootExName()
columns := sche.GetAllCols().GetColumns()
num := pr.GetNumRows()
@@ -75,7 +77,7 @@ func NewParquetReader(vrw types.ValueReadWriter, fr source.ParquetFile, sche sch
data := make(map[string][]interface{})
var colName []string
for _, col := range columns {
colData, _, _, cErr := pr.ReadColumnByPath(common.ReformPathStr(fmt.Sprintf("parquet_go_root.%s", col.Name)), num)
colData, _, _, cErr := pr.ReadColumnByPath(common.ReformPathStr(fmt.Sprintf("%s.%s", rootName, col.Name)), num)
if cErr != nil {
return nil, fmt.Errorf("cannot read column: %s", cErr.Error())
}

View File

@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.3-labs
FROM --platform=linux/amd64 golang:1.22-alpine as gobin
FROM --platform=linux/amd64 golang:1.23.3-alpine as gobin
FROM --platform=linux/amd64 ubuntu:22.04
COPY --from=gobin /usr/local/go/ /go/

View File

@@ -20,7 +20,7 @@ RUN apt update -y && \
# install go
WORKDIR /root
ENV GO_VERSION=1.22.1
ENV GO_VERSION=1.23.3
ENV GOPATH=$HOME/go
ENV PATH=$PATH:$GOPATH/bin
ENV PATH=$PATH:$GOPATH/bin:/usr/local/go/bin

View File

@@ -59,7 +59,7 @@ RUN apt update -y && \
# install go
WORKDIR /root
ENV GO_VERSION=1.22.1
ENV GO_VERSION=1.23.3
ENV GOPATH=$HOME/go
ENV PATH=$PATH:$GOPATH/bin
ENV PATH=$PATH:$GOPATH/bin:/usr/local/go/bin

View File

@@ -25,7 +25,7 @@ RUN apt update -y && \
# install go
WORKDIR /root
ENV GO_VERSION=1.22.1
ENV GO_VERSION=1.23.3
ENV GOPATH=$HOME/go
ENV PATH=$PATH:$GOPATH/bin
ENV PATH=$PATH:$GOPATH/bin:/usr/local/go/bin

View File

@@ -333,6 +333,11 @@ SQL
@test "branch-control: Issue #8623" {
# https://github.com/dolthub/dolt/issues/8623
dolt sql <<SQL
DELETE FROM dolt_branch_namespace_control WHERE true;
DELETE FROM dolt_branch_control WHERE true;
DROP USER IF EXISTS 'tadmin'@'%';
DROP USER IF EXISTS 'ttask'@'%';
DROP DATABASE IF EXISTS t;
CREATE DATABASE t;
CREATE USER 'ttask'@'%' IDENTIFIED BY 't';
GRANT ALL ON t.* TO 'ttask'@'%';

View File

@@ -108,7 +108,7 @@ test_mutation() {
run dolt sql -q "select * from $table ORDER BY pk1" -r csv
[ "$status" -eq "0" ]
[ "$output" == "$expected" ] || (echo $output && exit 1)
run dolt sql -q "explain $dml"
run dolt sql -q "explain plan $dml"
[ "$status" -eq "0" ]
if ! [ -z "$uses_pk" ]; then
[[ "$output" =~ "IndexedTableAccess" ]] || exit 1

Binary file not shown.

View File

@@ -0,0 +1 @@
create table strings(`text` varbinary(50) primary key);

View File

@@ -916,3 +916,18 @@ DELIM
[ "$status" -eq 1 ]
[[ "$output" =~ "parameters all-text and schema are mutually exclusive" ]] || false
}
@test "import-create-tables: import from pre-existing parquet table" {
# The file strings.parquet uses a different name for the root column than the one generated by `dolt table export`,
# but Dolt should still be able to import it.
run dolt table import -c -s `batshelper parquet/strings.sql` strings `batshelper parquet/strings.parquet`
[ "$status" -eq 0 ]
dolt sql -r csv -q "select * from strings;"
run dolt sql -r csv -q "select * from strings;"
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 3 ]
[[ "$output" =~ "text" ]] || false
[[ "$output" =~ "hello foo" ]] || false
[[ "$output" =~ "hello world" ]] || false
}

View File

@@ -163,6 +163,44 @@ teardown() {
[[ ! "$output" =~ "feature" ]] || false
}
# Asserts that when a branch is deleted and a tag is created and they have the same name,
# the replica is able to correctly apply both changes.
@test "replication: pull branch delete and tag create with same name on read" {
# Configure repo1 to push changes on commit and create branch b1
cd repo1
dolt config --local --add sqlserver.global.dolt_replicate_to_remote remote1
dolt sql -q "call dolt_branch('b1');"
# Configure repo2 to pull changes on read and assert the b1 branch exists
cd ..
dolt clone file://./rem1 repo2
cd repo2
dolt config --local --add sqlserver.global.dolt_read_replica_remote origin
dolt config --local --add sqlserver.global.dolt_replicate_all_heads 1
run dolt sql -q "select name from dolt_branches" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 3 ]
[[ "$output" =~ "name" ]] || false
[[ "$output" =~ "main" ]] || false
[[ "$output" =~ "b1" ]] || false
# Delete branch b1 in repo1 and create tag b1
cd ../repo1
dolt sql -q "call dolt_branch('-D', 'b1'); call dolt_tag('b1');"
# Confirm that branch b1 is deleted and tag b1 is created in repo2
cd ../repo2
run dolt sql -q "select name from dolt_branches" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[[ "$output" =~ "main" ]] || false
run dolt sql -q "select tag_name from dolt_tags" -r csv
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
[[ "$output" =~ "tag_name" ]] || false
[[ "$output" =~ "b1" ]] || false
}
@test "replication: pull branch delete current branch" {
skip "broken by latest transaction changes"

View File

@@ -1827,7 +1827,7 @@ behavior:
start_sql_server
dolt sql -q "SET character_set_results = utf8; CREATE TABLE mapping(branch_id binary(16) PRIMARY KEY, user_id binary(16) NOT NULL, company_id binary(16) NOT NULL);"
run dolt sql -q "EXPLAIN SELECT m.* FROM mapping m WHERE user_id = uuid_to_bin('1c4c4e33-8ad7-4421-8450-9d5182816ac3');"
run dolt sql -q "EXPLAIN PLAN SELECT m.* FROM mapping m WHERE user_id = uuid_to_bin('1c4c4e33-8ad7-4421-8450-9d5182816ac3');"
[ $status -eq 0 ]
[[ "$output" =~ "0x1C4C4E338AD7442184509D5182816AC3" ]] || false
}

View File

@@ -1,8 +1,6 @@
module github.com/dolthub/dolt/integration-tests/go-sql-server-driver
go 1.22.5
toolchain go1.22.7
go 1.23.3
require (
github.com/dolthub/dolt/go v0.40.4

View File

@@ -211,11 +211,11 @@ tests:
result:
columns: ["@@GLOBAL.max_connections"]
rows: [["999"]]
- name: persistence behavior set to load
- name: persistence behavior
repos:
- name: repo1
server:
args: ["--persistence-behavior", "load"]
args: []
connections:
- on: repo1
queries:
@@ -223,18 +223,6 @@ tests:
result:
columns: ["@@GLOBAL.max_connections"]
rows: [["151"]]
- name: persistence behavior set to ignore
repos:
- name: repo1
server:
args: ["--persistence-behavior", "ignore"]
connections:
- on: repo1
queries:
- query: "select @@GLOBAL.max_connections"
result:
columns: ["@@GLOBAL.max_connections"]
rows: [["100"]]
- name: persisted global variable defined on the command line
repos:
- name: repo1
@@ -247,34 +235,6 @@ tests:
result:
columns: ["@@GLOBAL.max_connections"]
rows: [["555"]]
- name: persist global variable before server startup with persistence behavior with ignore
repos:
- name: repo1
with_files:
- name: ".dolt/config.json"
contents: |
{"sqlserver.global.max_connections":"999"}
server:
args: ["--persistence-behavior", "ignore"]
connections:
- on: repo1
queries:
- query: "select @@GLOBAL.max_connections"
result:
columns: ["@@GLOBAL.max_connections"]
rows: [["100"]]
- name: persisted global variable defined on the command line with persistence ignored
repos:
- name: repo1
server:
args: ["--max-connections", "555", "--persistence-behavior", "ignore"]
connections:
- on: repo1
queries:
- query: "select @@GLOBAL.max_connections"
result:
columns: ["@@GLOBAL.max_connections"]
rows: [["555"]]
- name: "@@global.dolt_log_level behavior"
repos:
- name: repo1