From b54356fff2177ffa39a0b367c6f7a357477c2690 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Wed, 25 Jul 2012 09:59:03 -0400 Subject: [PATCH] More debugging code. --- contrib/hashtest/hashtest.c | 45 ++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) 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(); } -- 2.39.5