class ParseState

internal  
 

The definitions, identity lookups and issues of one parse.

Definitions are keyed by schema and name without joining them with a dot, which quoted names can contain.

Properties

TableDefinition> $tables
array<array-key, array<string, true>> $tableNames
View> $views
array<array-key, array<string, true>> $viewNames
EnumType> $enums
Domain> $domains
array<array-key, array<string, true>> $domainNames
array<string, array<string, true>> $children
ColumnType> $types
Issue> $issues
TableReference> $affectedRelations
TypeReference> $affectedTypes
bool $unknownImpact

Whether a statement may have changed relations or types without naming them, or changed how later statements resolve names.

string|null $defaultSchema

The schema of unqualified relation names: SQLite's main database, or the one a MySQL USE statement selects.

array<string, array{bool, bool}> $savedSqlModes
int $offset

The start of the statement being parsed.

Methods

__construct(string $sql, bool $caseInsensitive = false)

Create the state for parsing the given SQL.

issue(string $message)

Create an issue located at the current statement.

void
affect(TableReference $relation)

Record that the input alters, drops or renames a table or view, naming an unqualified one in the default schema.

void
affectType(TypeReference $type)

Record that the input alters or drops a user type or domain.

string
normalize(string $name)

Get the identity of a name, without its ASCII case where names compare case-insensitively.

string
key(string|null $schema, string $name)

Get the identity key of a schema-qualified name.

string
addTable(TableDefinition $table)

Add or replace a table definition and return its key.

void
removeTable(string $key)

Remove a table definition and its inheritance and partition links.

void
linkChild(string $parentKey, string $childKey)

Record that a stored table inherits from, or is a partition of, another stored table.

void
addIndex(string $key, Index $index)

Add an index to a stored table.

void
removeIndex(string $key, string $name)

Remove a stored table's index with the given name.

void
refreshIndexNames(string $key)

Record the index names of a stored table after its indexes change.

bool
hasIndex(string|null $schema, string $name)

Determine whether a stored table has an index with the given schema-qualified name.

string|null
indexTableKey(string|null $schema, string $name)

Find the stored table with the given schema-qualified index name, when only one has it.

array
indexTableKeys(string $name)

Get the keys of the stored tables with an index of the given name, in any schema.

string|null
tableKey(TableReference $table)

Find a table by exact identity or a unique unqualified name.

void
addView(View $view)

Add or replace a view.

void
removeView(string $key)

Remove a view.

string|null
viewKey(TableReference $view)

Find a view by exact identity or a unique unqualified name.

string|null
domainKey(string|null $schema, string $name)

Find a domain by exact identity or a unique unqualified name.

bool
hasDefinitions()

Determine whether any schema object has been read.

Details

at line 92
__construct(string $sql, bool $caseInsensitive = false)

Create the state for parsing the given SQL.

Parameters

string $sql
bool $caseInsensitive

whether schema, relation and index names compare without ASCII case, as SQLite's do

at line 101
Issue issue(string $message)

Create an issue located at the current statement.

Parameters

string $message

Return Value

Issue

at line 112
void affect(TableReference $relation)

Record that the input alters, drops or renames a table or view, naming an unqualified one in the default schema.

Parameters

TableReference $relation

Return Value

void

at line 124
void affectType(TypeReference $type)

Record that the input alters or drops a user type or domain.

Parameters

TypeReference $type

Return Value

void

at line 132
string normalize(string $name)

Get the identity of a name, without its ASCII case where names compare case-insensitively.

Parameters

string $name

Return Value

string

at line 140
string key(string|null $schema, string $name)

Get the identity key of a schema-qualified name.

Parameters

string|null $schema
string $name

Return Value

string

at line 153
string addTable(TableDefinition $table)

Add or replace a table definition and return its key.

Parameters

TableDefinition $table

Return Value

string

at line 166
void removeTable(string $key)

Remove a table definition and its inheritance and partition links.

Parameters

string $key

Return Value

void

at line 188
void linkChild(string $parentKey, string $childKey)

Record that a stored table inherits from, or is a partition of, another stored table.

Parameters

string $parentKey
string $childKey

Return Value

void

at line 197
void addIndex(string $key, Index $index)

Add an index to a stored table.

Parameters

string $key
Index $index

Return Value

void

at line 213
void removeIndex(string $key, string $name)

Remove a stored table's index with the given name.

Parameters

string $key
string $name

Return Value

void

at line 231
void refreshIndexNames(string $key)

Record the index names of a stored table after its indexes change.

Parameters

string $key

Return Value

void

at line 279
bool hasIndex(string|null $schema, string $name)

Determine whether a stored table has an index with the given schema-qualified name.

Parameters

string|null $schema
string $name

Return Value

bool

at line 287
string|null indexTableKey(string|null $schema, string $name)

Find the stored table with the given schema-qualified index name, when only one has it.

Parameters

string|null $schema
string $name

Return Value

string|null

at line 299
array indexTableKeys(string $name)

Get the keys of the stored tables with an index of the given name, in any schema.

Parameters

string $name

Return Value

array

at line 333
string|null tableKey(TableReference $table)

Find a table by exact identity or a unique unqualified name.

Parameters

TableReference $table

Return Value

string|null

at line 341
void addView(View $view)

Add or replace a view.

Parameters

View $view

Return Value

void

at line 351
void removeView(string $key)

Remove a view.

Parameters

string $key

Return Value

void

at line 359
string|null viewKey(TableReference $view)

Find a view by exact identity or a unique unqualified name.

Parameters

TableReference $view

Return Value

string|null

at line 367
string|null domainKey(string|null $schema, string $name)

Find a domain by exact identity or a unique unqualified name.

Parameters

string|null $schema
string $name

Return Value

string|null

at line 375
bool hasDefinitions()

Determine whether any schema object has been read.

Return Value

bool