Rule 3
This page documents the preview version (v2.21). Preview includes features under active development and is for development and testing only. For production, use the stable version (v2024.1). To learn more, see Versioning.
A string that's intended to identify a UTC offset is never resolved in pg_timezone_abbrevs.abbrev as the argument of set timezone but is resolved there as the argument of at time zone (and, equivalently, in timezone()) and as the argument of make_timestamptz() (and equivalently within a text literal for a timestamptz value).
You can discover, with ad hoc queries. that the string AZOT occurs uniquely in pg_timezone_names.abbrev. Use the function occurrences() to confirm it thus:
with c as (select occurrences('AZOT') as r)
select
(c.r).names_name ::text as "~names.name",
(c.r).names_abbrev ::text as "~names.abbrev",
(c.r).abbrevs_abbrev ::text as "~abbrevs.abbrev"
from c;
This is the result:
~names.name | ~names.abbrev | ~abbrevs.abbrev
-------------+---------------+-----------------
false | false | true
This means that the string AZOT can be used as a probe, using the function legal_scopes_for_syntax_context()_:
select x from legal_scopes_for_syntax_context('AZOT');
This is the result:
AZOT: names_name: false / names_abbrev: false / abbrevs_abbrev: true
------------------------------------------------------------------------------------------
set timezone = 'AZOT'; > invalid_parameter_value
select timezone('AZOT', '2021-06-07 12:00:00'); > OK
select '2021-06-07 12:00:00 AZOT'::timestamptz; > OK
You can copy-and-paste the offending expression and use it as the argument of a select to see the error occurring "live".
This outcome supports the formulation of the rule that this page addresses.