constellation_full_name(text) returns full IAU name from 3-letter abbreviation (88-entry static table, IMMUTABLE). Returns NULL for invalid input — composable with constellation() in queries. Three rise_set_status functions classify body visibility as 'rises_and_sets', 'circumpolar', or 'never_rises' by sampling elevation at 48 points across 24h. Separate diagnostic path — called only when rise/set returns NULL, zero cost in normal case. 147 → 151 SQL objects. 25 → 26 regression suites. All pass.
34 lines
1.7 KiB
SQL
34 lines
1.7 KiB
SQL
-- pg_orrery 0.14.0 -> 0.15.0 migration
|
|
--
|
|
-- Adds: constellation_full_name (1 function),
|
|
-- rise/set status diagnostics (3 functions).
|
|
|
|
-- ============================================================
|
|
-- Constellation full name lookup
|
|
-- ============================================================
|
|
|
|
CREATE FUNCTION constellation_full_name(abbr text) RETURNS text
|
|
AS 'MODULE_PATHNAME', 'constellation_full_name_from_abbr'
|
|
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
|
|
COMMENT ON FUNCTION constellation_full_name(text) IS
|
|
'Full IAU constellation name from 3-letter abbreviation. Returns NULL for invalid abbreviation.';
|
|
|
|
-- ============================================================
|
|
-- Rise/set status diagnostics
|
|
-- ============================================================
|
|
|
|
CREATE FUNCTION sun_rise_set_status(obs observer, t timestamptz) RETURNS text
|
|
AS 'MODULE_PATHNAME' LANGUAGE C STABLE STRICT PARALLEL SAFE;
|
|
COMMENT ON FUNCTION sun_rise_set_status(observer, timestamptz) IS
|
|
'Classify Sun visibility: rises_and_sets, circumpolar, or never_rises.';
|
|
|
|
CREATE FUNCTION moon_rise_set_status(obs observer, t timestamptz) RETURNS text
|
|
AS 'MODULE_PATHNAME' LANGUAGE C STABLE STRICT PARALLEL SAFE;
|
|
COMMENT ON FUNCTION moon_rise_set_status(observer, timestamptz) IS
|
|
'Classify Moon visibility: rises_and_sets, circumpolar, or never_rises.';
|
|
|
|
CREATE FUNCTION planet_rise_set_status(body_id int4, obs observer, t timestamptz) RETURNS text
|
|
AS 'MODULE_PATHNAME' LANGUAGE C STABLE STRICT PARALLEL SAFE;
|
|
COMMENT ON FUNCTION planet_rise_set_status(int4, observer, timestamptz) IS
|
|
'Classify planet visibility: rises_and_sets, circumpolar, or never_rises. Body IDs 1-8 (Mercury-Neptune).';
|