pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: RW Shore <rws228@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Array of box not supported?
Date: Wed, 16 Feb 2011 12:17:59 -0500
Message-ID: <12630.1297876679@sss.pgh.pa.us> (raw)
In-Reply-To: <AANLkTin8UAg6PXScMjnkYMzq3Ud5HuFZBOazmh466cCp@mail.gmail.com>
References: <AANLkTin8UAg6PXScMjnkYMzq3Ud5HuFZBOazmh466cCp@mail.gmail.com>

RW Shore <rws228@gmail.com> writes:
> To insert into a box[ ], I need to convert the individual boxes into a
> string. I get a "malformed array literal" error with any of the following
> formats for a 1 dimensional array with two boxes:

> {"1.0,1.0,0.0,0.0","10.0,10.0,0.0,0.0"}
> {"((1.0,1.0),(0.0,0.0))","((10.0,10.0),(0.0,0.0))"}
> {"(1.0,1.0),(0.0,0.0)","(10.0,10.0),(0.0,0.0)"}

For historical reasons (well, I can see why they did it, but it's still
weird), array of box uses semicolon not comma as the delimiter between
array elements.

regression=# select '{"1.0,1.0,0.0,0.0","10.0,10.0,0.0,0.0"}'::box[];
ERROR:  malformed array literal: "{"1.0,1.0,0.0,0.0","10.0,10.0,0.0,0.0"}"
LINE 1: select '{"1.0,1.0,0.0,0.0","10.0,10.0,0.0,0.0"}'::box[];
               ^
regression=# select '{"1.0,1.0,0.0,0.0";"10.0,10.0,0.0,0.0"}'::box[];
             box             
-----------------------------
 {(1,1),(0,0);(10,10),(0,0)}
(1 row)

The advantage is you don't need double quotes:

regression=# select '{1.0,1.0,0.0,0.0;10.0,10.0,0.0,0.0}'::box[];
             box             
-----------------------------
 {(1,1),(0,0);(10,10),(0,0)}
(1 row)

Whether this requires any special pushups on the JDBC side is beyond
my ken.

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <12630.1297876679@sss.pgh.pa.us>
Permalink:  ../12630.1297876679@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/12630.1297876679@sss.pgh.pa.us

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: tgl@sss.pgh.pa.us, rws228@gmail.com
  Subject: Re: Array of box not supported?
  In-Reply-To: <12630.1297876679@sss.pgh.pa.us>
  References: <AANLkTin8UAg6PXScMjnkYMzq3Ud5HuFZBOazmh466cCp@mail.gmail.com> <12630.1297876679@sss.pgh.pa.us>

* 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