Re: Is _<typename> a supported way to create a column of array type?

From: Piotr Findeisen <piotr(dot)findeisen(at)starburstdata(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Is _<typename> a supported way to create a column of array type?
Date: 2019-04-25 21:17:00
Message-ID: CAMrFzbtAzyrQy0CSj8T1tCTJvFQKJ1ZYm2bJpRcFBqns4Tz5Vg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Tom,

Thanks for your response.

I think I need to provide some context for my question.
I am maintaining Presto connector to Postgres (
https://github.com/prestosql/presto/tree/master/presto-postgresql).

When accessing a table in Postgres, we need to map columns' types to
appropriate types in Presto.
For mapping arrays, we need to know number of array dimensions.
Currently we read this from pg_attribute.attndims and this does not work
for _<type> columns.

1. is there a better way to get array dimensions for a column of array type?
2. is it possible to make pg_attribute.attndims have correct value when
column is defined using _<type> form?

Best,
Piotr

On Thu, Apr 25, 2019 at 11:03 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Piotr Findeisen <piotr(dot)findeisen(at)starburstdata(dot)com> writes:
> > Internally, array types get a name in the form of `_<typename>`.
>
> Typically, yes.
>
> > *Can a user use `_<typename>` to define a column of array type?*
>
> Sure ... didn't you try it?
>
> > *Is it supported?*
>
> Not really, because it's not guaranteed that the name looks like that.
> There are various corner cases where something else would be generated,
> either to avoid a collision, or because truncation is needed.
>
> However, if you've taken the trouble to check what name actually got
> assigned to the array type, it's perfectly valid to use that name.
>
> > The reason I am asking is that e.g. int4[] and _int4 behave differently.
> > Although they look the same, the have different pg_attribute.attndims.
>
> Yeah. Nothing really cares about attndims though ... it's vestigial.
> Perhaps we should remove it someday.
>
> regards, tom lane
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2019-04-25 21:36:13 Re: Is _<typename> a supported way to create a column of array type?
Previous Message Tom Lane 2019-04-25 21:03:43 Re: Is _<typename> a supported way to create a column of array type?