Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit332741e

Browse files
committed
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 occurwhen 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 bereached in normal dump/restore cases, and it's fairly debatable thatsuch conversion should ever have been made part of a type input functionin the first place. But in any case, I don't want to extend the softerror conventions into float.h without more discussion than this patchhas had.Amul Sul, minor mods by meDiscussion:https://postgr.es/m/CAAJ_b97KeDWUdpTKGOaFYPv0OicjOu6EW+QYWj-Ywrgj_aEy1g@mail.gmail.com
1 parent17407a8 commit332741e

File tree

15 files changed

+344
-71
lines changed

15 files changed

+344
-71
lines changed

‎src/backend/utils/adt/geo_ops.c

Lines changed: 113 additions & 71 deletions
Large diffs are not rendered by default.

‎src/test/regress/expected/box.out

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,3 +639,28 @@ WHERE seq.id IS NULL OR idx.id IS NULL;
639639
RESET enable_seqscan;
640640
RESET enable_indexscan;
641641
RESET enable_bitmapscan;
642+
-- test non-error-throwing API for some core types
643+
SELECT pg_input_is_valid('200', 'box');
644+
pg_input_is_valid
645+
-------------------
646+
f
647+
(1 row)
648+
649+
SELECT pg_input_error_message('200', 'box');
650+
pg_input_error_message
651+
------------------------------------------
652+
invalid input syntax for type box: "200"
653+
(1 row)
654+
655+
SELECT pg_input_is_valid('((200,300),(500, xyz))', 'box');
656+
pg_input_is_valid
657+
-------------------
658+
f
659+
(1 row)
660+
661+
SELECT pg_input_error_message('((200,300),(500, xyz))', 'box');
662+
pg_input_error_message
663+
-------------------------------------------------------------
664+
invalid input syntax for type box: "((200,300),(500, xyz))"
665+
(1 row)
666+

‎src/test/regress/expected/geometry.out

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5295,3 +5295,28 @@ SELECT * FROM polygon_tbl WHERE f1 @> '((1,1),(2,2),(2,1))'::polygon
52955295
((2,0),(2,4),(0,0))
52965296
(1 row)
52975297

5298+
-- test non-error-throwing API for some core types
5299+
SELECT pg_input_is_valid('(1', 'circle');
5300+
pg_input_is_valid
5301+
-------------------
5302+
f
5303+
(1 row)
5304+
5305+
SELECT pg_input_error_message('1,', 'circle');
5306+
pg_input_error_message
5307+
--------------------------------------------
5308+
invalid input syntax for type circle: "1,"
5309+
(1 row)
5310+
5311+
SELECT pg_input_is_valid('(1,2),-1', 'circle');
5312+
pg_input_is_valid
5313+
-------------------
5314+
f
5315+
(1 row)
5316+
5317+
SELECT pg_input_error_message('(1,2),-1', 'circle');
5318+
pg_input_error_message
5319+
--------------------------------------------------
5320+
invalid input syntax for type circle: "(1,2),-1"
5321+
(1 row)
5322+

‎src/test/regress/expected/line.out

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,64 @@ select '{nan, 1, nan}'::line = '{nan, 1, nan}'::line as true,
8585
t | f
8686
(1 row)
8787

88+
-- test non-error-throwing API for some core types
89+
SELECT pg_input_is_valid('{1, 1}', 'line');
90+
pg_input_is_valid
91+
-------------------
92+
f
93+
(1 row)
94+
95+
SELECT pg_input_error_message('{1, 1}', 'line');
96+
pg_input_error_message
97+
----------------------------------------------
98+
invalid input syntax for type line: "{1, 1}"
99+
(1 row)
100+
101+
SELECT pg_input_is_valid('{0, 0, 0}', 'line');
102+
pg_input_is_valid
103+
-------------------
104+
f
105+
(1 row)
106+
107+
SELECT pg_input_error_message('{0, 0, 0}', 'line');
108+
pg_input_error_message
109+
---------------------------------------------------------
110+
invalid line specification: A and B cannot both be zero
111+
(1 row)
112+
113+
SELECT pg_input_is_valid('{1, 1, a}', 'line');
114+
pg_input_is_valid
115+
-------------------
116+
f
117+
(1 row)
118+
119+
SELECT pg_input_error_message('{1, 1, a}', 'line');
120+
pg_input_error_message
121+
-------------------------------------------------
122+
invalid input syntax for type line: "{1, 1, a}"
123+
(1 row)
124+
125+
SELECT pg_input_is_valid('{1, 1, 1e400}', 'line');
126+
pg_input_is_valid
127+
-------------------
128+
f
129+
(1 row)
130+
131+
SELECT pg_input_error_message('{1, 1, 1e400}', 'line');
132+
pg_input_error_message
133+
---------------------------------------------------
134+
"1e400" is out of range for type double precision
135+
(1 row)
136+
137+
SELECT pg_input_is_valid('(1, 1), (1, 1e400)', 'line');
138+
pg_input_is_valid
139+
-------------------
140+
f
141+
(1 row)
142+
143+
SELECT pg_input_error_message('(1, 1), (1, 1e400)', 'line');
144+
pg_input_error_message
145+
---------------------------------------------------
146+
"1e400" is out of range for type double precision
147+
(1 row)
148+

‎src/test/regress/expected/lseg.out

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,16 @@ select * from LSEG_TBL;
4242
[(NaN,1),(NaN,90)]
4343
(8 rows)
4444

45+
-- test non-error-throwing API for some core types
46+
SELECT pg_input_is_valid('[(1,2),(3)]', 'lseg');
47+
pg_input_is_valid
48+
-------------------
49+
f
50+
(1 row)
51+
52+
SELECT pg_input_error_message('[(1,2),(3)]', 'lseg');
53+
pg_input_error_message
54+
---------------------------------------------------
55+
invalid input syntax for type lseg: "[(1,2),(3)]"
56+
(1 row)
57+

‎src/test/regress/expected/path.out

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,28 @@ SELECT popen(f1) AS open_path FROM PATH_TBL;
8080
[(11,12),(13,14)]
8181
(9 rows)
8282

83+
-- test non-error-throwing API for some core types
84+
SELECT pg_input_is_valid('[(1,2),(3)]', 'path');
85+
pg_input_is_valid
86+
-------------------
87+
f
88+
(1 row)
89+
90+
SELECT pg_input_error_message('[(1,2),(3)]', 'path');
91+
pg_input_error_message
92+
---------------------------------------------------
93+
invalid input syntax for type path: "[(1,2),(3)]"
94+
(1 row)
95+
96+
SELECT pg_input_is_valid('[(1,2,6),(3,4,6)]', 'path');
97+
pg_input_is_valid
98+
-------------------
99+
f
100+
(1 row)
101+
102+
SELECT pg_input_error_message('[(1,2,6),(3,4,6)]', 'path');
103+
pg_input_error_message
104+
---------------------------------------------------------
105+
invalid input syntax for type path: "[(1,2,6),(3,4,6)]"
106+
(1 row)
107+

‎src/test/regress/expected/point.out

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,3 +463,16 @@ SELECT COUNT(*) FROM point_gist_tbl WHERE f1 ~= '(0.0000018,0.0000018)'::point;
463463
RESET enable_seqscan;
464464
RESET enable_indexscan;
465465
RESET enable_bitmapscan;
466+
-- test non-error-throwing API for some core types
467+
SELECT pg_input_is_valid('1,y', 'point');
468+
pg_input_is_valid
469+
-------------------
470+
f
471+
(1 row)
472+
473+
SELECT pg_input_error_message('1,y', 'point');
474+
pg_input_error_message
475+
--------------------------------------------
476+
invalid input syntax for type point: "1,y"
477+
(1 row)
478+

‎src/test/regress/expected/polygon.out

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,28 @@ WHERE seq.id IS NULL OR idx.id IS NULL;
306306
RESET enable_seqscan;
307307
RESET enable_indexscan;
308308
RESET enable_bitmapscan;
309+
-- test non-error-throwing API for some core types
310+
SELECT pg_input_is_valid('(2.0,0.8,0.1)', 'polygon');
311+
pg_input_is_valid
312+
-------------------
313+
f
314+
(1 row)
315+
316+
SELECT pg_input_error_message('(2.0,0.8,0.1)', 'polygon');
317+
pg_input_error_message
318+
--------------------------------------------------------
319+
invalid input syntax for type polygon: "(2.0,0.8,0.1)"
320+
(1 row)
321+
322+
SELECT pg_input_is_valid('(2.0,xyz)', 'polygon');
323+
pg_input_is_valid
324+
-------------------
325+
f
326+
(1 row)
327+
328+
SELECT pg_input_error_message('(2.0,xyz)', 'polygon');
329+
pg_input_error_message
330+
----------------------------------------------------
331+
invalid input syntax for type polygon: "(2.0,xyz)"
332+
(1 row)
333+

‎src/test/regress/sql/box.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,9 @@ WHERE seq.id IS NULL OR idx.id IS NULL;
281281
RESET enable_seqscan;
282282
RESET enable_indexscan;
283283
RESET enable_bitmapscan;
284+
285+
-- test non-error-throwing API for some core types
286+
SELECT pg_input_is_valid('200','box');
287+
SELECT pg_input_error_message('200','box');
288+
SELECT pg_input_is_valid('((200,300),(500, xyz))','box');
289+
SELECT pg_input_error_message('((200,300),(500, xyz))','box');

‎src/test/regress/sql/geometry.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,3 +523,9 @@ SELECT * FROM polygon_tbl WHERE f1 @> '((1,1),(2,2),(2,1))'::polygon
523523
ORDER BY (poly_center(f1))[0];
524524
SELECT*FROM polygon_tblWHERE f1 @>'((1,1),(2,2),(2,1))'::polygon
525525
ORDER BY (poly_center(f1))[0];
526+
527+
-- test non-error-throwing API for some core types
528+
SELECT pg_input_is_valid('(1','circle');
529+
SELECT pg_input_error_message('1,','circle');
530+
SELECT pg_input_is_valid('(1,2),-1','circle');
531+
SELECT pg_input_error_message('(1,2),-1','circle');

‎src/test/regress/sql/line.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,15 @@ select * from LINE_TBL;
4040

4141
select'{nan, 1, nan}'::line='{nan, 1, nan}'::lineas true,
4242
'{nan, 1, nan}'::line='{nan, 2, nan}'::lineas false;
43+
44+
-- test non-error-throwing API for some core types
45+
SELECT pg_input_is_valid('{1, 1}','line');
46+
SELECT pg_input_error_message('{1, 1}','line');
47+
SELECT pg_input_is_valid('{0, 0, 0}','line');
48+
SELECT pg_input_error_message('{0, 0, 0}','line');
49+
SELECT pg_input_is_valid('{1, 1, a}','line');
50+
SELECT pg_input_error_message('{1, 1, a}','line');
51+
SELECT pg_input_is_valid('{1, 1, 1e400}','line');
52+
SELECT pg_input_error_message('{1, 1, 1e400}','line');
53+
SELECT pg_input_is_valid('(1, 1), (1, 1e400)','line');
54+
SELECT pg_input_error_message('(1, 1), (1, 1e400)','line');

‎src/test/regress/sql/lseg.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ INSERT INTO LSEG_TBL VALUES ('[(,2),(3,4)]');
2222
INSERT INTO LSEG_TBLVALUES ('[(1,2),(3,4)');
2323

2424
select*from LSEG_TBL;
25+
26+
-- test non-error-throwing API for some core types
27+
SELECT pg_input_is_valid('[(1,2),(3)]','lseg');
28+
SELECT pg_input_error_message('[(1,2),(3)]','lseg');

‎src/test/regress/sql/path.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,9 @@ SELECT f1 AS closed_path FROM PATH_TBL WHERE isclosed(f1);
4242
SELECT pclose(f1)AS closed_pathFROM PATH_TBL;
4343

4444
SELECT popen(f1)AS open_pathFROM PATH_TBL;
45+
46+
-- test non-error-throwing API for some core types
47+
SELECT pg_input_is_valid('[(1,2),(3)]','path');
48+
SELECT pg_input_error_message('[(1,2),(3)]','path');
49+
SELECT pg_input_is_valid('[(1,2,6),(3,4,6)]','path');
50+
SELECT pg_input_error_message('[(1,2,6),(3,4,6)]','path');

‎src/test/regress/sql/point.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,7 @@ SELECT COUNT(*) FROM point_gist_tbl WHERE f1 ~= '(0.0000018,0.0000018)'::point;
9696
RESET enable_seqscan;
9797
RESET enable_indexscan;
9898
RESET enable_bitmapscan;
99+
100+
-- test non-error-throwing API for some core types
101+
SELECT pg_input_is_valid('1,y','point');
102+
SELECT pg_input_error_message('1,y','point');

‎src/test/regress/sql/polygon.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,9 @@ WHERE seq.id IS NULL OR idx.id IS NULL;
140140
RESET enable_seqscan;
141141
RESET enable_indexscan;
142142
RESET enable_bitmapscan;
143+
144+
-- test non-error-throwing API for some core types
145+
SELECT pg_input_is_valid('(2.0,0.8,0.1)','polygon');
146+
SELECT pg_input_error_message('(2.0,0.8,0.1)','polygon');
147+
SELECT pg_input_is_valid('(2.0,xyz)','polygon');
148+
SELECT pg_input_error_message('(2.0,xyz)','polygon');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp