Re: [PATCHES] fix a bogus line in dynahash.c

2005-05-24 Thread Qingqing Zhou
"Tom Lane" <[EMAIL PROTECTED]> writes > "Qingqing Zhou" <[EMAIL PROTECTED]> writes: > > No. Remember that in most installations Assert() is a no-op. > Well, I still suggest to change it :( The only chance elog(ERROR, "unrecognized hash action code") could be triggered is the *unbelievable* prog

Re: [PATCHES] fix a bogus line in dynahash.c

2005-05-24 Thread Tom Lane
Neil Conway <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> 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. > Perhaps it would be a net win to change ShmemAlloc() to elog(ERROR) on > out-of-memory? Possibly

Re: [PATCHES] fix a bogus line in dynahash.c

2005-05-24 Thread Neil Conway
Tom Lane wrote: 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. Perhaps it would be a net win to change ShmemAlloc() to elog(ERROR) on out-of-memory? A fair few of the ShmemAlloc() call sites don't bother to

Re: [PATCHES] fix a bogus line in dynahash.c

2005-05-24 Thread Qingqing Zhou
"Neil Conway" <[EMAIL PROTECTED]>writes > Well, element_alloc() uses the hash table's alloc function pointer. In > theory, that could be malloc() or anything else, although I notice this > abstraction is not consistently maintained (e.g. dir_realloc assumes > pfree() is sufficient to free an alloc

Re: [PATCHES] fix a bogus line in dynahash.c

2005-05-24 Thread Tom Lane
"Qingqing Zhou" <[EMAIL PROTECTED]> 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 de

Re: [PATCHES] fix a bogus line in dynahash.c

2005-05-24 Thread Neil Conway
Qingqing Zhou wrote: 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 */ element_alloc() in fact uses MemoryCo