summaryrefslogtreecommitdiff
path: root/src/test/regress/sql
diff options
context:
space:
mode:
authorTom Lane2022-12-14 21:10:20 +0000
committerTom Lane2022-12-14 21:10:20 +0000
commit332741e73980401895e027eb697bb472860036fb (patch)
treeb752539838c2cf3f8a856ab5100f2f043440ac91 /src/test/regress/sql
parent17407a8eaa2afa8ac0de4b0a494f33d8eb7a98bd (diff)
Convert the geometric input functions to report errors softly.
Convert box_in, circle_in, line_in, lseg_in, path_in, point_in, and poly_in to the new style. line_in still throws hard errors for overflows/underflows that can occur when the input is specified as two points rather than in the canonical "Ax + By + C = 0" style. I'm not too concerned about that: it won't be reached in normal dump/restore cases, and it's fairly debatable that such conversion should ever have been made part of a type input function in the first place. But in any case, I don't want to extend the soft error conventions into float.h without more discussion than this patch has had. Amul Sul, minor mods by me Discussion: https://postgr.es/m/CAAJ_b97KeDWUdpTKGOaFYPv0OicjOu6EW+QYWj-Ywrgj_aEy1g@mail.gmail.com
Diffstat (limited to 'src/test/regress/sql')
-rw-r--r--src/test/regress/sql/box.sql6
-rw-r--r--src/test/regress/sql/geometry.sql6
-rw-r--r--src/test/regress/sql/line.sql12
-rw-r--r--src/test/regress/sql/lseg.sql4
-rw-r--r--src/test/regress/sql/path.sql6
-rw-r--r--src/test/regress/sql/point.sql4
-rw-r--r--src/test/regress/sql/polygon.sql6
7 files changed, 44 insertions, 0 deletions
diff --git a/src/test/regress/sql/box.sql b/src/test/regress/sql/box.sql
index ceae58fc02f..02e100391b4 100644
--- a/src/test/regress/sql/box.sql
+++ b/src/test/regress/sql/box.sql
@@ -281,3 +281,9 @@ WHERE seq.id IS NULL OR idx.id IS NULL;
RESET enable_seqscan;
RESET enable_indexscan;
RESET enable_bitmapscan;
+
+-- test non-error-throwing API for some core types
+SELECT pg_input_is_valid('200', 'box');
+SELECT pg_input_error_message('200', 'box');
+SELECT pg_input_is_valid('((200,300),(500, xyz))', 'box');
+SELECT pg_input_error_message('((200,300),(500, xyz))', 'box');
diff --git a/src/test/regress/sql/geometry.sql b/src/test/regress/sql/geometry.sql
index 8928d04aa3f..309234b76c1 100644
--- a/src/test/regress/sql/geometry.sql
+++ b/src/test/regress/sql/geometry.sql
@@ -523,3 +523,9 @@ SELECT * FROM polygon_tbl WHERE f1 @> '((1,1),(2,2),(2,1))'::polygon
ORDER BY (poly_center(f1))[0];
SELECT * FROM polygon_tbl WHERE f1 @> '((1,1),(2,2),(2,1))'::polygon
ORDER BY (poly_center(f1))[0];
+
+-- test non-error-throwing API for some core types
+SELECT pg_input_is_valid('(1', 'circle');
+SELECT pg_input_error_message('1,', 'circle');
+SELECT pg_input_is_valid('(1,2),-1', 'circle');
+SELECT pg_input_error_message('(1,2),-1', 'circle');
diff --git a/src/test/regress/sql/line.sql b/src/test/regress/sql/line.sql
index f589ffecc84..f706a41184d 100644
--- a/src/test/regress/sql/line.sql
+++ b/src/test/regress/sql/line.sql
@@ -40,3 +40,15 @@ select * from LINE_TBL;
select '{nan, 1, nan}'::line = '{nan, 1, nan}'::line as true,
'{nan, 1, nan}'::line = '{nan, 2, nan}'::line as false;
+
+-- test non-error-throwing API for some core types
+SELECT pg_input_is_valid('{1, 1}', 'line');
+SELECT pg_input_error_message('{1, 1}', 'line');
+SELECT pg_input_is_valid('{0, 0, 0}', 'line');
+SELECT pg_input_error_message('{0, 0, 0}', 'line');
+SELECT pg_input_is_valid('{1, 1, a}', 'line');
+SELECT pg_input_error_message('{1, 1, a}', 'line');
+SELECT pg_input_is_valid('{1, 1, 1e400}', 'line');
+SELECT pg_input_error_message('{1, 1, 1e400}', 'line');
+SELECT pg_input_is_valid('(1, 1), (1, 1e400)', 'line');
+SELECT pg_input_error_message('(1, 1), (1, 1e400)', 'line');
diff --git a/src/test/regress/sql/lseg.sql b/src/test/regress/sql/lseg.sql
index f266ca3e09e..0fece162e01 100644
--- a/src/test/regress/sql/lseg.sql
+++ b/src/test/regress/sql/lseg.sql
@@ -22,3 +22,7 @@ INSERT INTO LSEG_TBL VALUES ('[(,2),(3,4)]');
INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)');
select * from LSEG_TBL;
+
+-- test non-error-throwing API for some core types
+SELECT pg_input_is_valid('[(1,2),(3)]', 'lseg');
+SELECT pg_input_error_message('[(1,2),(3)]', 'lseg');
diff --git a/src/test/regress/sql/path.sql b/src/test/regress/sql/path.sql
index 89f1aa9a329..42c90afe53b 100644
--- a/src/test/regress/sql/path.sql
+++ b/src/test/regress/sql/path.sql
@@ -42,3 +42,9 @@ SELECT f1 AS closed_path FROM PATH_TBL WHERE isclosed(f1);
SELECT pclose(f1) AS closed_path FROM PATH_TBL;
SELECT popen(f1) AS open_path FROM PATH_TBL;
+
+-- test non-error-throwing API for some core types
+SELECT pg_input_is_valid('[(1,2),(3)]', 'path');
+SELECT pg_input_error_message('[(1,2),(3)]', 'path');
+SELECT pg_input_is_valid('[(1,2,6),(3,4,6)]', 'path');
+SELECT pg_input_error_message('[(1,2,6),(3,4,6)]', 'path');
diff --git a/src/test/regress/sql/point.sql b/src/test/regress/sql/point.sql
index 435ff4b9b69..7bd1ebe2b51 100644
--- a/src/test/regress/sql/point.sql
+++ b/src/test/regress/sql/point.sql
@@ -96,3 +96,7 @@ SELECT COUNT(*) FROM point_gist_tbl WHERE f1 ~= '(0.0000018,0.0000018)'::point;
RESET enable_seqscan;
RESET enable_indexscan;
RESET enable_bitmapscan;
+
+-- test non-error-throwing API for some core types
+SELECT pg_input_is_valid('1,y', 'point');
+SELECT pg_input_error_message('1,y', 'point');
diff --git a/src/test/regress/sql/polygon.sql b/src/test/regress/sql/polygon.sql
index f53b2cb6309..da644e34e30 100644
--- a/src/test/regress/sql/polygon.sql
+++ b/src/test/regress/sql/polygon.sql
@@ -140,3 +140,9 @@ WHERE seq.id IS NULL OR idx.id IS NULL;
RESET enable_seqscan;
RESET enable_indexscan;
RESET enable_bitmapscan;
+
+-- test non-error-throwing API for some core types
+SELECT pg_input_is_valid('(2.0,0.8,0.1)', 'polygon');
+SELECT pg_input_error_message('(2.0,0.8,0.1)', 'polygon');
+SELECT pg_input_is_valid('(2.0,xyz)', 'polygon');
+SELECT pg_input_error_message('(2.0,xyz)', 'polygon');