Copilot commented on code in PR #1146:
URL:
https://github.com/apache/incubator-seata-go/pull/1146#discussion_r3869351306
##########
pkg/datasource/sql/util/placeholders.go:
##########
@@ -108,3 +118,171 @@ func CompactPostgreSQLPlaceholders(query string, args
[]driver.NamedValue) (stri
return builder.String(), compactedArgs, nil
}
+
+// StripPostgreSQLStringCharset removes MySQL charset introducers emitted by
the
+// parser for string literals. PostgreSQL does not accept _UTF8MB4'...', and
the
+// following placeholder compaction must still see the literal quotes.
+func StripPostgreSQLStringCharset(query string) string {
+ const utf8mb4 = "_UTF8MB4"
+ if !strings.Contains(strings.ToUpper(query), utf8mb4) {
+ return query
+ }
Review Comment:
`StripPostgreSQLStringCharset` uses `strings.ToUpper(query)` just to do a
case-insensitive pre-check. `ToUpper` allocates a full copy of the SQL string;
this runs on every PostgreSQL before-image SQL and can be avoided with a
non-allocating fold/scan.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]