Re: [patch] Adding an assertion to report too long hash table name

From: Zhang Mingli <zmlpostgres(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Xiaoran Wang <wxiaoran(at)vmware(dot)com>
Subject: Re: [patch] Adding an assertion to report too long hash table name
Date: 2022-11-07 09:04:18
Message-ID: 4a703191-faf3-4310-a636-c0fbd15c035a@Spark
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Sep 29, 2022, 09:38 +0800, Xiaoran Wang <wxiaoran(at)vmware(dot)com>, wrote:
> Hi,
> The max size for the shmem hash table name is SHMEM_INDEX_KEYSIZE - 1. but when the caller uses a longer hash table name, it doesn't report any error, insteadit just uses the first SHMEM_INDEX_KEYSIZE -1 chars as the hash table name.
> I created some shmem hash tables with the same prefix which was longer thanSHMEM_INDEX_KEYSIZE - 1, and the size of those hash tables were the same,then only one hash table was created. But I thought those hash tables were createdsuccessfully.
> I know this is a corner case, but it's difficult to figure it out when run into it. So I addan assertion to prevent it.
>
> Thanks,Xiaoran
Seems Postgres doesn’t have a case that strlen(name) >= SHMEM_INDEX_KEYSIZE(48).
The max length of name I found is 29:
```
ShmemInitHash("Shared Buffer Lookup Table”

```
But it will help for other Databases built on Postgres or later Postgres in case of forgetting to update SHMEM_INDEX_KEYSIZE
when new shmem added with a name longer than current SHMEM_INDEX_KEYSIZE.
And we don’t have such assertion now.
So, +1 for the patch.

Regards,
Zhang Mingli

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Aleksander Alekseev 2022-11-07 09:06:58 Re: Adding doubly linked list type which stores the number of items in the list
Previous Message Aleksander Alekseev 2022-11-07 09:03:23 [PATCH] Const'ify the arguments of ilist.c/ilist.h functions