Changeset: e208196ce716 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e208196ce716
Modified Files:
        gdk/gdk_bbp.c
        gdk/gdk_logger.c
        java/ChangeLog.Jun2016
        java/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
Branch: default
Log Message:

Merge with Jun2016 branch.


diffs (truncated from 484 to 300 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -3653,6 +3653,18 @@ BBPsync(int cnt, bat *subcommit)
                        if (BBP_status(i) & BBPEXISTING) {
                                if (b != NULL && BBPbackup(b, subcommit != 
NULL) != GDK_SUCCEED)
                                        break;
+                       } else if (subcommit && (b = BBP_desc(i)) && 
BBP_status(i) & BBPDELETED) {
+                               char o[10];
+                               char *f;
+                               snprintf(o, sizeof(o), "%o", b->batCacheid);
+                               f = GDKfilepath(b->theap.farmid, BAKDIR, o, 
"tail");
+                               if (access(f, F_OK) == 0)
+                                       file_move(b->theap.farmid, BAKDIR, 
SUBDIR, o, "tail");
+                               GDKfree(f);
+                               f = GDKfilepath(b->theap.farmid, BAKDIR, o, 
"theap");
+                               if (access(f, F_OK) == 0)
+                                       file_move(b->theap.farmid, BAKDIR, 
SUBDIR, o, "theap");
+                               GDKfree(f);
                        }
                }
                if (idx < cnt)
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1250,7 +1250,6 @@ bm_subcommit(logger *lg, BAT *list_bid, 
        n[i++] = catalog_bid->batCacheid;
        n[i++] = catalog_nme->batCacheid;
        n[i++] = dcatalog->batCacheid;
-       assert((BUN) i <= nn);
        if (BATcount(dcatalog) > (BATcount(catalog_nme)/2) && catalog_bid == 
list_bid && catalog_nme == list_nme && lg->catalog_bid == catalog_bid) {
                BAT *bids, *nmes, *tids = bm_tids(catalog_bid, dcatalog), *b;
 
@@ -1276,6 +1275,7 @@ bm_subcommit(logger *lg, BAT *list_bid, 
                lg->catalog_bid = catalog_bid = bids;
                lg->catalog_nme = catalog_nme = nmes;
        }
+       assert((BUN) i <= nn);
        BATcommit(catalog_bid);
        BATcommit(catalog_nme);
        BATcommit(dcatalog);
diff --git a/java/ChangeLog.Jun2016 b/java/ChangeLog.Jun2016
--- a/java/ChangeLog.Jun2016
+++ b/java/ChangeLog.Jun2016
@@ -1,3 +1,30 @@
 # ChangeLog file for java
 # This file is updated with Maddlog
 
+* Thu Jul  7 2016 Martin van Dinther <[email protected]>
+- Corrected PROCEDURE_TYPE output value of method 
DatabaseMetaData.getProcedures().
+  It used to return procedureReturnsResult. Now it returns procedureNoResult.
+  Corrected ORDINAL_POSITION output value of method 
DatabaseMetaData.getProcedureColumns().
+  It used to start with 0, but as procedures do not return a result value it 
now
+  starts with 1 for all the procedure arguments, as defined by the JDBC API.
+- Improved output of method DatabaseMetaData.getProcedures(). The REMARKS
+  column now contains the procedure definition as stored in sys.functions.func.
+  The SPECIFIC_NAME column now contains the procedure unique identifier as
+  stored in sys.functions.id. This allows the caller to retrieve the specific
+  overloaded procedure which has the same name, but different arguments.
+  Also improved output of method DatabaseMetaData.getProcedureColumns().
+  The SPECIFIC_NAME column now contains the procedure unique identifier as
+  stored in sys.functions.id. This allows the caller to retrieve the proper
+  arguments of the specific overloaded procedure by matching the SPECIFIC_NAME
+  value.
+- Improved output of method DatabaseMetaData.getFunctions(). The REMARKS
+  column now contains the function definition as stored in sys.functions.func.
+  The SPECIFIC_NAME column now contains the function unique identifier as
+  stored in sys.functions.id. This allows the caller to retrieve the specific
+  overloaded function which has the same name, but different arguments.
+  Also improved output of method DatabaseMetaData.getFunctionColumns().
+  The SPECIFIC_NAME column now contains the function unique identifier as
+  stored in sys.functions.id. This allows the caller to retrieve the proper
+  arguments of the specific overloaded function by matching the SPECIFIC_NAME
+  value.
+
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
@@ -21,7 +21,6 @@ import java.util.ArrayList;
 
 /**
  * A DatabaseMetaData object suitable for the MonetDB database.
- * 
  *
  * @author Fabian Groffen, Martin van Dinther
  * @version 0.6
@@ -239,8 +238,7 @@ public class MonetDatabaseMetaData exten
        }
 
        /**
-        * What is the version string of this JDBC driver?      Again, this is
-        * static.
+        * Retrieves the version number of this JDBC driver as a String.
         *
         * @return the JDBC driver version string
         */
@@ -505,14 +503,7 @@ public class MonetDatabaseMetaData exten
                        " UNION SELECT 'extract'" +
                        " UNION SELECT 'ifthenelse'" +
                        " UNION SELECT 'isnull'" +
-                       " UNION SELECT 'nullif'" +
-                       // for completeness include also some pseudo columns
-                       " UNION SELECT 'current_role'" +
-                       " UNION SELECT 'current_schema'" +
-                       " UNION SELECT 'current_timezone'" +
-                       " UNION SELECT 'current_user'" +
-                       " UNION SELECT 'session_user'" +
-                       " UNION SELECT 'user'";
+                       " UNION SELECT 'nullif'";
                return getConcatenatedStringFromQuery(FunctionsSelect + 
wherePart + " ORDER BY 1");
        }
 
@@ -1480,11 +1471,12 @@ public class MonetDatabaseMetaData exten
        /**
         * What is the maximum length of a catalog
         *
-        * @return the max length
+        * @return the maximum number of characters allowed in a catalog name;
+        * a result of zero means that there is no limit or the limit is not 
known
         */
        @Override
        public int getMaxCatalogNameLength() {
-               return 1024;
+               return 0;  // MonetDB does not support catalog names
        }
 
        /**
@@ -1682,13 +1674,15 @@ public class MonetDatabaseMetaData exten
         *        <li> procedureReturnsResult - Returns a result
         *      </ul>
         * </ol>
-        * <li><b>SPECIFIC_NAME</b> String => The name which uniquely 
identifies this procedure within its schema. 
+        * <li><b>SPECIFIC_NAME</b> String => The name which uniquely 
identifies this procedure within its schema.
         *
-        * @param catalog - a catalog name; "" retrieves those without a
-        *      catalog; null means drop catalog name from criteria
-        * @param schemaPattern - a schema name pattern; "" retrieves those
-        *      without a schema - we ignore this parameter
-        * @param procedureNamePattern - a procedure name pattern
+        * @param catalog - a catalog name; must match the catalog name as it 
is stored in the database;
+        *      "" retrieves those without a catalog;
+        *      null means that the catalog name should not be used to narrow 
the search
+        * @param schemaPattern - a schema name pattern; must match the schema 
name as it is stored in the database;
+        *      "" retrieves those without a schema;
+        *      null means that the schema name should not be used to narrow 
the search
+        * @param procedureNamePattern - a procedure name pattern; must match 
the procedure name as it is stored in the database
         * @return ResultSet - each row is a procedure description
         * @throws SQLException if a database access error occurs
         */
@@ -1700,19 +1694,18 @@ public class MonetDatabaseMetaData exten
        ) throws SQLException
        {
                StringBuilder query = new StringBuilder(980);
-               query.append("SELECT DISTINCT cast(null as varchar(1)) AS 
\"PROCEDURE_CAT\", " +
+               query.append("SELECT cast(null as varchar(1)) AS 
\"PROCEDURE_CAT\", " +
                        "\"schemas\".\"name\" AS \"PROCEDURE_SCHEM\", " +
                        "\"functions\".\"name\" AS \"PROCEDURE_NAME\", " +
                        "cast(null as char(1)) AS \"Field4\", " +
                        "cast(null as char(1)) AS \"Field5\", " +
                        "cast(null as char(1)) AS \"Field6\", " +
-                       "cast(null as char(1)) AS \"REMARKS\", " +
-                       "CAST(CASE \"args\".\"type\" WHEN NULL THEN 
").append(DatabaseMetaData.procedureNoResult)
-                       .append(" ELSE 
").append(DatabaseMetaData.procedureReturnsResult).append(" END AS smallint) AS 
\"PROCEDURE_TYPE\", " +
-                       "CAST(CASE \"functions\".\"language\" WHEN 0 THEN 
\"functions\".\"mod\" || '.' || \"functions\".\"func\"" +
-                       " ELSE \"schemas\".\"name\" || '.' || 
\"functions\".\"name\" END AS VARCHAR(1500)) AS \"SPECIFIC_NAME\" " +
-               "FROM \"sys\".\"functions\" JOIN \"sys\".\"schemas\" ON 
(\"functions\".\"schema_id\" = \"schemas\".\"id\")" +
-               " LEFT OUTER JOIN \"sys\".\"args\" ON (\"args\".\"func_id\" = 
\"functions\".\"id\" and \"args\".\"number\" = 0) " +
+                       "cast(\"functions\".\"func\" as varchar(9999)) AS 
\"REMARKS\", " +
+                       // in MonetDB procedures have no return value by design.
+                       
"CAST(").append(DatabaseMetaData.procedureNoResult).append(" AS smallint) AS 
\"PROCEDURE_TYPE\", " +
+                       // only the id value uniquely identifies a procedure. 
Include it to be able to differentiate between multiple overloaded procedures 
with the same name
+                       "cast(\"functions\".\"id\" as varchar(10)) AS 
\"SPECIFIC_NAME\" " +
+               "FROM \"sys\".\"functions\" JOIN \"sys\".\"schemas\" ON 
(\"functions\".\"schema_id\" = \"schemas\".\"id\") " +
                // include procedures only (type = 2). Others will be returned 
via getFunctions()
                "WHERE \"functions\".\"type\" = 2");
 
@@ -1737,10 +1730,10 @@ public class MonetDatabaseMetaData exten
         * Get a description of a catalog's stored procedure parameters
         * and result columns.
         *
-        * <p>Only descriptions matching the schema, procedure and parameter
-        * name criteria are returned. They are ordered by PROCEDURE_SCHEM
-        * and PROCEDURE_NAME. Within this, the return value, if any, is
-        * first. Next are the parameter descriptions in call order. The
+        * <p>Only descriptions matching the schema, procedure and parameter 
name
+        * criteria are returned. They are ordered by PROCEDURE_SCHEM, 
PROCEDURE_NAME
+        * and SPECIFIC_NAME. Within this, the return value, if any, is first.
+        * Next are the parameter descriptions in call order. The
         * column descriptions follow in column number order.
         *
         * <p>Each row in the ResultSet is a parameter description or column
@@ -1773,23 +1766,29 @@ public class MonetDatabaseMetaData exten
         * <li><b>COLUMN_DEF</b> String => default value for the column, which 
should be interpreted as a string when the value is enclosed in single quotes 
(may be null)
         *         The string NULL (not enclosed in quotes) - if NULL was 
specified as the default value
         *         TRUNCATE (not enclosed in quotes) - if the specified default 
value cannot be represented without truncation
-        *         NULL - if a default value was not specified 
+        *         NULL - if a default value was not specified
         * <li><b>SQL_DATA_TYPE</b> int => reserved for future use
         * <li><b>SQL_DATETIME_SUB</b> int => reserved for future use
         * <li><b>CHAR_OCTET_LENGTH</b> int => the maximum length of binary and 
character based columns. For any other datatype the returned value is a NULL
-        * <li><b>ORDINAL_POSITION</b> int => the ordinal position, starting 
from 1, for the input and output parameters for a procedure. A value of 0 is 
returned if this row describes the procedure's return value. For result set 
columns, it is the ordinal position of the column in the result set starting 
from 1. If there are multiple result sets, the column ordinal positions are 
implementation defined.
+        * <li><b>ORDINAL_POSITION</b> int => the ordinal position, starting 
from 1, for the input and output parameters for a procedure.
+        *      A value of 0 is returned if this row describes the procedure's 
return value. For result set columns, it is the ordinal position of the
+        *      column in the result set starting from 1. If there are multiple 
result sets, the column ordinal positions are implementation defined.
         * <li><b>IS_NULLABLE</b> String => ISO rules are used to determine the 
nullability for a column.
         * <ul><li>YES --- if the parameter can include NULLs
         * <li>NO --- if the parameter cannot include NULLs
-        * <li>empty string --- if the nullability for the parameter is unknown 
+        * <li>empty string --- if the nullability for the parameter is unknown
         * </ul>
-        * <li><b>SPECIFIC_NAME</b> String => the name which uniquely 
identifies this procedure within its schema. 
+        * <li><b>SPECIFIC_NAME</b> String => the name which uniquely 
identifies this procedure within its schema.
         * </ol>
-        * @param catalog   not used
-        * @param schemaPattern not used
-        * @param procedureNamePattern a procedure name pattern
-        * @param columnNamePattern a column name pattern
-        * @return each row is a stored procedure parameter or column 
description
+        * @param catalog - a catalog name; must match the catalog name as it 
is stored in the database;
+        *      "" retrieves those without a catalog;
+        *      null means that the catalog name should not be used to narrow 
the search
+        * @param schemaPattern - a schema name pattern; must match the schema 
name as it is stored in the database;
+        *      "" retrieves those without a schema;
+        *      null means that the schema name should not be used to narrow 
the search
+        * @param procedureNamePattern - a procedure name pattern; must match 
the procedure name as it is stored in the database
+        * @param columnNamePattern - a column name pattern; must match the 
column name as it is stored in the database
+        * @return ResultSet - each row describes a stored procedure parameter 
or column
         * @throws SQLException if a database-access error occurs
         * @see #getSearchStringEscape
         */
@@ -1801,7 +1800,7 @@ public class MonetDatabaseMetaData exten
                String columnNamePattern
        ) throws SQLException {
                StringBuilder query = new StringBuilder(2900);
-               query.append("SELECT DISTINCT CAST(null as char(1)) AS 
\"PROCEDURE_CAT\", " +
+               query.append("SELECT cast(null as varchar(1)) AS 
\"PROCEDURE_CAT\", " +
                        "\"schemas\".\"name\" AS \"PROCEDURE_SCHEM\", " +
                        "\"functions\".\"name\" AS \"PROCEDURE_NAME\", " +
                        "\"args\".\"name\" AS \"COLUMN_NAME\", " +
@@ -1821,9 +1820,11 @@ public class MonetDatabaseMetaData exten
                        "CAST(0 as int) AS \"SQL_DATA_TYPE\", " +
                        "CAST(0 as int) AS \"SQL_DATETIME_SUB\", " +
                        "CAST(CASE WHEN \"args\".\"type\" IN 
('char','varchar','clob') THEN \"args\".\"type_digits\" ELSE NULL END as int) 
AS \"CHAR_OCTET_LENGTH\", " +
-                       "CAST(\"args\".\"number\" as int) AS 
\"ORDINAL_POSITION\", " +
+                       // in MonetDB procedures have no return value by 
design. The arguments in sys.args are numbered from 0 so we must add 1 to 
comply with the API specification.
+                       "CAST(\"args\".\"number\" + 1 as int) AS 
\"ORDINAL_POSITION\", " +
                        "CAST('' as varchar(3)) AS \"IS_NULLABLE\", " +
-                       "CAST(null as char(1)) AS \"SPECIFIC_NAME\" " +
+                       // the specific name contains the function id, in order 
to be able to match the args to the correct overloaded procedure name
+                       "cast(\"functions\".\"id\" as varchar(10)) AS 
\"SPECIFIC_NAME\" " +
                "FROM \"sys\".\"args\", \"sys\".\"functions\", 
\"sys\".\"schemas\" " +
                "WHERE \"args\".\"func_id\" = \"functions\".\"id\" " +
                "AND \"functions\".\"schema_id\" = \"schemas\".\"id\" " +
@@ -1844,7 +1845,7 @@ public class MonetDatabaseMetaData exten
                if (columnNamePattern != null) {
                        query.append(" AND \"args\".\"name\" 
").append(composeMatchPart(columnNamePattern));
                }
-               query.append(" ORDER BY \"PROCEDURE_SCHEM\", 
\"PROCEDURE_NAME\", \"ORDINAL_POSITION\"");
+               query.append(" ORDER BY \"PROCEDURE_SCHEM\", 
\"PROCEDURE_NAME\", \"SPECIFIC_NAME\", \"ORDINAL_POSITION\"");
 
                return executeMetaDataQuery(query.toString());
        }
@@ -1890,11 +1891,9 @@ public class MonetDatabaseMetaData exten
 
 
        /**
-        * Get a description of tables available in a catalog.
-        *
-        * <p>Only table descriptions matching the catalog, schema, table
-        * name and type criteria are returned. They are ordered by
-        * TABLE_TYPE, TABLE_CAT, TABLE_SCHEM and TABLE_NAME.
+        * Retrieves a description of the tables available in the given catalog.
+        * Only table descriptions matching the catalog, schema, table name and 
type criteria are returned.
+        * They are ordered by TABLE_TYPE, TABLE_CAT, TABLE_SCHEM and 
TABLE_NAME.
         *
         * <p>Each table description has the following columns:
         *
@@ -1909,14 +1908,20 @@ public class MonetDatabaseMetaData exten
         * <li><b>TYPE_SCHEM</b> String => the types schema (may be null)
         * <li><b>TYPE_NAME</b> String => type name (may be null)
         * <li><b>SELF_REFERENCING_COL_NAME</b> String => name of the 
designated "identifier" column of a typed table (may be null)
-        * <li><b>REF_GENERATION</b> String => specifies how values in 
SELF_REFERENCING_COL_NAME are created. Values are "SYSTEM", "USER", "DERIVED". 
(may be null) 
+        * <li><b>REF_GENERATION</b> String => specifies how values in 
SELF_REFERENCING_COL_NAME are created. Values are "SYSTEM", "USER", "DERIVED". 
(may be null)
         * </ol>
         *
-        * @param catalog a catalog name; this parameter is currently ignored
-        * @param schemaPattern a schema name pattern
-        * @param tableNamePattern a table name pattern. For all tables this 
should be "%"
-        * @param types a list of table types, which must be from the list of 
table types returned from getTableTypes(), to include; null returns all types;
-        * @return each row is a table description
+        * @param catalog - a catalog name; must match the catalog name as it 
is stored in the database;
+        *      "" retrieves those without a catalog; null means that the
+        *      catalog name should not be used to narrow the search
+        * @param schemaPattern - a schema name pattern; must match the schema 
name as it is stored
+        *      in the database; "" retrieves those without a schema;
+        *      null means that the schema name should not be used to narrow 
the search
+        * @param tableNamePattern - a table name pattern; must match the table 
name as it is stored in the database
+        *      For all tables this should be "%"
+        * @param types - a list of table types, which must be from the list of 
table types returned
+        *      from getTableTypes(),to include; null returns all types
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to