From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | miller_2555 <nabble(dot)30(dot)miller_2555(at)spamgourmet(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Multidimensional array definition in composite type appears parsed as string |
Date: | 2009-05-27 20:18:39 |
Message-ID: | 16296.1243455519@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
miller_2555 <nabble(dot)30(dot)miller_2555(at)spamgourmet(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-05-27 20:21:59 | Re: Bloated Table |
Previous Message | Alvaro Herrera | 2009-05-27 20:02:26 | Re: Bloated Table |