60
60
#error Expecting timestamps to be represented as integers, not as floating-point.
61
61
#endif
62
62
63
- #ifdef USE_POSTGIS
64
- /* POSTGIS version define so it doesn't redef macros */
65
- #define POSTGIS_PGSQL_VERSION 94
66
- #include "liblwgeom.h"
67
- #endif
68
-
69
63
PG_MODULE_MAGIC ;
70
64
71
65
/* define a time macro to convert TimestampTz into something more sane,
@@ -80,10 +74,6 @@ typedef struct {
80
74
bool debug_mode ;
81
75
} DecoderData ;
82
76
83
- /* GLOBALs for PostGIS dynamic OIDs */
84
- Oid geometry_oid = InvalidOid ;
85
- Oid geography_oid = InvalidOid ;
86
-
87
77
/* these must be available to pg_dlsym() */
88
78
extern void _PG_init (void );
89
79
extern void _PG_output_plugin_init (OutputPluginCallbacks * cb );
@@ -177,22 +167,6 @@ static void pg_decode_shutdown(LogicalDecodingContext *ctx) {
177
167
/* BEGIN callback */
178
168
static void pg_decode_begin_txn (LogicalDecodingContext * ctx ,
179
169
ReorderBufferTXN * txn ) {
180
- #ifdef USE_POSTGIS
181
- // set PostGIS geometry type id (these are dynamic)
182
- // TODO: Figure out how to make sure we get the typid's from postgis extension namespace
183
- if (geometry_oid == InvalidOid ) {
184
- geometry_oid = TypenameGetTypid ("geometry" );
185
- if (geometry_oid != InvalidOid ) {
186
- elog (DEBUG1 , "PostGIS geometry type detected: %u" , geometry_oid );
187
- }
188
- }
189
- if (geography_oid == InvalidOid ) {
190
- geography_oid = TypenameGetTypid ("geography" );
191
- if (geography_oid != InvalidOid ) {
192
- elog (DEBUG1 , "PostGIS geometry type detected: %u" , geography_oid );
193
- }
194
- }
195
- #endif
196
170
}
197
171
198
172
/* COMMIT callback */
@@ -280,42 +254,6 @@ static void print_row_msg(StringInfo out, Decoderbufs__RowMessage *rmsg) {
280
254
281
255
}
282
256
283
- static bool geography_point_as_decoderbufs_point (Datum datum ,
284
- Decoderbufs__Point * p ) {
285
- #ifdef USE_POSTGIS
286
- GSERIALIZED * geom ;
287
- LWGEOM * lwgeom ;
288
- LWPOINT * point = NULL ;
289
- POINT2D p2d ;
290
-
291
- geom = (GSERIALIZED * )PG_DETOAST_DATUM (datum );
292
- if (gserialized_get_type (geom ) != POINTTYPE ) {
293
- return false;
294
- }
295
-
296
- lwgeom = lwgeom_from_gserialized (geom );
297
- point = lwgeom_as_lwpoint (lwgeom );
298
- if (lwgeom_is_empty (lwgeom )) {
299
- return false;
300
- }
301
-
302
- getPoint2d_p (point -> point , 0 , & p2d );
303
-
304
- if (p != NULL ) {
305
- Decoderbufs__Point dp = DECODERBUFS__POINT__INIT ;
306
- dp .x = p2d .x ;
307
- dp .y = p2d .y ;
308
- memcpy (p , & dp , sizeof (dp ));
309
- elog (DEBUG1 , "Translating geography to point: (x,y) = (%f,%f)" , p -> x , p -> y );
310
- }
311
-
312
- return true;
313
- #else
314
- elog (DEBUG1 , "PostGIS support is off, recompile decoderbufs with USE_POSTGIS option!" );
315
- return false;
316
- #endif
317
- }
318
-
319
257
/* set a datum value based on its OID specified by typid */
320
258
static void set_datum_value (Decoderbufs__DatumMessage * datum_msg , Oid typid ,
321
259
Oid typoutput , Datum datum ) {
@@ -435,13 +373,7 @@ static void set_datum_value(Decoderbufs__DatumMessage *datum_msg, Oid typid,
435
373
datum_msg -> datum_case = DECODERBUFS__DATUM_MESSAGE__DATUM_DATUM_POINT ;
436
374
break ;
437
375
default :
438
- // PostGIS uses dynamic OIDs so we need to check the type again here
439
- if (typid == geometry_oid || typid == geography_oid ) {
440
- elog (DEBUG1 , "Converting geography point to datum_point" );
441
- datum_msg -> datum_point = palloc (sizeof (Decoderbufs__Point ));
442
- geography_point_as_decoderbufs_point (datum , datum_msg -> datum_point );
443
- datum_msg -> datum_case = DECODERBUFS__DATUM_MESSAGE__DATUM_DATUM_POINT ;
444
- } else {
376
+ {
445
377
int len ;
446
378
elog (DEBUG1 , "Encountered unknown typid: %d, using bytes" , typid );
447
379
output = OidOutputFunctionCall (typoutput , datum );
0 commit comments