MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / EncodeEscapedSQLIdent

Function EncodeEscapedSQLIdent

pkg/sql/lexbase/encode.go:101–120  ·  view source on GitHub ↗

EncodeEscapedSQLIdent writes the identifier in s to buf. The identifier is always quoted. Double quotes inside the identifier are escaped.

(buf *bytes.Buffer, s string)

Source from the content-addressed store, hash-verified

99// identifier is always quoted. Double quotes inside the identifier
100// are escaped.
101func EncodeEscapedSQLIdent(buf *bytes.Buffer, s string) {
102 buf.WriteByte('"')
103 start := 0
104 for i, n := 0, len(s); i < n; i++ {
105 ch := s[i]
106 // The only character that requires escaping is a double quote.
107 if ch == '"' {
108 if start != i {
109 buf.WriteString(s[start:i])
110 }
111 start = i + 1
112 buf.WriteByte(ch)
113 buf.WriteByte(ch) // add extra copy of ch
114 }
115 }
116 if start < len(s) {
117 buf.WriteString(s[start:])
118 }
119 buf.WriteByte('"')
120}
121
122const (
123 minPrintableChar = 0x20 // ' '

Callers 3

EncodeRestrictedSQLIdentFunction · 0.85
EscapeSQLIdentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…