From: | Jeff Davis <pgsql(at)j-davis(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | inconsistent use of SearchSysCacheCopy |
Date: | 2024-12-07 00:31:11 |
Message-ID: | 8f8d06fbf986437b1526c6ac68a27165cf4deea3.camel@j-davis.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
When modifying catalog contents, some callers use SearchSysCacheN() and
some use SearchSysCacheCopyN().
for instance, these callers use SearchSysCacheN():
- AggregateCreate()
- ProcedureCreate()
while these callers that use SearchSysCacheCopyN():
- OperatorCreate()
- TypeCreate()
I generally thought that the non-copy variant was preferred if you are
using heap_modify_tuple() or similar, and the latter used when
necessary (e.g. modifying through the Form_pg_foo pointer). Aside from
avoiding a needless copy, the non-copy variant is also a bit safer
because you'll get a WARNING if you forget to ReleaseSysCache().
On the other hand, if you don't use the copy variant, and you actually
do modify it, that would be quite dangerous; so perhaps that's why the
copy variants are used in so many places where it seems unnecessary.
Is there a preferred convention?
Regards,
Jeff Davis
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Davis | 2024-12-07 00:44:10 | Re: Statistics Import and Export |
Previous Message | Nathan Bossart | 2024-12-06 20:12:51 | Re: Remove dependence on integer wrapping |