Skip to content

Commit 4a0ff81

Browse files
authored
Merge branch 'main' into elian/9738
2 parents f468825 + 0308d9f commit 4a0ff81

File tree

234 files changed

+1902
-1617
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+1902
-1617
lines changed

driver/conn.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ import (
2323

2424
// Conn is a connection to a database.
2525
type Conn struct {
26-
dsn string
27-
options *Options
28-
dbConn *dbConn
2926
session sql.Session
3027
contexts ContextBuilder
28+
options *Options
29+
dbConn *dbConn
3130
indexes *sql.IndexRegistry
3231
views *sql.ViewRegistry
32+
dsn string
3333
}
3434

3535
// DSN returns the driver connection string.

driver/driver.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,11 @@ type ProviderWithSessionBuilder interface {
8282
// A Driver exposes an engine as a stdlib SQL driver.
8383
type Driver struct {
8484
provider Provider
85-
options *Options
8685
sessions SessionBuilder
8786
contexts ContextBuilder
88-
89-
mu sync.Mutex
90-
dbs map[string]*dbConn
87+
options *Options
88+
dbs map[string]*dbConn
89+
mu sync.Mutex
9190
}
9291

9392
// New returns a driver using the specified provider.
@@ -223,9 +222,9 @@ func (c *dbConn) close() error {
223222
type Connector struct {
224223
driver *Driver
225224
options *Options
225+
dbConn *dbConn
226226
serverName string
227227
dsn string
228-
dbConn *dbConn
229228
}
230229

231230
// Driver returns the driver.

driver/rows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ import (
2626

2727
// Rows is an iterator over an executed query's results.
2828
type Rows struct {
29+
rows sql.RowIter
2930
options *Options
3031
ctx *sql.Context
3132
cols sql.Schema
32-
rows sql.RowIter
3333
}
3434

3535
// Columns returns the names of the columns. The number of

driver/stmt.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,10 @@ func (s *Stmt) query(ctx context.Context, bindings map[string]sqlparser.Expr) (d
117117
return nil, err
118118
}
119119

120-
return &Rows{s.conn.options, qctx, cols, rows}, nil
120+
return &Rows{
121+
options: s.conn.options,
122+
ctx: qctx,
123+
cols: cols,
124+
rows: rows,
125+
}, nil
121126
}

engine.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ func init() {
5353
type Config struct {
5454
// VersionPostfix to display with the `VERSION()` UDF.
5555
VersionPostfix string
56+
// TemporaryUsers adds any users that should be included when the engine is created. By default, authentication is
57+
// disabled, and including any users here will enable authentication. All users in this list will have full access.
58+
// This field is only temporary, and will be removed as development on users and authentication continues.
59+
TemporaryUsers []TemporaryUser
5660
// IsReadOnly sets the engine to disallow modification queries.
5761
IsReadOnly bool
5862
IsServerLocked bool
5963
// IncludeRootAccount adds the root account (with no password) to the list of accounts, and also enables
6064
// authentication.
6165
IncludeRootAccount bool
62-
// TemporaryUsers adds any users that should be included when the engine is created. By default, authentication is
63-
// disabled, and including any users here will enable authentication. All users in this list will have full access.
64-
// This field is only temporary, and will be removed as development on users and authentication continues.
65-
TemporaryUsers []TemporaryUser
6666
}
6767

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

137137
// Engine is a SQL engine.
138138
type Engine struct {
139+
Parser sql.Parser
140+
ProcessList sql.ProcessList
139141
Analyzer *analyzer.Analyzer
140142
LS *sql.LockSubsystem
141-
ProcessList sql.ProcessList
142143
MemoryManager *sql.MemoryManager
143144
BackgroundThreads *sql.BackgroundThreads
144-
ReadOnly atomic.Bool
145-
IsServerLocked bool
146145
PreparedDataCache *PreparedDataCache
147146
mu *sync.Mutex
148-
Version sql.AnalyzerVersion
149147
EventScheduler *eventscheduler.EventScheduler
150-
Parser sql.Parser
148+
ReadOnly atomic.Bool
149+
IsServerLocked bool
150+
Version sql.AnalyzerVersion
151151
}
152152

153153
var _ sql.StatementRunner = (*Engine)(nil)

enginetest/queries/check_scripts.go

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -540,16 +540,36 @@ var ChecksOnUpdateScriptTests = []ScriptTest{
540540
},
541541
Assertions: []ScriptTestAssertion{
542542
{
543-
Query: "UPDATE sales JOIN (SELECT year_built FROM sales) AS t ON sales.year_built = t.year_built SET sales.year_built = 1901;",
544-
Expected: []sql.Row{{types.OkResult{1, 0, plan.UpdateInfo{1, 1, 0}}}},
543+
Query: "UPDATE sales JOIN (SELECT year_built FROM sales) AS t ON sales.year_built = t.year_built SET sales.year_built = 1901;",
544+
Expected: []sql.Row{
545+
{
546+
types.OkResult{
547+
RowsAffected: 1,
548+
Info: plan.UpdateInfo{
549+
Matched: 1,
550+
Updated: 1,
551+
},
552+
},
553+
},
554+
},
545555
},
546556
{
547557
Query: "select * from sales;",
548558
Expected: []sql.Row{{1901}},
549559
},
550560
{
551-
Query: "UPDATE sales as s1 JOIN (SELECT year_built FROM sales) AS t SET S1.year_built = 1902;",
552-
Expected: []sql.Row{{types.OkResult{1, 0, plan.UpdateInfo{1, 1, 0}}}},
561+
Query: "UPDATE sales as s1 JOIN (SELECT year_built FROM sales) AS t SET S1.year_built = 1902;",
562+
Expected: []sql.Row{
563+
{
564+
types.OkResult{
565+
RowsAffected: 1,
566+
Info: plan.UpdateInfo{
567+
Matched: 1,
568+
Updated: 1,
569+
},
570+
},
571+
},
572+
},
553573
},
554574
{
555575
Query: "select * from sales;",
@@ -599,8 +619,18 @@ var ChecksOnUpdateScriptTests = []ScriptTest{
599619
Expected: []sql.Row{{"WA"}},
600620
},
601621
{
602-
Query: "UPDATE sales JOIN locations SET sales.year_built = 2000, locations.state = 'CA';",
603-
Expected: []sql.Row{{types.OkResult{2, 0, plan.UpdateInfo{2, 2, 0}}}},
622+
Query: "UPDATE sales JOIN locations SET sales.year_built = 2000, locations.state = 'CA';",
623+
Expected: []sql.Row{
624+
{
625+
types.OkResult{
626+
RowsAffected: 2,
627+
Info: plan.UpdateInfo{
628+
Matched: 2,
629+
Updated: 2,
630+
},
631+
},
632+
},
633+
},
604634
},
605635
{
606636
Query: "select * from sales;",

enginetest/queries/function_queries.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,3 +1529,16 @@ var FunctionQueryTests = []QueryTest{
15291529
},
15301530
},
15311531
}
1532+
1533+
// BrokenFunctionQueryTests contains SQL function call queries that don't match MySQL behavior
1534+
var BrokenFunctionQueryTests = []QueryTest{
1535+
// https://github.com/dolthub/dolt/issues/9735
1536+
{
1537+
Query: "select log('10asdf', '100f')",
1538+
Expected: []sql.Row{{float64(2)}},
1539+
},
1540+
{
1541+
Query: "select log('a10asdf', 'b100f')",
1542+
Expected: []sql.Row{{nil}},
1543+
},
1544+
}

enginetest/queries/logic_test_scripts.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,6 @@ var SQLLogicSubqueryTests = []ScriptTest{
951951
},
952952
},
953953
{
954-
Skip: true,
955954
Query: "SELECT * FROM (SELECT c_id AS c_c_id, bill FROM c) sq1, LATERAL (SELECT row_number() OVER () AS rownum FROM o WHERE c_id = c_c_id) sq2 ORDER BY c_c_id, bill, rownum;",
956955
Expected: []sql.Row{
957956
{1, "CA", 1},

0 commit comments

Comments
 (0)