From 189699dd3680d85c74c3886b33d9a9f83301defd Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 13 Dec 2021 18:08:28 -0500 Subject: [PATCH] Remove unimplemented/undocumented geometric functions & operators. Nobody has filled in these stubs for upwards of twenty years, so it's time to drop the idea that they might get implemented any day now. The associated pg_operator and pg_proc entries are just confusing wastes of space. Per complaint from Anton Voloshin. Discussion: https://postgr.es/m/3426566.1638832718@sss.pgh.pa.us --- src/backend/utils/adt/geo_ops.c | 110 ------------------------- src/include/catalog/catversion.h | 2 +- src/include/catalog/pg_cast.dat | 2 - src/include/catalog/pg_operator.dat | 17 ---- src/include/catalog/pg_proc.dat | 18 ---- src/test/regress/expected/geometry.out | 14 ---- src/test/regress/sql/geometry.sql | 13 --- 7 files changed, 1 insertion(+), 175 deletions(-) diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index e9c347cb8c..92dc9483b9 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -2532,44 +2532,6 @@ dist_bs(PG_FUNCTION_ARGS) PG_RETURN_FLOAT8(box_closept_lseg(NULL, box, lseg)); } -/* - * Distance from a line to a box - */ -Datum -dist_lb(PG_FUNCTION_ARGS) -{ -#ifdef NOT_USED - LINE *line = PG_GETARG_LINE_P(0); - BOX *box = PG_GETARG_BOX_P(1); -#endif - - /* need to think about this one for a while */ - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("function \"dist_lb\" not implemented"))); - - PG_RETURN_NULL(); -} - -/* - * Distance from a box to a line - */ -Datum -dist_bl(PG_FUNCTION_ARGS) -{ -#ifdef NOT_USED - BOX *box = PG_GETARG_BOX_P(0); - LINE *line = PG_GETARG_LINE_P(1); -#endif - - /* need to think about this one for a while */ - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("function \"dist_bl\" not implemented"))); - - PG_RETURN_NULL(); -} - static float8 dist_cpoly_internal(CIRCLE *circle, POLYGON *poly) { @@ -2947,48 +2909,6 @@ close_pb(PG_FUNCTION_ARGS) PG_RETURN_POINT_P(result); } - -/* close_sl() - * Closest point on line to line segment. - * - * XXX THIS CODE IS WRONG - * The code is actually calculating the point on the line segment - * which is backwards from the routine naming convention. - * Copied code to new routine close_ls() but haven't fixed this one yet. - * - thomas 1998-01-31 - */ -Datum -close_sl(PG_FUNCTION_ARGS) -{ -#ifdef NOT_USED - LSEG *lseg = PG_GETARG_LSEG_P(0); - LINE *line = PG_GETARG_LINE_P(1); - Point *result; - float8 d1, - d2; - - result = (Point *) palloc(sizeof(Point)); - - if (lseg_interpt_line(result, lseg, line)) - PG_RETURN_POINT_P(result); - - d1 = line_closept_point(NULL, line, &lseg->p[0]); - d2 = line_closept_point(NULL, line, &lseg->p[1]); - if (float8_lt(d1, d2)) - *result = lseg->p[0]; - else - *result = lseg->p[1]; - - PG_RETURN_POINT_P(result); -#endif - - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("function \"close_sl\" not implemented"))); - - PG_RETURN_NULL(); -} - /* * Closest point on line segment to line. * @@ -3120,22 +3040,6 @@ close_sb(PG_FUNCTION_ARGS) } -Datum -close_lb(PG_FUNCTION_ARGS) -{ -#ifdef NOT_USED - LINE *line = PG_GETARG_LINE_P(0); - BOX *box = PG_GETARG_BOX_P(1); -#endif - - /* think about this one for a while */ - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("function \"close_lb\" not implemented"))); - - PG_RETURN_NULL(); -} - /*--------------------------------------------------------------------- * on_ * Whether one object lies completely within another. @@ -4503,20 +4407,6 @@ path_div_pt(PG_FUNCTION_ARGS) } -Datum -path_center(PG_FUNCTION_ARGS) -{ -#ifdef NOT_USED - PATH *path = PG_GETARG_PATH_P(0); -#endif - - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("function \"path_center\" not implemented"))); - - PG_RETURN_NULL(); -} - Datum path_poly(PG_FUNCTION_ARGS) { diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 6b19ffddde..6b24d90c76 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 202112111 +#define CATALOG_VERSION_NO 202112131 #endif diff --git a/src/include/catalog/pg_cast.dat b/src/include/catalog/pg_cast.dat index 67f73cb6fb..9a3e74c3f6 100644 --- a/src/include/catalog/pg_cast.dat +++ b/src/include/catalog/pg_cast.dat @@ -381,8 +381,6 @@ castcontext => 'a', castmethod => 'f' }, { castsource => 'lseg', casttarget => 'point', castfunc => 'point(lseg)', castcontext => 'e', castmethod => 'f' }, -{ castsource => 'path', casttarget => 'point', castfunc => 'point(path)', - castcontext => 'e', castmethod => 'f' }, { castsource => 'path', casttarget => 'polygon', castfunc => 'polygon(path)', castcontext => 'a', castmethod => 'f' }, { castsource => 'box', casttarget => 'point', castfunc => 'point(box)', diff --git a/src/include/catalog/pg_operator.dat b/src/include/catalog/pg_operator.dat index 0075a02f32..2bc7cc3548 100644 --- a/src/include/catalog/pg_operator.dat +++ b/src/include/catalog/pg_operator.dat @@ -1177,9 +1177,6 @@ { oid => '969', descr => 'center of', oprname => '@@', oprkind => 'l', oprleft => '0', oprright => 'lseg', oprresult => 'point', oprcode => 'lseg_center' }, -{ oid => '970', descr => 'center of', - oprname => '@@', oprkind => 'l', oprleft => '0', oprright => 'path', - oprresult => 'point', oprcode => 'path_center' }, { oid => '971', descr => 'center of', oprname => '@@', oprkind => 'l', oprleft => '0', oprright => 'polygon', oprresult => 'point', oprcode => 'poly_center' }, @@ -1742,14 +1739,6 @@ oprresult => 'float8', oprcom => '<->(circle,polygon)', oprcode => 'dist_polyc' }, -# additional geometric operators - thomas 1997-07-09 -{ oid => '1524', descr => 'distance between', - oprname => '<->', oprleft => 'line', oprright => 'box', oprresult => 'float8', - oprcom => '<->(box,line)', oprcode => 'dist_lb' }, -{ oid => '1382', descr => 'distance between', - oprname => '<->', oprleft => 'box', oprright => 'line', oprresult => 'float8', - oprcom => '<->(line,box)', oprcode => 'dist_bl' }, - { oid => '1525', descr => 'intersect', oprname => '?#', oprleft => 'lseg', oprright => 'lseg', oprresult => 'bool', oprcom => '?#(lseg,lseg)', oprcode => 'lseg_intersect' }, @@ -1805,15 +1794,9 @@ oprname => '##', oprleft => 'point', oprright => 'box', oprresult => 'point', oprcode => 'close_pb' }, -{ oid => '1566', descr => 'closest point to A on B', - oprname => '##', oprleft => 'lseg', oprright => 'line', oprresult => 'point', - oprcode => 'close_sl' }, { oid => '1567', descr => 'closest point to A on B', oprname => '##', oprleft => 'lseg', oprright => 'box', oprresult => 'point', oprcode => 'close_sb' }, -{ oid => '1568', descr => 'closest point to A on B', - oprname => '##', oprleft => 'line', oprright => 'box', oprresult => 'point', - oprcode => 'close_lb' }, { oid => '1577', descr => 'closest point to A on B', oprname => '##', oprleft => 'line', oprright => 'lseg', oprresult => 'point', oprcode => 'close_ls' }, diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 79d787cd26..4d992dc224 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -658,9 +658,6 @@ { oid => '225', proname => 'lseg_center', prorettype => 'point', proargtypes => 'lseg', prosrc => 'lseg_center' }, -{ oid => '226', - proname => 'path_center', prorettype => 'point', proargtypes => 'path', - prosrc => 'path_center' }, { oid => '227', proname => 'poly_center', prorettype => 'point', proargtypes => 'polygon', prosrc => 'poly_center' }, @@ -1460,12 +1457,6 @@ { oid => '702', proname => 'dist_lp', prorettype => 'float8', proargtypes => 'line point', prosrc => 'dist_lp' }, -{ oid => '726', - proname => 'dist_lb', prorettype => 'float8', proargtypes => 'line box', - prosrc => 'dist_lb' }, -{ oid => '703', - proname => 'dist_bl', prorettype => 'float8', proargtypes => 'box line', - prosrc => 'dist_bl' }, { oid => '727', proname => 'dist_sl', prorettype => 'float8', proargtypes => 'lseg line', prosrc => 'dist_sl' }, @@ -1970,12 +1961,6 @@ { oid => '961', proname => 'close_pl', prorettype => 'point', proargtypes => 'point line', prosrc => 'close_pl' }, -{ oid => '962', - proname => 'close_sl', prorettype => 'point', proargtypes => 'lseg line', - prosrc => 'close_sl' }, -{ oid => '963', - proname => 'close_lb', prorettype => 'point', proargtypes => 'line box', - prosrc => 'close_lb' }, { oid => '964', descr => 'large object unlink (delete)', proname => 'lo_unlink', provolatile => 'v', proparallel => 'u', @@ -3213,9 +3198,6 @@ { oid => '1532', descr => 'center of', proname => 'point', prorettype => 'point', proargtypes => 'lseg', prosrc => 'lseg_center' }, -{ oid => '1533', descr => 'center of', - proname => 'point', prorettype => 'point', proargtypes => 'path', - prosrc => 'path_center' }, { oid => '1534', descr => 'center of', proname => 'point', prorettype => 'point', proargtypes => 'box', prosrc => 'box_center' }, diff --git a/src/test/regress/expected/geometry.out b/src/test/regress/expected/geometry.out index eb717d3643..d91d829f0f 100644 --- a/src/test/regress/expected/geometry.out +++ b/src/test/regress/expected/geometry.out @@ -1467,11 +1467,6 @@ SELECT l1.s, l2.s, l1.s <-> l2.s FROM LINE_TBL l1, LINE_TBL l2; {-1,0,3} | {-1,0,3} | 0 (100 rows) --- Distance to box -SELECT l.s, b.f1, l.s <-> b.f1 FROM LINE_TBL l, BOX_TBL b; -ERROR: function "dist_lb" not implemented -SELECT l.s, b.f1, b.f1 <-> l.s FROM LINE_TBL l, BOX_TBL b; -ERROR: function "dist_bl" not implemented -- Intersect with line SELECT l1.s, l2.s FROM LINE_TBL l1, LINE_TBL l2 WHERE l1.s ?# l2.s; s | s @@ -1773,9 +1768,6 @@ SELECT l.s, l1.s, l.s ## l1.s FROM LINE_TBL l, LSEG_TBL l1; {-1,0,3} | [(NaN,1),(NaN,90)] | (80 rows) --- Closest point to box -SELECT l.s, b.f1, l.s ## b.f1 FROM LINE_TBL l, BOX_TBL b; -ERROR: function "close_lb" not implemented -- -- Line segments -- @@ -2376,9 +2368,6 @@ SELECT l1.s, l2.s, l1.s # l2.s FROM LSEG_TBL l1, LSEG_TBL l2; [(NaN,1),(NaN,90)] | [(NaN,1),(NaN,90)] | (64 rows) --- Closest point to line -SELECT l.s, l1.s, l.s ## l1.s FROM LSEG_TBL l, LINE_TBL l1; -ERROR: function "close_sl" not implemented -- Closest point to line segment SELECT l1.s, l2.s, l1.s ## l2.s FROM LSEG_TBL l1, LSEG_TBL l2; s | s | ?column? @@ -2922,9 +2911,6 @@ SELECT f1, @-@ f1 FROM PATH_TBL; ((11,12),(13,14)) | 5.65685424949 (9 rows) --- Center -SELECT f1, @@ f1 FROM PATH_TBL; -ERROR: function "path_center" not implemented -- To polygon SELECT f1, f1::polygon FROM PATH_TBL WHERE isclosed(f1); f1 | f1 diff --git a/src/test/regress/sql/geometry.sql b/src/test/regress/sql/geometry.sql index bbb6acd455..0aa06bcc9d 100644 --- a/src/test/regress/sql/geometry.sql +++ b/src/test/regress/sql/geometry.sql @@ -129,10 +129,6 @@ SELECT l1.s, l2.s FROM LINE_TBL l1, LINE_TBL l2 WHERE l1.s ?-| l2.s; -- Distance to line SELECT l1.s, l2.s, l1.s <-> l2.s FROM LINE_TBL l1, LINE_TBL l2; --- Distance to box -SELECT l.s, b.f1, l.s <-> b.f1 FROM LINE_TBL l, BOX_TBL b; -SELECT l.s, b.f1, b.f1 <-> l.s FROM LINE_TBL l, BOX_TBL b; - -- Intersect with line SELECT l1.s, l2.s FROM LINE_TBL l1, LINE_TBL l2 WHERE l1.s ?# l2.s; @@ -145,9 +141,6 @@ SELECT l1.s, l2.s, l1.s # l2.s FROM LINE_TBL l1, LINE_TBL l2; -- Closest point to line segment SELECT l.s, l1.s, l.s ## l1.s FROM LINE_TBL l, LSEG_TBL l1; --- Closest point to box -SELECT l.s, b.f1, l.s ## b.f1 FROM LINE_TBL l, BOX_TBL b; - -- -- Line segments -- @@ -213,9 +206,6 @@ SELECT l.s, b.f1 FROM LSEG_TBL l, BOX_TBL b WHERE l.s ?# b.f1; -- Intersection point with line segment SELECT l1.s, l2.s, l1.s # l2.s FROM LSEG_TBL l1, LSEG_TBL l2; --- Closest point to line -SELECT l.s, l1.s, l.s ## l1.s FROM LSEG_TBL l, LINE_TBL l1; - -- Closest point to line segment SELECT l1.s, l2.s, l1.s ## l2.s FROM LSEG_TBL l1, LSEG_TBL l2; @@ -285,9 +275,6 @@ SELECT f1, area(f1) FROM PATH_TBL; -- Length SELECT f1, @-@ f1 FROM PATH_TBL; --- Center -SELECT f1, @@ f1 FROM PATH_TBL; - -- To polygon SELECT f1, f1::polygon FROM PATH_TBL WHERE isclosed(f1);