mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-23 13:48:42 -05:00
Fixed system variables
This commit is contained in:
committed by
Daylon Wilkins
parent
378dcd73fb
commit
af43053fb2
@@ -105,6 +105,25 @@ func (cmd FilterBranchCmd) Exec(ctx context.Context, commandStr string, args []s
|
||||
return HandleVErrAndExitCode(verr, usage)
|
||||
}
|
||||
|
||||
sql.SystemVariables.AddSystemVariables([]sql.SystemVariable{
|
||||
{
|
||||
Name: dbName + "_head",
|
||||
Scope: sql.SystemVariableScope_Session,
|
||||
Dynamic: true,
|
||||
SetVarHintApplies: false,
|
||||
Type: sql.NewSystemStringType(dbName + "_head"),
|
||||
Default: "",
|
||||
},
|
||||
{
|
||||
Name: dbName + "_working",
|
||||
Scope: sql.SystemVariableScope_Session,
|
||||
Dynamic: true,
|
||||
SetVarHintApplies: false,
|
||||
Type: sql.NewSystemStringType(dbName + "_head"),
|
||||
Default: "",
|
||||
},
|
||||
})
|
||||
|
||||
query := apr.Arg(0)
|
||||
notFound := make(missingTbls)
|
||||
replay := func(ctx context.Context, commit, _, _ *doltdb.Commit) (*doltdb.RootValue, error) {
|
||||
@@ -237,12 +256,15 @@ func monoSqlEngine(ctx context.Context, dEnv *env.DoltEnv, cm *doltdb.Commit) (*
|
||||
sql.WithIndexRegistry(sql.NewIndexRegistry()),
|
||||
sql.WithViewRegistry(sql.NewViewRegistry()),
|
||||
sql.WithTracer(tracing.Tracer(ctx)))
|
||||
_ = sqlCtx.Set(sqlCtx, sql.AutoCommitSessionVar, sql.Boolean, true)
|
||||
err := sqlCtx.SetSessionVariable(sqlCtx, sql.AutoCommitSessionVar, true)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
db := dsqle.NewDatabase(dbName, dEnv.DbData())
|
||||
|
||||
cat := sql.NewCatalog()
|
||||
err := cat.Register(dfunctions.DoltFunctions...)
|
||||
err = cat.Register(dfunctions.DoltFunctions...)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
@@ -105,6 +105,19 @@ const (
|
||||
|
||||
var delimiterRegex = regexp.MustCompile(`(?i)^\s*DELIMITER\s+(\S+)\s*(\s+\S+\s*)?$`)
|
||||
|
||||
func init() {
|
||||
sql.SystemVariables.AddSystemVariables([]sql.SystemVariable{
|
||||
{
|
||||
Name: currentBatchModeKey,
|
||||
Scope: sql.SystemVariableScope_Session,
|
||||
Dynamic: true,
|
||||
SetVarHintApplies: false,
|
||||
Type: sql.NewSystemIntType(currentBatchModeKey, -9223372036854775808, 9223372036854775807, false),
|
||||
Default: int64(0),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
type SqlCmd struct {
|
||||
VersionStr string
|
||||
}
|
||||
@@ -246,7 +259,10 @@ func (cmd SqlCmd) Exec(ctx context.Context, commandStr string, args []string, dE
|
||||
sql.WithIndexRegistry(sql.NewIndexRegistry()),
|
||||
sql.WithViewRegistry(sql.NewViewRegistry()),
|
||||
sql.WithTracer(tracing.Tracer(ctx)))
|
||||
_ = sqlCtx.Set(sqlCtx, sql.AutoCommitSessionVar, sql.Boolean, true)
|
||||
err = sqlCtx.SetSessionVariable(sqlCtx, sql.AutoCommitSessionVar, true)
|
||||
if err != nil {
|
||||
return HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage)
|
||||
}
|
||||
|
||||
roots := make(map[string]*doltdb.RootValue)
|
||||
|
||||
@@ -1012,8 +1028,10 @@ func processBatchQuery(ctx *sql.Context, query string, se *sqlEngine) error {
|
||||
}
|
||||
|
||||
currentBatchMode := invalidBatchMode
|
||||
if t, v := ctx.Get(currentBatchModeKey); t == sql.Int64 {
|
||||
if v, err := ctx.GetSessionVariable(ctx, currentBatchModeKey); err == nil {
|
||||
currentBatchMode = batchMode(v.(int64))
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
|
||||
newBatchMode, err := canProcessAsBatchEdit(ctx, sqlStatement, se, query)
|
||||
@@ -1030,7 +1048,10 @@ func processBatchQuery(ctx *sql.Context, query string, se *sqlEngine) error {
|
||||
}
|
||||
}
|
||||
|
||||
ctx.Set(ctx, currentBatchModeKey, sql.Int64, int64(newBatchMode))
|
||||
err = ctx.SetSessionVariable(ctx, currentBatchModeKey, int64(newBatchMode))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if newBatchMode != invalidBatchMode {
|
||||
err = processBatchableEditQuery(ctx, se, query, sqlStatement)
|
||||
|
||||
@@ -175,14 +175,15 @@ func portInUse(hostPort string) bool {
|
||||
|
||||
func newSessionBuilder(sqlEngine *sqle.Engine, username, email string, autocommit bool) server.SessionBuilder {
|
||||
return func(ctx context.Context, conn *mysql.Conn, host string) (sql.Session, *sql.IndexRegistry, *sql.ViewRegistry, error) {
|
||||
tmpSqlCtx := sql.NewEmptyContext()
|
||||
mysqlSess := sql.NewSession(host, conn.RemoteAddr().String(), conn.User, conn.ConnectionID)
|
||||
doltSess, err := dsqle.NewDoltSession(ctx, mysqlSess, username, email, dbsAsDSQLDBs(sqlEngine.Catalog.AllDatabases())...)
|
||||
doltSess, err := dsqle.NewDoltSession(tmpSqlCtx, mysqlSess, username, email, dbsAsDSQLDBs(sqlEngine.Catalog.AllDatabases())...)
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
err = doltSess.Set(ctx, sql.AutoCommitSessionVar, sql.Boolean, autocommit)
|
||||
err = doltSess.SetSessionVariable(tmpSqlCtx, sql.AutoCommitSessionVar, autocommit)
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
|
||||
Reference in New Issue
Block a user