--- /dev/null
+# contrib/test_sballoc/Makefile
+
+MODULES = test_sballoc
+
+EXTENSION = test_sballoc
+DATA = test_sballoc--1.0.sql
+
+ifdef USE_PGXS
+PG_CONFIG = pg_config
+PGXS := $(shell $(PG_CONFIG) --pgxs)
+include $(PGXS)
+else
+subdir = contrib/test_sballoc
+top_builddir = ../..
+include $(top_builddir)/src/Makefile.global
+include $(top_srcdir)/contrib/contrib-global.mk
+endif
--- /dev/null
+/* contrib/test_sballoc/test_sballoc--1.0.sql */
+
+-- complain if script is sourced in psql, rather than via CREATE EXTENSION
+\echo Use "CREATE EXTENSION test_sballoc" to load this file. \quit
+
+CREATE FUNCTION alloc(size pg_catalog.int8, count pg_catalog.int8)
+ RETURNS pg_catalog.void
+ AS 'MODULE_PATHNAME' LANGUAGE C STRICT;
--- /dev/null
+/*--------------------------------------------------------------------------
+ *
+ * test_sballoc.c
+ * Test harness code for superblock allocator.
+ *
+ * Copyright (C) 2013, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * contrib/test_sballoc/test_sballoc.c
+ *
+ * -------------------------------------------------------------------------
+ */
+
+#include "postgres.h"
+
+#include "fmgr.h"
+#include "utils/sb_alloc.h"
+
+PG_MODULE_MAGIC;
+PG_FUNCTION_INFO_V1(alloc);
+
+Datum alloc(PG_FUNCTION_ARGS);
+
+Datum
+alloc(PG_FUNCTION_ARGS)
+{
+ int64 size = PG_GETARG_INT64(0);
+ int64 count = PG_GETARG_INT64(0);
+ int64 i;
+ sb_allocator *a;
+
+ a = sb_create_private_allocator();
+ for (i = 0; i < count; ++i)
+ (void) sb_alloc(a, size, 0);
+
+ PG_RETURN_VOID();
+}
--- /dev/null
+comment = 'Test code for shared memory message queues'
+default_version = '1.0'
+module_pathname = '$libdir/test_sballoc'
+relocatable = true