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();
}