(
scx: &mut StatementContext,
stmt: CommentStatement<Aug>,
)
| 7660 | } |
| 7661 | |
| 7662 | pub 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) => { |
no test coverage detected