classIdentifiers
final class Identifiers
Decodes the spelling of a PostgreSQL identifier token into the name the server uses.
Rule: PG-IDENT-001. Scope: the IDENT terminal (plain, "quoted" and U&"..." with an optional UESCAPE clause, which the lexer delivers as one token) and every keyword terminal used as a name. An unquoted identifier and a keyword are folded to lower case, ASCII letters only, as the server does for a multibyte server encoding. A quoted identifier is taken literally with each doubled quote read as one quote. A Unicode identifier has its escapes replaced after the quotes are undoubled. Every name is then cut to 63 bytes on a character boundary (NAMEDATALEN - 1), because the server stores no longer identifier. Invalid Unicode escapes are lexical errors of the server and are reported as SQL outside the grammar. Source: https://www.postgresql.org/docs/17/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS. Status: Implemented.
Constants§
public const LIMIT = 63The longest name the server keeps, in bytes.
Methods§
public function decode(string $text): stringDecodes the text of an identifier token.
Parameters
$text | string |
Returns
stringTest cases 6
IdentifiersTest::testDecodeCutsANameToSixtyThreeBytescallsIdentifiersTest::testDecodeFoldsAnUnquotedIdentifierToLowerCasecallsIdentifiersTest::testDecodeHonoursTheEscapeCharacterOfAUescapeClausecallsIdentifiersTest::testDecodeKeepsNonAsciiLettersOfAnUnquotedIdentifiercallsIdentifiersTest::testDecodeReadsAQuotedIdentifierLiterallycallsIdentifiersTest::testDecodeReplacesTheEscapesOfAUnicodeIdentifiercalls
Called from 5
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Names::token() packages/sql-semantics-postgres/src/Lowering/Leaf/Names.php:70
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Names::text() packages/sql-semantics-postgres/src/Lowering/Leaf/Names.php:85
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Table\PolicyRule::create() packages/sql-semantics-postgres/src/Lowering/Table/PolicyRule.php:65
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Table\PolicyRule::create() packages/sql-semantics-postgres/src/Lowering/Table/PolicyRule.php:66
- method-call SqlSemantics\Platform\PostgreSql\Rules\LeafKeys::key() packages/sql-semantics-postgres/src/Rules/LeafKeys.php:65
Calls 8
- function-call
str_starts_withline 39 - method-call Identifiers::clip() line 40
- function-call
str_replaceline 40 - function-call
substrline 40 - function-call
preg_matchline 42 - method-call UnicodeEscapes::decode() line 45
- new UnicodeEscapes line 45
- method-call Identifiers::fold() line 48
public function fold(string $word): stringFolds the ASCII letters of an unquoted word to lower case.
Parameters
$word | string |
Returns
stringTest cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Keywords::word() packages/sql-semantics-postgres/src/Lowering/Leaf/Keywords.php:62
- method-call SqlSemantics\Platform\PostgreSql\Rules\Identifiers::decode() packages/sql-semantics-postgres/src/Rules/Identifiers.php:48
- method-call SqlSemantics\Platform\PostgreSql\Rules\LeafKeys::key() packages/sql-semantics-postgres/src/Rules/LeafKeys.php:61
Calls 1
- function-call
strtrline 56
public function clip(string $name): stringCuts a name to the stored length without splitting a UTF-8 character.
Parameters
$name | string |
Returns
stringTest cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Identifiers::decode() packages/sql-semantics-postgres/src/Rules/Identifiers.php:40
- method-call SqlSemantics\Platform\PostgreSql\Rules\Identifiers::decode() packages/sql-semantics-postgres/src/Rules/Identifiers.php:45
- method-call SqlSemantics\Platform\PostgreSql\Rules\Identifiers::decode() packages/sql-semantics-postgres/src/Rules/Identifiers.php:48
Calls 4
- function-call
strlenline 64 - class-const Identifiers::LIMIT() line 64
- function-call
ordline 68 - function-call
substrline 72
Test cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
IdentifiersTest::testClipDoesNotSplitACharactercallsIdentifiersTest::testDecodeCutsANameToSixtyThreeBytescallsIdentifiersTest::testDecodeFoldsAnUnquotedIdentifierToLowerCasecallsIdentifiersTest::testDecodeHonoursTheEscapeCharacterOfAUescapeClausecallsIdentifiersTest::testDecodeKeepsNonAsciiLettersOfAnUnquotedIdentifiercallsIdentifiersTest::testDecodeReadsAQuotedIdentifierLiterallycallsIdentifiersTest::testDecodeReplacesTheEscapesOfAUnicodeIdentifiercallsIdentifiersTest::testFoldLowersAsciiLettersOnlycalls
Relations§
Instantiated in 7
- new SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Keywords::word() packages/sql-semantics-postgres/src/Lowering/Leaf/Keywords.php:62
- new SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Names::token() packages/sql-semantics-postgres/src/Lowering/Leaf/Names.php:70
- new SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Names::text() packages/sql-semantics-postgres/src/Lowering/Leaf/Names.php:85
- new SqlSemantics\Platform\PostgreSql\Lowering\Table\PolicyRule::create() packages/sql-semantics-postgres/src/Lowering/Table/PolicyRule.php:65
- new SqlSemantics\Platform\PostgreSql\Lowering\Table\PolicyRule::create() packages/sql-semantics-postgres/src/Lowering/Table/PolicyRule.php:66
- new SqlSemantics\Platform\PostgreSql\Rules\LeafKeys::key() packages/sql-semantics-postgres/src/Rules/LeafKeys.php:61
- new SqlSemantics\Platform\PostgreSql\Rules\LeafKeys::key() packages/sql-semantics-postgres/src/Rules/LeafKeys.php:65
Method calls 7
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Keywords::word() packages/sql-semantics-postgres/src/Lowering/Leaf/Keywords.php:62
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Names::token() packages/sql-semantics-postgres/src/Lowering/Leaf/Names.php:70
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Names::text() packages/sql-semantics-postgres/src/Lowering/Leaf/Names.php:85
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Table\PolicyRule::create() packages/sql-semantics-postgres/src/Lowering/Table/PolicyRule.php:65
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Table\PolicyRule::create() packages/sql-semantics-postgres/src/Lowering/Table/PolicyRule.php:66
- method-call SqlSemantics\Platform\PostgreSql\Rules\LeafKeys::key() packages/sql-semantics-postgres/src/Rules/LeafKeys.php:61
- method-call SqlSemantics\Platform\PostgreSql\Rules\LeafKeys::key() packages/sql-semantics-postgres/src/Rules/LeafKeys.php:65