]> granicus.if.org Git - postgis/commitdiff
Put PostgreSQL module related code in a new postgis_module.c file
authorSandro Santilli <strk@keybit.net>
Wed, 21 Dec 2011 14:03:47 +0000 (14:03 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 21 Dec 2011 14:03:47 +0000 (14:03 +0000)
Beside the existing MODULE_MAGIC macro we now also have
_PG_init and _PG_fini which are called at module load and unload.
Such functions may be used to deal with GUC (and sample code for
that is stubbed already). See #1393.

git-svn-id: http://svn.osgeo.org/postgis/trunk@8486 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/Makefile.in
postgis/lwgeom_functions_basic.c
postgis/postgis_module.c [new file with mode: 0644]

index 951e5f6555f21a90f9b3661a6f549a41f758c7c4..f70fa49ca839c22841b4e19fd1b805d3620af71c 100644 (file)
@@ -22,6 +22,7 @@ SQL_OBJS=postgis.sql.in uninstall_postgis.sql.in legacy.sql.in uninstall_legacy.
 
 # PostgreSQL objects
 PG_OBJS=lwgeom_debug.o \
+       postgis_module.o \
        lwgeom_accum.o \
        lwgeom_spheroid.o \
        lwgeom_ogc.o \
index 30e7c6804532142104024f636bd95d735e02ec91..68ae03e7ce17c8d163e3865fce28ef9b8758f25a 100644 (file)
 #include <stdio.h>
 #include <errno.h>
 
-/*
- * This is required for builds against pgsql
- */
-PG_MODULE_MAGIC;
-
 Datum LWGEOM_mem_size(PG_FUNCTION_ARGS);
 Datum LWGEOM_summary(PG_FUNCTION_ARGS);
 Datum LWGEOM_npoints(PG_FUNCTION_ARGS);
diff --git a/postgis/postgis_module.c b/postgis/postgis_module.c
new file mode 100644 (file)
index 0000000..654b84b
--- /dev/null
@@ -0,0 +1,84 @@
+/**********************************************************************
+ *
+ * PostGIS - Spatial Types for PostgreSQL
+ * http://postgis.refractions.net
+ *
+ * Copyright (C) 2011  OpenGeo.org 
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public Licence. See the COPYING file.
+ *
+ **********************************************************************/
+
+#include "postgres.h"
+#include "fmgr.h"
+#include "utils/elog.h"
+#include "utils/guc.h"
+
+#include "lwgeom_log.h"
+#include "lwgeom_pg.h"
+#include "../postgis_config.h"
+
+/*
+ * This is required for builds against pgsql
+ */
+PG_MODULE_MAGIC;
+
+/*
+ * Module load callback
+ */
+void _PG_init(void);
+void
+_PG_init(void)
+{
+#if 0
+  /* Define custom GUC variables. */
+  DefineCustomIntVariable(
+    "postgis.debug.level", /* name */
+    "Sets the debugging level of PostGIS.", /* short_desc */
+    "This is an experimental configuration.", /* long_desc */
+    &postgis_debug_level, /* valueAddr */
+    0, 8, /* min-max */
+    0, /* bootValue */
+    PGC_SUSET, /* GucContext context */
+    GUC_UNIT_MS, /* int flags */
+#if POSTGIS_PGSQL_VERSION >= 91
+    NULL, /* GucStringCheckHook check_hook */
+#endif
+    NULL, /* GucStringAssignHook assign_hook */
+    NULL  /* GucShowHook show_hook */
+   );
+#endif
+
+#if 0
+  /* Define custom GUC variables. */
+  DefineCustomStringVariable(
+    "postgis.greeting.string", /* name */
+    "Sets the greeting string used on postgis module load.", /* short_desc */
+    "This is an experimental configuration.", /* long_desc */
+    &greeting, /* valueAddr */
+    "Welcome to PostGIS " POSTGIS_VERSION, /* bootValue */
+    PGC_SUSET, /* GucContext context */
+    GUC_UNIT_MS, /* int flags */
+#if POSTGIS_PGSQL_VERSION >= 91
+    NULL, /* GucStringCheckHook check_hook */
+#endif
+    NULL, /* GucStringAssignHook assign_hook */
+    NULL  /* GucShowHook show_hook */
+   );
+#endif
+
+}
+
+/*
+ * Module unload callback
+ */
+void _PG_fini(void);
+void
+_PG_fini(void)
+{
+  elog(NOTICE, "Goodbye from PostGIS %s", POSTGIS_VERSION);
+}
+
+
+