[pgsql-ogr-fdw] 01/02: Pull patch from upstream to fix building with gdal-2.2.

Christoph Berg myon at debian.org
Tue Oct 3 19:38:13 UTC 2017


This is an automated email from the git hooks/post-receive script.

myon pushed a commit to branch master
in repository pgsql-ogr-fdw.

commit 7058c5ee4a0d9d58db33e81a38107648b341fd26
Author: Christoph Berg <myon at debian.org>
Date:   Tue Oct 3 20:29:40 2017 +0200

    Pull patch from upstream to fix building with gdal-2.2.
---
 debian/changelog        |  1 +
 debian/patches/gdal-2.2 | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
 debian/patches/series   |  1 +
 3 files changed, 63 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index abc9585..c50020d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ pgsql-ogr-fdw (1.0.3-1) UNRELEASED; urgency=medium
 
   * New upstream version with PostgreSQL 10 support.
   * Remove typos.patch.
+  * Pull patch from upstream to fix building with gdal-2.2.
   * debian/tests: Run testsuite.
   * Add myself to Uploaders.
   * Bump S-V; no changes.
diff --git a/debian/patches/gdal-2.2 b/debian/patches/gdal-2.2
new file mode 100644
index 0000000..82432b9
--- /dev/null
+++ b/debian/patches/gdal-2.2
@@ -0,0 +1,61 @@
+commit df22bcb661d67e52997b40686c38dbcc6a7a8b07
+Author: Paul Ramsey <pramsey at cleverelephant.ca>
+Date:   Tue Oct 3 05:56:15 2017 -0700
+
+    Properly handle NULL fields using the new GDAL 2.2 API (Closes #133)
+
+diff --git a/ogr_fdw.c b/ogr_fdw.c
+index 78965ac..18e2ab6 100644
+--- a/ogr_fdw.c
++++ b/ogr_fdw.c
+@@ -1544,11 +1544,17 @@ ogrFeatureToSlot(const OGRFeatureH feat, TupleTableSlot *slot, const OgrFdwExecS
+ 		}
+ 		else if ( ogrvariant == OGR_FIELD )
+ 		{
++#if GDAL_VERSION_MAJOR >= 2 && GDAL_VERSION_MINOR >= 2
++			int field_not_null = OGR_F_IsFieldSet(feat, ogrfldnum) && ! OGR_F_IsFieldNull(feat, ogrfldnum);
++#else
++			int field_not_null = OGR_F_IsFieldSet(feat, ogrfldnum);
++#endif
++
+ 			/* Ensure that the OGR data type fits the destination Pg column */
+ 			ogrCanConvertToPg(ogrfldtype, pgtype, pgname, tbl->tblname);
+ 
+ 			/* Only convert non-null fields */
+-			if ( OGR_F_IsFieldSet(feat, ogrfldnum) )
++			if ( field_not_null )
+ 			{
+ 				switch(ogrfldtype)
+ 				{
+@@ -1579,18 +1585,11 @@ ogrFeatureToSlot(const OGRFeatureH feat, TupleTableSlot *slot, const OgrFdwExecS
+ 						 * Handling numbers directly would be faster, but require a lot of extra code.
+ 						 * For now, we go via text.
+ 						 */
+-						const char *cstr = OGR_F_GetFieldAsString(feat, ogrfldnum);
+-						size_t cstr_len = strlen(cstr);
+-						if ( cstr && cstr_len > 0 )
+-						{
+-							char *cstr_decoded = pg_any_to_server(cstr, cstr_len, PG_UTF8);
+-							nulls[i] = false;
+-							values[i] = pgDatumFromCString(cstr_decoded, pgtype, pgtypmod, pginputfunc);
+-						}
+-						else
+-						{
+-							ogrNullSlot(values, nulls, i);
+-						}
++						const char *cstr_in = OGR_F_GetFieldAsString(feat, ogrfldnum);
++						size_t cstr_len = cstr_in ? strlen(cstr_in) : 0;
++						char *cstr_decoded = pg_any_to_server(cstr_in, cstr_len, PG_UTF8);
++						nulls[i] = false;
++						values[i] = pgDatumFromCString(cstr_decoded, pgtype, pgtypmod, pginputfunc);
+ 						break;
+ 					}
+ 					case OFTDate:
+@@ -1621,7 +1620,6 @@ ogrFeatureToSlot(const OGRFeatureH feat, TupleTableSlot *slot, const OgrFdwExecS
+ 						{
+ 							snprintf(cstr, 256, "%d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, minute, second);
+ 						}
+-
+ 						nulls[i] = false;
+ 						values[i] = pgDatumFromCString(cstr, pgtype, pgtypmod, pginputfunc);
+ 						break;
diff --git a/debian/patches/series b/debian/patches/series
index e1652b3..726c08d 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 install.patch
+gdal-2.2

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pgsql-ogr-fdw.git



More information about the Pkg-grass-devel mailing list