Thread: open and closed paths ...
I am using PostgreSQL 7.0.3. I have tried the isopen() function but it doesn't seem to work (or it is not fully implemented yet). In my opinion the third record is a closed path but the isopen() functions return f. Have I done something wrong, have I got something wrong or is it a bug? Hans shop=# SELECT * FROM temppath; fieldname ----------------------((1,3),(4,12))((3,1),(2,8),(10,4))((3,1),(2,8),(3,1))((1,1),(2,2),(3,3)) (4 rows) shop=# INSERT INTO temppath(fieldname) VALUES ('(1,1), (2,3)'); INSERT 51857 1 shop=# SELECT isopen(fieldname) FROM temppath;isopen --------fffff (5 rows)
Hans-Jürgen Schönig writes: > I am using PostgreSQL 7.0.3. I have tried the isopen() function but it > doesn't seem to work (or it is not fully implemented yet). > In my opinion the third record is a closed path but the isopen() > functions return f. For no good reason apart from ancient tradition, paths enclosed in parentheses, like ((3,1),(2,8),(10,4)), are implicitly closed. To make an open path brackets should be used, like [(3,1),(2,8),(10,4)]. -- Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/
The only problem left is the correct syntax of the command when using []. I've tried some versions but it did not work. Maybe Tom can include an example into the docs. Hans shop=# INSERT INTO temppath(fieldname) VALUES '((1,3), (4,12))'; ERROR: parser: parse error at or near "'" shop=# INSERT INTO temppath(fieldname) VALUES ((1,3), (4,12)); ERROR: parser: parse error at or near "," shop=# INSERT INTO temppath(fieldname) VALUES ('(1,3), (4,12)'); INSERT 51947 1 shop=# INSERT INTO temppath(fieldname) VALUES ['(1,3), (4,12)']; ERROR: parser: parse error at or near "[" shop=# INSERT INTO temppath(fieldname) VALUES '[(1,3), (4,12)]'; ERROR: parser: parse error at or near "'" shop=# INSERT INTO temppath(fieldname) VALUES '[(1,3), (4,12)]'::path; ERROR: parser: parse error at or near "'" shop=# INSERT INTO temppath(fieldname) VALUES ['(1,3), (4,12)']::path; ERROR: parser: parse error at or near "[" shop=# SELECT isopen(fieldname) FROM temppath;isopen --------f (1 row)
Hans-Jürgen Schönig writes: > The only problem left is the correct syntax of the command when using []. > I've tried some versions but it did not work. > Maybe Tom can include an example into the docs. > > Hans > > > shop=# INSERT INTO temppath(fieldname) VALUES '((1,3), (4,12))'; > ERROR: parser: parse error at or near "'" Should be VALUES ('((1,3), (4,12))'); The outer parentheses belong to the INSERT command, the quotes delimit the data literal, whatever is inside the quotes is the data type's business. > shop=# INSERT INTO temppath(fieldname) VALUES ((1,3), (4,12)); > ERROR: parser: parse error at or near "," > shop=# INSERT INTO temppath(fieldname) VALUES ('(1,3), (4,12)'); > INSERT 51947 1 > shop=# INSERT INTO temppath(fieldname) VALUES ['(1,3), (4,12)']; > ERROR: parser: parse error at or near "[" > shop=# INSERT INTO temppath(fieldname) VALUES '[(1,3), (4,12)]'; > ERROR: parser: parse error at or near "'" > shop=# INSERT INTO temppath(fieldname) VALUES '[(1,3), (4,12)]'::path; > ERROR: parser: parse error at or near "'" > shop=# INSERT INTO temppath(fieldname) VALUES ['(1,3), (4,12)']::path; > ERROR: parser: parse error at or near "[" -- Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/