Multidimensional array definition in composite type appears parsed as string

From: miller_2555 <nabble(dot)30(dot)miller_2555(at)spamgourmet(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Multidimensional array definition in composite type appears parsed as string
Date: 2009-05-27 19:19:41
Message-ID: 23749072.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hi -

I am trying to declare an array of the following compound type:
CREATE TYPE myschema.mytype AS (
sometext text,
onedimarray text[],
multidimarray text[][]
);

The current assignment occurs as follows:
myvar myschema.mytype[] := ARRAY[

ROW('textaa',ARRAY['textab'],ARRAY[ARRAY['textac1','textac2']])::myschema.mytype,

ROW('textba',ARRAY['textbb'],ARRAY[ARRAY['textbc1','textbc2']])::myschema.mytype
];

However, each multidimarray in the assignment appears as a string on the
output from the following statement (declared within a pgSQL function):
statement: RAISE INFO '%',myvar;
outputt: INFO:
{"(textaa,{textab},\"{{textac1,textac2}}\")","(textba,{textbb},\"{{textbc1,textbc2}}\")"}

I believe that I would have expected the following output from the RAISE
INFO statement:
INFO:
{"(textaa,{textab},{{textac1,textac2}})","(textba,{textbb},{{textbc1,textbc2}})"}

I have attempted different explicit typecasts and syntax and have also tried
adding additional elements to the arrays to see if a one-element array was
the cause. So far, I have not been able to access the multidimensional array
in the composite type as an array (though I can perform string functions).
No issues were noted with the one-dimensional array. I would like to retain
a clean definition of the assignment as this variable provides a single
place for programmers to define meta-data used in subsequent dynamic SQL
calls.

Subsequent code attempts to access the multidimensional array elements using
(i,j, and k are iterators):
(myvar[i]).multidimarray[j][k];

How should I amend the assignment syntax so that subsequent code will
recognize the multidimensional arrays?

Thanks for the help.
--
View this message in context: http://www.nabble.com/Multidimensional-array-definition-in-composite-type-appears-parsed-as-string-tp23749072p23749072.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-05-27 19:28:11 Re: Bloated Table
Previous Message Alan McKay 2009-05-27 19:13:28 Re: Postgres Clustering