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

Function collectCTENames

backend/plugin/parser/tidb/backup.go:410–416  ·  view source on GitHub ↗

collectCTENames returns the set of CTE (WITH clause) names that precede the statement, lower-cased for case-insensitive matching. omni does not attach UPDATE/DELETE CTEs to the statement node, so we parse the text before the statement Loc as a WITH clause.

(fullSQL string, stmtLoc ast.Loc)

Source from the content-addressed store, hash-verified

408// UPDATE/DELETE CTEs to the statement node, so we parse the text before the
409// statement Loc as a WITH clause.
410func collectCTENames(fullSQL string, stmtLoc ast.Loc) map[string]bool {
411 result := make(map[string]bool)
412 for _, cte := range parseCTEPrefix(fullSQL, stmtLoc) {
413 result[strings.ToLower(cte.Name)] = true
414 }
415 return result
416}
417
418// isCTERef reports whether ref resolves to a CTE. A CTE reference is always
419// unqualified, so a schema-qualified physical table (db.test) is never a CTE

Callers 2

extractTablesFromDeleteFunction · 0.70
extractTablesFromUpdateFunction · 0.70

Calls 1

parseCTEPrefixFunction · 0.70

Tested by

no test coverage detected