array type name mangling

Lists: pgsql-hackers
From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: array type name mangling
Date: 2007-05-05 14:58:19
Message-ID: 463C9B8B.9050805@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

In connection with completing David Fetter's array of composites patch,
I am looking at doing some better name mangling for array types as
recently discussed. What I'm thinking of is prepending one or more
underscores to the type name up to some limit (NAMEDATALEN / 2 ?) and if
necessary truncating the result, and then looking to see if there is a
name clash. That would, I hope, enable us to get rid of all the places
where we require names to be no more than NAMEDATALEN - 2 chars. Does
that seem like a reasonable approach? Will it break anything, i.e., is
there somewhere that has assumes the array type for foo will be called
_foo rather than ___foo ?

cheers

andrew


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: array type name mangling
Date: 2007-05-05 15:08:10
Message-ID: 463C9DDA.8040502@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I wrote:
>
> In connection with completing David Fetter's array of composites
> patch, I am looking at doing some better name mangling for array types
> as recently discussed. What I'm thinking of is prepending one or more
> underscores to the type name up to some limit (NAMEDATALEN / 2 ?) and
> if necessary truncating the result, and then looking to see if there
> is a name clash. That would, I hope, enable us to get rid of all the
> places where we require names to be no more than NAMEDATALEN - 2
> chars. Does that seem like a reasonable approach? Will it break
> anything, i.e., is there somewhere that has assumes the array type for
> foo will be called _foo rather than ___foo ?

Actually, looking back in the email history I see Tom suggested this,
which I'll try instead:

> prepend _, truncate to less than 64 bytes if necessary,
> then substitute numbers at the end if needed to get something unique.

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: array type name mangling
Date: 2007-05-05 15:13:33
Message-ID: 19607.1178378013@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> In connection with completing David Fetter's array of composites patch,
> I am looking at doing some better name mangling for array types as
> recently discussed. What I'm thinking of is prepending one or more
> underscores to the type name up to some limit (NAMEDATALEN / 2 ?) and if
> necessary truncating the result, and then looking to see if there is a
> name clash. That would, I hope, enable us to get rid of all the places
> where we require names to be no more than NAMEDATALEN - 2 chars. Does
> that seem like a reasonable approach? Will it break anything, i.e., is
> there somewhere that has assumes the array type for foo will be called
> _foo rather than ___foo ?

makeArrayTypeName and users thereof. Or are you going to extend pg_type
to have a direct link?

regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: array type name mangling
Date: 2007-05-05 15:24:26
Message-ID: 463CA1AA.5040909@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>
>> In connection with completing David Fetter's array of composites patch,
>> I am looking at doing some better name mangling for array types as
>> recently discussed. What I'm thinking of is prepending one or more
>> underscores to the type name up to some limit (NAMEDATALEN / 2 ?) and if
>> necessary truncating the result, and then looking to see if there is a
>> name clash. That would, I hope, enable us to get rid of all the places
>> where we require names to be no more than NAMEDATALEN - 2 chars. Does
>> that seem like a reasonable approach? Will it break anything, i.e., is
>> there somewhere that has assumes the array type for foo will be called
>> _foo rather than ___foo ?
>>
>
> makeArrayTypeName and users thereof. Or are you going to extend pg_type
> to have a direct link?
>
>
>

I am going to change makeArrayTypeName() to do the mangling. Its users
will need to pass in a namespace as well as a typename so it can do the
checking.

There's a direct link via typelem - do you think we need a reverse mapping?

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: array type name mangling
Date: 2007-05-05 18:39:25
Message-ID: 25598.1178390365@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> Tom Lane wrote:
>> makeArrayTypeName and users thereof. Or are you going to extend pg_type
>> to have a direct link?

> I am going to change makeArrayTypeName() to do the mangling. Its users
> will need to pass in a namespace as well as a typename so it can do the
> checking.

You missed the point: there is a need to find the array type associated
with an existing element type, not only the other way round. See
LookupTypeName() and get_array_type().

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: array type name mangling
Date: 2007-05-05 18:51:47
Message-ID: 26542.1178391107@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> Actually, looking back in the email history I see Tom suggested this,
> which I'll try instead:

>> prepend _, truncate to less than 64 bytes if necessary,
>> then substitute numbers at the end if needed to get something unique.

Your idea of multiple underscores seems just as reasonable, maybe more
so. Either way, remember that the truncation needs to be
multibyte-aware.

regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: array type name mangling
Date: 2007-05-05 19:05:16
Message-ID: 463CD56C.8090707@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>
>> Tom Lane wrote:
>>
>>> makeArrayTypeName and users thereof. Or are you going to extend pg_type
>>> to have a direct link?
>>>
>
>
>> I am going to change makeArrayTypeName() to do the mangling. Its users
>> will need to pass in a namespace as well as a typename so it can do the
>> checking.
>>
>
> You missed the point: there is a need to find the array type associated
> with an existing element type, not only the other way round. See
> LookupTypeName() and get_array_type().
>
>
>

OK, in that case I think we should extend pg_type with a direct link,
don't you?

cheers

andrew