Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions internal/explain/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ func FormatFloat(val float64) string {

// escapeStringLiteral escapes special characters in a string for EXPLAIN AST output
// Uses double-escaping as ClickHouse EXPLAIN AST displays strings
// Iterates over bytes to preserve raw bytes (including invalid UTF-8)
func escapeStringLiteral(s string) string {
var sb strings.Builder
for _, r := range s {
switch r {
for i := 0; i < len(s); i++ {
b := s[i]
switch b {
case '\\':
sb.WriteString("\\\\\\\\") // backslash becomes four backslashes (\\\\)
case '\'':
Expand All @@ -48,7 +50,7 @@ func escapeStringLiteral(s string) string {
case '\f':
sb.WriteString("\\\\f") // form feed becomes \\f
default:
sb.WriteRune(r)
sb.WriteByte(b)
}
}
return sb.String()
Expand Down
4 changes: 4 additions & 0 deletions lexer/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,14 @@ func (l *Lexer) readString(quote rune) Item {
sb.WriteRune('\r')
case '0':
sb.WriteRune('\x00')
case 'a':
sb.WriteRune('\a')
case 'b':
sb.WriteRune('\b')
case 'f':
sb.WriteRune('\f')
case 'v':
sb.WriteRune('\v')
case 'x':
// Hex escape: \xNN
l.readChar()
Expand Down
2 changes: 1 addition & 1 deletion parser/testdata/00342_escape_sequences/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"todo": true}
{}