Changeset: cec836bb2b9b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cec836bb2b9b
Modified Files:
        NT/monetdb_config.h.in
        gdk/gdk_cbp.c
        gdk/gdk_posix.c
        gdk/gdk_posix.h
        gdk/gdk_storage.c
Branch: headless
Log Message:

Merge with default branch.


diffs (truncated from 1544 to 300 lines):

diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in
--- a/NT/monetdb_config.h.in
+++ b/NT/monetdb_config.h.in
@@ -643,7 +643,10 @@
 /* modifiable single-machine data */
 #define LOCALSTATEDIR PREFIX "\\var"
 
-#define lstat stat
+#include <sys/stat.h>
+#define lstat _stat64
+#define stat _stat64
+#define fstat _fstat64
 #ifndef S_ISREG        /* swig-generated source file doesn't include us first 
*/
 #define S_ISREG(mode)  (((mode) & _S_IFMT) == _S_IFREG)
 #endif
diff --git a/gdk/ChangeLog.Apr2011 b/gdk/ChangeLog.Apr2011
--- a/gdk/ChangeLog.Apr2011
+++ b/gdk/ChangeLog.Apr2011
@@ -1,3 +1,7 @@
 # ChangeLog file for MonetDB
 # This file is updated with Maddlog
 
+* Fri May 13 2011 Sjoerd Mullender <[email protected]>
+- Fixed a bug where large files (> 2GB) didn't always get deleted on
+  Windows.
+
diff --git a/gdk/gdk_cbp.c b/gdk/gdk_cbp.c
--- a/gdk/gdk_cbp.c
+++ b/gdk/gdk_cbp.c
@@ -459,6 +459,8 @@
                                break;
                        default:
                                assert(0);
+                               /* cannot happen, but compiler doesn't know */
+                               s = NULL;
                        }
                        b->heap.free += b->width;
                        COLset_str(b, i, s, 0);
diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -1435,11 +1435,12 @@
        return buf;
 }
 
+#undef _stat64
 int
-win_stat(const char *pathname, struct stat *st)
+win_stat(const char *pathname, struct _stat64 *st)
 {
        char buf[128], *p = reduce_dir_name(pathname, buf, sizeof(buf));
-       int ret = stat(p, st);
+       int ret = _stat64(p, st);
 
        if (p != buf)
                free(p);
diff --git a/gdk/gdk_posix.h b/gdk/gdk_posix.h
--- a/gdk/gdk_posix.h
+++ b/gdk/gdk_posix.h
@@ -264,7 +264,7 @@
 gdk_export int win_unlink(const char *);
 gdk_export int win_mkdir(const char *, const int mode);
 
-#define stat(x,y)      win_stat(x,y)
+#define _stat64(x,y)   win_stat(x,y)
 #define mkdir          win_mkdir
 #define rmdir          win_rmdir
 #define rename         win_rename
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -185,27 +185,20 @@
 /*
  * Unlink the file.
  */
-static int
-delete_file(const char *path)
-{
-       int err = unlink(path);
-
-       if (err)
-               GDKsyserror("GDKunlink(%s)\n", path);
-       IODEBUG THRprintf(GDKout, "#unlink %s = %d\n", path, err);
-
-       return err;
-}
-
 int
 GDKunlink(const char *dir, const char *nme, const char *ext)
 {
        char path[PATHLENGTH];
-       struct stat st;
+
        if (nme && *nme) {
                GDKfilepath(path, dir, nme, ext);
-               if (lstat(path, &st) == 0)
-                       return delete_file(path);
+               /* if file already doesn't exist, we don't care */
+               if (unlink(path) == -1 && errno != ENOENT) {
+                       GDKsyserror("GDKunlink(%s)\n", path);
+                       IODEBUG THRprintf(GDKout, "#unlink %s = -1\n", path);
+                       return -1;
+               }
+               return 0;
        }
        return -1;
 }
diff --git a/java/ChangeLog.Apr2011 b/java/ChangeLog.Apr2011
--- a/java/ChangeLog.Apr2011
+++ b/java/ChangeLog.Apr2011
@@ -1,3 +1,8 @@
 # ChangeLog file for java
 # This file is updated with Maddlog
 
+* Wed May 11 2011 Fabian Groffen <[email protected]>
+- Insertion via PreparedStatement and retrieval via ResultSet of timestamp
+  and time fields with and without timezones was improved to better
+  respect timezones, as partly indicated in bug #2781.
+
diff --git a/java/Makefile.ag b/java/Makefile.ag
--- a/java/Makefile.ag
+++ b/java/Makefile.ag
@@ -27,7 +27,7 @@
 ant_distjdbc = {
        COND = HAVE_JAVAJDBC
        DIR = datadir/monetdb/lib
-       FILES = monetdb-1.6-mcl.jar monetdb-1.19-jdbc.jar jdbcclient.jar
+       FILES = monetdb-1.6-mcl.jar monetdb-1.20-jdbc.jar jdbcclient.jar
 }
 
 ant_distmerocontrol = {
diff --git a/java/build.properties b/java/build.properties
--- a/java/build.properties
+++ b/java/build.properties
@@ -19,7 +19,7 @@
 # major release number
 JDBC_MAJOR=1
 # minor release number
-JDBC_MINOR=19
+JDBC_MINOR=20
 # an additional identifying string
 JDBC_VER_SUFFIX=Magnistipula
 # the default port to connect on, if no port given when using SQL
diff --git a/java/release.txt b/java/release.txt
--- a/java/release.txt
+++ b/java/release.txt
@@ -1,8 +1,8 @@
 RELEASE NOTES
-MonetDB JDBC driver version 1.19 (Magnistipula/MCL-1.6)
+MonetDB JDBC driver version 1.20 (Magnistipula/MCL-1.6)
 Fabian Groffen <[email protected]>
 
-Release date: 2011-04-05
+Release date: 2011-05-11
 
 
 This JDBC driver is designed for use with MonetDB, a main-memory
diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java 
b/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java
--- a/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java
+++ b/java/src/nl/cwi/monetdb/jdbc/MonetConnection.java
@@ -252,7 +252,8 @@
                        setAutoCommit(true);
                        // set our time zone on the server
                        Calendar cal = Calendar.getInstance();
-                       int offset = (cal.get(Calendar.ZONE_OFFSET) + 
cal.get(Calendar.DST_OFFSET)) / (60 * 1000);
+                       int offset = cal.get(Calendar.ZONE_OFFSET) + 
cal.get(Calendar.DST_OFFSET);
+                       offset /= (60 * 1000); // milliseconds to minutes
                        String tz = offset < 0 ? "-" : "+";
                        tz += (Math.abs(offset) / 60 < 10 ? "0" : "") + 
(Math.abs(offset) / 60) + ":";
                        offset -= (offset / 60) * 60;
diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java 
b/java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
--- a/java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
+++ b/java/src/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java
@@ -69,10 +69,16 @@
        /** Format of a timestamp with RFC822 time zone */
        final SimpleDateFormat mTimestampZ =
                new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
+       /** Format of a timestamp */
+       final SimpleDateFormat mTimestamp =
+               new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        /** Format of a time with RFC822 time zone */
        final SimpleDateFormat mTimeZ =
                new SimpleDateFormat("HH:mm:ss.SSSZ");
-       /** Format of a date used by Mserver */
+       /** Format of a time */
+       final SimpleDateFormat mTime =
+               new SimpleDateFormat("HH:mm:ss.SSS");
+       /** Format of a date used by mserver */
        final SimpleDateFormat mDate =
                new SimpleDateFormat("yyyy-MM-dd");
 
@@ -652,7 +658,7 @@
        public void setDate(int parameterIndex, java.sql.Date x)
                throws SQLException
        {
-               setValue(parameterIndex, "date '" + x.toString() + "'");
+               setDate(parameterIndex, x, null);
        }
 
        /**
@@ -672,8 +678,12 @@
        public void setDate(int parameterIndex, java.sql.Date x, Calendar cal)
                throws SQLException
        {
-               mDate.setTimeZone(cal.getTimeZone());
-               setValue(parameterIndex, "date '" + mDate.format(x) + "'");
+               if (cal == null) {
+                       setValue(parameterIndex, "date '" + x.toString() + "'");
+               } else {
+                       mDate.setTimeZone(cal.getTimeZone());
+                       setValue(parameterIndex, "date '" + mDate.format(x) + 
"'");
+               }
        }
 
        /**
@@ -1208,10 +1218,7 @@
         * @throws SQLException if a database access error occurs
         */
        public void setTime(int index, Time x) throws SQLException {
-               if (index < 1 || index > size)
-                       throw new SQLException("No such parameter with index: " 
+ index);
-
-               setValue(index, monetdbType[index - 1] + " '" + x.toString() + 
"'");
+               setTime(index, x, null);
        }
 
        /**
@@ -1235,11 +1242,25 @@
                if (index < 1 || index > size)
                        throw new SQLException("No such parameter with index: " 
+ index);
 
-               mTimeZ.setTimeZone(cal.getTimeZone());
-
-               String RFC822 = mTimeZ.format(x);
-               setValue(index, monetdbType[index - 1] + " '" +
-                               RFC822.substring(0, 15) + ":" + 
RFC822.substring(15) + "'");
+               boolean hasTimeZone = monetdbType[index - 1].endsWith("tz");
+               if (hasTimeZone) {
+                       // timezone shouldn't matter, since the server is 
timezone
+                       // aware in this case
+                       String RFC822 = mTimeZ.format(x);
+                       setValue(index, "timetz '" +
+                                       RFC822.substring(0, 15) + ":" + 
RFC822.substring(15) + "'");
+               } else {
+                       // server is not timezone aware for this field, and no
+                       // calendar given, since we told the server our 
timezone at
+                       // connection creation, we can just write a plain 
timestamp
+                       // here
+                       if (cal == null) {
+                               setValue(index, "time '" + x.toString() + "'");
+                       } else {
+                               mTime.setTimeZone(cal.getTimeZone());
+                               setValue(index, "time '" + mTime.format(x) + 
"'");
+                       }
+               }
        }
 
        /**
@@ -1254,10 +1275,7 @@
        public void setTimestamp(int index, Timestamp x)
                throws SQLException
        {
-               if (index < 1 || index > size)
-                       throw new SQLException("No such parameter with index: " 
+ index);
-
-               setValue(index, monetdbType[index - 1] + " '" + x.toString() + 
"'");
+               setTimestamp(index, x, null);
        }
 
     /**
@@ -1282,11 +1300,25 @@
                if (index < 1 || index > size)
                        throw new SQLException("No such parameter with index: " 
+ index);
 
-               if (cal == null) cal = Calendar.getInstance();
-               mTimestampZ.setTimeZone(cal.getTimeZone());
-               String RFC822 = mTimestampZ.format(x);
-               setValue(index, monetdbType[index - 1] + " '" +
-                               RFC822.substring(0, 26) + ":" + 
RFC822.substring(26) + "'");
+               boolean hasTimeZone = monetdbType[index - 1].endsWith("tz");
+               if (hasTimeZone) {
+                       // timezone shouldn't matter, since the server is 
timezone
+                       // aware in this case
+                       String RFC822 = mTimestampZ.format(x);
+                       setValue(index, "timestamptz '" +
+                                       RFC822.substring(0, 26) + ":" + 
RFC822.substring(26) + "'");
+               } else {
+                       // server is not timezone aware for this field, and no
+                       // calendar given, since we told the server our 
timezone at
+                       // connection creation, we can just write a plain 
timestamp
+                       // here
+                       if (cal == null) {
+                               setValue(index, "timestamp '" + x.toString() + 
"'");
+                       } else {
+                               mTimestamp.setTimeZone(cal.getTimeZone());
+                               setValue(index, "timestamp '" + 
mTimestamp.format(x) + "'");
+                       }
+               }
        }
 
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to