Changeset: 36e98ab03c4f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=36e98ab03c4f
Modified Files:
sql/backends/monet5/sql.mx
sql/backends/monet5/sql_scenario.c
sql/backends/monet5/sql_user.c
Branch: headless
Log Message:
Merge with default branch.
diffs (truncated from 2454 to 300 lines):
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -1123,7 +1123,7 @@ clean_print(char *msg, const char *prefi
msg += len;
/* skip SQLSTATE if provided */
- if (strlen(msg) > 6 && msg[5] == ':' &&
+ 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')) &&
@@ -1154,7 +1154,7 @@ indented_print(const char *msg, const ch
s = " ";
/* skip SQLSTATE if provided */
- if (strlen(p) > 6 && p[5] == ':' &&
+ 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')) &&
diff --git a/clients/odbc/driver/ODBCError.c b/clients/odbc/driver/ODBCError.c
--- a/clients/odbc/driver/ODBCError.c
+++ b/clients/odbc/driver/ODBCError.c
@@ -71,31 +71,32 @@ static struct SQLStateMsg {
{"01001", "Cursor operation conflict"},
{"01002", "Disconnect error"},
{"01003", "NULL value eliminated in set function"},
- {"01004", "String data, right-truncated"},
+ {"01004", "String data, right truncated"},
{"01006", "Privilege not revoked"},
{"01007", "Privilege not granted"},
{"01S00", "Invalid connection string attribute"},
{"01S01", "Error in row"},
{"01S02", "Option value changed"},
- {"01S06", "Attempt to fetch before the result set returned the first
rowset"},
+ {"01S06", "Attempt to fetch before the result set returned the first "
+ "rowset"},
{"01S07", "Fractional truncation"},
- {"01S08", "Error saving File DSN"},
+ {"01S08", "Error saving file DSN"},
{"01S09", "Invalid keyword"},
- {"07001", "Wrong number of parameters"},
{"07002", "COUNT field incorrect"},
{"07005", "Prepared statement not a cursor-specification"},
{"07006", "Restricted data type attribute violation"},
+ {"07007", "Restricted parameter value violation"},
{"07009", "Invalid descriptor index"},
{"07S01", "Invalid use of default parameter"},
{"08001", "Client unable to establish connection"},
{"08002", "Connection name in use"},
- {"08003", "Connection does not exist"},
+ {"08003", "Connection not open"},
{"08004", "Server rejected the connection"},
{"08007", "Connection failure during transaction"},
{"08S01", "Communication link failure"},
{"21S01", "Insert value list does not match column list"},
{"21S02", "Degree of derived table does not match column list"},
- {"22001", "String data, right-truncated"},
+ {"22001", "String data, right truncated"},
{"22002", "Indicator variable required but not supplied"},
{"22003", "Numeric value out of range"},
{"22007", "Invalid datetime format"},
@@ -109,7 +110,7 @@ static struct SQLStateMsg {
{"23000", "Integrity constraint violation"},
{"24000", "Invalid cursor state"},
{"25000", "Invalid transaction state"},
- {"25S01", "Transaction state"},
+ {"25S01", "Transaction state unknown"},
{"25S02", "Transaction is still active"},
{"25S03", "Transaction is rolled back"},
{"28000", "Invalid authorization specification"},
@@ -134,7 +135,7 @@ static struct SQLStateMsg {
{"HY004", "Invalid SQL data type"},
{"HY007", "Associated statement is not prepared"},
{"HY008", "Operation canceled"},
- {"HY009", "Invalid use of null pointer"},
+ {"HY009", "Invalid argument value"},
{"HY010", "Function sequence error"},
{"HY011", "Attribute cannot be set now"},
{"HY012", "Invalid transaction operation code"},
@@ -142,7 +143,8 @@ static struct SQLStateMsg {
{"HY014", "Limit on the number of handles exceeded"},
{"HY015", "No cursor name available"},
{"HY016", "Cannot modify an implementation row descriptor"},
- {"HY017", "Invalid use of an automatically allocated descriptor
handle"},
+ {"HY017", "Invalid use of an automatically allocated descriptor "
+ "handle"},
{"HY018", "Server declined cancel request"},
{"HY019", "Non-character and non-binary data sent in pieces"},
{"HY020", "Attempt to concatenate a null value"},
@@ -152,7 +154,7 @@ static struct SQLStateMsg {
{"HY091", "Invalid descriptor field identifier"},
{"HY092", "Invalid attribute/option identifier"},
{"HY095", "Function type out of range"},
- {"HY096", "Invalid information type"},
+ {"HY096", "Information type out of range"},
{"HY097", "Column type out of range"},
{"HY098", "Scope type out of range"},
{"HY099", "Nullable type out of range"},
@@ -166,24 +168,36 @@ static struct SQLStateMsg {
{"HY109", "Invalid cursor position"},
{"HY110", "Invalid driver completion"},
{"HY111", "Invalid bookmark value"},
+ {"HY114", "Driver does not support connection-level asynchronous "
+ "function execution"},
+ {"HY115", "SQLEndTran is not allowed for an environment that contains "
+ "a connection with asynchronous function execution enabled"},
+ {"HY117", "Connection is suspended due to unknown transaction state. "
+ "Only disconnect and read-only functions are allowed."},
+ {"HY121", "Cursor Library and Driver-Aware Pooling cannot be enabled "
+ "at the same time"},
{"HYC00", "Optional feature not implemented"},
{"HYT00", "Timeout expired"},
{"HYT01", "Connection timeout expired"},
{"IM001", "Driver does not support this function"},
- {"IM002", "Data source name not found and no default driver specified"},
- {"IM003", "Specified driver could not be loaded"},
+ {"IM002", "Data source not found and no default driver specified"},
+ {"IM003", "Specified driver could not be connected to"},
{"IM004", "Driver's SQLAllocHandle on SQL_HANDLE_ENV failed"},
{"IM005", "Driver's SQLAllocHandle on SQL_HANDLE_DBC failed"},
{"IM006", "Driver's SQLSetConnectAttr failed"},
{"IM007", "No data source or driver specified; dialog prohibited"},
{"IM008", "Dialog failed"},
- {"IM009", "Unable to load translation DLL"},
+ {"IM009", "Unable to connect to translation DLL"},
{"IM010", "Data source name too long"},
{"IM011", "Driver name too long"},
{"IM012", "DRIVER keyword syntax error"},
- {"IM013", "Trace file error"},
- {"IM014", "Invalid name of File DSN"},
- {"IM015", "Corrupt file data source"},
+ {"IM014", "The specified DSN contains an architecture mismatch "
+ "between the Driver and Application"},
+ {"IM015", "Driver's SQLConnect on SQL_HANDLE_DBC_INFO_HANDLE failed"},
+ {"IM017", "Polling is disabled in asynchronous notification mode"},
+ {"IM018", "SQLCompleteAsync has not been called to complete the "
+ "previous asynchronous operation on this handle."},
+ {"S1118", "Driver does not support asynchronous notification"},
{0, 0}
};
@@ -198,13 +212,13 @@ getStandardSQLStateMsg(const char *SQLSt
assert(SQLState);
for (p = SQLStateMsg; p->SQLState; p++)
- if (strcmp(p->SQLState, SQLState) == 0)
+ if (strncmp(p->SQLState, SQLState, 5) == 0)
return p->SQLMsg;
/* Present a msg to notify the system administrator/programmer */
fprintf(stderr,
"\nMonetDB, ODBC Driver, ODBCError.c: "
- "No message defined for SQLState: %s. "
+ "No message defined for SQLState: %.5s. "
"Please report this error.\n", SQLState);
return SQLState; /* always return a string */
diff --git a/clients/odbc/driver/ODBCStmt.h b/clients/odbc/driver/ODBCStmt.h
--- a/clients/odbc/driver/ODBCStmt.h
+++ b/clients/odbc/driver/ODBCStmt.h
@@ -221,6 +221,6 @@ SQLRETURN SQLPrepare_(ODBCStmt *stmt, SQ
SQLINTEGER nSqlStrLength);
SQLRETURN SQLSetStmtAttr_(ODBCStmt *stmt, SQLINTEGER Attribute,
SQLPOINTER Value, SQLINTEGER StringLength);
-const char *ODBCErrorType(const char *msg);
+const char *ODBCErrorType(const char *msg, const char **emsg);
#endif
diff --git a/clients/odbc/driver/SQLExecDirect.c
b/clients/odbc/driver/SQLExecDirect.c
--- a/clients/odbc/driver/SQLExecDirect.c
+++ b/clients/odbc/driver/SQLExecDirect.c
@@ -45,23 +45,32 @@ static struct errors {
const char *msg;
} errors[] = {
{"syntax error", "42000"},
- {"DROP TABLE: no such table", "42S02"},
- {"DROP VIEW: unknown view", "42S02"},
- {"ALTER TABLE: no such table", "42S02"},
- {"CREATE INDEX: no such table", "42S02"},
- {"SELECT: no such table", "42S02"},
- {"INSERT INTO: no such table", "42S02"},
- {"DELETE FROM: no such table", "42S02"},
- {"UPDATE: no such table", "42S02"},
- {"CONSTRAINT FOREIGN KEY: no such table", "42S02"},
{NULL, NULL}, /* sentinel */
};
const char *
-ODBCErrorType(const char *msg)
+ODBCErrorType(const char *msg, const char **emsg)
{
struct errors *e;
+ 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'))) {
+ *emsg = msg + 6;
+ while (**emsg == ' ')
+ (*emsg)++;
+ return msg;
+ }
+
+ *emsg = msg;
for (e = errors; e->error != NULL; e++)
if (strncmp(msg, e->error, strlen(e->error)) == 0)
return e->msg;
@@ -124,10 +133,11 @@ ODBCExecDirect(ODBCStmt *stmt, SQLCHAR *
if (query == NULL)
query = mapi_error_str(stmt->Dbc->mid);
if (query != NULL) {
- const char *e = ODBCErrorType(query);
+ const char *m;
+ const char *e = ODBCErrorType(query, &m);
if (e) {
- addStmtError(stmt, e, query, 0);
+ addStmtError(stmt, e, m, 0);
return SQL_ERROR;
}
}
diff --git a/clients/odbc/driver/SQLExecute.c b/clients/odbc/driver/SQLExecute.c
--- a/clients/odbc/driver/SQLExecute.c
+++ b/clients/odbc/driver/SQLExecute.c
@@ -127,9 +127,14 @@ ODBCInitResult(ODBCStmt *stmt)
repeat:
errstr = mapi_result_error(hdl);
if (errstr) {
- /* XXX more fine-grained control required */
- /* Syntax error or access violation */
- addStmtError(stmt, "42000", errstr, 0);
+ const char *emsg, *sqlstate;
+
+ if ((sqlstate = ODBCErrorType(errstr, &emsg)) != NULL)
+ addStmtError(stmt, sqlstate, emsg, 0);
+ else {
+ /* Syntax error or access violation */
+ addStmtError(stmt, "42000", errstr, 0);
+ }
return SQL_ERROR;
}
nrCols = mapi_get_field_count(hdl);
@@ -434,7 +439,8 @@ SQLExecute_(ODBCStmt *stmt)
#endif
/* Have the server execute the query */
- if (stmt->next == NULL && stmt->Dbc->FirstStmt == stmt &&
stmt->cursorType == SQL_CURSOR_FORWARD_ONLY) {
+ if (stmt->next == NULL && stmt->Dbc->FirstStmt == stmt &&
+ stmt->cursorType == SQL_CURSOR_FORWARD_ONLY) {
/* we're the only Stmt handle, and we're only going forward */
if (stmt->Dbc->cachelimit != 1000)
mapi_cache_limit(stmt->Dbc->mid, 1000);
@@ -454,8 +460,20 @@ SQLExecute_(ODBCStmt *stmt)
addStmtError(stmt, "08S01", mapi_error_str(stmt->Dbc->mid), 0);
return SQL_ERROR;
default:
+ /* reuse variable query for error message */
+ query = mapi_result_error(hdl);
+ if (query == NULL)
+ query = mapi_error_str(stmt->Dbc->mid);
+ if (query) {
+ const char *emsg, *sqlstate;
+
+ if ((sqlstate = ODBCErrorType(query, &emsg)) != NULL) {
+ addStmtError(stmt, sqlstate, emsg, 0);
+ return SQL_ERROR;
+ }
+ }
/* General error */
- addStmtError(stmt, "HY000", mapi_error_str(stmt->Dbc->mid), 0);
+ addStmtError(stmt, "HY000", query, 0);
return SQL_ERROR;
}
diff --git a/clients/odbc/driver/SQLGetDiagField.c
b/clients/odbc/driver/SQLGetDiagField.c
--- a/clients/odbc/driver/SQLGetDiagField.c
+++ b/clients/odbc/driver/SQLGetDiagField.c
@@ -172,51 +172,11 @@ SQLGetDiagField_(SQLSMALLINT HandleType,
char *state = getSqlState(err);
char *msg;
- if (strcmp(state, "01S00") == 0 ||
- strcmp(state, "01S01") == 0 ||
- strcmp(state, "01S02") == 0 ||
- strcmp(state, "01S06") == 0 ||
- strcmp(state, "01S07") == 0 ||
- strcmp(state, "07S01") == 0 ||
- strcmp(state, "08S01") == 0 ||
- strcmp(state, "21S01") == 0 ||
- strcmp(state, "21S02") == 0 ||
- strcmp(state, "25S01") == 0 ||
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list