Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing error doesn't show in show errors/warnings for PREPARE through binary protocol #59275

Open
YangKeao opened this issue Feb 6, 2025 · 0 comments · May be fixed by #59276
Open

Parsing error doesn't show in show errors/warnings for PREPARE through binary protocol #59275

YangKeao opened this issue Feb 6, 2025 · 0 comments · May be fixed by #59276
Assignees
Labels
severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@YangKeao
Copy link
Member

YangKeao commented Feb 6, 2025

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

func TestMySQL(t *testing.T) {
	db, err := sql.Open("mysql", "root:123456@tcp(127.0.0.1:3306)/test")
	require.NoError(t, err)

	conn, err := db.Conn(context.Background())
	require.NoError(t, err)

	assertWarningCount := func() {
		rows, err := conn.QueryContext(context.Background(), "show warnings")
		require.NoError(t, err)
		defer rows.Close()

		count := 0
		for rows.Next() {
			count++
		}
		require.Equal(t, 1, count)
	}

	for i := 0; i < 5; i++ {
		stmt, err := conn.PrepareContext(context.Background(), "VALUES ( ('foo'), ROW('bar') )")
		require.Error(t, err)
		require.Nil(t, stmt)

		assertWarningCount()
	}
}

This test will succeed for MySQL, but fail for TiDB.

Ref #34276. The #34311 only handled the normal ParseSQL path for handleQuery, but didn't fix this issue for binary protocol.

@YangKeao YangKeao added severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug. labels Feb 6, 2025
@YangKeao YangKeao self-assigned this Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
1 participant