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
4 changes: 4 additions & 0 deletions sql/planbuilder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ type parseErr struct {
err error
}

func (p parseErr) Error() string {
return p.err.Error()
}

func (b *Builder) handleErr(err error) {
panic(parseErr{err})
}
Expand Down
23 changes: 23 additions & 0 deletions sql/planbuilder/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3014,3 +3014,26 @@ func TestPlanBuilderErr(t *testing.T) {
})
}
}

// TestParseErrImplementsError verifies that parseErr implements the error interface (issue #3144)
// This ensures that when parseErr structs are logged directly (like in tracing), they show
// actual error messages instead of memory addresses like "{0xc006f85d80}"
func TestParseErrImplementsError(t *testing.T) {
// Create a parseErr directly to test the Error() method implementation
originalErr := sql.ErrColumnNotFound.New("test_column", "test_table")
pErr := parseErr{err: originalErr}

// Test that parseErr implements the error interface
var _ error = pErr

// Test that Error() returns the underlying error message
require.Equal(t, originalErr.Error(), pErr.Error())

// Test that when formatted as string, it shows meaningful content
formatted := fmt.Sprintf("%v", pErr)
require.Contains(t, formatted, "test_column")
require.NotContains(t, formatted, "0x", "Should not show memory address")

// Test that the error message is not a struct format
require.NotContains(t, formatted, "{github.com/dolthub/go-mysql-server/sql/planbuilder.parseErr")
}
Loading