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

Function IsEmptyQuery

server/sqlcore/query.go:8–16  ·  view source on GitHub ↗

IsEmptyQuery checks if a query contains only semicolons, whitespace, and/or SQL comments. PostgreSQL returns EmptyQueryResponse for queries like ";", "-- ping", "/* */", etc.

(query string)

Source from the content-addressed store, hash-verified

6// SQL comments. PostgreSQL returns EmptyQueryResponse for queries like ";",
7// "-- ping", "/* */", etc.
8func IsEmptyQuery(query string) bool {
9 stripped := StripLeadingComments(query)
10 for _, r := range stripped {
11 if r != ';' && r != ' ' && r != '\t' && r != '\n' && r != '\r' {
12 return false
13 }
14 }
15 return true
16}
17
18// StripLeadingComments removes leading SQL comments from a query.
19// Handles both block comments /* ... */ and line comments -- ...

Callers 3

isEmptyQueryFunction · 0.92
QueryContextMethod · 0.92
ExecContextMethod · 0.92

Calls 1

StripLeadingCommentsFunction · 0.85

Tested by

no test coverage detected