canCacheQuery returns true if q can be cached.
(q []byte)
| 178 | |
| 179 | // canCacheQuery returns true if q can be cached. |
| 180 | func canCacheQuery(q []byte) bool { |
| 181 | q = skipLeadingComments(q) |
| 182 | |
| 183 | for _, statement := range cachableStatements { |
| 184 | if len(q) < len(statement) { |
| 185 | continue |
| 186 | } |
| 187 | |
| 188 | l := bytes.ToUpper(q[:len(statement)]) |
| 189 | if bytes.HasPrefix(l, []byte(statement)) { |
| 190 | return true |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | return false |
| 195 | } |
| 196 | |
| 197 | //nolint:cyclop // No clean way to split this. |
| 198 | func skipLeadingComments(q []byte) []byte { |