Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/scripts/sql-correctness/current_correctness.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
100
99.998838
2 changes: 1 addition & 1 deletion go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ require (
github.com/dolthub/aws-sdk-go-ini-parser v0.0.0-20250305001723-2821c37f6c12
github.com/dolthub/eventsapi_schema v0.0.0-20250725194025-a087efa1ee55
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-mysql-server v0.20.1-0.20250815200358-4678e45abe87
github.com/dolthub/go-mysql-server v0.20.1-0.20250818234713-774cd94a89fa
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63
github.com/edsrzf/mmap-go v1.2.0
github.com/esote/minmaxheap v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,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-20250327004329-6799764f2dad h1:66ZPawHszNu37VPQckdhX1BPPVzREsGgNxQeefnlm3g=
github.com/dolthub/go-icu-regex v0.0.0-20250327004329-6799764f2dad/go.mod h1:ylU4XjUpsMcvl/BKeRRMXSH7e7WBrPXdSLvnRJYrxEA=
github.com/dolthub/go-mysql-server v0.20.1-0.20250815200358-4678e45abe87 h1:SrfKxmrKWAmi4BKj8AKsHK4kdOrduJ2/Ix7GEcwh+FY=
github.com/dolthub/go-mysql-server v0.20.1-0.20250815200358-4678e45abe87/go.mod h1:J+ixF8s/kL8x8W8sQh4UNmufcyFOeIi/FPo+MwAjUcU=
github.com/dolthub/go-mysql-server v0.20.1-0.20250818234713-774cd94a89fa h1:FkrDykpx7oywLJAZJLRZCbpzwwzlAl+fx9Mo+GOjbjQ=
github.com/dolthub/go-mysql-server v0.20.1-0.20250818234713-774cd94a89fa/go.mod h1:J+ixF8s/kL8x8W8sQh4UNmufcyFOeIi/FPo+MwAjUcU=
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=
Expand Down
66 changes: 25 additions & 41 deletions go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,53 +113,37 @@ func TestSchemaOverridesWithAdaptiveEncoding(t *testing.T) {

// Convenience test for debugging a single query. Unskip and set to the desired query.
func TestSingleScript(t *testing.T) {
t.Skip()
//t.Skip()
var scripts = []queries.ScriptTest{
{
Name: "Database syntax properly handles inter-CALL communication",
Name: "set op schema merge",
SetUpScript: []string{
`CREATE PROCEDURE p1()
BEGIN
DECLARE str VARCHAR(20);
CALL p2(str);
SET str = CONCAT('a', str);
SELECT str;
END`,
`CREATE PROCEDURE p2(OUT param VARCHAR(20))
BEGIN
SET param = 'b';
END`,
"CALL DOLT_ADD('-A');",
"CALL DOLT_COMMIT('-m', 'First procedures');",
"CALL DOLT_BRANCH('p12');",
"DROP PROCEDURE p1;",
"DROP PROCEDURE p2;",
`CREATE PROCEDURE p1()
BEGIN
DECLARE str VARCHAR(20);
CALL p2(str);
SET str = CONCAT('c', str);
SELECT str;
END`,
`CREATE PROCEDURE p2(OUT param VARCHAR(20))
BEGIN
SET param = 'd';
END`,
"CALL DOLT_ADD('-A');",
"CALL DOLT_COMMIT('-m', 'Second procedures');",
"create table `left` (i int primary key, j mediumint, k varchar(20));",
"create table `right` (i int primary key, j bigint, k text);",
"insert into `left` values (1,2, 'a')",
"insert into `right` values (3,4, 'b')",

"create table t1 (i int);",
"insert into t1 values (1), (2), (3);",
"create table t2 (i int);",
"insert into t2 values (1), (3);",
"create table t3 (j int);",
"insert into t3 values (1), (3);",
},
Assertions: []queries.ScriptTestAssertion{
{
Query: "CALL p1();",
Expected: []sql.Row{{"cd"}},
},
{
Query: "CALL `mydb/main`.p1();",
Expected: []sql.Row{{"cd"}},
},
{
Query: "CALL `mydb/p12`.p1();",
Expected: []sql.Row{{"ab"}},
Query: "table t1 union table t2 order by i;",
ExpectedColumns: sql.Schema{
{
Name: "i",
Type: gmstypes.Int32,
},
},
Expected: []sql.Row{
{1},
{2},
{3},
},
},
},
},
Expand Down
13 changes: 10 additions & 3 deletions go/libraries/doltcore/sqle/index/prolly_row_iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type prollyRowIter struct {
// ordProj is a concatenated list of output ordinals for |keyProj| and |valProj|
ordProj []int
rowLen int

rows []sql.Row
}

var _ sql.RowIter = prollyRowIter{}
Expand Down Expand Up @@ -172,8 +174,8 @@ func (it prollyRowIter) Next(ctx *sql.Context) (sql.Row, error) {
if err != nil {
return nil, err
}

row := make(sql.Row, it.rowLen)
row := sql.GetRow(it.rowLen)
it.rows = append(it.rows, row)
for i, idx := range it.keyProj {
outputIdx := it.ordProj[i]
row[outputIdx], err = tree.GetField(ctx, it.keyDesc, idx, key, it.ns)
Expand All @@ -192,6 +194,7 @@ func (it prollyRowIter) Next(ctx *sql.Context) (sql.Row, error) {
}

func (it prollyRowIter) Close(ctx *sql.Context) error {
sql.PutRows(it.rows)
return nil
}

Expand All @@ -206,6 +209,8 @@ type prollyKeylessIter struct {

curr sql.Row
card uint64

rows []sql.Row
}

var _ sql.RowIter = &prollyKeylessIter{}
Expand All @@ -231,7 +236,8 @@ func (it *prollyKeylessIter) nextTuple(ctx *sql.Context) error {
}

it.card = val.ReadKeylessCardinality(value)
it.curr = make(sql.Row, it.rowLen)
it.curr = sql.GetRow(it.rowLen)
it.rows = append(it.rows, it.curr)

for i, idx := range it.valProj {
outputIdx := it.ordProj[i]
Expand All @@ -244,5 +250,6 @@ func (it *prollyKeylessIter) nextTuple(ctx *sql.Context) error {
}

func (it *prollyKeylessIter) Close(ctx *sql.Context) error {
sql.PutRows(it.rows)
return nil
}
11 changes: 10 additions & 1 deletion go/libraries/doltcore/sqle/kvexec/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ type prollyToSqlJoiner struct {
desc []kvDesc
ordMappings []int
outCnt int

rows []sql.Row
}

type kvDesc struct {
Expand Down Expand Up @@ -243,7 +245,9 @@ func (m *prollyToSqlJoiner) buildRow(ctx context.Context, tuples ...val.Tuple) (
if len(tuples) != 2*len(m.desc) {
panic("invalid KV count for prollyToSqlJoiner")
}
row := make(sql.Row, m.outCnt)
row := sql.GetRow(m.outCnt)
m.rows = append(m.rows, row)

split := 0
var err error
var tup val.Tuple
Expand Down Expand Up @@ -276,6 +280,11 @@ func (m *prollyToSqlJoiner) buildRow(ctx context.Context, tuples ...val.Tuple) (
return row, nil
}

func (m *prollyToSqlJoiner) Close(ctx *sql.Context) error {
sql.PutRows(m.rows)
return nil
}

func getPhysicalColCount(schemas []schema.Schema, splits []int, projections []uint64) int {
var virtual bool
for _, sch := range schemas {
Expand Down
9 changes: 5 additions & 4 deletions go/libraries/doltcore/sqle/kvexec/lookup_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ type lookupJoinKvIter struct {
returnedARow bool
}

func (l *lookupJoinKvIter) Close(_ *sql.Context) error {
return nil
}

var _ sql.RowIter = (*lookupJoinKvIter)(nil)

func newLookupKvIter(
Expand Down Expand Up @@ -137,6 +133,7 @@ func (l *lookupJoinKvIter) Next(ctx *sql.Context) (sql.Row, error) {
}
}

// TODO: we can actually free these rows much earlier
ret, err := l.joiner.buildRow(ctx, l.srcKey, l.srcVal, dstKey, dstVal)
if err != nil {
return nil, err
Expand Down Expand Up @@ -182,6 +179,10 @@ func (l *lookupJoinKvIter) Next(ctx *sql.Context) (sql.Row, error) {
}
}

func (l *lookupJoinKvIter) Close(ctx *sql.Context) error {
return l.joiner.Close(ctx)
}

// lookupMapping is responsible for generating keys for lookups into
// the destination iterator.
type lookupMapping struct {
Expand Down
4 changes: 2 additions & 2 deletions go/libraries/doltcore/sqle/kvexec/merge_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ type mergeJoinKvIter struct {

var _ sql.RowIter = (*mergeJoinKvIter)(nil)

func (l *mergeJoinKvIter) Close(_ *sql.Context) error {
return nil
func (l *mergeJoinKvIter) Close(ctx *sql.Context) error {
return l.joiner.Close(ctx)
}

func (l *mergeJoinKvIter) Next(ctx *sql.Context) (sql.Row, error) {
Expand Down