using __func__ to locate and distinguish some error messages

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: using __func__ to locate and distinguish some error messages
Date: 2024-06-07 08:22:10
Message-ID: CACJufxHZmDeCSqdU745Vs954kD3ujrYHgon_6yCmdsp6AnwVSA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi.

we have 450 appearance of
`cache lookup failed .*`

we have 141 appearance of
`could not open file .*`

so when it actually happens, it cannot quickly locate which function
where the error has happened.
maybe under certain conditions (e.g. certain build type or certain
log_min_messages),
we can also print out the function name by using gcc __func__.

or we can just do like:
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u %s",
RelationGetRelid(rel), __func__);

given that these errors are very unlikely to happen, if it happens,
printing out the function name seems not that inversive?

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2024-06-07 08:27:49 Re: use CREATE DATABASE STRATEGY = FILE_COPY in pg_upgrade
Previous Message Ryo Matsumura (Fujitsu) 2024-06-07 08:09:03 Re: Bug: PGTYPEStimestamp_from_asc() in ECPG pgtypelib