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

Function collectSingleTablesFromExpr

backend/plugin/parser/mysql/backup.go:250–276  ·  view source on GitHub ↗
(databaseName string, expr ast.TableExpr, out map[string]*TableReference)

Source from the content-addressed store, hash-verified

248}
249
250func collectSingleTablesFromExpr(databaseName string, expr ast.TableExpr, out map[string]*TableReference) {
251 switch e := expr.(type) {
252 case *ast.TableRef:
253 db := e.Schema
254 if db == "" {
255 db = databaseName
256 }
257 ref := &TableReference{
258 Database: db,
259 Table: e.Name,
260 Alias: e.Alias,
261 }
262 key := e.Name
263 if e.Alias != "" {
264 key = e.Alias
265 }
266 out[key] = ref
267 case *ast.JoinClause:
268 if e.Left != nil {
269 collectSingleTablesFromExpr(databaseName, e.Left, out)
270 }
271 if e.Right != nil {
272 collectSingleTablesFromExpr(databaseName, e.Right, out)
273 }
274 default:
275 }
276}
277
278// collectCTENames extracts CTE names from the SQL text before the statement Loc.
279// MySQL's UPDATE/DELETE CTEs are not in the omni AST, so we parse the prefix.

Callers 1

collectSingleTablesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected