Re: contrib/pg_freespacemap first check input argument, then relation_open.

Поиск
Список
Период
Сортировка
От Julien Rouhaud
Тема Re: contrib/pg_freespacemap first check input argument, then relation_open.
Дата
Msg-id 20230706030933.mr4jt45d6m3yet3d@jrouhaud
обсуждение исходный текст
Ответ на contrib/pg_freespacemap first check input argument, then relation_open.  (jian he <jian.universality@gmail.com>)
Список pgsql-hackers
Hi,

On Thu, Jul 06, 2023 at 10:14:46AM +0800, jian he wrote:
>
> In:
> https://git.postgresql.org/cgit/postgresql.git/tree/contrib/pg_freespacemap/pg_freespacemap.c
>
> rel = relation_open(relid, AccessShareLock);
>
> if (blkno < 0 || blkno > MaxBlockNumber)
> ereport(ERROR,
> (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
> errmsg("invalid block number")));
>
> --------------------
> should it first check input arguments, then relation_open?

It would probably be a slightly better approach but wouldn't really change much
in practice so I'm not sure it's worth changing now.

> Does ereport automatically unlock the relation?

Yes, locks, lwlocks, memory contexts and everything else is properly cleaned /
released in case of error.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: test_extensions: fix inconsistency between meson.build and Makefile
Следующее
От: Nathan Bossart
Дата:
Сообщение: Re: Should we remove db_user_namespace?