pg_orrery/sql/pg_orrery--0.10.0--0.11.0.sql
Ryan Malloy 3906023ade Harden v0.11.0 constructors: NaN/Inf guards, expanded error path tests
- Add validate_orbital_elements_args() with isnan/isinf checks for all
  7 propagation parameters (epoch, q, e, inc, omega, node, tp); h_mag
  and g_slope exempt (NaN is valid sentinel for "unknown magnitude")
- Deduplicate validation between make_orbital_elements() and _deg()
- Update SQL COMMENTs to clarify geometric vs apparent coordinates
- Add NaN/Inf rejection tests (q, e, epoch, Inf inclination)
- Add NaN H/G acceptance test (sentinel value)
- Expand error path coverage to all 4 moon families + negative body_id
- All 20 regression suites pass
2026-02-23 14:25:43 -07:00

52 lines
2.8 KiB
SQL

-- pg_orrery 0.10.0 -> 0.11.0 migration
--
-- Adds make_orbital_elements() constructors and
-- geocentric equatorial functions for planetary moons.
-- ============================================================
-- orbital_elements constructors
-- ============================================================
CREATE FUNCTION make_orbital_elements(
epoch_jd float8, q_au float8, e float8,
inc_rad float8, omega_rad float8, node_rad float8,
tp_jd float8, h_mag float8, g_slope float8
) RETURNS orbital_elements
AS 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
COMMENT ON FUNCTION make_orbital_elements(float8,float8,float8,float8,float8,float8,float8,float8,float8) IS
'Construct orbital_elements from 9 floats (angular elements in radians).';
CREATE FUNCTION make_orbital_elements_deg(
epoch_jd float8, q_au float8, e float8,
inc_deg float8, omega_deg float8, node_deg float8,
tp_jd float8, h_mag float8, g_slope float8
) RETURNS orbital_elements
AS 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
COMMENT ON FUNCTION make_orbital_elements_deg(float8,float8,float8,float8,float8,float8,float8,float8,float8) IS
'Construct orbital_elements from 9 floats (angular elements in degrees). Matches text I/O and most catalog column layouts.';
-- ============================================================
-- Planetary moon equatorial functions
-- ============================================================
CREATE FUNCTION galilean_equatorial(int4, timestamptz) RETURNS equatorial
AS 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
COMMENT ON FUNCTION galilean_equatorial(int4, timestamptz) IS
'Geometric geocentric RA/Dec of a Galilean moon (0=Io, 1=Europa, 2=Ganymede, 3=Callisto). L1.2 theory + VSOP87. No light-time or aberration correction.';
CREATE FUNCTION saturn_moon_equatorial(int4, timestamptz) RETURNS equatorial
AS 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
COMMENT ON FUNCTION saturn_moon_equatorial(int4, timestamptz) IS
'Geometric geocentric RA/Dec of a Saturn moon (0=Mimas..7=Hyperion). TASS17 theory + VSOP87. No light-time or aberration correction.';
CREATE FUNCTION uranus_moon_equatorial(int4, timestamptz) RETURNS equatorial
AS 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
COMMENT ON FUNCTION uranus_moon_equatorial(int4, timestamptz) IS
'Geometric geocentric RA/Dec of a Uranus moon (0=Miranda..4=Oberon). GUST86 theory + VSOP87. No light-time or aberration correction.';
CREATE FUNCTION mars_moon_equatorial(int4, timestamptz) RETURNS equatorial
AS 'MODULE_PATHNAME' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
COMMENT ON FUNCTION mars_moon_equatorial(int4, timestamptz) IS
'Geometric geocentric RA/Dec of a Mars moon (0=Phobos, 1=Deimos). MarsSat theory + VSOP87. No light-time or aberration correction.';