MCPcopy
hub / github.com/jackc/pgx / init

Method init

internal/sanitize/sanitize.go:126–146  ·  view source on GitHub ↗
(sql string)

Source from the content-addressed store, hash-verified

124}
125
126func (q *Query) init(sql string) {
127 parts := q.Parts[:0]
128 if parts == nil {
129 // dirty, but fast heuristic to preallocate for ~90% usecases
130 n := strings.Count(sql, "$") + strings.Count(sql, "--") + 1
131 parts = make([]Part, 0, n)
132 }
133
134 l := sqlLexerPool.get()
135 defer sqlLexerPool.put(l)
136
137 l.src = sql
138 l.stateFn = rawState
139 l.parts = parts
140
141 for l.stateFn != nil {
142 l.stateFn = l.stateFn(l)
143 }
144
145 q.Parts = l.parts
146}
147
148func QuoteString(dst []byte, str string) []byte {
149 const quote = '\''

Callers 2

NewQueryFunction · 0.95
SanitizeSQLFunction · 0.80

Calls 2

getMethod · 0.80
putMethod · 0.80

Tested by

no test coverage detected