3
votes

I am using MySQL 5.6.11 running on 32-bit Microsoft Windows XP (Professional Version 2002 Service Pack 3). I installed the MySQL sys_exec UDF. Since I am running on 32-bit Windows, I used this lib_mysqludf_sys.dll (placed under C:\Program Files\MySQL\MySQL Server 5.6\lib\plugin\ as it is the default installation).

Afterwards, the following command was executed (after logging in into an already created database).

mysql> CREATE FUNCTION sys_exec RETURNS INT SONAME 'lib_mysqludf_sys.dll';
Query OK, 0 rows affected (0.02 sec)

I had already created a PL/SQL stored procedure as follows.

DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `country_push`()
BEGIN 
    SET @result=sys_exec('curl http://localhost:8080/ContextPath/push-update-country'); 
END

This procedure is supposed to be invoked by database triggers (which is adequately done) and accordingly, it should raise an HTTP GET request on the said URL but no HTTP GET request is raised on the URL, when this stored procedure is executed by a trigger on a certain event.


Manually executing the procedure on the command line succeeds as well, as follows.

mysql> CALL country_push();
Query OK, 0 rows affected (0.08 sec)

The sys_exec() function returns 1 as follows which is a success flag.

mysql> SELECT sys_exec('curl http://localhost:8080/ContextPath/push-update-country')
AS result;
+--------+
| result |
+--------+
|      1 |
+--------+
1 row in set (0.06 sec)

There is already a Java Servlet running on GlassFish (4.1) application server which is supposed to listen to this HTTP GET request as follows.

@WebServlet(name = "PushCountry", urlPatterns = {"/push-update-country"})
public class PushCountry extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("PushCountry called.");
    }
}

The line System.out.println("PushCountry called."); in the doGet() method produces nothing on the server terminal (because it is not executed/invoked), when the above-mentioned MySQL stuff is put into practice.

Is it not practical to do this using MySQL, is there something else I might be missing or is it the old EOL dinosaur : Windows XP?


The shared Dynamic Link Library I am using might not be suitable. Please clarify, if such is a case as this is beyond me.


EDIT:

When entering,

mysql> SELECT sys_eval('id');

MySQL terminates/crashes with the following error report.

enter image description here

On closing this dialog, MySQL leaves the following error message.

ERROR 2013 (HY000): Lost connection to MySQL server during query

It fails to reconnect until/unless the system itself is restarted.

Perhaps, I will think of reinstalling the operating system itself later on.

1
The sys_exec() function returns 1 as follows which is a success flag. Are you sure about that? The return value appears to be the exit status of the process, and anything non-zero means error -- not success. What do you get as a response if you use the sys_eval() function? Maybe a useful error message?Michael - sqlbot
There is an error in response to SELECT sys_eval('id');. A popup appears all of a sudden indicating : mysqld.exe has encountered a problem and needs to close. We are sorry for the inconvenience. When closing this dialog, this message ERROR 2013 (HY000): Lost connection to MySQL server during query prompts on the command line. MySQL stops working forever then onwards until the system itself is restarted.Tiny
Yikes, server crash... well, that's not exactly the kind of error message I had in mind.Michael - sqlbot

1 Answers

0
votes

seems that 'id' is a Linux command not existing under Windows... anyway i also get trouble with sys_exec() under windows that return a number but no process is launched. For info it works well under linux.