MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / plan_comment

Function plan_comment

src/sql/src/plan/statement/ddl.rs:7662–7820  ·  view source on GitHub ↗
(
    scx: &mut StatementContext,
    stmt: CommentStatement<Aug>,
)

Source from the content-addressed store, hash-verified

7660}
7661
7662pub fn plan_comment(
7663 scx: &mut StatementContext,
7664 stmt: CommentStatement<Aug>,
7665) -> Result<Plan, PlanError> {
7666 const MAX_COMMENT_LENGTH: usize = 1024;
7667
7668 let CommentStatement { object, comment } = stmt;
7669
7670 // TODO(parkmycar): Make max comment length configurable.
7671 if let Some(c) = &comment {
7672 if c.len() > 1024 {
7673 return Err(PlanError::CommentTooLong {
7674 length: c.len(),
7675 max_size: MAX_COMMENT_LENGTH,
7676 });
7677 }
7678 }
7679
7680 let (object_id, column_pos) = match &object {
7681 com_ty @ CommentObjectType::Table { name }
7682 | com_ty @ CommentObjectType::View { name }
7683 | com_ty @ CommentObjectType::MaterializedView { name }
7684 | com_ty @ CommentObjectType::Index { name }
7685 | com_ty @ CommentObjectType::Func { name }
7686 | com_ty @ CommentObjectType::Connection { name }
7687 | com_ty @ CommentObjectType::Source { name }
7688 | com_ty @ CommentObjectType::Sink { name }
7689 | com_ty @ CommentObjectType::Secret { name } => {
7690 let item = scx.get_item_by_resolved_name(name)?;
7691 match (com_ty, item.item_type()) {
7692 (CommentObjectType::Table { .. }, CatalogItemType::Table) => {
7693 (CommentObjectId::Table(item.id()), None)
7694 }
7695 (CommentObjectType::View { .. }, CatalogItemType::View) => {
7696 (CommentObjectId::View(item.id()), None)
7697 }
7698 (CommentObjectType::MaterializedView { .. }, CatalogItemType::MaterializedView) => {
7699 (CommentObjectId::MaterializedView(item.id()), None)
7700 }
7701 (CommentObjectType::Index { .. }, CatalogItemType::Index) => {
7702 (CommentObjectId::Index(item.id()), None)
7703 }
7704 (CommentObjectType::Func { .. }, CatalogItemType::Func) => {
7705 (CommentObjectId::Func(item.id()), None)
7706 }
7707 (CommentObjectType::Connection { .. }, CatalogItemType::Connection) => {
7708 (CommentObjectId::Connection(item.id()), None)
7709 }
7710 (CommentObjectType::Source { .. }, CatalogItemType::Source) => {
7711 (CommentObjectId::Source(item.id()), None)
7712 }
7713 (CommentObjectType::Sink { .. }, CatalogItemType::Sink) => {
7714 (CommentObjectId::Sink(item.id()), None)
7715 }
7716 (CommentObjectType::Secret { .. }, CatalogItemType::Secret) => {
7717 (CommentObjectId::Secret(item.id()), None)
7718 }
7719 (com_ty, cat_ty) => {

Callers 1

planFunction · 0.85

Calls 15

database_idMethod · 0.80
database_specMethod · 0.80
schema_specMethod · 0.80
SchemaClass · 0.70
TableClass · 0.50
ViewClass · 0.50
MaterializedViewClass · 0.50
IndexClass · 0.50
FuncEnum · 0.50
ConnectionClass · 0.50

Tested by

no test coverage detected