mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-08 09:36:52 +02:00
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 predictable consequences. Remarkably, this has been wrong since the circle datatype was added in 1997, but nobody noticed till now. David Zhang, with some help from me Discussion: https://postgr.es/m/332c47fa-d951-7574-b5cc-a8f7f7201202@highgo.ca
This commit is contained in:
parent
5d79fc60c5
commit
5fae664101
@ -4525,8 +4525,8 @@ poly_path(PG_FUNCTION_ARGS)
|
|||||||
/* circle_in - convert a string to internal form.
|
/* circle_in - convert a string to internal form.
|
||||||
*
|
*
|
||||||
* External format: (center and radius of circle)
|
* External format: (center and radius of circle)
|
||||||
* "((f8,f8)<f8>)"
|
* "<(f8,f8),f8>"
|
||||||
* also supports quick entry style "(f8,f8,f8)"
|
* also supports quick entry style "f8,f8,f8"
|
||||||
*/
|
*/
|
||||||
Datum
|
Datum
|
||||||
circle_in(PG_FUNCTION_ARGS)
|
circle_in(PG_FUNCTION_ARGS)
|
||||||
@ -4540,16 +4540,19 @@ circle_in(PG_FUNCTION_ARGS)
|
|||||||
s = str;
|
s = str;
|
||||||
while (isspace((unsigned char) *s))
|
while (isspace((unsigned char) *s))
|
||||||
s++;
|
s++;
|
||||||
if ((*s == LDELIM_C) || (*s == LDELIM))
|
if (*s == LDELIM_C)
|
||||||
|
depth++, s++;
|
||||||
|
else if (*s == LDELIM)
|
||||||
{
|
{
|
||||||
depth++;
|
/* If there are two left parens, consume the first one */
|
||||||
cp = (s + 1);
|
cp = (s + 1);
|
||||||
while (isspace((unsigned char) *cp))
|
while (isspace((unsigned char) *cp))
|
||||||
cp++;
|
cp++;
|
||||||
if (*cp == LDELIM)
|
if (*cp == LDELIM)
|
||||||
s = cp;
|
depth++, s = cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* pair_decode will consume parens around the pair, if any */
|
||||||
pair_decode(s, &circle->center.x, &circle->center.y, &s, "circle", str);
|
pair_decode(s, &circle->center.x, &circle->center.y, &s, "circle", str);
|
||||||
|
|
||||||
if (*s == DELIM)
|
if (*s == DELIM)
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
--
|
--
|
||||||
CREATE TABLE CIRCLE_TBL (f1 circle);
|
CREATE TABLE CIRCLE_TBL (f1 circle);
|
||||||
INSERT INTO CIRCLE_TBL VALUES ('<(5,1),3>');
|
INSERT INTO CIRCLE_TBL VALUES ('<(5,1),3>');
|
||||||
INSERT INTO CIRCLE_TBL VALUES ('<(1,2),100>');
|
INSERT INTO CIRCLE_TBL VALUES ('((1,2),100)');
|
||||||
INSERT INTO CIRCLE_TBL VALUES ('1,3,5');
|
INSERT INTO CIRCLE_TBL VALUES (' 1 , 3 , 5 ');
|
||||||
INSERT INTO CIRCLE_TBL VALUES ('((1,2),3)');
|
INSERT INTO CIRCLE_TBL VALUES (' ( ( 1 , 2 ) , 3 ) ');
|
||||||
INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10>');
|
INSERT INTO CIRCLE_TBL VALUES (' ( 100 , 200 ) , 10 ');
|
||||||
INSERT INTO CIRCLE_TBL VALUES ('<(100,1),115>');
|
INSERT INTO CIRCLE_TBL VALUES (' < ( 100 , 1 ) , 115 > ');
|
||||||
-- bad values
|
-- bad values
|
||||||
INSERT INTO CIRCLE_TBL VALUES ('<(-100,0),-100>');
|
INSERT INTO CIRCLE_TBL VALUES ('<(-100,0),-100>');
|
||||||
ERROR: invalid input syntax for type circle: "<(-100,0),-100>"
|
ERROR: invalid input syntax for type circle: "<(-100,0),-100>"
|
||||||
|
@ -6,15 +6,15 @@ CREATE TABLE CIRCLE_TBL (f1 circle);
|
|||||||
|
|
||||||
INSERT INTO CIRCLE_TBL VALUES ('<(5,1),3>');
|
INSERT INTO CIRCLE_TBL VALUES ('<(5,1),3>');
|
||||||
|
|
||||||
INSERT INTO CIRCLE_TBL VALUES ('<(1,2),100>');
|
INSERT INTO CIRCLE_TBL VALUES ('((1,2),100)');
|
||||||
|
|
||||||
INSERT INTO CIRCLE_TBL VALUES ('1,3,5');
|
INSERT INTO CIRCLE_TBL VALUES (' 1 , 3 , 5 ');
|
||||||
|
|
||||||
INSERT INTO CIRCLE_TBL VALUES ('((1,2),3)');
|
INSERT INTO CIRCLE_TBL VALUES (' ( ( 1 , 2 ) , 3 ) ');
|
||||||
|
|
||||||
INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10>');
|
INSERT INTO CIRCLE_TBL VALUES (' ( 100 , 200 ) , 10 ');
|
||||||
|
|
||||||
INSERT INTO CIRCLE_TBL VALUES ('<(100,1),115>');
|
INSERT INTO CIRCLE_TBL VALUES (' < ( 100 , 1 ) , 115 > ');
|
||||||
|
|
||||||
-- bad values
|
-- bad values
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user