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

Function EncodeEscapedSQLIdent

pkg/sql/lex/encode.go:163–182  ·  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

161// identifier is always quoted. Double quotes inside the identifier
162// are escaped.
163func EncodeEscapedSQLIdent(buf *bytes.Buffer, s string) {
164 buf.WriteByte('"')
165 start := 0
166 for i, n := 0, len(s); i < n; i++ {
167 ch := s[i]
168 // The only character that requires escaping is a double quote.
169 if ch == '"' {
170 if start != i {
171 buf.WriteString(s[start:i])
172 }
173 start = i + 1
174 buf.WriteByte(ch)
175 buf.WriteByte(ch) // add extra copy of ch
176 }
177 }
178 if start < len(s) {
179 buf.WriteString(s[start:])
180 }
181 buf.WriteByte('"')
182}
183
184// EncodeLocaleName writes the locale identifier in s to buf. Any dash
185// characters are mapped to underscore characters. Underscore characters do not

Callers 2

EncodeRestrictedSQLIdentFunction · 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…