Changeset: 869218e72161 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=869218e72161
Modified Files:
clients/mapiclient/mclient.c
common/stream/stream.c
java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
java/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
Branch: default
Log Message:
Merge with Jun2016 branch.
diffs (221 lines):
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -1995,6 +1995,8 @@ doFileBulk(Mapi mid, stream *fp)
buf = malloc(bufsize + 1);
if (!buf) {
fprintf(stderr, "cannot allocate memory for send buffer\n");
+ if (fp)
+ close_stream(fp);
return 1;
}
@@ -2067,6 +2069,8 @@ doFileBulk(Mapi mid, stream *fp)
free(buf);
mnstr_flush(toConsole);
+ if (fp)
+ close_stream(fp);
return errseen;
}
@@ -2637,11 +2641,12 @@ doFile(Mapi mid, stream *fp, int useinse
* convert filename from UTF-8
* to locale */
if ((s = open_rastream(line)) == NULL ||
- mnstr_errnr(s))
+ mnstr_errnr(s)) {
+ if (s)
+ close_stream(s);
fprintf(stderr, "%s: cannot
open\n", line);
- else
+ } else
doFile(mid, s, 0, 0, 0);
- close_stream(s);
continue;
}
case '>':
@@ -2832,6 +2837,7 @@ doFile(Mapi mid, stream *fp, int useinse
if (prompt)
deinit_readline();
#endif
+ close_stream(fp);
return errseen;
}
@@ -3381,7 +3387,9 @@ main(int argc, char **argv)
stream *s;
if (fp == NULL &&
- (fp = fopen(argv[optind], "r")) == NULL) {
+ (fp = (strcmp(argv[optind], "-") == 0 ?
+ stdin :
+ fopen(argv[optind], "r"))) == NULL) {
fprintf(stderr, "%s: cannot open\n",
argv[optind]);
c |= 1;
} else if ((s = file_rastream(fp, argv[optind])) ==
NULL) {
@@ -3389,7 +3397,6 @@ main(int argc, char **argv)
c |= 1;
} else {
c |= doFile(mid, s, useinserts, interactive,
save_history);
- close_stream(s);
}
fp = NULL;
optind++;
@@ -3400,7 +3407,6 @@ main(int argc, char **argv)
if (!has_fileargs && command == NULL) {
stream *s = file_rastream(stdin, "<stdin>");
c = doFile(mid, s, useinserts, interactive, save_history);
- mnstr_destroy(s);
}
mapi_destroy(mid);
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -4575,6 +4575,8 @@ cb_destroy(stream *s)
if (cb->destroy)
(*cb->destroy)(cb->private);
+ free(cb);
+ s->stream_data.p = NULL;
destroy(s);
}
diff --git a/java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
b/java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
--- a/java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
+++ b/java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
@@ -1190,7 +1190,7 @@ public class MonetDatabaseMetaData exten
*/
@Override
public boolean supportsStoredProcedures() {
- return false;
+ return true;
}
/**
@@ -2476,7 +2476,7 @@ public class MonetDatabaseMetaData exten
if (table != null) {
query.append(" AND \"tables\".\"name\"
").append(composeMatchPart(table));
}
- if (scope != DatabaseMetaData.bestRowSession) {
+ if (scope != DatabaseMetaData.bestRowSession && scope !=
DatabaseMetaData.bestRowTransaction && scope !=
DatabaseMetaData.bestRowTemporary) {
query.append(" AND 1 = 0");
}
if (!nullable) {
diff --git a/java/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
b/java/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
--- a/java/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
+++ b/java/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
@@ -345,11 +345,14 @@ public class MonetResultSet extends Mone
public InputStream getAsciiStream(String columnName) throws
SQLException {
throw newSQLFeatureNotSupportedException("getAsciiStream");
}
+
@Override
+ @Deprecated
public InputStream getUnicodeStream(int columnIndex) throws
SQLException {
throw newSQLFeatureNotSupportedException("getUnicodeStream");
}
@Override
+ @Deprecated
public InputStream getUnicodeStream(String columnName) throws
SQLException {
throw newSQLFeatureNotSupportedException("getUnicodeStream");
}
@@ -633,6 +636,7 @@ public class MonetResultSet extends Mone
* @throws SQLException if a database access error occurs
*/
@Override
+ @Deprecated
public BigDecimal getBigDecimal(int columnIndex, int scale)
throws SQLException
{
@@ -675,6 +679,7 @@ public class MonetResultSet extends Mone
* @throws SQLException if a database access error occurs
*/
@Override
+ @Deprecated
public BigDecimal getBigDecimal(String columnName, int scale)
throws SQLException
{
@@ -1574,32 +1579,29 @@ public class MonetResultSet extends Mone
*/
@Override
public String getColumnClassName(int column) throws
SQLException {
- try {
- if (conn == null) {
- // prevent NullPointerException
when statement is null (i.c. MonetVirtualResultSet)
- if (getStatement() != null) {
- // first time, get a
Connection object and cache it for all next columns
- conn =
getStatement().getConnection();
- }
+ final String MonetDBtype =
getColumnTypeName(column);
+ Class<?> type = null;
+ if (conn == null) {
+ // prevent NullPointerException when
statement is null (i.c. MonetVirtualResultSet)
+ if (getStatement() != null) {
+ // first time, get a Connection
object and cache it for all next columns
+ conn =
getStatement().getConnection();
}
- if (conn != null) {
- Class type = null;
- Map map = conn.getTypeMap();
- if (map != null &&
map.containsKey(types[column - 1])) {
- type =
(Class)map.get(types[column - 1]);
- } else {
- type =
getClassForType(getJavaType(types[column - 1]));
- }
- if (type != null)
- return type.getName();
+ }
+ if (conn != null) {
+ Map map = conn.getTypeMap();
+ if (map != null &&
map.containsKey(MonetDBtype)) {
+ type =
(Class)map.get(MonetDBtype);
}
- throw new SQLException("column type
mapping null: " + types[column - 1], "M0M03");
- } catch (IndexOutOfBoundsException e) {
- throw new SQLException("No such column
" + column, "M1M05");
- } catch (NullPointerException npe) {
- /* do nothing */
}
- return "";
+ if (type == null) {
+ // fallback to the standard Class
mappings
+ type =
getClassForType(getJavaType(MonetDBtype));
+ }
+ if (type != null) {
+ return type.getName();
+ }
+ throw new SQLException("column type mapping
null: " + MonetDBtype, "M0M03");
}
/**
@@ -1797,8 +1799,6 @@ public class MonetResultSet extends Mone
throw new SQLException(ie.getMessage(),
"M0M27");
} catch (IllegalAccessException iae) {
throw new SQLException(iae.getMessage(),
"M0M27");
- } catch (IllegalArgumentException ige) {
- throw new SQLException(ige.getMessage(),
"M0M27");
} catch (InvocationTargetException ite) {
throw new SQLException(ite.getMessage(),
"M0M27");
}
@@ -2013,7 +2013,7 @@ public class MonetResultSet extends Mone
* This switch returns the types as objects according to table
B-3 from
* Oracle's JDBC specification 4.1
*/
- // keep this switch aligned with getObject(int, Map) !
+ // keep this switch regarding the returned classes aligned with
getObject(int, Map) !
switch(type) {
case Types.CHAR:
case Types.VARCHAR:
@@ -2022,9 +2022,9 @@ public class MonetResultSet extends Mone
case Types.NUMERIC:
case Types.DECIMAL:
return BigDecimal.class;
- case Types.BIT: // we don't use type BIT, it's here for
completeness
case Types.BOOLEAN:
return Boolean.class;
+ case Types.BIT: // MonetDB doesn't support type BIT,
it's here for completeness
case Types.TINYINT:
case Types.SMALLINT:
return Short.class;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list