Skip to content

Commit

Permalink
update bind variable type (#8315)
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifersp authored Sep 18, 2024
1 parent 0083a13 commit 88ae8c9
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 27 deletions.
3 changes: 1 addition & 2 deletions go/cmd/dolt/cli/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"syscall"

"github.com/dolthub/go-mysql-server/sql"
querypb "github.com/dolthub/vitess/go/vt/proto/query"
"github.com/dolthub/vitess/go/vt/sqlparser"
"github.com/fatih/color"

Expand Down Expand Up @@ -88,7 +87,7 @@ type SignalCommand interface {
// SQL. The Queryist can be obtained from the CliContext passed into the Exec method by calling the QueryEngine method.
type Queryist interface {
Query(ctx *sql.Context, query string) (sql.Schema, sql.RowIter, *sql.QueryFlags, error)
QueryWithBindings(ctx *sql.Context, query string, parsed sqlparser.Statement, bindings map[string]*querypb.BindVariable, qFlags *sql.QueryFlags) (sql.Schema, sql.RowIter, *sql.QueryFlags, error)
QueryWithBindings(ctx *sql.Context, query string, parsed sqlparser.Statement, bindings map[string]sqlparser.Expr, qFlags *sql.QueryFlags) (sql.Schema, sql.RowIter, *sql.QueryFlags, error)
}

// This type is to store the content of a documented command, elsewhere we can transform this struct into
Expand Down
3 changes: 1 addition & 2 deletions go/cmd/dolt/commands/engine/sqlengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/dolthub/go-mysql-server/sql/mysql_db"
"github.com/dolthub/go-mysql-server/sql/rowexec"
_ "github.com/dolthub/go-mysql-server/sql/variables"
querypb "github.com/dolthub/vitess/go/vt/proto/query"
"github.com/dolthub/vitess/go/vt/sqlparser"
"github.com/sirupsen/logrus"

Expand Down Expand Up @@ -312,7 +311,7 @@ func (se *SqlEngine) Query(ctx *sql.Context, query string) (sql.Schema, sql.RowI
return se.engine.Query(ctx, query)
}

func (se *SqlEngine) QueryWithBindings(ctx *sql.Context, query string, parsed sqlparser.Statement, bindings map[string]*querypb.BindVariable, qFlags *sql.QueryFlags) (sql.Schema, sql.RowIter, *sql.QueryFlags, error) {
func (se *SqlEngine) QueryWithBindings(ctx *sql.Context, query string, parsed sqlparser.Statement, bindings map[string]sqlparser.Expr, qFlags *sql.QueryFlags) (sql.Schema, sql.RowIter, *sql.QueryFlags, error) {
return se.engine.QueryWithBindings(ctx, query, parsed, bindings, qFlags)
}

Expand Down
3 changes: 1 addition & 2 deletions go/cmd/dolt/commands/sqlserver/queryist_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/types"
querypb "github.com/dolthub/vitess/go/vt/proto/query"
"github.com/dolthub/vitess/go/vt/sqlparser"
"github.com/go-sql-driver/mysql"
"github.com/gocraft/dbr/v2"
Expand Down Expand Up @@ -94,7 +93,7 @@ func (c ConnectionQueryist) Query(ctx *sql.Context, query string) (sql.Schema, s
return rowIter.Schema(), rowIter, nil, nil
}

func (c ConnectionQueryist) QueryWithBindings(ctx *sql.Context, query string, _ sqlparser.Statement, _ map[string]*querypb.BindVariable, _ *sql.QueryFlags) (sql.Schema, sql.RowIter, *sql.QueryFlags, error) {
func (c ConnectionQueryist) QueryWithBindings(ctx *sql.Context, query string, _ sqlparser.Statement, _ map[string]sqlparser.Expr, _ *sql.QueryFlags) (sql.Schema, sql.RowIter, *sql.QueryFlags, error) {
return c.Query(ctx, query)
}

Expand Down
2 changes: 1 addition & 1 deletion go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0
github.com/creasty/defaults v1.6.0
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-mysql-server v0.18.2-0.20240918043246-e3846f5468f5
github.com/dolthub/go-mysql-server v0.18.2-0.20240918214853-7e76e21750a6
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63
github.com/dolthub/swiss v0.1.0
github.com/goccy/go-json v0.10.2
Expand Down
4 changes: 2 additions & 2 deletions go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,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-20240916130659-0118adc6b662 h1:aC17hZD6iwzBwwfO5M+3oBT5E5gGRiQPdn+vzpDXqIA=
github.com/dolthub/go-icu-regex v0.0.0-20240916130659-0118adc6b662/go.mod h1:KPUcpx070QOfJK1gNe0zx4pA5sicIK1GMikIGLKC168=
github.com/dolthub/go-mysql-server v0.18.2-0.20240918043246-e3846f5468f5 h1:m12ohMzoZUQExnXqWeTYziQiSwwtzjoEFBSKzBVHin8=
github.com/dolthub/go-mysql-server v0.18.2-0.20240918043246-e3846f5468f5/go.mod h1:m88EMm9OthVVa6qIhbpnRDpj/eYUXuNpvY/+0YWKVwc=
github.com/dolthub/go-mysql-server v0.18.2-0.20240918214853-7e76e21750a6 h1:bqXlOmbV1cX3G83xLz4+czZUsAn4Fp2hRsypkz6N1fM=
github.com/dolthub/go-mysql-server v0.18.2-0.20240918214853-7e76e21750a6/go.mod h1:m88EMm9OthVVa6qIhbpnRDpj/eYUXuNpvY/+0YWKVwc=
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
6 changes: 2 additions & 4 deletions go/go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,8 @@ github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE=
github.com/dolthub/go-mysql-server v0.18.2-0.20240812011431-f3892cc42bbf h1:F4OT8cjaQzGlLne9vp7/q0i5QFsQE2OUWIaL5thO5qA=
github.com/dolthub/go-mysql-server v0.18.2-0.20240812011431-f3892cc42bbf/go.mod h1:PwuemL+YK+YiWcUFhknixeqNLjJNfCx7KDsHNajx9fM=
github.com/dolthub/go-mysql-server v0.18.2-0.20240827100900-3bf086dd5c18 h1:1lgwZvnecrjoc9v0iqxjdKBvaasAPiQzty40uTKOHsE=
github.com/dolthub/go-mysql-server v0.18.2-0.20240827100900-3bf086dd5c18/go.mod h1:nbdOzd0ceWONE80vbfwoRBjut7z3CIj69ZgDF/cKuaA=
github.com/dolthub/go-mysql-server v0.18.2-0.20240918194055-f75a63f64679 h1:O6eSicGwVPYnEzE0jgLakX2Ud54p6OGdcaqwBgNB+vU=
github.com/dolthub/go-mysql-server v0.18.2-0.20240918194055-f75a63f64679/go.mod h1:m88EMm9OthVVa6qIhbpnRDpj/eYUXuNpvY/+0YWKVwc=
github.com/dylanmei/iso8601 v0.1.0/go.mod h1:w9KhXSgIyROl1DefbMYIE7UVSIvELTbMrCfx+QkYnoQ=
github.com/dylanmei/winrmtest v0.0.0-20210303004826-fbc9ae56efb6/go.mod h1:6BLLhzn1VEiJ4veuAGhINBTrBlV889Wd+aU4auxKOww=
github.com/eapache/go-resiliency v1.1.0 h1:1NtRmCAqadE2FN4ZcN6g90TP3uk8cg9rn9eNK2197aU=
Expand Down
19 changes: 9 additions & 10 deletions go/libraries/doltcore/sqle/enginetest/dolt_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import (
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/plan"
"github.com/dolthub/go-mysql-server/sql/types"
"github.com/dolthub/vitess/go/sqltypes"
"github.com/dolthub/vitess/go/vt/proto/query"
"github.com/dolthub/vitess/go/vt/sqlparser"

"github.com/dolthub/dolt/go/libraries/doltcore/sqle"
)
Expand Down Expand Up @@ -1226,29 +1225,29 @@ var DoltScripts = []queries.ScriptTest{
{
Query: "select * from test as of 'HEAD~' where pk=?;",
Expected: []sql.Row{{0, 0}},
Bindings: map[string]*query.BindVariable{
"v1": sqltypes.Int8BindVariable(int8(0)),
Bindings: map[string]sqlparser.Expr{
"v1": sqlparser.NewIntVal([]byte("0")),
},
},
{
Query: "select * from test as of hashof('HEAD') where pk=?;",
Expected: []sql.Row{{1, 1, nil}},
Bindings: map[string]*query.BindVariable{
"v1": sqltypes.Int8BindVariable(int8(1)),
Bindings: map[string]sqlparser.Expr{
"v1": sqlparser.NewIntVal([]byte("1")),
},
},
{
Query: "select * from test as of @Commit1 where pk=?;",
Expected: []sql.Row{{0, 0}},
Bindings: map[string]*query.BindVariable{
"v1": sqltypes.Int8BindVariable(int8(0)),
Bindings: map[string]sqlparser.Expr{
"v1": sqlparser.NewIntVal([]byte("0")),
},
},
{
Query: "select * from test as of @Commit2 where pk=?;",
Expected: []sql.Row{{0, 0, nil}},
Bindings: map[string]*query.BindVariable{
"v1": sqltypes.Int8BindVariable(int8(0)),
Bindings: map[string]sqlparser.Expr{
"v1": sqlparser.NewIntVal([]byte("0")),
},
},
},
Expand Down
8 changes: 4 additions & 4 deletions go/libraries/doltcore/sqle/enginetest/prepared_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import (
"fmt"
"testing"

"github.com/dolthub/vitess/go/vt/sqlparser"

"github.com/dolthub/go-mysql-server/enginetest"
"github.com/dolthub/go-mysql-server/enginetest/queries"
"github.com/dolthub/go-mysql-server/enginetest/scriptgen/setup"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/vitess/go/sqltypes"
"github.com/dolthub/vitess/go/vt/proto/query"
"github.com/stretchr/testify/require"
)

Expand All @@ -36,8 +36,8 @@ func DoltPreparedScripts(t *testing.T, harness enginetest.Harness) {
},
{
Query: "SELECT table_name FROM information_schema.columns WHERE table_name = ? group by table_name ORDER BY ORDINAL_POSITION",
Bindings: map[string]*query.BindVariable{
"v1": sqltypes.StringBindVariable("dolt_history_mytable"),
Bindings: map[string]sqlparser.Expr{
"v1": sqlparser.NewStrVal([]byte("dolt_history_mytable")),
},
Expected: []sql.Row{{"dolt_history_mytable"}},
},
Expand Down

0 comments on commit 88ae8c9

Please sign in to comment.