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

Commit4c7a311

Browse files
committed
Fix circle_in to accept "(x,y),r" as it's advertised to do.
Our documentation describes four allowed input syntaxes for circles,but the regression tests tried only three ... with predictableconsequences. Remarkably, this has been wrong since the circledatatype was added in 1997, but nobody noticed till now.David Zhang, with some help from meDiscussion:https://postgr.es/m/332c47fa-d951-7574-b5cc-a8f7f7201202@highgo.ca
1 parent889786e commit4c7a311

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4526,8 +4526,8 @@ poly_path(PG_FUNCTION_ARGS)
45264526
/*circle_in-convert a string to internal form.
45274527
*
45284528
*External format: (center and radius of circle)
4529-
*"((f8,f8)<f8>)"
4530-
*also supports quick entry style "(f8,f8,f8)"
4529+
*"<(f8,f8),f8>"
4530+
*also supports quick entry style "f8,f8,f8"
45314531
*/
45324532
Datum
45334533
circle_in(PG_FUNCTION_ARGS)
@@ -4541,16 +4541,19 @@ circle_in(PG_FUNCTION_ARGS)
45414541
s=str;
45424542
while (isspace((unsignedchar)*s))
45434543
s++;
4544-
if ((*s==LDELIM_C)|| (*s==LDELIM))
4544+
if (*s==LDELIM_C)
4545+
depth++,s++;
4546+
elseif (*s==LDELIM)
45454547
{
4546-
depth++;
4548+
/* If there are two left parens, consume the first one */
45474549
cp= (s+1);
45484550
while (isspace((unsignedchar)*cp))
45494551
cp++;
45504552
if (*cp==LDELIM)
4551-
s=cp;
4553+
depth++,s=cp;
45524554
}
45534555

4556+
/* pair_decode will consume parens around the pair, if any */
45544557
pair_decode(s,&circle->center.x,&circle->center.y,&s,"circle",str);
45554558

45564559
if (*s==DELIM)

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
--
44
CREATE TABLE CIRCLE_TBL (f1 circle);
55
INSERT INTO CIRCLE_TBL VALUES ('<(5,1),3>');
6-
INSERT INTO CIRCLE_TBL VALUES ('<(1,2),100>');
7-
INSERT INTO CIRCLE_TBL VALUES ('1,3,5');
8-
INSERT INTO CIRCLE_TBL VALUES ('((1,2),3)');
9-
INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10>');
10-
INSERT INTO CIRCLE_TBL VALUES ('<(100,1),115>');
6+
INSERT INTO CIRCLE_TBL VALUES ('((1,2),100)');
7+
INSERT INTO CIRCLE_TBL VALUES (' 1 , 3 , 5');
8+
INSERT INTO CIRCLE_TBL VALUES (' ( ( 1 , 2 ) , 3 )');
9+
INSERT INTO CIRCLE_TBL VALUES (' (100 ,200 ) , 10');
10+
INSERT INTO CIRCLE_TBL VALUES (' < (100 , 1 ) ,115 >');
1111
-- bad values
1212
INSERT INTO CIRCLE_TBL VALUES ('<(-100,0),-100>');
1313
ERROR: invalid input syntax for type circle: "<(-100,0),-100>"

‎src/test/regress/sql/circle.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ CREATE TABLE CIRCLE_TBL (f1 circle);
66

77
INSERT INTO CIRCLE_TBLVALUES ('<(5,1),3>');
88

9-
INSERT INTO CIRCLE_TBLVALUES ('<(1,2),100>');
9+
INSERT INTO CIRCLE_TBLVALUES ('((1,2),100)');
1010

11-
INSERT INTO CIRCLE_TBLVALUES ('1,3,5');
11+
INSERT INTO CIRCLE_TBLVALUES (' 1 , 3 , 5');
1212

13-
INSERT INTO CIRCLE_TBLVALUES ('((1,2),3)');
13+
INSERT INTO CIRCLE_TBLVALUES (' ( ( 1 , 2 ) , 3 )');
1414

15-
INSERT INTO CIRCLE_TBLVALUES ('<(100,200),10>');
15+
INSERT INTO CIRCLE_TBLVALUES (' (100 ,200 ) , 10');
1616

17-
INSERT INTO CIRCLE_TBLVALUES ('<(100,1),115>');
17+
INSERT INTO CIRCLE_TBLVALUES (' < (100 , 1 ) ,115 >');
1818

1919
-- bad values
2020

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp