Changeset: f16966084980 for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java/rev/f16966084980
Modified Files:
        ChangeLog
        src/main/java/org/monetdb/util/MDBvalidator.java
        tests/JDBC_API_Tester.java
Branch: default
Log Message:

In JdbcClient when running the \vsci or \vdbi or \vsi commands, we now suppress 
"42000 SELECT: insufficient privileges for ..." and "42000 SELECT: access 
denied for ..." error messages when the connected user does not have 'monetdb' 
or 'sysadmin' privileges, needed for some validations.


diffs (58 lines):

diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
 # ChangeLog file for monetdb-java
 # This file is updated with Maddlog
 
+* Thu Nov  7 2024 Martin van Dinther <martin.van.dint...@monetdbsolutions.com>
+- In JdbcClient when running the \vsci or \vdbi or \vsi commands, we now
+  suppress "42000 SELECT: insufficient privileges for ..." and
+  "42000 SELECT: access denied for ..." error messages when the connected user
+  does not have 'monetdb' or 'sysadmin' privileges, needed for some 
validations.
+
 * Wed Jun 19 2024 Joeri van Ruth <joeri.van.r...@monetdbsolutions.com>
 - Implemented Connection#set/getClientInfo, and send sensible default info
   at connect time. This can be controlled with the properties 
'client_info=on/off',
diff --git a/src/main/java/org/monetdb/util/MDBvalidator.java 
b/src/main/java/org/monetdb/util/MDBvalidator.java
--- a/src/main/java/org/monetdb/util/MDBvalidator.java
+++ b/src/main/java/org/monetdb/util/MDBvalidator.java
@@ -757,8 +757,25 @@ public final class MDBvalidator {
                                }
                        }
                } catch (SQLException e) {
-                       System.err.println("Failed to execute query: " + qry);
-                       printExceptions(e);
+                       // When the connected user does not have enough select 
privileges,
+                       // we may get following error messages, both with 
SQLState "42000":
+                       // "SELECT: access denied for ..." or
+                       // "SELECT: insufficient privileges for table returning 
function ..."
+                       // Suppress them from the violation output report.
+                       String state = e.getSQLState();
+                       boolean suppress = "42000".equals(state);
+                       if (suppress) {
+                               String msg = e.getMessage();
+                               // System.err.println("SQLState: " + state + " 
msg: " + msg);
+                               if (msg != null) {
+                                       suppress = msg.startsWith("SELECT: 
access denied for")
+                                               || msg.startsWith("SELECT: 
insufficient privileges for");
+                               }
+                       }
+                       if (!suppress) {
+                               System.err.println("Failed to execute query: " 
+ qry);
+                               printExceptions(e);
+                       }
                }
                freeStmtRs(stmt, rs);
        }
diff --git a/tests/JDBC_API_Tester.java b/tests/JDBC_API_Tester.java
--- a/tests/JDBC_API_Tester.java
+++ b/tests/JDBC_API_Tester.java
@@ -773,7 +773,6 @@ public final class JDBC_API_Tester {
                        "3  cert  true  null  path to TLS certificate to 
authenticate server with\n");
        }
 
-
        private void handleExecuteDDL(Statement stmt, String action, String 
objtype, String objname, String sql) {
                try {
                        int response = stmt.executeUpdate(sql);
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to