aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/geo_ops.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-04-07 20:50:02 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2020-04-07 20:50:02 -0400
commit35d1eefb29d03d5a85f71038679f1f8a14358255 (patch)
tree8ea18e89f4971e6b3f0a4f57e2f41cd5df0dcb4e /src/backend/utils/adt/geo_ops.c
parent6e6b74a206c3b4ad9f22f4910b2e0ed9d922b312 (diff)
downloadpostgresql-35d1eefb29d03d5a85f71038679f1f8a14358255.tar.gz
postgresql-35d1eefb29d03d5a85f71038679f1f8a14358255.zip
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
Diffstat (limited to 'src/backend/utils/adt/geo_ops.c')
-rw-r--r--src/backend/utils/adt/geo_ops.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c
index f8e74a00762..cb8f723e66b 100644
--- a/src/backend/utils/adt/geo_ops.c
+++ b/src/backend/utils/adt/geo_ops.c
@@ -4488,8 +4488,8 @@ poly_path(PG_FUNCTION_ARGS)
/* circle_in - convert a string to internal form.
*
* External format: (center and radius of circle)
- * "((f8,f8)<f8>)"
- * also supports quick entry style "(f8,f8,f8)"
+ * "<(f8,f8),f8>"
+ * also supports quick entry style "f8,f8,f8"
*/
Datum
circle_in(PG_FUNCTION_ARGS)
@@ -4503,16 +4503,19 @@ circle_in(PG_FUNCTION_ARGS)
s = str;
while (isspace((unsigned char) *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);
while (isspace((unsigned char) *cp))
cp++;
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);
if (*s == DELIM)