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

Commit41a194f

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 parent75848bc commit41a194f

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4604,8 +4604,8 @@ poly_path(PG_FUNCTION_ARGS)
46044604
/*circle_in-convert a string to internal form.
46054605
*
46064606
*External format: (center and radius of circle)
4607-
*"((f8,f8)<f8>)"
4608-
*also supports quick entry style "(f8,f8,f8)"
4607+
*"<(f8,f8),f8>"
4608+
*also supports quick entry style "f8,f8,f8"
46094609
*/
46104610
Datum
46114611
circle_in(PG_FUNCTION_ARGS)
@@ -4619,16 +4619,19 @@ circle_in(PG_FUNCTION_ARGS)
46194619
s=str;
46204620
while (isspace((unsignedchar)*s))
46214621
s++;
4622-
if ((*s==LDELIM_C)|| (*s==LDELIM))
4622+
if (*s==LDELIM_C)
4623+
depth++,s++;
4624+
elseif (*s==LDELIM)
46234625
{
4624-
depth++;
4626+
/* If there are two left parens, consume the first one */
46254627
cp= (s+1);
46264628
while (isspace((unsignedchar)*cp))
46274629
cp++;
46284630
if (*cp==LDELIM)
4629-
s=cp;
4631+
depth++,s=cp;
46304632
}
46314633

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

46344637
if (*s==DELIM)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
SET extra_float_digits = -1;
77
CREATE TABLE CIRCLE_TBL (f1 circle);
88
INSERT INTO CIRCLE_TBL VALUES ('<(5,1),3>');
9-
INSERT INTO CIRCLE_TBL VALUES ('<(1,2),100>');
10-
INSERT INTO CIRCLE_TBL VALUES ('1,3,5');
11-
INSERT INTO CIRCLE_TBL VALUES ('((1,2),3)');
12-
INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10>');
9+
INSERT INTO CIRCLE_TBL VALUES ('((1,2),100)');
10+
INSERT INTO CIRCLE_TBL VALUES (' 1 , 3 , 5');
11+
INSERT INTO CIRCLE_TBL VALUES (' ( ( 1 , 2 ) , 3 )');
12+
INSERT INTO CIRCLE_TBL VALUES (' (100 ,200 ) , 10');
1313
INSERT INTO CIRCLE_TBL VALUES (' < ( 100 , 1 ) , 115 > ');
1414
INSERT INTO CIRCLE_TBL VALUES ('<(3,5),0>');-- Zero radius
1515
INSERT INTO CIRCLE_TBL VALUES ('<(3,5),NaN>');-- NaN radius

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ CREATE TABLE CIRCLE_TBL (f1 circle);
1010

1111
INSERT INTO CIRCLE_TBLVALUES ('<(5,1),3>');
1212

13-
INSERT INTO CIRCLE_TBLVALUES ('<(1,2),100>');
13+
INSERT INTO CIRCLE_TBLVALUES ('((1,2),100)');
1414

15-
INSERT INTO CIRCLE_TBLVALUES ('1,3,5');
15+
INSERT INTO CIRCLE_TBLVALUES (' 1 , 3 , 5');
1616

17-
INSERT INTO CIRCLE_TBLVALUES ('((1,2),3)');
17+
INSERT INTO CIRCLE_TBLVALUES (' ( ( 1 , 2 ) , 3 )');
1818

19-
INSERT INTO CIRCLE_TBLVALUES ('<(100,200),10>');
19+
INSERT INTO CIRCLE_TBLVALUES (' (100 ,200 ) , 10');
2020

2121
INSERT INTO CIRCLE_TBLVALUES (' < ( 100 , 1 ) , 115 >');
2222

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp