Skip to content
Commits on Source (5)
pgsql-ogr-fdw (1.0.6-3) UNRELEASED; urgency=medium
pgsql-ogr-fdw (1.0.7-1) unstable; urgency=medium
* Team upload.
* New upstream release.
* Bump Standards-Version to 4.2.1, no changes.
* Update watch file to handle common issues.
* Drop unused lintian overrides.
-- Christoph Berg <christoph.berg@credativ.de> Sun, 05 Aug 2018 20:42:37 +0200
-- Bas Couwenberg <sebastic@debian.org> Tue, 25 Sep 2018 07:10:57 +0200
pgsql-ogr-fdw (1.0.6-2) unstable; urgency=medium
......
# don't bug people uploading from @work
source: changelog-should-mention-nmu
source: source-nmu-has-incorrect-version-number
......@@ -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
);
......
......@@ -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 */
......@@ -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);
......