public static IQsiDefinitionNode VisitCreateViewStatement(CreateViewContext context) { if (!context.TryGetTokenIndex(VIEW_SYMBOL, out var index)) { throw new QsiException(QsiError.Syntax); } var viewName = (ViewNameContext)context.children[index + 1]; var viewTail = (ViewTailContext)context.children[index + 2]; var columnInternalRefList = viewTail.columnInternalRefList(); var node = new MySqlViewDefinitionNode { Identifier = IdentifierVisitor.VisitViewName(viewName), }; if (context.viewReplaceOrAlgorithm() != null) { var replaceOrAlgorithm = context.viewReplaceOrAlgorithm(); node.Replace = replaceOrAlgorithm.HasToken(REPLACE_SYMBOL); if (replaceOrAlgorithm.viewAlgorithm() != null) { node.ViewAlgorithm.SetValue(TreeHelper.Fragment(replaceOrAlgorithm.viewAlgorithm().GetInputText())); } } if (context.definerClause() != null) { node.Definer = context.definerClause().user().GetInputText(); } if (context.viewSuid() != null) { node.ViewSuid.SetValue(TreeHelper.Fragment(context.viewSuid().GetInputText())); } node.Columns.SetValue(columnInternalRefList == null ? TreeHelper.CreateAllColumnsDeclaration() : TableVisitor.CreateSequentialColumns(columnInternalRefList)); node.Source.SetValue(TableVisitor.VisitViewSelect(viewTail.viewSelect())); return(node); }
public static QsiActionNode VisitDeleteStatement(DeleteStatementContext context) { var derivedNode = new QsiDerivedTableNode(); var withClause = context.withClause(); var whereClause = context.whereClause(); var tableAliasRefList = context.tableAliasRefList(); if (withClause != null) { derivedNode.Directives.SetValue(TableVisitor.VisitWithClause(withClause)); } if (whereClause != null) { derivedNode.Where.SetValue(ExpressionVisitor.VisitWhereClause(whereClause)); } if (tableAliasRefList != null) { var tableReferenceList = context.tableReferenceList(); (QsiQualifiedIdentifier Identifier, bool Wildcard)[] aliases = tableAliasRefList.tableRefWithWildcard()