]> git.ipfire.org Git - thirdparty/ulogd2.git/commitdiff
DB plugin: add capability to specify complete INSERT command
authorEric Leblond <eric@inl.fr>
Thu, 16 Apr 2009 08:21:49 +0000 (10:21 +0200)
committerEric Leblond <eric@inl.fr>
Fri, 17 Apr 2009 05:38:59 +0000 (07:38 +0200)
This patch modifies the procedure name parsing to be able to specify a
complete INSERT command.

util/db.c

index fee91b2df92bf6067ec061509d1d7cdf9c00d0de..c2b674e236a18467af98771ac41126508fc9d1ff 100644 (file)
--- a/util/db.c
+++ b/util/db.c
@@ -91,14 +91,19 @@ static int sql_createstmt(struct ulogd_pluginstance *upi)
                return -ENOMEM;
        }
 
-       if (strcasecmp(procedure,"INSERT") == 0) {
-               char buf[ULOGD_MAX_KEYLEN];
-               char *underscore;
+       if (strncasecmp(procedure, "INSERT INTO", strlen("INSERT INTO")) == 0)
+               sprintf(mi->stmt, "%s (", procedure);
 
+       if (strcasecmp(procedure,"INSERT") == 0) {
                if (mi->schema)
                        sprintf(mi->stmt, "insert into %s.%s (", mi->schema, table);
                else
                        sprintf(mi->stmt, "insert into %s (", table);
+       }
+
+       if (strncasecmp(procedure,"INSERT", strlen("INSERT")) == 0) {
+               char buf[ULOGD_MAX_KEYLEN];
+               char *underscore;
                mi->stmt_val = mi->stmt + strlen(mi->stmt);
 
                for (i = 0; i < upi->input.num_keys; i++) {