final class SetTimeZone
    implements Statement
    uses Snapshot
Public API: explicitly declared with @visibility public.

SET [LOCAL] TIME ZONE value: a request to change the time zone of the session.

Rule: PG-SET-003. Mirrors PostgreSQL's VariableSetStmt on timezone written with the TIME ZONE keywords. The value is a zone name as a string or a plain identifier (a keyword must be quoted there), a number of hours east of UTC, an interval constant, or LOCAL or DEFAULT. Facts: the interval constant has the interval type. Diagnostic: an interval restricted to fields other than HOUR or HOUR TO MINUTE is rejected by the server while parsing. Source: https://www.postgresql.org/docs/17/sql-set.html. Status: Implemented.

Reading a time zone set by an intervaldoctest
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze("SET TIME ZONE INTERVAL '-08:00' HOUR TO MINUTE");
    [$operation->statement->zone->value->value, $operation->toString()] // => ['-08:00', "SET TIME ZONE INTERVAL '-08:00' HOUR TO MINUTE"]
Refusing a constant of another typedoctest
new \SqlSemantics\Platform\PostgreSql\Statement\Utility\Session\SetTimeZone(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\TypedLiteral(
        new \SqlSemantics\Platform\PostgreSql\Statement\Type\TypeName(new \SqlSemantics\Platform\PostgreSql\Statement\Type\Designation\NamedDesignation(new \SqlSemantics\Platform\PostgreSql\Statement\Name\DottedName([new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('date')]))),
        new \SqlSemantics\Platform\PostgreSql\Statement\Literal\StringConstant('1'),
    )) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstruction

Properties§

public bool $local = false

Methods§

public function __construct(
    public StringConstant|Name|SignedNumber|TypedLiteral|ZoneKeyword $zone,
    public bool $local = false,
)

Parameters

$zoneStringConstant|Name|SignedNumber|TypedLiteral|ZoneKeywordThe zone: a name, an offset in hours, an interval constant, or a keyword
$localboolWhether the change lasts for the current transaction only
Calls 1
public function deriveStatement(Derivation $derivation): void

Derives the interval constant and reports an interval of other fields than hours and minutes.

Parameters

$derivationDerivation
Calls 8
public function render(Output $out): void

Writes the request.

Parameters

$outOutput
Calls 4

Test cases 3§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1
Other tests reaching this symbol 2

Relations§

Instantiated in 1