(e QueryLogEntry)
| 343 | // that differ only in parameter values. |
| 344 | func normalizeQueryHash(query string) int64 { |
| 345 | // Collapse whitespace |
| 346 | var sb strings.Builder |
| 347 | inSpace := false |
| 348 | for _, r := range query { |
| 349 | if unicode.IsSpace(r) { |
| 350 | if !inSpace { |
| 351 | sb.WriteByte(' ') |
| 352 | inSpace = true |
| 353 | } |
| 354 | } else { |
| 355 | sb.WriteRune(r) |
| 356 | inSpace = false |
| 357 | } |
| 358 | } |
| 359 | normalized := strings.TrimSpace(strings.ToUpper(sb.String())) |
| 360 | |
| 361 | // Replace literals with ? |
| 362 | normalized = literalRegexp.ReplaceAllString(normalized, "?") |
| 363 | normalized = comparisonBoolNullRegexp.ReplaceAllString(normalized, "$1 ?") |
| 364 | |
| 365 | h := fnv.New64a() |
| 366 | h.Write([]byte(normalized)) |
| 367 | return int64(h.Sum64()) |
| 368 | } |
| 369 | |
| 370 | // isQueryLogSelfReferential returns true if the query targets system.query_log, |
| 371 | // to prevent infinite recursion. |
| 372 | func isQueryLogSelfReferential(query string) bool { |
| 373 | upper := strings.ToUpper(query) |
| 374 | return strings.Contains(upper, "SYSTEM.QUERY_LOG") |
| 375 | } |
| 376 | |
| 377 | // queryLogSink resolves where this connection's query-log entries go. The |
no test coverage detected