MCPcopy Create free account
hub / github.com/bytebase/bytebase / isWriteSelect

Function isWriteSelect

backend/plugin/parser/pg/query_antlr.go:91–99  ·  view source on GitHub ↗

isWriteSelect reports whether a SelectStmt actually writes — and so must not take the read-only editor path. A SELECT writes if it has an INTO target (SELECT ... INTO creates a table) or any of its CTE terms is data-modifying. This is the unified write-detection primitive for the read-only gate; cl

(n *ast.SelectStmt)

Source from the content-addressed store, hash-verified

89// classifyQueryType (query_type.go) keeps reporting the root statement type for its
90// own consumers — only the detection is shared, not the classifiers' outputs.
91func isWriteSelect(n *ast.SelectStmt) bool {
92 if n == nil {
93 return false
94 }
95 if hasOmniIntoClause(n) {
96 return true
97 }
98 return containsWriteCTE(n)
99}
100
101// containsWriteCTE reports whether any common table expression in the tree is
102// data-modifying. Fail-safe by construction — a whitelist, not a denylist: a CTE

Callers 1

validateQueryANTLRFunction · 0.85

Calls 2

hasOmniIntoClauseFunction · 0.85
containsWriteCTEFunction · 0.85

Tested by

no test coverage detected