[PATCH 1/2] Support stored mysql procedures besides stored functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
---
 doc/ulogd.sgml |    4 ++++
 util/db.c      |    2 ++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/doc/ulogd.sgml b/doc/ulogd.sgml
index 547b56a..0f18611 100644
--- a/doc/ulogd.sgml
+++ b/doc/ulogd.sgml
@@ -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.
diff --git a/util/db.c b/util/db.c
index 8d812c7..54f8882 100644
--- 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);
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux