AS 'MODULE_PATHNAME', 'chash_delete_test'
LANGUAGE C;
+CREATE FUNCTION chash_concurrent_test()
+RETURNS void
+AS 'MODULE_PATHNAME', 'chash_concurrent_test'
+LANGUAGE C;
+
CREATE FUNCTION dynahash_insert_test()
RETURNS void
AS 'MODULE_PATHNAME', 'dynahash_insert_test'
Datum chash_insert_test(PG_FUNCTION_ARGS);
Datum chash_search_test(PG_FUNCTION_ARGS);
Datum chash_delete_test(PG_FUNCTION_ARGS);
+Datum chash_concurrent_test(PG_FUNCTION_ARGS);
Datum dynahash_insert_test(PG_FUNCTION_ARGS);
Datum dynahash_search_test(PG_FUNCTION_ARGS);
Datum dynahash_delete_test(PG_FUNCTION_ARGS);
PG_RETURN_VOID();
}
+Datum
+chash_concurrent_test(PG_FUNCTION_ARGS)
+{
+ uint32 i;
+ hentry e;
+ uint32 seed = MyProcPid << 16;
+
+ for (i = 0; i < 10000; ++i)
+ {
+ bool ok;
+
+ e.key = seed | i;
+ e.val = MyProcPid;
+ ok = CHashInsert(chash, &e);
+ if (!ok)
+ elog(LOG, "insert %u: found", i);
+ }
+
+ for (i = 0; i < 10000; ++i)
+ {
+ bool ok;
+
+ e.key = seed | i;
+ e.val = 0;
+ ok = CHashSearch(chash, &e);
+ if (!ok)
+ elog(LOG, "search %u: not found", i);
+ if (e.val != MyProcPid)
+ elog(LOG, "search %u: expected %u found %u", i, (unsigned) MyProcPid, e.val);
+ }
+
+ for (i = 0; i < 10000; ++i)
+ {
+ bool ok;
+
+ e.key = seed | i;
+ ok = CHashDelete(chash, &e);
+ if (!ok)
+ elog(LOG, "delete %u: not found", i);
+ }
+
+ PG_RETURN_VOID();
+}
+
static bool
dynahash_insert(uint32 key, uint32 val)
{