Skip to content

Commit e806822

Browse files
committed
Merge main
2 parents 4bfc225 + d32c9ce commit e806822

File tree

267 files changed

+3618
-1859
lines changed

Some content is hidden

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

267 files changed

+3618
-1859
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/enginetests.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6089,6 +6089,15 @@ func TestVectorFunctions(t *testing.T, h Harness) {
60896089
for _, tt := range queries.VectorFunctionQueries {
60906090
TestScript(t, h, tt)
60916091
}
6092+
for _, testCase := range queries.VectorFunctionTestCases {
6093+
TestScript(t, h, queries.MakeVectorFunctionTest(testCase))
6094+
}
6095+
}
6096+
6097+
func TestVectorType(t *testing.T, h Harness) {
6098+
for _, tt := range queries.VectorDDLQueries {
6099+
TestScript(t, h, tt)
6100+
}
60926101
}
60936102

60946103
func TestIndexPrefix(t *testing.T, h Harness) {

enginetest/join_op_tests.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,6 +2046,72 @@ WHERE
20462046
},
20472047
},
20482048
},
2049+
{
2050+
name: "joining on decimals",
2051+
setup: [][]string{
2052+
{
2053+
"create table t1(c0 decimal(6,3))",
2054+
"create table t2(c0 decimal(5,2))",
2055+
"insert into t1 values (10.000),(20.505),(30.000)",
2056+
"insert into t2 values (20.5), (25.0), (30.0)",
2057+
},
2058+
},
2059+
tests: []JoinOpTests{
2060+
{
2061+
Query: "select * from t1 join t2 on t1.c0 = t2.c0",
2062+
Expected: []sql.Row{{"30.000", "30.00"}},
2063+
},
2064+
},
2065+
},
2066+
{
2067+
// https://github.com/dolthub/dolt/issues/9777
2068+
name: "join with % condition",
2069+
setup: [][]string{
2070+
{
2071+
"create table t1(c0 int)",
2072+
"create table t2(c0 int)",
2073+
"insert into t1 values (1),(2)",
2074+
"insert into t2 values (3),(4)",
2075+
},
2076+
},
2077+
tests: []JoinOpTests{
2078+
{
2079+
Query: "select * from t1 join t2 on (t1.c0 % 2) = (t2.c0 % 2)",
2080+
Expected: []sql.Row{
2081+
{1, 3},
2082+
{2, 4},
2083+
},
2084+
},
2085+
},
2086+
},
2087+
{
2088+
// https://github.com/dolthub/dolt/issues/9782
2089+
name: "joining with subquery on empty table",
2090+
setup: [][]string{
2091+
{
2092+
"CREATE TABLE t(c INT);",
2093+
"INSERT INTO t VALUES (1);",
2094+
},
2095+
},
2096+
tests: []JoinOpTests{
2097+
{
2098+
Query: "SELECT t.c FROM t LEFT JOIN (SELECT t.c FROM t WHERE FALSE) AS subq ON TRUE;",
2099+
Expected: []sql.Row{{1}},
2100+
},
2101+
{
2102+
Query: "SELECT t.c FROM t NATURAL LEFT JOIN (SELECT t.c FROM t WHERE FALSE) AS subq;",
2103+
Expected: []sql.Row{{1}},
2104+
},
2105+
{
2106+
Query: "SELECT t.c FROM (SELECT t.c FROM t WHERE FALSE) AS subq RIGHT JOIN t ON TRUE;",
2107+
Expected: []sql.Row{{1}},
2108+
},
2109+
{
2110+
Query: "SELECT t.c FROM (SELECT t.c FROM t WHERE FALSE) AS subq NATURAL RIGHT JOIN t;",
2111+
Expected: []sql.Row{{1}},
2112+
},
2113+
},
2114+
},
20492115
}
20502116

20512117
var rangeJoinOpTests = []JoinOpTests{

enginetest/memory_engine_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,10 @@ func TestVectorFunctions(t *testing.T) {
922922
enginetest.TestVectorFunctions(t, enginetest.NewDefaultMemoryHarness())
923923
}
924924

925+
func TestVectorType(t *testing.T) {
926+
enginetest.TestVectorType(t, enginetest.NewDefaultMemoryHarness())
927+
}
928+
925929
func TestIndexPrefix(t *testing.T) {
926930
enginetest.TestIndexPrefix(t, enginetest.NewDefaultMemoryHarness())
927931
}
@@ -997,9 +1001,6 @@ func TestDatabaseCollationWire(t *testing.T) {
9971001
}
9981002

9991003
func TestTypesOverWire(t *testing.T) {
1000-
if _, ok := os.LookupEnv("CI_TEST"); !ok {
1001-
t.Skip("Skipping test that requires CI_TEST=true")
1002-
}
10031004
harness := enginetest.NewDefaultMemoryHarness()
10041005
enginetest.TestTypesOverWire(t, harness, harness.SessionBuilder())
10051006
}

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/column_alias_queries.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,17 @@ var ColumnAliasQueries = []ScriptTest{
269269
Assertions: []ScriptTestAssertion{
270270
{
271271
// GMS returns "expression 'dt.two' doesn't appear in the group by expressions", but MySQL will execute
272-
// this query.
272+
// this query. https://github.com/dolthub/dolt/issues/9717
273273
Query: "select 1 as a, one + 1 as mod1, dt.* from mytable as t1, (select 1, 2 from mytable) as dt (one, two) where dt.one > 0 group by one;",
274274
// column names: a, mod1, one, two
275275
Expected: []sql.Row{{1, 2, 1, 2}},
276276
},
277+
{
278+
// MySQL will execute this query but group by validation isn't able to recognize that exprAlias is a
279+
// literal https://github.com/dolthub/dolt/issues/9717
280+
Query: "select 1 as exprAlias, 2, 3, (select exprAlias + count(*) from one_pk_three_idx a cross join one_pk_three_idx b);",
281+
Expected: []sql.Row{{1, 2, 3, 65}},
282+
},
277283
},
278284
},
279285
}

0 commit comments

Comments
 (0)