MCPcopy Index your code
hub / github.com/bytebase/bytebase / installReal

Method installReal

backend/plugin/parser/pg/query_span_loader.go:548–591  ·  view source on GitHub ↗

installReal translates the object's metadata into an AST and calls the matching omni DefineX / ExecCreateTableAs / CreateFunctionStmt. Returns the first error encountered.

(obj *objectEntry)

Source from the content-addressed store, hash-verified

546// matching omni DefineX / ExecCreateTableAs / CreateFunctionStmt. Returns
547// the first error encountered.
548func (l *catalogLoader) installReal(obj *objectEntry) error {
549 switch obj.kind {
550 case kindSchema:
551 err := l.cat.CreateSchemaCommand(&ast.CreateSchemaStmt{
552 Schemaname: obj.schema,
553 })
554 // Built-in schemas (public, pg_catalog, pg_toast) are preloaded by
555 // catalog.New(). Treating duplicate-schema as success keeps the
556 // loader's "every metadata object is present post-Load" invariant
557 // without needing a hardcoded exclusion list.
558 var cErr *catalog.Error
559 if errors.As(err, &cErr) && cErr.Code == catalog.CodeDuplicateSchema {
560 return nil
561 }
562 return err
563 case kindEnum:
564 return l.cat.DefineEnum(buildCreateEnumStmt(obj.schema, obj.enumMeta))
565 case kindTable:
566 stmt, err := buildCreateStmt(obj.schema, obj.tableMeta)
567 if err != nil {
568 return err
569 }
570 return l.cat.DefineRelation(stmt, 'r')
571 case kindView:
572 stmt, err := buildViewStmt(obj.schema, obj.viewMeta)
573 if err != nil {
574 return err
575 }
576 return l.cat.DefineView(stmt)
577 case kindMatView:
578 stmt, err := buildCreateTableAsStmt(obj.schema, obj.matViewMeta)
579 if err != nil {
580 return err
581 }
582 return l.cat.ExecCreateTableAs(stmt)
583 case kindFunction:
584 stmt, err := buildCreateFunctionStmt(obj.schema, obj.funcMeta)
585 if err != nil {
586 return err
587 }
588 return l.cat.CreateFunctionStmt(stmt)
589 }
590 return errors.Errorf("unknown object kind %d", obj.kind)
591}
592
593// installPseudo builds and installs the pseudo variant of an object. Every
594// pseudo form is text-backed and free of user-object dependencies, so this

Callers 1

installOneMethod · 0.95

Calls 6

buildCreateEnumStmtFunction · 0.85
buildCreateStmtFunction · 0.85
buildViewStmtFunction · 0.85
buildCreateTableAsStmtFunction · 0.85
buildCreateFunctionStmtFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected