Bas Couwenberg pushed to branch upstream at Debian GIS Project / pgsql-ogr-fdw


Commits:
09cbc603 by Bas Couwenberg at 2018-09-25T05:09:30Z
New upstream version 1.0.7
- - - - -


3 changed files:

- ogr_fdw.c
- ogr_fdw.h
- ogr_fdw_deparse.c


Changes:

=====================================
ogr_fdw.c
=====================================
@@ -192,15 +192,6 @@ ogrErrorHandler(CPLErr eErrClass, int err_no, const char 
*msg)
 void
 _PG_init(void)
 {
-       Oid typoid = TypenameGetTypid("geometry");
-       if (OidIsValid(typoid) && get_typisdefined(typoid))
-       {
-               GEOMETRYOID = typoid;
-       }
-       else
-       {
-               GEOMETRYOID = BYTEAOID;
-       }
 
        on_proc_exit(&ogr_fdw_exit, PointerGetDatum(NULL));
 
@@ -220,6 +211,25 @@ ogr_fdw_exit(int code, Datum arg)
        OGRCleanupAll();
 }
 
+/*
+ * Function to get the geometry OID if required
+ */
+Oid ogrGetGeometryOid(void)
+{
+       if (GEOMETRYOID == InvalidOid) {
+               Oid typoid = TypenameGetTypid("geometry");
+               if (OidIsValid(typoid) && get_typisdefined(typoid))
+               {
+                       GEOMETRYOID = typoid;
+               }
+               else
+               {
+                       GEOMETRYOID = BYTEAOID;
+               }
+       }
+
+       return GEOMETRYOID;
+}
 
 /*
  * Foreign-data wrapper handler function: return a struct with pointers
@@ -1175,7 +1185,7 @@ ogrReadColumnData(OgrFdwState *state)
 
                /* If the OGR source has geometries, can we match them to Pg 
columns? */
                /* We'll match to the first ones we find, irrespective of name 
*/
-               if ( geom_count < ogr_geom_count && col.pgtype == GEOMETRYOID )
+               if ( geom_count < ogr_geom_count && col.pgtype == 
ogrGetGeometryOid() )
                {
                        col.ogrvariant = OGR_GEOMETRY;
                        col.ogrfldtype = OFTBinary;
@@ -1256,7 +1266,7 @@ ogrLookupGeometryFunctionOid(const char *proname)
        FuncCandidateList clist;
 
        /* This only works if PostGIS is installed */
-       if ( GEOMETRYOID == InvalidOid || GEOMETRYOID == BYTEAOID )
+       if ( ogrGetGeometryOid() == InvalidOid || ogrGetGeometryOid() == 
BYTEAOID )
                return InvalidOid;
 
        names = stringToQualifiedNameList(proname);
@@ -1272,7 +1282,7 @@ ogrLookupGeometryFunctionOid(const char *proname)
                        int i;
                        for ( i = 0; i < clist->nargs; i++ )
                        {
-                               if ( clist->args[i] == GEOMETRYOID )
+                               if ( clist->args[i] == ogrGetGeometryOid() )
                                        return clist->oid;
                        }
                }
@@ -1485,7 +1495,7 @@ ogrFeatureToSlot(const OGRFeatureH feat, TupleTableSlot 
*slot, const OgrFdwExecS
                                nulls[i] = false;
                                values[i] = PointerGetDatum(varlena);
                        }
-                       else if ( pgtype == GEOMETRYOID )
+                       else if ( pgtype == ogrGetGeometryOid() )
                        {
                                /*
                                 * For geometry we need to convert the varlena 
WKB data into a serialized
@@ -2619,7 +2629,7 @@ ogrImportForeignSchema(ImportForeignSchemaStmt *stmt, Oid 
serverOid)
                                 quote_identifier(server->servername),
                                 launder_table_names,
                                 launder_column_names,
-                                GEOMETRYOID != BYTEAOID,
+                                ogrGetGeometryOid() != BYTEAOID,
                                 &buf
                              );
 


=====================================
ogr_fdw.h
=====================================
@@ -183,8 +183,6 @@ typedef struct OgrFdwModifyState
 /* Shared function signatures */
 bool ogrDeparse(StringInfo buf, PlannerInfo *root, RelOptInfo *foreignrel, 
List *exprs, OgrFdwState *state, List **param);
 
-
-/* Shared global value of the Geometry OId */
-extern Oid GEOMETRYOID;
+Oid ogrGetGeometryOid(void);
 
 #endif /* _OGR_FDW_H */


=====================================
ogr_fdw_deparse.c
=====================================
@@ -68,7 +68,7 @@ ogrStringFromDatum(Datum datum, Oid type)
        initStringInfo(&result);
 
        /* Special handling to convert a geometry to a bbox needed here */
-       if ( type == GEOMETRYOID )
+       if ( type == ogrGetGeometryOid() )
        {
                elog(ERROR, "got a GEOMETRY!");
                return NULL;
@@ -128,7 +128,7 @@ ogrDeparseConst(Const* constant, OgrDeparseCtx *context)
                appendStringInfoString(context->buf, "NULL");
        }
        /* Use geometry as a spatial filter? */
-       else if ( constant->consttype == GEOMETRYOID )
+       else if ( constant->consttype == ogrGetGeometryOid() )
        {
                /*
                 * For geometry we need to convert the gserialized constant 
into 
@@ -355,7 +355,7 @@ ogrDeparseOpExpr(OpExpr* node, OgrDeparseCtx *context)
                // else
                //      return false;
                
-               // if ( constant->consttype != GEOMETRYOID )
+               // if ( constant->consttype != ogrGetGeometryOid() )
 
                ReleaseSysCache(tuple);
 
@@ -483,12 +483,12 @@ ogrDeparseNullTest(NullTest *node, OgrDeparseCtx *context)
 {
        StringInfo buf = context->buf;
 
-    appendStringInfoChar(buf, '(');
-    ogrDeparseExpr(node->arg, context);
-    if (node->nulltesttype == IS_NULL)
-        appendStringInfoString(buf, " IS NULL)");
-    else
-        appendStringInfoString(buf, " IS NOT NULL)");
+       appendStringInfoChar(buf, '(');
+       ogrDeparseExpr(node->arg, context);
+       if (node->nulltesttype == IS_NULL)
+               appendStringInfoString(buf, " IS NULL)");
+       else
+               appendStringInfoString(buf, " IS NOT NULL)");
 
        return true;
 }



View it on GitLab: 
https://salsa.debian.org/debian-gis-team/pgsql-ogr-fdw/commit/09cbc603d30c6fd83032a81de36178706b487b6b

-- 
View it on GitLab: 
https://salsa.debian.org/debian-gis-team/pgsql-ogr-fdw/commit/09cbc603d30c6fd83032a81de36178706b487b6b
You're receiving this email because of your account on salsa.debian.org.
_______________________________________________
Pkg-grass-devel mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-grass-devel

Reply via email to