pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
polygon problem
3+ messages / 3 participants
[nested] [flat]

* polygon problem
@ 1999-12-11 21:32 Brent Wood <brent.wood@blazemail.com>
  1999-12-12 01:43 ` Re: [SQL] polygon problem Gene Selkov Jr. <selkovjr@selkovjr.xnet.com>
  1999-12-12 05:53 ` Re: [SQL] polygon problem Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 3+ messages in thread

From: Brent Wood @ 1999-12-11 21:32 UTC (permalink / raw)
  To: pgsql-sql

A novice question (hopefully in the correct list):

I have installed PostgreSQL v6.5.3 on a Mandrake (RH 6.0) Linux system.
Regression tests do the normal thing....

Created a database "mydb", with a table "table1", comprising:
name            type        lgth        null?

p_name       bpchar     25     NOT NULL
s_region      polygon
p_type        bpchar     1

I'm trying to get data into this table, using the insert command to get
a feel for it, and the copy command for bulk insertions. (Longer term
goal is to have some code to load data from GIS packages into postgresql
for management/query systems)

    insert into table1 ( p_name ) values ('poly1');
This works fine, the table has a single record, with NULL's in the other
two attrs.

    insert into table1 ( p_name, p_type ) values ('poly1', 's');
This works, inserting a second record with only the polygon attr as
NULL.

    insert into table1 values ('poly1',((0,0),(0,1),(1,0)),'s');
This fails with the msg:
ERROR:   parser: parser error at or near ","

As I read the docs on polygon types, this should work. I can't find a
reference as to whether the polygon definition needs to repeat the last
coord pair to properly close the polygon or not. I have tried the insert
command with spaces between parentheses & values, and without commas
between polygon coords.

I need some help in getting carification of the polygon (& if possible,
other geometric datatypes) text formats for using with the insert/copy
SQL commands.

Related to this, given that the main purpose of the database will be
point-in-poly queries, some info on the relative merits of closed paths
vs polygons would also be appreciated (relative space, performance,
etc). I'm assuming (out of ignorance) that while they are functionally
equivalent, I'm better of using the polygon datatype in this context.


Any advice/suggestions gratefully accepted....

Thanks,

 Brent Wood




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [SQL] polygon problem
  1999-12-11 21:32 polygon problem Brent Wood <brent.wood@blazemail.com>
@ 1999-12-12 01:43 ` Gene Selkov Jr. <selkovjr@selkovjr.xnet.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Gene Selkov Jr. @ 1999-12-12 01:43 UTC (permalink / raw)
  To: Brent Wood <brent.wood@blazemail.com>; +Cc: pgsql-sql

According to Brent Wood:
> 
>     insert into table1 values ('poly1',((0,0),(0,1),(1,0)),'s');
> This fails with the msg:
> ERROR:   parser: parser error at or near ","
> 
> As I read the docs on polygon types, this should work.

It shouldn't. The SQL parser can't read the VALUES() clause because
you omitted the quotes around the polygon string. It had to be:

     insert into table1 values ('poly1', '((0,0),(0,1),(1,0))', 's');

or

     insert into table1 values ('poly1', '(0,0,0,1,1,0)', 's');


--Gene



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [SQL] polygon problem
  1999-12-11 21:32 polygon problem Brent Wood <brent.wood@blazemail.com>
@ 1999-12-12 05:53 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 1999-12-12 05:53 UTC (permalink / raw)
  To: Brent Wood <brent.wood@blazemail.com>; +Cc: pgsql-sql

Brent Wood <brent.wood@blazemail.com> writes:
>     insert into table1 values ('poly1',((0,0),(0,1),(1,0)),'s');
> This fails with the msg:
> ERROR:   parser: parser error at or near ","

I think you need quotes around the polygon value, ie,

    insert into table1 values ('poly1','((0,0),(0,1),(1,0))','s');

As a rule of thumb, the only datatypes that don't need quotes around
literal values in SQL statements are numeric types.  Our SQL parser
doesn't understand weird datatypes like polygon --- it wants a string
literal, which it'll eventually hand off to the type-specific input
routine for the datatype.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~1999-12-12 05:53 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-12-11 21:32 polygon problem Brent Wood <brent.wood@blazemail.com>
1999-12-12 01:43 ` Gene Selkov Jr. <selkovjr@selkovjr.xnet.com>
1999-12-12 05:53 ` Tom Lane <tgl@sss.pgh.pa.us>

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