You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2020/03/09 16:21:50 UTC

[GitHub] [netbeans] sbrbot opened a new pull request #2010: Mysqlprocs

sbrbot opened a new pull request #2010: Mysqlprocs
URL: https://github.com/apache/netbeans/pull/2010
 
 
   Changed the code inside NetBeans IDE module which was fetching mysql.proc table. The mysql.proc table does not exist in new MySQL databases any more and is replaced with several tables in INFORMATION_SCHEMA.
   
   This code was successfully tested on old MySQL 5.1.5 database from 2010. and the current version MySQL 8.0.19. It was successfully tested on Oracle 11g too.
   
   ![MySQL-procedures-in-NetBeans-11 3](https://user-images.githubusercontent.com/1915443/76234593-34128980-622a-11ea-8727-129a7bc16632.png)
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] matthiasblaesing commented on a change in pull request #2010: [NETBEANS-1603] MySQL Procedures in DB Explorer

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on a change in pull request #2010: [NETBEANS-1603] MySQL Procedures in DB Explorer
URL: https://github.com/apache/netbeans/pull/2010#discussion_r389876098
 
 

 ##########
 File path: ide/db/src/org/netbeans/modules/db/explorer/node/ProcedureNode.java
 ##########
 @@ -485,35 +493,36 @@ public String getBody() {
                     case Function:
                     case Procedure:
                         escapedName = getName().replace("'", "''");
-                        query = "SELECT body FROM mysql.proc WHERE name = '" + escapedName + "';"; // NOI18N
-                        try (Statement stat = connection.getJDBCConnection().createStatement();
-                                ResultSet rs = stat.executeQuery(query);) {
+                        query = "SELECT routine_definition" // NOI18N
+                              + " FROM information_schema.routines" // NOI18N
+                              + " WHERE routine_name='" + escapedName + "';"; // NOI18N
+                        try (Statement stat = connection.getJDBCConnection().createStatement(); ResultSet rs = stat.executeQuery(query);) {
                             while (rs.next()) {
-                                body = rs.getString("body"); // NOI18N
+                                body = rs.getString("routine_definition"); // NOI18N
                             }
                         }
                         break;
                     case Trigger:
                         escapedName = getName().replace("'", "''");
-                        query = "SELECT ACTION_STATEMENT FROM information_schema.triggers WHERE TRIGGER_NAME = '"  // NOI18N
-                                + escapedName + "';"; // NOI18N
-                        try (Statement stat = connection.getJDBCConnection().createStatement();
-                                ResultSet rs = stat.executeQuery(query)) {
+                        query = "SELECT action_statement" // NOI18N
+                              + " FROM information_schema.triggers" // NOI18N
+                              + " WHERE trigger_name='" + escapedName + "';"; // NOI18N
+                        try (Statement stat = connection.getJDBCConnection().createStatement(); ResultSet rs = stat.executeQuery(query)) {
 
 Review comment:
   Plase put these on two statements onto two lines.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] matthiasblaesing commented on a change in pull request #2010: [NETBEANS-1603] MySQL Procedures in DB Explorer

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on a change in pull request #2010: [NETBEANS-1603] MySQL Procedures in DB Explorer
URL: https://github.com/apache/netbeans/pull/2010#discussion_r389872870
 
 

 ##########
 File path: ide/db/src/org/netbeans/modules/db/explorer/node/ProcedureNode.java
 ##########
 @@ -336,39 +337,48 @@ public String getSource() {
             String source = "";
             try {
                 String query = "";
-                String escapedName = "";
+                String escapedName = getName().replace("'", "''");
                 boolean function = false;
                 switch (getType()) {
                     case Function:
                         function = true;
                     case Procedure:
-                        escapedName = getName().replace("'", "''");
-                        query = "SELECT param_list, returns, body, db FROM mysql.proc WHERE name = '"
-                                + escapedName + "';"; // NOI18N
-                        try (Statement stat = connection.getJDBCConnection().createStatement();
-                                ResultSet rs = stat.executeQuery(query);) {
+                        query = "SELECT routine_schema,routine_definition,dtd_identifier,is_deterministic,sql_data_access,routine_comment," // NOI18N
+                              + "(SELECT GROUP_CONCAT(CONCAT(" + (function ? "" : "parameter_mode,' ',") + "parameter_name,' ',dtd_identifier))" // NOI18N
+                              + " FROM information_schema.parameters" // NOI18N
+                              + " WHERE specific_name=routine_name AND ordinal_position>0) AS routine_params" // NOI18N
 
 Review comment:
   This subselect needs an order by, else the DB server is free to reorder.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] matthiasblaesing commented on a change in pull request #2010: [NETBEANS-1603] MySQL Procedures in DB Explorer

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on a change in pull request #2010: [NETBEANS-1603] MySQL Procedures in DB Explorer
URL: https://github.com/apache/netbeans/pull/2010#discussion_r389878620
 
 

 ##########
 File path: ide/db/src/org/netbeans/modules/db/explorer/node/ProcedureNodeProvider.java
 ##########
 @@ -202,8 +201,8 @@ public void run(Metadata metaData) {
                     NodeRegistry.handleMetadataModelException(this.getClass(), connection, e, true);
                 }
             }
-        } else if (connection != null && connection.getDriverName() != null &&
-                connection.getDriverName().startsWith(DatabaseModule.IDENTIFIER_ORACLE)) {
+        } else if (connection != null && connection.getDriverName() != null && connection.getDriverName().startsWith(DatabaseModule.IDENTIFIER_ORACLE)) {
 
 Review comment:
   This PR deals with MySQL and the changes below are cosmetical - please remove them.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] matthiasblaesing commented on a change in pull request #2010: [NETBEANS-1603] MySQL Procedures in DB Explorer

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on a change in pull request #2010: [NETBEANS-1603] MySQL Procedures in DB Explorer
URL: https://github.com/apache/netbeans/pull/2010#discussion_r389875446
 
 

 ##########
 File path: ide/db/src/org/netbeans/modules/db/explorer/node/ProcedureNode.java
 ##########
 @@ -429,40 +435,42 @@ public String getParams() {
             String escapedName = "";
             String query = "";
             try {
+                boolean function = false;
                 switch (getType()) {
                     case Function:
+                        function = true;
                     case Procedure:
                         escapedName = getName().replace("'", "''");
-                        query = "SELECT param_list FROM mysql.proc WHERE name = '" // NOI18N
-                                + escapedName + "';"; // NOI18N
-                        try (Statement stat = connection.getJDBCConnection().createStatement();
-                                ResultSet rs = stat.executeQuery(query);) {
+                        query = "SELECT GROUP_CONCAT(CONCAT(" + (function ? "" : "parameter_mode,' ',") + "parameter_name,' ',dtd_identifier)) AS routine_params" // NOI18N
+                              + " FROM information_schema.parameters" // NOI18N
+                              + " WHERE ordinal_position>0 AND specific_name='" + escapedName + "';"; // NOI18N
+                        try (Statement stat = connection.getJDBCConnection().createStatement(); ResultSet rs = stat.executeQuery(query);) {
 
 Review comment:
   Please place the two resources onto two rows.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] matthiasblaesing commented on a change in pull request #2010: [NETBEANS-1603] MySQL Procedures in DB Explorer

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on a change in pull request #2010: [NETBEANS-1603] MySQL Procedures in DB Explorer
URL: https://github.com/apache/netbeans/pull/2010#discussion_r391246264
 
 

 ##########
 File path: ide/db/src/org/netbeans/modules/db/explorer/node/ProcedureNode.java
 ##########
 @@ -336,39 +337,48 @@ public String getSource() {
             String source = "";
             try {
                 String query = "";
-                String escapedName = "";
+                String escapedName = getName().replace("'", "''");
                 boolean function = false;
                 switch (getType()) {
                     case Function:
                         function = true;
                     case Procedure:
-                        escapedName = getName().replace("'", "''");
-                        query = "SELECT param_list, returns, body, db FROM mysql.proc WHERE name = '"
-                                + escapedName + "';"; // NOI18N
-                        try (Statement stat = connection.getJDBCConnection().createStatement();
-                                ResultSet rs = stat.executeQuery(query);) {
+                        query = "SELECT routine_schema,routine_definition,dtd_identifier,is_deterministic,sql_data_access,routine_comment," // NOI18N
+                              + "(SELECT GROUP_CONCAT(CONCAT(" + (function ? "" : "parameter_mode,' ',") + "parameter_name,' ',dtd_identifier))" // NOI18N
+                              + " FROM information_schema.parameters" // NOI18N
+                              + " WHERE specific_name=routine_name AND ordinal_position>0) AS routine_params" // NOI18N
 
 Review comment:
   The ordering is needed for the subquery to `information_schema.parameters`. I suspect, that the DB server will always return parameters in the natural order, but if it is not guaranteed an order by will give the safety.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sbrbot commented on a change in pull request #2010: [NETBEANS-1603] MySQL Procedures in DB Explorer

Posted by GitBox <gi...@apache.org>.
sbrbot commented on a change in pull request #2010: [NETBEANS-1603] MySQL Procedures in DB Explorer
URL: https://github.com/apache/netbeans/pull/2010#discussion_r391180347
 
 

 ##########
 File path: ide/db/src/org/netbeans/modules/db/explorer/node/ProcedureNode.java
 ##########
 @@ -429,40 +435,42 @@ public String getParams() {
             String escapedName = "";
             String query = "";
             try {
+                boolean function = false;
                 switch (getType()) {
                     case Function:
+                        function = true;
                     case Procedure:
                         escapedName = getName().replace("'", "''");
-                        query = "SELECT param_list FROM mysql.proc WHERE name = '" // NOI18N
-                                + escapedName + "';"; // NOI18N
-                        try (Statement stat = connection.getJDBCConnection().createStatement();
-                                ResultSet rs = stat.executeQuery(query);) {
+                        query = "SELECT GROUP_CONCAT(CONCAT(" + (function ? "" : "parameter_mode,' ',") + "parameter_name,' ',dtd_identifier)) AS routine_params" // NOI18N
+                              + " FROM information_schema.parameters" // NOI18N
+                              + " WHERE ordinal_position>0 AND specific_name='" + escapedName + "';"; // NOI18N
 
 Review comment:
   No need for ordering here. The query retrieves only one routine.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] sbrbot commented on a change in pull request #2010: [NETBEANS-1603] MySQL Procedures in DB Explorer

Posted by GitBox <gi...@apache.org>.
sbrbot commented on a change in pull request #2010: [NETBEANS-1603] MySQL Procedures in DB Explorer
URL: https://github.com/apache/netbeans/pull/2010#discussion_r391180177
 
 

 ##########
 File path: ide/db/src/org/netbeans/modules/db/explorer/node/ProcedureNode.java
 ##########
 @@ -336,39 +337,48 @@ public String getSource() {
             String source = "";
             try {
                 String query = "";
-                String escapedName = "";
+                String escapedName = getName().replace("'", "''");
                 boolean function = false;
                 switch (getType()) {
                     case Function:
                         function = true;
                     case Procedure:
-                        escapedName = getName().replace("'", "''");
-                        query = "SELECT param_list, returns, body, db FROM mysql.proc WHERE name = '"
-                                + escapedName + "';"; // NOI18N
-                        try (Statement stat = connection.getJDBCConnection().createStatement();
-                                ResultSet rs = stat.executeQuery(query);) {
+                        query = "SELECT routine_schema,routine_definition,dtd_identifier,is_deterministic,sql_data_access,routine_comment," // NOI18N
+                              + "(SELECT GROUP_CONCAT(CONCAT(" + (function ? "" : "parameter_mode,' ',") + "parameter_name,' ',dtd_identifier))" // NOI18N
+                              + " FROM information_schema.parameters" // NOI18N
+                              + " WHERE specific_name=routine_name AND ordinal_position>0) AS routine_params" // NOI18N
 
 Review comment:
   No need for ordering here. The query retrieves only one routine.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] matthiasblaesing commented on a change in pull request #2010: [NETBEANS-1603] MySQL Procedures in DB Explorer

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on a change in pull request #2010: [NETBEANS-1603] MySQL Procedures in DB Explorer
URL: https://github.com/apache/netbeans/pull/2010#discussion_r389874971
 
 

 ##########
 File path: ide/db/src/org/netbeans/modules/db/explorer/node/ProcedureNode.java
 ##########
 @@ -429,40 +435,42 @@ public String getParams() {
             String escapedName = "";
             String query = "";
             try {
+                boolean function = false;
                 switch (getType()) {
                     case Function:
+                        function = true;
                     case Procedure:
                         escapedName = getName().replace("'", "''");
-                        query = "SELECT param_list FROM mysql.proc WHERE name = '" // NOI18N
-                                + escapedName + "';"; // NOI18N
-                        try (Statement stat = connection.getJDBCConnection().createStatement();
-                                ResultSet rs = stat.executeQuery(query);) {
+                        query = "SELECT GROUP_CONCAT(CONCAT(" + (function ? "" : "parameter_mode,' ',") + "parameter_name,' ',dtd_identifier)) AS routine_params" // NOI18N
+                              + " FROM information_schema.parameters" // NOI18N
+                              + " WHERE ordinal_position>0 AND specific_name='" + escapedName + "';"; // NOI18N
 
 Review comment:
   This needs an order by.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists