MCPcopy
hub / github.com/go-sql-driver/mysql / escapeBytesQuotes

Function escapeBytesQuotes

utils.go:691–715  ·  view source on GitHub ↗

escapeBytesQuotes appends _binary'...' or '...' with single-quote escaping for bytes.

(buf, v []byte, binary bool)

Source from the content-addressed store, hash-verified

689
690// escapeBytesQuotes appends _binary'...' or '...' with single-quote escaping for bytes.
691func escapeBytesQuotes(buf, v []byte, binary bool) []byte {
692 pos := len(buf)
693 if binary {
694 buf = reserveBuffer(buf, len(v)*2+9)
695 copy(buf[pos:], []byte("_binary'"))
696 pos += 8
697 } else {
698 buf = reserveBuffer(buf, len(v)*2+2)
699 buf[pos] = '\''
700 pos++
701 }
702 for _, c := range v {
703 if c == '\'' {
704 buf[pos+1] = '\''
705 buf[pos] = '\''
706 pos += 2
707 } else {
708 buf[pos] = c
709 pos++
710 }
711 }
712 buf[pos] = '\''
713 pos++
714 return buf[:pos]
715}
716
717// escapeStringQuotes is similar to escapeBytesQuotes but for string.
718func escapeStringQuotes(buf []byte, v string) []byte {

Callers 2

TestEscapeQuotesFunction · 0.85
interpolateParamsMethod · 0.85

Calls 1

reserveBufferFunction · 0.85

Tested by 1

TestEscapeQuotesFunction · 0.68