Re: fix a bogus line in dynahash.c - Mailing list pgsql-patches

From Tom Lane
Subject Re: fix a bogus line in dynahash.c
Date
Msg-id 7639.1116989955@sss.pgh.pa.us
Whole thread Raw
In response to fix a bogus line in dynahash.c  ("Qingqing Zhou" <zhouqq@cs.toronto.edu>)
Responses Re: fix a bogus line in dynahash.c
List pgsql-patches
"Qingqing Zhou" <zhouqq@cs.toronto.edu> writes:
> Change elog(ERROR) to Assert(false) for two reasons:

No.  Remember that in most installations Assert() is a no-op.

> (2) even if it could happen, elog(ERROR) won't save us since in many places
> we have to check the return code of hash_search() and decide the error
> level.

You do know that elog(ERROR) doesn't return control to the caller?

> On a separate matter, can anyone please explain me how this piece of code
> works:

>     /* no free elements.  allocate another chunk of buckets */
>     if (!element_alloc(hashp, HASHELEMENT_ALLOC_INCR))
>      return NULL; /* out of memory */

That test is a no-op in the case where hashp->alloc in fact points to
palloc.  But it doesn't always point there --- see shmem_alloc.

            regards, tom lane

pgsql-patches by date:

Previous
From: Neil Conway
Date:
Subject: Re: fix a bogus line in dynahash.c
Next
From: Neil Conway
Date:
Subject: Re: fix a bogus line in dynahash.c