pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Array Char/VarChar Size
5+ messages / 3 participants
[nested] [flat]

* Array Char/VarChar Size
@ 2008-02-27 07:35  dmp <danap@ttc-cmc.net>
  0 siblings, 2 replies; 5+ messages in thread

From: dmp @ 2008-02-27 07:35 UTC (permalink / raw)
  To: pgsql-jdbc

Given a defined table as such:

CREATE TABLE array_types (

    data_type_id serial NOT NULL,
   
    decimal_array decimal(16,2)[] DEFAULT NULL,
    numeric_array numeric(10,2)[] DEFAULT NULL,
    varchar_array varchar(30)[] DEFAULT NULL,
    char_array char(30)[][] DEFAULT NULL,
    PRIMARY KEY  (data_type_id)
);

How do I obtain the precision, decimal places, or character
sizing information from the database. Notice these are array
types.

danap.



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

* Re: Array Char/VarChar Size
@ 2008-02-29 16:59  Kris Jurka <books@ejurka.com>
  parent: dmp <danap@ttc-cmc.net>
  1 sibling, 0 replies; 5+ messages in thread

From: Kris Jurka @ 2008-02-29 16:59 UTC (permalink / raw)
  To: dmp <danap@ttc-cmc.net>; +Cc: pgsql-jdbc



On Wed, 27 Feb 2008, dmp wrote:

> Given a defined table as such:
>
> CREATE TABLE array_types (
>
>   data_type_id serial NOT NULL,
>     decimal_array decimal(16,2)[] DEFAULT NULL,
>   numeric_array numeric(10,2)[] DEFAULT NULL,
>   varchar_array varchar(30)[] DEFAULT NULL,
>   char_array char(30)[][] DEFAULT NULL,
>   PRIMARY KEY  (data_type_id)
> );
>
> How do I obtain the precision, decimal places, or character
> sizing information from the database. Notice these are array
> types.

Currently the driver does not return this information, but we've listed it 
as an open feature request:

http://pgfoundry.org/tracker/index.php?func=detail&aid=1010248&group_id=1000224&atid=857

Kris Jurka




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

* Re: Array Char/VarChar Size
@ 2008-02-29 17:32  dmp <danap@ttc-cmc.net>
  parent: dmp <danap@ttc-cmc.net>
  1 sibling, 1 reply; 5+ messages in thread

From: dmp @ 2008-02-29 17:32 UTC (permalink / raw)
  To: pgsql-jdbc

Perhaps this is not the appropriate list, but is there a way to 
determine this information
from the information_schema? The reason I ask is I can not seem to find 
this information
there either. pg_dump does provide this information, though lacking the 
ability to proper
identify multi-dimensional arrays, ex. char(30)[][] gives char(30)[].

danap.


> Currently the driver does not return this information, but we've 
> listed it as an open feature request:
>
> http://pgfoundry.org/tracker/index.php?func=detail&aid=1010248&group_id=1000224&atid=857
>
> Kris Jurka



> Given a defined table as such:
>
> CREATE TABLE array_types (
>
>    data_type_id serial NOT NULL,
>      decimal_array decimal(16,2)[] DEFAULT NULL,
>    numeric_array numeric(10,2)[] DEFAULT NULL,
>    varchar_array varchar(30)[] DEFAULT NULL,
>    char_array char(30)[][] DEFAULT NULL,
>    PRIMARY KEY  (data_type_id)
> );
>
> How do I obtain the precision, decimal places, or character
> sizing information from the database. Notice these are array
> types.
>
> danap. 




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

* Re: Array Char/VarChar Size
@ 2008-02-29 17:53  Kris Jurka <books@ejurka.com>
  parent: dmp <danap@ttc-cmc.net>
  0 siblings, 1 reply; 5+ messages in thread

From: Kris Jurka @ 2008-02-29 17:53 UTC (permalink / raw)
  To: dmp <danap@ttc-cmc.net>; +Cc: pgsql-jdbc



On Fri, 29 Feb 2008, dmp wrote:

> Perhaps this is not the appropriate list, but is there a way to 
> determine this information from the information_schema? The reason I ask 
> is I can not seem to find this information there either. pg_dump does 
> provide this information, though lacking the ability to proper identify 
> multi-dimensional arrays, ex. char(30)[][] gives char(30)[].

Multi-dimensional array information is not stored.  Every array type may 
be any number of dimensions.  The precision information is not available 
in the information_schema, but it is available in the system catalog 
tables.  See pg_attribute.atttypmod, but it does require some decoding.

Kris Jurka




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

* Re: Array Char/VarChar Size
@ 2008-02-29 18:44  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Kris Jurka <books@ejurka.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2008-02-29 18:44 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: dmp <danap@ttc-cmc.net>; pgsql-jdbc

Kris Jurka <books@ejurka.com> writes:
> Multi-dimensional array information is not stored.  Every array type may 
> be any number of dimensions.  The precision information is not available 
> in the information_schema, but it is available in the system catalog 
> tables.  See pg_attribute.atttypmod, but it does require some decoding.

Rather than embedding knowledge of typmod encoding in client-side code,
may I suggest using the format_type function?  For example

select format_type(atttypid, atttypmod) from pg_attribute where
attrelid = 'my_table'::regclass and attname = 'my_column';

This will give you back something reasonably standardized, like
"character varying(42)[]".  You'll still need a bit of logic to
extract what you want, but it seems much less likely to break.

			regards, tom lane



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


end of thread, other threads:[~2008-02-29 18:44 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-02-27 07:35 Array Char/VarChar Size dmp <danap@ttc-cmc.net>
2008-02-29 16:59 ` Kris Jurka <books@ejurka.com>
2008-02-29 17:32 ` dmp <danap@ttc-cmc.net>
2008-02-29 17:53   ` Kris Jurka <books@ejurka.com>
2008-02-29 18:44     ` 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