class MariaDbParser extends MySqlParser

Constants

private ENTRY_ENDS

The texts of the punctuation and terminator that end a list entry.

private DATA_STATEMENTS

Statements that change rows rather than relations.

protected NON_RELATION_OBJECTS

Kinds of objects that are not relations, which a relation only depends on in ways that stop a drop without CASCADE.

protected COLUMN_CLAUSES

Keywords that begin a column clause, so none of them can name a column type.

protected INDEX_KINDS

The kinds of index that CREATE INDEX can name before its INDEX keyword.

private TABLE_ENTRY_STARTS

The first keywords of the constraints and indexes in a table definition.

private UNNAMED_CONSTRAINTS

The constraints that can directly follow CONSTRAINT, which then has no name.

private TABLE_OPTIONS

Physical table options with a scalar value.

private COLUMN_OPTIONS

Physical column options with a scalar value.

private INDEX_OPTIONS

Physical index options with a scalar value.

Methods

parse(string $sql)

Parse a SQL schema dump.

from  Parser
createLexer(string $sql)

Create the lexer for one input, reading MariaDB executable comments as SQL.

createState(string $sql)

Create the state of one parse.

from  Parser
void
parseStatement(TokenStream $tokens, ParseState $state)

Read the statement's represented facts, leaving any unread remainder to be skipped.

parseType(TokenStream $tokens, ParseState $state)

Read a column type with its modifiers, enum or set labels and attributes.

void
recordUnreadStatement(TokenStream $tokens, ParseState $state)

Record that a statement the dialect does not read may change relations without naming them, unless it only changes rows.

from  Parser
string
parseName(TokenStream $tokens, string $description)

Read an identifier.

from  Parser
parseQualifiedName(TokenStream $tokens, string $description)

Read an optionally schema-qualified name.

from  Parser
parseRelationName(TokenStream $tokens, ParseState $state, string $description)

Read the name of a table or view, which belongs to the default schema when unqualified.

from  Parser
array
parseNameList(TokenStream $tokens, string $description)

Read a parenthesized list of identifiers.

from  Parser
string
parseCollation(TokenStream $tokens)

Read a collation name, keeping its qualification and quoting as written.

from  Parser
string
parseGroup(TokenStream $tokens)

Read a parenthesized group, returning its source text with the brackets.

from  Parser
string
parseExpression(TokenStream $tokens, array $clauses, string $description)

Read an expression that ends before a clause keyword or the end of its list entry.

from  Parser
bool
atClause(TokenStream $tokens, array $clauses)

Determine whether the current word begins one of the given clauses rather than naming a schema.

from  Parser
string|null
parseLiteral(TokenStream $tokens)

Read a string literal that forms a complete value, or return null without consuming anything.

from  Parser
bool
atEntryEnd(TokenStream $tokens)

Determine whether the current list entry, such as a column definition, has ended.

from  Parser
void
skipEntry(TokenStream $tokens)

Skip the rest of the current list entry.

from  Parser
void
parseTableBody(TokenStream $tokens, ParseState $state, TableDefinition $table)

Read the parenthesized columns and constraints of a table.

from  Parser
bool
isTableConstraint(TokenStream $tokens)

Determine whether a table body entry is a constraint, index or period rather than a column.

string|null
parseConstraintName(TokenStream $tokens)

Read the name given by a CONSTRAINT keyword, which MySQL lets a constraint omit.

void
parseTableConstraint(TokenStream $tokens, ParseState $state, TableDefinition $table)

Read a table constraint, keeping an unsupported one as a table issue.

from  Parser
bool
parseConstraint(TokenStream $tokens, ParseState $state, TableDefinition $table, string|null $column, string|null $name)

Read a table constraint, index or period, or a column constraint on the given column, returning false when it is not supported.

parseColumn(TokenStream $tokens, ParseState $state, TableDefinition $table)

Read a column definition into the table, expanding SERIAL into the facts it stands for.

bool
parseColumnConstraint(TokenStream $tokens, ParseState $state, TableDefinition $table, ColumnDefinition $column, string|null $name)

Read one column clause, returning false when it is not supported.

parseGeneration(TokenStream $tokens)

Read a generated column's expression and kind, which PERSISTENT also declares stored.

void
markPrimaryKeyColumnsNotNull(Index $index, TableDefinition $table)

Make the columns of a primary key non-null on a table.

from  Parser
findColumn(TableDefinition $table, string $name)

Find a table's column by name, which MySQL compares case-insensitively.

array
parseIndexColumns(TokenStream $tokens, ParseState $state, TableDefinition $table)

Read a parenthesized list of index keys.

from  Parser
parseIndexColumn(TokenStream $tokens, ParseState $state, TableDefinition $table)

Read an index key, keeping an application-time period key part as its source text.

array
parseForeignKeyRules(TokenStream $tokens, ParseState $state, TableDefinition $table)

Read a foreign key's match mode and referential actions, which can come in any order.

from  Parser
ReferentialAction
parseReferentialAction(TokenStream $tokens)

Read a referential action.

from  Parser
parseCreateView(TokenStream $tokens, ParseState $state, bool $materialized = false)

Read a view from its name, without inferring the types its query produces, and return its name.

from  Parser
bool
isTemporary(TableReference $reference)

Determine whether a name belongs to the session's temporary schema.

from  Parser
bool
relationExists(ParseState $state, string|null $schema, string $name)

Determine whether a known relation already has the given name.

from  Parser
string
parseViewQuery(TokenStream $tokens)

Read a view query, excluding a trailing view option.

from  Parser
bool
isViewOption(TokenStream $tokens)

Determine whether a WITH clause is the view's trailing check option.

from  Parser
freeze(ParseState $state)

Freeze the parsed definitions into a schema.

from  Parser
freezeTable(TableDefinition $table, ParseState $state)

Freeze a table after resolving foreign keys that omit their referenced columns.

from  Parser
array|null
referencedColumns(ForeignKey $foreignKey, ParseState $state)

Get the columns a foreign key references, which default to the referenced table's primary key, or null when they cannot be resolved.

from  Parser
freezeColumn(ColumnDefinition $column, TableDefinition $table, ParseState $state)

Freeze a column.

from  Parser
void
parseTableTail(TokenStream $tokens, ParseState $state, TableDefinition $table, bool $columns)

Report system versioning, which adds implicit columns and temporal rules, before the rest of a table's tail.

void
parseTableIndex(TokenStream $tokens, ParseState $state, TableDefinition $table, string|null $name, string|null $type = null, bool $unique = false)

Read a table index after its kind keywords, starting from its optional name.

void
parseReferences(TokenStream $tokens, ParseState $state, TableDefinition $table, string|null $name, array $columns)

Read a foreign key's referenced table, columns and rules after its REFERENCES keyword.

string|null
foreignKeyName(string|null $constraintName, string|null $indexName)

Name a foreign key by its constraint name, or else by its index name as MariaDB does.

Details

in Parser at line 62
Schema parse(string $sql)

Parse a SQL schema dump.

Parameters

string $sql

Return Value

Schema

at line 26
protected Lexer createLexer(string $sql)

Create the lexer for one input, reading MariaDB executable comments as SQL.

Parameters

string $sql

Return Value

Lexer

in Parser at line 86
protected ParseState createState(string $sql)

Create the state of one parse.

Parameters

string $sql

Return Value

ParseState

in MySqlParser at line 111
protected void parseStatement(TokenStream $tokens, ParseState $state)

Read the statement's represented facts, leaving any unread remainder to be skipped.

Parameters

TokenStream $tokens
ParseState $state

Return Value

void

in MySqlParser at line 432
protected ColumnType parseType(TokenStream $tokens, ParseState $state)

Read a column type with its modifiers, enum or set labels and attributes.

Parameters

TokenStream $tokens
ParseState $state

Return Value

ColumnType

in Parser at line 108
protected void recordUnreadStatement(TokenStream $tokens, ParseState $state)

Record that a statement the dialect does not read may change relations without naming them, unless it only changes rows.

Row changes can still run server-side code, such as triggers, whose effects are outside the impact.

Parameters

TokenStream $tokens
ParseState $state

Return Value

void

in Parser at line 118
protected string parseName(TokenStream $tokens, string $description)

Read an identifier.

Parameters

TokenStream $tokens
string $description

Return Value

string

in Parser at line 126
protected TableReference parseQualifiedName(TokenStream $tokens, string $description)

Read an optionally schema-qualified name.

Parameters

TokenStream $tokens
string $description

Return Value

TableReference

in Parser at line 138
protected TableReference parseRelationName(TokenStream $tokens, ParseState $state, string $description)

Read the name of a table or view, which belongs to the default schema when unqualified.

Parameters

TokenStream $tokens
ParseState $state
string $description

Return Value

TableReference

in Parser at line 152
protected array parseNameList(TokenStream $tokens, string $description)

Read a parenthesized list of identifiers.

Parameters

TokenStream $tokens
string $description

Return Value

array

in Parser at line 169
protected string parseCollation(TokenStream $tokens)

Read a collation name, keeping its qualification and quoting as written.

Parameters

TokenStream $tokens

Return Value

string

in Parser at line 180
protected string parseGroup(TokenStream $tokens)

Read a parenthesized group, returning its source text with the brackets.

Parameters

TokenStream $tokens

Return Value

string

in Parser at line 198
protected string parseExpression(TokenStream $tokens, array $clauses, string $description)

Read an expression that ends before a clause keyword or the end of its list entry.

Parameters

TokenStream $tokens
array $clauses
string $description

Return Value

string

in Parser at line 214
protected bool atClause(TokenStream $tokens, array $clauses)

Determine whether the current word begins one of the given clauses rather than naming a schema.

Parameters

TokenStream $tokens
array $clauses

Return Value

bool

in Parser at line 222
protected string|null parseLiteral(TokenStream $tokens)

Read a string literal that forms a complete value, or return null without consuming anything.

Parameters

TokenStream $tokens

Return Value

string|null

in Parser at line 245
protected bool atEntryEnd(TokenStream $tokens)

Determine whether the current list entry, such as a column definition, has ended.

Parameters

TokenStream $tokens

Return Value

bool

in Parser at line 253
protected void skipEntry(TokenStream $tokens)

Skip the rest of the current list entry.

Parameters

TokenStream $tokens

Return Value

void

in Parser at line 267
protected void parseTableBody(TokenStream $tokens, ParseState $state, TableDefinition $table)

Read the parenthesized columns and constraints of a table.

Parameters

TokenStream $tokens
ParseState $state
TableDefinition $table

Return Value

void

at line 46
protected bool isTableConstraint(TokenStream $tokens)

Determine whether a table body entry is a constraint, index or period rather than a column.

Parameters

TokenStream $tokens

Return Value

bool

in MySqlParser at line 391
protected string|null parseConstraintName(TokenStream $tokens)

Read the name given by a CONSTRAINT keyword, which MySQL lets a constraint omit.

Parameters

TokenStream $tokens

Return Value

string|null

in Parser at line 309
protected void parseTableConstraint(TokenStream $tokens, ParseState $state, TableDefinition $table)

Read a table constraint, keeping an unsupported one as a table issue.

Parameters

TokenStream $tokens
ParseState $state
TableDefinition $table

Return Value

void

at line 92
protected bool parseConstraint(TokenStream $tokens, ParseState $state, TableDefinition $table, string|null $column, string|null $name)

Read a table constraint, index or period, or a column constraint on the given column, returning false when it is not supported.

Parameters

TokenStream $tokens
ParseState $state
TableDefinition $table
string|null $column
string|null $name

Return Value

bool

in MySqlParser at line 401
protected ColumnDefinition parseColumn(TokenStream $tokens, ParseState $state, TableDefinition $table)

Read a column definition into the table, expanding SERIAL into the facts it stands for.

Parameters

TokenStream $tokens
ParseState $state
TableDefinition $table

Return Value

ColumnDefinition

at line 58
protected bool parseColumnConstraint(TokenStream $tokens, ParseState $state, TableDefinition $table, ColumnDefinition $column, string|null $name)

Read one column clause, returning false when it is not supported.

Parameters

TokenStream $tokens
ParseState $state
TableDefinition $table
ColumnDefinition $column
string|null $name

Return Value

bool

at line 80
protected Generation parseGeneration(TokenStream $tokens)

Read a generated column's expression and kind, which PERSISTENT also declares stored.

Parameters

TokenStream $tokens

Return Value

Generation

in Parser at line 410
protected void markPrimaryKeyColumnsNotNull(Index $index, TableDefinition $table)

Make the columns of a primary key non-null on a table.

Parameters

Index $index
TableDefinition $table

Return Value

void

in MySqlParser at line 418
protected ColumnDefinition|null findColumn(TableDefinition $table, string $name)

Find a table's column by name, which MySQL compares case-insensitively.

Parameters

TableDefinition $table
string $name

Return Value

ColumnDefinition|null

in Parser at line 434
protected array parseIndexColumns(TokenStream $tokens, ParseState $state, TableDefinition $table)

Read a parenthesized list of index keys.

Parameters

TokenStream $tokens
ParseState $state
TableDefinition $table

Return Value

array

at line 125
protected IndexColumn parseIndexColumn(TokenStream $tokens, ParseState $state, TableDefinition $table)

Read an index key, keeping an application-time period key part as its source text.

Parameters

TokenStream $tokens
ParseState $state
TableDefinition $table

Return Value

IndexColumn

in Parser at line 458
protected array parseForeignKeyRules(TokenStream $tokens, ParseState $state, TableDefinition $table)

Read a foreign key's match mode and referential actions, which can come in any order.

Parameters

TokenStream $tokens
ParseState $state
TableDefinition $table

Return Value

array

the match mode, then the update and delete actions

in Parser at line 491
protected ReferentialAction parseReferentialAction(TokenStream $tokens)

Read a referential action.

Parameters

TokenStream $tokens

Return Value

ReferentialAction

in Parser at line 506
protected TableReference parseCreateView(TokenStream $tokens, ParseState $state, bool $materialized = false)

Read a view from its name, without inferring the types its query produces, and return its name.

Parameters

TokenStream $tokens
ParseState $state
bool $materialized

Return Value

TableReference

in Parser at line 536
protected bool isTemporary(TableReference $reference)

Determine whether a name belongs to the session's temporary schema.

Parameters

TableReference $reference

Return Value

bool

in Parser at line 544
protected bool relationExists(ParseState $state, string|null $schema, string $name)

Determine whether a known relation already has the given name.

Parameters

ParseState $state
string|null $schema
string $name

Return Value

bool

in Parser at line 554
protected string parseViewQuery(TokenStream $tokens)

Read a view query, excluding a trailing view option.

Parameters

TokenStream $tokens

Return Value

string

in Parser at line 576
protected bool isViewOption(TokenStream $tokens)

Determine whether a WITH clause is the view's trailing check option.

Parameters

TokenStream $tokens

Return Value

bool

in Parser at line 588
protected Schema freeze(ParseState $state)

Freeze the parsed definitions into a schema.

Parameters

ParseState $state

Return Value

Schema

in Parser at line 609
protected Table freezeTable(TableDefinition $table, ParseState $state)

Freeze a table after resolving foreign keys that omit their referenced columns.

Parameters

TableDefinition $table
ParseState $state

Return Value

Table

in Parser at line 667
protected array|null referencedColumns(ForeignKey $foreignKey, ParseState $state)

Get the columns a foreign key references, which default to the referenced table's primary key, or null when they cannot be resolved.

Parameters

ForeignKey $foreignKey
ParseState $state

Return Value

array|null

in Parser at line 687
protected Column freezeColumn(ColumnDefinition $column, TableDefinition $table, ParseState $state)

Freeze a column.

Parameters

ColumnDefinition $column
TableDefinition $table
ParseState $state

Return Value

Column

at line 34
protected void parseTableTail(TokenStream $tokens, ParseState $state, TableDefinition $table, bool $columns)

Report system versioning, which adds implicit columns and temporal rules, before the rest of a table's tail.

Parameters

TokenStream $tokens
ParseState $state
TableDefinition $table
bool $columns

Return Value

void

in MySqlParser at line 689
protected void parseTableIndex(TokenStream $tokens, ParseState $state, TableDefinition $table, string|null $name, string|null $type = null, bool $unique = false)

Read a table index after its kind keywords, starting from its optional name.

Parameters

TokenStream $tokens
ParseState $state
TableDefinition $table
string|null $name
string|null $type
bool $unique

Return Value

void

in MySqlParser at line 789
protected void parseReferences(TokenStream $tokens, ParseState $state, TableDefinition $table, string|null $name, array $columns)

Read a foreign key's referenced table, columns and rules after its REFERENCES keyword.

Parameters

TokenStream $tokens
ParseState $state
TableDefinition $table
string|null $name
array $columns

Return Value

void

at line 138
protected string|null foreignKeyName(string|null $constraintName, string|null $indexName)

Name a foreign key by its constraint name, or else by its index name as MariaDB does.

Parameters

string|null $constraintName
string|null $indexName

Return Value

string|null