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

Function getResourceChanges

backend/plugin/parser/tidb/resource_change.go:74–299  ·  view source on GitHub ↗
(database string, node tidbast.StmtNode, _ string, changedResources *model.ChangedResources)

Source from the content-addressed store, hash-verified

72}
73
74func getResourceChanges(database string, node tidbast.StmtNode, _ string, changedResources *model.ChangedResources) error {
75 switch node := node.(type) {
76 case *tidbast.CreateTableStmt:
77 d, table := node.Table.Schema.O, node.Table.Name.O
78 if d == "" {
79 d = database
80 }
81 changedResources.AddTable(
82 d,
83 "",
84 &storepb.ChangedResourceTable{
85 Name: table,
86 },
87 false,
88 )
89 case *tidbast.DropTableStmt:
90 if node.IsView {
91 // Views aren't tracked as changed tables (risk/approval doesn't use them), but a
92 // qualified cross-database DROP VIEW is gated by its target database. SUP-222.
93 for _, name := range node.Tables {
94 addTiDBObjectDatabase(changedResources, name)
95 }
96 return nil
97 }
98 for _, name := range node.Tables {
99 d, table := name.Schema.O, name.Name.O
100 if d == "" {
101 d = database
102 }
103 changedResources.AddTable(
104 d,
105 "",
106 &storepb.ChangedResourceTable{
107 Name: table,
108 },
109 true,
110 )
111 }
112 case *tidbast.AlterTableStmt:
113 d, table := node.Table.Schema.O, node.Table.Name.O
114 if d == "" {
115 d = database
116 }
117 changedResources.AddTable(
118 d,
119 "",
120 &storepb.ChangedResourceTable{
121 Name: table,
122 },
123 true,
124 )
125 case *tidbast.TruncateTableStmt:
126 d, table := node.Table.Schema.O, node.Table.Name.O
127 if d == "" {
128 d = database
129 }
130 changedResources.AddTable(
131 d,

Callers 1

extractChangedResourcesFunction · 0.85

Calls 3

addTiDBObjectDatabaseFunction · 0.85
extractTableRefsFunction · 0.85
AddTableMethod · 0.80

Tested by

no test coverage detected