miller_2555 <nabble.30.miller_2555@spamgourmet.com> writes:
> 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
> ];
Looks okay so far ...
> 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}})"}
No, you're wrong --- that output is perfectly correct. The
multidimarray value contains a comma, and therefore it needs to be
double-quoted according to the rules for composite type I/O. The 1-dim
array value would have gotten quoted, too, had it contained more than
one element.
> 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).
It sounds like you are using some code that mistakenly thinks that
double quotes have a semantic meaning here. They do not. They are just
there to delimit members of the row value, not to tell you what type the
members are.
regards, tom lane