示例#1
0
        public IQsiDefinitionNode VisitViewStmt(ViewStmt stmt)
        {
            var node = new PgViewDefinitionNode
            {
                Identifier  = IdentifierVisitor.VisitRangeVar(stmt.view[0]),
                Source      = { Value = TableVisitor.Visit(stmt.query[0]) },
                CheckOption = stmt.withCheckOption?.ToString()
            };

            if (stmt.replace ?? false)
            {
                node.ConflictBehavior = QsiDefinitionConflictBehavior.Replace;
            }

            // stmt.options: DefElem[]
            // Syntax: WITH ( key=<value_expression> [, ...] )

            if (!ListUtility.IsNullOrEmpty(stmt.aliases))
            {
                node.Columns.Value = new QsiColumnsDeclarationNode();
                node.Columns.Value.Columns.AddRange(TableVisitor.CreateSequentialColumnNodes(stmt.aliases.Cast <PgString>()));
            }

            return(node);
        }
示例#2
0
        public IQsiDefinitionNode VisitCreateTableAsStmt(CreateTableAsStmt stmt)
        {
            if (stmt.relkind != ObjectType.OBJECT_MATVIEW)
            {
                throw TreeHelper.NotSupportedTree($"{nameof(CreateTableAsStmt)}({stmt.relkind})");
            }

            var node = new QsiViewDefinitionNode
            {
                Identifier = IdentifierVisitor.VisitRangeVar(stmt.into[0].rel[0]),
                Source     = { Value = TableVisitor.Visit(stmt.query[0]) }
            };

            if (stmt.if_not_exists ?? false)
            {
                node.ConflictBehavior = QsiDefinitionConflictBehavior.Ignore;
            }

            return(node);
        }