Lists: | pgsql-general |
---|
From: | Phil Couling <couling(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Why is cast array integer[] <--> text[] is not immutable. |
Date: | 2011-12-09 11:42:01 |
Message-ID: | CANWftz+7uGNBjO=FznkVvqsXObX4Y=otnBXRxM4z2ozuKrWN2Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Hi
I'm struggling to understand why this casts is not immutable:
integer[]::text[]
text[]::integer[]
The following are all immutable:
integer::text
text::integer
integer[]::float[]
integer::float
I hit on this while trying to make a gin index which cast from one to the other.
Why does the encapsulation of an array suddenly make this not immutable?
Thanks
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Phil Couling <couling(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Why is cast array integer[] <--> text[] is not immutable. |
Date: | 2011-12-09 15:09:58 |
Message-ID: | 27130.1323443398@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Phil Couling <couling(at)gmail(dot)com> writes:
> I'm struggling to understand why this casts is not immutable:
> integer[]::text[]
> text[]::integer[]
Because it's implemented via array_out/array_in rather than any more
direct method, and those are marked stable because they potentially
invoke non-immutable element I/O functions.
regards, tom lane
From: | Phil Couling <couling(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Why is cast array integer[] <--> text[] is not immutable. |
Date: | 2011-12-09 16:23:44 |
Message-ID: | CANWftzLLVJM=A55t8xZ6EpQucgfBGM4VrK-_WDYy0b77oMmfiA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Thanks
I'm having trouble finding any reference to array_out and array_in in
the documentation.
Is there a way to set a different cast for an array?
Regards
On 9 December 2011 15:09, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Phil Couling <couling(at)gmail(dot)com> writes:
>> I'm struggling to understand why this casts is not immutable:
>
>> integer[]::text[]
>> text[]::integer[]
>
> Because it's implemented via array_out/array_in rather than any more
> direct method, and those are marked stable because they potentially
> invoke non-immutable element I/O functions.
>
> regards, tom lane
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Phil Couling <couling(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Why is cast array integer[] <--> text[] is not immutable. |
Date: | 2011-12-09 17:05:57 |
Message-ID: | 1634.1323450357@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Phil Couling <couling(at)gmail(dot)com> writes:
> Is there a way to set a different cast for an array?
I think it should work to declare a cast explicitly for the particular
case.
regards, tom lane