From: David Zhang <david.zhang@highgo.ca>
To: pgsql-hackers@postgresql.org, David Zhang <david.zhang@highgo.ca>
Subject: ERROR: invalid input syntax for type circle
Date: Mon, 6 Apr 2020 14:12:38 -0700
Message-ID: <332c47fa-d951-7574-b5cc-a8f7f7201202@highgo.ca> (raw)
Hi,
I got an error when I was trying to insert a circle using the syntax
(the 3rd one) specified in the latest document.
https://www.postgresql.org/docs/current/datatype-geometric.html#DATATYPE-CIRCLE
< ( x , y ) , r >
( ( x , y ) , r )
( x , y ) , r
x , y , r
Here is how to reproduce it.
CREATE TABLE tbl_circle(id serial PRIMARY KEY, a circle);
INSERT INTO tbl_circle(a) VALUES('( 1 , 1 ) , 5'::circle );
ERROR: invalid input syntax for type circle: "( 1 , 1 ) , 5"
LINE 1: INSERT INTO tbl_circle(a) VALUES('( 1 , 1 ) , 5'::circle );
I made a little change in the "circle_in" function, and then I can enter
a circle using the 3rd way.
INSERT INTO tbl_circle(a) VALUES('( 1 , 1 ) , 5'::circle );
INSERT 0 1
The fix does generate the same output as the other three ways.
INSERT INTO tbl_circle(a) VALUES( '< ( 1 , 1 ) , 5 >'::circle );
INSERT INTO tbl_circle(a) VALUES( '( ( 1 , 1 ) , 5 )'::circle );
INSERT INTO tbl_circle(a) VALUES( '1 , 1 , 5'::circle );
select * from tbl_circle;
id | a
----+-----------
1 | <(1,1),5>
2 | <(1,1),5>
3 | <(1,1),5>
4 | <(1,1),5>
(4 rows)
Sor far, no error found during the "make check".
The patch based on tag "REL_12_2" is attached.
--
David
Software Engineer
Highgo Software Inc. (Canada)
www.highgo.ca
Attachments:circle-in-input-format-fix.patch (text/plain, 434B) downloaddiff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.cindex 373784fcc1..6efd5bc1f2 100644--- a/src/backend/utils/adt/geo_ops.c+++ b/src/backend/utils/adt/geo_ops.c@@ -4528,7 +4528,7 @@ circle_in(PG_FUNCTION_ARGS)
while (depth > 0)
{
- if ((*s == RDELIM) || ((*s == RDELIM_C) && (depth == 1)))+ if ((*s == RDELIM) || (((*s == RDELIM_C) || (*s == '\0')) && (depth == 1)))
{
depth--;
s++;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: david.zhang@highgo.ca
Subject: Re: ERROR: invalid input syntax for type circle
In-Reply-To: <332c47fa-d951-7574-b5cc-a8f7f7201202@highgo.ca>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox