Fix libmdbsql build on Windows

This commit is contained in:
Evan Miller
2020-12-17 11:04:54 -05:00
parent f6be7a74ef
commit e7d5125e2b
2 changed files with 8 additions and 3 deletions

View File

@@ -36,7 +36,7 @@ AC_CHECK_DECLS([program_invocation_short_name], [], [], [[
dnl Checks for library functions.
VL_LIB_READLINE
AC_CHECK_FUNCS(strptime fmemopen)
AC_CHECK_FUNCS(strptime fmemopen gmtime_r)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

View File

@@ -763,9 +763,14 @@ int mdb_sql_find_sargcol(MdbSargNode *node, gpointer data)
* Plain integers are UNIX timestamps for backwards compatibility of parser
*/
if (col->col_type == MDB_DATETIME && node->val_type == MDB_INT) {
struct tm *tmp;
#ifdef HAVE_GMTIME_R
struct tm tm;
gmtime_r((time_t*)&node->value.i, &tm);
mdb_tm_to_date(&tm, &node->value.d);
tmp = gmtime_r((time_t*)&node->value.i, &tm);
#else // regular gmtime on Windows uses thread-local storage
tmp = gmtime((time_t*)&node->value.i);
#endif
mdb_tm_to_date(tmp, &node->value.d);
node->val_type = MDB_DOUBLE;
}
}