Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
2682f4e
field align plan package
Aug 19, 2025
f6a39c9
pointers
Aug 19, 2025
183ebd4
field align planbuilder
Aug 19, 2025
5c93fd7
field align memo
Aug 19, 2025
d5f1ae0
fieldalign rowexec
Aug 19, 2025
ee878ca
fieldalign engine
Aug 19, 2025
373a1c3
field align sql
Aug 19, 2025
a749252
fix test
Aug 19, 2025
6c4f907
fieldalign driver
Aug 19, 2025
3836d10
field align types
Aug 19, 2025
900ec38
fix scripts
Aug 19, 2025
5ac8b3f
fix tests
Aug 19, 2025
4d548fc
field align encodings
Aug 19, 2025
0870100
field align encoding
Aug 19, 2025
77ffd55
field align fulltext
Aug 19, 2025
9a9edb4
fieldalign window
Aug 19, 2025
a36d210
field align json
Aug 19, 2025
997be2e
field align function
Aug 19, 2025
29c6c92
field align expression
Aug 19, 2025
837a8f8
field align iters
Aug 19, 2025
884d1c9
field align stats
Aug 19, 2025
86b9b9c
field align transform
Aug 19, 2025
613a54b
field align binlog
Aug 19, 2025
f635f71
fix
Aug 19, 2025
46224e0
field align analyzer
Aug 19, 2025
8b58699
field align mysql_db
Aug 19, 2025
7ca933f
fixed align golden
Aug 19, 2025
0a26efc
field align server
Aug 19, 2025
ec98ce1
field align internal
Aug 19, 2025
7167abe
field align eventscheduler
Aug 19, 2025
aa1ea6f
field align information schema
Aug 19, 2025
d06d7e3
fix planbuilder
Aug 19, 2025
e934ae4
field align plan
Aug 19, 2025
49b6430
field align interpreter
Aug 19, 2025
5fc50eb
field align in mem table
Aug 19, 2025
35d05c6
field align memory
Aug 19, 2025
4c059e7
align
Aug 19, 2025
7a0b473
fix
Aug 19, 2025
2979915
[ga-format-pr] Run ./format_repo.sh to fix formatting
jycor Aug 19, 2025
ce1c9fc
bring back comments for engine
Aug 19, 2025
f0b6c7f
restore a bunch of comments
Aug 19, 2025
eeb12c9
restore comments
Aug 20, 2025
c4f1790
bump
Aug 20, 2025
d5a29a5
[ga-format-pr] Run ./format_repo.sh to fix formatting
jycor Aug 20, 2025
c0adc42
rebase and field align
Aug 20, 2025
409cecc
revert stats changes
Aug 25, 2025
e2b090b
comments
Aug 28, 2025
50fd62f
[ga-format-pr] Run ./format_repo.sh to fix formatting
jycor Aug 28, 2025
01aaf11
test: optimize database connection test logic
Johonsoy May 23, 2025
75fbf4d
bump
Aug 28, 2025
211c852
restore
Aug 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions driver/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (

// Conn is a connection to a database.
type Conn struct {
dsn string
options *Options
dbConn *dbConn
session sql.Session
contexts ContextBuilder
options *Options
dbConn *dbConn
indexes *sql.IndexRegistry
views *sql.ViewRegistry
dsn string
}

// DSN returns the driver connection string.
Expand Down
9 changes: 4 additions & 5 deletions driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,11 @@ type ProviderWithSessionBuilder interface {
// A Driver exposes an engine as a stdlib SQL driver.
type Driver struct {
provider Provider
options *Options
sessions SessionBuilder
contexts ContextBuilder

mu sync.Mutex
dbs map[string]*dbConn
options *Options
dbs map[string]*dbConn
mu sync.Mutex
}

// New returns a driver using the specified provider.
Expand Down Expand Up @@ -223,9 +222,9 @@ func (c *dbConn) close() error {
type Connector struct {
driver *Driver
options *Options
dbConn *dbConn
serverName string
dsn string
dbConn *dbConn
}

// Driver returns the driver.
Expand Down
2 changes: 1 addition & 1 deletion driver/rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (

// Rows is an iterator over an executed query's results.
type Rows struct {
rows sql.RowIter
options *Options
ctx *sql.Context
cols sql.Schema
rows sql.RowIter
}

// Columns returns the names of the columns. The number of
Expand Down
7 changes: 6 additions & 1 deletion driver/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,10 @@ func (s *Stmt) query(ctx context.Context, bindings map[string]sqlparser.Expr) (d
return nil, err
}

return &Rows{s.conn.options, qctx, cols, rows}, nil
return &Rows{
options: s.conn.options,
ctx: qctx,
cols: cols,
rows: rows,
}, nil
}
18 changes: 9 additions & 9 deletions engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ func init() {
type Config struct {
// VersionPostfix to display with the `VERSION()` UDF.
VersionPostfix string
// TemporaryUsers adds any users that should be included when the engine is created. By default, authentication is
// disabled, and including any users here will enable authentication. All users in this list will have full access.
// This field is only temporary, and will be removed as development on users and authentication continues.
TemporaryUsers []TemporaryUser
// IsReadOnly sets the engine to disallow modification queries.
IsReadOnly bool
IsServerLocked bool
// IncludeRootAccount adds the root account (with no password) to the list of accounts, and also enables
// authentication.
IncludeRootAccount bool
// TemporaryUsers adds any users that should be included when the engine is created. By default, authentication is
// disabled, and including any users here will enable authentication. All users in this list will have full access.
// This field is only temporary, and will be removed as development on users and authentication continues.
TemporaryUsers []TemporaryUser
}

// TemporaryUser is a user that will be added to the engine. This is for temporary use while the remaining features
Expand Down Expand Up @@ -136,18 +136,18 @@ func (p *PreparedDataCache) UncacheStmt(sessId uint32, query string) {

// Engine is a SQL engine.
type Engine struct {
Parser sql.Parser
ProcessList sql.ProcessList
Analyzer *analyzer.Analyzer
LS *sql.LockSubsystem
ProcessList sql.ProcessList
MemoryManager *sql.MemoryManager
BackgroundThreads *sql.BackgroundThreads
ReadOnly atomic.Bool
IsServerLocked bool
PreparedDataCache *PreparedDataCache
mu *sync.Mutex
Version sql.AnalyzerVersion
EventScheduler *eventscheduler.EventScheduler
Parser sql.Parser
ReadOnly atomic.Bool
IsServerLocked bool
Version sql.AnalyzerVersion
}

var _ sql.StatementRunner = (*Engine)(nil)
Expand Down
42 changes: 36 additions & 6 deletions enginetest/queries/check_scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,16 +540,36 @@ var ChecksOnUpdateScriptTests = []ScriptTest{
},
Assertions: []ScriptTestAssertion{
{
Query: "UPDATE sales JOIN (SELECT year_built FROM sales) AS t ON sales.year_built = t.year_built SET sales.year_built = 1901;",
Expected: []sql.Row{{types.OkResult{1, 0, plan.UpdateInfo{1, 1, 0}}}},
Query: "UPDATE sales JOIN (SELECT year_built FROM sales) AS t ON sales.year_built = t.year_built SET sales.year_built = 1901;",
Expected: []sql.Row{
{
types.OkResult{
RowsAffected: 1,
Info: plan.UpdateInfo{
Matched: 1,
Updated: 1,
},
},
},
},
},
{
Query: "select * from sales;",
Expected: []sql.Row{{1901}},
},
{
Query: "UPDATE sales as s1 JOIN (SELECT year_built FROM sales) AS t SET S1.year_built = 1902;",
Expected: []sql.Row{{types.OkResult{1, 0, plan.UpdateInfo{1, 1, 0}}}},
Query: "UPDATE sales as s1 JOIN (SELECT year_built FROM sales) AS t SET S1.year_built = 1902;",
Expected: []sql.Row{
{
types.OkResult{
RowsAffected: 1,
Info: plan.UpdateInfo{
Matched: 1,
Updated: 1,
},
},
},
},
},
{
Query: "select * from sales;",
Expand Down Expand Up @@ -599,8 +619,18 @@ var ChecksOnUpdateScriptTests = []ScriptTest{
Expected: []sql.Row{{"WA"}},
},
{
Query: "UPDATE sales JOIN locations SET sales.year_built = 2000, locations.state = 'CA';",
Expected: []sql.Row{{types.OkResult{2, 0, plan.UpdateInfo{2, 2, 0}}}},
Query: "UPDATE sales JOIN locations SET sales.year_built = 2000, locations.state = 'CA';",
Expected: []sql.Row{
{
types.OkResult{
RowsAffected: 2,
Info: plan.UpdateInfo{
Matched: 2,
Updated: 2,
},
},
},
},
},
{
Query: "select * from sales;",
Expand Down
4 changes: 2 additions & 2 deletions eventscheduler/enabled_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import (

// enabledEvent is used for storing a list of events that are enabled in EventScheduler.
type enabledEvent struct {
edb sql.EventDatabase
event sql.EventDefinition
nextExecutionAt time.Time
edb sql.EventDatabase
username string
address string
event sql.EventDefinition
}

var _ fmt.Stringer = (*enabledEvent)(nil)
Expand Down
4 changes: 2 additions & 2 deletions eventscheduler/event_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ import (
// to update the enabled events list in the eventExecutor. It also handles updating the event
// metadata in the database or dropping it from the database after its execution.
type eventExecutor struct {
catalog sql.Catalog
bThreads *sql.BackgroundThreads
list *enabledEventsList
runningEventsStatus *runningEventsStatus
ctxGetterFunc func() (*sql.Context, error)
queryRunFunc func(ctx *sql.Context, dbName, query, username, address string) error
stop atomic.Bool
catalog sql.Catalog
tokenTracker *tokenTracker
period int
stop atomic.Bool
}

// newEventExecutor returns a new eventExecutor instance with an empty enabled events list.
Expand Down
2 changes: 1 addition & 1 deletion eventscheduler/event_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ var _ sql.EventScheduler = (*EventScheduler)(nil)

// EventScheduler is responsible for SQL events execution.
type EventScheduler struct {
status SchedulerStatus
executor *eventExecutor
ctxGetterFunc func() (*sql.Context, error)
status SchedulerStatus
}

// InitEventScheduler is called at the start of the server. This function returns EventScheduler object
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/dolthub/go-icu-regex v0.0.0-20250820171420-f2b78f56ce9f
github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81
github.com/dolthub/vitess v0.0.0-20250814204310-c749d213f235
github.com/dolthub/vitess v0.0.0-20250828002016-b8fc8e714bf8
github.com/go-sql-driver/mysql v1.7.2-0.20231213112541-0004702b931d
github.com/gocraft/dbr/v2 v2.7.2
github.com/google/uuid v1.3.0
Expand Down
12 changes: 2 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@ github.com/denisenkom/go-mssqldb v0.10.0 h1:QykgLZBorFE95+gO3u9esLd0BmbvpWp0/waN
github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 h1:u3PMzfF8RkKd3lB9pZ2bfn0qEG+1Gms9599cr0REMww=
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2/go.mod h1:mIEZOHnFx4ZMQeawhw9rhsj+0zwQj7adVsnBX7t+eKY=
github.com/dolthub/go-icu-regex v0.0.0-20250327004329-6799764f2dad h1:66ZPawHszNu37VPQckdhX1BPPVzREsGgNxQeefnlm3g=
github.com/dolthub/go-icu-regex v0.0.0-20250327004329-6799764f2dad/go.mod h1:ylU4XjUpsMcvl/BKeRRMXSH7e7WBrPXdSLvnRJYrxEA=
github.com/dolthub/go-icu-regex v0.0.0-20250820171420-f2b78f56ce9f h1:oSA8CptGeCEdTdD9LFtv8x4juDfdaLKsx1eocyaj1bE=
github.com/dolthub/go-icu-regex v0.0.0-20250820171420-f2b78f56ce9f/go.mod h1:kpsRG+a196Y69zsAFL0RkQICII9a571lcaxhvQnmrdY=
github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71 h1:bMGS25NWAGTEtT5tOBsCuCrlYnLRKpbJVJkDbrTRhwQ=
github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71/go.mod h1:2/2zjLQ/JOOSbbSboojeg+cAwcRV0fDLzIiWch/lhqI=
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81 h1:7/v8q9XGFa6q5Ap4Z/OhNkAMBaK5YeuEzwJt+NZdhiE=
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81/go.mod h1:siLfyv2c92W1eN/R4QqG/+RjjX5W2+gCTRjZxBjI3TY=
github.com/dolthub/vitess v0.0.0-20250730174048-497aebb8cea7 h1:l+mWO0xoh4eG1J9gMS87opL6N6WGAQitF36R/Lg4bWs=
github.com/dolthub/vitess v0.0.0-20250730174048-497aebb8cea7/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
github.com/dolthub/vitess v0.0.0-20250813175212-45844169a751 h1:BBQKyvyODewdQxS+ICklMn1d/fFj2pVlkmMN1QFY4ms=
github.com/dolthub/vitess v0.0.0-20250813175212-45844169a751/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
github.com/dolthub/vitess v0.0.0-20250814204310-c749d213f235 h1:uXrK+xn8rCwz/8jWDKaDyqZG1HbZI9F4V4HJ7zXFPMY=
github.com/dolthub/vitess v0.0.0-20250814204310-c749d213f235/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
github.com/dolthub/vitess v0.0.0-20250828002016-b8fc8e714bf8 h1:RJwo+L0E5NDcYsipjwWau0I85SlPPhtx9xN2UMYtfd4=
github.com/dolthub/vitess v0.0.0-20250828002016-b8fc8e714bf8/go.mod h1:1gQZs/byeHLMSul3Lvl3MzioMtOW1je79QYGyi2fd70=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
Expand Down Expand Up @@ -81,8 +75,6 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tetratelabs/wazero v1.8.2 h1:yIgLR/b2bN31bjxwXHD8a3d+BogigR952csSDdLYEv4=
github.com/tetratelabs/wazero v1.8.2/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs=
github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I=
github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM=
go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY=
Expand Down
8 changes: 4 additions & 4 deletions internal/sockstate/netstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ func (s *sockAddr) String() string {

// sockTabEntry type represents each line of the /proc/net/tcp
type sockTabEntry struct {
Ino string
LocalAddr *sockAddr
RemoteAddr *sockAddr
State skState
UID uint32
Process *process
Ino string
UID uint32
State skState
}

// process holds the PID and process name to which each socket belongs
type process struct {
pid int
name string
pid int
}

func (p *process) String() string {
Expand Down
2 changes: 1 addition & 1 deletion internal/sockstate/netstat_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (p *procFd) iterFdDir() {
}
z := bytes.SplitN(buf[:n], []byte(" "), 3)
name := getProcName(z[1])
p.p = &process{p.pid, name}
p.p = &process{name: name, pid: p.pid}
}
sk.Process = p.p
}
Expand Down
6 changes: 3 additions & 3 deletions memory/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ var _ sql.SchemaValidator = (*BaseDatabase)(nil)

// BaseDatabase is an in-memory database that can't store views, only for testing the engine
type BaseDatabase struct {
name string
tables map[string]MemTable
fkColl *ForeignKeyCollection
tablesMu *sync.RWMutex
name string
triggers []sql.TriggerDefinition
storedProcedures []sql.StoredProcedureDetails
events []sql.EventDefinition
primaryKeyIndexes bool
collation sql.CollationID
tablesMu *sync.RWMutex
primaryKeyIndexes bool
}

var _ MemoryDatabase = (*Database)(nil)
Expand Down
24 changes: 13 additions & 11 deletions memory/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,23 @@ import (
const CommentPreventingIndexBuilding = "__FOR TESTING: I cannot be built__"

type Index struct {
DB string // required for engine tests with driver
DriverName string // required for engine tests with driver
Tbl *Table // required for engine tests with driver
TableName string
Exprs []sql.Expression
Name string
Unique bool
Spatial bool
Fulltext bool
// If SupportedVectorFunction is non-nil, this index can be used to optimize ORDER BY
// expressions on this type of distance function.
SupportedVectorFunction vector.DistanceType
CommentStr string
PrefixLens []uint16

Tbl *Table // required for engine tests with driver
DriverName string // required for engine tests with driver
DB string // required for engine tests with driver
TableName string
Name string
CommentStr string

Exprs []sql.Expression
PrefixLens []uint16
fulltextInfo
Unique bool
Spatial bool
Fulltext bool
}

type fulltextInfo struct {
Expand Down
2 changes: 1 addition & 1 deletion memory/index_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const IndexDriverId = "MemoryIndexDriver"
// create or delete indexes, but will use the index types defined in this package to alter how queries are executed,
// retrieving values from the indexes rather than from the tables directly.
type TestIndexDriver struct {
db string
indexes map[string][]sql.DriverIndex
db string
}

// NewIndexDriver returns a new index driver for database and the indexes given, keyed by the table name.
Expand Down
6 changes: 3 additions & 3 deletions memory/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ var _ sql.ExternalStoredProcedureProvider = (*DbProvider)(nil)
// DbProvider is a provider for in-memory databases
type DbProvider struct {
dbs map[string]sql.Database
tableFunctions map[string]sql.TableFunction
externalProcedureRegistry sql.ExternalStoredProcedureRegistry
mu *sync.RWMutex
history bool
readOnly bool
nativeIndexes bool
mu *sync.RWMutex
tableFunctions map[string]sql.TableFunction
externalProcedureRegistry sql.ExternalStoredProcedureRegistry
}

type ProviderOption func(*DbProvider)
Expand Down
2 changes: 1 addition & 1 deletion memory/required_lookup_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ var _ sql.IndexRequired = RequiredLookupTable{}

// RequiredLookupTable is a table that will error if not executed as an index lookup
type RequiredLookupTable struct {
indexOk bool
IntSequenceTable
indexOk bool
}

func (s RequiredLookupTable) RequiredPredicates() []string {
Expand Down
Loading
Loading