[Git][debian-gis-team/pgsql-ogr-fdw][master] 4 commits: New upstream version 1.1.6
Bas Couwenberg (@sebastic)
gitlab at salsa.debian.org
Tue Mar 11 04:31:50 GMT 2025
Bas Couwenberg pushed to branch master at Debian GIS Project / pgsql-ogr-fdw
Commits:
0e370067 by Bas Couwenberg at 2025-03-11T05:27:50+01:00
New upstream version 1.1.6
- - - - -
76366b1a by Bas Couwenberg at 2025-03-11T05:27:51+01:00
Update upstream source from tag 'upstream/1.1.6'
Update to upstream version '1.1.6'
with Debian dir 4dbe3dbd27c5547a2c7fee8cdac46fb74b9775e5
- - - - -
e220e484 by Bas Couwenberg at 2025-03-11T05:28:19+01:00
New upstream release.
- - - - -
5664cf34 by Bas Couwenberg at 2025-03-11T05:29:17+01:00
Set distribution to unstable.
- - - - -
6 changed files:
- .github/workflows/ci.yml
- README.md
- debian/changelog
- ogr_fdw.c
- ogr_fdw.h
- ogr_fdw_common.c
Changes:
=====================================
.github/workflows/ci.yml
=====================================
@@ -16,6 +16,8 @@ jobs:
fail-fast: false
matrix:
ci:
+ - { PGVER: 11 }
+ - { PGVER: 12 }
- { PGVER: 13 }
- { PGVER: 14 }
- { PGVER: 15 }
=====================================
README.md
=====================================
@@ -10,7 +10,7 @@ OGR is the **vector** half of the [GDAL](http://www.gdal.org/) spatial data acce
This implementation currently has the following limitations:
-* **PostgreSQL 9.3 or higher.** This wrapper does not support the FDW implementations in older versions of PostgreSQL.
+* **PostgreSQL 11 or higher.**
* **Limited non-spatial query restrictions are pushed down to OGR.** OGR only supports a [minimal set](https://gdal.org/user/ogr_sql_dialect.html) of SQL operators (>, <, <=, >=, =).
* **Only bounding box filters (&&) are pushed down.** Spatial filtering is possible, but only bounding boxes, and only using the && operator.
* **OGR connections every time** Rather than pooling OGR connections, each query makes (and disposes of) **two** new ones, which seems to be the largest performance drag at the moment for restricted (small) queries.
=====================================
debian/changelog
=====================================
@@ -1,3 +1,10 @@
+pgsql-ogr-fdw (1.1.6-1) unstable; urgency=medium
+
+ * Team upload.
+ * New upstream release.
+
+ -- Bas Couwenberg <sebastic at debian.org> Tue, 11 Mar 2025 05:29:09 +0100
+
pgsql-ogr-fdw (1.1.5-2) unstable; urgency=medium
* Team upload.
=====================================
ogr_fdw.c
=====================================
@@ -264,27 +264,112 @@ ogr_fdw_exit(int code, Datum arg)
}
/*
- * Function to get the geometry OID if required
+ * Given extension oid, lookup installation namespace oid.
+ * This side steps search_path issues with
+ * TypenameGetTypid encountered in
+ * https://github.com/pramsey/pgsql-ogr-fdw/issues/263
+ */
+static Oid
+get_extension_nsp_oid(Oid extOid)
+{
+ Oid result;
+ SysScanDesc scandesc;
+ HeapTuple tuple;
+ ScanKeyData entry[1];
+
+#if PG_VERSION_NUM < 120000
+ Relation rel = heap_open(ExtensionRelationId, AccessShareLock);
+ ScanKeyInit(&entry[0],
+ ObjectIdAttributeNumber,
+ BTEqualStrategyNumber, F_OIDEQ,
+ ObjectIdGetDatum(extOid));
+#else
+ Relation rel = table_open(ExtensionRelationId, AccessShareLock);
+ ScanKeyInit(&entry[0],
+ Anum_pg_extension_oid,
+ BTEqualStrategyNumber, F_OIDEQ,
+ ObjectIdGetDatum(extOid));
+#endif /* PG_VERSION_NUM */
+
+ scandesc = systable_beginscan(rel, ExtensionOidIndexId, true,
+ NULL, 1, entry);
+
+ tuple = systable_getnext(scandesc);
+
+ /* We assume that there can be at most one matching tuple */
+ if (HeapTupleIsValid(tuple))
+ result = ((Form_pg_extension) GETSTRUCT(tuple))->extnamespace;
+ else
+ result = InvalidOid;
+
+ systable_endscan(scandesc);
+
+#if PG_VERSION_NUM < 120000
+ heap_close(rel, AccessShareLock);
+#else
+ table_close(rel, AccessShareLock);
+#endif
+
+ return result;
+}
+
+
+/*
+ * Get the geometry OID (if postgis is
+ * installed) and cache it for quick lookup.
*/
Oid
ogrGetGeometryOid(void)
{
+ /* Is value not set yet? */
if (GEOMETRYOID == InvalidOid)
{
- Oid typoid = TypenameGetTypid("geometry");
- if (OidIsValid(typoid) && get_typisdefined(typoid))
+ const char *extName = "postgis";
+ const char *typName = "geometry";
+ bool missing_ok = true;
+ Oid extOid, extNspOid, typOid;
+
+ /* Got postgis extension? */
+ extOid = get_extension_oid(extName, missing_ok);
+ if (!OidIsValid(extOid))
{
- GEOMETRYOID = typoid;
+ elog(DEBUG2, "%s: lookup of extension '%s' failed", __func__, extName);
+ GEOMETRYOID = BYTEAOID;
+ return GEOMETRYOID;
}
- else
+
+ /* Got namespace for extension? */
+ extNspOid = get_extension_nsp_oid(extOid);
+ if (!OidIsValid(extNspOid))
{
+ elog(DEBUG2, "%s: lookup of namespace for '%s' (%u) failed", __func__, extName, extOid);
GEOMETRYOID = BYTEAOID;
+ return GEOMETRYOID;
}
+
+ /* Got geometry type in namespace? */
+ typOid = GetSysCacheOid2(TYPENAMENSP,
+#if PG_VERSION_NUM >= 120000
+ Anum_pg_type_oid,
+#endif
+ PointerGetDatum(typName),
+ ObjectIdGetDatum(extNspOid));
+
+
+
+ elog(DEBUG2, "%s: lookup of type id for '%s' got %u", __func__, typName, typOid);
+
+ /* Geometry type is good? */
+ if (OidIsValid(typOid) && get_typisdefined(typOid))
+ GEOMETRYOID = typOid;
+ else
+ GEOMETRYOID = BYTEAOID;
}
return GEOMETRYOID;
}
+
/*
* Foreign-data wrapper handler function: return a struct with pointers
* to my callback routines.
@@ -1179,7 +1264,7 @@ ogrCanConvertToPg(OGRFieldType ogr_type, Oid pg_type)
{OFTInteger, {BOOLOID, INT4OID, INT8OID, NUMERICOID, FLOAT4OID, FLOAT8OID, TEXTOID, VARCHAROID, 0}},
{OFTReal, {NUMERICOID, FLOAT4OID, FLOAT8OID, TEXTOID, VARCHAROID, 0}},
{OFTBinary, {BYTEAOID, 0}},
- {OFTString, {TEXTOID, VARCHAROID, CHAROID, BPCHAROID, 0}},
+ {OFTString, {TEXTOID, VARCHAROID, CHAROID, BPCHAROID, JSONBOID, JSONOID, 0}},
{OFTDate, {DATEOID, TIMESTAMPOID, TEXTOID, VARCHAROID, 0}},
{OFTTime, {TIMEOID, TEXTOID, VARCHAROID, 0}},
{OFTDateTime, {TIMESTAMPOID, TEXTOID, VARCHAROID, 0}},
@@ -1547,6 +1632,9 @@ ogrLookupGeometryFunctionOid(const char* proname)
#else
clist = FuncnameGetCandidates(names, -1, NIL, false, false, false, false);
#endif
+
+ if (!clist) return InvalidOid;
+
if (streq(proname, "st_setsrid"))
{
do
=====================================
ogr_fdw.h
=====================================
@@ -22,8 +22,10 @@
#include "access/reloptions.h"
#include "access/sysattr.h"
#include "access/transam.h"
+#include "catalog/indexing.h"
#include "catalog/namespace.h"
#include "catalog/pg_collation.h"
+#include "catalog/pg_extension.h"
#include "catalog/pg_foreign_table.h"
#include "catalog/pg_foreign_server.h"
#include "catalog/pg_namespace.h"
@@ -33,6 +35,7 @@
#include "commands/copy.h"
#include "commands/defrem.h"
#include "commands/explain.h"
+#include "commands/extension.h"
#include "commands/vacuum.h"
#include "foreign/fdwapi.h"
#include "foreign/foreign.h"
@@ -49,6 +52,7 @@
#include "storage/ipc.h"
#include "utils/builtins.h"
#include "utils/date.h"
+#include "utils/fmgroids.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/numeric.h"
=====================================
ogr_fdw_common.c
=====================================
@@ -91,11 +91,15 @@ static void
ogrTypeToPgType(OGRFieldDefnH ogr_fld, char *pgtype, size_t width)
{
OGRFieldType ogr_type = OGR_Fld_GetType(ogr_fld);
+#if GDAL_VERSION_MAJOR >= 2
+ OGRFieldSubType ogr_subtype = OGR_Fld_GetSubType(ogr_fld);
+#endif
+
switch(ogr_type)
{
case OFTInteger:
#if GDAL_VERSION_MAJOR >= 2
- if( OGR_Fld_GetSubType(ogr_fld) == OFSTBoolean )
+ if (ogr_subtype == OFSTBoolean)
{
snprintf(pgtype, width, "boolean");
break;
@@ -109,7 +113,15 @@ ogrTypeToPgType(OGRFieldDefnH ogr_fld, char *pgtype, size_t width)
break;
case OFTString:
{
- int ogr_fld_width = OGR_Fld_GetWidth(ogr_fld);
+ int ogr_fld_width;
+#if GDAL_VERSION_MAJOR >= 2
+ if (ogr_subtype == OFSTJSON)
+ {
+ snprintf(pgtype, width, "jsonb");
+ break;
+ }
+#endif
+ ogr_fld_width = OGR_Fld_GetWidth(ogr_fld);
if (ogr_fld_width > 0)
snprintf(pgtype, width, "varchar(%d)", ogr_fld_width);
else
View it on GitLab: https://salsa.debian.org/debian-gis-team/pgsql-ogr-fdw/-/compare/5fa6428ad49c37a6217e7e13b430686ee935478e...5664cf34116f6b18da9e9f80d4404da914cc58e7
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/pgsql-ogr-fdw/-/compare/5fa6428ad49c37a6217e7e13b430686ee935478e...5664cf34116f6b18da9e9f80d4404da914cc58e7
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20250311/339d9671/attachment-0001.htm>
More information about the Pkg-grass-devel
mailing list