classSetTimeZone
final class SetTimeZone
implements Statement
uses Snapshot
@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.
$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"]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\InvalidConstructionProperties§
public StringConstant|Name|SignedNumber|TypedLiteral|ZoneKeyword $zonepublic bool $local = falseMethods§
public function __construct(
public StringConstant|Name|SignedNumber|TypedLiteral|ZoneKeyword $zone,
public bool $local = false,
)Parameters
$zone | StringConstant|Name|SignedNumber|TypedLiteral|ZoneKeyword | The zone: a name, an offset in hours, an interval constant, or a keyword |
$local | bool | Whether the change lasts for the current transaction only |
Calls 1
- static-call Check::input() line 53
public function deriveStatement(Derivation $derivation): voidDerives the interval constant and reports an interval of other fields than hours and minutes.
Parameters
$derivation | Derivation |
Calls 8
- method-call Derivation::scalar() line 64
- method-call Derivation::environment() line 64
- function-call
in_arrayline 66 - class-const IntervalFields::Hour() line 66
- class-const IntervalFields::HourToMinute() line 66
- method-call Derivation::report() line 67
- new UtilityProblem line 67
- class-const UtilityProblemKind::ZoneIntervalFields() line 67
public function render(Output $out): voidWrites the request.
Parameters
$out | Output |
Calls 4
- method-call Output::keyword() line 76
- method-call Output::name() line 87
- class-const NameUse::Identifier() line 87
- method-call Output::node() line 91
Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.