Skip to content

Commit c76b4ab

Browse files
authored
Merge pull request #3147 from dolthub/elianddb/3144-fix-trace-parse-exceptions
#3144 - Fix parseErr tracing to show error messages instead of memory addresses
2 parents 32ba561 + cc75ff1 commit c76b4ab

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

sql/planbuilder/builder.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ type parseErr struct {
205205
err error
206206
}
207207

208+
func (p parseErr) Error() string {
209+
return p.err.Error()
210+
}
211+
208212
func (b *Builder) handleErr(err error) {
209213
panic(parseErr{err})
210214
}

sql/planbuilder/parse_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3014,3 +3014,26 @@ func TestPlanBuilderErr(t *testing.T) {
30143014
})
30153015
}
30163016
}
3017+
3018+
// TestParseErrImplementsError verifies that parseErr implements the error interface (issue #3144)
3019+
// This ensures that when parseErr structs are logged directly (like in tracing), they show
3020+
// actual error messages instead of memory addresses like "{0xc006f85d80}"
3021+
func TestParseErrImplementsError(t *testing.T) {
3022+
// Create a parseErr directly to test the Error() method implementation
3023+
originalErr := sql.ErrColumnNotFound.New("test_column", "test_table")
3024+
pErr := parseErr{err: originalErr}
3025+
3026+
// Test that parseErr implements the error interface
3027+
var _ error = pErr
3028+
3029+
// Test that Error() returns the underlying error message
3030+
require.Equal(t, originalErr.Error(), pErr.Error())
3031+
3032+
// Test that when formatted as string, it shows meaningful content
3033+
formatted := fmt.Sprintf("%v", pErr)
3034+
require.Contains(t, formatted, "test_column")
3035+
require.NotContains(t, formatted, "0x", "Should not show memory address")
3036+
3037+
// Test that the error message is not a struct format
3038+
require.NotContains(t, formatted, "{github.com/dolthub/go-mysql-server/sql/planbuilder.parseErr")
3039+
}

0 commit comments

Comments
 (0)