PostGIS  2.1.10dev-r@@SVN_REVISION@@
postgis_module.c
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * PostGIS - Spatial Types for PostgreSQL
4  * http://postgis.net
5  *
6  * Copyright (C) 2011 OpenGeo.org
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU General Public Licence. See the COPYING file.
10  *
11  **********************************************************************/
12 
13 #include "postgres.h"
14 #include "fmgr.h"
15 #include "utils/elog.h"
16 #include "utils/guc.h"
17 #include "libpq/pqsignal.h"
18 
19 #include "../postgis_config.h"
20 
21 #include "lwgeom_log.h"
22 #include "lwgeom_pg.h"
23 #include "geos_c.h"
24 #include "lwgeom_backend_api.h"
25 
26 /*
27  * This is required for builds against pgsql
28  */
30 
31 static pqsigfunc coreIntHandler = 0;
32 static void handleInterrupt(int sig);
33 
34 #ifdef WIN32
35 #if POSTGIS_GEOS_VERSION >= 34
36 static void geosInterruptCallback() {
37  if (UNBLOCKED_SIGNAL_QUEUE())
38  pgwin32_dispatch_queued_signals();
39 }
40 #endif
41 #endif
42 
43 /*
44  * Module load callback
45  */
46 void _PG_init(void);
47 void
48 _PG_init(void)
49 {
50 
51  coreIntHandler = pqsignal(SIGINT, handleInterrupt);
52 
53 #ifdef WIN32
54 #if POSTGIS_GEOS_VERSION >= 34
55  GEOS_interruptRegisterCallback(geosInterruptCallback);
56 #endif
57 #endif
58 
59 #if 0
60  /* Define custom GUC variables. */
61  DefineCustomIntVariable(
62  "postgis.debug.level", /* name */
63  "Sets the debugging level of PostGIS.", /* short_desc */
64  "This is an experimental configuration.", /* long_desc */
65  &postgis_debug_level, /* valueAddr */
66  0, 8, /* min-max */
67  0, /* bootValue */
68  PGC_SUSET, /* GucContext context */
69  GUC_UNIT_MS, /* int flags */
70 #if POSTGIS_PGSQL_VERSION >= 91
71  NULL, /* GucStringCheckHook check_hook */
72 #endif
73  NULL, /* GucStringAssignHook assign_hook */
74  NULL /* GucShowHook show_hook */
75  );
76 #endif
77 
78 #if 0
79  /* Define custom GUC variables. */
80  DefineCustomStringVariable(
81  "postgis.greeting.string", /* name */
82  "Sets the greeting string used on postgis module load.", /* short_desc */
83  "This is an experimental configuration.", /* long_desc */
84  &greeting, /* valueAddr */
85  "Welcome to PostGIS " POSTGIS_VERSION, /* bootValue */
86  PGC_SUSET, /* GucContext context */
87  GUC_UNIT_MS, /* int flags */
88 #if POSTGIS_PGSQL_VERSION >= 91
89  NULL, /* GucStringCheckHook check_hook */
90 #endif
91  NULL, /* GucStringAssignHook assign_hook */
92  NULL /* GucShowHook show_hook */
93  );
94 #endif
95 
96  /* install PostgreSQL handlers */
97  pg_install_lwgeom_handlers();
98 
99  /* initialize geometry backend */
101 }
102 
103 /*
104  * Module unload callback
105  */
106 void _PG_fini(void);
107 void
108 _PG_fini(void)
109 {
110  elog(NOTICE, "Goodbye from PostGIS %s", POSTGIS_VERSION);
111 }
112 
113 
114 static void
116 {
117  /* NOTE: printf here would be dangerous, see
118  * https://trac.osgeo.org/postgis/ticket/3644
119  *
120  * TODO: block interrupts during execution, to fix the problem
121  */
122  /* printf("Interrupt requested\n"); fflush(stdout); */
123 
124 #if POSTGIS_GEOS_VERSION >= 34
125  GEOS_interruptRequest();
126 #endif
127 
128  /* TODO: request interruption of liblwgeom as well ? */
129 
130  if ( coreIntHandler ) {
131  (*coreIntHandler)(sig);
132  }
133 }
static pqsigfunc coreIntHandler
void _PG_fini(void)
void lwgeom_init_backend()
#define POSTGIS_PGSQL_VERSION
Definition: sqldefines.h:9
void _PG_init(void)
PG_MODULE_MAGIC
static void handleInterrupt(int sig)