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

Function isExplainStmt

server/conn.go:1828–1842  ·  view source on GitHub ↗

isExplainStmt reports whether the query is an EXPLAIN statement (the EXPLAIN keyword followed by a space or '('). Used to avoid executing EXPLAIN at Describe time — EXPLAIN ANALYZE of a write mutates, and a describe-probe execution would run it a second time.

(query string)

Source from the content-addressed store, hash-verified

1826 // Determine command type for proper response
1827 upperQuery := strings.ToUpper(query)
1828 cmdType := c.getCommandType(upperQuery)
1829
1830 // Handle COPY commands specially
1831 if cmdType == "COPY" {
1832 return c.handleCopy(query, upperQuery)
1833 }
1834
1835 // For queries that don't return result rows, use Exec
1836 if !queryReturnsResults(query) {
1837 // Handle nested BEGIN: PostgreSQL issues a warning but continues,
1838 // while DuckDB throws an error. Match PostgreSQL behavior.
1839 if cmdType == "BEGIN" && c.txStatus == txStatusTransaction {
1840 c.sendNotice("WARNING", "25001", "there is already a transaction in progress")
1841 _ = c.writeCommandComplete("BEGIN")
1842 _ = c.writeReadyForQuery(c.txStatus)
1843 _ = c.flushWriter()
1844 return nil
1845 }

Callers 1

handleDescribeMethod · 0.85

Calls 1

stripLeadingNoiseFunction · 0.85

Tested by

no test coverage detected