Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 'types.OkResult' is not a valid value type for 'int' #222

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 14 additions & 5 deletions backend/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ func (b *DuckBuilder) Build(ctx *sql.Context, root sql.Node, r sql.Row) (sql.Row
case sql.Expressioner:
return b.executeExpressioner(ctx, node, conn)
case *plan.DeleteFrom:
return b.executeDML(ctx, conn)
return b.executeDML(ctx, node, conn)
case *plan.Truncate:
return b.executeDML(ctx, conn)
return b.executeDML(ctx, node, conn)
default:
return b.base.Build(ctx, n, r)
}
Expand All @@ -131,9 +131,9 @@ func (b *DuckBuilder) executeExpressioner(ctx *sql.Context, n sql.Expressioner,
node := n.(sql.Node)
switch n.(type) {
case *plan.InsertInto:
return b.executeDML(ctx, conn)
return b.executeDML(ctx, node, conn)
case *plan.Update:
return b.executeDML(ctx, conn)
return b.executeDML(ctx, node, conn)
default:
return b.executeQuery(ctx, node, conn)
}
Expand Down Expand Up @@ -172,7 +172,7 @@ func (b *DuckBuilder) executeQuery(ctx *sql.Context, n sql.Node, conn *stdsql.Co
return NewSQLRowIter(rows, n.Schema())
}

func (b *DuckBuilder) executeDML(ctx *sql.Context, conn *stdsql.Conn) (sql.RowIter, error) {
func (b *DuckBuilder) executeDML(ctx *sql.Context, n sql.Node, conn *stdsql.Conn) (sql.RowIter, error) {
// Translate the MySQL query to a DuckDB query
duckSQL, err := transpiler.TranslateWithSQLGlot(ctx.Query())
if err != nil {
Expand Down Expand Up @@ -200,9 +200,18 @@ func (b *DuckBuilder) executeDML(ctx *sql.Context, conn *stdsql.Conn) (sql.RowIt
return nil, err
}

var info fmt.Stringer
if _, ok := n.(*plan.Update); ok {
info = plan.UpdateInfo{
Matched: int(affected),
Updated: int(affected),
}
}

return sql.RowsToRowIter(sql.NewRow(types.OkResult{
RowsAffected: uint64(affected),
InsertID: uint64(insertId),
Info: info,
})), nil
}

Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ require (
github.com/cockroachdb/cockroachdb-parser v0.23.2
github.com/cockroachdb/errors v1.9.0
github.com/dolthub/doltgresql v0.13.0
github.com/dolthub/go-mysql-server v0.18.2-0.20241112002228-81b13e8034f2
github.com/dolthub/vitess v0.0.0-20241111235433-a20a5ab9d7c9
github.com/dolthub/go-mysql-server v0.18.2-0.20241127000145-a1809677932e
github.com/dolthub/vitess v0.0.0-20241126223332-cd8f828f26ac
github.com/go-sql-driver/mysql v1.8.1
github.com/google/uuid v1.6.0
github.com/jackc/pglogrepl v0.0.0-20240307033717-828fbfe908e9
Expand All @@ -29,8 +29,8 @@ require (
)

replace (
github.com/dolthub/go-mysql-server v0.18.2-0.20241112002228-81b13e8034f2 => github.com/apecloud/go-mysql-server v0.0.0-20241113072459-9ad423c065f8
github.com/dolthub/vitess v0.0.0-20241111235433-a20a5ab9d7c9 => github.com/apecloud/dolt-vitess v0.0.0-20241113031931-99ad35228a58
github.com/dolthub/go-mysql-server v0.18.2-0.20241127000145-a1809677932e => github.com/apecloud/go-mysql-server v0.0.0-20241127073935-94c04f2f750d
github.com/dolthub/vitess v0.0.0-20241126223332-cd8f828f26ac => github.com/apecloud/dolt-vitess v0.0.0-20241127063501-5c7c985f0e57
github.com/marcboeker/go-duckdb v1.8.3 => github.com/apecloud/go-duckdb v0.0.0-20241113073916-47619770e595
)

Expand Down Expand Up @@ -95,8 +95,8 @@ require (
github.com/twpayne/go-kml v1.5.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
go.opentelemetry.io/otel v1.30.0 // indirect
go.opentelemetry.io/otel/trace v1.30.0 // indirect
go.opentelemetry.io/otel v1.31.0 // indirect
go.opentelemetry.io/otel/trace v1.31.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
golang.org/x/mod v0.21.0 // indirect
Expand Down
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,16 @@ github.com/apache/thrift v0.21.0 h1:tdPmh/ptjE1IJnhbhrcl2++TauVjy242rkV/UzJChnE=
github.com/apache/thrift v0.21.0/go.mod h1:W1H8aR/QRtYNvrPeFXBtobyRkd0/YVhTc6i07XIAgDw=
github.com/apecloud/dolt-vitess v0.0.0-20241113031931-99ad35228a58 h1:B7QNvHZxwoXvxOO8c48eQYrBG0cjpsFP6FZESe7ncaQ=
github.com/apecloud/dolt-vitess v0.0.0-20241113031931-99ad35228a58/go.mod h1:uBvlRluuL+SbEWTCZ68o0xvsdYZER3CEG/35INdzfJM=
github.com/apecloud/dolt-vitess v0.0.0-20241127063501-5c7c985f0e57 h1:djc1asm2fLvAwY9LKT4Jz8jzGkZQv0DH+WiUIyIEz3A=
github.com/apecloud/dolt-vitess v0.0.0-20241127063501-5c7c985f0e57/go.mod h1:alcJgfdyIhFaAiYyEmuDCFSLCzedz3KCaIclLoCUtJg=
github.com/apecloud/go-duckdb v0.0.0-20241113073916-47619770e595 h1:zAJgtlElXKLbo3HgZmFvfc96vSWGwTqAJphwFarz6Os=
github.com/apecloud/go-duckdb v0.0.0-20241113073916-47619770e595/go.mod h1:C9bYRE1dPYb1hhfu/SSomm78B0FXmNgRvv6YBW/Hooc=
github.com/apecloud/go-mysql-server v0.0.0-20241113072459-9ad423c065f8 h1:RzzXe1S0g49GrgfQ/AL2a+hrEqcXJM8Bv4NxPpzK+VI=
github.com/apecloud/go-mysql-server v0.0.0-20241113072459-9ad423c065f8/go.mod h1:SXieGXBXf24LLsXZ8uKu8LaFPfBYgcASfU7wNmWYlUg=
github.com/apecloud/go-mysql-server v0.0.0-20241127061707-8d47d8ec4ad7 h1:1IWCpbMT+kQM9Gq1oGCoFjxXOecCgAf9tcpXkIDQmy0=
github.com/apecloud/go-mysql-server v0.0.0-20241127061707-8d47d8ec4ad7/go.mod h1:QdaXQKE8XFwM4P1yN14m2eydx4V2xyuqpQp4tmNoXzQ=
github.com/apecloud/go-mysql-server v0.0.0-20241127073935-94c04f2f750d h1:qyupLWM3sncs2fgIekV8yBKPXNvvCunHKYL8cEDTIpI=
github.com/apecloud/go-mysql-server v0.0.0-20241127073935-94c04f2f750d/go.mod h1:QdaXQKE8XFwM4P1yN14m2eydx4V2xyuqpQp4tmNoXzQ=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
Expand Down Expand Up @@ -143,6 +149,8 @@ github.com/dolthub/jsonpath v0.0.2-0.20240227200619-19675ab05c71 h1:bMGS25NWAGTE
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-20240618184124-ca47f9354216 h1:JWkKRE4EHUcEVQCMRBej8DYxjYjRz/9MdF/NNQh0o70=
github.com/dolthub/sqllogictest/go v0.0.0-20240618184124-ca47f9354216/go.mod h1:e/FIZVvT2IR53HBCAo41NjqgtEnjMJGKca3Y/dAmZaA=
github.com/dolthub/vitess v0.0.0-20241126223332-cd8f828f26ac h1:A0U/OdIqdCkAV0by7MVBbnSyZBsa94ZjIZxx7PhjBW4=
github.com/dolthub/vitess v0.0.0-20241126223332-cd8f828f26ac/go.mod h1:alcJgfdyIhFaAiYyEmuDCFSLCzedz3KCaIclLoCUtJg=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
Expand Down Expand Up @@ -650,8 +658,12 @@ go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts=
go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc=
go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY=
go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE=
go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc=
go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o=
go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys=
go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
Expand Down
Loading