diff --git a/src/test/modules/foo/Makefile b/src/test/modules/foo/Makefile new file mode 100644 index 0000000..da13e65 --- /dev/null +++ b/src/test/modules/foo/Makefile @@ -0,0 +1,18 @@ +# src/test/modules/foo/Makefile + +MODULES = foo + +EXTENSION = foo +DATA = foo--1.0.sql +PGFILEDESC = "foo -- a random testing/hacking extension" + +ifdef USE_PGXS +PG_CONFIG = pg_config +PGXS := $(shell $(PG_CONFIG) --pgxs) +include $(PGXS) +else +subdir = src/test/modules/foo +top_builddir = ../../../.. +include $(top_builddir)/src/Makefile.global +include $(top_srcdir)/contrib/contrib-global.mk +endif diff --git a/src/test/modules/foo/foo--1.0.sql b/src/test/modules/foo/foo--1.0.sql new file mode 100644 index 0000000..bc12ebd --- /dev/null +++ b/src/test/modules/foo/foo--1.0.sql @@ -0,0 +1,8 @@ +\echo Use "CREATE EXTENSION foo" to load this file. \quit + +CREATE FUNCTION test_dsm(size bigint) +RETURNS void +AS 'MODULE_PATHNAME' +LANGUAGE C; + + diff --git a/src/test/modules/foo/foo.c b/src/test/modules/foo/foo.c new file mode 100644 index 0000000..6c3ebad --- /dev/null +++ b/src/test/modules/foo/foo.c @@ -0,0 +1,25 @@ +#include "postgres.h" + +#include "fmgr.h" +#include "funcapi.h" +#include "miscadmin.h" +#include "storage/dsm.h" +#include "utils/builtins.h" + +PG_MODULE_MAGIC; + +PG_FUNCTION_INFO_V1(test_dsm); + +Datum +test_dsm(PG_FUNCTION_ARGS) +{ + size_t size = PG_GETARG_INT64(0); + void *data; + + dsm_segment *segment = dsm_create(size, 0); + data = dsm_segment_address(segment); + memset(data, 0, size); + dsm_detach(segment); + + PG_RETURN_VOID(); +} diff --git a/src/test/modules/foo/foo.control b/src/test/modules/foo/foo.control new file mode 100644 index 0000000..af1b50a --- /dev/null +++ b/src/test/modules/foo/foo.control @@ -0,0 +1,4 @@ +comment = 'foo' +default_version = '1.0' +module_pathname = '$libdir/foo' +relocatable = true