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

Function updateReturningReadsModifiedColumn

transpiler/transform/writablecte.go:403–422  ·  view source on GitHub ↗

updateReturningReadsModifiedColumn reports whether an UPDATE's RETURNING list references, by name, a column the UPDATE modifies (so the pre-update capture would be stale). RETURNING * is exempt (see returningRefsColumn). Returns false when there is no RETURNING list or it reads only unmodified colum

(u *pg_query.UpdateStmt)

Source from the content-addressed store, hash-verified

401// would be stale). RETURNING * is exempt (see returningRefsColumn). Returns false
402// when there is no RETURNING list or it reads only unmodified columns.
403func updateReturningReadsModifiedColumn(u *pg_query.UpdateStmt) bool {
404 if u == nil || len(u.ReturningList) == 0 {
405 return false
406 }
407 setCols := map[string]bool{}
408 for _, tgt := range u.TargetList {
409 if rt := tgt.GetResTarget(); rt != nil && rt.Name != "" {
410 setCols[strings.ToLower(rt.Name)] = true
411 }
412 }
413 if len(setCols) == 0 {
414 return false
415 }
416 for _, ret := range u.ReturningList {
417 if returningRefsColumn(ret, setCols) {
418 return true
419 }
420 }
421 return false
422}
423
424// returningRefsColumn reports whether a RETURNING item references, by name, any
425// column in cols. RETURNING * is deliberately NOT treated as a hit: it is the

Callers 1

rewriteWritableCTEMethod · 0.85

Calls 1

returningRefsColumnFunction · 0.85

Tested by

no test coverage detected