]> git.ipfire.org Git - thirdparty/ulogd2.git/commitdiff
Support stored mysql procedures besides stored functions
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Sun, 15 Jan 2012 12:16:01 +0000 (13:16 +0100)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Mon, 16 Jan 2012 15:56:17 +0000 (16:56 +0100)
MySQL stored procedures must be invoked by the "CALL" SQL command and
not by "SELECT". Add the convention that if the procedure name starts
with "CALL", then the issued SQL command is "CALL procedurename(args)".

The stored procedure support in MySQL automatically brings transaction
support too.

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
doc/ulogd.sgml
util/db.c

index 547b56af039081b08a79b2178d531ee662006b5b..0f18611520a13a53e2a820637936f2b992416752 100644 (file)
@@ -471,6 +471,10 @@ If procedure name is:
   "table" variable.</item>
 <item>start with "INSERT ": Configuration has to specify the start of the INSERT query that will be used. For example,
 a typical value is "INSERT INTO ulog2".</item>
+<item>start with "CALL": the named stored procedure is executed with
+the "CALL" MySQL command.</item>
+<item>Otherwise the named stored function is executed with
+the "SELECT" MySQL command.</item> 
 </itemize>
 <tag>db</tag>
 Name of the mysql database.
index 8d812c71d3a9443432f45bb1ba59aa7944a5bf36..54f888221d3c5e4f64f08ebf2fdad8342f32e2be 100644 (file)
--- a/util/db.c
+++ b/util/db.c
@@ -122,6 +122,8 @@ static int sql_createstmt(struct ulogd_pluginstance *upi)
                *(mi->stmt_val - 1) = ')';
 
                sprintf(mi->stmt_val, " values (");
+       } else if (strncasecmp(procedure,"CALL", strlen("CALL")) == 0) {
+               sprintf(mi->stmt, "CALL %s(", procedure);
        } else {
                sprintf(mi->stmt, "SELECT %s(", procedure);