(pos Pos)
| 120 | } |
| 121 | |
| 122 | func (p *Parser) parseSystemCtrlExpr(pos Pos) (*SystemCtrlExpr, error) { |
| 123 | if !p.matchKeyword(KeywordStart) && !p.matchKeyword(KeywordStop) { |
| 124 | return nil, fmt.Errorf("expected START|STOP") |
| 125 | } |
| 126 | command := strings.ToUpper(p.last().String) |
| 127 | _ = p.lexer.consumeToken() |
| 128 | |
| 129 | var typ string |
| 130 | switch { |
| 131 | case p.tryConsumeKeywords(KeywordDistributed): |
| 132 | switch { |
| 133 | case p.matchKeyword(KeywordSends): |
| 134 | typ = "DISTRIBUTED SENDS" |
| 135 | case p.matchKeyword(KeywordFetches): |
| 136 | typ = "FETCHES" |
| 137 | case p.matchKeyword(KeywordMerges): |
| 138 | typ = "MERGES" |
| 139 | case p.matchKeyword(KeywordTtl): |
| 140 | typ = "TTL MERGES" |
| 141 | if err := p.expectKeyword(KeywordMerges); err != nil { |
| 142 | return nil, err |
| 143 | } |
| 144 | default: |
| 145 | return nil, fmt.Errorf("expected SENDS|FETCHES|MERGES|TTL") |
| 146 | } |
| 147 | cluster, err := p.parseTableIdentifier(p.Pos()) |
| 148 | if err != nil { |
| 149 | return nil, err |
| 150 | } |
| 151 | return &SystemCtrlExpr{ |
| 152 | CtrlPos: pos, |
| 153 | StatementEnd: cluster.End(), |
| 154 | Command: command, |
| 155 | Type: typ, |
| 156 | Cluster: cluster, |
| 157 | }, nil |
| 158 | case p.tryConsumeKeywords(KeywordReplicated): |
| 159 | lastToken := p.last() |
| 160 | if err := p.expectKeyword(KeywordSends); err != nil { |
| 161 | return nil, err |
| 162 | } |
| 163 | typ = "REPLICATED SENDS" |
| 164 | return &SystemCtrlExpr{ |
| 165 | CtrlPos: pos, |
| 166 | StatementEnd: lastToken.End, |
| 167 | Command: command, |
| 168 | Type: typ, |
| 169 | }, nil |
| 170 | default: |
| 171 | return nil, fmt.Errorf("expected DISTRIBUTED|REPLICATED") |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | func (p *Parser) parseSystemDropExpr(pos Pos) (*SystemDropExpr, error) { |
| 176 | if err := p.expectKeyword(KeywordDrop); err != nil { |
no test coverage detected