parseRefreshStatement parses REFRESH MATERIALIZED VIEW statement
()
| 235 | |
| 236 | // parseRefreshStatement parses REFRESH MATERIALIZED VIEW statement |
| 237 | func (p *Parser) parseRefreshStatement() (*ast.RefreshMaterializedViewStatement, error) { |
| 238 | // Expect MATERIALIZED |
| 239 | if !p.isType(models.TokenTypeMaterialized) { |
| 240 | return nil, p.expectedError("MATERIALIZED after REFRESH") |
| 241 | } |
| 242 | p.advance() // Consume MATERIALIZED |
| 243 | |
| 244 | // Expect VIEW |
| 245 | if !p.isType(models.TokenTypeView) { |
| 246 | return nil, p.expectedError("VIEW after MATERIALIZED") |
| 247 | } |
| 248 | p.advance() // Consume VIEW |
| 249 | |
| 250 | stmt := &ast.RefreshMaterializedViewStatement{} |
| 251 | |
| 252 | // Check for CONCURRENTLY |
| 253 | if p.isTokenMatch("CONCURRENTLY") { |
| 254 | stmt.Concurrently = true |
| 255 | p.advance() |
| 256 | } |
| 257 | |
| 258 | // Parse view name (supports schema.view qualification and double-quoted identifiers) |
| 259 | refreshViewName, err := p.parseQualifiedName() |
| 260 | if err != nil { |
| 261 | return nil, p.expectedError("materialized view name") |
| 262 | } |
| 263 | stmt.Name = refreshViewName |
| 264 | |
| 265 | // Parse optional WITH [NO] DATA |
| 266 | // Note: DATA and NO may be tokenized as IDENT since they're common identifiers |
| 267 | if p.isType(models.TokenTypeWith) { |
| 268 | p.advance() // Consume WITH |
| 269 | if p.isTokenMatch("NO") { |
| 270 | p.advance() // Consume NO |
| 271 | if !p.isTokenMatch("DATA") { |
| 272 | return nil, p.expectedError("DATA after NO") |
| 273 | } |
| 274 | p.advance() // Consume DATA |
| 275 | withData := false |
| 276 | stmt.WithData = &withData |
| 277 | } else if p.isTokenMatch("DATA") { |
| 278 | p.advance() // Consume DATA |
| 279 | withData := true |
| 280 | stmt.WithData = &withData |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | return stmt, nil |
| 285 | } |
no test coverage detected