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

ExecStmt.OriginText doesn't return the original text #57396

Open
b6g opened this issue Nov 15, 2024 · 0 comments · May be fixed by #57393
Open

ExecStmt.OriginText doesn't return the original text #57396

b6g opened this issue Nov 15, 2024 · 0 comments · May be fixed by #57393
Labels
severity/moderate type/bug The issue is confirmed as a bug.

Comments

@b6g
Copy link
Contributor

b6g commented Nov 15, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Start a TiDB playground with tiup, and run the following program.

package main

import (
	"database/sql"
	"fmt"

	_ "github.com/go-sql-driver/mysql"
)

func main() {
	b := []byte{0x41, 0xf6, 0xec, 0x9a}
	db, _ := sql.Open("mysql", "root:@tcp(127.0.0.1:4000)/test")
	defer db.Close()
	db.Exec(`DROP TABLE IF EXISTS test`)
	db.Exec(`CREATE TABLE IF NOT EXISTS test (a BINARY(4))`)
	db.Exec(`SET SESSION tidb_general_log = 1`)
	db.Exec(`INSERT INTO test VALUES (?)`, b)
	db.Exec(fmt.Sprintf(`select * from test where a = _binary '%s'`, b))
}

2. What did you expect to see? (Required)

The sql field of the GENERAL_LOG message should include the original text, like,

sql="select * from test where a = _binary 'A\ufffd\ufffd\ufffd'"

3. What did you see instead (Required)

The GENERAL_LOG message is,

[2024/11/14 18:42:53.920 -08:00] [INFO] [session.go:3929] [GENERAL_LOG] [conn=1138753544] [session_alias=] [[email protected]] [schemaVersion=55] [txnStartTS=0] [forUpdateTS=0] [isReadConsistency=false] [currentDB=test] [isPessimistic=false] [sessionTxnMode=PESSIMISTIC] [sql="select * from test where a = _binary 'A???'"]

where the binary characters are replaced with ?.

4. What is your TiDB version? (Required)

I tried with the master version and v7.5.1.

@b6g b6g added the type/bug The issue is confirmed as a bug. label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants