Re: unsafe use of hash_search(... HASH_ENTER ...)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: unsafe use of hash_search(... HASH_ENTER ...)
Date: 2005-05-29 04:25:22
Message-ID: 877.1117340722@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu> writes:
> In general, code snippet like this:

> if (hash_search(..., HASH_ENTER, ...) == NULL)
> action_except_elog__ERROR__;

> are considered unsafe if: (1) the allocation method of the target hash table
> could elog(ERROR) themselves and (2) the reaction to the failure of
> hash_search() is not elog(ERROR).

I've made some changes to hopefully prevent this type of thinko again.
Thanks for spotting it.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Oleg Bartunov 2005-05-29 06:26:09 Re: Bloom Filter indexes?
Previous Message Bruce Momjian 2005-05-29 03:58:01 Escape handling in COPY, strings, psql