classDefineChecks
final class DefineChecks
Reports the attributes a definition lacks or combines in a way its command rejects.
Rule: PG-DEFINE-CHECK-001. Attribute names are compared respecting case (an unquoted name is folded to lower case). An operator needs a function (function or procedure) and, as postfix operators no longer exist, a right argument type. An aggregate needs a state type and a state transition function; the moving-aggregate attributes come with mstype, and mstype with msfunc and minvfunc; serialization needs both functions; only an ordered-set aggregate is hypothetical; an old-style aggregate names its input type with basetype, which is redundant in the new style. A base type needs input and output functions and a modifier input function for a modifier output function. A range type needs a subtype. A collation copied from another takes no other attribute and locale excludes lc_collate and lc_ctype; otherwise its provider (libc when not given) needs lc_collate and lc_ctype or locale, or for ICU and builtin locale, and only ICU takes rules or is nondeterministic. A text search parser needs its start, gettoken, end and lextypes methods, a template its lexize method, a dictionary its template, and a configuration a parser or a configuration to copy, but not both. Attribute values and unrecognized names are PG-DEFINE-ATTRIBUTE-001. Terminates: one pass over the attributes. Source: https://www.postgresql.org/docs/17/sql-createaggregate.html, https://www.postgresql.org/docs/17/sql-createoperator.html, https://www.postgresql.org/docs/17/sql-createtype.html, https://www.postgresql.org/docs/17/sql-createcollation.html, DefineOperator, DefineAggregate, DefineType, DefineRange, DefineCollation, DefineTSParser, DefineTSTemplate, DefineTSDictionary and DefineTSConfiguration in src/backend/commands of PostgreSQL 17. Status: Implemented.
Methods§
public function derive(Define $define, Derivation $derivation): voidReports the problems of the attributes and of their combination.
Parameters
$define | Define | |
$derivation | Derivation |
Called from 1
Calls 16
- method-call AttributeReader::command() line 64
- new AttributeReader line 64
- method-call AttributeChecks::derive() line 65
- new AttributeChecks line 65
- class-const ObjectKind::Type() line 65
- class-const ObjectKind::Collation() line 65
- method-call DefineChecks::present() line 66
- class-const ObjectKind::Operator() line 68
- method-call DefineChecks::operator() line 68
- class-const ObjectKind::Aggregate() line 69
- method-call DefineChecks::aggregate() line 69
- method-call DefineChecks::baseType() line 70
- method-call DefineChecks::collation() line 71
- function-call
countline 71 - method-call DefineChecks::search() line 72
- method-call Derivation::report() line 75
public function range(list<Attribute> $attributes, Derivation $derivation): voidReports the problems of the attributes of a range type.
Parameters
$attributes | list<Attribute> | |
$derivation | Derivation |
Called from 1
Calls 7
- method-call AttributeChecks::derive() line 86
- new AttributeChecks line 86
- class-const RangeAttribute::class() line 86
- method-call DefineChecks::present() line 87
- method-call Derivation::report() line 88
- new AttributeProblem line 88
- class-const AttributeProblemKind::MissingSubtype() line 88
Answers the recognized attributes by name; a later attribute replaces an earlier one, as the commands read them.
Parameters
$attributes | list<Attribute> |
Returns
array<string, Attribute>Test cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\DefineChecks::derive() packages/sql-semantics-postgres/src/Rules/Routine/DefineChecks.php:66
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\DefineChecks::range() packages/sql-semantics-postgres/src/Rules/Routine/DefineChecks.php:87
public function operator(array<string, Attribute> $present): list<AttributeProblem>Answers the missing function and argument types of an operator.
Parameters
$present | array<string, Attribute> |
Returns
list<AttributeProblem>Called from 1
Calls 4
public function aggregate(
array<string, Attribute> $present,
?AggregateArguments $arguments,
): list<AttributeProblem>Answers the missing and contradictory attributes of an aggregate.
Parameters
$present | array<string, Attribute> | |
$arguments | ?AggregateArguments |
Returns
list<AttributeProblem>Called from 1
Calls 9
- new AttributeProblem line 143
- class-const AttributeProblemKind::MissingAggregateAttribute() line 143
- function-call
in_arrayline 150 - class-const AttributeProblemKind::MissingMovingAttribute() line 151
- class-const AttributeProblemKind::MovingWithoutState() line 154
- class-const AttributeProblemKind::HypotheticalPlain() line 159
- class-const AttributeProblemKind::MissingInputType() line 162
- class-const AttributeProblemKind::RedundantBaseType() line 162
- class-const AttributeProblemKind::HalfSerialization() line 165
public function baseType(array<string, Attribute> $present): list<AttributeProblem>Answers the missing support functions of a base type.
Parameters
$present | array<string, Attribute> |
Returns
list<AttributeProblem>Test cases 1
Called from 1
Calls 4
public function collation(
array<string, Attribute> $present,
int $count,
GrammarRelease $release,
): list<AttributeProblem>Answers the contradictory and missing attributes of a collation; a provider the server does not know stops the checks, as it does.
Parameters
$present | array<string, Attribute> | |
$count | int | |
$release | GrammarRelease |
Returns
list<AttributeProblem>Test cases 1
Called from 1
Calls 6
- new AttributeProblem line 206
- class-const AttributeProblemKind::Conflicting() line 206
- class-const CollationProvider::Libc() line 210
- class-const CollationProvider::Builtin() line 211
- class-const GrammarRelease::PostgreSql166() line 211
- method-call DefineChecks::provided() line 215
public function provided(
CollationProvider $provider,
array<string, Attribute> $present,
): list<AttributeProblem>Answers the attributes a collation of a provider lacks or may not take.
Parameters
$provider | CollationProvider | |
$present | array<string, Attribute> |
Returns
list<AttributeProblem>Test cases 1
Called from 1
Calls 6
- class-const CollationProvider::Libc() line 228
- new AttributeProblem line 230
- class-const AttributeProblemKind::MissingCollationParameter() line 230
- class-const CollationProvider::Icu() line 234
- class-const AttributeProblemKind::Nondeterministic() line 235
- class-const AttributeProblemKind::RulesWithoutIcu() line 238
public function search(
ObjectKind $kind,
array<string, Attribute> $present,
): list<AttributeProblem>Answers the missing or contradictory attributes of a text search object.
Parameters
$kind | ObjectKind | |
$present | array<string, Attribute> |
Returns
list<AttributeProblem>Test cases 1
Called from 1
Calls 11
- class-const ObjectKind::TextSearchParser() line 254
- class-const DefineChecks::PARSER_METHODS() line 254
- new AttributeProblem line 256
- class-const AttributeProblemKind::MissingParserMethod() line 256
- class-const ObjectKind::TextSearchTemplate() line 260
- class-const AttributeProblemKind::MissingLexize() line 260
- class-const ObjectKind::TextSearchDictionary() line 261
- class-const AttributeProblemKind::MissingTemplate() line 261
- class-const ObjectKind::TextSearchConfiguration() line 262
- class-const AttributeProblemKind::ParserAndCopy() line 262
- class-const AttributeProblemKind::MissingParser() line 263
Private surface 1§
Implementation details, listed for orientation only.
private const PARSER_METHODS = ['start', 'gettoken', 'end', 'lextypes']Test cases 7§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 7
DefineChecksTest::testAggregateReportsMovingSerializationHypotheticalAndBaseTypecallsDefineChecksTest::testBaseTypeReportsTheMissingOutputFunctioncallsDefineChecksTest::testCollationFollowsTheProvidercallsDefineChecksTest::testOperatorTellsAMissingRightArgumentFromMissingArgumentscallsDefineChecksTest::testPresentKeepsTheLastRecognizedAttributeOfEachNamecallsDefineChecksTest::testProvidedReportsWhatOnlyIcuTakescallsDefineChecksTest::testSearchReportsAConfigurationWithParserAndCopycalls
Relations§
Instantiated in 2
- new SqlSemantics\Platform\PostgreSql\Statement\Catalog\Type\CreateRange::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Type/CreateRange.php:61
- new SqlSemantics\Platform\PostgreSql\Statement\Object\Define::deriveStatement() packages/sql-semantics-postgres/src/Statement/Object/Define.php:92
Method calls 2
- method-call SqlSemantics\Platform\PostgreSql\Statement\Catalog\Type\CreateRange::deriveStatement() packages/sql-semantics-postgres/src/Statement/Catalog/Type/CreateRange.php:61
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Define::deriveStatement() packages/sql-semantics-postgres/src/Statement/Object/Define.php:92