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

Function handleDropTableOmni

backend/plugin/parser/pg/resource_change.go:231–253  ·  view source on GitHub ↗

handleDropTableOmni handles DROP TABLE/MATERIALIZED VIEW.

(n *ast.DropStmt, database string, searchPath []string, dbMetadata *model.DatabaseMetadata, changedResources *model.ChangedResources)

Source from the content-addressed store, hash-verified

229
230// handleDropTableOmni handles DROP TABLE/MATERIALIZED VIEW.
231func handleDropTableOmni(n *ast.DropStmt, database string, searchPath []string, dbMetadata *model.DatabaseMetadata, changedResources *model.ChangedResources) {
232 if n.Objects == nil {
233 return
234 }
235 for _, item := range n.Objects.Items {
236 nameList, ok := item.(*ast.List)
237 if !ok {
238 continue
239 }
240 db, schema, name := extractNameListParts(nameList, database)
241 if schema == "" {
242 schemaName, _ := dbMetadata.SearchObject(searchPath, name)
243 if schemaName == "" {
244 if len(searchPath) > 0 {
245 schema = searchPath[0]
246 }
247 } else {
248 schema = schemaName
249 }
250 }
251 changedResources.AddTable(db, schema, &storepb.ChangedResourceTable{Name: name}, true)
252 }
253}
254
255// handleDropIndexOmni handles DROP INDEX.
256func handleDropIndexOmni(n *ast.DropStmt, database string, searchPath []string, dbMetadata *model.DatabaseMetadata, changedResources *model.ChangedResources) {

Callers 1

extractChangedResourcesFunction · 0.85

Calls 3

extractNameListPartsFunction · 0.85
AddTableMethod · 0.80
SearchObjectMethod · 0.45

Tested by

no test coverage detected