Changeset: f5b846d86fbe for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f5b846d86fbe
Modified Files:
        sql/backends/monet5/Makefile.ag
        sql/backends/monet5/sql.mx
        sql/include/sql_catalog.h
        sql/server/rel_select.c
        sql/server/sql_parser.h
        sql/server/sql_parser.y
        sql/server/sql_scan.c
Branch: sciql
Log Message:

merged from default


diffs (truncated from 653 to 300 lines):

diff --git a/clients/odbc/driver/ODBCUtil.h b/clients/odbc/driver/ODBCUtil.h
--- a/clients/odbc/driver/ODBCUtil.h
+++ b/clients/odbc/driver/ODBCUtil.h
@@ -126,21 +126,18 @@ extern char *ODBCutf82wchar(const SQLCHA
        } while (0)
 #define fixWcharOut(r, s, sl, ws, wsl, wslp, cw, errfunc, hdl)         \
        do {                                                            \
-               if (SQL_SUCCEEDED(r)) {                                 \
-                       char *e = ODBCutf82wchar((s), (sl), (ws), (wsl) / (cw), 
&(sl)); \
-                       if (e) {                                        \
-                               /* General error */                     \
-                               errfunc((hdl), "HY000", e, 0);          \
-                               (r) = SQL_ERROR;                        \
-                       } else if ((sl) * (cw) >= (wsl)) {              \
-                               /* String data, right-truncated */      \
-                               errfunc((hdl), "01004", NULL, 0);       \
-                               (r) = SQL_SUCCESS_WITH_INFO;            \
-                       }                                               \
-                       if (wslp)                                       \
-                               *(wslp) = (sl) * (cw);                  \
+               char *e = ODBCutf82wchar((s), (sl), (ws), (wsl) / (cw), &(sl)); 
\
+               if (e) {                                                \
+                       /* General error */                             \
+                       errfunc((hdl), "HY000", e, 0);                  \
+                       (r) = SQL_ERROR;                                \
+               } else if ((sl) * (cw) >= (wsl)) {                      \
+                       /* String data, right-truncated */              \
+                       errfunc((hdl), "01004", NULL, 0);               \
+                       (r) = SQL_SUCCESS_WITH_INFO;                    \
                }                                                       \
-               free(s);                                                \
+               if (wslp)                                               \
+                       *(wslp) = (sl) * (cw);                          \
        } while (0)
 #endif /* WITH_WCHAR */
 
diff --git a/clients/odbc/driver/SQLBrowseConnect.c 
b/clients/odbc/driver/SQLBrowseConnect.c
--- a/clients/odbc/driver/SQLBrowseConnect.c
+++ b/clients/odbc/driver/SQLBrowseConnect.c
@@ -302,8 +302,11 @@ SQLBrowseConnectW(SQLHDBC ConnectionHand
                   addDbcError, dbc, return SQL_ERROR);
        out = malloc(1024);
        rc = SQLBrowseConnect_(dbc, in, SQL_NTS, out, 1024, &n);
-       fixWcharOut(rc, out, n, OutConnectionString, BufferLength,
-                   StringLength2Ptr, 1, addDbcError, dbc);
+       if (SQL_SUCCEEDED(rc) || rc == SQL_NEED_DATA) {
+               fixWcharOut(rc, out, n, OutConnectionString, BufferLength,
+                           StringLength2Ptr, 1, addDbcError, dbc);
+       }
+       free(out);
        if (in)
                free(in);
        return rc;
diff --git a/clients/odbc/driver/SQLColAttribute.c 
b/clients/odbc/driver/SQLColAttribute.c
--- a/clients/odbc/driver/SQLColAttribute.c
+++ b/clients/odbc/driver/SQLColAttribute.c
@@ -340,10 +340,14 @@ SQLColAttributeW(SQLHSTMT StatementHandl
        rc = SQLColAttribute_(stmt, ColumnNumber, FieldIdentifier, ptr,
                              n, &n, NumericAttributePtr);
 
-       if (ptr != CharacterAttributePtr)
-               fixWcharOut(rc, ptr, n, CharacterAttributePtr, BufferLength,
-                           StringLengthPtr, 2, addStmtError, stmt);
-       else if (StringLengthPtr)
+       if (ptr != CharacterAttributePtr) {
+               if (SQL_SUCCEEDED(rc)) {
+                       fixWcharOut(rc, ptr, n, CharacterAttributePtr,
+                                   BufferLength, StringLengthPtr, 2,
+                                   addStmtError, stmt);
+               }
+               free(ptr);
+       } else if (StringLengthPtr)
                *StringLengthPtr = n;
 
        return rc;
diff --git a/clients/odbc/driver/SQLColAttributes.c 
b/clients/odbc/driver/SQLColAttributes.c
--- a/clients/odbc/driver/SQLColAttributes.c
+++ b/clients/odbc/driver/SQLColAttributes.c
@@ -181,10 +181,14 @@ SQLColAttributesW(SQLHSTMT StatementHand
        rc = SQLColAttributes_(stmt, ColumnNumber, FieldIdentifier, ptr,
                               n, &n, NumericAttributePtr);
 
-       if (ptr != CharacterAttributePtr)
-               fixWcharOut(rc, ptr, n, CharacterAttributePtr, BufferLength,
-                           StringLengthPtr, 2, addStmtError, stmt);
-       else if (StringLengthPtr)
+       if (ptr != CharacterAttributePtr) {
+               if (SQL_SUCCEEDED(rc)) {
+                       fixWcharOut(rc, ptr, n, CharacterAttributePtr,
+                                   BufferLength, StringLengthPtr, 2,
+                                   addStmtError, stmt);
+               }
+               free(ptr);
+       } else if (StringLengthPtr)
                *StringLengthPtr = n;
 
        return rc;
diff --git a/clients/odbc/driver/SQLDataSources.c 
b/clients/odbc/driver/SQLDataSources.c
--- a/clients/odbc/driver/SQLDataSources.c
+++ b/clients/odbc/driver/SQLDataSources.c
@@ -147,12 +147,16 @@ SQLDataSourcesW(SQLHENV EnvironmentHandl
                             server, 100, &length1,
                             descr, 100, &length2);
 
-       fixWcharOut(rc, server, length1,
-                   ServerName, BufferLength1, NameLength1,
-                   1, addEnvError, env);
-       fixWcharOut(rc, descr, length2,
-                   Description, BufferLength2, NameLength2,
-                   1, addEnvError, env);
+       if (SQL_SUCCEEDED(rc)) {
+               fixWcharOut(rc, server, length1,
+                           ServerName, BufferLength1, NameLength1,
+                           1, addEnvError, env);
+               fixWcharOut(rc, descr, length2,
+                           Description, BufferLength2, NameLength2,
+                           1, addEnvError, env);
+       }
+       free(server);
+       free(descr);
 
        return rc;
 }
diff --git a/clients/odbc/driver/SQLDescribeCol.c 
b/clients/odbc/driver/SQLDescribeCol.c
--- a/clients/odbc/driver/SQLDescribeCol.c
+++ b/clients/odbc/driver/SQLDescribeCol.c
@@ -225,8 +225,11 @@ SQLDescribeColW(SQLHSTMT StatementHandle
                             ColumnSizePtr,
                             DecimalDigitsPtr,
                             NullablePtr);
-       fixWcharOut(rc, colname, n, ColumnName, BufferLength, NameLengthPtr,
-                   1, addStmtError, stmt);
+       if (SQL_SUCCEEDED(rc)) {
+               fixWcharOut(rc, colname, n, ColumnName, BufferLength,
+                           NameLengthPtr, 1, addStmtError, stmt);
+       }
+       free(colname);
 
        return rc;
 }
diff --git a/clients/odbc/driver/SQLDriverConnect.c 
b/clients/odbc/driver/SQLDriverConnect.c
--- a/clients/odbc/driver/SQLDriverConnect.c
+++ b/clients/odbc/driver/SQLDriverConnect.c
@@ -434,8 +434,11 @@ SQLDriverConnectW(SQLHDBC ConnectionHand
        out = malloc(n);
        rc = SQLDriverConnect_(dbc, WindowHandle, in, SQL_NTS, out, n, &n,
                               DriverCompletion, 0);
-       fixWcharOut(rc, out, n, OutConnectionString, BufferLength,
-                   StringLength2Ptr, 1, addDbcError, dbc);
+       if (SQL_SUCCEEDED(rc)) {
+               fixWcharOut(rc, out, n, OutConnectionString, BufferLength,
+                           StringLength2Ptr, 1, addDbcError, dbc);
+       }
+       free(out);
        if (in)
                free(in);
        return rc;
diff --git a/clients/odbc/driver/SQLGetConnectAttr.c 
b/clients/odbc/driver/SQLGetConnectAttr.c
--- a/clients/odbc/driver/SQLGetConnectAttr.c
+++ b/clients/odbc/driver/SQLGetConnectAttr.c
@@ -196,10 +196,13 @@ SQLGetConnectAttrW(SQLHDBC ConnectionHan
        rc = SQLGetConnectAttr_(dbc, Attribute, ptr, n, &n);
 
        if (ptr != ValuePtr) {
-               SQLSMALLINT nn = (SQLSMALLINT) n;
+               if (SQL_SUCCEEDED(rc)) {
+                       SQLSMALLINT nn = (SQLSMALLINT) n;
 
-               fixWcharOut(rc, ptr, nn, ValuePtr, BufferLength,
-                           StringLengthPtr, 2, addDbcError, dbc);
+                       fixWcharOut(rc, ptr, nn, ValuePtr, BufferLength,
+                                   StringLengthPtr, 2, addDbcError, dbc);
+               }
+               free(ptr);
        } else if (StringLengthPtr)
                *StringLengthPtr = n;
 
diff --git a/clients/odbc/driver/SQLGetConnectOption.c 
b/clients/odbc/driver/SQLGetConnectOption.c
--- a/clients/odbc/driver/SQLGetConnectOption.c
+++ b/clients/odbc/driver/SQLGetConnectOption.c
@@ -135,11 +135,15 @@ SQLGetConnectOptionW(SQLHDBC ConnectionH
        rc = SQLGetConnectOption_(dbc, Option, ptr);
 
        if (ptr != ValuePtr) {
-               SQLSMALLINT n = (SQLSMALLINT) strlen((char *) ptr);
-               SQLSMALLINT *nullp = NULL;
+               if (SQL_SUCCEEDED(rc)) {
+                       SQLSMALLINT n = (SQLSMALLINT) strlen((char *) ptr);
+                       SQLSMALLINT *nullp = NULL;
 
-               fixWcharOut(rc, ptr, n, ValuePtr, SQL_MAX_OPTION_STRING_LENGTH,
-                           nullp, 2, addDbcError, dbc);
+                       fixWcharOut(rc, ptr, n, ValuePtr,
+                                   SQL_MAX_OPTION_STRING_LENGTH, nullp, 2,
+                                   addDbcError, dbc);
+               }
+               free(ptr);
        }
 
        return rc;
diff --git a/clients/odbc/driver/SQLGetCursorName.c 
b/clients/odbc/driver/SQLGetCursorName.c
--- a/clients/odbc/driver/SQLGetCursorName.c
+++ b/clients/odbc/driver/SQLGetCursorName.c
@@ -121,8 +121,11 @@ SQLGetCursorNameW(SQLHSTMT StatementHand
        n++;                    /* account for NUL byte */
        cursor = malloc(n);
        rc = SQLGetCursorName_(stmt, cursor, BufferLength, &n);
-       fixWcharOut(rc, cursor, n, CursorName, BufferLength,
-                   NameLengthPtr, 1, addStmtError, stmt);
+       if (SQL_SUCCEEDED(rc))    {
+               fixWcharOut(rc, cursor, n, CursorName, BufferLength,
+                           NameLengthPtr, 1, addStmtError, stmt);
+       }
+       free(cursor);
 
        return rc;
 }
diff --git a/clients/odbc/driver/SQLGetDescField.c 
b/clients/odbc/driver/SQLGetDescField.c
--- a/clients/odbc/driver/SQLGetDescField.c
+++ b/clients/odbc/driver/SQLGetDescField.c
@@ -377,10 +377,13 @@ SQLGetDescFieldW(SQLHDESC DescriptorHand
        rc = SQLGetDescField_(desc, RecordNumber, FieldIdentifier, ptr, n, &n);
 
        if (ptr != ValuePtr) {
-               SQLSMALLINT nn = (SQLSMALLINT) n;
+               if (SQL_SUCCEEDED(rc)) {
+                       SQLSMALLINT nn = (SQLSMALLINT) n;
 
-               fixWcharOut(rc, ptr, nn, ValuePtr, BufferLength,
-                           StringLengthPtr, 2, addDescError, desc);
+                       fixWcharOut(rc, ptr, nn, ValuePtr, BufferLength,
+                                   StringLengthPtr, 2, addDescError, desc);
+               }
+               free(ptr);
        } else if (StringLengthPtr)
                *StringLengthPtr = n;
 
diff --git a/clients/odbc/driver/SQLGetInfo.c b/clients/odbc/driver/SQLGetInfo.c
--- a/clients/odbc/driver/SQLGetInfo.c
+++ b/clients/odbc/driver/SQLGetInfo.c
@@ -867,10 +867,13 @@ SQLGetInfoW(SQLHDBC ConnectionHandle,
 
        rc = SQLGetInfo_(dbc, InfoType, ptr, n, &n);
 
-       if (ptr != InfoValuePtr)
-               fixWcharOut(rc, ptr, n, InfoValuePtr, BufferLength,
-                           StringLengthPtr, 2, addDbcError, dbc);
-       else if (StringLengthPtr)
+       if (ptr != InfoValuePtr) {
+               if (SQL_SUCCEEDED(rc)) {
+                       fixWcharOut(rc, ptr, n, InfoValuePtr, BufferLength,
+                                   StringLengthPtr, 2, addDbcError, dbc);
+               }
+               free(ptr);
+       } else if (StringLengthPtr)
                *StringLengthPtr = n;
 
        return rc;
diff --git a/clients/odbc/driver/SQLNativeSql.c 
b/clients/odbc/driver/SQLNativeSql.c
--- a/clients/odbc/driver/SQLNativeSql.c
+++ b/clients/odbc/driver/SQLNativeSql.c
@@ -150,8 +150,11 @@ SQLNativeSqlW(SQLHSTMT StatementHandle,
        sqlout = malloc(n);
        rc = SQLNativeSql_(stmt, sqlin, SQL_NTS, sqlout, n, &n);
        nn = (SQLSMALLINT) n;
-       fixWcharOut(rc, sqlout, nn, OutStatementText, BufferLength,
-                   TextLength2Ptr, 1, addStmtError, stmt);
+       if (SQL_SUCCEEDED(rc)) {
+               fixWcharOut(rc, sqlout, nn, OutStatementText, BufferLength,
+                           TextLength2Ptr, 1, addStmtError, stmt);
+       }
+       free(sqlout);
 
        return rc;
 }
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
@@ -59,7 +59,7 @@ public class JdbcClient {
                copts.addOption("f", "file", CmdLineOpts.CAR_ONE, null,
                                "A file name to use either for reading or 
writing.  The " +
                                "file will be used for writing when dump mode 
is used " +
-                               "(-d --dump).  In read mode, the file can also 
be an URL " +
+                               "(-D --dump).  In read mode, the file can also 
be an URL " +
                                "pointing to a plain text file that is 
optionally gzip " +
                                "compressed.");
                copts.addOption("u", "user", CmdLineOpts.CAR_ONE, 
System.getProperty("user.name"),
@@ -69,9 +69,9 @@ public class JdbcClient {
                copts.addOption(null, "password", CmdLineOpts.CAR_ONE, null, 
null);
                copts.addOption("d", "database", CmdLineOpts.CAR_ONE, "",
                                "Try to connect to the given database (only 
makes sense " +
-                               "if connecting to a DatabasePool, M5 or 
equivalent process).");
+                               "if connecting to monetdbd).");
                copts.addOption("l", "language", CmdLineOpts.CAR_ONE, "sql",
-                               "Use the given language, for example 
'xquery'.");
+                               "Use the given language, defaults to 'sql'.");
 
                // arguments which have no argument(s)
                copts.addOption(null, "help", CmdLineOpts.CAR_ZERO, null,
@@ -148,7 +148,7 @@ public class JdbcClient {
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to