Changeset: 24151f3d30e3 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=24151f3d30e3
Modified Files:
gdk/gdk_posix.mx
gdk/gdk_relop.mx
gdk/gdk_utils.mx
monetdb5/mal/mal_interpreter.mx
sql/backends/monet5/sql.mx
sql/server/rel_schema.c
sql/server/rel_select.c
Branch: default
Log Message:
Merged from Apr2011
diffs (truncated from 868 to 300 lines):
diff --git a/gdk/gdk_posix.mx b/gdk/gdk_posix.mx
--- a/gdk/gdk_posix.mx
+++ b/gdk/gdk_posix.mx
@@ -598,7 +598,7 @@
if (MT_mmap_cur == -1)
MT_mmap_cur = i;
#ifdef MMAP_DEBUG
- mnstr_printf(GDKerr, "#MT_mmap_new: %s fd=%d\n", path, fd);
+ mnstr_printf(GDKstdout, "#MT_mmap_new: %s fd=%d\n", path, fd);
#endif
strncpy(MT_mmap_tab[i].path, path, 128);
MT_mmap_tab[i].base = base;
@@ -649,7 +649,7 @@
/* tell the OS quite clearly that you want to
drop this */
ret = posix_fadvise(MT_mmap_tab[victim].fd,
0LL, MT_mmap_tab[victim].len & ~(MT_pagesize() - 1), POSIX_FADV_DONTNEED);
#ifdef MMAP_DEBUG
- mnstr_printf(GDKerr,
+ mnstr_printf(GDKstdout,
"#MT_mmap_del:
posix_fadvise(%s,fd=%d,%uMB,POSIX_FADV_DONTNEED) = %d\n",
MT_mmap_tab[victim].path,
MT_mmap_tab[victim].fd,
@@ -660,7 +660,7 @@
#endif
ret = close(MT_mmap_tab[victim].fd);
#ifdef MMAP_DEBUG
- mnstr_printf(GDKerr,
+ mnstr_printf(GDKstdout,
"#MT_mmap_del: close(%s fd=%d) = %d\n",
MT_mmap_tab[victim].path,
MT_mmap_tab[victim].fd,
@@ -693,7 +693,7 @@
if (MT_mmap_tab[i].fd >= 0) {
ret = posix_fadvise(MT_mmap_tab[i].fd, 0, len &
~(MT_pagesize() - 1), advice);
#ifdef MMAP_DEBUG
- mnstr_printf(GDKerr,
+ mnstr_printf(GDKstdout,
"#MT_fadvise:
posix_fadvise(%s,fd=%d,%uMB,%d) = %d\n",
MT_mmap_tab[i].path,
MT_mmap_tab[i].fd,
@@ -907,8 +907,8 @@
return (worry);
}
-/* a thread informs it is goin to (preload==1) or stops (preload==-1)
- using a range of memory */
+/* a thread informs it is going to (preload==1) or stops
+ using (preload==-1) a range of memory */
void
MT_mmap_inform(void *base, size_t len, int preload, int advice, int writable)
{
@@ -932,13 +932,13 @@
}
(void) pthread_mutex_unlock(&MT_mmap_lock);
if (ret) {
- mnstr_printf(GDKerr,
- "#MT_mmap_inform: posix_madvise(file=%s, fd=%d,
base=" PTRFMT ", len=" SZFMT "MB, advice=MMAP_SEQUENTIAL) = %d\n",
+ mnstr_printf(GDKstdout,
+ "#MT_mmap_inform: posix_madvise(file=%s, fd=%d,
base=" PTRFMT ", len=" SZFMT "MB, advice=MMAP_SEQUENTIAL) = %d (%s)\n",
(i >= 0 ? MT_mmap_tab[i].path : ""),
(i >= 0 ? MT_mmap_tab[i].fd : -1),
PTRFMTCAST base,
len >> 20,
- errno);
+ errno, strerror(errno));
}
}
@@ -1127,7 +1127,7 @@
int ret = munmap(p, len);
#ifdef MMAP_DEBUG
- mnstr_printf(GDKerr, "#munmap(" LLFMT "," LLFMT ",%d) = %d\n", (long
long) p, (long long) len, ret);
+ mnstr_printf(GDKstdout, "#munmap(" LLFMT "," LLFMT ",%d) = %d\n", (long
long) p, (long long) len, ret);
#endif
MT_mmap_del(p, len);
return ret;
@@ -1139,7 +1139,7 @@
int ret = msync(((char *) p) + off, len, (mode & MMAP_SYNC) ? MS_SYNC :
((mode & MMAP_ASYNC) ? MS_ASYNC : MS_INVALIDATE));
#ifdef MMAP_DEBUG
- mnstr_printf(GDKerr,
+ mnstr_printf(GDKstdout,
"#msync(" LLFMT "," LLFMT ",%s) = %d\n",
(long long) p, (long long) len,
(mode & MMAP_SYNC) ? "MS_SYNC" : ((mode & MMAP_ASYNC) ?
"MS_ASYNC" : "MS_INVALIDATE"),
@@ -1156,7 +1156,7 @@
int ret = posix_madvise(p, len & ~(MT_pagesize() - 1), advice);
#ifdef MMAP_DEBUG
- mnstr_printf(GDKerr, "#posix_madvise(" PTRFMT "," SZFMT ",%d) = %d\n",
+ mnstr_printf(GDKstdout, "#posix_madvise(" PTRFMT "," SZFMT ",%d) =
%d\n",
PTRFMTCAST p, len, advice, ret);
#endif
if (MT_fadvise(p, len, advice))
@@ -1536,7 +1536,7 @@
}
if (heapstatus == _HEAPBADPTR || heapstatus == _HEAPBADBEGIN ||
heapstatus == _HEAPBADNODE) {
- mnstr_printf(GDKerr, "#mallinfo(): heap is corrupt.");
+ mnstr_printf(GDKstdout, "#mallinfo(): heap is corrupt.");
}
_heapmin();
return _ret;
@@ -1733,7 +1733,7 @@
/* it could be the <expletive deleted> indexing
* service which prevents us from doing what we have a
* right to do, so try again (once) */
- IODEBUG THRprintf(GDKout, "#retry rename %s %s\n", old, new);
+ IODEBUG THRprintf(GDKstdout, "#retry rename %s %s\n", old, new);
MT_sleep_ms(100); /* wait a little */
ret = rename(old, new);
}
@@ -2018,7 +2018,7 @@
p = (void *) VirtualAlloc(a, size, MEM_COMMIT | mode, PAGE_READWRITE);
(void) pthread_mutex_unlock(&MT_mmap_lock);
if (p == NULL) {
- mnstr_printf(GDKerr, "#VirtualAlloc(" PTRFMT "," SZFMT
",MEM_COMMIT,PAGE_READWRITE): failed\n", PTRFMTCAST a, size);
+ mnstr_printf(GDKstdout, "#VirtualAlloc(" PTRFMT "," SZFMT
",MEM_COMMIT,PAGE_READWRITE): failed\n", PTRFMTCAST a, size);
}
return p;
}
@@ -2028,9 +2028,9 @@
MT_vmfree(void *p, size_t size)
{
if (VirtualFree(p, size, MEM_DECOMMIT) == 0)
- mnstr_printf(GDKerr, "#VirtualFree(" PTRFMT "," SZFMT
",MEM_DECOMMIT): failed\n", PTRFMTCAST p, size);
+ mnstr_printf(GDKstdout, "#VirtualFree(" PTRFMT "," SZFMT
",MEM_DECOMMIT): failed\n", PTRFMTCAST p, size);
if (VirtualFree(p, 0, MEM_RELEASE) == 0)
- mnstr_printf(GDKerr, "#VirtualFree(" PTRFMT ",0,MEM_RELEASE):
failed\n", PTRFMTCAST p);
+ mnstr_printf(GDKstdout, "#VirtualFree(" PTRFMT
",0,MEM_RELEASE): failed\n", PTRFMTCAST p);
}
void *
@@ -2051,7 +2051,7 @@
size_t ret = VirtualFree(p + newsize, oldsize - newsize,
MEM_DECOMMIT);
if (ret == 0)
- mnstr_printf(GDKerr, "#VirtualFree(" PTRFMT "," SSZFMT
",MEM_DECOMMIT): failed\n", PTRFMTCAST(p + newsize), (ssize_t) (oldsize -
newsize));
+ mnstr_printf(GDKstdout, "#VirtualFree(" PTRFMT ","
SSZFMT ",MEM_DECOMMIT): failed\n", PTRFMTCAST(p + newsize), (ssize_t) (oldsize
- newsize));
} else if (oldsize < newsize) {
(void) pthread_mutex_lock(&MT_mmap_lock);
a = (char *) VirtualAlloc(p, newsize, MEM_COMMIT,
PAGE_READWRITE);
diff --git a/gdk/gdk_relop.mx b/gdk/gdk_relop.mx
--- a/gdk/gdk_relop.mx
+++ b/gdk/gdk_relop.mx
@@ -1497,7 +1497,8 @@
JOINPROPCHK {
if (b) {
BATpropcheck(b, BATPROPS_QUICK);
- BATpropcheck(BATmirror(b), BATPROPS_QUICK);
+ if (b->H != b->T)
+ BATpropcheck(BATmirror(b), BATPROPS_QUICK);
}
}
@@ -1516,8 +1517,11 @@
* Disable via command line option --debug=16777216
*/
JOINPROPCHK {
- if (b)
- BATpropcheck(BATmirror(b), BATPROPS_QUICK);
+ if (b) {
+ BATpropcheck(b, BATPROPS_QUICK);
+ if (b->H != b->T)
+ BATpropcheck(BATmirror(b), BATPROPS_QUICK);
+ }
}
return b;
}
diff --git a/gdk/gdk_utils.mx b/gdk/gdk_utils.mx
--- a/gdk/gdk_utils.mx
+++ b/gdk/gdk_utils.mx
@@ -1427,7 +1427,7 @@
GDKmemfail("GDKmmap", len, 0, BBPTRIM_ALL);
ret = MT_mmap(path, mode, off, len);
if (ret != (void *) -1L) {
- THRprintf(GDKout, "#GDKmmap: recovery ok.
Continuing..\n");
+ THRprintf(GDKstdout, "#GDKmmap: recovery ok.
Continuing..\n");
}
}
ALLOCDEBUG fprintf(stderr, "#GDKmmap " LLFMT " " SZFMT " " PTRFMT "\n",
(lng) off, len, PTRFMTCAST ret);
@@ -1477,7 +1477,7 @@
MT_alloc_print();
GDKfatal("GDKvmalloc: failed for " SZFMT " bytes",
size);
} else {
- THRprintf(GDKout, "#GDKvmalloc(" SZFMT "): recovery ok.
Continuing..\n", size);
+ THRprintf(GDKstdout, "#GDKvmalloc(" SZFMT "): recovery
ok. Continuing..\n", size);
}
}
ALLOCDEBUG fprintf(stderr, "#GDKvmalloc " SZFMT " " SZFMT " " PTRFMT
"\n", size, *maxsize, PTRFMTCAST ret);
@@ -1504,7 +1504,7 @@
MT_alloc_print();
GDKfatal("GDKvmrealloc: failed for " SZFMT " bytes
(from " SZFMT ")", newsize, oldsize);
} else {
- THRprintf(GDKout, "#GDKvmrealloc(" SZFMT "): recovery
ok. Continuing..\n", newsize);
+ THRprintf(GDKstdout, "#GDKvmrealloc(" SZFMT "):
recovery ok. Continuing..\n", newsize);
}
}
ALLOCDEBUG fprintf(stderr, "#GDKvmrealloc " SZFMT " " SZFMT " " PTRFMT
" " PTRFMT "\n", newsize, *newmax, PTRFMTCAST pold, PTRFMTCAST ret);
diff --git a/java/ChangeLog.Apr2011 b/java/ChangeLog.Apr2011
--- a/java/ChangeLog.Apr2011
+++ b/java/ChangeLog.Apr2011
@@ -1,6 +1,11 @@
# ChangeLog file for java
# This file is updated with Maddlog
+* Fri Jul 8 2011 Fabian Groffen <[email protected]>
+- Return false from Statement.getMoreResults() instead of a
+ NullPointerException when no query has been performed on the Statement
+ yet, bug #2833
+
* Mon Jun 6 2011 Fabian Groffen <[email protected]>
- Fixed read-only interpretation. Connection.isReadOnly now always
returns false, setReadOnly now generates a warning when called with
diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetStatement.java
b/java/src/nl/cwi/monetdb/jdbc/MonetStatement.java
--- a/java/src/nl/cwi/monetdb/jdbc/MonetStatement.java
+++ b/java/src/nl/cwi/monetdb/jdbc/MonetStatement.java
@@ -766,6 +766,12 @@
* @throws SQLException if a database access error occurs
*/
public boolean getMoreResults(int current) throws SQLException {
+ // protect against people calling this on an unitialised state
+ if (lastResponseList == null) {
+ header = null;
+ return(false);
+ }
+
if (current == CLOSE_CURRENT_RESULT) {
lastResponseList.closeCurrentResponse();
} else if (current == CLOSE_ALL_RESULTS) {
diff --git a/java/tests/Test_Smoreresults.java
b/java/tests/Test_Smoreresults.java
new file mode 100644
--- /dev/null
+++ b/java/tests/Test_Smoreresults.java
@@ -0,0 +1,64 @@
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2011 MonetDB B.V.
+ * All Rights Reserved.
+ */
+
+import java.sql.*;
+
+public class Test_Smoreresults {
+ public static void main(String[] args) throws Exception {
+ Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
+ Connection con = DriverManager.getConnection(args[0]);
+ Statement stmt = con.createStatement();
+ ResultSet rs = null;
+ //DatabaseMetaData dbmd = con.getMetaData();
+
+ // >> true: auto commit should be on by default
+ System.out.println("0. true\t" + con.getAutoCommit());
+
+ try {
+ System.out.print("1. more results?...");
+ if (stmt.getMoreResults() != false ||
stmt.getUpdateCount() != -1)
+ throw new SQLException("more results on an
unitialised Statement, how can that be?");
+ System.out.println(" nope :)");
+
+ System.out.print("2. SELECT 1...");
+ if (stmt.execute("SELECT 1;") == false)
+ throw new SQLException("SELECT 1 returns update
or no results");
+ System.out.println(" ResultSet :)");
+
+ System.out.print("3. more results?...");
+ if (stmt.getMoreResults() != false ||
stmt.getUpdateCount() != -1)
+ throw new SQLException("more results after
SELECT 1 query, how can that be?");
+ System.out.println(" nope :)");
+
+ System.out.print("4. even more results?...");
+ if (stmt.getMoreResults() != false ||
stmt.getUpdateCount() != -1)
+ throw new SQLException("more results after
SELECT 1 query, how can that be?");
+ System.out.println(" nope :)");
+
+ } catch (SQLException e) {
+ // this means we failed (table not there perhaps?)
+ System.out.println("FAILED :( " + e.getMessage());
+ System.out.println("ABORTING TEST!!!");
+ }
+
+ if (rs != null) rs.close();
+
+ con.close();
+ }
+}
diff --git a/java/tests/build.xml b/java/tests/build.xml
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list