From: | Julien Rouhaud <rjuju123(at)gmail(dot)com> |
---|---|
To: | jian he <jian(dot)universality(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: contrib/pg_freespacemap first check input argument, then relation_open. |
Date: | 2023-07-06 03:09:33 |
Message-ID: | 20230706030933.mr4jt45d6m3yet3d@jrouhaud |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Nathan Bossart | 2023-07-06 03:49:26 | Re: Should we remove db_user_namespace? |
Previous Message | Michael Paquier | 2023-07-06 02:41:02 | Re: test_extensions: fix inconsistency between meson.build and Makefile |