classXmlTable
final class XmlTable
implements Relation
uses Snapshot
Public API: explicitly declared with
@visibility public.XMLTABLE as a FROM item: rows and columns read from an XML value.
Mirrors PostgreSQL's RangeTableFunc. The facts follow PG-XMLTABLE-001. Like a function call, it may refer to the FROM items before it whether or not LATERAL is written; the word is kept as written. Source: https://www.postgresql.org/docs/17/functions-xml.html#FUNCTIONS-XML-PROCESSING-XMLTABLE. Status: Implemented.
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze("SELECT * FROM XMLTABLE ('/r' PASSING '<r/>' COLUMNS n FOR ORDINALITY, a text PATH 'a' NOT NULL) AS x");
[$query->field(0)->type->descriptor->name(), $query->field(1)->nullability->name] // => ['integer', 'NotNull']Properties§
public list<XmlNamespace> $namespacespublic non-empty-list<XmlTableColumn> $columnspublic list<Name> $aliasespublic Scalar $rowpublic Clause $passingpublic Name|null $alias = nullpublic bool $lateral = falseMethods§
public function __construct(
public Scalar $row,
public Clause $passing,
list<XmlTableColumn> $columns,
list<XmlNamespace> $namespaces = [],
public Name|null $alias = null,
list<Name> $aliases = [],
public bool $lateral = false,
)Parameters
$row | Scalar | The XPath expression that yields the rows, a primary expression |
$passing | Clause | The PASSING clause with the document |
$columns | list<XmlTableColumn> | The columns in written order; at least one |
$namespaces | list<XmlNamespace> | The namespaces of XMLNAMESPACES |
$alias | Name|null | The correlation name |
$aliases | list<Name> | The column names written after the correlation name |
$lateral | bool | Whether LATERAL is written |
Calls 7
- static-call Check::listOf() line 71
- class-const XmlTableColumn::class() line 71
- class-const XmlNamespace::class() line 72
- class-const Name::class() line 73
- static-call Check::input() line 74
- method-call Precedence::primary() line 75
- new Precedence line 75
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFactDerives the expressions and the columns of the occurrence.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 2
- method-call TableFunctionShapes::xml() line 83
- new TableFunctionShapes line 83
public function render(Output $out): voidWrites LATERAL, XMLTABLE with its namespaces, row expression, PASSING clause and columns, and the alias.
Parameters
$out | Output |
Calls 4
- method-call Output::keyword() line 92
- method-call Output::node() line 98
- method-call AliasSpelling::write() line 99
- new AliasSpelling line 99
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
XmlTableTestcalls
Relations§
Instantiated in 1
Type checks 4
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Locking::refused() packages/sql-semantics-postgres/src/Rules/Query/Locking.php:141
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::open() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:61
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::visible() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:75
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::visible() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:79
Type declarations 2
- type SqlSemantics\Platform\PostgreSql\Lowering\Query\TableFunctionRule packages/sql-semantics-postgres/src/Lowering/Query/TableFunctionRule.php:64
- type SqlSemantics\Platform\PostgreSql\Rules\Resolution\TableFunctionShapes packages/sql-semantics-postgres/src/Rules/Resolution/TableFunctionShapes.php:57