More debugging code.
authorRobert Haas <[email protected]>
Wed, 25 Jul 2012 13:59:03 +0000 (09:59 -0400)
committerRobert Haas <[email protected]>
Wed, 25 Jul 2012 13:59:03 +0000 (09:59 -0400)
contrib/hashtest/hashtest.c

index 45aa75a2b74663df6e210cb14ccef2b304a52b2f..baa60493d3ff1004106153142d983af2051d839d 100644 (file)
@@ -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();
 }