Re: Postgres do not allow to create many tables with more than 63-symbols prefix

From: Andrey Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, d(dot)koval(at)postgrespro(dot)ru
Subject: Re: Postgres do not allow to create many tables with more than 63-symbols prefix
Date: 2022-06-27 02:57:29
Message-ID: 9de21b26-64dd-d2a9-0dc5-99452a882a79@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 6/27/22 06:38, Masahiko Sawada wrote:
> On Fri, Jun 24, 2022 at 2:12 PM Andrey Lepikhov
> <a(dot)lepikhov(at)postgrespro(dot)ru> wrote:
>> On 6/23/22 07:03, Masahiko Sawada wrote:
>> > On Sat, Jun 4, 2022 at 4:03 AM Andrey Lepikhov
>> > <a(dot)lepikhov(at)postgrespro(dot)ru> wrote:
>> >> It is very corner case, of course. But solution is easy and short. So,
>> >> why not to fix? - See the patch in attachment.
>> >
>> > While this seems to be a good improvement, I think it's not a bug.
>> > Probably we cannot backpatch it as it will end up having type names
>> > defined by different naming rules. I'd suggest discussing it on
>> > -hackers.
>> Done.
>
> Thank for updating the patch. Please register this item to the next CF
> if not yet.
Done [1].

>> > Regarding the patch, I think we can merge makeUniqueTypeName() to
>> > makeArrayTypeName() as there is no caller of makeUniqueTypeName() who
>> > pass tryOriginal = true.
>> I partially agree with you. But I have one reason to leave
>> makeUniqueTypeName() separated:
>> It may be used in other codes with auto generated types. For example, I
>> think, the DefineRelation routine should choose composite type instead
>> of using the same name as the table.
>
> Okay.
>
> I have one comment on v2 patch:
>
> + for(;;)
> {
> - dest[i - 1] = '_';
> - strlcpy(dest + i, typeName, NAMEDATALEN - i);
> - if (namelen + i >= NAMEDATALEN)
> - truncate_identifier(dest, NAMEDATALEN, false);
> -
> if (!SearchSysCacheExists2(TYPENAMENSP,
> - CStringGetDatum(dest),
> + CStringGetDatum(type_name),
> ObjectIdGetDatum(typeNamespace)))
> - return pstrdup(dest);
> + return type_name;
> +
> + /* Previous attempt was failed. Prepare a new one. */
> + pfree(type_name);
> + snprintf(suffix, sizeof(suffix), "%d", ++pass);
> + type_name = makeObjectName("", typeName, suffix);
> }
>
> return NULL;
>
> I think it's better to break from the loop instead of returning from
> there. That way, we won't need "return NULL".
Agree. Done.

[1] https://commitfest.postgresql.org/38/3712/

--
Regards
Andrey Lepikhov
Postgres Professional

Attachment Content-Type Size
v3-0001-Allow-postgresql-to-generate-more-relations-with-the.patch text/x-patch 3.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Shinoda, Noriyoshi (PN Japan FSIP) 2022-06-27 03:49:20 RE: PG15 beta1 fix pg_stats_ext/pg_stats_ext_exprs view manual
Previous Message Masahiko Sawada 2022-06-27 01:38:50 Re: Postgres do not allow to create many tables with more than 63-symbols prefix