MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / parsePeriodDefinition

Method parsePeriodDefinition

pkg/sql/parser/mariadb.go:440–480  ·  view source on GitHub ↗

parsePeriodDefinition parses: PERIOD FOR name (start_col, end_col) The caller positions the parser at the PERIOD keyword; this function advances past it.

()

Source from the content-addressed store, hash-verified

438// parsePeriodDefinition parses: PERIOD FOR name (start_col, end_col)
439// The caller positions the parser at the PERIOD keyword; this function advances past it.
440func (p *Parser) parsePeriodDefinition() (*ast.PeriodDefinition, error) {
441 // current token is PERIOD; advance past it
442 p.advance()
443 if !strings.EqualFold(p.currentToken.Token.Value, "FOR") {
444 return nil, p.expectedError("FOR")
445 }
446 p.advance()
447
448 // Use parseColumnName so that reserved-keyword period names like SYSTEM_TIME are accepted.
449 name := p.parseColumnName()
450 if name == nil || name.Name == "" {
451 return nil, p.expectedError("period name")
452 }
453
454 if !p.isType(models.TokenTypeLParen) {
455 return nil, p.expectedError("(")
456 }
457 p.advance()
458
459 startCol := p.parseIdent()
460 if startCol == nil || startCol.Name == "" {
461 return nil, p.expectedError("start column name")
462 }
463
464 if !p.isType(models.TokenTypeComma) {
465 return nil, p.expectedError(",")
466 }
467 p.advance()
468
469 endCol := p.parseIdent()
470 if endCol == nil || endCol.Name == "" {
471 return nil, p.expectedError("end column name")
472 }
473
474 if !p.isType(models.TokenTypeRParen) {
475 return nil, p.expectedError(")")
476 }
477 p.advance()
478
479 return &ast.PeriodDefinition{Name: name, StartCol: startCol, EndCol: endCol}, nil
480}

Callers 1

parseCreateTableMethod · 0.95

Calls 5

advanceMethod · 0.95
expectedErrorMethod · 0.95
parseColumnNameMethod · 0.95
isTypeMethod · 0.95
parseIdentMethod · 0.95

Tested by

no test coverage detected