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

Function returningRefsColumn

transpiler/transform/writablecte.go:430–444  ·  view source on GitHub ↗

returningRefsColumn reports whether a RETURNING item references, by name, any column in cols. RETURNING * is deliberately NOT treated as a hit: it is the common row-identification idiom (callers typically consume only the key), and rejecting it would break legitimate upsert patterns. The narrower ri

(ret *pg_query.Node, cols map[string]bool)

Source from the content-addressed store, hash-verified

428// caller reads a modified column out of a RETURNING * is left as a documented
429// limitation.
430func returningRefsColumn(ret *pg_query.Node, cols map[string]bool) bool {
431 found := false
432 WalkFunc(&pg_query.ParseResult{Stmts: []*pg_query.RawStmt{{Stmt: ret}}}, func(n *pg_query.Node) bool {
433 if cr := n.GetColumnRef(); cr != nil {
434 for _, f := range cr.Fields {
435 if s := f.GetString_(); s != nil && cols[strings.ToLower(s.Sval)] {
436 found = true
437 return false
438 }
439 }
440 }
441 return true
442 })
443 return found
444}
445
446// updateToSelect converts UPDATE...FROM...WHERE...RETURNING to equivalent SELECT
447func (t *WritableCTETransform) updateToSelect(

Callers 1

Calls 1

WalkFuncFunction · 0.85

Tested by

no test coverage detected