From: Robert Haas Date: Wed, 25 Jul 2012 13:59:03 +0000 (-0400) Subject: More debugging code. X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=9fd09de2924db54e24e256b3d9daddd6cbca16ee;p=users%2Fandresfreund%2Fpostgres.git More debugging code. --- diff --git a/contrib/hashtest/hashtest.c b/contrib/hashtest/hashtest.c index 45aa75a2b7..baa60493d3 100644 --- a/contrib/hashtest/hashtest.c +++ b/contrib/hashtest/hashtest.c @@ -68,14 +68,47 @@ Datum test_chash(PG_FUNCTION_ARGS) { hentry e; - bool found; + bool ok; e.key = 1; - found = CHashSearch(chash, &e); - if (found) - elog(LOG, "found"); + e.val = 0; + ok = CHashSearch(chash, &e); + if (ok) + elog(LOG, "search 1: found (value = %d)", e.val); else - elog(LOG, "not found"); - + elog(LOG, "search 1: not found"); + + e.key = 1; + e.val = 2; + ok = CHashInsert(chash, &e); + if (ok) + elog(LOG, "insert 1: done"); + else + elog(LOG, "insert 1: collision (value = %d)", e.val); + + e.key = 1; + e.val = 0; + ok = CHashSearch(chash, &e); + if (ok) + elog(LOG, "search 1: found (value = %d)", e.val); + else + elog(LOG, "search 1: not found"); + + e.key = 1; + e.val = 3; + ok = CHashInsert(chash, &e); + if (ok) + elog(LOG, "insert 1: done"); + else + elog(LOG, "insert 1: collision (value = %d)", e.val); + + e.key = 1; + e.val = 0; + ok = CHashSearch(chash, &e); + if (ok) + elog(LOG, "search 1: found (value = %d)", e.val); + else + elog(LOG, "search 1: not found"); + PG_RETURN_VOID(); }