Skip to content

Commit

Permalink
fix: error.as method usage to send pointer to the reference type expe…
Browse files Browse the repository at this point in the history
…cted. (#13496)

Signed-off-by: Harshit Gangal <harshit@planetscale.com>
  • Loading branch information
harshit-gangal authored Jul 14, 2023
1 parent 658586f commit b318fa3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletserver/schema/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func (se *Engine) reload(ctx context.Context, includeStats bool) error {
table, err := LoadTable(conn, se.cp.DBName(), tableName, tableType, row[3].ToString())
if err != nil {
isView := strings.Contains(tableType, tmutils.TableView)
var emptyColumnsError mysqlctl.EmptyColumnsErr
var emptyColumnsError *mysqlctl.EmptyColumnsErr
if errors.As(err, &emptyColumnsError) && isView {
log.Warningf("Failed reading schema for the table: %s, error: %v", tableName, err)
continue
Expand Down
29 changes: 29 additions & 0 deletions go/vt/vttablet/tabletserver/schema/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,35 @@ func TestOpenFailedDueToLoadTableErr(t *testing.T) {
assert.Contains(t, logOutput, "The user specified as a definer ('root'@'%') does not exist (errno 1449) (sqlstate HY000)")
}

// TestOpenFailedDueToEmptyColumnInView tests that schema engine load should not fail instead should log the failures for empty columns in view
func TestOpenFailedDueToEmptyColumnInView(t *testing.T) {
tl := syslogger.NewTestLogger()
defer tl.Close()
db := fakesqldb.New(t)
defer db.Close()
schematest.AddDefaultQueries(db)
db.AddQueryPattern(baseShowTablesPattern, &sqltypes.Result{
Fields: mysql.BaseShowTablesFields,
Rows: [][]sqltypes.Value{
mysql.BaseShowTablesRow("test_view", true, "VIEW"),
},
})

// adding column query for table_view
db.AddQueryPattern(fmt.Sprintf(mysql.GetColumnNamesQueryPatternForTable, "test_view"),
&sqltypes.Result{})

AddFakeInnoDBReadRowsResult(db, 0)
se := newEngine(10, 1*time.Second, 1*time.Second, 0, db)
err := se.Open()
require.NoError(t, err)

logs := tl.GetAllLogs()
logOutput := strings.Join(logs, ":::")
assert.Contains(t, logOutput, "WARNING:Failed reading schema for the table: test_view")
assert.Contains(t, logOutput, "unable to get columns for table fakesqldb.test_view")
}

func TestExportVars(t *testing.T) {
db := fakesqldb.New(t)
defer db.Close()
Expand Down

0 comments on commit b318fa3

Please sign in to comment.