MCPcopy Create free account
hub / github.com/PostHog/duckgres / queryLogEntryInsertArgs

Function queryLogEntryInsertArgs

server/querylog.go:345–374  ·  view source on GitHub ↗
(e QueryLogEntry)

Source from the content-addressed store, hash-verified

343// that differ only in parameter values.
344func 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.
372func 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

Callers 2

insertQueryLogEntriesFunction · 0.85

Calls 2

truncateNullableQueryFunction · 0.85
truncateQueryFunction · 0.70

Tested by

no test coverage detected