Changeset: e19d64f8b39c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e19d64f8b39c
Modified Files:
sql/backends/monet5/sql.mx
sql/backends/monet5/sql_optimizer.c
sql/server/sql_parser.y
Branch: default
Log Message:
Merged from Dec2011
diffs (truncated from 7253 to 300 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -5755,6 +5755,7 @@ str divRef;
str doALGfetch(ptr ret, BAT *b, lng *pos);
str doneRef;
int dropRegist(str sch, str tab, str col, int acc);
+void dumpExceptionsToStream(stream *out, str msg);
void dumpHelpTable(stream *f, Module s, str text, int flag);
void dumpManual(stream *f, Module v, int recursive);
void dumpManualFooter(stream *f);
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -1122,6 +1122,17 @@ clean_print(char *msg, const char *prefi
if (strncmp(msg, prefix, len) == 0)
msg += len;
+ /* skip SQLSTATE if provided */
+ if (strlen(msg) > 6 && msg[5] == ':' &&
+ ((msg[0] >= '0' && msg[0] <= '9') || (msg[0] >=
'A' && msg[0] <= 'Z')) &&
+ ((msg[1] >= '0' && msg[1] <= '9') || (msg[1] >=
'A' && msg[1] <= 'Z')) &&
+ ((msg[2] >= '0' && msg[2] <= '9') || (msg[2] >=
'A' && msg[2] <= 'Z')) &&
+ ((msg[3] >= '0' && msg[3] <= '9') || (msg[3] >=
'A' && msg[3] <= 'Z')) &&
+ ((msg[4] >= '0' && msg[4] <= '9') || (msg[4] >=
'A' && msg[4] <= 'Z')))
+ {
+ msg += 6;
+ }
+
/* output line */
fputs(msg, fd);
fputc('\n', fd);
@@ -1141,6 +1152,18 @@ indented_print(const char *msg, const ch
while (p && *p) {
fprintf(fd, "%.*s%c", len - 1, s, t);
s = " ";
+
+ /* skip SQLSTATE if provided */
+ if (strlen(p) > 6 && p[5] == ':' &&
+ ((p[0] >= '0' && p[0] <= '9') || (p[0] >= 'A'
&& p[0] <= 'Z')) &&
+ ((p[1] >= '0' && p[1] <= '9') || (p[1] >= 'A'
&& p[1] <= 'Z')) &&
+ ((p[2] >= '0' && p[2] <= '9') || (p[2] >= 'A'
&& p[2] <= 'Z')) &&
+ ((p[3] >= '0' && p[3] <= '9') || (p[3] >= 'A'
&& p[3] <= 'Z')) &&
+ ((p[4] >= '0' && p[4] <= '9') || (p[4] >= 'A'
&& p[4] <= 'Z')))
+ {
+ p += 6;
+ }
+
q = strchr(p, '\n');
if (q) {
q++; /* also print the newline */
diff --git a/clients/odbc/driver/ODBCUtil.c b/clients/odbc/driver/ODBCUtil.c
--- a/clients/odbc/driver/ODBCUtil.c
+++ b/clients/odbc/driver/ODBCUtil.c
@@ -905,7 +905,7 @@ translateConnectOption(SQLUSMALLINT Opti
case SQL_TRANSLATE_DLL:
return "SQL_TRANSLATE_DLL";
default:
- return "unknown";
+ return translateConnectAttribute((SQLSMALLINT) Option);
}
}
diff --git a/java/ChangeLog.Dec2011 b/java/ChangeLog.Dec2011
--- a/java/ChangeLog.Dec2011
+++ b/java/ChangeLog.Dec2011
@@ -1,6 +1,11 @@
# ChangeLog file for java
# This file is updated with Maddlog
+* Sun Dec 11 2011 Fabian Groffen <[email protected]>
+- SQLExceptions thrown now carry a SQLSTATE. Until the server starts
+ sending correct SQLSTATEs for all errors, server originated errors
+ without SQLSTATE are considered generic data exceptions (22000).
+
* Sat Dec 10 2011 Fabian Groffen <[email protected]>
- Fixed a bug where closing ResultSets and PreparedStatements could lead
to errors on concurrent running queries using the same Connection due
diff --git a/java/SQLSTATEs b/java/SQLSTATEs
new file mode 100644
--- /dev/null
+++ b/java/SQLSTATEs
@@ -0,0 +1,36 @@
+08M01 opening logfile failed
+01M02 redirect warning
+M0M03 illegal arguments (invalid call of internal function)
+01M03 illegal arguments (invalid call of internal function)
+M0M04 only supported in SQL mode
+M1M05 invalid argument (user supplied)
+M0M06 savepoint is not MonetSavepoint
+01M07 unrecognised clientinfo property
+01M08 read-only conection mode not supported
+01M09 transaction mode not supported
+M0M10 protocol violation/unexpected server response
+01M10 unexpected server output
+01M11 server-client autocommit state mismatch
+M0M12 matching client handle referenced by server not found
+01M13 concurrency mode not supported
+01M14 scrolling mode not supported
+01M15 holdability mode not supported
+M1M16 multistatements not supported in batches
+M1M17 result set not expected for DML or DDL-statement
+01M18 generated keys for columns not supported
+M1M19 response is not a result set
+M1M20 object closed
+01M21 cursors not supported
+0AM21 cursors not supported
+01M22 JDBC escape syntax not supported
+01M23 field size limitation not supported
+01M24 query time out not supported
+M1M25 failed reading from/writing to object stream
+08M26 invalid URI
+M0M27 unknown error
+22M28 invalid BLOB format
+M0M29 assert
+3BM30 autocommit mode active
+2DM30 autocommit mode active
+M1M31 no such object
+M1M32 object already exists
diff --git a/java/src/nl/cwi/monetdb/client/JdbcClient.java
b/java/src/nl/cwi/monetdb/client/JdbcClient.java
--- a/java/src/nl/cwi/monetdb/client/JdbcClient.java
+++ b/java/src/nl/cwi/monetdb/client/JdbcClient.java
@@ -554,15 +554,14 @@ copts.produceHelpMessage()
executeQuery(query, stmt, out);
} catch (SQLException e) {
out.flush();
- if (hasFile) {
-
System.err.println("Error on line " + i + ": " + e.getMessage());
- } else {
-
System.err.println("Error: " + e.getMessage());
- }
- // print all error messages in
the chain (if any)
- while ((e =
e.getNextException()) != null) {
-
System.err.println(e.getMessage());
- }
+ do {
+ if (hasFile) {
+
System.err.println("Error on line " + i + ": [" + e.getSQLState() + "] " +
e.getMessage());
+ } else {
+
System.err.println("Error: [" + e.getSQLState() + "] " + e.getMessage());
+ }
+ // print all error
messages in the chain (if any)
+ } while ((e =
e.getNextException()) != null);
}
query = "";
wasComplete = true;
@@ -672,7 +671,10 @@ copts.produceHelpMessage()
}
} catch (SQLException e) {
out.flush();
-
System.err.println("Error: " + e.getMessage());
+ do {
+
System.err.println("Error: [" + e.getSQLState() + "] " + e.getMessage());
+ // print all
error messages in the chain (if any)
+ } while ((e =
e.getNextException()) != null);
}
} else if
(qp.getQuery().startsWith("\\l") ||
qp.getQuery().startsWith("\\i"))
@@ -716,11 +718,14 @@ copts.produceHelpMessage()
executeQuery(query,
stmt, out);
} catch (SQLException e) {
out.flush();
- if (hasFile) {
-
System.err.println("Error on line " + i + ": " + e.getMessage());
- } else {
-
System.err.println("Error: " + e.getMessage());
- }
+ do {
+ if (hasFile) {
+
System.err.println("Error on line " + i + ": [" + e.getSQLState() + "] " +
e.getMessage());
+ } else {
+
System.err.println("Error: [" + e.getSQLState() + "] " + e.getMessage());
+ }
+ // print all
error messages in the chain (if any)
+ } while ((e =
e.getNextException()) != null);
}
query = "";
wasComplete = true;
@@ -862,11 +867,11 @@ copts.produceHelpMessage()
stmt.executeBatch();
stmt.clearBatch();
} catch (SQLException e) {
- System.err.println("Error at line " + i + ": " +
e.getMessage());
- // print all error messages in the chain (if any)
- while ((e = e.getNextException()) != null) {
- System.err.println(e.getMessage());
- }
+ do {
+ System.err.println("Error at line " + i + ": ["
+
+ e.getSQLState() + "] " +
e.getMessage());
+ // print all error messages in the chain (if
any)
+ } while ((e = e.getNextException()) != null);
}
}
diff --git a/java/src/nl/cwi/monetdb/jdbc/MonetBlob.java
b/java/src/nl/cwi/monetdb/jdbc/MonetBlob.java
--- a/java/src/nl/cwi/monetdb/jdbc/MonetBlob.java
+++ b/java/src/nl/cwi/monetdb/jdbc/MonetBlob.java
@@ -73,7 +73,7 @@ public class MonetBlob implements Blob {
*/
public InputStream getBinaryStream() throws SQLException {
if (buf == null)
- throw new SQLException("This Blob object has been
freed");
+ throw new SQLException("This Blob object has been
freed", "M1M20");
return(new ByteArrayInputStream(buf));
}
@@ -98,13 +98,13 @@ public class MonetBlob implements Blob {
throws SQLException
{
if (buf == null)
- throw new SQLException("This Blob object has been
freed");
+ throw new SQLException("This Blob object has been
freed", "M1M20");
if (pos < 1)
- throw new SQLException("pos is less than 1");
+ throw new SQLException("pos is less than 1", "M1M05");
if (pos - 1 > buf.length)
- throw new SQLException("pos is greater than the number
of bytes in the Blob");
+ throw new SQLException("pos is greater than the number
of bytes in the Blob", "M1M05");
if (pos - 1 + length > buf.length)
- throw new SQLException("pos + length is greater than
the number of bytes in the Blob");
+ throw new SQLException("pos + length is greater than
the number of bytes in the Blob", "M1M05");
return(new ByteArrayInputStream(buf, (int)(pos - 1),
(int)length));
}
@@ -124,14 +124,14 @@ public class MonetBlob implements Blob {
*/
public byte[] getBytes(long pos, int length) throws SQLException {
if (buf == null)
- throw new SQLException("This Blob object has been
freed");
+ throw new SQLException("This Blob object has been
freed", "M1M20");
try {
byte[] r = new byte[length];
for (int i = 0; i < length; i++)
r[i] = buf[(int)pos - 1 + i];
return(r);
} catch (IndexOutOfBoundsException e) {
- throw new SQLException(e.getMessage());
+ throw new SQLException(e.getMessage(), "M0M10");
}
}
@@ -145,7 +145,7 @@ public class MonetBlob implements Blob {
*/
public long length() throws SQLException {
if (buf == null)
- throw new SQLException("This Blob object has been
freed");
+ throw new SQLException("This Blob object has been
freed", "M1M20");
return((long)buf.length);
}
@@ -180,7 +180,7 @@ public class MonetBlob implements Blob {
*/
public long position(byte[] pattern, long start) throws SQLException {
if (buf == null)
- throw new SQLException("This Blob object has been
freed");
+ throw new SQLException("This Blob object has been
freed", "M1M20");
try {
for (int i = (int)(start - 1); i < buf.length -
pattern.length; i++) {
int j;
@@ -192,7 +192,7 @@ public class MonetBlob implements Blob {
return(i);
}
} catch (IndexOutOfBoundsException e) {
- throw new SQLException(e.getMessage());
+ throw new SQLException(e.getMessage(), "M0M10");
}
return(-1);
}
@@ -217,10 +217,10 @@ public class MonetBlob implements Blob {
*/
public OutputStream setBinaryStream(long pos) throws SQLException {
if (buf == null)
- throw new SQLException("This Blob object has been
freed");
+ throw new SQLException("This Blob object has been
freed", "M1M20");
if (pos < 1)
- throw new SQLException("pos is less than 1");
- throw new SQLFeatureNotSupportedException("Operation
setBinaryStream(long pos) currently not supported");
+ throw new SQLException("pos is less than 1", "M1M05");
+ throw new SQLFeatureNotSupportedException("Operation
setBinaryStream(long pos) currently not supported", "0A000");
}
/**
@@ -262,13 +262,13 @@ public class MonetBlob implements Blob {
throws SQLException
{
if (buf == null)
- throw new SQLException("This Blob object has been
freed");
+ throw new SQLException("This Blob object has been
freed", "M1M20");
try {
/* transactions? what are you talking about? */
for (int i = (int)pos; i < len; i++)
buf[i] = bytes[offset - 1 + i];
} catch (IndexOutOfBoundsException e) {
- throw new SQLException(e.getMessage());
+ throw new SQLException(e.getMessage(), "M0M10");
}
return(len);
}
@@ -284,7 +284,7 @@ public class MonetBlob implements Blob {
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list