From c5740ff3cf89d091bbf6cc57ae4f6bd94553b8b4 Mon Sep 17 00:00:00 2001 From: elianddb Date: Wed, 6 Aug 2025 23:53:48 +0000 Subject: [PATCH 1/2] add Error() --- sql/planbuilder/builder.go | 4 ++++ sql/planbuilder/parse_test.go | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/sql/planbuilder/builder.go b/sql/planbuilder/builder.go index 0001fcb1ee..8d32b0adce 100644 --- a/sql/planbuilder/builder.go +++ b/sql/planbuilder/builder.go @@ -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}) } diff --git a/sql/planbuilder/parse_test.go b/sql/planbuilder/parse_test.go index 45e2ef882c..e426c779bf 100644 --- a/sql/planbuilder/parse_test.go +++ b/sql/planbuilder/parse_test.go @@ -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") +} From cc75ff159a83fbe3ec744ee51f76d2e18213e4fd Mon Sep 17 00:00:00 2001 From: elianddb Date: Wed, 6 Aug 2025 23:57:04 +0000 Subject: [PATCH 2/2] [ga-format-pr] Run ./format_repo.sh to fix formatting --- sql/planbuilder/parse_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/planbuilder/parse_test.go b/sql/planbuilder/parse_test.go index e426c779bf..22a1588a23 100644 --- a/sql/planbuilder/parse_test.go +++ b/sql/planbuilder/parse_test.go @@ -3022,18 +3022,18 @@ 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") }