# HG changeset patch
# User Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
# Date 1530203583 -7200
# Node ID 55375d48902412c5f1abe794a6428756b29df9e8
# Parent  337a1292fe18ffc09bebf3a1e00e80627f1e30d2
Corrected return values of DatabaseMetaData methods allTablesAreSelectable() and allProceduresAreCallable().
They used to return true but now return false.
This issue is found when analysing bug 6617.

diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,39 +1,8 @@
 # ChangeLog file for monetdb-java
 # This file is updated with Maddlog
 
-* Wed May 23 2018 Sjoerd Mullender <sjoerd@acm.org>
-- Compiled and released new jars: monetdb-jdbc-2.28.jar, monetdb-mcl-1.17.jar
-  and updated jdbcclient.jar
-
-* Thu Apr 26 2018 Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
-- Corrected and extended output of DatabaseMetaData methods
-  getTimeDateFunctions() and getSystemFunctions().  The Date/Time functions
-  (curdate, current_date, current_time, current_timestamp, curtime,
-  local_timezone, localtime, localtimestamp) were returned by
-  getSystemFunctions() but are now returned by getTimeDateFunctions().
-  getTimeDateFunctions() now also lists functions: date_to_str, extract, now,
-  str_to_date, str_to_time, str_to_timestamp, time_to_str and timestamp_to_str.
-- Improved DatabaseMetaData methods getTablePrivileges() and
-  getColumnPrivileges() by returning also any combination of privileges
-  for the table or column in the PRIVILEGE result column. Previously only
-  single privileges (SELECT or UPDATE or INSERT or DELETE or EXECUTE or
-  GRANT) would be returned.
+* Thu Jun 28 2018 Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
+- Corrected return values of DatabaseMetaData methods
+  allTablesAreSelectable() and allProceduresAreCallable().
+  They used to return true but now return false.
 
-* Thu Apr 19 2018 Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
-- Corrected method DatabaseMetaData.getFunctions() for result column
-  FUNCTION_TYPE.  It used to return DatabaseMetaData.functionResultUnknown
-  value for Analytic (functions.type 6) and Loader function (functions type 7).
-  It now returns DatabaseMetaData.functionNoTable for Analytic functions and
-  DatabaseMetaData.functionReturnsTable for Loader functions.
-- DatabaseMetaData methods getTables(), getColumns(), getProcedures() and
-  getFunctions() now return the comment in the REMARKS result column when a
-  comment has been set for the table / view / column / procedure / function
-  via the SQL command COMMENT ON <db-object type> <qname> IS 'comment-text'.
-
-* Thu Dec 14 2017 Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
-- Fixed a problem with retrieving Dates and Timestamps which contained a
-  year value less than 1000. It would throw an SQLDataException with message:
-   Could not convert value to a Date. Expected JDBC date escape format
-   yyyy-[m]m-[d]d.
-  See also: https://www.monetdb.org/bugzilla/show_bug.cgi?id=6468
-
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java
@@ -107,25 +107,27 @@ public class MonetDatabaseMetaData exten
 	}
 
 	/**
-	 * Can all the procedures returned by getProcedures be called
-	 * by the current user?
+	 * Retrieves whether the current user can call all the procedures
+	 * returned by the method getProcedures.
 	 *
-	 * @return true if so
+	 * @return false because we currently return all procedures from sys.functions
+	 *    and do not filter on EXECUTE privilege or procedure ownership.
 	 */
 	@Override
 	public boolean allProceduresAreCallable() {
-		return true;
+		return false;
 	}
 
 	/**
-	 * Can all the tables returned by getTable be SELECTed by
-	 * the current user?
+	 * Retrieves whether the current user can use all the tables
+	 * returned by the method getTables in a SELECT statement.
 	 *
-	 * @return true because we only have one user a.t.m.
+	 * @return false because we currently return all tables from sys.tables
+	 *    and do not filter on SELECT privilege or table ownership.
 	 */
 	@Override
 	public boolean allTablesAreSelectable() {
-		return true;
+		return false;
 	}
 
 	/**
@@ -1698,6 +1700,7 @@ public class MonetDatabaseMetaData exten
 	 *	"" 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
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @return ResultSet - each row is a procedure description
 	 * @throws SQLException if a database access error occurs
 	 */
@@ -1807,7 +1810,9 @@ public class MonetDatabaseMetaData exten
 	 *	"" 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
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @param columnNamePattern - a column name pattern; must match the column name as it is stored in the database
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @return ResultSet - each row describes a stored procedure parameter or column
 	 * @throws SQLException if a database-access error occurs
 	 * @see #getSearchStringEscape
@@ -1877,7 +1882,7 @@ public class MonetDatabaseMetaData exten
 
 	/**
 	 * Returns a SQL match part string where depending on the input value we
-	 * compose an exact match (use =) or match with wildcards (use LIKE)
+	 * compose an exact match (use =) or match with wildcards (use LIKE) or IS NULL
 	 *
 	 * @param in the string to match
 	 * @return the SQL match part string
@@ -1941,6 +1946,7 @@ public class MonetDatabaseMetaData exten
 	 *	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 "%"
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @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 ResultSet - each row is a table description
@@ -2199,7 +2205,9 @@ public class MonetDatabaseMetaData exten
 	 *	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 "%"
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @param columnNamePattern - a column name pattern; must match the column name as it is stored in the database
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @return ResultSet - each row is a column description
 	 * @throws SQLException if a database error occurs
 	 * @see #getSearchStringEscape
@@ -2295,7 +2303,9 @@ public class MonetDatabaseMetaData exten
 	 * @param catalog a catalog name; "" retrieves those without a catalog
 	 * @param schemaPattern a schema name; "" retrieves those without a schema
 	 * @param tableNamePattern a table name
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @param columnNamePattern a column name pattern
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @return ResultSet each row is a column privilege description
 	 * @see #getSearchStringEscape
 	 * @throws SQLException if a database error occurs
@@ -2394,6 +2404,7 @@ public class MonetDatabaseMetaData exten
 	 * @param catalog a catalog name; "" retrieves those without a catalog
 	 * @param schemaPattern a schema name pattern; "" retrieves those without a schema
 	 * @param tableNamePattern a table name pattern
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @return ResultSet each row is a table privilege description
 	 * @see #getSearchStringEscape
 	 * @throws SQLException if a database error occurs
@@ -2491,6 +2502,7 @@ public class MonetDatabaseMetaData exten
 	 * @param catalog a catalog name; "" retrieves those without a catalog
 	 * @param schema a schema name; "" retrieves those without a schema
 	 * @param table a table name
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @param scope the scope of interest; use same values as SCOPE
 	 * @param nullable include columns that are nullable?
 	 * @return ResultSet each row is a column description
@@ -2577,6 +2589,7 @@ public class MonetDatabaseMetaData exten
 	 * @param catalog a catalog name; "" retrieves those without a catalog
 	 * @param schema a schema name; "" retrieves those without a schema
 	 * @param table a table name
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @return ResultSet each row is a column description
 	 * @throws SQLException if a database error occurs
 	 */
@@ -2617,9 +2630,9 @@ public class MonetDatabaseMetaData exten
 	 *	</OL>
 	 *
 	 * @param catalog a catalog name; "" retrieves those without a catalog
-	 * @param schema a schema name pattern; "" retrieves those
-	 * without a schema
+	 * @param schema a schema name pattern; "" retrieves those without a schema
 	 * @param table a table name
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @return ResultSet each row is a primary key column description
 	 * @throws SQLException if a database error occurs
 	 */
@@ -2754,6 +2767,7 @@ public class MonetDatabaseMetaData exten
 	 * @param catalog a catalog name; "" retrieves those without a catalog
 	 * @param schema a schema name pattern; "" retrieves those without a schema
 	 * @param table a table name
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @return ResultSet each row is a primary key column description
 	 * @see #getExportedKeys
 	 * @throws SQLException if a database error occurs
@@ -2838,6 +2852,7 @@ public class MonetDatabaseMetaData exten
 	 * @param catalog a catalog name; "" retrieves those without a catalog
 	 * @param schema a schema name pattern; "" retrieves those without a schema
 	 * @param table a table name
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @return ResultSet each row is a foreign key column description
 	 * @see #getImportedKeys
 	 * @throws SQLException if a database error occurs
@@ -2925,9 +2940,11 @@ public class MonetDatabaseMetaData exten
 	 * @param pcatalog primary key catalog name; "" retrieves those without a catalog
 	 * @param pschema primary key schema name pattern; "" retrieves those without a schema
 	 * @param ptable primary key table name
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @param fcatalog foreign key catalog name; "" retrieves those without a catalog
 	 * @param fschema foreign key schema name pattern; "" retrieves those without a schema
 	 * @param ftable koreign key table name
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @return ResultSet each row is a foreign key column description
 	 * @throws SQLException if a database error occurs
 	 * @see #getImportedKeys
@@ -3102,6 +3119,7 @@ public class MonetDatabaseMetaData exten
 	 * @param catalog a catalog name; "" retrieves those without a catalog
 	 * @param schema a schema name pattern; "" retrieves those without a schema
 	 * @param table a table name
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @param unique when true, return only indices for unique values;
 	 *	   when false, return indices regardless of whether unique or not
 	 * @param approximate when true, result is allowed to reflect approximate
@@ -3468,10 +3486,8 @@ public class MonetDatabaseMetaData exten
 	 *
 	 * @param catalog a catalog name; "" retrieves those without a catalog;
 	 *		  <code>null</code> means drop catalog name from the selection criteria
-	 * @param schemaPattern a schema name pattern; "" retrieves those
-	 *		  without a schema
-	 * @param typeNamePattern a UDT name pattern; may be a fully-qualified
-	 *		  name
+	 * @param schemaPattern a schema name pattern; "" retrieves those without a schema
+	 * @param typeNamePattern a UDT name pattern; may be a fully-qualified name
 	 * @return a <code>ResultSet</code> object in which a row gives information
 	 *		   about the designated UDT
 	 * @throws SQLException if a database access error occurs
@@ -3516,10 +3532,8 @@ public class MonetDatabaseMetaData exten
 	 *
 	 * @param catalog a catalog name; "" retrieves those without a catalog;
 	 *		  <code>null</code> means drop catalog name from the selection criteria
-	 * @param schemaPattern a schema name pattern; "" retrieves those
-	 *		  without a schema
-	 * @param tableNamePattern a table name pattern; may be a fully-qualified
-	 *		  name
+	 * @param schemaPattern a schema name pattern; "" retrieves those without a schema
+	 * @param tableNamePattern a table name pattern; may be a fully-qualified name
 	 * @return a <code>ResultSet</code> object in which each row is a type description
 	 * @throws SQLException if a database access error occurs
 	 */
@@ -3905,6 +3919,7 @@ public class MonetDatabaseMetaData exten
 	 *        not be used to narrow the search
 	 * @param functionNamePattern a function name pattern; must match
 	 *        the function name as it is stored in the database
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @return ResultSet - each row is a function description
 	 * @throws SQLException if a database access error occurs
 	 */
@@ -4008,8 +4023,10 @@ public class MonetDatabaseMetaData exten
 	 *        not be used to narrow the search
 	 * @param functionNamePattern a procedure name pattern; must match the
 	 *        function name as it is stored in the database
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @param columnNamePattern a parameter name pattern; must match the
 	 *        parameter or column name as it is stored in the database
+	 *   Note that our implementation allows this param to be null also (for efficiency as no extra LIKE "%" condition is added to be evaluated).
 	 * @return ResultSet - each row describes a user function parameter,
 	 *         column or return type
 	 * @throws SQLException - if a database access error occurs