Skip to content
Merged
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
10 changes: 10 additions & 0 deletions go/test/endtoend/vtgate/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,16 @@ func TestSwitchBetweenOlapAndOltp(t *testing.T) {
exec(t, conn, "set workload='oltp'")
}

func TestFoundRowsOnDualQueries(t *testing.T) {
ctx := context.Background()
conn, err := mysql.Connect(ctx, &vtParams)
require.NoError(t, err)
defer conn.Close()

exec(t, conn, "select 42")
assertMatches(t, conn, "select found_rows()", "[[UINT64(1)]]")
}

func TestUseStmtInOLAP(t *testing.T) {
defer cluster.PanicHandler(t)
ctx := context.Background()
Expand Down
8 changes: 2 additions & 6 deletions go/vt/vtgate/engine/singlerow.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ func (s *SingleRow) GetTableName() string {
// Execute performs a non-streaming exec.
func (s *SingleRow) Execute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantfields bool) (*sqltypes.Result, error) {
result := sqltypes.Result{
Fields: nil,
RowsAffected: 0,
InsertID: 0,
RowsAffected: 1,
Rows: [][]sqltypes.Value{
{},
},
Expand All @@ -60,9 +58,7 @@ func (s *SingleRow) Execute(vcursor VCursor, bindVars map[string]*query.BindVari
// StreamExecute performs a streaming exec.
func (s *SingleRow) StreamExecute(vcursor VCursor, bindVars map[string]*query.BindVariable, wantields bool, callback func(*sqltypes.Result) error) error {
result := sqltypes.Result{
Fields: nil,
RowsAffected: 0,
InsertID: 0,
RowsAffected: 1,
Rows: [][]sqltypes.Value{
{},
},
Expand Down
8 changes: 7 additions & 1 deletion go/vt/vtgate/executor_select_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ func TestSelectLastInsertId(t *testing.T) {
sql := "select last_insert_id()"
result, err := executorExec(executor, sql, map[string]*querypb.BindVariable{})
wantResult := &sqltypes.Result{
RowsAffected: 1,
Fields: []*querypb.Field{
{Name: "last_insert_id()", Type: sqltypes.Uint64},
},
Expand All @@ -324,6 +325,7 @@ func TestSelectUserDefindVariable(t *testing.T) {
result, err := executorExec(executor, sql, map[string]*querypb.BindVariable{})
require.NoError(t, err)
wantResult := &sqltypes.Result{
RowsAffected: 1,
Fields: []*querypb.Field{
{Name: "@foo", Type: sqltypes.Null},
},
Expand All @@ -337,6 +339,7 @@ func TestSelectUserDefindVariable(t *testing.T) {
result, err = executorExec(executor, sql, map[string]*querypb.BindVariable{})
require.NoError(t, err)
wantResult = &sqltypes.Result{
RowsAffected: 1,
Fields: []*querypb.Field{
{Name: "@foo", Type: sqltypes.VarBinary},
},
Expand All @@ -360,11 +363,12 @@ func TestFoundRows(t *testing.T) {
sql := "select found_rows()"
result, err := executorExec(executor, sql, map[string]*querypb.BindVariable{})
wantResult := &sqltypes.Result{
RowsAffected: 1,
Fields: []*querypb.Field{
{Name: "found_rows()", Type: sqltypes.Uint64},
},
Rows: [][]sqltypes.Value{{
sqltypes.NewUint64(0),
sqltypes.NewUint64(1),
}},
}
require.NoError(t, err)
Expand All @@ -389,6 +393,7 @@ func TestRowCount(t *testing.T) {
func testRowCount(t *testing.T, executor *Executor, wantRowCount int64) {
result, err := executorExec(executor, "select row_count()", map[string]*querypb.BindVariable{})
wantResult := &sqltypes.Result{
RowsAffected: 1,
Fields: []*querypb.Field{
{Name: "row_count()", Type: sqltypes.Int64},
},
Expand Down Expand Up @@ -492,6 +497,7 @@ func TestSelectDatabase(t *testing.T) {
sql,
map[string]*querypb.BindVariable{})
wantResult := &sqltypes.Result{
RowsAffected: 1,
Fields: []*querypb.Field{
{Name: "database()", Type: sqltypes.VarBinary},
},
Expand Down