Add patch for GDAL issue #6360

This commit is contained in:
Volker Fröhlich 2016-02-14 01:05:35 +01:00
parent a79c2956fe
commit 8b1cb1317b
2 changed files with 87 additions and 1 deletions

View File

@ -0,0 +1,79 @@
Index: /branches/2.0/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitevfs.cpp
===================================================================
--- /branches/2.0/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitevfs.cpp (revision 33410)
+++ /branches/2.0/gdal/ogr/ogrsf_frmts/sqlite/ogrsqlitevfs.cpp (revision 33411)
@@ -381,9 +381,49 @@
}
-static int OGRSQLiteVFSCurrentTime (sqlite3_vfs* pVFS, double* p1)
-{
- sqlite3_vfs* pUnderlyingVFS = GET_UNDERLYING_VFS(pVFS);
- //CPLDebug("SQLITE", "OGRSQLiteVFSCurrentTime()");
- return pUnderlyingVFS->xCurrentTime(pUnderlyingVFS, p1);
+// Derived for sqlite3.c implementation of unixCurrentTime64 and winCurrentTime64
+#ifdef WIN32
+#include <windows.h>
+static int OGRSQLiteVFSCurrentTimeInt64 (sqlite3_vfs* /*pVFS*/, sqlite3_int64 *piNow)
+{
+ FILETIME ft;
+ static const sqlite3_int64 winFiletimeEpoch = 23058135*(sqlite3_int64)8640000;
+ static const sqlite3_int64 max32BitValue =
+ (sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 +
+ (sqlite3_int64)294967296;
+
+#if defined(_WIN32_WCE)
+ SYSTEMTIME time;
+ GetSystemTime(&time);
+ /* if SystemTimeToFileTime() fails, it returns zero. */
+ if (!SystemTimeToFileTime(&time,&ft)){
+ return SQLITE_ERROR;
+ }
+#else
+ GetSystemTimeAsFileTime( &ft );
+#endif
+ *piNow = winFiletimeEpoch +
+ ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) +
+ (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000;
+ return SQLITE_OK;
+}
+#else
+#include <sys/time.h>
+static int OGRSQLiteVFSCurrentTimeInt64 (sqlite3_vfs* /*pVFS*/, sqlite3_int64 *piNow)
+{
+ struct timeval sNow;
+ static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000;
+ (void)gettimeofday(&sNow, NULL); /* Cannot fail given valid arguments */
+ *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_usec/1000;
+
+ return SQLITE_OK;
+}
+#endif
+
+static int OGRSQLiteVFSCurrentTime (sqlite3_vfs* /*pVFS*/, double* p1)
+{
+ sqlite3_int64 i = 0;
+ int rc = OGRSQLiteVFSCurrentTimeInt64(NULL, &i);
+ *p1 = i/86400000.0;
+ return rc;
}
@@ -408,5 +448,9 @@
pVFSAppData->nCounter = 0;
+#if SQLITE_VERSION_NUMBER >= 3008000L /* perhaps not the minimal version that defines xCurrentTimeInt64, but who cares */
+ pMyVFS->iVersion = 2;
+#else
pMyVFS->iVersion = 1;
+#endif
pMyVFS->szOsFile = sizeof(OGRSQLiteFileStruct);
pMyVFS->mxPathname = pDefaultVFS->mxPathname;
@@ -425,4 +469,9 @@
pMyVFS->xCurrentTime = OGRSQLiteVFSCurrentTime;
pMyVFS->xGetLastError = OGRSQLiteVFSGetLastError;
+#if SQLITE_VERSION_NUMBER >= 3008000L /* perhaps not the minimal version that defines xCurrentTimeInt64, but who cares */
+ if( pMyVFS->iVersion >= 2 )
+ pMyVFS->xCurrentTimeInt64 = OGRSQLiteVFSCurrentTimeInt64;
+#endif
+
return pMyVFS;
}

View File

@ -42,7 +42,7 @@
Name: gdal
Version: 2.0.2
Release: 2%{?dist}
Release: 3%{?dist}
Summary: GIS file format library
Group: System Environment/Libraries
License: MIT
@ -67,6 +67,9 @@ Patch2: %{name}-jni.patch
# https://trac.osgeo.org/gdal/ticket/6159#ticket
Patch3: %{name}-2.0.1-iso8211-include.patch
# https://trac.osgeo.org/gdal/ticket/6360
Patch4: %{name}-2.0.2-sqlite-crash.patch
# Fedora uses Alternatives for Java
Patch8: %{name}-1.9.0-java.patch
@ -279,6 +282,7 @@ rm -r frmts/grib/degrib18/g2clib-1.0.4
%patch1 -p1 -b .g2clib~
%patch2 -p1 -b .jni~
%patch3 -p1 -b .iso8211~
%patch4 -p4 -b .sqlite~
%patch8 -p1 -b .java~
# Copy in PROVENANCE.TXT-fedora
@ -795,6 +799,9 @@ popd
#Or as before, using ldconfig
%changelog
* Sun Feb 14 2016 Volker Froehlich <volker27@gmx.at> - 2.0.2-3
- Add patch for GDAL issue #6360
* Mon Feb 08 2016 Volker Froehlich <volker27@gmx.at> - 2.0.2-2
- Rebuild for armadillo 6