Re: Array of box not supported? - Mailing list pgsql-jdbc

From Tom Lane
Subject Re: Array of box not supported?
Date
Msg-id 12630.1297876679@sss.pgh.pa.us
Whole thread Raw
In response to Array of box not supported?  (RW Shore <rws228@gmail.com>)
Responses Re: Array of box not supported?  (RW Shore <rws228@gmail.com>)
List pgsql-jdbc
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

pgsql-jdbc by date:

Previous
From: Lukas Eder
Date:
Subject: Re: [HACKERS] Fwd: Weird issues when reading UDT from stored function
Next
From: RW Shore
Date:
Subject: Re: Array of box not supported?